diff --git a/.babelrc-deno.json b/.babelrc-deno.json deleted file mode 100644 index 0e173bfb4e..0000000000 --- a/.babelrc-deno.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "plugins": [ - "@babel/plugin-syntax-typescript", - ["./resources/add-extension-to-import-paths", { "extension": "ts" }], - "./resources/inline-invariant" - ] -} diff --git a/.babelrc-npm.json b/.babelrc-npm.json deleted file mode 100644 index 357c91dbc0..0000000000 --- a/.babelrc-npm.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "plugins": [ - "@babel/plugin-transform-typescript", - "./resources/inline-invariant" - ], - "env": { - "cjs": { - "presets": [ - [ - "@babel/preset-env", - { "modules": "commonjs", "targets": { "node": "12" } } - ] - ], - "plugins": [ - ["./resources/add-extension-to-import-paths", { "extension": "js" }] - ] - }, - "mjs": { - "presets": [ - ["@babel/preset-env", { "modules": false, "targets": { "node": "12" } }] - ], - "plugins": [ - ["./resources/add-extension-to-import-paths", { "extension": "mjs" }] - ] - } - } -} diff --git a/.babelrc.json b/.babelrc.json deleted file mode 100644 index caa5300ad7..0000000000 --- a/.babelrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": ["@babel/plugin-transform-typescript"], - "presets": [ - [ - "@babel/preset-env", - { "bugfixes": true, "targets": { "node": "current" } } - ] - ] -} diff --git a/.c8rc.json b/.c8rc.json deleted file mode 100644 index fdd5bb2de9..0000000000 --- a/.c8rc.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "all": true, - "include": ["src/"], - "exclude": [ - "src/**/index.ts", - "src/**/*-fuzz.ts", - "src/jsutils/Maybe.ts", - "src/jsutils/ObjMap.ts", - "src/jsutils/PromiseOrValue.ts", - "src/utilities/assertValidName.ts", - "src/utilities/typedQueryDocumentNode.ts", - "src/**/__tests__/**/*.ts" - ], - "clean": true, - "temp-directory": "coverage", - "report-dir": "coverage", - "skip-full": true, - "reporter": ["json", "html", "text"], - "check-coverage": true, - "branches": 100, - "lines": 100, - "functions": 100, - "statements": 100 -} diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 74aca39c9d..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,11 +0,0 @@ -# Copied from '.gitignore', please keep it in sync. -/.eslintcache -/node_modules -/coverage -/npmDist -/denoDist -/websiteDist -/website - -# Ignore TS files inside integration test -/integrationTests/ts/*.ts diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index b548dcad93..0000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,730 +0,0 @@ -parserOptions: - sourceType: script -env: - es2022: true -reportUnusedDisableDirectives: true -plugins: - - internal-rules - - node - - import - - simple-import-sort -settings: - node: - tryExtensions: ['.js', '.jsx', '.json', '.node', '.ts', '.d.ts'] - -rules: - ############################################################################## - # Internal rules located in 'resources/eslint-internal-rules'. - # See './resources/eslint-internal-rules/README.md' - ############################################################################## - - internal-rules/only-ascii: error - internal-rules/no-dir-import: error - internal-rules/require-to-string-tag: off - - ############################################################################## - # `eslint-plugin-node` rule list based on `v11.1.x` - ############################################################################## - - # Possible Errors - # https://github.com/mysticatea/eslint-plugin-node#possible-errors - - node/handle-callback-err: [error, error] - node/no-callback-literal: error - node/no-exports-assign: error - node/no-extraneous-import: error - node/no-extraneous-require: error - node/no-missing-import: error - node/no-missing-require: error - node/no-new-require: error - node/no-path-concat: error - node/no-process-exit: off - node/no-unpublished-bin: error - node/no-unpublished-import: error - node/no-unpublished-require: error - node/no-unsupported-features/es-builtins: error - node/no-unsupported-features/es-syntax: [error, { ignores: [modules] }] - node/no-unsupported-features/node-builtins: error - node/process-exit-as-throw: error - node/shebang: error - - # Best Practices - # https://github.com/mysticatea/eslint-plugin-node#best-practices - node/no-deprecated-api: error - - # Stylistic Issues - # https://github.com/mysticatea/eslint-plugin-node#stylistic-issues - - node/callback-return: error - node/exports-style: off # TODO consider - node/file-extension-in-import: off # TODO consider - node/global-require: error - node/no-mixed-requires: error - node/no-process-env: off - node/no-restricted-import: off - node/no-restricted-require: off - node/no-sync: error - node/prefer-global/buffer: error - node/prefer-global/console: error - node/prefer-global/process: error - node/prefer-global/text-decoder: error - node/prefer-global/text-encoder: error - node/prefer-global/url-search-params: error - node/prefer-global/url: error - node/prefer-promises/dns: off - node/prefer-promises/fs: off - - ############################################################################## - # `eslint-plugin-import` rule list based on `v2.26.x` - ############################################################################## - - # Static analysis - # https://github.com/benmosher/eslint-plugin-import#static-analysis - import/no-unresolved: error - import/named: error - import/default: error - import/namespace: error - import/no-restricted-paths: - - error - - basePath: './' - zones: - - { target: './src', from: 'src/__testUtils__' } - import/no-absolute-path: error - import/no-dynamic-require: error - import/no-internal-modules: off - import/no-webpack-loader-syntax: error - import/no-self-import: error - import/no-cycle: error - import/no-useless-path-segments: error - import/no-relative-parent-imports: off - import/no-relative-packages: off - - # Helpful warnings - # https://github.com/benmosher/eslint-plugin-import#helpful-warnings - import/export: error - import/no-named-as-default: error - import/no-named-as-default-member: error - import/no-deprecated: error - import/no-extraneous-dependencies: [error, { devDependencies: false }] - import/no-mutable-exports: error - import/no-unused-modules: error - - # Module systems - # https://github.com/benmosher/eslint-plugin-import#module-systems - import/unambiguous: error - import/no-commonjs: error - import/no-amd: error - import/no-nodejs-modules: error - import/no-import-module-exports: off - - # Style guide - # https://github.com/benmosher/eslint-plugin-import#style-guide - import/first: error - import/exports-last: off - import/no-duplicates: error - import/no-namespace: error - import/extensions: - - error - - ignorePackages - - ts: never # TODO: remove once TS supports extensions - import/order: [error, { newlines-between: always-and-inside-groups }] - import/newline-after-import: error - import/prefer-default-export: off - import/max-dependencies: off - import/no-unassigned-import: error - import/no-named-default: error - import/no-default-export: error - import/no-named-export: off - import/no-anonymous-default-export: error - import/group-exports: off - import/dynamic-import-chunkname: off - - ############################################################################## - # `eslint-plugin-simple-import-sort` rule list based on `v2.25.x` - # https://github.com/lydell/eslint-plugin-simple-import-sort - ############################################################################## - simple-import-sort/imports: - - error - - groups: - # Packages. - # Things that start with a letter (or digit or underscore), or `@` followed by a letter. - - ["^@?\\w"] - - # General utilities - - ["^(\\./|(\\.\\./)+)__testUtils__/"] - - ["^(\\./|(\\.\\./)+)jsutils/"] - - # Top-level directories - - ["^(\\./|(\\.\\./)+)error/"] - - ["^(\\./|(\\.\\./)+)language/"] - - ["^(\\./|(\\.\\./)+)type/"] - - ["^(\\./|(\\.\\./)+)validation/"] - - ["^(\\./|(\\.\\./)+)execution/"] - - ["^(\\./|(\\.\\./)+)utilities/"] - - # Relative imports. - # Anything that starts with a dot. - - ["^(\\.\\./){4,}"] - - ["^(\\.\\./){3}"] - - ["^(\\.\\./){2}"] - - ["^(\\.\\./){1}"] - - ["^\\./"] - simple-import-sort/exports: off # TODO - - ############################################################################## - # ESLint builtin rules list based on `v8.13.x` - ############################################################################## - - # Possible Errors - # https://eslint.org/docs/rules/#possible-errors - - for-direction: error - getter-return: error - no-async-promise-executor: error - no-await-in-loop: error - no-compare-neg-zero: error - no-cond-assign: error - no-console: warn - no-constant-condition: error - no-control-regex: error - no-debugger: warn - no-dupe-args: error - no-dupe-else-if: error - no-dupe-keys: error - no-duplicate-case: error - no-empty: error - no-empty-character-class: error - no-ex-assign: error - no-extra-boolean-cast: error - no-func-assign: error - no-import-assign: error - no-inner-declarations: [error, both] - no-invalid-regexp: error - no-irregular-whitespace: error - no-loss-of-precision: error - no-misleading-character-class: error - no-obj-calls: error - no-promise-executor-return: off # TODO - no-prototype-builtins: error - no-regex-spaces: error - no-setter-return: error - no-sparse-arrays: error - no-template-curly-in-string: error - no-unreachable: error - no-unreachable-loop: error - no-unsafe-finally: error - no-unsafe-negation: error - no-unsafe-optional-chaining: [error, { disallowArithmeticOperators: true }] - no-unused-private-class-members: error - no-useless-backreference: error - require-atomic-updates: error - use-isnan: error - valid-typeof: error - - # Best Practices - # https://eslint.org/docs/rules/#best-practices - - accessor-pairs: error - array-callback-return: error - block-scoped-var: error - class-methods-use-this: off - complexity: off - consistent-return: off - curly: error - default-case: off - default-case-last: error - default-param-last: error - dot-notation: error - eqeqeq: [error, smart] - grouped-accessor-pairs: error - guard-for-in: error - max-classes-per-file: off - no-alert: error - no-caller: error - no-case-declarations: error - no-constructor-return: error - no-div-regex: error - no-else-return: error - no-empty-function: error - no-empty-pattern: error - no-eq-null: off - no-eval: error - no-extend-native: error - no-extra-bind: error - no-extra-label: error - no-fallthrough: error - no-global-assign: error - no-implicit-coercion: error - no-implicit-globals: off - no-implied-eval: error - no-invalid-this: error - no-iterator: error - no-labels: error - no-lone-blocks: error - no-loop-func: error - no-magic-numbers: off - no-multi-str: error - no-new: error - no-new-func: error - no-new-wrappers: error - no-nonoctal-decimal-escape: error - no-octal: error - no-octal-escape: error - no-param-reassign: error - no-proto: error - no-redeclare: error - no-restricted-properties: off - no-return-assign: error - no-return-await: error - no-script-url: error - no-self-assign: error - no-self-compare: off # TODO - no-sequences: error - no-throw-literal: error - no-unmodified-loop-condition: error - no-unused-expressions: error - no-unused-labels: error - no-useless-call: error - no-useless-catch: error - no-useless-concat: error - no-useless-escape: error - no-useless-return: error - no-void: error - no-warning-comments: off - no-with: error - prefer-named-capture-group: off # ES2018 - prefer-promise-reject-errors: error - prefer-regex-literals: error - radix: error - require-await: error - require-unicode-regexp: off - vars-on-top: error - yoda: [error, never, { exceptRange: true }] - - # Strict Mode - # https://eslint.org/docs/rules/#strict-mode - - strict: error - - # Variables - # https://eslint.org/docs/rules/#variables - - init-declarations: off - no-delete-var: error - no-label-var: error - no-restricted-globals: off - no-shadow: error - no-shadow-restricted-names: error - no-undef: error - no-undef-init: error - no-undefined: off - no-unused-vars: [error, { vars: all, args: all, argsIgnorePattern: '^_' }] - no-use-before-define: off - - # Stylistic Issues - # https://eslint.org/docs/rules/#stylistic-issues - - camelcase: error - capitalized-comments: off # maybe - consistent-this: off - func-name-matching: off - func-names: [error, as-needed] # improve debug experience - func-style: off - id-denylist: off - id-length: off - id-match: [error, '^(?:_?[a-zA-Z0-9]*)|[_A-Z0-9]+$'] - line-comment-position: off - lines-around-comment: off - lines-between-class-members: [error, always, { exceptAfterSingleLine: true }] - max-depth: off - max-lines: off - max-lines-per-function: off - max-nested-callbacks: off - max-params: off - max-statements: off - max-statements-per-line: off - multiline-comment-style: off - new-cap: error - no-array-constructor: error - no-bitwise: off - no-continue: off - no-inline-comments: off - no-lonely-if: error - no-multi-assign: off - no-negated-condition: off - no-nested-ternary: off - no-new-object: error - no-plusplus: off - no-restricted-syntax: off - no-tabs: error - no-ternary: off - no-underscore-dangle: off # TODO - no-unneeded-ternary: error - one-var: [error, never] - operator-assignment: error - padding-line-between-statements: off - prefer-exponentiation-operator: error - prefer-object-spread: error - quotes: [error, single, { avoidEscape: true }] - sort-keys: off - sort-vars: off - spaced-comment: error - - # ECMAScript 6 - # https://eslint.org/docs/rules/#ecmascript-6 - - arrow-body-style: error - constructor-super: error - no-class-assign: error - no-const-assign: error - no-dupe-class-members: error - no-duplicate-imports: off # Superseded by `import/no-duplicates` - no-new-symbol: error - no-restricted-exports: off - no-restricted-imports: off - no-this-before-super: error - no-useless-computed-key: error - no-useless-constructor: error - no-useless-rename: error - no-var: error - object-shorthand: error - prefer-arrow-callback: error - prefer-const: error - prefer-destructuring: off - prefer-numeric-literals: error - prefer-object-has-own: off # TODO requires Node.js v16.9.0 - prefer-rest-params: off # TODO - prefer-spread: error - prefer-template: off - require-yield: error - sort-imports: off - symbol-description: off - - # Bellow rules are disabled because coflicts with Prettier, see: - # https://github.com/prettier/eslint-config-prettier/blob/master/index.js - array-bracket-newline: off - array-bracket-spacing: off - array-element-newline: off - arrow-parens: off - arrow-spacing: off - block-spacing: off - brace-style: off - comma-dangle: off - comma-spacing: off - comma-style: off - computed-property-spacing: off - dot-location: off - eol-last: off - func-call-spacing: off - function-call-argument-newline: off - function-paren-newline: off - generator-star-spacing: off - implicit-arrow-linebreak: off - indent: off - jsx-quotes: off - key-spacing: off - keyword-spacing: off - linebreak-style: off - max-len: off - multiline-ternary: off - newline-per-chained-call: off - new-parens: off - no-confusing-arrow: off - no-extra-parens: off - no-extra-semi: off - no-floating-decimal: off - no-mixed-operators: off - no-mixed-spaces-and-tabs: off - no-multi-spaces: off - no-multiple-empty-lines: off - no-trailing-spaces: off - no-unexpected-multiline: off - no-whitespace-before-property: off - nonblock-statement-body-position: off - object-curly-newline: off - object-curly-spacing: off - object-property-newline: off - one-var-declaration-per-line: off - operator-linebreak: off - padded-blocks: off - quote-props: off - rest-spread-spacing: off - semi: off - semi-spacing: off - semi-style: off - space-before-blocks: off - space-before-function-paren: off - space-in-parens: off - space-infix-ops: off - space-unary-ops: off - switch-colon-spacing: off - template-curly-spacing: off - template-tag-spacing: off - unicode-bom: off - wrap-iife: off - wrap-regex: off - yield-star-spacing: off - -overrides: - - files: - - '**/*.ts' - - '**/*.tsx' - parser: '@typescript-eslint/parser' - parserOptions: - sourceType: module - project: ['./tsconfig.json', './website/tsconfig.json'] - plugins: - - '@typescript-eslint' - - 'eslint-plugin-tsdoc' - extends: - - plugin:import/typescript - rules: - ########################################################################## - # `eslint-plugin-tsdoc` rule list based on `v0.2.x` - # https://github.com/microsoft/tsdoc/tree/master/eslint-plugin - ########################################################################## - - tsdoc/syntax: error - - ########################################################################## - # `@typescript-eslint/eslint-plugin` rule list based on `v5.19.x` - ########################################################################## - - # Supported Rules - # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules - '@typescript-eslint/adjacent-overload-signatures': error - '@typescript-eslint/array-type': [error, { default: generic }] - '@typescript-eslint/await-thenable': error - '@typescript-eslint/ban-ts-comment': [error, { 'ts-expect-error': false }] - '@typescript-eslint/ban-tslint-comment': error - '@typescript-eslint/ban-types': off # TODO temporarily disabled - '@typescript-eslint/class-literal-property-style': off # TODO enable after TS conversion - '@typescript-eslint/consistent-indexed-object-style': - [error, index-signature] - '@typescript-eslint/consistent-type-assertions': off # TODO temporarily disable - '@typescript-eslint/consistent-type-definitions': error - '@typescript-eslint/consistent-type-exports': error - '@typescript-eslint/consistent-type-imports': error - '@typescript-eslint/explicit-function-return-type': off # TODO consider - '@typescript-eslint/explicit-member-accessibility': off # TODO consider - '@typescript-eslint/explicit-module-boundary-types': off # TODO consider - '@typescript-eslint/member-ordering': error - '@typescript-eslint/method-signature-style': error - '@typescript-eslint/naming-convention': off # TODO consider - '@typescript-eslint/no-base-to-string': error - '@typescript-eslint/no-confusing-non-null-assertion': error - '@typescript-eslint/no-confusing-void-expression': off # TODO enable with ignoreArrowShorthand - '@typescript-eslint/no-dynamic-delete': off - '@typescript-eslint/no-empty-interface': error - '@typescript-eslint/no-explicit-any': off # TODO error - '@typescript-eslint/no-extra-non-null-assertion': error - '@typescript-eslint/no-extraneous-class': off # TODO consider - '@typescript-eslint/no-floating-promises': error - '@typescript-eslint/no-for-in-array': error - '@typescript-eslint/no-implicit-any-catch': off # TODO: Enable after TS conversion - '@typescript-eslint/no-implied-eval': error - '@typescript-eslint/no-inferrable-types': - [error, { ignoreParameters: true, ignoreProperties: true }] - '@typescript-eslint/no-misused-new': error - '@typescript-eslint/no-misused-promises': error - '@typescript-eslint/no-namespace': error - '@typescript-eslint/no-non-null-asserted-nullish-coalescing': error - '@typescript-eslint/no-non-null-asserted-optional-chain': error - '@typescript-eslint/no-non-null-assertion': error - '@typescript-eslint/no-parameter-properties': error - '@typescript-eslint/no-redundant-type-constituents': error - '@typescript-eslint/no-invalid-void-type': error - '@typescript-eslint/no-require-imports': error - '@typescript-eslint/no-this-alias': error - '@typescript-eslint/no-type-alias': off # TODO consider - '@typescript-eslint/no-unnecessary-boolean-literal-compare': error - '@typescript-eslint/no-unnecessary-condition': off # TODO temporary disable - '@typescript-eslint/no-unnecessary-qualifier': error - '@typescript-eslint/no-unnecessary-type-arguments': error - '@typescript-eslint/no-unnecessary-type-assertion': error - '@typescript-eslint/no-unnecessary-type-constraint': error - '@typescript-eslint/no-unsafe-argument': off # TODO consider - '@typescript-eslint/no-unsafe-assignment': off # TODO consider - '@typescript-eslint/no-unsafe-call': off # TODO consider - '@typescript-eslint/no-unsafe-member-access': off # TODO consider - '@typescript-eslint/no-unsafe-return': off # TODO consider - '@typescript-eslint/no-useless-empty-export': error - '@typescript-eslint/no-var-requires': error - '@typescript-eslint/non-nullable-type-assertion-style': off #TODO temporarily disabled - '@typescript-eslint/prefer-as-const': error - '@typescript-eslint/prefer-enum-initializers': error - '@typescript-eslint/prefer-for-of': error - '@typescript-eslint/prefer-function-type': error - '@typescript-eslint/prefer-includes': error - '@typescript-eslint/prefer-literal-enum-member': error - '@typescript-eslint/prefer-namespace-keyword': error - '@typescript-eslint/prefer-nullish-coalescing': error - '@typescript-eslint/prefer-optional-chain': error - '@typescript-eslint/prefer-readonly': off - '@typescript-eslint/prefer-readonly-parameter-types': off # TODO consider - '@typescript-eslint/prefer-reduce-type-parameter': error - '@typescript-eslint/prefer-regexp-exec': off - '@typescript-eslint/prefer-return-this-type': error - '@typescript-eslint/prefer-string-starts-ends-with': error - '@typescript-eslint/prefer-ts-expect-error': error - '@typescript-eslint/promise-function-async': off - '@typescript-eslint/require-array-sort-compare': error - '@typescript-eslint/restrict-plus-operands': off #TODO temporarily disabled - '@typescript-eslint/restrict-template-expressions': off #TODO temporarily disabled - '@typescript-eslint/sort-type-union-intersection-members': off # TODO consider - '@typescript-eslint/strict-boolean-expressions': off # TODO consider - '@typescript-eslint/switch-exhaustiveness-check': error - '@typescript-eslint/triple-slash-reference': error - '@typescript-eslint/typedef': off - '@typescript-eslint/unbound-method': off # TODO consider - '@typescript-eslint/unified-signatures': error - - # Extension Rules - # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#extension-rules - - # Disable conflicting ESLint rules and enable TS-compatible ones - default-param-last: off - dot-notation: off - lines-between-class-members: off - no-array-constructor: off - no-dupe-class-members: off - no-empty-function: off - no-invalid-this: off - no-loop-func: off - no-loss-of-precision: off - no-redeclare: off - no-throw-literal: off - no-shadow: off - no-unused-expressions: off - no-unused-vars: off - no-useless-constructor: off - require-await: off - no-return-await: off - '@typescript-eslint/default-param-last': error - '@typescript-eslint/dot-notation': error - '@typescript-eslint/lines-between-class-members': - [error, always, { exceptAfterSingleLine: true }] - '@typescript-eslint/no-array-constructor': error - '@typescript-eslint/no-dupe-class-members': error - '@typescript-eslint/no-empty-function': error - '@typescript-eslint/no-invalid-this': error - '@typescript-eslint/no-loop-func': error - '@typescript-eslint/no-loss-of-precision': error - '@typescript-eslint/no-redeclare': error - '@typescript-eslint/no-throw-literal': error # TODO [error, { allowThrowingAny: false, allowThrowingUnknown: false }] - '@typescript-eslint/no-shadow': error - '@typescript-eslint/no-unused-expressions': error - '@typescript-eslint/no-unused-vars': - [ - error, - { - vars: all, - args: all, - argsIgnorePattern: '^_', - varsIgnorePattern: '^_T', - }, - ] - '@typescript-eslint/no-useless-constructor': error - '@typescript-eslint/require-await': error - '@typescript-eslint/return-await': error - - # Disable for JS and TS - '@typescript-eslint/init-declarations': off - '@typescript-eslint/no-magic-numbers': off - '@typescript-eslint/no-restricted-imports': off - '@typescript-eslint/no-use-before-define': off - '@typescript-eslint/no-duplicate-imports': off # Superseded by `import/no-duplicates` - - # Below rules are disabled because they conflict with Prettier, see: - # https://github.com/prettier/eslint-config-prettier/blob/main/index.js - '@typescript-eslint/object-curly-spacing': off - '@typescript-eslint/quotes': off - '@typescript-eslint/brace-style': off - '@typescript-eslint/comma-dangle': off - '@typescript-eslint/comma-spacing': off - '@typescript-eslint/func-call-spacing': off - '@typescript-eslint/indent': off - '@typescript-eslint/keyword-spacing': off - '@typescript-eslint/member-delimiter-style': off - '@typescript-eslint/no-extra-parens': off - '@typescript-eslint/no-extra-semi': off - '@typescript-eslint/semi': off - '@typescript-eslint/space-before-blocks': off - '@typescript-eslint/space-before-function-paren': off - '@typescript-eslint/space-infix-ops': off - '@typescript-eslint/type-annotation-spacing': off - - files: 'src/**' - rules: - internal-rules/require-to-string-tag: error - - files: 'src/**/__*__/**' - rules: - internal-rules/require-to-string-tag: off - node/no-unpublished-import: [error, { allowModules: ['chai', 'mocha'] }] - import/no-deprecated: off - import/no-restricted-paths: off - import/no-extraneous-dependencies: [error, { devDependencies: true }] - - files: 'integrationTests/*' - env: - node: true - rules: - node/no-sync: off - node/no-unpublished-require: [error, { allowModules: ['mocha'] }] - import/no-extraneous-dependencies: [error, { devDependencies: true }] - import/no-nodejs-modules: off - - files: 'integrationTests/*/**' - env: - node: true - rules: - node/no-sync: off - node/no-missing-require: [error, { allowModules: ['graphql'] }] - import/no-commonjs: off - import/no-nodejs-modules: off - no-console: off - - files: 'benchmark/**' - env: - node: true - rules: - internal-rules/only-ascii: [error, { allowEmoji: true }] - node/no-sync: off - node/no-missing-require: off - import/no-nodejs-modules: off - import/no-commonjs: off - no-console: off - no-await-in-loop: off - - files: 'resources/**' - env: - node: true - rules: - internal-rules/only-ascii: [error, { allowEmoji: true }] - node/no-unpublished-require: off - node/no-sync: off - import/no-extraneous-dependencies: [error, { devDependencies: true }] - import/no-nodejs-modules: off - import/no-commonjs: off - no-console: off - - files: '**/*.jsx' - parserOptions: - sourceType: module - ecmaFeatures: - jsx: true - rules: - node/no-unpublished-import: off - import/no-default-export: off - - files: 'website/**' - env: - node: true - plugins: - - 'react' - extends: - - 'plugin:react/recommended' - - 'plugin:react-hooks/recommended' - settings: - react: - version: detect - rules: - node/no-unpublished-require: off - node/no-missing-import: off - import/no-default-export: off - import/no-commonjs: off - import/no-nodejs-modules: off - import/no-extraneous-dependencies: off diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index fffb2cb1dc..0000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @graphql/graphql-js-reviewers diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index d935f6d400..0000000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,101 +0,0 @@ -# Contributing to graphql-js - -We want to make contributing to this project as easy and transparent as -possible. Hopefully this document makes the process for contributing clear and -answers any questions you may have. If not, feel free to open an -[Issue](https://github.com/graphql/graphql-spec/issues/). - -## Issues - -We use GitHub issues to track public bugs and requests. Please ensure your bug -description is clear and has sufficient instructions to be able to reproduce the -issue. The best way is to provide a reduced test case on jsFiddle or jsBin. - -## Pull Requests - -All active development of graphql-js happens on GitHub. We actively welcome -your [pull requests](https://help.github.com/articles/creating-a-pull-request). - -### Considered Changes - -Since graphql-js is a reference implementation of the -[GraphQL spec](https://graphql.github.io/graphql-spec/), only changes which comply -with this spec will be considered. If you have a change in mind which requires a -change to the spec, please first open an -[issue](https://github.com/graphql/graphql-spec/issues/) against the spec. - -### GraphQL Specification Membership Agreement - -This repository is managed by EasyCLA. Project participants must sign the free ([GraphQL Specification Membership agreement](https://preview-spec-membership.graphql.org) before making a contribution. You only need to do this one time, and it can be signed by [individual contributors](http://individual-spec-membership.graphql.org/) or their [employers](http://corporate-spec-membership.graphql.org/). - -To initiate the signature process please open a PR against this repo. The EasyCLA bot will block the merge if we still need a membership agreement from you. - -You can find [detailed information here](https://github.com/graphql/graphql-wg/tree/main/membership). If you have issues, please email [operations@graphql.org](mailto:operations@graphql.org). - -If your company benefits from GraphQL and you would like to provide essential financial support for the systems and people that power our community, please also consider membership in the [GraphQL Foundation](https://foundation.graphql.org/join). - -### Getting Started - -1. Fork this repo by using the "Fork" button in the upper-right - -2. Check out your fork - - ```sh - git clone git@github.com:your_name_here/graphql-js.git - ``` - -3. Install or Update all dependencies - - ```sh - npm install - ``` - -4. Get coding! If you've added code, add tests. If you've changed APIs, update - any relevant documentation or tests. Ensure your work is committed within a - feature branch. - -5. Ensure all tests pass - - ```sh - npm test - ``` - -## Coding Style - -This project uses [Prettier](https://prettier.io/) for standard formatting. To -ensure your pull request matches the style guides, run `npm run prettier`. - -- 2 spaces for indentation (no tabs) -- 80 character line length strongly preferred. -- Prefer `'` over `"` -- ES6 syntax when possible. However do not rely on ES6-specific functions to be available. -- Use [TypeScript](https://www.typescriptlang.org). -- Use semicolons; -- Trailing commas, -- Avd abbr wrds. - -## Release on NPM - -_Only core contributors may release to NPM._ - -To release a new version on NPM, first ensure all tests pass with `npm test`, -then use `npm version patch|minor|major` in order to increment the version in -package.json and tag and commit a release. Then `git push && git push --tags` -to sync this change with source control. Then `npm publish npmDist` to actually -publish the release to NPM. -Once published, add [release notes](https://github.com/graphql/graphql-js/tags). -Use [semver](https://semver.org/) to determine which version part to increment. - -Example for a patch release: - -```sh -npm test -npm version patch -git push --follow-tags -npm publish npmDist -``` - -## License - -By contributing to graphql-js, you agree that your contributions will be -licensed under its [MIT license](../LICENSE). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index d82363189e..0000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,21 +0,0 @@ -# Questions regarding how to use GraphQL - -We want to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track bugs and features that affect development. - -If you have a question on how to use GraphQL, please [post it to Stack Overflow](https://stackoverflow.com/questions/ask?tags=graphql) with the tag [#graphql](https://stackoverflow.com/questions/tagged/graphql). - -Please do not post general questions directly as GitHub issues. They may sit for weeks unanswered, or may be spontaneously closed without answer. - -# Reporting issues with GraphQL.js - -Before filing a new issue, make sure an issue for your problem doesn't already exist. - -The best way to get a bug fixed is to provide a _pull request_ with a simplified failing test case (or better yet, include a fix). - -# Feature requests - -GraphQL.js is a reference implementation of the [GraphQL specification](https://github.com/graphql/graphql-spec). To discuss new features which are not GraphQL.js specific and fundamentally change the way GraphQL works, open an issue against the specification. - -# Security bugs - -Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index dfcc49855b..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,280 +0,0 @@ -name: CI -on: - workflow_call: - secrets: - codecov_token: - required: true -permissions: {} -jobs: - lint: - name: Lint source files - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: '.node-version' - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Lint ESLint - run: npm run lint - - - name: Check Types - run: npm run check - - - name: Lint Prettier - run: npm run prettier:check - - - name: Spellcheck - run: npm run check:spelling - - - name: Lint GitHub Actions - uses: docker://rhysd/actionlint:latest - with: - args: -color - - checkForCommonlyIgnoredFiles: - name: Check for commonly ignored files - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Check if commit contains files that should be ignored - run: | - git clone --depth 1 https://github.com/github/gitignore.git - - rm gitignore/Global/ModelSim.gitignore - rm gitignore/Global/Images.gitignore - cat gitignore/Node.gitignore gitignore/Global/*.gitignore > all.gitignore - - IGNORED_FILES=$(git ls-files --cached --ignored --exclude-from=all.gitignore) - if [[ "$IGNORED_FILES" != "" ]]; then - echo -e "::error::Please remove these files:\n$IGNORED_FILES" | sed -z 's/\n/%0A/g' - exit 1 - fi - - checkPackageLock: - name: Check health of package-lock.json file - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: '.node-version' - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Check that package-lock.json doesn't have conflicts - run: npm ls --depth 999 - - - name: Run npm install - run: npm install --ignore-scripts --force --package-lock-only --engine-strict --strict-peer-deps - - - name: Check that package-lock.json is in sync with package.json - run: git diff --exit-code package-lock.json - - integrationTests: - name: Run integration tests - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version-file: '.node-version' - # We install bunch of packages during integration tests without locking them - # so we skip cache action to not pollute cache for other jobs. - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Run Integration Tests - run: npm run check:integrations - - fuzz: - name: Run fuzzing tests - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: '.node-version' - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Run Tests - run: npm run fuzzonly - - coverage: - name: Measure test coverage - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: '.node-version' - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Run tests and measure code coverage - run: npm run testonly:cover - - - name: Upload coverage to Codecov - if: ${{ always() }} - uses: codecov/codecov-action@v4 - with: - file: ./coverage/coverage-final.json - fail_ci_if_error: true - token: ${{ secrets.codecov_token }} - - test: - name: Run tests on Node v${{ matrix.node_version_to_setup }} - runs-on: ubuntu-latest - strategy: - matrix: - node_version_to_setup: [12, 14, 16, 17] - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js v${{ matrix.node_version_to_setup }} - uses: actions/setup-node@v4 - with: - cache: npm - node-version: ${{ matrix.node_version_to_setup }} - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Run Tests - run: npm run testonly - - codeql: - name: Run CodeQL security scan - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - security-events: write # for codeql-action - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: 'javascript, typescript' - - - name: Perform CodeQL analysis - uses: github/codeql-action/analyze@v3 - - build-npm-dist: - name: Build 'npmDist' artifact - runs-on: ubuntu-latest - needs: [test, fuzz, lint, integrationTests] - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: '.node-version' - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Build NPM package - run: npm run build:npm - - - name: Upload npmDist package - uses: actions/upload-artifact@v4 - with: - name: npmDist - path: ./npmDist - - build-deno-dist: - name: Build 'denoDist' artifact - runs-on: ubuntu-latest - needs: [test, fuzz, lint, integrationTests] - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: '.node-version' - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Build Deno package - run: npm run build:deno - - - name: Upload denoDist package - uses: actions/upload-artifact@v4 - with: - name: denoDist - path: ./denoDist diff --git a/.github/workflows/deploy-artifact-as-branch.yml b/.github/workflows/deploy-artifact-as-branch.yml deleted file mode 100644 index dc17b9093d..0000000000 --- a/.github/workflows/deploy-artifact-as-branch.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Deploy specified artifact as a branch -on: - workflow_call: - inputs: - environment: - description: Environment to publish under - required: true - type: string - artifact_name: - description: Artifact name - required: true - type: string - target_branch: - description: Target branch - required: true - type: string - commit_message: - description: Commit message - required: true - type: string -permissions: {} -jobs: - deploy-artifact-as-branch: - environment: - name: ${{ inputs.environment }} - url: ${{ github.server_url }}/${{ github.repository }}/tree/${{ inputs.target_branch }} - runs-on: ubuntu-latest - permissions: - contents: write # for actions/checkout and to push branch - steps: - - name: Checkout `${{ inputs.target_branch }}` branch - uses: actions/checkout@v4 - with: - ref: ${{ inputs.target_branch }} - - - name: Remove existing files first - run: git rm -r . - - - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.artifact_name }} - - - name: Publish target branch - run: | - git add -A - if git diff --staged --quiet; then - echo 'Nothing to publish' - else - git config user.name 'GitHub Action Script' - git config user.email 'please@open.issue' - - git commit -a -m "$COMMIT_MESSAGE" - git push - echo 'Pushed' - fi - env: - TARGET_BRANCH: ${{ inputs.target_branch }} - COMMIT_MESSAGE: ${{ inputs.commit_message }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml deleted file mode 100644 index 4e80470456..0000000000 --- a/.github/workflows/pull_request.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: PullRequest -on: pull_request -permissions: {} -jobs: - ci: - permissions: - contents: read # for actions/checkout - security-events: write # for codeql-action - uses: ./.github/workflows/ci.yml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - - dependency-review: - name: Security check of added dependencies - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Dependency review - uses: actions/dependency-review-action@v2 - - diff-npm-package: - name: Diff content of NPM package - runs-on: ubuntu-latest - permissions: - contents: read # for actions/checkout - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Deepen cloned repo - env: - BASE_SHA: ${{ github.event.pull_request.base.sha }} - run: 'git fetch --depth=1 origin "$BASE_SHA:refs/tags/BASE"' - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: '.node-version' - - - name: Install Dependencies - run: npm ci --ignore-scripts - - - name: Generate report - run: 'node resources/diff-npm-package.js BASE HEAD' - - - name: Upload generated report - uses: actions/upload-artifact@v4 - with: - name: npm-dist-diff.html - path: ./npm-dist-diff.html - if-no-files-found: ignore diff --git a/.github/workflows/pull_request_opened.yml b/.github/workflows/pull_request_opened.yml deleted file mode 100644 index d0e6aef0ac..0000000000 --- a/.github/workflows/pull_request_opened.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: PullRequestOpened -on: - pull_request: - types: [opened] -permissions: {} -jobs: - save-github-event: - name: "Save `github.event` as an artifact to use in subsequent 'workflow_run' actions" - runs-on: ubuntu-latest - steps: - - name: Upload event.json - uses: actions/upload-artifact@v4 - with: - name: event.json - path: ${{ github.event_path }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index d78b26652b..0000000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Push -on: push -permissions: {} -jobs: - ci: - permissions: - contents: read # for actions/checkout - security-events: write - uses: ./.github/workflows/ci.yml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - deploy-to-npm-branch: - name: Deploy to `npm` branch - needs: ci - if: github.ref == 'refs/heads/main' - permissions: - contents: write # for actions/checkout and to push branch - uses: ./.github/workflows/deploy-artifact-as-branch.yml - with: - environment: npm-branch - artifact_name: npmDist - target_branch: npm - commit_message: "Deploy ${{github.event.workflow_run.head_sha}} to 'npm' branch" - - deploy-to-deno-branch: - name: Deploy to `deno` branch - needs: ci - if: github.ref == 'refs/heads/main' - permissions: - contents: write # for actions/checkout and to push branch - uses: ./.github/workflows/deploy-artifact-as-branch.yml - with: - environment: deno-branch - artifact_name: denoDist - target_branch: deno - commit_message: "Deploy ${{github.event.workflow_run.head_sha}} to 'deno' branch" diff --git a/.gitignore b/.gitignore deleted file mode 100644 index bc35ca93a3..0000000000 --- a/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# This .gitignore only ignores files specific to this repository. -# If you see other files generated by your OS or tools you use, consider -# creating a global .gitignore file. -# -# https://help.github.com/articles/ignoring-files/#create-a-global-gitignore -# https://www.gitignore.io/ - -/diff-npm-package.html -/.eslintcache -/.cspellcache -node_modules -/coverage -/npmDist -/denoDist -/websiteDist -/website/.next -/website/out diff --git a/.mocharc.yml b/.mocharc.yml deleted file mode 100644 index 5050fbe4ac..0000000000 --- a/.mocharc.yml +++ /dev/null @@ -1,7 +0,0 @@ -fail-zero: true -throw-deprecation: true -check-leaks: true -require: - - 'resources/ts-register.js' -extension: - - 'ts' diff --git a/.node-version b/.node-version deleted file mode 100644 index 703a257b8b..0000000000 --- a/.node-version +++ /dev/null @@ -1 +0,0 @@ -v17 diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 1801e9556e..0000000000 --- a/.prettierignore +++ /dev/null @@ -1,11 +0,0 @@ -# Copied from '.gitignore', please keep it in sync. -/diff-npm-package.html -/.eslintcache -/node_modules -/coverage -/npmDist -/denoDist -/websiteDist -/website/out -/website/**/*.mdx -.next diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index a20502b7f0..0000000000 --- a/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all" -} diff --git a/NotSupportedTSVersion.d.ts b/NotSupportedTSVersion.d.ts new file mode 100644 index 0000000000..05d0ede067 --- /dev/null +++ b/NotSupportedTSVersion.d.ts @@ -0,0 +1 @@ +"Package 'graphql' support only TS versions that are >=4.4.0". \ No newline at end of file diff --git a/README.md b/README.md index ca30be668a..8908c605f5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![GraphQLConf 2025 Banner: September 08-10, Amsterdam. Hosted by the GraphQL Foundation](./assets/graphql-conf-2025.png)](https://graphql.org/conf/2025/?utm_source=github&utm_medium=graphql_js&utm_campaign=readme) +[![GraphQLConf 2024 Banner: September 10-12, San Francisco. Hosted by the GraphQL Foundation](https://github.com/user-attachments/assets/2d048502-e5b2-4e9d-a02a-50b841824de6)](https://graphql.org/conf/2024/?utm_source=github&utm_medium=graphql_js&utm_campaign=readme) # GraphQL.js @@ -6,7 +6,6 @@ The JavaScript reference implementation for GraphQL, a query language for APIs c [![npm version](https://badge.fury.io/js/graphql.svg)](https://badge.fury.io/js/graphql) [![Build Status](https://github.com/graphql/graphql-js/workflows/CI/badge.svg?branch=main)](https://github.com/graphql/graphql-js/actions?query=branch%3Amain) -[![Coverage Status](https://codecov.io/gh/graphql/graphql-js/branch/main/graph/badge.svg)](https://codecov.io/gh/graphql/graphql-js) See more complete documentation at https://graphql.org/ and https://graphql.org/graphql-js/. @@ -26,18 +25,24 @@ through that README and the corresponding tests in parallel. Install GraphQL.js from npm -With npm: +With `npm`: ```sh npm install --save graphql ``` -or using yarn: +With `yarn`: ```sh yarn add graphql ``` +With `bun`: + +```sh +bun add graphql +``` + GraphQL.js provides two important capabilities: building a type schema and serving queries against that type schema. @@ -105,7 +110,7 @@ graphql({ schema, source }).then((result) => { **Note**: Please don't forget to set `NODE_ENV=production` if you are running a production server. It will disable some checks that can be useful during development but will significantly improve performance. -## Want to ride the bleeding edge? +### Want to ride the bleeding edge? The `npm` branch in this repository is automatically maintained to be the last commit to `main` to pass all tests, in the same form found on npm. It is @@ -117,17 +122,7 @@ directly on this branch: npm install graphql@git://github.com/graphql/graphql-js.git#npm ``` -### Experimental features - -Each release of GraphQL.js will be accompanied by an experimental release containing support for the `@defer` and `@stream` directive proposal. We are hoping to get community feedback on these releases before the proposal is accepted into the GraphQL specification. You can use this experimental release of GraphQL.js by adding the following to your project's `package.json` file. - -``` -"graphql": "experimental-stream-defer" -``` - -Community feedback on this experimental release is much appreciated and can be provided on the [issue created for this purpose](https://github.com/graphql/graphql-js/issues/2848). - -## Using in a Browser +### Using in a Browser GraphQL.js is a general-purpose library and can be used both in a Node server and in the browser. As an example, the [GraphiQL](https://github.com/graphql/graphiql/) @@ -139,7 +134,7 @@ the portions of the library you use. This works because GraphQL.js is distribute with both CommonJS (`require()`) and ESModule (`import`) files. Ensure that any custom build configurations look for `.mjs` files! -## Contributing +### Contributing We actively welcome pull requests. Learn how to [contribute](./.github/CONTRIBUTING.md). @@ -151,53 +146,10 @@ You can find [detailed information here](https://github.com/graphql/graphql-wg/t If your company benefits from GraphQL and you would like to provide essential financial support for the systems and people that power our community, please also consider membership in the [GraphQL Foundation](https://foundation.graphql.org/join). -## Changelog +### Changelog Changes are tracked as [GitHub releases](https://github.com/graphql/graphql-js/releases). -## License +### License GraphQL.js is [MIT-licensed](./LICENSE). - -## Version Support - -GraphQL.JS follows Semantic Versioning (SemVer) for its releases. Our version support policy is as follows: - -- Latest Major Version: We provide full support, including bug fixes and security updates, for the latest major version of GraphQL.JS. -- Previous Major Version: We offer feature support for the previous major version for 12 months after the release of the newest major version. - This means that for 12 months we can backport features for specification changes _if_ they don't cause any breaking changes. We'll continue - supporting the previous major version with bug and security fixes. -- Older Versions: Versions older than the previous major release are considered unsupported. While the code remains available, - we do not actively maintain or provide updates for these versions. - One exception to this rule is when the older version has been released < 1 year ago, in that case we - will treat it like the "Previous Major Version". - -### Long-Term Support (LTS) - -We do not currently offer a Long-Term Support version of GraphQL.JS. Users are encouraged to upgrade to the latest stable version -to receive the most up-to-date features, performance improvements, and security updates. - -### End-of-Life (EOL) Schedule - -We will announce the EOL date for a major version at least 6 months in advance. -After a version reaches its EOL, it will no longer receive updates, even for critical security issues. - -### Upgrade Assistance - -To assist users in upgrading to newer versions: - -- We maintain detailed release notes for each version, highlighting new features, breaking changes, and deprecations. -- [Our documentation](https://www.graphql-js.org/) includes migration guides for moving between major versions. -- The [community forum (Discord channel #graphql-js)](https://discord.graphql.org) is available for users who need additional assistance with upgrades. - -### Security Updates - -We prioritize the security of GraphQL.JS: - -- Critical security updates will be applied to both the current and previous major version. -- For versions that have reached EOL, we strongly recommend upgrading to a supported version to receive security updates. - -### Community Contributions - -We welcome community contributions for all versions of GraphQL.JS. However, our maintainers will primarily focus on reviewing -and merging contributions for supported versions. diff --git a/assets/graphql-conf-2025.png b/assets/graphql-conf-2025.png deleted file mode 100644 index d2c7ec22b0..0000000000 Binary files a/assets/graphql-conf-2025.png and /dev/null differ diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 9288d1f273..0000000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,393 +0,0 @@ -'use strict'; - -const os = require('os'); -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); -const cp = require('child_process'); - -const NS_PER_SEC = 1e9; -const LOCAL = 'local'; - -// The maximum time in seconds a benchmark is allowed to run before finishing. -const maxTime = 5; -// The minimum sample size required to perform statistical analysis. -const minSamples = 5; - -// Get the revisions and make things happen! -if (require.main === module) { - const { benchmarks, revisions } = getArguments(process.argv.slice(2)); - const benchmarkProjects = prepareBenchmarkProjects(revisions); - - runBenchmarks(benchmarks, benchmarkProjects).catch((error) => { - console.error(error); - process.exit(1); - }); -} - -function localDir(...paths) { - return path.join(__dirname, '..', ...paths); -} - -function exec(command, options = {}) { - const result = cp.execSync(command, { - encoding: 'utf-8', - stdio: ['inherit', 'pipe', 'inherit'], - ...options, - }); - return result?.trimEnd(); -} - -// Build a benchmark-friendly environment for the given revision -// and returns path to its 'dist' directory. -function prepareBenchmarkProjects(revisionList) { - const tmpDir = path.join(os.tmpdir(), 'graphql-js-benchmark'); - fs.rmSync(tmpDir, { recursive: true, force: true }); - fs.mkdirSync(tmpDir); - - const setupDir = path.join(tmpDir, 'setup'); - fs.mkdirSync(setupDir); - - return revisionList.map((revision) => { - console.log(`🍳 Preparing ${revision}...`); - const projectPath = path.join(setupDir, revision); - fs.rmSync(projectPath, { recursive: true, force: true }); - fs.mkdirSync(projectPath); - - fs.writeFileSync( - path.join(projectPath, 'package.json'), - '{ "private": true }', - ); - exec( - 'npm --quiet install --ignore-scripts ' + prepareNPMPackage(revision), - { cwd: projectPath }, - ); - exec(`cp -R ${localDir('benchmark')} ${projectPath}`); - - return { revision, projectPath }; - }); - - function prepareNPMPackage(revision) { - if (revision === LOCAL) { - const repoDir = localDir(); - const archivePath = path.join(tmpDir, 'graphql-local.tgz'); - fs.renameSync(buildNPMArchive(repoDir), archivePath); - return archivePath; - } - - // Returns the complete git hash for a given git revision reference. - const hash = exec(`git rev-parse "${revision}"`); - - const archivePath = path.join(tmpDir, `graphql-${hash}.tgz`); - if (fs.existsSync(archivePath)) { - return archivePath; - } - - const repoDir = path.join(tmpDir, hash); - fs.rmSync(repoDir, { recursive: true, force: true }); - fs.mkdirSync(repoDir); - exec(`git archive "${hash}" | tar -xC "${repoDir}"`); - exec('npm --quiet ci --ignore-scripts', { cwd: repoDir }); - fs.renameSync(buildNPMArchive(repoDir), archivePath); - fs.rmSync(repoDir, { recursive: true }); - return archivePath; - } - - function buildNPMArchive(repoDir) { - exec('npm --quiet run build:npm', { cwd: repoDir }); - - const distDir = path.join(repoDir, 'npmDist'); - const archiveName = exec(`npm --quiet pack ${distDir}`, { cwd: repoDir }); - return path.join(repoDir, archiveName); - } -} - -async function collectSamples(modulePath) { - const samples = []; - - // If time permits, increase sample size to reduce the margin of error. - const start = Date.now(); - while (samples.length < minSamples || (Date.now() - start) / 1e3 < maxTime) { - const { clocked, memUsed } = await sampleModule(modulePath); - assert(clocked > 0); - assert(memUsed > 0); - samples.push({ clocked, memUsed }); - } - return samples; -} - -// T-Distribution two-tailed critical values for 95% confidence. -// See http://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm. -// prettier-ignore -const tTable = { - '1': 12.706, '2': 4.303, '3': 3.182, '4': 2.776, '5': 2.571, '6': 2.447, - '7': 2.365, '8': 2.306, '9': 2.262, '10': 2.228, '11': 2.201, '12': 2.179, - '13': 2.16, '14': 2.145, '15': 2.131, '16': 2.12, '17': 2.11, '18': 2.101, - '19': 2.093, '20': 2.086, '21': 2.08, '22': 2.074, '23': 2.069, '24': 2.064, - '25': 2.06, '26': 2.056, '27': 2.052, '28': 2.048, '29': 2.045, '30': 2.042, - infinity: 1.96, -}; - -// Computes stats on benchmark results. -function computeStats(samples) { - assert(samples.length > 1); - - // Compute the sample mean (estimate of the population mean). - let mean = 0; - let meanMemUsed = 0; - for (const { clocked, memUsed } of samples) { - mean += clocked; - meanMemUsed += memUsed; - } - mean /= samples.length; - meanMemUsed /= samples.length; - - // Compute the sample variance (estimate of the population variance). - let variance = 0; - for (const { clocked } of samples) { - variance += (clocked - mean) ** 2; - } - variance /= samples.length - 1; - - // Compute the sample standard deviation (estimate of the population standard deviation). - const sd = Math.sqrt(variance); - - // Compute the standard error of the mean (a.k.a. the standard deviation of the sampling distribution of the sample mean). - const sem = sd / Math.sqrt(samples.length); - - // Compute the degrees of freedom. - const df = samples.length - 1; - - // Compute the critical value. - const critical = tTable[df] || tTable.infinity; - - // Compute the margin of error. - const moe = sem * critical; - - // The relative margin of error (expressed as a percentage of the mean). - const rme = (moe / mean) * 100 || 0; - - return { - memPerOp: Math.floor(meanMemUsed), - ops: NS_PER_SEC / mean, - deviation: rme, - numSamples: samples.length, - }; -} - -function beautifyBenchmark(results) { - const nameMaxLen = maxBy(results, ({ name }) => name.length); - const opsTop = maxBy(results, ({ ops }) => ops); - const opsMaxLen = maxBy(results, ({ ops }) => beautifyNumber(ops).length); - const memPerOpMaxLen = maxBy( - results, - ({ memPerOp }) => beautifyBytes(memPerOp).length, - ); - - for (const result of results) { - printBench(result); - } - - function printBench(bench) { - const { name, memPerOp, ops, deviation, numSamples } = bench; - console.log( - ' ' + - nameStr() + - grey(' x ') + - opsStr() + - ' ops/sec ' + - grey('\xb1') + - deviationStr() + - cyan('%') + - grey(' x ') + - memPerOpStr() + - '/op' + - grey(' (' + numSamples + ' runs sampled)'), - ); - - function nameStr() { - const nameFmt = name.padEnd(nameMaxLen); - return ops === opsTop ? green(nameFmt) : nameFmt; - } - - function opsStr() { - const percent = ops / opsTop; - const colorFn = percent > 0.95 ? green : percent > 0.8 ? yellow : red; - return colorFn(beautifyNumber(ops).padStart(opsMaxLen)); - } - - function deviationStr() { - const colorFn = deviation > 5 ? red : deviation > 2 ? yellow : green; - return colorFn(deviation.toFixed(2)); - } - - function memPerOpStr() { - return beautifyBytes(memPerOp).padStart(memPerOpMaxLen); - } - } -} - -function beautifyBytes(bytes) { - const sizes = ['Bytes', 'KB', 'MB', 'GB']; - const i = Math.floor(Math.log2(bytes) / 10); - return beautifyNumber(bytes / 2 ** (i * 10)) + ' ' + sizes[i]; -} - -function beautifyNumber(num) { - return Number(num.toFixed(num > 100 ? 0 : 2)).toLocaleString(); -} - -function maxBy(array, fn) { - return Math.max(...array.map(fn)); -} - -// Prepare all revisions and run benchmarks matching a pattern against them. -async function runBenchmarks(benchmarks, benchmarkProjects) { - for (const benchmark of benchmarks) { - const results = []; - for (let i = 0; i < benchmarkProjects.length; ++i) { - const { revision, projectPath } = benchmarkProjects[i]; - const modulePath = path.join(projectPath, benchmark); - - if (i === 0) { - const { name } = await sampleModule(modulePath); - console.log('⏱ ' + name); - } - - try { - const samples = await collectSamples(modulePath); - - results.push({ - name: revision, - samples, - ...computeStats(samples), - }); - process.stdout.write(' ' + cyan(i + 1) + ' tests completed.\u000D'); - } catch (error) { - console.log(' ' + revision + ': ' + red(String(error))); - } - } - console.log('\n'); - - beautifyBenchmark(results); - console.log(''); - } -} - -function getArguments(argv) { - const revsIndex = argv.indexOf('--revs'); - const revisions = revsIndex === -1 ? [] : argv.slice(revsIndex + 1); - const benchmarks = revsIndex === -1 ? argv : argv.slice(0, revsIndex); - - switch (revisions.length) { - case 0: - revisions.unshift('HEAD'); - // fall through - case 1: { - revisions.unshift('local'); - - const assumeArgv = ['benchmark', ...benchmarks, '--revs', ...revisions]; - console.warn('Assuming you meant: ' + bold(assumeArgv.join(' '))); - break; - } - } - - if (benchmarks.length === 0) { - benchmarks.push(...findAllBenchmarks()); - } - - return { benchmarks, revisions }; -} - -function findAllBenchmarks() { - return fs - .readdirSync(localDir('benchmark'), { withFileTypes: true }) - .filter((dirent) => dirent.isFile()) - .map((dirent) => dirent.name) - .filter((name) => name.endsWith('-benchmark.js')) - .map((name) => path.join('benchmark', name)); -} - -function bold(str) { - return '\u001b[1m' + str + '\u001b[0m'; -} - -function red(str) { - return '\u001b[31m' + str + '\u001b[0m'; -} - -function green(str) { - return '\u001b[32m' + str + '\u001b[0m'; -} - -function yellow(str) { - return '\u001b[33m' + str + '\u001b[0m'; -} - -function cyan(str) { - return '\u001b[36m' + str + '\u001b[0m'; -} - -function grey(str) { - return '\u001b[90m' + str + '\u001b[0m'; -} - -function sampleModule(modulePath) { - const sampleCode = ` - const assert = require('assert'); - - assert(global.gc); - assert(process.send); - const module = require('${modulePath}'); - - clock(7, module.measure); // warm up - global.gc(); - process.nextTick(() => { - const memBaseline = process.memoryUsage().heapUsed; - const clocked = clock(module.count, module.measure); - process.send({ - name: module.name, - clocked: clocked / module.count, - memUsed: (process.memoryUsage().heapUsed - memBaseline) / module.count, - }); - }); - - // Clocks the time taken to execute a test per cycle (secs). - function clock(count, fn) { - const start = process.hrtime.bigint(); - for (let i = 0; i < count; ++i) { - fn(); - } - return Number(process.hrtime.bigint() - start); - } - `; - - return new Promise((resolve, reject) => { - const child = cp.spawn( - process.argv[0], - [ - '--no-concurrent-sweeping', - '--predictable', - '--expose-gc', - '--eval', - sampleCode, - ], - { - stdio: ['inherit', 'inherit', 'inherit', 'ipc'], - env: { NODE_ENV: 'production' }, - }, - ); - - let message; - let error; - - child.on('message', (msg) => (message = msg)); - child.on('error', (e) => (error = e)); - child.on('close', () => { - if (message) { - return resolve(message); - } - reject(error || new Error('Spawn process closed without error')); - }); - }); -} diff --git a/benchmark/buildASTSchema-benchmark.js b/benchmark/buildASTSchema-benchmark.js deleted file mode 100644 index b578d71a7f..0000000000 --- a/benchmark/buildASTSchema-benchmark.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { buildASTSchema } = require('graphql/utilities/buildASTSchema.js'); - -const { bigSchemaSDL } = require('./fixtures.js'); - -const schemaAST = parse(bigSchemaSDL); - -module.exports = { - name: 'Build Schema from AST', - count: 10, - measure() { - buildASTSchema(schemaAST, { assumeValid: true }); - }, -}; diff --git a/benchmark/buildClientSchema-benchmark.js b/benchmark/buildClientSchema-benchmark.js deleted file mode 100644 index 240c9ca1f1..0000000000 --- a/benchmark/buildClientSchema-benchmark.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -const { buildClientSchema } = require('graphql/utilities/buildClientSchema.js'); - -const { bigSchemaIntrospectionResult } = require('./fixtures.js'); - -module.exports = { - name: 'Build Schema from Introspection', - count: 10, - measure() { - buildClientSchema(bigSchemaIntrospectionResult.data, { assumeValid: true }); - }, -}; diff --git a/benchmark/fixtures.js b/benchmark/fixtures.js deleted file mode 100644 index 8f3aa1edd8..0000000000 --- a/benchmark/fixtures.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); - -exports.bigSchemaSDL = fs.readFileSync( - path.join(__dirname, 'github-schema.graphql'), - 'utf8', -); - -exports.bigDocumentSDL = fs.readFileSync( - path.join(__dirname, 'kitchen-sink.graphql'), - 'utf8', -); - -exports.bigSchemaIntrospectionResult = JSON.parse( - fs.readFileSync(path.join(__dirname, 'github-schema.json'), 'utf8'), -); diff --git a/benchmark/github-schema.graphql b/benchmark/github-schema.graphql deleted file mode 100644 index 7baa42397a..0000000000 --- a/benchmark/github-schema.graphql +++ /dev/null @@ -1,20367 +0,0 @@ -""" -Autogenerated input type of AcceptTopicSuggestion -""" -input AcceptTopicSuggestionInput { - """ - The Node ID of the repository. - """ - repositoryId: ID! - - """ - The name of the suggested topic. - """ - name: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AcceptTopicSuggestion -""" -type AcceptTopicSuggestionPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The accepted topic. - """ - topic: Topic -} - -""" -Represents an object which can take actions on GitHub. Typically a User or Bot. -""" -interface Actor { - """ - A URL pointing to the actor's public avatar. - """ - avatarUrl( - """ - The size of the resulting square image. - """ - size: Int - ): URI! - - """ - The username of the actor. - """ - login: String! - - """ - The HTTP path for this actor. - """ - resourcePath: URI! - - """ - The HTTP URL for this actor. - """ - url: URI! -} - -""" -Autogenerated input type of AddAssigneesToAssignable -""" -input AddAssigneesToAssignableInput { - """ - The id of the assignable object to add assignees to. - """ - assignableId: ID! - - """ - The id of users to add as assignees. - """ - assigneeIds: [ID!]! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddAssigneesToAssignable -""" -type AddAssigneesToAssignablePayload { - """ - The item that was assigned. - """ - assignable: Assignable - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated input type of AddComment -""" -input AddCommentInput { - """ - The Node ID of the subject to modify. - """ - subjectId: ID! - - """ - The contents of the comment. - """ - body: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddComment -""" -type AddCommentPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The edge from the subject's comment connection. - """ - commentEdge: IssueCommentEdge - - """ - The subject - """ - subject: Node - - """ - The edge from the subject's timeline connection. - """ - timelineEdge: IssueTimelineItemEdge -} - -""" -Represents a 'added_to_project' event on a given issue or pull request. -""" -type AddedToProjectEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! -} - -""" -Autogenerated input type of AddLabelsToLabelable -""" -input AddLabelsToLabelableInput { - """ - The id of the labelable object to add labels to. - """ - labelableId: ID! - - """ - The ids of the labels to add. - """ - labelIds: [ID!]! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddLabelsToLabelable -""" -type AddLabelsToLabelablePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The item that was labeled. - """ - labelable: Labelable -} - -""" -Autogenerated input type of AddProjectCard -""" -input AddProjectCardInput { - """ - The Node ID of the ProjectColumn. - """ - projectColumnId: ID! - - """ - The content of the card. Must be a member of the ProjectCardItem union - """ - contentId: ID - - """ - The note on the card. - """ - note: String - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddProjectCard -""" -type AddProjectCardPayload { - """ - The edge from the ProjectColumn's card connection. - """ - cardEdge: ProjectCardEdge - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The ProjectColumn - """ - projectColumn: ProjectColumn -} - -""" -Autogenerated input type of AddProjectColumn -""" -input AddProjectColumnInput { - """ - The Node ID of the project. - """ - projectId: ID! - - """ - The name of the column. - """ - name: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddProjectColumn -""" -type AddProjectColumnPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The edge from the project's column connection. - """ - columnEdge: ProjectColumnEdge - - """ - The project - """ - project: Project -} - -""" -Autogenerated input type of AddPullRequestReviewComment -""" -input AddPullRequestReviewCommentInput { - """ - The Node ID of the review to modify. - """ - pullRequestReviewId: ID! - - """ - The SHA of the commit to comment on. - """ - commitOID: GitObjectID - - """ - The text of the comment. - """ - body: String! - - """ - The relative path of the file to comment on. - """ - path: String - - """ - The line index in the diff to comment on. - """ - position: Int - - """ - The comment id to reply to. - """ - inReplyTo: ID - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddPullRequestReviewComment -""" -type AddPullRequestReviewCommentPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The newly created comment. - """ - comment: PullRequestReviewComment - - """ - The edge from the review's comment connection. - """ - commentEdge: PullRequestReviewCommentEdge -} - -""" -Autogenerated input type of AddPullRequestReview -""" -input AddPullRequestReviewInput { - """ - The Node ID of the pull request to modify. - """ - pullRequestId: ID! - - """ - The commit OID the review pertains to. - """ - commitOID: GitObjectID - - """ - The contents of the review body comment. - """ - body: String - - """ - The event to perform on the pull request review. - """ - event: PullRequestReviewEvent - - """ - The review line comments. - """ - comments: [DraftPullRequestReviewComment] - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddPullRequestReview -""" -type AddPullRequestReviewPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The newly created pull request review. - """ - pullRequestReview: PullRequestReview - - """ - The edge from the pull request's review connection. - """ - reviewEdge: PullRequestReviewEdge -} - -""" -Autogenerated input type of AddReaction -""" -input AddReactionInput { - """ - The Node ID of the subject to modify. - """ - subjectId: ID! - - """ - The name of the emoji to react with. - """ - content: ReactionContent! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddReaction -""" -type AddReactionPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The reaction object. - """ - reaction: Reaction - - """ - The reactable subject. - """ - subject: Reactable -} - -""" -Autogenerated input type of AddStar -""" -input AddStarInput { - """ - The Starrable ID to star. - """ - starrableId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of AddStar -""" -type AddStarPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The starrable. - """ - starrable: Starrable -} - -""" -A GitHub App. -""" -type App implements Node { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The description of the app. - """ - description: String - id: ID! - - """ - The hex color code, without the leading '#', for the logo background. - """ - logoBackgroundColor: String! - - """ - A URL pointing to the app's logo. - """ - logoUrl( - """ - The size of the resulting image. - """ - size: Int - ): URI! - - """ - The name of the app. - """ - name: String! - - """ - A slug based on the name of the app for use in URLs. - """ - slug: String! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The URL to the app's homepage. - """ - url: URI! -} - -""" -An edge in a connection. -""" -type AppEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: App -} - -""" -An object that can have users assigned to it. -""" -interface Assignable { - """ - A list of Users assigned to this object. - """ - assignees( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! -} - -""" -Represents an 'assigned' event on any assignable object. -""" -type AssignedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the assignable associated with the event. - """ - assignable: Assignable! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the user who was assigned. - """ - user: User -} - -""" -Represents a 'base_ref_changed' event on a given issue or pull request. -""" -type BaseRefChangedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! -} - -""" -Represents a 'base_ref_force_pushed' event on a given pull request. -""" -type BaseRefForcePushedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the after commit SHA for the 'base_ref_force_pushed' event. - """ - afterCommit: Commit - - """ - Identifies the before commit SHA for the 'base_ref_force_pushed' event. - """ - beforeCommit: Commit - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! - - """ - Identifies the fully qualified ref name for the 'base_ref_force_pushed' event. - """ - ref: Ref -} - -""" -Represents a Git blame. -""" -type Blame { - """ - The list of ranges from a Git blame. - """ - ranges: [BlameRange!]! -} - -""" -Represents a range of information from a Git blame. -""" -type BlameRange { - """ - Identifies the recency of the change, from 1 (new) to 10 (old). This is - calculated as a 2-quantile and determines the length of distance between the - median age of all the changes in the file and the recency of the current - range's change. - """ - age: Int! - - """ - Identifies the line author - """ - commit: Commit! - - """ - The ending line for the range - """ - endingLine: Int! - - """ - The starting line for the range - """ - startingLine: Int! -} - -""" -Represents a Git blob. -""" -type Blob implements Node & GitObject { - """ - An abbreviated version of the Git object ID - """ - abbreviatedOid: String! - - """ - Byte size of Blob object - """ - byteSize: Int! - - """ - The HTTP path for this Git object - """ - commitResourcePath: URI! - - """ - The HTTP URL for this Git object - """ - commitUrl: URI! - id: ID! - - """ - Indicates whether the Blob is binary or text - """ - isBinary: Boolean! - - """ - Indicates whether the contents is truncated - """ - isTruncated: Boolean! - - """ - The Git object ID - """ - oid: GitObjectID! - - """ - The Repository the Git object belongs to - """ - repository: Repository! - - """ - UTF8 text data or null if the Blob is binary - """ - text: String -} - -""" -A special type of user which takes actions on behalf of GitHub Apps. -""" -type Bot implements Node & Actor & UniformResourceLocatable { - """ - A URL pointing to the GitHub App's public avatar. - """ - avatarUrl( - """ - The size of the resulting square image. - """ - size: Int - ): URI! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - The username of the actor. - """ - login: String! - - """ - The HTTP path for this bot - """ - resourcePath: URI! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this bot - """ - url: URI! -} - -""" -A branch protection rule. -""" -type BranchProtectionRule implements Node { - """ - A list of conflicts matching branches protection rule and other branch protection rules - """ - branchProtectionRuleConflicts( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): BranchProtectionRuleConflictConnection! - - """ - The actor who created this branch protection rule. - """ - creator: Actor - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - Will new commits pushed to matching branches dismiss pull request review approvals. - """ - dismissesStaleReviews: Boolean! - id: ID! - - """ - Can admins overwrite branch protection. - """ - isAdminEnforced: Boolean! - - """ - Repository refs that are protected by this rule - """ - matchingRefs( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RefConnection! - - """ - Identifies the protection rule pattern. - """ - pattern: String! - - """ - A list push allowances for this branch protection rule. - """ - pushAllowances( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PushAllowanceConnection! - - """ - The repository associated with this branch protection rule. - """ - repository: Repository - - """ - Number of approving reviews required to update matching branches. - """ - requiredApprovingReviewCount: Int - - """ - List of required status check contexts that must pass for commits to be accepted to matching branches. - """ - requiredStatusCheckContexts: [String] - - """ - Are approving reviews required to update matching branches. - """ - requiresApprovingReviews: Boolean! - - """ - Are commits required to be signed. - """ - requiresCommitSignatures: Boolean! - - """ - Are status checks required to update matching branches. - """ - requiresStatusChecks: Boolean! - - """ - Are branches required to be up to date before merging. - """ - requiresStrictStatusChecks: Boolean! - - """ - Is pushing to matching branches restricted. - """ - restrictsPushes: Boolean! - - """ - Is dismissal of pull request reviews restricted. - """ - restrictsReviewDismissals: Boolean! - - """ - A list review dismissal allowances for this branch protection rule. - """ - reviewDismissalAllowances( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ReviewDismissalAllowanceConnection! -} - -""" -A conflict between two branch protection rules. -""" -type BranchProtectionRuleConflict { - """ - Identifies the branch protection rule. - """ - branchProtectionRule: BranchProtectionRule - - """ - Identifies the conflicting branch protection rule. - """ - conflictingBranchProtectionRule: BranchProtectionRule - - """ - Identifies the branch ref that has conflicting rules - """ - ref: Ref -} - -""" -The connection type for BranchProtectionRuleConflict. -""" -type BranchProtectionRuleConflictConnection { - """ - A list of edges. - """ - edges: [BranchProtectionRuleConflictEdge] - - """ - A list of nodes. - """ - nodes: [BranchProtectionRuleConflict] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type BranchProtectionRuleConflictEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: BranchProtectionRuleConflict -} - -""" -The connection type for BranchProtectionRule. -""" -type BranchProtectionRuleConnection { - """ - A list of edges. - """ - edges: [BranchProtectionRuleEdge] - - """ - A list of nodes. - """ - nodes: [BranchProtectionRule] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type BranchProtectionRuleEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: BranchProtectionRule -} - -""" -Autogenerated input type of ChangeUserStatus -""" -input ChangeUserStatusInput { - """ - The emoji to represent your status. Can either be a native Unicode emoji or an emoji name with colons, e.g., :grinning:. - """ - emoji: String - - """ - A short description of your current status. - """ - message: String - - """ - The ID of the organization whose members will be allowed to see the status. If - omitted, the status will be publicly visible. - """ - organizationId: ID - - """ - Whether this status should indicate you are not fully available on GitHub, e.g., you are away. - """ - limitedAvailability: Boolean = false - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of ChangeUserStatus -""" -type ChangeUserStatusPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - Your updated status. - """ - status: UserStatus -} - -""" -Autogenerated input type of ClearLabelsFromLabelable -""" -input ClearLabelsFromLabelableInput { - """ - The id of the labelable object to clear the labels from. - """ - labelableId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of ClearLabelsFromLabelable -""" -type ClearLabelsFromLabelablePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The item that was unlabeled. - """ - labelable: Labelable -} - -""" -Autogenerated input type of CloneProject -""" -input CloneProjectInput { - """ - The owner ID to create the project under. - """ - targetOwnerId: ID! - - """ - The source project to clone. - """ - sourceId: ID! - - """ - Whether or not to clone the source project's workflows. - """ - includeWorkflows: Boolean! - - """ - The name of the project. - """ - name: String! - - """ - The description of the project. - """ - body: String - - """ - The visibility of the project, defaults to false (private). - """ - public: Boolean - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of CloneProject -""" -type CloneProjectPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The id of the JobStatus for populating cloned fields. - """ - jobStatusId: String - - """ - The new cloned project. - """ - project: Project -} - -""" -An object that can be closed -""" -interface Closable { - """ - `true` if the object is closed (definition of closed may depend on type) - """ - closed: Boolean! - - """ - Identifies the date and time when the object was closed. - """ - closedAt: DateTime -} - -""" -Represents a 'closed' event on any `Closable`. -""" -type ClosedEvent implements Node & UniformResourceLocatable { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Object that was closed. - """ - closable: Closable! - - """ - Object which triggered the creation of this event. - """ - closer: Closer - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - The HTTP path for this closed event. - """ - resourcePath: URI! - - """ - The HTTP URL for this closed event. - """ - url: URI! -} - -""" -Autogenerated input type of CloseIssue -""" -input CloseIssueInput { - """ - ID of the issue to be closed. - """ - issueId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of CloseIssue -""" -type CloseIssuePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The issue that was closed. - """ - issue: Issue -} - -""" -Autogenerated input type of ClosePullRequest -""" -input ClosePullRequestInput { - """ - ID of the pull request to be closed. - """ - pullRequestId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of ClosePullRequest -""" -type ClosePullRequestPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The pull request that was closed. - """ - pullRequest: PullRequest -} - -""" -The object which triggered a `ClosedEvent`. -""" -union Closer = Commit | PullRequest - -""" -The Code of Conduct for a repository -""" -type CodeOfConduct implements Node { - """ - The body of the Code of Conduct - """ - body: String - id: ID! - - """ - The key for the Code of Conduct - """ - key: String! - - """ - The formal name of the Code of Conduct - """ - name: String! - - """ - The HTTP path for this Code of Conduct - """ - resourcePath: URI - - """ - The HTTP URL for this Code of Conduct - """ - url: URI -} - -""" -Collaborators affiliation level with a subject. -""" -enum CollaboratorAffiliation { - """ - All outside collaborators of an organization-owned subject. - """ - OUTSIDE - - """ - All collaborators with permissions to an organization-owned subject, regardless of organization membership status. - """ - DIRECT - - """ - All collaborators the authenticated user can see. - """ - ALL -} - -""" -Types that can be inside Collection Items. -""" -union CollectionItemContent = Repository | Organization | User - -""" -Represents a comment. -""" -interface Comment { - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the subject of the comment. - """ - authorAssociation: CommentAuthorAssociation! - - """ - The body as Markdown. - """ - body: String! - - """ - The body rendered to HTML. - """ - bodyHTML: HTML! - - """ - The body rendered to text. - """ - bodyText: String! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - The actor who edited the comment. - """ - editor: Actor - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! -} - -""" -A comment author association with repository. -""" -enum CommentAuthorAssociation { - """ - Author is a member of the organization that owns the repository. - """ - MEMBER - - """ - Author is the owner of the repository. - """ - OWNER - - """ - Author has been invited to collaborate on the repository. - """ - COLLABORATOR - - """ - Author has previously committed to the repository. - """ - CONTRIBUTOR - - """ - Author has not previously committed to the repository. - """ - FIRST_TIME_CONTRIBUTOR - - """ - Author has not previously committed to GitHub. - """ - FIRST_TIMER - - """ - Author has no association with the repository. - """ - NONE -} - -""" -The possible errors that will prevent a user from updating a comment. -""" -enum CommentCannotUpdateReason { - """ - You must be the author or have write access to this repository to update this comment. - """ - INSUFFICIENT_ACCESS - - """ - Unable to create comment because issue is locked. - """ - LOCKED - - """ - You must be logged in to update this comment. - """ - LOGIN_REQUIRED - - """ - Repository is under maintenance. - """ - MAINTENANCE - - """ - At least one email address must be verified to update this comment. - """ - VERIFIED_EMAIL_REQUIRED - - """ - You cannot update this comment - """ - DENIED -} - -""" -Represents a 'comment_deleted' event on a given issue or pull request. -""" -type CommentDeletedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! -} - -""" -Represents a Git commit. -""" -type Commit implements Node & GitObject & Subscribable & UniformResourceLocatable { - """ - An abbreviated version of the Git object ID - """ - abbreviatedOid: String! - - """ - The number of additions in this commit. - """ - additions: Int! - - """ - The pull requests associated with a commit - """ - associatedPullRequests( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for pull requests. - """ - orderBy: PullRequestOrder - ): PullRequestConnection - - """ - Authorship details of the commit. - """ - author: GitActor - - """ - Check if the committer and the author match. - """ - authoredByCommitter: Boolean! - - """ - The datetime when this commit was authored. - """ - authoredDate: DateTime! - - """ - Fetches `git blame` information. - """ - blame( - """ - The file whose Git blame information you want. - """ - path: String! - ): Blame! - - """ - The number of changed files in this commit. - """ - changedFiles: Int! - - """ - Comments made on the commit. - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): CommitCommentConnection! - - """ - The HTTP path for this Git object - """ - commitResourcePath: URI! - - """ - The HTTP URL for this Git object - """ - commitUrl: URI! - - """ - The datetime when this commit was committed. - """ - committedDate: DateTime! - - """ - Check if commited via GitHub web UI. - """ - committedViaWeb: Boolean! - - """ - Committership details of the commit. - """ - committer: GitActor - - """ - The number of deletions in this commit. - """ - deletions: Int! - - """ - The deployments associated with a commit. - """ - deployments( - """ - Environments to list deployments for - """ - environments: [String!] - - """ - Ordering options for deployments returned from the connection. - """ - orderBy: DeploymentOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): DeploymentConnection - - """ - The linear commit history starting from (and including) this commit, in the same order as `git log`. - """ - history( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - If non-null, filters history to only show commits touching files under this path. - """ - path: String - - """ - If non-null, filters history to only show commits with matching authorship. - """ - author: CommitAuthor - - """ - Allows specifying a beginning time or date for fetching commits. - """ - since: GitTimestamp - - """ - Allows specifying an ending time or date for fetching commits. - """ - until: GitTimestamp - ): CommitHistoryConnection! - id: ID! - - """ - The Git commit message - """ - message: String! - - """ - The Git commit message body - """ - messageBody: String! - - """ - The commit message body rendered to HTML. - """ - messageBodyHTML: HTML! - - """ - The Git commit message headline - """ - messageHeadline: String! - - """ - The commit message headline rendered to HTML. - """ - messageHeadlineHTML: HTML! - - """ - The Git object ID - """ - oid: GitObjectID! - - """ - The parents of a commit. - """ - parents( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): CommitConnection! - - """ - The datetime when this commit was pushed. - """ - pushedDate: DateTime - - """ - The Repository this commit belongs to - """ - repository: Repository! - - """ - The HTTP path for this commit - """ - resourcePath: URI! - - """ - Commit signing information, if present. - """ - signature: GitSignature - - """ - Status information for this commit - """ - status: Status - - """ - Returns a URL to download a tarball archive for a repository. - Note: For private repositories, these links are temporary and expire after five minutes. - """ - tarballUrl: URI! - - """ - Commit's root Tree - """ - tree: Tree! - - """ - The HTTP path for the tree of this commit - """ - treeResourcePath: URI! - - """ - The HTTP URL for the tree of this commit - """ - treeUrl: URI! - - """ - The HTTP URL for this commit - """ - url: URI! - - """ - Check if the viewer is able to change their subscription status for the repository. - """ - viewerCanSubscribe: Boolean! - - """ - Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. - """ - viewerSubscription: SubscriptionState - - """ - Returns a URL to download a zipball archive for a repository. - Note: For private repositories, these links are temporary and expire after five minutes. - """ - zipballUrl: URI! -} - -""" -Specifies an author for filtering Git commits. -""" -input CommitAuthor { - """ - ID of a User to filter by. If non-null, only commits authored by this user - will be returned. This field takes precedence over emails. - """ - id: ID - - """ - Email addresses to filter by. Commits authored by any of the specified email addresses will be returned. - """ - emails: [String!] -} - -""" -Represents a comment on a given Commit. -""" -type CommitComment implements Node & Comment & Deletable & Updatable & UpdatableComment & Reactable & RepositoryNode { - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the subject of the comment. - """ - authorAssociation: CommentAuthorAssociation! - - """ - Identifies the comment body. - """ - body: String! - - """ - Identifies the comment body rendered to HTML. - """ - bodyHTML: HTML! - - """ - The body rendered to text. - """ - bodyText: String! - - """ - Identifies the commit associated with the comment, if the commit exists. - """ - commit: Commit - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The actor who edited the comment. - """ - editor: Actor - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - Returns whether or not a comment has been minimized. - """ - isMinimized: Boolean! - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - Returns why the comment was minimized. - """ - minimizedReason: String - - """ - Identifies the file path associated with the comment. - """ - path: String - - """ - Identifies the line position associated with the comment. - """ - position: Int - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - A list of reactions grouped by content left on the subject. - """ - reactionGroups: [ReactionGroup!] - - """ - A list of Reactions left on the Issue. - """ - reactions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Allows filtering Reactions by emoji. - """ - content: ReactionContent - - """ - Allows specifying the order in which reactions are returned. - """ - orderBy: ReactionOrder - ): ReactionConnection! - - """ - The repository associated with this node. - """ - repository: Repository! - - """ - The HTTP path permalink for this commit comment. - """ - resourcePath: URI! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL permalink for this commit comment. - """ - url: URI! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Check if the current viewer can delete this object. - """ - viewerCanDelete: Boolean! - - """ - Check if the current viewer can minimize this object. - """ - viewerCanMinimize: Boolean! - - """ - Can user react to this subject - """ - viewerCanReact: Boolean! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! - - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! -} - -""" -The connection type for CommitComment. -""" -type CommitCommentConnection { - """ - A list of edges. - """ - edges: [CommitCommentEdge] - - """ - A list of nodes. - """ - nodes: [CommitComment] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type CommitCommentEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: CommitComment -} - -""" -A thread of comments on a commit. -""" -type CommitCommentThread implements Node & RepositoryNode { - """ - The comments that exist in this thread. - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): CommitCommentConnection! - - """ - The commit the comments were made on. - """ - commit: Commit! - id: ID! - - """ - The file the comments were made on. - """ - path: String - - """ - The position in the diff for the commit that the comment was made on. - """ - position: Int - - """ - The repository associated with this node. - """ - repository: Repository! -} - -""" -The connection type for Commit. -""" -type CommitConnection { - """ - A list of edges. - """ - edges: [CommitEdge] - - """ - A list of nodes. - """ - nodes: [Commit] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Ordering options for commit contribution connections. -""" -input CommitContributionOrder { - """ - The field by which to order commit contributions. - """ - field: CommitContributionOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which commit contribution connections can be ordered. -""" -enum CommitContributionOrderField { - """ - Order commit contributions by when they were made. - """ - OCCURRED_AT - - """ - Order commit contributions by how many commits they represent. - """ - COMMIT_COUNT -} - -""" -This aggregates commits made by a user within one repository. -""" -type CommitContributionsByRepository { - """ - The commit contributions, each representing a day. - """ - contributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for commit contributions returned from the connection. - """ - orderBy: CommitContributionOrder - ): CreatedCommitContributionConnection! - - """ - The repository in which the commits were made. - """ - repository: Repository! - - """ - The HTTP path for the user's commits to the repository in this time range. - """ - resourcePath: URI! - - """ - The HTTP URL for the user's commits to the repository in this time range. - """ - url: URI! -} - -""" -An edge in a connection. -""" -type CommitEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Commit -} - -""" -The connection type for Commit. -""" -type CommitHistoryConnection { - """ - A list of edges. - """ - edges: [CommitEdge] - - """ - A list of nodes. - """ - nodes: [Commit] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -A content attachment -""" -type ContentAttachment { - """ - The body text of the content attachment. This parameter supports markdown. - """ - body: String! - - """ - The content reference that the content attachment is attached to. - """ - contentReference: ContentReference! - - """ - Identifies the primary key from the database. - """ - databaseId: Int! - id: ID! - - """ - The title of the content attachment. - """ - title: String! -} - -""" -A content reference -""" -type ContentReference { - """ - Identifies the primary key from the database. - """ - databaseId: Int! - id: ID! - - """ - The reference of the content reference. - """ - reference: String! -} - -""" -Represents a contribution a user made on GitHub, such as opening an issue. -""" -interface Contribution { - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -A calendar of contributions made on GitHub by a user. -""" -type ContributionCalendar { - """ - A list of hex color codes used in this calendar. The darker the color, the more contributions it represents. - """ - colors: [String!]! - - """ - Determine if the color set was chosen because it's currently Halloween. - """ - isHalloween: Boolean! - - """ - A list of the months of contributions in this calendar. - """ - months: [ContributionCalendarMonth!]! - - """ - The count of total contributions in the calendar. - """ - totalContributions: Int! - - """ - A list of the weeks of contributions in this calendar. - """ - weeks: [ContributionCalendarWeek!]! -} - -""" -Represents a single day of contributions on GitHub by a user. -""" -type ContributionCalendarDay { - """ - The hex color code that represents how many contributions were made on this day compared to others in the calendar. - """ - color: String! - - """ - How many contributions were made by the user on this day. - """ - contributionCount: Int! - - """ - The day this square represents. - """ - date: Date! - - """ - A number representing which day of the week this square represents, e.g., 1 is Monday. - """ - weekday: Int! -} - -""" -A month of contributions in a user's contribution graph. -""" -type ContributionCalendarMonth { - """ - The date of the first day of this month. - """ - firstDay: Date! - - """ - The name of the month. - """ - name: String! - - """ - How many weeks started in this month. - """ - totalWeeks: Int! - - """ - The year the month occurred in. - """ - year: Int! -} - -""" -A week of contributions in a user's contribution graph. -""" -type ContributionCalendarWeek { - """ - The days of contributions in this week. - """ - contributionDays: [ContributionCalendarDay!]! - - """ - The date of the earliest square in this week. - """ - firstDay: Date! -} - -""" -Ordering options for contribution connections. -""" -input ContributionOrder { - """ - The field by which to order contributions. - """ - field: ContributionOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which contribution connections can be ordered. -""" -enum ContributionOrderField { - """ - Order contributions by when they were made. - """ - OCCURRED_AT -} - -""" -A contributions collection aggregates contributions such as opened issues and commits created by a user. -""" -type ContributionsCollection { - """ - Commit contributions made by the user, grouped by repository. - """ - commitContributionsByRepository( - """ - How many repositories should be included. - """ - maxRepositories: Int = 25 - ): [CommitContributionsByRepository!]! - - """ - A calendar of this user's contributions on GitHub. - """ - contributionCalendar: ContributionCalendar! - - """ - The years the user has been making contributions with the most recent year first. - """ - contributionYears: [Int!]! - - """ - Determine if this collection's time span ends in the current month. - """ - doesEndInCurrentMonth: Boolean! - - """ - The date of the first restricted contribution the user made in this time - period. Can only be non-null when the user has enabled private contribution counts. - """ - earliestRestrictedContributionDate: Date - - """ - The ending date and time of this collection. - """ - endedAt: DateTime! - - """ - The first issue the user opened on GitHub. This will be null if that issue was - opened outside the collection's time range and ignoreTimeRange is false. If - the issue is not visible but the user has opted to show private contributions, - a RestrictedContribution will be returned. - """ - firstIssueContribution( - """ - If true, the first issue will be returned even if it was opened outside of the collection's time range. - - **Upcoming Change on 2019-07-01 UTC** - **Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back - **Reason:** ignore_time_range will be removed - """ - ignoreTimeRange: Boolean = false - ): CreatedIssueOrRestrictedContribution - - """ - The first pull request the user opened on GitHub. This will be null if that - pull request was opened outside the collection's time range and - ignoreTimeRange is not true. If the pull request is not visible but the user - has opted to show private contributions, a RestrictedContribution will be returned. - """ - firstPullRequestContribution( - """ - If true, the first pull request will be returned even if it was opened outside of the collection's time range. - - **Upcoming Change on 2019-07-01 UTC** - **Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back - **Reason:** ignore_time_range will be removed - """ - ignoreTimeRange: Boolean = false - ): CreatedPullRequestOrRestrictedContribution - - """ - The first repository the user created on GitHub. This will be null if that - first repository was created outside the collection's time range and - ignoreTimeRange is false. If the repository is not visible, then a - RestrictedContribution is returned. - """ - firstRepositoryContribution( - """ - If true, the first repository will be returned even if it was opened outside of the collection's time range. - - **Upcoming Change on 2019-07-01 UTC** - **Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back - **Reason:** ignore_time_range will be removed - """ - ignoreTimeRange: Boolean = false - ): CreatedRepositoryOrRestrictedContribution - - """ - Does the user have any more activity in the timeline that occurred prior to the collection's time range? - """ - hasActivityInThePast: Boolean! - - """ - Determine if there are any contributions in this collection. - """ - hasAnyContributions: Boolean! - - """ - Determine if the user made any contributions in this time frame whose details - are not visible because they were made in a private repository. Can only be - true if the user enabled private contribution counts. - """ - hasAnyRestrictedContributions: Boolean! - - """ - Whether or not the collector's time span is all within the same day. - """ - isSingleDay: Boolean! - - """ - A list of issues the user opened. - """ - issueContributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Should the user's first issue ever be excluded from the result. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented issue be excluded from the result. - """ - excludePopular: Boolean = false - - """ - Ordering options for contributions returned from the connection. - """ - orderBy: ContributionOrder - ): CreatedIssueContributionConnection! - - """ - Issue contributions made by the user, grouped by repository. - """ - issueContributionsByRepository( - """ - How many repositories should be included. - """ - maxRepositories: Int = 25 - - """ - Should the user's first issue ever be excluded from the result. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented issue be excluded from the result. - """ - excludePopular: Boolean = false - ): [IssueContributionsByRepository!]! - - """ - When the user signed up for GitHub. This will be null if that sign up date - falls outside the collection's time range and ignoreTimeRange is false. - """ - joinedGitHubContribution( - """ - If true, the contribution will be returned even if the user signed up outside of the collection's time range. - - **Upcoming Change on 2019-07-01 UTC** - **Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back - **Reason:** ignore_time_range will be removed - """ - ignoreTimeRange: Boolean = false - ): JoinedGitHubContribution - - """ - The date of the most recent restricted contribution the user made in this time - period. Can only be non-null when the user has enabled private contribution counts. - """ - latestRestrictedContributionDate: Date - - """ - When this collection's time range does not include any activity from the user, use this - to get a different collection from an earlier time range that does have activity. - """ - mostRecentCollectionWithActivity: ContributionsCollection - - """ - Returns a different contributions collection from an earlier time range than this one - that does not have any contributions. - """ - mostRecentCollectionWithoutActivity: ContributionsCollection - - """ - The issue the user opened on GitHub that received the most comments in the specified - time frame. - """ - popularIssueContribution: CreatedIssueContribution - - """ - The pull request the user opened on GitHub that received the most comments in the - specified time frame. - """ - popularPullRequestContribution: CreatedPullRequestContribution - - """ - Pull request contributions made by the user. - """ - pullRequestContributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Should the user's first pull request ever be excluded from the result. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented pull request be excluded from the result. - """ - excludePopular: Boolean = false - - """ - Ordering options for contributions returned from the connection. - """ - orderBy: ContributionOrder - ): CreatedPullRequestContributionConnection! - - """ - Pull request contributions made by the user, grouped by repository. - """ - pullRequestContributionsByRepository( - """ - How many repositories should be included. - """ - maxRepositories: Int = 25 - - """ - Should the user's first pull request ever be excluded from the result. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented pull request be excluded from the result. - """ - excludePopular: Boolean = false - ): [PullRequestContributionsByRepository!]! - - """ - Pull request review contributions made by the user. - """ - pullRequestReviewContributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for contributions returned from the connection. - """ - orderBy: ContributionOrder - ): CreatedPullRequestReviewContributionConnection! - - """ - Pull request review contributions made by the user, grouped by repository. - """ - pullRequestReviewContributionsByRepository( - """ - How many repositories should be included. - """ - maxRepositories: Int = 25 - ): [PullRequestReviewContributionsByRepository!]! - - """ - A list of repositories owned by the user that the user created in this time range. - """ - repositoryContributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Should the user's first repository ever be excluded from the result. - """ - excludeFirst: Boolean = false - - """ - Ordering options for contributions returned from the connection. - """ - orderBy: ContributionOrder - ): CreatedRepositoryContributionConnection! - - """ - A count of contributions made by the user that the viewer cannot access. Only - non-zero when the user has chosen to share their private contribution counts. - """ - restrictedContributionsCount: Int! - - """ - The beginning date and time of this collection. - """ - startedAt: DateTime! - - """ - How many commits were made by the user in this time span. - """ - totalCommitContributions: Int! - - """ - How many issues the user opened. - """ - totalIssueContributions( - """ - Should the user's first issue ever be excluded from this count. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented issue be excluded from this count. - """ - excludePopular: Boolean = false - ): Int! - - """ - How many pull requests the user opened. - """ - totalPullRequestContributions( - """ - Should the user's first pull request ever be excluded from this count. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented pull request be excluded from this count. - """ - excludePopular: Boolean = false - ): Int! - - """ - How many pull request reviews the user left. - """ - totalPullRequestReviewContributions: Int! - - """ - How many different repositories the user committed to. - """ - totalRepositoriesWithContributedCommits: Int! - - """ - How many different repositories the user opened issues in. - """ - totalRepositoriesWithContributedIssues( - """ - Should the user's first issue ever be excluded from this count. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented issue be excluded from this count. - """ - excludePopular: Boolean = false - ): Int! - - """ - How many different repositories the user left pull request reviews in. - """ - totalRepositoriesWithContributedPullRequestReviews: Int! - - """ - How many different repositories the user opened pull requests in. - """ - totalRepositoriesWithContributedPullRequests( - """ - Should the user's first pull request ever be excluded from this count. - """ - excludeFirst: Boolean = false - - """ - Should the user's most commented pull request be excluded from this count. - """ - excludePopular: Boolean = false - ): Int! - - """ - How many repositories the user created. - """ - totalRepositoryContributions( - """ - Should the user's first repository ever be excluded from this count. - """ - excludeFirst: Boolean = false - ): Int! - - """ - The user who made the contributions in this collection. - """ - user: User! -} - -""" -Represents a 'converted_note_to_issue' event on a given issue or pull request. -""" -type ConvertedNoteToIssueEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! -} - -""" -Autogenerated input type of ConvertProjectCardNoteToIssue -""" -input ConvertProjectCardNoteToIssueInput { - """ - The ProjectCard ID to convert. - """ - projectCardId: ID! - - """ - The ID of the repository to create the issue in. - """ - repositoryId: ID! - - """ - The title of the newly created issue. Defaults to the card's note text. - """ - title: String - - """ - The body of the newly created issue. - """ - body: String - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of ConvertProjectCardNoteToIssue -""" -type ConvertProjectCardNoteToIssuePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated ProjectCard. - """ - projectCard: ProjectCard -} - -""" -Autogenerated input type of CreateBranchProtectionRule -""" -input CreateBranchProtectionRuleInput { - """ - The global relay id of the repository in which a new branch protection rule should be created in. - """ - repositoryId: ID! - - """ - The glob-like pattern used to determine matching branches. - """ - pattern: String! - - """ - Are approving reviews required to update matching branches. - """ - requiresApprovingReviews: Boolean - - """ - Number of approving reviews required to update matching branches. - """ - requiredApprovingReviewCount: Int - - """ - Are commits required to be signed. - """ - requiresCommitSignatures: Boolean - - """ - Can admins overwrite branch protection. - """ - isAdminEnforced: Boolean - - """ - Are status checks required to update matching branches. - """ - requiresStatusChecks: Boolean - - """ - Are branches required to be up to date before merging. - """ - requiresStrictStatusChecks: Boolean - - """ - Are reviews from code owners required to update matching branches. - """ - requiresCodeOwnerReviews: Boolean - - """ - Will new commits pushed to matching branches dismiss pull request review approvals. - """ - dismissesStaleReviews: Boolean - - """ - Is dismissal of pull request reviews restricted. - """ - restrictsReviewDismissals: Boolean - - """ - A list of User or Team IDs allowed to dismiss reviews on pull requests targeting matching branches. - """ - reviewDismissalActorIds: [ID!] - - """ - Is pushing to matching branches restricted. - """ - restrictsPushes: Boolean - - """ - A list of User or Team IDs allowed to push to matching branches. - """ - pushActorIds: [ID!] - - """ - List of required status check contexts that must pass for commits to be accepted to matching branches. - """ - requiredStatusCheckContexts: [String!] - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of CreateBranchProtectionRule -""" -type CreateBranchProtectionRulePayload { - """ - The newly created BranchProtectionRule. - """ - branchProtectionRule: BranchProtectionRule - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated input type of CreateContentAttachment -""" -input CreateContentAttachmentInput { - """ - The node ID of the content_reference. - """ - contentReferenceId: ID! - - """ - The title of the content attachment. - """ - title: String! - - """ - The body of the content attachment, which may contain markdown. - """ - body: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Represents the contribution a user made by committing to a repository. -""" -type CreatedCommitContribution implements Contribution { - """ - How many commits were made on this day to this repository by the user. - """ - commitCount: Int! - - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The repository the user made a commit in. - """ - repository: Repository! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -The connection type for CreatedCommitContribution. -""" -type CreatedCommitContributionConnection { - """ - A list of edges. - """ - edges: [CreatedCommitContributionEdge] - - """ - A list of nodes. - """ - nodes: [CreatedCommitContribution] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of commits across days and repositories in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type CreatedCommitContributionEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: CreatedCommitContribution -} - -""" -Represents the contribution a user made on GitHub by opening an issue. -""" -type CreatedIssueContribution implements Contribution { - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - The issue that was opened. - """ - issue: Issue! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -The connection type for CreatedIssueContribution. -""" -type CreatedIssueContributionConnection { - """ - A list of edges. - """ - edges: [CreatedIssueContributionEdge] - - """ - A list of nodes. - """ - nodes: [CreatedIssueContribution] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type CreatedIssueContributionEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: CreatedIssueContribution -} - -""" -Represents either a issue the viewer can access or a restricted contribution. -""" -union CreatedIssueOrRestrictedContribution = - CreatedIssueContribution - | RestrictedContribution - -""" -Represents the contribution a user made on GitHub by opening a pull request. -""" -type CreatedPullRequestContribution implements Contribution { - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The pull request that was opened. - """ - pullRequest: PullRequest! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -The connection type for CreatedPullRequestContribution. -""" -type CreatedPullRequestContributionConnection { - """ - A list of edges. - """ - edges: [CreatedPullRequestContributionEdge] - - """ - A list of nodes. - """ - nodes: [CreatedPullRequestContribution] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type CreatedPullRequestContributionEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: CreatedPullRequestContribution -} - -""" -Represents either a pull request the viewer can access or a restricted contribution. -""" -union CreatedPullRequestOrRestrictedContribution = - CreatedPullRequestContribution - | RestrictedContribution - -""" -Represents the contribution a user made by leaving a review on a pull request. -""" -type CreatedPullRequestReviewContribution implements Contribution { - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The pull request the user reviewed. - """ - pullRequest: PullRequest! - - """ - The review the user left on the pull request. - """ - pullRequestReview: PullRequestReview! - - """ - The repository containing the pull request that the user reviewed. - """ - repository: Repository! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -The connection type for CreatedPullRequestReviewContribution. -""" -type CreatedPullRequestReviewContributionConnection { - """ - A list of edges. - """ - edges: [CreatedPullRequestReviewContributionEdge] - - """ - A list of nodes. - """ - nodes: [CreatedPullRequestReviewContribution] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type CreatedPullRequestReviewContributionEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: CreatedPullRequestReviewContribution -} - -""" -Represents the contribution a user made on GitHub by creating a repository. -""" -type CreatedRepositoryContribution implements Contribution { - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The repository that was created. - """ - repository: Repository! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -The connection type for CreatedRepositoryContribution. -""" -type CreatedRepositoryContributionConnection { - """ - A list of edges. - """ - edges: [CreatedRepositoryContributionEdge] - - """ - A list of nodes. - """ - nodes: [CreatedRepositoryContribution] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type CreatedRepositoryContributionEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: CreatedRepositoryContribution -} - -""" -Represents either a repository the viewer can access or a restricted contribution. -""" -union CreatedRepositoryOrRestrictedContribution = - CreatedRepositoryContribution - | RestrictedContribution - -""" -Autogenerated input type of CreateIssue -""" -input CreateIssueInput { - """ - The Node ID of the repository. - """ - repositoryId: ID! - - """ - The title for the issue. - """ - title: String! - - """ - The body for the issue description. - """ - body: String - - """ - The Node ID for the user assignee for this issue. - """ - assigneeIds: [ID!] - - """ - The Node ID of the milestone for this issue. - """ - milestoneId: ID - - """ - An array of Node IDs of labels for this issue. - """ - labelIds: [ID!] - - """ - An array of Node IDs for projects associated with this issue. - """ - projectIds: [ID!] - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of CreateIssue -""" -type CreateIssuePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The new issue. - """ - issue: Issue -} - -""" -Autogenerated input type of CreateProject -""" -input CreateProjectInput { - """ - The owner ID to create the project under. - """ - ownerId: ID! - - """ - The name of project. - """ - name: String! - - """ - The description of project. - """ - body: String - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of CreateProject -""" -type CreateProjectPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The new project. - """ - project: Project -} - -""" -Autogenerated input type of CreatePullRequest -""" -input CreatePullRequestInput { - """ - The Node ID of the repository. - """ - repositoryId: ID! - - """ - The name of the branch you want your changes pulled into. This should be an existing branch - on the current repository. You cannot update the base branch on a pull request to point - to another repository. - """ - baseRefName: String! - - """ - The name of the branch where your changes are implemented. For cross-repository pull requests - in the same network, namespace `head_ref_name` with a user like this: `username:branch`. - """ - headRefName: String! - - """ - The title of the pull request. - """ - title: String! - - """ - The contents of the pull request. - """ - body: String - - """ - Indicates whether maintainers can modify the pull request. - """ - maintainerCanModify: Boolean = true - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of CreatePullRequest -""" -type CreatePullRequestPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The new pull request. - """ - pullRequest: PullRequest -} - -""" -Represents a mention made by one issue or pull request to another. -""" -type CrossReferencedEvent implements Node & UniformResourceLocatable { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Reference originated in a different repository. - """ - isCrossRepository: Boolean! - - """ - Identifies when the reference was made. - """ - referencedAt: DateTime! - - """ - The HTTP path for this pull request. - """ - resourcePath: URI! - - """ - Issue or pull request that made the reference. - """ - source: ReferencedSubject! - - """ - Issue or pull request to which the reference was made. - """ - target: ReferencedSubject! - - """ - The HTTP URL for this pull request. - """ - url: URI! - - """ - Checks if the target will be closed when the source is merged. - """ - willCloseTarget: Boolean! -} - -""" -An ISO-8601 encoded date string. -""" -scalar Date - -""" -An ISO-8601 encoded UTC date string. -""" -scalar DateTime - -""" -Autogenerated input type of DeclineTopicSuggestion -""" -input DeclineTopicSuggestionInput { - """ - The Node ID of the repository. - """ - repositoryId: ID! - - """ - The name of the suggested topic. - """ - name: String! - - """ - The reason why the suggested topic is declined. - """ - reason: TopicSuggestionDeclineReason! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeclineTopicSuggestion -""" -type DeclineTopicSuggestionPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The declined topic. - """ - topic: Topic -} - -""" -The possible default permissions for repositories. -""" -enum DefaultRepositoryPermissionField { - """ - No access - """ - NONE - - """ - Can read repos by default - """ - READ - - """ - Can read and write repos by default - """ - WRITE - - """ - Can read, write, and administrate repos by default - """ - ADMIN -} - -""" -Entities that can be deleted. -""" -interface Deletable { - """ - Check if the current viewer can delete this object. - """ - viewerCanDelete: Boolean! -} - -""" -Autogenerated input type of DeleteBranchProtectionRule -""" -input DeleteBranchProtectionRuleInput { - """ - The global relay id of the branch protection rule to be deleted. - """ - branchProtectionRuleId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeleteBranchProtectionRule -""" -type DeleteBranchProtectionRulePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated input type of DeleteIssueComment -""" -input DeleteIssueCommentInput { - """ - The ID of the comment to delete. - """ - id: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeleteIssueComment -""" -type DeleteIssueCommentPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated input type of DeleteIssue -""" -input DeleteIssueInput { - """ - The ID of the issue to delete. - """ - issueId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeleteIssue -""" -type DeleteIssuePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The repository the issue belonged to - """ - repository: Repository -} - -""" -Autogenerated input type of DeleteProjectCard -""" -input DeleteProjectCardInput { - """ - The id of the card to delete. - """ - cardId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeleteProjectCard -""" -type DeleteProjectCardPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The column the deleted card was in. - """ - column: ProjectColumn - - """ - The deleted card ID. - """ - deletedCardId: ID -} - -""" -Autogenerated input type of DeleteProjectColumn -""" -input DeleteProjectColumnInput { - """ - The id of the column to delete. - """ - columnId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeleteProjectColumn -""" -type DeleteProjectColumnPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The deleted column ID. - """ - deletedColumnId: ID - - """ - The project the deleted column was in. - """ - project: Project -} - -""" -Autogenerated input type of DeleteProject -""" -input DeleteProjectInput { - """ - The Project ID to update. - """ - projectId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeleteProject -""" -type DeleteProjectPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The repository or organization the project was removed from. - """ - owner: ProjectOwner -} - -""" -Autogenerated input type of DeletePullRequestReviewComment -""" -input DeletePullRequestReviewCommentInput { - """ - The ID of the comment to delete. - """ - id: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeletePullRequestReviewComment -""" -type DeletePullRequestReviewCommentPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The pull request review the deleted comment belonged to. - """ - pullRequestReview: PullRequestReview -} - -""" -Autogenerated input type of DeletePullRequestReview -""" -input DeletePullRequestReviewInput { - """ - The Node ID of the pull request review to delete. - """ - pullRequestReviewId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DeletePullRequestReview -""" -type DeletePullRequestReviewPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The deleted pull request review. - """ - pullRequestReview: PullRequestReview -} - -""" -Represents a 'demilestoned' event on a given issue or pull request. -""" -type DemilestonedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the milestone title associated with the 'demilestoned' event. - """ - milestoneTitle: String! - - """ - Object referenced by event. - """ - subject: MilestoneItem! -} - -""" -Represents a 'deployed' event on a given pull request. -""" -type DeployedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The deployment associated with the 'deployed' event. - """ - deployment: Deployment! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! - - """ - The ref associated with the 'deployed' event. - """ - ref: Ref -} - -""" -A repository deploy key. -""" -type DeployKey implements Node { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - The deploy key. - """ - key: String! - - """ - Whether or not the deploy key is read only. - """ - readOnly: Boolean! - - """ - The deploy key title. - """ - title: String! - - """ - Whether or not the deploy key has been verified. - """ - verified: Boolean! -} - -""" -The connection type for DeployKey. -""" -type DeployKeyConnection { - """ - A list of edges. - """ - edges: [DeployKeyEdge] - - """ - A list of nodes. - """ - nodes: [DeployKey] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type DeployKeyEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: DeployKey -} - -""" -Represents triggered deployment instance. -""" -type Deployment implements Node { - """ - Identifies the commit sha of the deployment. - """ - commit: Commit - - """ - Identifies the oid of the deployment commit, even if the commit has been deleted. - """ - commitOid: String! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the actor who triggered the deployment. - """ - creator: Actor - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The deployment description. - """ - description: String - - """ - The environment to which this deployment was made. - """ - environment: String - id: ID! - - """ - The latest status of this deployment. - """ - latestStatus: DeploymentStatus - - """ - Extra information that a deployment system might need. - """ - payload: String - - """ - Identifies the Ref of the deployment, if the deployment was created by ref. - """ - ref: Ref - - """ - Identifies the repository associated with the deployment. - """ - repository: Repository! - - """ - The current state of the deployment. - """ - state: DeploymentState - - """ - A list of statuses associated with the deployment. - """ - statuses( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): DeploymentStatusConnection - - """ - The deployment task. - """ - task: String - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! -} - -""" -The connection type for Deployment. -""" -type DeploymentConnection { - """ - A list of edges. - """ - edges: [DeploymentEdge] - - """ - A list of nodes. - """ - nodes: [Deployment] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type DeploymentEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Deployment -} - -""" -Represents a 'deployment_environment_changed' event on a given pull request. -""" -type DeploymentEnvironmentChangedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The deployment status that updated the deployment environment. - """ - deploymentStatus: DeploymentStatus! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! -} - -""" -Ordering options for deployment connections -""" -input DeploymentOrder { - """ - The field to order deployments by. - """ - field: DeploymentOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which deployment connections can be ordered. -""" -enum DeploymentOrderField { - """ - Order collection by creation time - """ - CREATED_AT -} - -""" -The possible states in which a deployment can be. -""" -enum DeploymentState { - """ - The pending deployment was not updated after 30 minutes. - """ - ABANDONED - - """ - The deployment is currently active. - """ - ACTIVE - - """ - An inactive transient deployment. - """ - DESTROYED - - """ - The deployment experienced an error. - """ - ERROR - - """ - The deployment has failed. - """ - FAILURE - - """ - The deployment is inactive. - """ - INACTIVE - - """ - The deployment is pending. - """ - PENDING - - """ - The deployment has queued - """ - QUEUED - - """ - The deployment is in progress. - """ - IN_PROGRESS -} - -""" -Describes the status of a given deployment attempt. -""" -type DeploymentStatus implements Node { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the actor who triggered the deployment. - """ - creator: Actor - - """ - Identifies the deployment associated with status. - """ - deployment: Deployment! - - """ - Identifies the description of the deployment. - """ - description: String - - """ - Identifies the environment URL of the deployment. - """ - environmentUrl: URI - id: ID! - - """ - Identifies the log URL of the deployment. - """ - logUrl: URI - - """ - Identifies the current state of the deployment. - """ - state: DeploymentStatusState! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! -} - -""" -The connection type for DeploymentStatus. -""" -type DeploymentStatusConnection { - """ - A list of edges. - """ - edges: [DeploymentStatusEdge] - - """ - A list of nodes. - """ - nodes: [DeploymentStatus] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type DeploymentStatusEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: DeploymentStatus -} - -""" -The possible states for a deployment status. -""" -enum DeploymentStatusState { - """ - The deployment is pending. - """ - PENDING - - """ - The deployment was successful. - """ - SUCCESS - - """ - The deployment has failed. - """ - FAILURE - - """ - The deployment is inactive. - """ - INACTIVE - - """ - The deployment experienced an error. - """ - ERROR - - """ - The deployment is queued - """ - QUEUED - - """ - The deployment is in progress. - """ - IN_PROGRESS -} - -""" -Autogenerated input type of DismissPullRequestReview -""" -input DismissPullRequestReviewInput { - """ - The Node ID of the pull request review to modify. - """ - pullRequestReviewId: ID! - - """ - The contents of the pull request review dismissal message. - """ - message: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of DismissPullRequestReview -""" -type DismissPullRequestReviewPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The dismissed pull request review. - """ - pullRequestReview: PullRequestReview -} - -""" -Specifies a review comment to be left with a Pull Request Review. -""" -input DraftPullRequestReviewComment { - """ - Path to the file being commented on. - """ - path: String! - - """ - Position in the file to leave a comment on. - """ - position: Int! - - """ - Body of the comment to leave. - """ - body: String! -} - -""" -An external identity provisioned by SAML SSO or SCIM. -""" -type ExternalIdentity implements Node { - """ - The GUID for this identity - """ - guid: String! - id: ID! - - """ - Organization invitation for this SCIM-provisioned external identity - """ - organizationInvitation: OrganizationInvitation - - """ - SAML Identity attributes - """ - samlIdentity: ExternalIdentitySamlAttributes - - """ - SCIM Identity attributes - """ - scimIdentity: ExternalIdentityScimAttributes - - """ - User linked to this external identity. Will be NULL if this identity has not been claimed by an organization member. - """ - user: User -} - -""" -The connection type for ExternalIdentity. -""" -type ExternalIdentityConnection { - """ - A list of edges. - """ - edges: [ExternalIdentityEdge] - - """ - A list of nodes. - """ - nodes: [ExternalIdentity] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ExternalIdentityEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: ExternalIdentity -} - -""" -SAML attributes for the External Identity -""" -type ExternalIdentitySamlAttributes { - """ - The NameID of the SAML identity - """ - nameId: String -} - -""" -SCIM attributes for the External Identity -""" -type ExternalIdentityScimAttributes { - """ - The userName of the SCIM identity - """ - username: String -} - -""" -The connection type for User. -""" -type FollowerConnection { - """ - A list of edges. - """ - edges: [UserEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -The connection type for User. -""" -type FollowingConnection { - """ - A list of edges. - """ - edges: [UserEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -A Gist. -""" -type Gist implements Node & Starrable { - """ - A list of comments associated with the gist - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): GistCommentConnection! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The gist description. - """ - description: String - - """ - The files in this gist. - """ - files( - """ - The maximum number of files to return. - """ - limit: Int = 10 - ): [GistFile] - id: ID! - - """ - Identifies if the gist is a fork. - """ - isFork: Boolean! - - """ - Whether the gist is public or not. - """ - isPublic: Boolean! - - """ - The gist name. - """ - name: String! - - """ - The gist owner. - """ - owner: RepositoryOwner - - """ - Identifies when the gist was last pushed to. - """ - pushedAt: DateTime - - """ - A list of users who have starred this starrable. - """ - stargazers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Order for connection - """ - orderBy: StarOrder - ): StargazerConnection! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - Returns a boolean indicating whether the viewing user has starred this starrable. - """ - viewerHasStarred: Boolean! -} - -""" -Represents a comment on an Gist. -""" -type GistComment implements Node & Comment & Deletable & Updatable & UpdatableComment { - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the gist. - """ - authorAssociation: CommentAuthorAssociation! - - """ - Identifies the comment body. - """ - body: String! - - """ - The comment body rendered to HTML. - """ - bodyHTML: HTML! - - """ - The body rendered to text. - """ - bodyText: String! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The actor who edited the comment. - """ - editor: Actor - - """ - The associated gist. - """ - gist: Gist! - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - Returns whether or not a comment has been minimized. - """ - isMinimized: Boolean! - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - Returns why the comment was minimized. - """ - minimizedReason: String - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Check if the current viewer can delete this object. - """ - viewerCanDelete: Boolean! - - """ - Check if the current viewer can minimize this object. - """ - viewerCanMinimize: Boolean! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! - - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! -} - -""" -The connection type for GistComment. -""" -type GistCommentConnection { - """ - A list of edges. - """ - edges: [GistCommentEdge] - - """ - A list of nodes. - """ - nodes: [GistComment] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type GistCommentEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: GistComment -} - -""" -The connection type for Gist. -""" -type GistConnection { - """ - A list of edges. - """ - edges: [GistEdge] - - """ - A list of nodes. - """ - nodes: [Gist] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type GistEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Gist -} - -""" -A file in a gist. -""" -type GistFile { - """ - The file name encoded to remove characters that are invalid in URL paths. - """ - encodedName: String - - """ - The gist file encoding. - """ - encoding: String - - """ - The file extension from the file name. - """ - extension: String - - """ - Indicates if this file is an image. - """ - isImage: Boolean! - - """ - Whether the file's contents were truncated. - """ - isTruncated: Boolean! - - """ - The programming language this file is written in. - """ - language: Language - - """ - The gist file name. - """ - name: String - - """ - The gist file size in bytes. - """ - size: Int - - """ - UTF8 text data or null if the file is binary - """ - text( - """ - Optionally truncate the returned file to this length. - """ - truncate: Int - ): String -} - -""" -Ordering options for gist connections -""" -input GistOrder { - """ - The field to order repositories by. - """ - field: GistOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which gist connections can be ordered. -""" -enum GistOrderField { - """ - Order gists by creation time - """ - CREATED_AT - - """ - Order gists by update time - """ - UPDATED_AT - - """ - Order gists by push time - """ - PUSHED_AT -} - -""" -The privacy of a Gist -""" -enum GistPrivacy { - """ - Public - """ - PUBLIC - - """ - Secret - """ - SECRET - - """ - Gists that are public and secret - """ - ALL -} - -""" -Represents an actor in a Git commit (ie. an author or committer). -""" -type GitActor { - """ - A URL pointing to the author's public avatar. - """ - avatarUrl( - """ - The size of the resulting square image. - """ - size: Int - ): URI! - - """ - The timestamp of the Git action (authoring or committing). - """ - date: GitTimestamp - - """ - The email in the Git commit. - """ - email: String - - """ - The name in the Git commit. - """ - name: String - - """ - The GitHub user corresponding to the email field. Null if no such user exists. - """ - user: User -} - -""" -Represents information about the GitHub instance. -""" -type GitHubMetadata { - """ - Returns a String that's a SHA of `github-services` - """ - gitHubServicesSha: GitObjectID! - - """ - IP addresses that users connect to for git operations - """ - gitIpAddresses: [String!] - - """ - IP addresses that service hooks are sent from - """ - hookIpAddresses: [String!] - - """ - IP addresses that the importer connects from - """ - importerIpAddresses: [String!] - - """ - Whether or not users are verified - """ - isPasswordAuthenticationVerifiable: Boolean! - - """ - IP addresses for GitHub Pages' A records - """ - pagesIpAddresses: [String!] -} - -""" -Represents a Git object. -""" -interface GitObject { - """ - An abbreviated version of the Git object ID - """ - abbreviatedOid: String! - - """ - The HTTP path for this Git object - """ - commitResourcePath: URI! - - """ - The HTTP URL for this Git object - """ - commitUrl: URI! - id: ID! - - """ - The Git object ID - """ - oid: GitObjectID! - - """ - The Repository the Git object belongs to - """ - repository: Repository! -} - -""" -A Git object ID. -""" -scalar GitObjectID - -""" -Information about a signature (GPG or S/MIME) on a Commit or Tag. -""" -interface GitSignature { - """ - Email used to sign this object. - """ - email: String! - - """ - True if the signature is valid and verified by GitHub. - """ - isValid: Boolean! - - """ - Payload for GPG signing object. Raw ODB object without the signature header. - """ - payload: String! - - """ - ASCII-armored signature header from object. - """ - signature: String! - - """ - GitHub user corresponding to the email signing this commit. - """ - signer: User - - """ - The state of this signature. `VALID` if signature is valid and verified by - GitHub, otherwise represents reason why signature is considered invalid. - """ - state: GitSignatureState! - - """ - True if the signature was made with GitHub's signing key. - """ - wasSignedByGitHub: Boolean! -} - -""" -The state of a Git signature. -""" -enum GitSignatureState { - """ - Valid signature and verified by GitHub - """ - VALID - - """ - Invalid signature - """ - INVALID - - """ - Malformed signature - """ - MALFORMED_SIG - - """ - Key used for signing not known to GitHub - """ - UNKNOWN_KEY - - """ - Invalid email used for signing - """ - BAD_EMAIL - - """ - Email used for signing unverified on GitHub - """ - UNVERIFIED_EMAIL - - """ - Email used for signing not known to GitHub - """ - NO_USER - - """ - Unknown signature type - """ - UNKNOWN_SIG_TYPE - - """ - Unsigned - """ - UNSIGNED - - """ - Internal error - the GPG verification service is unavailable at the moment - """ - GPGVERIFY_UNAVAILABLE - - """ - Internal error - the GPG verification service misbehaved - """ - GPGVERIFY_ERROR - - """ - The usage flags for the key that signed this don't allow signing - """ - NOT_SIGNING_KEY - - """ - Signing key expired - """ - EXPIRED_KEY - - """ - Valid signature, pending certificate revocation checking - """ - OCSP_PENDING - - """ - Valid siganture, though certificate revocation check failed - """ - OCSP_ERROR - - """ - The signing certificate or its chain could not be verified - """ - BAD_CERT - - """ - One or more certificates in chain has been revoked - """ - OCSP_REVOKED -} - -""" -Git SSH string -""" -scalar GitSSHRemote - -""" -An ISO-8601 encoded date string. Unlike the DateTime type, GitTimestamp is not converted in UTC. -""" -scalar GitTimestamp - -""" -Represents a GPG signature on a Commit or Tag. -""" -type GpgSignature implements GitSignature { - """ - Email used to sign this object. - """ - email: String! - - """ - True if the signature is valid and verified by GitHub. - """ - isValid: Boolean! - - """ - Hex-encoded ID of the key that signed this object. - """ - keyId: String - - """ - Payload for GPG signing object. Raw ODB object without the signature header. - """ - payload: String! - - """ - ASCII-armored signature header from object. - """ - signature: String! - - """ - GitHub user corresponding to the email signing this commit. - """ - signer: User - - """ - The state of this signature. `VALID` if signature is valid and verified by - GitHub, otherwise represents reason why signature is considered invalid. - """ - state: GitSignatureState! - - """ - True if the signature was made with GitHub's signing key. - """ - wasSignedByGitHub: Boolean! -} - -""" -Represents a 'head_ref_deleted' event on a given pull request. -""" -type HeadRefDeletedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the Ref associated with the `head_ref_deleted` event. - """ - headRef: Ref - - """ - Identifies the name of the Ref associated with the `head_ref_deleted` event. - """ - headRefName: String! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! -} - -""" -Represents a 'head_ref_force_pushed' event on a given pull request. -""" -type HeadRefForcePushedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the after commit SHA for the 'head_ref_force_pushed' event. - """ - afterCommit: Commit - - """ - Identifies the before commit SHA for the 'head_ref_force_pushed' event. - """ - beforeCommit: Commit - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! - - """ - Identifies the fully qualified ref name for the 'head_ref_force_pushed' event. - """ - ref: Ref -} - -""" -Represents a 'head_ref_restored' event on a given pull request. -""" -type HeadRefRestoredEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! -} - -""" -A string containing HTML code. -""" -scalar HTML - -""" -The possible states in which authentication can be configured with an identity provider. -""" -enum IdentityProviderConfigurationState { - """ - Authentication with an identity provider is configured and enforced. - """ - ENFORCED - - """ - Authentication with an identity provider is configured but not enforced. - """ - CONFIGURED - - """ - Authentication with an identity provider is not configured. - """ - UNCONFIGURED -} - -""" -Autogenerated input type of ImportProject -""" -input ImportProjectInput { - """ - The name of the Organization or User to create the Project under. - """ - ownerName: String! - - """ - The name of Project. - """ - name: String! - - """ - The description of Project. - """ - body: String - - """ - Whether the Project is public or not. - """ - public: Boolean = false - - """ - A list of columns containing issues and pull requests. - """ - columnImports: [ProjectColumnImport!]! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -An Issue is a place to discuss ideas, enhancements, tasks, and bugs for a project. -""" -type Issue implements Node & Assignable & Closable & Comment & Updatable & UpdatableComment & Labelable & Lockable & Reactable & RepositoryNode & Subscribable & UniformResourceLocatable { - """ - Reason that the conversation was locked. - """ - activeLockReason: LockReason - - """ - A list of Users assigned to this object. - """ - assignees( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! - - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the subject of the comment. - """ - authorAssociation: CommentAuthorAssociation! - - """ - Identifies the body of the issue. - """ - body: String! - - """ - Identifies the body of the issue rendered to HTML. - """ - bodyHTML: HTML! - - """ - Identifies the body of the issue rendered to text. - """ - bodyText: String! - - """ - `true` if the object is closed (definition of closed may depend on type) - """ - closed: Boolean! - - """ - Identifies the date and time when the object was closed. - """ - closedAt: DateTime - - """ - A list of comments associated with the Issue. - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueCommentConnection! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The actor who edited the comment. - """ - editor: Actor - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - A list of labels associated with the object. - """ - labels( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): LabelConnection - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - `true` if the object is locked - """ - locked: Boolean! - - """ - Identifies the milestone associated with the issue. - """ - milestone: Milestone - - """ - Identifies the issue number. - """ - number: Int! - - """ - A list of Users that are participating in the Issue conversation. - """ - participants( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! - - """ - List of project cards associated with this issue. - """ - projectCards( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - A list of archived states to filter the cards by - """ - archivedStates: [ProjectCardArchivedState] - ): ProjectCardConnection! - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - A list of reactions grouped by content left on the subject. - """ - reactionGroups: [ReactionGroup!] - - """ - A list of Reactions left on the Issue. - """ - reactions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Allows filtering Reactions by emoji. - """ - content: ReactionContent - - """ - Allows specifying the order in which reactions are returned. - """ - orderBy: ReactionOrder - ): ReactionConnection! - - """ - The repository associated with this node. - """ - repository: Repository! - - """ - The HTTP path for this issue - """ - resourcePath: URI! - - """ - Identifies the state of the issue. - """ - state: IssueState! - - """ - A list of events, comments, commits, etc. associated with the issue. - """ - timeline( - """ - Allows filtering timeline events by a `since` timestamp. - """ - since: DateTime - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueTimelineConnection! - - """ - A list of events, comments, commits, etc. associated with the issue. - """ - timelineItems( - """ - Filter timeline items by a `since` timestamp. - """ - since: DateTime - - """ - Skips the first _n_ elements in the list. - """ - skip: Int - - """ - Filter timeline items by type. - """ - itemTypes: [IssueTimelineItemsItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueTimelineItemsConnection! - - """ - Identifies the issue title. - """ - title: String! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this issue - """ - url: URI! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Can user react to this subject - """ - viewerCanReact: Boolean! - - """ - Check if the viewer is able to change their subscription status for the repository. - """ - viewerCanSubscribe: Boolean! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! - - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! - - """ - Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. - """ - viewerSubscription: SubscriptionState -} - -""" -Represents a comment on an Issue. -""" -type IssueComment implements Node & Comment & Deletable & Updatable & UpdatableComment & Reactable & RepositoryNode { - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the subject of the comment. - """ - authorAssociation: CommentAuthorAssociation! - - """ - The body as Markdown. - """ - body: String! - - """ - The body rendered to HTML. - """ - bodyHTML: HTML! - - """ - The body rendered to text. - """ - bodyText: String! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The actor who edited the comment. - """ - editor: Actor - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - Returns whether or not a comment has been minimized. - """ - isMinimized: Boolean! - - """ - Identifies the issue associated with the comment. - """ - issue: Issue! - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - Returns why the comment was minimized. - """ - minimizedReason: String - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - Returns the pull request associated with the comment, if this comment was made on a - pull request. - """ - pullRequest: PullRequest - - """ - A list of reactions grouped by content left on the subject. - """ - reactionGroups: [ReactionGroup!] - - """ - A list of Reactions left on the Issue. - """ - reactions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Allows filtering Reactions by emoji. - """ - content: ReactionContent - - """ - Allows specifying the order in which reactions are returned. - """ - orderBy: ReactionOrder - ): ReactionConnection! - - """ - The repository associated with this node. - """ - repository: Repository! - - """ - The HTTP path for this issue comment - """ - resourcePath: URI! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this issue comment - """ - url: URI! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Check if the current viewer can delete this object. - """ - viewerCanDelete: Boolean! - - """ - Check if the current viewer can minimize this object. - """ - viewerCanMinimize: Boolean! - - """ - Can user react to this subject - """ - viewerCanReact: Boolean! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! - - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! -} - -""" -The connection type for IssueComment. -""" -type IssueCommentConnection { - """ - A list of edges. - """ - edges: [IssueCommentEdge] - - """ - A list of nodes. - """ - nodes: [IssueComment] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type IssueCommentEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: IssueComment -} - -""" -The connection type for Issue. -""" -type IssueConnection { - """ - A list of edges. - """ - edges: [IssueEdge] - - """ - A list of nodes. - """ - nodes: [Issue] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -This aggregates issues opened by a user within one repository. -""" -type IssueContributionsByRepository { - """ - The issue contributions. - """ - contributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for contributions returned from the connection. - """ - orderBy: ContributionOrder - ): CreatedIssueContributionConnection! - - """ - The repository in which the issues were opened. - """ - repository: Repository! -} - -""" -An edge in a connection. -""" -type IssueEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Issue -} - -""" -Ways in which to filter lists of issues. -""" -input IssueFilters { - """ - List issues assigned to given name. Pass in `null` for issues with no assigned - user, and `*` for issues assigned to any user. - """ - assignee: String - - """ - List issues created by given name. - """ - createdBy: String - - """ - List issues where the list of label names exist on the issue. - """ - labels: [String!] - - """ - List issues where the given name is mentioned in the issue. - """ - mentioned: String - - """ - List issues by given milestone argument. If an string representation of an - integer is passed, it should refer to a milestone by its number field. Pass in - `null` for issues with no milestone, and `*` for issues that are assigned to any milestone. - """ - milestone: String - - """ - List issues that have been updated at or after the given date. - """ - since: DateTime - - """ - List issues filtered by the list of states given. - """ - states: [IssueState!] - - """ - List issues subscribed to by viewer. - """ - viewerSubscribed: Boolean = false -} - -""" -Ways in which lists of issues can be ordered upon return. -""" -input IssueOrder { - """ - The field in which to order issues by. - """ - field: IssueOrderField! - - """ - The direction in which to order issues by the specified field. - """ - direction: OrderDirection! -} - -""" -Properties by which issue connections can be ordered. -""" -enum IssueOrderField { - """ - Order issues by creation time - """ - CREATED_AT - - """ - Order issues by update time - """ - UPDATED_AT - - """ - Order issues by comment count - """ - COMMENTS -} - -""" -Used for return value of Repository.issueOrPullRequest. -""" -union IssueOrPullRequest = Issue | PullRequest - -""" -The possible PubSub channels for an issue. -""" -enum IssuePubSubTopic { - """ - The channel ID for observing issue updates. - """ - UPDATED - - """ - The channel ID for marking an issue as read. - """ - MARKASREAD - - """ - The channel ID for updating items on the issue timeline. - """ - TIMELINE - - """ - The channel ID for observing issue state updates. - """ - STATE -} - -""" -The possible states of an issue. -""" -enum IssueState { - """ - An issue that is still open - """ - OPEN - - """ - An issue that has been closed - """ - CLOSED -} - -""" -The connection type for IssueTimelineItem. -""" -type IssueTimelineConnection { - """ - A list of edges. - """ - edges: [IssueTimelineItemEdge] - - """ - A list of nodes. - """ - nodes: [IssueTimelineItem] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An item in an issue timeline -""" -union IssueTimelineItem = - Commit - | IssueComment - | CrossReferencedEvent - | ClosedEvent - | ReopenedEvent - | SubscribedEvent - | UnsubscribedEvent - | ReferencedEvent - | AssignedEvent - | UnassignedEvent - | LabeledEvent - | UnlabeledEvent - | UserBlockedEvent - | MilestonedEvent - | DemilestonedEvent - | RenamedTitleEvent - | LockedEvent - | UnlockedEvent - | TransferredEvent - -""" -An edge in a connection. -""" -type IssueTimelineItemEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: IssueTimelineItem -} - -""" -An item in an issue timeline -""" -union IssueTimelineItems = - IssueComment - | CrossReferencedEvent - | AddedToProjectEvent - | AssignedEvent - | ClosedEvent - | CommentDeletedEvent - | ConvertedNoteToIssueEvent - | DemilestonedEvent - | LabeledEvent - | LockedEvent - | MentionedEvent - | MilestonedEvent - | MovedColumnsInProjectEvent - | PinnedEvent - | ReferencedEvent - | RemovedFromProjectEvent - | RenamedTitleEvent - | ReopenedEvent - | SubscribedEvent - | TransferredEvent - | UnassignedEvent - | UnlabeledEvent - | UnlockedEvent - | UserBlockedEvent - | UnpinnedEvent - | UnsubscribedEvent - -""" -The connection type for IssueTimelineItems. -""" -type IssueTimelineItemsConnection { - """ - A list of edges. - """ - edges: [IssueTimelineItemsEdge] - - """ - Identifies the count of items after applying `before` and `after` filters. - """ - filteredCount: Int! - - """ - A list of nodes. - """ - nodes: [IssueTimelineItems] - - """ - Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing. - """ - pageCount: Int! - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! - - """ - Identifies the date and time when the timeline was last updated. - """ - updatedAt: DateTime! -} - -""" -An edge in a connection. -""" -type IssueTimelineItemsEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: IssueTimelineItems -} - -""" -The possible item types found in a timeline. -""" -enum IssueTimelineItemsItemType { - """ - Represents a comment on an Issue. - """ - ISSUE_COMMENT - - """ - Represents a mention made by one issue or pull request to another. - """ - CROSS_REFERENCED_EVENT - - """ - Represents a 'added_to_project' event on a given issue or pull request. - """ - ADDED_TO_PROJECT_EVENT - - """ - Represents an 'assigned' event on any assignable object. - """ - ASSIGNED_EVENT - - """ - Represents a 'closed' event on any `Closable`. - """ - CLOSED_EVENT - - """ - Represents a 'comment_deleted' event on a given issue or pull request. - """ - COMMENT_DELETED_EVENT - - """ - Represents a 'converted_note_to_issue' event on a given issue or pull request. - """ - CONVERTED_NOTE_TO_ISSUE_EVENT - - """ - Represents a 'demilestoned' event on a given issue or pull request. - """ - DEMILESTONED_EVENT - - """ - Represents a 'labeled' event on a given issue or pull request. - """ - LABELED_EVENT - - """ - Represents a 'locked' event on a given issue or pull request. - """ - LOCKED_EVENT - - """ - Represents a 'mentioned' event on a given issue or pull request. - """ - MENTIONED_EVENT - - """ - Represents a 'milestoned' event on a given issue or pull request. - """ - MILESTONED_EVENT - - """ - Represents a 'moved_columns_in_project' event on a given issue or pull request. - """ - MOVED_COLUMNS_IN_PROJECT_EVENT - - """ - Represents a 'pinned' event on a given issue or pull request. - """ - PINNED_EVENT - - """ - Represents a 'referenced' event on a given `ReferencedSubject`. - """ - REFERENCED_EVENT - - """ - Represents a 'removed_from_project' event on a given issue or pull request. - """ - REMOVED_FROM_PROJECT_EVENT - - """ - Represents a 'renamed' event on a given issue or pull request - """ - RENAMED_TITLE_EVENT - - """ - Represents a 'reopened' event on any `Closable`. - """ - REOPENED_EVENT - - """ - Represents a 'subscribed' event on a given `Subscribable`. - """ - SUBSCRIBED_EVENT - - """ - Represents a 'transferred' event on a given issue or pull request. - """ - TRANSFERRED_EVENT - - """ - Represents an 'unassigned' event on any assignable object. - """ - UNASSIGNED_EVENT - - """ - Represents an 'unlabeled' event on a given issue or pull request. - """ - UNLABELED_EVENT - - """ - Represents an 'unlocked' event on a given issue or pull request. - """ - UNLOCKED_EVENT - - """ - Represents a 'user_blocked' event on a given user. - """ - USER_BLOCKED_EVENT - - """ - Represents an 'unpinned' event on a given issue or pull request. - """ - UNPINNED_EVENT - - """ - Represents an 'unsubscribed' event on a given `Subscribable`. - """ - UNSUBSCRIBED_EVENT -} - -""" -Represents a user signing up for a GitHub account. -""" -type JoinedGitHubContribution implements Contribution { - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -A label for categorizing Issues or Milestones with a given Repository. -""" -type Label implements Node { - """ - Identifies the label color. - """ - color: String! - - """ - Identifies the date and time when the label was created. - """ - createdAt: DateTime - - """ - A brief description of this label. - """ - description: String - id: ID! - - """ - Indicates whether or not this is a default label. - """ - isDefault: Boolean! - - """ - A list of issues associated with this label. - """ - issues( - """ - Ordering options for issues returned from the connection. - """ - orderBy: IssueOrder - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - A list of states to filter the issues by. - """ - states: [IssueState!] - - """ - Filtering options for issues returned from the connection. - """ - filterBy: IssueFilters - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueConnection! - - """ - Identifies the label name. - """ - name: String! - - """ - A list of pull requests associated with this label. - """ - pullRequests( - """ - A list of states to filter the pull requests by. - """ - states: [PullRequestState!] - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - The head ref name to filter the pull requests by. - """ - headRefName: String - - """ - The base ref name to filter the pull requests by. - """ - baseRefName: String - - """ - Ordering options for pull requests returned from the connection. - """ - orderBy: IssueOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestConnection! - - """ - The repository associated with this label. - """ - repository: Repository! - - """ - The HTTP path for this label. - """ - resourcePath: URI! - - """ - Identifies the date and time when the label was last updated. - """ - updatedAt: DateTime - - """ - The HTTP URL for this label. - """ - url: URI! -} - -""" -An object that can have labels assigned to it. -""" -interface Labelable { - """ - A list of labels associated with the object. - """ - labels( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): LabelConnection -} - -""" -The connection type for Label. -""" -type LabelConnection { - """ - A list of edges. - """ - edges: [LabelEdge] - - """ - A list of nodes. - """ - nodes: [Label] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a 'labeled' event on a given issue or pull request. -""" -type LabeledEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the label associated with the 'labeled' event. - """ - label: Label! - - """ - Identifies the `Labelable` associated with the event. - """ - labelable: Labelable! -} - -""" -An edge in a connection. -""" -type LabelEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Label -} - -""" -Represents a given language found in repositories. -""" -type Language implements Node { - """ - The color defined for the current language. - """ - color: String - id: ID! - - """ - The name of the current language. - """ - name: String! -} - -""" -A list of languages associated with the parent. -""" -type LanguageConnection { - """ - A list of edges. - """ - edges: [LanguageEdge] - - """ - A list of nodes. - """ - nodes: [Language] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! - - """ - The total size in bytes of files written in that language. - """ - totalSize: Int! -} - -""" -Represents the language of a repository. -""" -type LanguageEdge { - cursor: String! - node: Language! - - """ - The number of bytes of code written in the language. - """ - size: Int! -} - -""" -Ordering options for language connections. -""" -input LanguageOrder { - """ - The field to order languages by. - """ - field: LanguageOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which language connections can be ordered. -""" -enum LanguageOrderField { - """ - Order languages by the size of all files containing the language - """ - SIZE -} - -""" -A repository's open source license -""" -type License implements Node { - """ - The full text of the license - """ - body: String! - - """ - The conditions set by the license - """ - conditions: [LicenseRule]! - - """ - A human-readable description of the license - """ - description: String - - """ - Whether the license should be featured - """ - featured: Boolean! - - """ - Whether the license should be displayed in license pickers - """ - hidden: Boolean! - id: ID! - - """ - Instructions on how to implement the license - """ - implementation: String - - """ - The lowercased SPDX ID of the license - """ - key: String! - - """ - The limitations set by the license - """ - limitations: [LicenseRule]! - - """ - The license full name specified by - """ - name: String! - - """ - Customary short name if applicable (e.g, GPLv3) - """ - nickname: String - - """ - The permissions set by the license - """ - permissions: [LicenseRule]! - - """ - Whether the license is a pseudo-license placeholder (e.g., other, no-license) - """ - pseudoLicense: Boolean! - - """ - Short identifier specified by - """ - spdxId: String - - """ - URL to the license on - """ - url: URI -} - -""" -Describes a License's conditions, permissions, and limitations -""" -type LicenseRule { - """ - A description of the rule - """ - description: String! - - """ - The machine-readable rule key - """ - key: String! - - """ - The human-readable rule label - """ - label: String! -} - -""" -An object that can be locked. -""" -interface Lockable { - """ - Reason that the conversation was locked. - """ - activeLockReason: LockReason - - """ - `true` if the object is locked - """ - locked: Boolean! -} - -""" -Represents a 'locked' event on a given issue or pull request. -""" -type LockedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Reason that the conversation was locked (optional). - """ - lockReason: LockReason - - """ - Object that was locked. - """ - lockable: Lockable! -} - -""" -Autogenerated input type of LockLockable -""" -input LockLockableInput { - """ - ID of the issue or pull request to be locked. - """ - lockableId: ID! - - """ - A reason for why the issue or pull request will be locked. - """ - lockReason: LockReason - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of LockLockable -""" -type LockLockablePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The item that was locked. - """ - lockedRecord: Lockable -} - -""" -The possible reasons that an issue or pull request was locked. -""" -enum LockReason { - """ - The issue or pull request was locked because the conversation was off-topic. - """ - OFF_TOPIC - - """ - The issue or pull request was locked because the conversation was too heated. - """ - TOO_HEATED - - """ - The issue or pull request was locked because the conversation was resolved. - """ - RESOLVED - - """ - The issue or pull request was locked because the conversation was spam. - """ - SPAM -} - -""" -A placeholder user for attribution of imported data on GitHub. -""" -type Mannequin implements Node & Actor & UniformResourceLocatable { - """ - A URL pointing to the GitHub App's public avatar. - """ - avatarUrl( - """ - The size of the resulting square image. - """ - size: Int - ): URI! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - The username of the actor. - """ - login: String! - - """ - The HTML path to this resource. - """ - resourcePath: URI! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The URL to this resource. - """ - url: URI! -} - -""" -A public description of a Marketplace category. -""" -type MarketplaceCategory implements Node { - """ - The category's description. - """ - description: String - - """ - The technical description of how apps listed in this category work with GitHub. - """ - howItWorks: String - id: ID! - - """ - The category's name. - """ - name: String! - - """ - How many Marketplace listings have this as their primary category. - """ - primaryListingCount: Int! - - """ - The HTTP path for this Marketplace category. - """ - resourcePath: URI! - - """ - How many Marketplace listings have this as their secondary category. - """ - secondaryListingCount: Int! - - """ - The short name of the category used in its URL. - """ - slug: String! - - """ - The HTTP URL for this Marketplace category. - """ - url: URI! -} - -""" -A listing in the GitHub integration marketplace. -""" -type MarketplaceListing implements Node { - """ - The GitHub App this listing represents. - """ - app: App - - """ - URL to the listing owner's company site. - """ - companyUrl: URI - - """ - The HTTP path for configuring access to the listing's integration or OAuth app - """ - configurationResourcePath: URI! - - """ - The HTTP URL for configuring access to the listing's integration or OAuth app - """ - configurationUrl: URI! - - """ - URL to the listing's documentation. - """ - documentationUrl: URI - - """ - The listing's detailed description. - """ - extendedDescription: String - - """ - The listing's detailed description rendered to HTML. - """ - extendedDescriptionHTML: HTML! - - """ - The listing's introductory description. - """ - fullDescription: String! - - """ - The listing's introductory description rendered to HTML. - """ - fullDescriptionHTML: HTML! - - """ - Whether this listing has been submitted for review from GitHub for approval to be displayed in the Marketplace. - """ - hasApprovalBeenRequested: Boolean! - @deprecated( - reason: "`hasApprovalBeenRequested` will be removed. Use `isVerificationPendingFromDraft` instead. Removal on 2019-10-01 UTC." - ) - - """ - Does this listing have any plans with a free trial? - """ - hasPublishedFreeTrialPlans: Boolean! - - """ - Does this listing have a terms of service link? - """ - hasTermsOfService: Boolean! - - """ - A technical description of how this app works with GitHub. - """ - howItWorks: String - - """ - The listing's technical description rendered to HTML. - """ - howItWorksHTML: HTML! - id: ID! - - """ - URL to install the product to the viewer's account or organization. - """ - installationUrl: URI - - """ - Whether this listing's app has been installed for the current viewer - """ - installedForViewer: Boolean! - - """ - Whether this listing has been approved for display in the Marketplace. - """ - isApproved: Boolean! - @deprecated( - reason: "`isApproved` will be removed. Use `isPublic` instead. Removal on 2019-10-01 UTC." - ) - - """ - Whether this listing has been removed from the Marketplace. - """ - isArchived: Boolean! - - """ - Whether this listing has been removed from the Marketplace. - """ - isDelisted: Boolean! - @deprecated( - reason: "`isDelisted` will be removed. Use `isArchived` instead. Removal on 2019-10-01 UTC." - ) - - """ - Whether this listing is still an editable draft that has not been submitted - for review and is not publicly visible in the Marketplace. - """ - isDraft: Boolean! - - """ - Whether the product this listing represents is available as part of a paid plan. - """ - isPaid: Boolean! - - """ - Whether this listing has been approved for display in the Marketplace. - """ - isPublic: Boolean! - - """ - Whether this listing has been rejected by GitHub for display in the Marketplace. - """ - isRejected: Boolean! - - """ - Whether this listing has been approved for unverified display in the Marketplace. - """ - isUnverified: Boolean! - - """ - Whether this draft listing has been submitted for review for approval to be unverified in the Marketplace. - """ - isUnverifiedPending: Boolean! - - """ - Whether this draft listing has been submitted for review from GitHub for approval to be verified in the Marketplace. - """ - isVerificationPendingFromDraft: Boolean! - - """ - Whether this unverified listing has been submitted for review from GitHub for approval to be verified in the Marketplace. - """ - isVerificationPendingFromUnverified: Boolean! - - """ - Whether this listing has been approved for verified display in the Marketplace. - """ - isVerified: Boolean! - - """ - The hex color code, without the leading '#', for the logo background. - """ - logoBackgroundColor: String! - - """ - URL for the listing's logo image. - """ - logoUrl( - """ - The size in pixels of the resulting square image. - """ - size: Int = 400 - ): URI - - """ - The listing's full name. - """ - name: String! - - """ - The listing's very short description without a trailing period or ampersands. - """ - normalizedShortDescription: String! - - """ - URL to the listing's detailed pricing. - """ - pricingUrl: URI - - """ - The category that best describes the listing. - """ - primaryCategory: MarketplaceCategory! - - """ - URL to the listing's privacy policy, may return an empty string for listings that do not require a privacy policy URL. - """ - privacyPolicyUrl: URI! - - """ - The HTTP path for the Marketplace listing. - """ - resourcePath: URI! - - """ - The URLs for the listing's screenshots. - """ - screenshotUrls: [String]! - - """ - An alternate category that describes the listing. - """ - secondaryCategory: MarketplaceCategory - - """ - The listing's very short description. - """ - shortDescription: String! - - """ - The short name of the listing used in its URL. - """ - slug: String! - - """ - URL to the listing's status page. - """ - statusUrl: URI - - """ - An email address for support for this listing's app. - """ - supportEmail: String - - """ - Either a URL or an email address for support for this listing's app, may - return an empty string for listings that do not require a support URL. - """ - supportUrl: URI! - - """ - URL to the listing's terms of service. - """ - termsOfServiceUrl: URI - - """ - The HTTP URL for the Marketplace listing. - """ - url: URI! - - """ - Can the current viewer add plans for this Marketplace listing. - """ - viewerCanAddPlans: Boolean! - - """ - Can the current viewer approve this Marketplace listing. - """ - viewerCanApprove: Boolean! - - """ - Can the current viewer delist this Marketplace listing. - """ - viewerCanDelist: Boolean! - - """ - Can the current viewer edit this Marketplace listing. - """ - viewerCanEdit: Boolean! - - """ - Can the current viewer edit the primary and secondary category of this - Marketplace listing. - """ - viewerCanEditCategories: Boolean! - - """ - Can the current viewer edit the plans for this Marketplace listing. - """ - viewerCanEditPlans: Boolean! - - """ - Can the current viewer return this Marketplace listing to draft state - so it becomes editable again. - """ - viewerCanRedraft: Boolean! - - """ - Can the current viewer reject this Marketplace listing by returning it to - an editable draft state or rejecting it entirely. - """ - viewerCanReject: Boolean! - - """ - Can the current viewer request this listing be reviewed for display in - the Marketplace as verified. - """ - viewerCanRequestApproval: Boolean! - - """ - Indicates whether the current user has an active subscription to this Marketplace listing. - """ - viewerHasPurchased: Boolean! - - """ - Indicates if the current user has purchased a subscription to this Marketplace listing - for all of the organizations the user owns. - """ - viewerHasPurchasedForAllOrganizations: Boolean! - - """ - Does the current viewer role allow them to administer this Marketplace listing. - """ - viewerIsListingAdmin: Boolean! -} - -""" -Look up Marketplace Listings -""" -type MarketplaceListingConnection { - """ - A list of edges. - """ - edges: [MarketplaceListingEdge] - - """ - A list of nodes. - """ - nodes: [MarketplaceListing] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type MarketplaceListingEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: MarketplaceListing -} - -""" -Entities that have members who can set status messages. -""" -interface MemberStatusable { - """ - Get the status messages members of this entity have set that are either public or visible only to the organization. - """ - memberStatuses( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for user statuses returned from the connection. - """ - orderBy: UserStatusOrder - ): UserStatusConnection! -} - -""" -Represents a 'mentioned' event on a given issue or pull request. -""" -type MentionedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! -} - -""" -Whether or not a PullRequest can be merged. -""" -enum MergeableState { - """ - The pull request can be merged. - """ - MERGEABLE - - """ - The pull request cannot be merged due to merge conflicts. - """ - CONFLICTING - - """ - The mergeability of the pull request is still being calculated. - """ - UNKNOWN -} - -""" -Represents a 'merged' event on a given pull request. -""" -type MergedEvent implements Node & UniformResourceLocatable { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the commit associated with the `merge` event. - """ - commit: Commit - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the Ref associated with the `merge` event. - """ - mergeRef: Ref - - """ - Identifies the name of the Ref associated with the `merge` event. - """ - mergeRefName: String! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! - - """ - The HTTP path for this merged event. - """ - resourcePath: URI! - - """ - The HTTP URL for this merged event. - """ - url: URI! -} - -""" -Autogenerated input type of MergePullRequest -""" -input MergePullRequestInput { - """ - ID of the pull request to be merged. - """ - pullRequestId: ID! - - """ - Commit headline to use for the merge commit; if omitted, a default message will be used. - """ - commitHeadline: String - - """ - Commit body to use for the merge commit; if omitted, a default message will be used - """ - commitBody: String - - """ - OID that the pull request head ref must match to allow merge; if omitted, no check is performed. - """ - expectedHeadOid: GitObjectID - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of MergePullRequest -""" -type MergePullRequestPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The pull request that was merged. - """ - pullRequest: PullRequest -} - -""" -Represents a Milestone object on a given repository. -""" -type Milestone implements Node & Closable & UniformResourceLocatable { - """ - `true` if the object is closed (definition of closed may depend on type) - """ - closed: Boolean! - - """ - Identifies the date and time when the object was closed. - """ - closedAt: DateTime - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the actor who created the milestone. - """ - creator: Actor - - """ - Identifies the description of the milestone. - """ - description: String - - """ - Identifies the due date of the milestone. - """ - dueOn: DateTime - id: ID! - - """ - A list of issues associated with the milestone. - """ - issues( - """ - Ordering options for issues returned from the connection. - """ - orderBy: IssueOrder - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - A list of states to filter the issues by. - """ - states: [IssueState!] - - """ - Filtering options for issues returned from the connection. - """ - filterBy: IssueFilters - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueConnection! - - """ - Identifies the number of the milestone. - """ - number: Int! - - """ - A list of pull requests associated with the milestone. - """ - pullRequests( - """ - A list of states to filter the pull requests by. - """ - states: [PullRequestState!] - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - The head ref name to filter the pull requests by. - """ - headRefName: String - - """ - The base ref name to filter the pull requests by. - """ - baseRefName: String - - """ - Ordering options for pull requests returned from the connection. - """ - orderBy: IssueOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestConnection! - - """ - The repository associated with this milestone. - """ - repository: Repository! - - """ - The HTTP path for this milestone - """ - resourcePath: URI! - - """ - Identifies the state of the milestone. - """ - state: MilestoneState! - - """ - Identifies the title of the milestone. - """ - title: String! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this milestone - """ - url: URI! -} - -""" -The connection type for Milestone. -""" -type MilestoneConnection { - """ - A list of edges. - """ - edges: [MilestoneEdge] - - """ - A list of nodes. - """ - nodes: [Milestone] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a 'milestoned' event on a given issue or pull request. -""" -type MilestonedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the milestone title associated with the 'milestoned' event. - """ - milestoneTitle: String! - - """ - Object referenced by event. - """ - subject: MilestoneItem! -} - -""" -An edge in a connection. -""" -type MilestoneEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Milestone -} - -""" -Types that can be inside a Milestone. -""" -union MilestoneItem = Issue | PullRequest - -""" -Ordering options for milestone connections. -""" -input MilestoneOrder { - """ - The field to order milestones by. - """ - field: MilestoneOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which milestone connections can be ordered. -""" -enum MilestoneOrderField { - """ - Order milestones by when they are due. - """ - DUE_DATE - - """ - Order milestones by when they were created. - """ - CREATED_AT - - """ - Order milestones by when they were last updated. - """ - UPDATED_AT - - """ - Order milestones by their number. - """ - NUMBER -} - -""" -The possible states of a milestone. -""" -enum MilestoneState { - """ - A milestone that is still open. - """ - OPEN - - """ - A milestone that has been closed. - """ - CLOSED -} - -""" -Autogenerated input type of MinimizeComment -""" -input MinimizeCommentInput { - """ - The Node ID of the subject to modify. - """ - subjectId: ID! - - """ - The classification of comment - """ - classifier: ReportedContentClassifiers! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Represents a 'moved_columns_in_project' event on a given issue or pull request. -""" -type MovedColumnsInProjectEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! -} - -""" -Autogenerated input type of MoveProjectCard -""" -input MoveProjectCardInput { - """ - The id of the card to move. - """ - cardId: ID! - - """ - The id of the column to move it into. - """ - columnId: ID! - - """ - Place the new card after the card with this id. Pass null to place it at the top. - """ - afterCardId: ID - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of MoveProjectCard -""" -type MoveProjectCardPayload { - """ - The new edge of the moved card. - """ - cardEdge: ProjectCardEdge - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated input type of MoveProjectColumn -""" -input MoveProjectColumnInput { - """ - The id of the column to move. - """ - columnId: ID! - - """ - Place the new column after the column with this id. Pass null to place it at the front. - """ - afterColumnId: ID - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of MoveProjectColumn -""" -type MoveProjectColumnPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The new edge of the moved column. - """ - columnEdge: ProjectColumnEdge -} - -""" -The root query for implementing GraphQL mutations. -""" -type Mutation { - """ - Applies a suggested topic to the repository. - """ - acceptTopicSuggestion( - input: AcceptTopicSuggestionInput! - ): AcceptTopicSuggestionPayload - - """ - Adds assignees to an assignable object. - """ - addAssigneesToAssignable( - input: AddAssigneesToAssignableInput! - ): AddAssigneesToAssignablePayload - - """ - Adds a comment to an Issue or Pull Request. - """ - addComment(input: AddCommentInput!): AddCommentPayload - - """ - Adds labels to a labelable object. - """ - addLabelsToLabelable( - input: AddLabelsToLabelableInput! - ): AddLabelsToLabelablePayload - - """ - Adds a card to a ProjectColumn. Either `contentId` or `note` must be provided but **not** both. - """ - addProjectCard(input: AddProjectCardInput!): AddProjectCardPayload - - """ - Adds a column to a Project. - """ - addProjectColumn(input: AddProjectColumnInput!): AddProjectColumnPayload - - """ - Adds a review to a Pull Request. - """ - addPullRequestReview( - input: AddPullRequestReviewInput! - ): AddPullRequestReviewPayload - - """ - Adds a comment to a review. - """ - addPullRequestReviewComment( - input: AddPullRequestReviewCommentInput! - ): AddPullRequestReviewCommentPayload - - """ - Adds a reaction to a subject. - """ - addReaction(input: AddReactionInput!): AddReactionPayload - - """ - Adds a star to a Starrable. - """ - addStar(input: AddStarInput!): AddStarPayload - - """ - Update your status on GitHub. - """ - changeUserStatus(input: ChangeUserStatusInput!): ChangeUserStatusPayload - - """ - Clears all labels from a labelable object. - """ - clearLabelsFromLabelable( - input: ClearLabelsFromLabelableInput! - ): ClearLabelsFromLabelablePayload - - """ - Creates a new project by cloning configuration from an existing project. - """ - cloneProject(input: CloneProjectInput!): CloneProjectPayload - - """ - Close an issue. - """ - closeIssue(input: CloseIssueInput!): CloseIssuePayload - - """ - Close a pull request. - """ - closePullRequest(input: ClosePullRequestInput!): ClosePullRequestPayload - - """ - Convert a project note card to one associated with a newly created issue. - """ - convertProjectCardNoteToIssue( - input: ConvertProjectCardNoteToIssueInput! - ): ConvertProjectCardNoteToIssuePayload - - """ - Create a new branch protection rule - """ - createBranchProtectionRule( - input: CreateBranchProtectionRuleInput! - ): CreateBranchProtectionRulePayload - - """ - Creates a new issue. - """ - createIssue(input: CreateIssueInput!): CreateIssuePayload - - """ - Creates a new project. - """ - createProject(input: CreateProjectInput!): CreateProjectPayload - - """ - Create a new pull request - """ - createPullRequest(input: CreatePullRequestInput!): CreatePullRequestPayload - - """ - Rejects a suggested topic for the repository. - """ - declineTopicSuggestion( - input: DeclineTopicSuggestionInput! - ): DeclineTopicSuggestionPayload - - """ - Delete a branch protection rule - """ - deleteBranchProtectionRule( - input: DeleteBranchProtectionRuleInput! - ): DeleteBranchProtectionRulePayload - - """ - Deletes an Issue object. - """ - deleteIssue(input: DeleteIssueInput!): DeleteIssuePayload - - """ - Deletes an IssueComment object. - """ - deleteIssueComment(input: DeleteIssueCommentInput!): DeleteIssueCommentPayload - - """ - Deletes a project. - """ - deleteProject(input: DeleteProjectInput!): DeleteProjectPayload - - """ - Deletes a project card. - """ - deleteProjectCard(input: DeleteProjectCardInput!): DeleteProjectCardPayload - - """ - Deletes a project column. - """ - deleteProjectColumn( - input: DeleteProjectColumnInput! - ): DeleteProjectColumnPayload - - """ - Deletes a pull request review. - """ - deletePullRequestReview( - input: DeletePullRequestReviewInput! - ): DeletePullRequestReviewPayload - - """ - Deletes a pull request review comment. - """ - deletePullRequestReviewComment( - input: DeletePullRequestReviewCommentInput! - ): DeletePullRequestReviewCommentPayload - - """ - Dismisses an approved or rejected pull request review. - """ - dismissPullRequestReview( - input: DismissPullRequestReviewInput! - ): DismissPullRequestReviewPayload - - """ - Lock a lockable object - """ - lockLockable(input: LockLockableInput!): LockLockablePayload - - """ - Merge a pull request. - """ - mergePullRequest(input: MergePullRequestInput!): MergePullRequestPayload - - """ - Moves a project card to another place. - """ - moveProjectCard(input: MoveProjectCardInput!): MoveProjectCardPayload - - """ - Moves a project column to another place. - """ - moveProjectColumn(input: MoveProjectColumnInput!): MoveProjectColumnPayload - - """ - Removes assignees from an assignable object. - """ - removeAssigneesFromAssignable( - input: RemoveAssigneesFromAssignableInput! - ): RemoveAssigneesFromAssignablePayload - - """ - Removes labels from a Labelable object. - """ - removeLabelsFromLabelable( - input: RemoveLabelsFromLabelableInput! - ): RemoveLabelsFromLabelablePayload - - """ - Removes outside collaborator from all repositories in an organization. - """ - removeOutsideCollaborator( - input: RemoveOutsideCollaboratorInput! - ): RemoveOutsideCollaboratorPayload - - """ - Removes a reaction from a subject. - """ - removeReaction(input: RemoveReactionInput!): RemoveReactionPayload - - """ - Removes a star from a Starrable. - """ - removeStar(input: RemoveStarInput!): RemoveStarPayload - - """ - Reopen a issue. - """ - reopenIssue(input: ReopenIssueInput!): ReopenIssuePayload - - """ - Reopen a pull request. - """ - reopenPullRequest(input: ReopenPullRequestInput!): ReopenPullRequestPayload - - """ - Set review requests on a pull request. - """ - requestReviews(input: RequestReviewsInput!): RequestReviewsPayload - - """ - Marks a review thread as resolved. - """ - resolveReviewThread( - input: ResolveReviewThreadInput! - ): ResolveReviewThreadPayload - - """ - Submits a pending pull request review. - """ - submitPullRequestReview( - input: SubmitPullRequestReviewInput! - ): SubmitPullRequestReviewPayload - - """ - Unlock a lockable object - """ - unlockLockable(input: UnlockLockableInput!): UnlockLockablePayload - - """ - Unmark an issue as a duplicate of another issue. - """ - unmarkIssueAsDuplicate( - input: UnmarkIssueAsDuplicateInput! - ): UnmarkIssueAsDuplicatePayload - - """ - Marks a review thread as unresolved. - """ - unresolveReviewThread( - input: UnresolveReviewThreadInput! - ): UnresolveReviewThreadPayload - - """ - Create a new branch protection rule - """ - updateBranchProtectionRule( - input: UpdateBranchProtectionRuleInput! - ): UpdateBranchProtectionRulePayload - - """ - Updates an Issue. - """ - updateIssue(input: UpdateIssueInput!): UpdateIssuePayload - - """ - Updates an IssueComment object. - """ - updateIssueComment(input: UpdateIssueCommentInput!): UpdateIssueCommentPayload - - """ - Updates an existing project. - """ - updateProject(input: UpdateProjectInput!): UpdateProjectPayload - - """ - Updates an existing project card. - """ - updateProjectCard(input: UpdateProjectCardInput!): UpdateProjectCardPayload - - """ - Updates an existing project column. - """ - updateProjectColumn( - input: UpdateProjectColumnInput! - ): UpdateProjectColumnPayload - - """ - Update a pull request - """ - updatePullRequest(input: UpdatePullRequestInput!): UpdatePullRequestPayload - - """ - Updates the body of a pull request review. - """ - updatePullRequestReview( - input: UpdatePullRequestReviewInput! - ): UpdatePullRequestReviewPayload - - """ - Updates a pull request review comment. - """ - updatePullRequestReviewComment( - input: UpdatePullRequestReviewCommentInput! - ): UpdatePullRequestReviewCommentPayload - - """ - Updates the state for subscribable subjects. - """ - updateSubscription(input: UpdateSubscriptionInput!): UpdateSubscriptionPayload - - """ - Replaces the repository's topics with the given topics. - """ - updateTopics(input: UpdateTopicsInput!): UpdateTopicsPayload -} - -""" -An object with an ID. -""" -interface Node { - """ - ID of the object. - """ - id: ID! -} - -""" -Possible directions in which to order a list of items when provided an `orderBy` argument. -""" -enum OrderDirection { - """ - Specifies an ascending order for a given `orderBy` argument. - """ - ASC - - """ - Specifies a descending order for a given `orderBy` argument. - """ - DESC -} - -""" -An account on GitHub, with one or more owners, that has repositories, members and teams. -""" -type Organization implements Node & Actor & RegistryPackageOwner & RegistryPackageSearch & ProjectOwner & RepositoryOwner & UniformResourceLocatable & MemberStatusable & ProfileOwner { - """ - Determine if this repository owner has any items that can be pinned to their profile. - """ - anyPinnableItems( - """ - Filter to only a particular kind of pinnable item. - """ - type: PinnableItemType - ): Boolean! - - """ - A URL pointing to the organization's public avatar. - """ - avatarUrl( - """ - The size of the resulting square image. - """ - size: Int - ): URI! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The organization's public profile description. - """ - description: String - - """ - The organization's public email. - """ - email: String - id: ID! - - """ - Whether the organization has verified its profile email and website. - """ - isVerified: Boolean! - - """ - Showcases a selection of repositories and gists that the profile owner has - either curated or that have been selected automatically based on popularity. - """ - itemShowcase: ProfileItemShowcase! - - """ - The organization's public profile location. - """ - location: String - - """ - The organization's login name. - """ - login: String! - - """ - Get the status messages members of this entity have set that are either public or visible only to the organization. - """ - memberStatuses( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for user statuses returned from the connection. - """ - orderBy: UserStatusOrder - ): UserStatusConnection! - - """ - A list of users who are members of this organization. - """ - membersWithRole( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): OrganizationMemberConnection! - - """ - The organization's public profile name. - """ - name: String - - """ - The HTTP path creating a new team - """ - newTeamResourcePath: URI! - - """ - The HTTP URL creating a new team - """ - newTeamUrl: URI! - - """ - The billing email for the organization. - """ - organizationBillingEmail: String - - """ - A list of users who have been invited to join this organization. - """ - pendingMembers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! - - """ - A list of repositories and gists this profile owner can pin to their profile. - """ - pinnableItems( - """ - Filter the types of pinnable items that are returned. - """ - types: [PinnableItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PinnableItemConnection! - - """ - A list of repositories and gists this profile owner has pinned to their profile - """ - pinnedItems( - """ - Filter the types of pinned items that are returned. - """ - types: [PinnableItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PinnableItemConnection! - - """ - Returns how many more items this profile owner can pin to their profile. - """ - pinnedItemsRemaining: Int! - - """ - A list of repositories this user has pinned to their profile - """ - pinnedRepositories( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Array of viewer's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - current viewer owns. - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryConnection! - @deprecated( - reason: "pinnedRepositories will be removed Use ProfileOwner.pinnedItems instead. Removal on 2019-07-01 UTC." - ) - - """ - Find project by number. - """ - project( - """ - The project number to find. - """ - number: Int! - ): Project - - """ - A list of projects under the owner. - """ - projects( - """ - Ordering options for projects returned from the connection - """ - orderBy: ProjectOrder - - """ - Query to search projects by, currently only searching by name. - """ - search: String - - """ - A list of states to filter the projects by. - """ - states: [ProjectState!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ProjectConnection! - - """ - The HTTP path listing organization's projects - """ - projectsResourcePath: URI! - - """ - The HTTP URL listing organization's projects - """ - projectsUrl: URI! - - """ - A list of repositories that the user owns. - """ - repositories( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Array of viewer's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - current viewer owns. - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - If non-null, filters repositories according to whether they are forks of another repository - """ - isFork: Boolean - ): RepositoryConnection! - - """ - Find Repository. - """ - repository( - """ - Name of Repository to find. - """ - name: String! - ): Repository - - """ - When true the organization requires all members, billing managers, and outside - collaborators to enable two-factor authentication. - """ - requiresTwoFactorAuthentication: Boolean - - """ - The HTTP path for this organization. - """ - resourcePath: URI! - - """ - The Organization's SAML identity providers - """ - samlIdentityProvider: OrganizationIdentityProvider - - """ - Find an organization's team by its slug. - """ - team( - """ - The name or slug of the team to find. - """ - slug: String! - ): Team - - """ - A list of teams in this organization. - """ - teams( - """ - If non-null, filters teams according to privacy - """ - privacy: TeamPrivacy - - """ - If non-null, filters teams according to whether the viewer is an admin or member on team - """ - role: TeamRole - - """ - If non-null, filters teams with query on team name and team slug - """ - query: String - - """ - User logins to filter by - """ - userLogins: [String!] - - """ - Ordering options for teams returned from the connection - """ - orderBy: TeamOrder - - """ - If true, filters teams that are mapped to an LDAP Group (Enterprise only) - """ - ldapMapped: Boolean - - """ - If true, restrict to only root teams - """ - rootTeamsOnly: Boolean = false - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): TeamConnection! - - """ - The HTTP path listing organization's teams - """ - teamsResourcePath: URI! - - """ - The HTTP URL listing organization's teams - """ - teamsUrl: URI! - - """ - The HTTP URL for this organization. - """ - url: URI! - - """ - Organization is adminable by the viewer. - """ - viewerCanAdminister: Boolean! - - """ - Can the viewer pin repositories and gists to the profile? - """ - viewerCanChangePinnedItems: Boolean! - - """ - Can the current viewer create new projects on this owner. - """ - viewerCanCreateProjects: Boolean! - - """ - Viewer can create repositories on this organization - """ - viewerCanCreateRepositories: Boolean! - - """ - Viewer can create teams on this organization. - """ - viewerCanCreateTeams: Boolean! - - """ - Viewer is an active member of this organization. - """ - viewerIsAMember: Boolean! - - """ - The organization's public profile URL. - """ - websiteUrl: URI -} - -""" -The connection type for Organization. -""" -type OrganizationConnection { - """ - A list of edges. - """ - edges: [OrganizationEdge] - - """ - A list of nodes. - """ - nodes: [Organization] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type OrganizationEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Organization -} - -""" -An Identity Provider configured to provision SAML and SCIM identities for Organizations -""" -type OrganizationIdentityProvider implements Node { - """ - The digest algorithm used to sign SAML requests for the Identity Provider. - """ - digestMethod: URI - - """ - External Identities provisioned by this Identity Provider - """ - externalIdentities( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ExternalIdentityConnection! - id: ID! - - """ - The x509 certificate used by the Identity Provder to sign assertions and responses. - """ - idpCertificate: X509Certificate - - """ - The Issuer Entity ID for the SAML Identity Provider - """ - issuer: String - - """ - Organization this Identity Provider belongs to - """ - organization: Organization - - """ - The signature algorithm used to sign SAML requests for the Identity Provider. - """ - signatureMethod: URI - - """ - The URL endpoint for the Identity Provider's SAML SSO. - """ - ssoUrl: URI -} - -""" -An Invitation for a user to an organization. -""" -type OrganizationInvitation implements Node { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The email address of the user invited to the organization. - """ - email: String - id: ID! - - """ - The type of invitation that was sent (e.g. email, user). - """ - invitationType: OrganizationInvitationType! - - """ - The user who was invited to the organization. - """ - invitee: User - - """ - The user who created the invitation. - """ - inviter: User! - - """ - The organization the invite is for - """ - organization: Organization! - - """ - The user's pending role in the organization (e.g. member, owner). - """ - role: OrganizationInvitationRole! -} - -""" -The connection type for OrganizationInvitation. -""" -type OrganizationInvitationConnection { - """ - A list of edges. - """ - edges: [OrganizationInvitationEdge] - - """ - A list of nodes. - """ - nodes: [OrganizationInvitation] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type OrganizationInvitationEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: OrganizationInvitation -} - -""" -The possible organization invitation roles. -""" -enum OrganizationInvitationRole { - """ - The user is invited to be a direct member of the organization. - """ - DIRECT_MEMBER - - """ - The user is invited to be an admin of the organization. - """ - ADMIN - - """ - The user is invited to be a billing manager of the organization. - """ - BILLING_MANAGER - - """ - The user's previous role will be reinstated. - """ - REINSTATE -} - -""" -The possible organization invitation types. -""" -enum OrganizationInvitationType { - """ - The invitation was to an existing user. - """ - USER - - """ - The invitation was to an email address. - """ - EMAIL -} - -""" -The connection type for User. -""" -type OrganizationMemberConnection { - """ - A list of edges. - """ - edges: [OrganizationMemberEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a user within an organization. -""" -type OrganizationMemberEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - Whether the organization member has two factor enabled or not. Returns null if information is not available to viewer. - """ - hasTwoFactorEnabled: Boolean - - """ - The item at the end of the edge. - """ - node: User - - """ - The role this user has in the organization. - """ - role: OrganizationMemberRole -} - -""" -The possible roles within an organization for its members. -""" -enum OrganizationMemberRole { - """ - The user is a member of the organization. - """ - MEMBER - - """ - The user is an administrator of the organization. - """ - ADMIN -} - -""" -Information about pagination in a connection. -""" -type PageInfo { - """ - When paginating forwards, the cursor to continue. - """ - endCursor: String - - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - - """ - When paginating backwards, the cursor to continue. - """ - startCursor: String -} - -""" -Types that can grant permissions on a repository to a user -""" -union PermissionGranter = Organization | Repository | Team - -""" -A level of permission and source for a user's access to a repository. -""" -type PermissionSource { - """ - The organization the repository belongs to. - """ - organization: Organization! - - """ - The level of access this source has granted to the user. - """ - permission: DefaultRepositoryPermissionField! - - """ - The source of this permission. - """ - source: PermissionGranter! -} - -""" -Autogenerated input type of PinIssue -""" -input PinIssueInput { - """ - The ID of the issue to be pinned - """ - issueId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Types that can be pinned to a profile page. -""" -union PinnableItem = Gist | Repository - -""" -The connection type for PinnableItem. -""" -type PinnableItemConnection { - """ - A list of edges. - """ - edges: [PinnableItemEdge] - - """ - A list of nodes. - """ - nodes: [PinnableItem] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type PinnableItemEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PinnableItem -} - -""" -Represents items that can be pinned to a profile page or dashboard. -""" -enum PinnableItemType { - """ - A repository. - """ - REPOSITORY - - """ - A gist. - """ - GIST - - """ - An issue. - """ - ISSUE -} - -""" -Represents a 'pinned' event on a given issue or pull request. -""" -type PinnedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the issue associated with the event. - """ - issue: Issue! -} - -""" -A curatable list of repositories relating to a repository owner, which defaults -to showing the most popular repositories they own. -""" -type ProfileItemShowcase { - """ - Whether or not the owner has pinned any repositories or gists. - """ - hasPinnedItems: Boolean! - - """ - The repositories and gists in the showcase. If the profile owner has any - pinned items, those will be returned. Otherwise, the profile owner's popular - repositories will be returned. - """ - items( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PinnableItemConnection! -} - -""" -Represents any entity on GitHub that has a profile page. -""" -interface ProfileOwner { - """ - Determine if this repository owner has any items that can be pinned to their profile. - """ - anyPinnableItems( - """ - Filter to only a particular kind of pinnable item. - """ - type: PinnableItemType - ): Boolean! - - """ - The public profile email. - """ - email: String - id: ID! - - """ - Showcases a selection of repositories and gists that the profile owner has - either curated or that have been selected automatically based on popularity. - """ - itemShowcase: ProfileItemShowcase! - - """ - The public profile location. - """ - location: String - - """ - The username used to login. - """ - login: String! - - """ - The public profile name. - """ - name: String - - """ - A list of repositories and gists this profile owner can pin to their profile. - """ - pinnableItems( - """ - Filter the types of pinnable items that are returned. - """ - types: [PinnableItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PinnableItemConnection! - - """ - A list of repositories and gists this profile owner has pinned to their profile - """ - pinnedItems( - """ - Filter the types of pinned items that are returned. - """ - types: [PinnableItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PinnableItemConnection! - - """ - Returns how many more items this profile owner can pin to their profile. - """ - pinnedItemsRemaining: Int! - - """ - Can the viewer pin repositories and gists to the profile? - """ - viewerCanChangePinnedItems: Boolean! - - """ - The public profile website URL. - """ - websiteUrl: URI -} - -""" -Projects manage issues, pull requests and notes within a project owner. -""" -type Project implements Node & Closable & Updatable { - """ - The project's description body. - """ - body: String - - """ - The projects description body rendered to HTML. - """ - bodyHTML: HTML! - - """ - `true` if the object is closed (definition of closed may depend on type) - """ - closed: Boolean! - - """ - Identifies the date and time when the object was closed. - """ - closedAt: DateTime - - """ - List of columns in the project - """ - columns( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ProjectColumnConnection! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The actor who originally created the project. - """ - creator: Actor - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - The project's name. - """ - name: String! - - """ - The project's number. - """ - number: Int! - - """ - The project's owner. Currently limited to repositories, organizations, and users. - """ - owner: ProjectOwner! - - """ - List of pending cards in this project - """ - pendingCards( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - A list of archived states to filter the cards by - """ - archivedStates: [ProjectCardArchivedState] - ): ProjectCardConnection! - - """ - The HTTP path for this project - """ - resourcePath: URI! - - """ - Whether the project is open or closed. - """ - state: ProjectState! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this project - """ - url: URI! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! -} - -""" -A card in a project. -""" -type ProjectCard implements Node { - """ - The project column this card is associated under. A card may only belong to one - project column at a time. The column field will be null if the card is created - in a pending state and has yet to be associated with a column. Once cards are - associated with a column, they will not become pending in the future. - """ - column: ProjectColumn - - """ - The card content item - """ - content: ProjectCardItem - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The actor who created this card - """ - creator: Actor - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - Whether the card is archived - """ - isArchived: Boolean! - - """ - The card note - """ - note: String - - """ - The project that contains this card. - """ - project: Project! - - """ - The HTTP path for this card - """ - resourcePath: URI! - - """ - The state of ProjectCard - """ - state: ProjectCardState - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this card - """ - url: URI! -} - -""" -The possible archived states of a project card. -""" -enum ProjectCardArchivedState { - """ - A project card that is archived - """ - ARCHIVED - - """ - A project card that is not archived - """ - NOT_ARCHIVED -} - -""" -The connection type for ProjectCard. -""" -type ProjectCardConnection { - """ - A list of edges. - """ - edges: [ProjectCardEdge] - - """ - A list of nodes. - """ - nodes: [ProjectCard] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ProjectCardEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: ProjectCard -} - -""" -An issue or PR and its owning repository to be used in a project card. -""" -input ProjectCardImport { - """ - Repository name with owner (owner/repository). - """ - repository: String! - - """ - The issue or pull request number. - """ - number: Int! -} - -""" -Types that can be inside Project Cards. -""" -union ProjectCardItem = Issue | PullRequest - -""" -Various content states of a ProjectCard -""" -enum ProjectCardState { - """ - The card has content only. - """ - CONTENT_ONLY - - """ - The card has a note only. - """ - NOTE_ONLY - - """ - The card is redacted. - """ - REDACTED -} - -""" -A column inside a project. -""" -type ProjectColumn implements Node { - """ - List of cards in the column - """ - cards( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - A list of archived states to filter the cards by - """ - archivedStates: [ProjectCardArchivedState] - ): ProjectCardConnection! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - The project column's name. - """ - name: String! - - """ - The project that contains this column. - """ - project: Project! - - """ - The semantic purpose of the column - """ - purpose: ProjectColumnPurpose - - """ - The HTTP path for this project column - """ - resourcePath: URI! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this project column - """ - url: URI! -} - -""" -The connection type for ProjectColumn. -""" -type ProjectColumnConnection { - """ - A list of edges. - """ - edges: [ProjectColumnEdge] - - """ - A list of nodes. - """ - nodes: [ProjectColumn] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ProjectColumnEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: ProjectColumn -} - -""" -A project column and a list of its issues and PRs. -""" -input ProjectColumnImport { - """ - The name of the column. - """ - columnName: String! - - """ - The position of the column, starting from 0. - """ - position: Int! - - """ - A list of issues and pull requests in the column. - """ - issues: [ProjectCardImport!] -} - -""" -The semantic purpose of the column - todo, in progress, or done. -""" -enum ProjectColumnPurpose { - """ - The column contains cards still to be worked on - """ - TODO - - """ - The column contains cards which are currently being worked on - """ - IN_PROGRESS - - """ - The column contains cards which are complete - """ - DONE -} - -""" -A list of projects associated with the owner. -""" -type ProjectConnection { - """ - A list of edges. - """ - edges: [ProjectEdge] - - """ - A list of nodes. - """ - nodes: [Project] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ProjectEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Project -} - -""" -Ways in which lists of projects can be ordered upon return. -""" -input ProjectOrder { - """ - The field in which to order projects by. - """ - field: ProjectOrderField! - - """ - The direction in which to order projects by the specified field. - """ - direction: OrderDirection! -} - -""" -Properties by which project connections can be ordered. -""" -enum ProjectOrderField { - """ - Order projects by creation time - """ - CREATED_AT - - """ - Order projects by update time - """ - UPDATED_AT - - """ - Order projects by name - """ - NAME -} - -""" -Represents an owner of a Project. -""" -interface ProjectOwner { - id: ID! - - """ - Find project by number. - """ - project( - """ - The project number to find. - """ - number: Int! - ): Project - - """ - A list of projects under the owner. - """ - projects( - """ - Ordering options for projects returned from the connection - """ - orderBy: ProjectOrder - - """ - Query to search projects by, currently only searching by name. - """ - search: String - - """ - A list of states to filter the projects by. - """ - states: [ProjectState!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ProjectConnection! - - """ - The HTTP path listing owners projects - """ - projectsResourcePath: URI! - - """ - The HTTP URL listing owners projects - """ - projectsUrl: URI! - - """ - Can the current viewer create new projects on this owner. - """ - viewerCanCreateProjects: Boolean! -} - -""" -State of the project; either 'open' or 'closed' -""" -enum ProjectState { - """ - The project is open. - """ - OPEN - - """ - The project is closed. - """ - CLOSED -} - -""" -A user's public key. -""" -type PublicKey implements Node { - """ - The last time this authorization was used to perform an action - """ - accessedAt: DateTime - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The fingerprint for this PublicKey - """ - fingerprint: String - id: ID! - - """ - Whether this PublicKey is read-only or not - """ - isReadOnly: Boolean! - - """ - The public key string - """ - key: String! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! -} - -""" -The connection type for PublicKey. -""" -type PublicKeyConnection { - """ - A list of edges. - """ - edges: [PublicKeyEdge] - - """ - A list of nodes. - """ - nodes: [PublicKey] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type PublicKeyEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PublicKey -} - -""" -A repository pull request. -""" -type PullRequest implements Node & Assignable & Closable & Comment & Updatable & UpdatableComment & Labelable & Lockable & Reactable & RepositoryNode & Subscribable & UniformResourceLocatable { - """ - Reason that the conversation was locked. - """ - activeLockReason: LockReason - - """ - The number of additions in this pull request. - """ - additions: Int! - - """ - A list of Users assigned to this object. - """ - assignees( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! - - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the subject of the comment. - """ - authorAssociation: CommentAuthorAssociation! - - """ - Identifies the base Ref associated with the pull request. - """ - baseRef: Ref - - """ - Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. - """ - baseRefName: String! - - """ - Identifies the oid of the base ref associated with the pull request, even if the ref has been deleted. - """ - baseRefOid: GitObjectID! - - """ - The repository associated with this pull request's base Ref. - """ - baseRepository: Repository - - """ - The body as Markdown. - """ - body: String! - - """ - The body rendered to HTML. - """ - bodyHTML: HTML! - - """ - The body rendered to text. - """ - bodyText: String! - - """ - The number of changed files in this pull request. - """ - changedFiles: Int! - - """ - `true` if the pull request is closed - """ - closed: Boolean! - - """ - Identifies the date and time when the object was closed. - """ - closedAt: DateTime - - """ - A list of comments associated with the pull request. - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueCommentConnection! - - """ - A list of commits present in this pull request's head branch not present in the base branch. - """ - commits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestCommitConnection! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The number of deletions in this pull request. - """ - deletions: Int! - - """ - The actor who edited this pull request's body. - """ - editor: Actor - - """ - Lists the files changed within this pull request. - """ - files( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestChangedFileConnection - - """ - Identifies the head Ref associated with the pull request. - """ - headRef: Ref - - """ - Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. - """ - headRefName: String! - - """ - Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. - """ - headRefOid: GitObjectID! - - """ - The repository associated with this pull request's head Ref. - """ - headRepository: Repository - - """ - The owner of the repository associated with this pull request's head Ref. - """ - headRepositoryOwner: RepositoryOwner - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - The head and base repositories are different. - """ - isCrossRepository: Boolean! - - """ - A list of labels associated with the object. - """ - labels( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): LabelConnection - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - `true` if the pull request is locked - """ - locked: Boolean! - - """ - Indicates whether maintainers can modify the pull request. - """ - maintainerCanModify: Boolean! - - """ - The commit that was created when this pull request was merged. - """ - mergeCommit: Commit - - """ - Whether or not the pull request can be merged based on the existence of merge conflicts. - """ - mergeable: MergeableState! - - """ - Whether or not the pull request was merged. - """ - merged: Boolean! - - """ - The date and time that the pull request was merged. - """ - mergedAt: DateTime - - """ - The actor who merged the pull request. - """ - mergedBy: Actor - - """ - Identifies the milestone associated with the pull request. - """ - milestone: Milestone - - """ - Identifies the pull request number. - """ - number: Int! - - """ - A list of Users that are participating in the Pull Request conversation. - """ - participants( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! - - """ - The permalink to the pull request. - """ - permalink: URI! - - """ - The commit that GitHub automatically generated to test if this pull request - could be merged. This field will not return a value if the pull request is - merged, or if the test merge commit is still being generated. See the - `mergeable` field for more details on the mergeability of the pull request. - """ - potentialMergeCommit: Commit - - """ - List of project cards associated with this pull request. - """ - projectCards( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - A list of archived states to filter the cards by - """ - archivedStates: [ProjectCardArchivedState] - ): ProjectCardConnection! - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - A list of reactions grouped by content left on the subject. - """ - reactionGroups: [ReactionGroup!] - - """ - A list of Reactions left on the Issue. - """ - reactions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Allows filtering Reactions by emoji. - """ - content: ReactionContent - - """ - Allows specifying the order in which reactions are returned. - """ - orderBy: ReactionOrder - ): ReactionConnection! - - """ - The repository associated with this node. - """ - repository: Repository! - - """ - The HTTP path for this pull request. - """ - resourcePath: URI! - - """ - The HTTP path for reverting this pull request. - """ - revertResourcePath: URI! - - """ - The HTTP URL for reverting this pull request. - """ - revertUrl: URI! - - """ - A list of review requests associated with the pull request. - """ - reviewRequests( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ReviewRequestConnection - - """ - The list of all review threads for this pull request. - """ - reviewThreads( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestReviewThreadConnection! - - """ - A list of reviews associated with the pull request. - """ - reviews( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - A list of states to filter the reviews. - """ - states: [PullRequestReviewState!] - - """ - Filter by author of the review. - """ - author: String - ): PullRequestReviewConnection - - """ - Identifies the state of the pull request. - """ - state: PullRequestState! - - """ - A list of reviewer suggestions based on commit history and past review comments. - """ - suggestedReviewers: [SuggestedReviewer]! - - """ - A list of events, comments, commits, etc. associated with the pull request. - """ - timeline( - """ - Allows filtering timeline events by a `since` timestamp. - """ - since: DateTime - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestTimelineConnection! - - """ - A list of events, comments, commits, etc. associated with the pull request. - """ - timelineItems( - """ - Filter timeline items by a `since` timestamp. - """ - since: DateTime - - """ - Skips the first _n_ elements in the list. - """ - skip: Int - - """ - Filter timeline items by type. - """ - itemTypes: [PullRequestTimelineItemsItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestTimelineItemsConnection! - - """ - Identifies the pull request title. - """ - title: String! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this pull request. - """ - url: URI! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Whether or not the viewer can apply suggestion. - """ - viewerCanApplySuggestion: Boolean! - - """ - Can user react to this subject - """ - viewerCanReact: Boolean! - - """ - Check if the viewer is able to change their subscription status for the repository. - """ - viewerCanSubscribe: Boolean! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! - - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! - - """ - Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. - """ - viewerSubscription: SubscriptionState -} - -""" -A file changed in a pull request. -""" -type PullRequestChangedFile { - """ - The number of additions to the file. - """ - additions: Int! - - """ - The number of deletions to the file. - """ - deletions: Int! - - """ - The path of the file. - """ - path: String! -} - -""" -The connection type for PullRequestChangedFile. -""" -type PullRequestChangedFileConnection { - """ - A list of edges. - """ - edges: [PullRequestChangedFileEdge] - - """ - A list of nodes. - """ - nodes: [PullRequestChangedFile] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type PullRequestChangedFileEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequestChangedFile -} - -""" -Represents a Git commit part of a pull request. -""" -type PullRequestCommit implements Node & UniformResourceLocatable { - """ - The Git commit object - """ - commit: Commit! - id: ID! - - """ - The pull request this commit belongs to - """ - pullRequest: PullRequest! - - """ - The HTTP path for this pull request commit - """ - resourcePath: URI! - - """ - The HTTP URL for this pull request commit - """ - url: URI! -} - -""" -Represents a commit comment thread part of a pull request. -""" -type PullRequestCommitCommentThread implements Node & RepositoryNode { - """ - The comments that exist in this thread. - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): CommitCommentConnection! - - """ - The commit the comments were made on. - """ - commit: Commit! - id: ID! - - """ - The file the comments were made on. - """ - path: String - - """ - The position in the diff for the commit that the comment was made on. - """ - position: Int - - """ - The pull request this commit comment thread belongs to - """ - pullRequest: PullRequest! - - """ - The repository associated with this node. - """ - repository: Repository! -} - -""" -The connection type for PullRequestCommit. -""" -type PullRequestCommitConnection { - """ - A list of edges. - """ - edges: [PullRequestCommitEdge] - - """ - A list of nodes. - """ - nodes: [PullRequestCommit] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type PullRequestCommitEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequestCommit -} - -""" -The connection type for PullRequest. -""" -type PullRequestConnection { - """ - A list of edges. - """ - edges: [PullRequestEdge] - - """ - A list of nodes. - """ - nodes: [PullRequest] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -This aggregates pull requests opened by a user within one repository. -""" -type PullRequestContributionsByRepository { - """ - The pull request contributions. - """ - contributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for contributions returned from the connection. - """ - orderBy: ContributionOrder - ): CreatedPullRequestContributionConnection! - - """ - The repository in which the pull requests were opened. - """ - repository: Repository! -} - -""" -An edge in a connection. -""" -type PullRequestEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequest -} - -""" -Ways in which lists of issues can be ordered upon return. -""" -input PullRequestOrder { - """ - The field in which to order pull requests by. - """ - field: PullRequestOrderField! - - """ - The direction in which to order pull requests by the specified field. - """ - direction: OrderDirection! -} - -""" -Properties by which pull_requests connections can be ordered. -""" -enum PullRequestOrderField { - """ - Order pull_requests by creation time - """ - CREATED_AT - - """ - Order pull_requests by update time - """ - UPDATED_AT -} - -""" -The possible PubSub channels for a pull request. -""" -enum PullRequestPubSubTopic { - """ - The channel ID for observing pull request updates. - """ - UPDATED - - """ - The channel ID for marking an pull request as read. - """ - MARKASREAD - - """ - The channel ID for observing head ref updates. - """ - HEAD_REF - - """ - The channel ID for updating items on the pull request timeline. - """ - TIMELINE - - """ - The channel ID for observing pull request state updates. - """ - STATE -} - -""" -A review object for a given pull request. -""" -type PullRequestReview implements Node & Comment & Deletable & Updatable & UpdatableComment & Reactable & RepositoryNode { - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the subject of the comment. - """ - authorAssociation: CommentAuthorAssociation! - - """ - Identifies the pull request review body. - """ - body: String! - - """ - The body of this review rendered to HTML. - """ - bodyHTML: HTML! - - """ - The body of this review rendered as plain text. - """ - bodyText: String! - - """ - A list of review comments for the current pull request review. - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestReviewCommentConnection! - - """ - Identifies the commit associated with this pull request review. - """ - commit: Commit - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The actor who edited the comment. - """ - editor: Actor - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - A list of teams that this review was made on behalf of. - """ - onBehalfOf( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): TeamConnection! - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - Identifies the pull request associated with this pull request review. - """ - pullRequest: PullRequest! - - """ - A list of reactions grouped by content left on the subject. - """ - reactionGroups: [ReactionGroup!] - - """ - A list of Reactions left on the Issue. - """ - reactions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Allows filtering Reactions by emoji. - """ - content: ReactionContent - - """ - Allows specifying the order in which reactions are returned. - """ - orderBy: ReactionOrder - ): ReactionConnection! - - """ - The repository associated with this node. - """ - repository: Repository! - - """ - The HTTP path permalink for this PullRequestReview. - """ - resourcePath: URI! - - """ - Identifies the current state of the pull request review. - """ - state: PullRequestReviewState! - - """ - Identifies when the Pull Request Review was submitted - """ - submittedAt: DateTime - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL permalink for this PullRequestReview. - """ - url: URI! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Check if the current viewer can delete this object. - """ - viewerCanDelete: Boolean! - - """ - Can user react to this subject - """ - viewerCanReact: Boolean! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! - - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! -} - -""" -A review comment associated with a given repository pull request. -""" -type PullRequestReviewComment implements Node & Comment & Deletable & Updatable & UpdatableComment & Reactable & RepositoryNode { - """ - The actor who authored the comment. - """ - author: Actor - - """ - Author's association with the subject of the comment. - """ - authorAssociation: CommentAuthorAssociation! - - """ - The comment body of this review comment. - """ - body: String! - - """ - The comment body of this review comment rendered to HTML. - """ - bodyHTML: HTML! - - """ - The comment body of this review comment rendered as plain text. - """ - bodyText: String! - - """ - Identifies the commit associated with the comment. - """ - commit: Commit! - - """ - Identifies when the comment was created. - """ - createdAt: DateTime! - - """ - Check if this comment was created via an email reply. - """ - createdViaEmail: Boolean! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The diff hunk to which the comment applies. - """ - diffHunk: String! - - """ - Identifies when the comment was created in a draft state. - """ - draftedAt: DateTime! - - """ - The actor who edited the comment. - """ - editor: Actor - id: ID! - - """ - Check if this comment was edited and includes an edit with the creation data - """ - includesCreatedEdit: Boolean! - - """ - Returns whether or not a comment has been minimized. - """ - isMinimized: Boolean! - - """ - The moment the editor made the last edit - """ - lastEditedAt: DateTime - - """ - Returns why the comment was minimized. - """ - minimizedReason: String - - """ - Identifies the original commit associated with the comment. - """ - originalCommit: Commit - - """ - The original line index in the diff to which the comment applies. - """ - originalPosition: Int! - - """ - Identifies when the comment body is outdated - """ - outdated: Boolean! - - """ - The path to which the comment applies. - """ - path: String! - - """ - The line index in the diff to which the comment applies. - """ - position: Int - - """ - Identifies when the comment was published at. - """ - publishedAt: DateTime - - """ - The pull request associated with this review comment. - """ - pullRequest: PullRequest! - - """ - The pull request review associated with this review comment. - """ - pullRequestReview: PullRequestReview - - """ - A list of reactions grouped by content left on the subject. - """ - reactionGroups: [ReactionGroup!] - - """ - A list of Reactions left on the Issue. - """ - reactions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Allows filtering Reactions by emoji. - """ - content: ReactionContent - - """ - Allows specifying the order in which reactions are returned. - """ - orderBy: ReactionOrder - ): ReactionConnection! - - """ - The comment this is a reply to. - """ - replyTo: PullRequestReviewComment - - """ - The repository associated with this node. - """ - repository: Repository! - - """ - The HTTP path permalink for this review comment. - """ - resourcePath: URI! - - """ - Identifies the state of the comment. - """ - state: PullRequestReviewCommentState! - - """ - Identifies when the comment was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL permalink for this review comment. - """ - url: URI! - - """ - A list of edits to this content. - """ - userContentEdits( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserContentEditConnection - - """ - Check if the current viewer can delete this object. - """ - viewerCanDelete: Boolean! - - """ - Check if the current viewer can minimize this object. - """ - viewerCanMinimize: Boolean! - - """ - Can user react to this subject - """ - viewerCanReact: Boolean! - - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! - - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! - - """ - Did the viewer author this comment. - """ - viewerDidAuthor: Boolean! -} - -""" -The connection type for PullRequestReviewComment. -""" -type PullRequestReviewCommentConnection { - """ - A list of edges. - """ - edges: [PullRequestReviewCommentEdge] - - """ - A list of nodes. - """ - nodes: [PullRequestReviewComment] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type PullRequestReviewCommentEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequestReviewComment -} - -""" -The possible states of a pull request review comment. -""" -enum PullRequestReviewCommentState { - """ - A comment that is part of a pending review - """ - PENDING - - """ - A comment that is part of a submitted review - """ - SUBMITTED -} - -""" -The connection type for PullRequestReview. -""" -type PullRequestReviewConnection { - """ - A list of edges. - """ - edges: [PullRequestReviewEdge] - - """ - A list of nodes. - """ - nodes: [PullRequestReview] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -This aggregates pull request reviews made by a user within one repository. -""" -type PullRequestReviewContributionsByRepository { - """ - The pull request review contributions. - """ - contributions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for contributions returned from the connection. - """ - orderBy: ContributionOrder - ): CreatedPullRequestReviewContributionConnection! - - """ - The repository in which the pull request reviews were made. - """ - repository: Repository! -} - -""" -An edge in a connection. -""" -type PullRequestReviewEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequestReview -} - -""" -The possible events to perform on a pull request review. -""" -enum PullRequestReviewEvent { - """ - Submit general feedback without explicit approval. - """ - COMMENT - - """ - Submit feedback and approve merging these changes. - """ - APPROVE - - """ - Submit feedback that must be addressed before merging. - """ - REQUEST_CHANGES - - """ - Dismiss review so it now longer effects merging. - """ - DISMISS -} - -""" -The possible states of a pull request review. -""" -enum PullRequestReviewState { - """ - A review that has not yet been submitted. - """ - PENDING - - """ - An informational review. - """ - COMMENTED - - """ - A review allowing the pull request to merge. - """ - APPROVED - - """ - A review blocking the pull request from merging. - """ - CHANGES_REQUESTED - - """ - A review that has been dismissed. - """ - DISMISSED -} - -""" -A threaded list of comments for a given pull request. -""" -type PullRequestReviewThread implements Node { - """ - A list of pull request comments associated with the thread. - """ - comments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestReviewCommentConnection! - id: ID! - - """ - Whether this thread has been resolved - """ - isResolved: Boolean! - - """ - Identifies the pull request associated with this thread. - """ - pullRequest: PullRequest! - - """ - Identifies the repository associated with this thread. - """ - repository: Repository! - - """ - The user who resolved this thread - """ - resolvedBy: User - - """ - Whether or not the viewer can resolve this thread - """ - viewerCanResolve: Boolean! - - """ - Whether or not the viewer can unresolve this thread - """ - viewerCanUnresolve: Boolean! -} - -""" -Review comment threads for a pull request review. -""" -type PullRequestReviewThreadConnection { - """ - A list of edges. - """ - edges: [PullRequestReviewThreadEdge] - - """ - A list of nodes. - """ - nodes: [PullRequestReviewThread] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type PullRequestReviewThreadEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequestReviewThread -} - -""" -Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits. -""" -type PullRequestRevisionMarker { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The last commit the viewer has seen. - """ - lastSeenCommit: Commit! - - """ - The pull request to which the marker belongs. - """ - pullRequest: PullRequest! -} - -""" -The possible states of a pull request. -""" -enum PullRequestState { - """ - A pull request that is still open. - """ - OPEN - - """ - A pull request that has been closed without being merged. - """ - CLOSED - - """ - A pull request that has been closed by being merged. - """ - MERGED -} - -""" -The connection type for PullRequestTimelineItem. -""" -type PullRequestTimelineConnection { - """ - A list of edges. - """ - edges: [PullRequestTimelineItemEdge] - - """ - A list of nodes. - """ - nodes: [PullRequestTimelineItem] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An item in an pull request timeline -""" -union PullRequestTimelineItem = - Commit - | CommitCommentThread - | PullRequestReview - | PullRequestReviewThread - | PullRequestReviewComment - | IssueComment - | ClosedEvent - | ReopenedEvent - | SubscribedEvent - | UnsubscribedEvent - | MergedEvent - | ReferencedEvent - | CrossReferencedEvent - | AssignedEvent - | UnassignedEvent - | LabeledEvent - | UnlabeledEvent - | MilestonedEvent - | DemilestonedEvent - | RenamedTitleEvent - | LockedEvent - | UnlockedEvent - | DeployedEvent - | DeploymentEnvironmentChangedEvent - | HeadRefDeletedEvent - | HeadRefRestoredEvent - | HeadRefForcePushedEvent - | BaseRefForcePushedEvent - | ReviewRequestedEvent - | ReviewRequestRemovedEvent - | ReviewDismissedEvent - | UserBlockedEvent - -""" -An edge in a connection. -""" -type PullRequestTimelineItemEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequestTimelineItem -} - -""" -An item in a pull request timeline -""" -union PullRequestTimelineItems = - PullRequestCommit - | PullRequestCommitCommentThread - | PullRequestReview - | PullRequestReviewThread - | PullRequestRevisionMarker - | BaseRefChangedEvent - | BaseRefForcePushedEvent - | DeployedEvent - | DeploymentEnvironmentChangedEvent - | HeadRefDeletedEvent - | HeadRefForcePushedEvent - | HeadRefRestoredEvent - | MergedEvent - | ReviewDismissedEvent - | ReviewRequestedEvent - | ReviewRequestRemovedEvent - | IssueComment - | CrossReferencedEvent - | AddedToProjectEvent - | AssignedEvent - | ClosedEvent - | CommentDeletedEvent - | ConvertedNoteToIssueEvent - | DemilestonedEvent - | LabeledEvent - | LockedEvent - | MentionedEvent - | MilestonedEvent - | MovedColumnsInProjectEvent - | PinnedEvent - | ReferencedEvent - | RemovedFromProjectEvent - | RenamedTitleEvent - | ReopenedEvent - | SubscribedEvent - | TransferredEvent - | UnassignedEvent - | UnlabeledEvent - | UnlockedEvent - | UserBlockedEvent - | UnpinnedEvent - | UnsubscribedEvent - -""" -The connection type for PullRequestTimelineItems. -""" -type PullRequestTimelineItemsConnection { - """ - A list of edges. - """ - edges: [PullRequestTimelineItemsEdge] - - """ - Identifies the count of items after applying `before` and `after` filters. - """ - filteredCount: Int! - - """ - A list of nodes. - """ - nodes: [PullRequestTimelineItems] - - """ - Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing. - """ - pageCount: Int! - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! - - """ - Identifies the date and time when the timeline was last updated. - """ - updatedAt: DateTime! -} - -""" -An edge in a connection. -""" -type PullRequestTimelineItemsEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PullRequestTimelineItems -} - -""" -The possible item types found in a timeline. -""" -enum PullRequestTimelineItemsItemType { - """ - Represents a Git commit part of a pull request. - """ - PULL_REQUEST_COMMIT - - """ - Represents a commit comment thread part of a pull request. - """ - PULL_REQUEST_COMMIT_COMMENT_THREAD - - """ - A review object for a given pull request. - """ - PULL_REQUEST_REVIEW - - """ - A threaded list of comments for a given pull request. - """ - PULL_REQUEST_REVIEW_THREAD - - """ - Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits. - """ - PULL_REQUEST_REVISION_MARKER - - """ - Represents a 'base_ref_changed' event on a given issue or pull request. - """ - BASE_REF_CHANGED_EVENT - - """ - Represents a 'base_ref_force_pushed' event on a given pull request. - """ - BASE_REF_FORCE_PUSHED_EVENT - - """ - Represents a 'deployed' event on a given pull request. - """ - DEPLOYED_EVENT - - """ - Represents a 'deployment_environment_changed' event on a given pull request. - """ - DEPLOYMENT_ENVIRONMENT_CHANGED_EVENT - - """ - Represents a 'head_ref_deleted' event on a given pull request. - """ - HEAD_REF_DELETED_EVENT - - """ - Represents a 'head_ref_force_pushed' event on a given pull request. - """ - HEAD_REF_FORCE_PUSHED_EVENT - - """ - Represents a 'head_ref_restored' event on a given pull request. - """ - HEAD_REF_RESTORED_EVENT - - """ - Represents a 'merged' event on a given pull request. - """ - MERGED_EVENT - - """ - Represents a 'review_dismissed' event on a given issue or pull request. - """ - REVIEW_DISMISSED_EVENT - - """ - Represents an 'review_requested' event on a given pull request. - """ - REVIEW_REQUESTED_EVENT - - """ - Represents an 'review_request_removed' event on a given pull request. - """ - REVIEW_REQUEST_REMOVED_EVENT - - """ - Represents a comment on an Issue. - """ - ISSUE_COMMENT - - """ - Represents a mention made by one issue or pull request to another. - """ - CROSS_REFERENCED_EVENT - - """ - Represents a 'added_to_project' event on a given issue or pull request. - """ - ADDED_TO_PROJECT_EVENT - - """ - Represents an 'assigned' event on any assignable object. - """ - ASSIGNED_EVENT - - """ - Represents a 'closed' event on any `Closable`. - """ - CLOSED_EVENT - - """ - Represents a 'comment_deleted' event on a given issue or pull request. - """ - COMMENT_DELETED_EVENT - - """ - Represents a 'converted_note_to_issue' event on a given issue or pull request. - """ - CONVERTED_NOTE_TO_ISSUE_EVENT - - """ - Represents a 'demilestoned' event on a given issue or pull request. - """ - DEMILESTONED_EVENT - - """ - Represents a 'labeled' event on a given issue or pull request. - """ - LABELED_EVENT - - """ - Represents a 'locked' event on a given issue or pull request. - """ - LOCKED_EVENT - - """ - Represents a 'mentioned' event on a given issue or pull request. - """ - MENTIONED_EVENT - - """ - Represents a 'milestoned' event on a given issue or pull request. - """ - MILESTONED_EVENT - - """ - Represents a 'moved_columns_in_project' event on a given issue or pull request. - """ - MOVED_COLUMNS_IN_PROJECT_EVENT - - """ - Represents a 'pinned' event on a given issue or pull request. - """ - PINNED_EVENT - - """ - Represents a 'referenced' event on a given `ReferencedSubject`. - """ - REFERENCED_EVENT - - """ - Represents a 'removed_from_project' event on a given issue or pull request. - """ - REMOVED_FROM_PROJECT_EVENT - - """ - Represents a 'renamed' event on a given issue or pull request - """ - RENAMED_TITLE_EVENT - - """ - Represents a 'reopened' event on any `Closable`. - """ - REOPENED_EVENT - - """ - Represents a 'subscribed' event on a given `Subscribable`. - """ - SUBSCRIBED_EVENT - - """ - Represents a 'transferred' event on a given issue or pull request. - """ - TRANSFERRED_EVENT - - """ - Represents an 'unassigned' event on any assignable object. - """ - UNASSIGNED_EVENT - - """ - Represents an 'unlabeled' event on a given issue or pull request. - """ - UNLABELED_EVENT - - """ - Represents an 'unlocked' event on a given issue or pull request. - """ - UNLOCKED_EVENT - - """ - Represents a 'user_blocked' event on a given user. - """ - USER_BLOCKED_EVENT - - """ - Represents an 'unpinned' event on a given issue or pull request. - """ - UNPINNED_EVENT - - """ - Represents an 'unsubscribed' event on a given `Subscribable`. - """ - UNSUBSCRIBED_EVENT -} - -""" -A team or user who has the ability to push to a protected branch. -""" -type PushAllowance implements Node { - """ - The actor that can push. - """ - actor: PushAllowanceActor - - """ - Identifies the branch protection rule associated with the allowed user or team. - """ - branchProtectionRule: BranchProtectionRule - id: ID! -} - -""" -Types that can be an actor. -""" -union PushAllowanceActor = User | Team - -""" -The connection type for PushAllowance. -""" -type PushAllowanceConnection { - """ - A list of edges. - """ - edges: [PushAllowanceEdge] - - """ - A list of nodes. - """ - nodes: [PushAllowance] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type PushAllowanceEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: PushAllowance -} - -""" -The query root of GitHub's GraphQL interface. -""" -type Query { - """ - Look up a code of conduct by its key - """ - codeOfConduct( - """ - The code of conduct's key - """ - key: String! - ): CodeOfConduct - - """ - Look up a code of conduct by its key - """ - codesOfConduct: [CodeOfConduct] - - """ - Look up an open source license by its key - """ - license( - """ - The license's downcased SPDX ID - """ - key: String! - ): License - - """ - Return a list of known open source licenses - """ - licenses: [License]! - - """ - Get alphabetically sorted list of Marketplace categories - """ - marketplaceCategories( - """ - Return only the specified categories. - """ - includeCategories: [String!] - - """ - Exclude categories with no listings. - """ - excludeEmpty: Boolean - - """ - Returns top level categories only, excluding any subcategories. - """ - excludeSubcategories: Boolean - ): [MarketplaceCategory!]! - - """ - Look up a Marketplace category by its slug. - """ - marketplaceCategory( - """ - The URL slug of the category. - """ - slug: String! - - """ - Also check topic aliases for the category slug - """ - useTopicAliases: Boolean - ): MarketplaceCategory - - """ - Look up a single Marketplace listing - """ - marketplaceListing( - """ - Select the listing that matches this slug. It's the short name of the listing used in its URL. - """ - slug: String! - ): MarketplaceListing - - """ - Look up Marketplace listings - """ - marketplaceListings( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Select only listings with the given category. - """ - categorySlug: String - - """ - Also check topic aliases for the category slug - """ - useTopicAliases: Boolean - - """ - Select listings to which user has admin access. If omitted, listings visible to the - viewer are returned. - """ - viewerCanAdmin: Boolean - - """ - Select listings that can be administered by the specified user. - """ - adminId: ID - - """ - Select listings for products owned by the specified organization. - """ - organizationId: ID - - """ - Select listings visible to the viewer even if they are not approved. If omitted or - false, only approved listings will be returned. - """ - allStates: Boolean - - """ - Select the listings with these slugs, if they are visible to the viewer. - """ - slugs: [String] - - """ - Select only listings where the primary category matches the given category slug. - """ - primaryCategoryOnly: Boolean = false - - """ - Select only listings that offer a free trial. - """ - withFreeTrialsOnly: Boolean = false - ): MarketplaceListingConnection! - - """ - Return information about the GitHub instance - """ - meta: GitHubMetadata! - - """ - Fetches an object given its ID. - """ - node( - """ - ID of the object. - """ - id: ID! - ): Node - - """ - Lookup nodes by a list of IDs. - """ - nodes( - """ - The list of node IDs. - """ - ids: [ID!]! - ): [Node]! - - """ - Lookup a organization by login. - """ - organization( - """ - The organization's login. - """ - login: String! - ): Organization - - """ - The client's rate limit information. - """ - rateLimit( - """ - If true, calculate the cost for the query without evaluating it - """ - dryRun: Boolean = false - ): RateLimit - - """ - Hack to workaround https://github.com/facebook/relay/issues/112 re-exposing the root query object - """ - relay: Query! - - """ - Lookup a given repository by the owner and repository name. - """ - repository( - """ - The login field of a user or organization - """ - owner: String! - - """ - The name of the repository - """ - name: String! - ): Repository - - """ - Lookup a repository owner (ie. either a User or an Organization) by login. - """ - repositoryOwner( - """ - The username to lookup the owner by. - """ - login: String! - ): RepositoryOwner - - """ - Lookup resource by a URL. - """ - resource( - """ - The URL. - """ - url: URI! - ): UniformResourceLocatable - - """ - Perform a search across resources. - """ - search( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - The search string to look for. - """ - query: String! - - """ - The types of search items to search within. - """ - type: SearchType! - ): SearchResultItemConnection! - - """ - GitHub Security Advisories - """ - securityAdvisories( - """ - Ordering options for the returned topics. - """ - orderBy: SecurityAdvisoryOrder - - """ - Filter advisories by identifier, e.g. GHSA or CVE. - """ - identifier: SecurityAdvisoryIdentifierFilter - - """ - Filter advisories to those published since a time in the past. - """ - publishedSince: DateTime - - """ - Filter advisories to those updated since a time in the past. - """ - updatedSince: DateTime - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): SecurityAdvisoryConnection! - - """ - Fetch a Security Advisory by its GHSA ID - """ - securityAdvisory( - """ - GitHub Security Advisory ID. - """ - ghsaId: String! - ): SecurityAdvisory - - """ - Software Vulnerabilities documented by GitHub Security Advisories - """ - securityVulnerabilities( - """ - Ordering options for the returned topics. - """ - orderBy: SecurityVulnerabilityOrder - - """ - An ecosystem to filter vulnerabilities by. - """ - ecosystem: SecurityAdvisoryEcosystem - - """ - A package name to filter vulnerabilities by. - """ - package: String - - """ - A list of severities to filter vulnerabilities by. - """ - severities: [SecurityAdvisorySeverity!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): SecurityVulnerabilityConnection! - - """ - Look up a topic by name. - """ - topic( - """ - The topic's name. - """ - name: String! - ): Topic - - """ - Lookup a user by login. - """ - user( - """ - The user's login. - """ - login: String! - ): User - - """ - The currently authenticated user. - """ - viewer: User! -} - -""" -Represents the client's rate limit. -""" -type RateLimit { - """ - The point cost for the current query counting against the rate limit. - """ - cost: Int! - - """ - The maximum number of points the client is permitted to consume in a 60 minute window. - """ - limit: Int! - - """ - The maximum number of nodes this query may return - """ - nodeCount: Int! - - """ - The number of points remaining in the current rate limit window. - """ - remaining: Int! - - """ - The time at which the current rate limit window resets in UTC epoch seconds. - """ - resetAt: DateTime! -} - -""" -Represents a subject that can be reacted on. -""" -interface Reactable { - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - A list of reactions grouped by content left on the subject. - """ - reactionGroups: [ReactionGroup!] - - """ - A list of Reactions left on the Issue. - """ - reactions( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Allows filtering Reactions by emoji. - """ - content: ReactionContent - - """ - Allows specifying the order in which reactions are returned. - """ - orderBy: ReactionOrder - ): ReactionConnection! - - """ - Can user react to this subject - """ - viewerCanReact: Boolean! -} - -""" -The connection type for User. -""" -type ReactingUserConnection { - """ - A list of edges. - """ - edges: [ReactingUserEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a user that's made a reaction. -""" -type ReactingUserEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - node: User! - - """ - The moment when the user made the reaction. - """ - reactedAt: DateTime! -} - -""" -An emoji reaction to a particular piece of content. -""" -type Reaction implements Node { - """ - Identifies the emoji reaction. - """ - content: ReactionContent! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - The reactable piece of content - """ - reactable: Reactable! - - """ - Identifies the user who created this reaction. - """ - user: User -} - -""" -A list of reactions that have been left on the subject. -""" -type ReactionConnection { - """ - A list of edges. - """ - edges: [ReactionEdge] - - """ - A list of nodes. - """ - nodes: [Reaction] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! - - """ - Whether or not the authenticated user has left a reaction on the subject. - """ - viewerHasReacted: Boolean! -} - -""" -Emojis that can be attached to Issues, Pull Requests and Comments. -""" -enum ReactionContent { - """ - Represents the πŸ‘ emoji. - """ - THUMBS_UP - - """ - Represents the πŸ‘Ž emoji. - """ - THUMBS_DOWN - - """ - Represents the πŸ˜„ emoji. - """ - LAUGH - - """ - Represents the πŸŽ‰ emoji. - """ - HOORAY - - """ - Represents the πŸ˜• emoji. - """ - CONFUSED - - """ - Represents the ❀️ emoji. - """ - HEART - - """ - Represents the πŸš€ emoji. - """ - ROCKET - - """ - Represents the πŸ‘€ emoji. - """ - EYES -} - -""" -An edge in a connection. -""" -type ReactionEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Reaction -} - -""" -A group of emoji reactions to a particular piece of content. -""" -type ReactionGroup { - """ - Identifies the emoji reaction. - """ - content: ReactionContent! - - """ - Identifies when the reaction was created. - """ - createdAt: DateTime - - """ - The subject that was reacted to. - """ - subject: Reactable! - - """ - Users who have reacted to the reaction subject with the emotion represented by this reaction group - """ - users( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ReactingUserConnection! - - """ - Whether or not the authenticated user has left a reaction on the subject. - """ - viewerHasReacted: Boolean! -} - -""" -Ways in which lists of reactions can be ordered upon return. -""" -input ReactionOrder { - """ - The field in which to order reactions by. - """ - field: ReactionOrderField! - - """ - The direction in which to order reactions by the specified field. - """ - direction: OrderDirection! -} - -""" -A list of fields that reactions can be ordered by. -""" -enum ReactionOrderField { - """ - Allows ordering a list of reactions by when they were created. - """ - CREATED_AT -} - -""" -Represents a Git reference. -""" -type Ref implements Node { - """ - A list of pull requests with this ref as the head ref. - """ - associatedPullRequests( - """ - A list of states to filter the pull requests by. - """ - states: [PullRequestState!] - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - The head ref name to filter the pull requests by. - """ - headRefName: String - - """ - The base ref name to filter the pull requests by. - """ - baseRefName: String - - """ - Ordering options for pull requests returned from the connection. - """ - orderBy: IssueOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestConnection! - id: ID! - - """ - The ref name. - """ - name: String! - - """ - The ref's prefix, such as `refs/heads/` or `refs/tags/`. - """ - prefix: String! - - """ - The repository the ref belongs to. - """ - repository: Repository! - - """ - The object the ref points to. - """ - target: GitObject! -} - -""" -The connection type for Ref. -""" -type RefConnection { - """ - A list of edges. - """ - edges: [RefEdge] - - """ - A list of nodes. - """ - nodes: [Ref] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type RefEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Ref -} - -""" -Represents a 'referenced' event on a given `ReferencedSubject`. -""" -type ReferencedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the commit associated with the 'referenced' event. - """ - commit: Commit - - """ - Identifies the repository associated with the 'referenced' event. - """ - commitRepository: Repository! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Reference originated in a different repository. - """ - isCrossRepository: Boolean! - - """ - Checks if the commit message itself references the subject. Can be false in the case of a commit comment reference. - """ - isDirectReference: Boolean! - - """ - Object referenced by event. - """ - subject: ReferencedSubject! -} - -""" -Any referencable object -""" -union ReferencedSubject = Issue | PullRequest - -""" -Ways in which lists of git refs can be ordered upon return. -""" -input RefOrder { - """ - The field in which to order refs by. - """ - field: RefOrderField! - - """ - The direction in which to order refs by the specified field. - """ - direction: OrderDirection! -} - -""" -Properties by which ref connections can be ordered. -""" -enum RefOrderField { - """ - Order refs by underlying commit date if the ref prefix is refs/tags/ - """ - TAG_COMMIT_DATE - - """ - Order refs by their alphanumeric name - """ - ALPHABETICAL -} - -""" -Represents an owner of a registry package. -""" -interface RegistryPackageOwner { - id: ID! -} - -""" -Represents an interface to search packages on an object. -""" -interface RegistryPackageSearch { - id: ID! -} - -""" -A release contains the content for a release. -""" -type Release implements Node & UniformResourceLocatable { - """ - The author of the release - """ - author: User - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the description of the release. - """ - description: String - id: ID! - - """ - Whether or not the release is a draft - """ - isDraft: Boolean! - - """ - Whether or not the release is a prerelease - """ - isPrerelease: Boolean! - - """ - Identifies the title of the release. - """ - name: String - - """ - Identifies the date and time when the release was created. - """ - publishedAt: DateTime - - """ - List of releases assets which are dependent on this release. - """ - releaseAssets( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - A list of names to filter the assets by. - """ - name: String - ): ReleaseAssetConnection! - - """ - The HTTP path for this issue - """ - resourcePath: URI! - - """ - The Git tag the release points to - """ - tag: Ref - - """ - The name of the release's Git tag - """ - tagName: String! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this issue - """ - url: URI! -} - -""" -A release asset contains the content for a release asset. -""" -type ReleaseAsset implements Node { - """ - The asset's content-type - """ - contentType: String! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The number of times this asset was downloaded - """ - downloadCount: Int! - - """ - Identifies the URL where you can download the release asset via the browser. - """ - downloadUrl: URI! - id: ID! - - """ - Identifies the title of the release asset. - """ - name: String! - - """ - Release that the asset is associated with - """ - release: Release - - """ - The size (in bytes) of the asset - """ - size: Int! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The user that performed the upload - """ - uploadedBy: User! - - """ - Identifies the URL of the release asset. - """ - url: URI! -} - -""" -The connection type for ReleaseAsset. -""" -type ReleaseAssetConnection { - """ - A list of edges. - """ - edges: [ReleaseAssetEdge] - - """ - A list of nodes. - """ - nodes: [ReleaseAsset] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ReleaseAssetEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: ReleaseAsset -} - -""" -The connection type for Release. -""" -type ReleaseConnection { - """ - A list of edges. - """ - edges: [ReleaseEdge] - - """ - A list of nodes. - """ - nodes: [Release] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ReleaseEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Release -} - -""" -Ways in which lists of releases can be ordered upon return. -""" -input ReleaseOrder { - """ - The field in which to order releases by. - """ - field: ReleaseOrderField! - - """ - The direction in which to order releases by the specified field. - """ - direction: OrderDirection! -} - -""" -Properties by which release connections can be ordered. -""" -enum ReleaseOrderField { - """ - Order releases by creation time - """ - CREATED_AT - - """ - Order releases alphabetically by name - """ - NAME -} - -""" -Autogenerated input type of RemoveAssigneesFromAssignable -""" -input RemoveAssigneesFromAssignableInput { - """ - The id of the assignable object to remove assignees from. - """ - assignableId: ID! - - """ - The id of users to remove as assignees. - """ - assigneeIds: [ID!]! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of RemoveAssigneesFromAssignable -""" -type RemoveAssigneesFromAssignablePayload { - """ - The item that was unassigned. - """ - assignable: Assignable - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Represents a 'removed_from_project' event on a given issue or pull request. -""" -type RemovedFromProjectEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! -} - -""" -Autogenerated input type of RemoveLabelsFromLabelable -""" -input RemoveLabelsFromLabelableInput { - """ - The id of the Labelable to remove labels from. - """ - labelableId: ID! - - """ - The ids of labels to remove. - """ - labelIds: [ID!]! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of RemoveLabelsFromLabelable -""" -type RemoveLabelsFromLabelablePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The Labelable the labels were removed from. - """ - labelable: Labelable -} - -""" -Autogenerated input type of RemoveOutsideCollaborator -""" -input RemoveOutsideCollaboratorInput { - """ - The ID of the outside collaborator to remove. - """ - userId: ID! - - """ - The ID of the organization to remove the outside collaborator from. - """ - organizationId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of RemoveOutsideCollaborator -""" -type RemoveOutsideCollaboratorPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The user that was removed as an outside collaborator. - """ - removedUser: User -} - -""" -Autogenerated input type of RemoveReaction -""" -input RemoveReactionInput { - """ - The Node ID of the subject to modify. - """ - subjectId: ID! - - """ - The name of the emoji reaction to remove. - """ - content: ReactionContent! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of RemoveReaction -""" -type RemoveReactionPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The reaction object. - """ - reaction: Reaction - - """ - The reactable subject. - """ - subject: Reactable -} - -""" -Autogenerated input type of RemoveStar -""" -input RemoveStarInput { - """ - The Starrable ID to unstar. - """ - starrableId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of RemoveStar -""" -type RemoveStarPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The starrable. - """ - starrable: Starrable -} - -""" -Represents a 'renamed' event on a given issue or pull request -""" -type RenamedTitleEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the current title of the issue or pull request. - """ - currentTitle: String! - id: ID! - - """ - Identifies the previous title of the issue or pull request. - """ - previousTitle: String! - - """ - Subject that was renamed. - """ - subject: RenamedTitleSubject! -} - -""" -An object which has a renamable title -""" -union RenamedTitleSubject = Issue | PullRequest - -""" -Represents a 'reopened' event on any `Closable`. -""" -type ReopenedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Object that was reopened. - """ - closable: Closable! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! -} - -""" -Autogenerated input type of ReopenIssue -""" -input ReopenIssueInput { - """ - ID of the issue to be opened. - """ - issueId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of ReopenIssue -""" -type ReopenIssuePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The issue that was opened. - """ - issue: Issue -} - -""" -Autogenerated input type of ReopenPullRequest -""" -input ReopenPullRequestInput { - """ - ID of the pull request to be reopened. - """ - pullRequestId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of ReopenPullRequest -""" -type ReopenPullRequestPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The pull request that was reopened. - """ - pullRequest: PullRequest -} - -""" -The reasons a piece of content can be reported or minimized. -""" -enum ReportedContentClassifiers { - """ - A spammy piece of content - """ - SPAM - - """ - An abusive or harassing piece of content - """ - ABUSE - - """ - An irrelevant piece of content - """ - OFF_TOPIC - - """ - An outdated piece of content - """ - OUTDATED - - """ - The content has been resolved - """ - RESOLVED -} - -""" -A repository contains the content for a project. -""" -type Repository implements Node & ProjectOwner & RegistryPackageOwner & Subscribable & Starrable & UniformResourceLocatable & RepositoryInfo { - """ - A list of users that can be assigned to issues in this repository. - """ - assignableUsers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! - - """ - A list of branch protection rules for this repository. - """ - branchProtectionRules( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): BranchProtectionRuleConnection! - - """ - Returns the code of conduct for this repository - """ - codeOfConduct: CodeOfConduct - - """ - A list of collaborators associated with the repository. - """ - collaborators( - """ - Collaborators affiliation level with a repository. - """ - affiliation: CollaboratorAffiliation - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryCollaboratorConnection - - """ - A list of commit comments associated with the repository. - """ - commitComments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): CommitCommentConnection! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The Ref associated with the repository's default branch. - """ - defaultBranchRef: Ref - - """ - A list of deploy keys that are on this repository. - """ - deployKeys( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): DeployKeyConnection! - - """ - Deployments associated with the repository - """ - deployments( - """ - Environments to list deployments for - """ - environments: [String!] - - """ - Ordering options for deployments returned from the connection. - """ - orderBy: DeploymentOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): DeploymentConnection! - - """ - The description of the repository. - """ - description: String - - """ - The description of the repository rendered to HTML. - """ - descriptionHTML: HTML! - - """ - The number of kilobytes this repository occupies on disk. - """ - diskUsage: Int - - """ - Returns how many forks there are of this repository in the whole network. - """ - forkCount: Int! - - """ - A list of direct forked repositories. - """ - forks( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Array of viewer's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - current viewer owns. - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryConnection! - - """ - Indicates if the repository has issues feature enabled. - """ - hasIssuesEnabled: Boolean! - - """ - Indicates if the repository has wiki feature enabled. - """ - hasWikiEnabled: Boolean! - - """ - The repository's URL. - """ - homepageUrl: URI - id: ID! - - """ - Indicates if the repository is unmaintained. - """ - isArchived: Boolean! - - """ - Returns whether or not this repository disabled. - """ - isDisabled: Boolean! - - """ - Identifies if the repository is a fork. - """ - isFork: Boolean! - - """ - Indicates if the repository has been locked or not. - """ - isLocked: Boolean! - - """ - Identifies if the repository is a mirror. - """ - isMirror: Boolean! - - """ - Identifies if the repository is private. - """ - isPrivate: Boolean! - - """ - Returns a single issue from the current repository by number. - """ - issue( - """ - The number for the issue to be returned. - """ - number: Int! - ): Issue - - """ - Returns a single issue-like object from the current repository by number. - """ - issueOrPullRequest( - """ - The number for the issue to be returned. - """ - number: Int! - ): IssueOrPullRequest - - """ - A list of issues that have been opened in the repository. - """ - issues( - """ - Ordering options for issues returned from the connection. - """ - orderBy: IssueOrder - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - A list of states to filter the issues by. - """ - states: [IssueState!] - - """ - Filtering options for issues returned from the connection. - """ - filterBy: IssueFilters - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueConnection! - - """ - Returns a single label by name - """ - label( - """ - Label name - """ - name: String! - ): Label - - """ - A list of labels associated with the repository. - """ - labels( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - If provided, searches labels by name and description. - """ - query: String - ): LabelConnection - - """ - A list containing a breakdown of the language composition of the repository. - """ - languages( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Order for connection - """ - orderBy: LanguageOrder - ): LanguageConnection - - """ - The license associated with the repository - """ - licenseInfo: License - - """ - The reason the repository has been locked. - """ - lockReason: RepositoryLockReason - - """ - A list of Users that can be mentioned in the context of the repository. - """ - mentionableUsers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! - - """ - Whether or not PRs are merged with a merge commit on this repository. - """ - mergeCommitAllowed: Boolean! - - """ - Returns a single milestone from the current repository by number. - """ - milestone( - """ - The number for the milestone to be returned. - """ - number: Int! - ): Milestone - - """ - A list of milestones associated with the repository. - """ - milestones( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Filter by the state of the milestones. - """ - states: [MilestoneState!] - - """ - Ordering options for milestones. - """ - orderBy: MilestoneOrder - ): MilestoneConnection - - """ - The repository's original mirror URL. - """ - mirrorUrl: URI - - """ - The name of the repository. - """ - name: String! - - """ - The repository's name with owner. - """ - nameWithOwner: String! - - """ - A Git object in the repository - """ - object( - """ - The Git object ID - """ - oid: GitObjectID - - """ - A Git revision expression suitable for rev-parse - """ - expression: String - ): GitObject - - """ - The User owner of the repository. - """ - owner: RepositoryOwner! - - """ - The repository parent, if this is a fork. - """ - parent: Repository - - """ - The primary language of the repository's code. - """ - primaryLanguage: Language - - """ - Find project by number. - """ - project( - """ - The project number to find. - """ - number: Int! - ): Project - - """ - A list of projects under the owner. - """ - projects( - """ - Ordering options for projects returned from the connection - """ - orderBy: ProjectOrder - - """ - Query to search projects by, currently only searching by name. - """ - search: String - - """ - A list of states to filter the projects by. - """ - states: [ProjectState!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ProjectConnection! - - """ - The HTTP path listing the repository's projects - """ - projectsResourcePath: URI! - - """ - The HTTP URL listing the repository's projects - """ - projectsUrl: URI! - - """ - Returns a single pull request from the current repository by number. - """ - pullRequest( - """ - The number for the pull request to be returned. - """ - number: Int! - ): PullRequest - - """ - A list of pull requests that have been opened in the repository. - """ - pullRequests( - """ - A list of states to filter the pull requests by. - """ - states: [PullRequestState!] - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - The head ref name to filter the pull requests by. - """ - headRefName: String - - """ - The base ref name to filter the pull requests by. - """ - baseRefName: String - - """ - Ordering options for pull requests returned from the connection. - """ - orderBy: IssueOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestConnection! - - """ - Identifies when the repository was last pushed to. - """ - pushedAt: DateTime - - """ - Whether or not rebase-merging is enabled on this repository. - """ - rebaseMergeAllowed: Boolean! - - """ - Fetch a given ref from the repository - """ - ref( - """ - The ref to retrieve. Fully qualified matches are checked in order - (`refs/heads/master`) before falling back onto checks for short name matches (`master`). - """ - qualifiedName: String! - ): Ref - - """ - Fetch a list of refs from the repository - """ - refs( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - A ref name prefix like `refs/heads/`, `refs/tags/`, etc. - """ - refPrefix: String! - - """ - DEPRECATED: use orderBy. The ordering direction. - """ - direction: OrderDirection - - """ - Ordering options for refs returned from the connection. - """ - orderBy: RefOrder - ): RefConnection - - """ - Lookup a single release given various criteria. - """ - release( - """ - The name of the Tag the Release was created from - """ - tagName: String! - ): Release - - """ - List of releases which are dependent on this repository. - """ - releases( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Order for connection - """ - orderBy: ReleaseOrder - ): ReleaseConnection! - - """ - A list of applied repository-topic associations for this repository. - """ - repositoryTopics( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryTopicConnection! - - """ - The HTTP path for this repository - """ - resourcePath: URI! - - """ - A description of the repository, rendered to HTML without any links in it. - """ - shortDescriptionHTML( - """ - How many characters to return. - """ - limit: Int = 200 - ): HTML! - - """ - Whether or not squash-merging is enabled on this repository. - """ - squashMergeAllowed: Boolean! - - """ - The SSH URL to clone this repository - """ - sshUrl: GitSSHRemote! - - """ - A list of users who have starred this starrable. - """ - stargazers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Order for connection - """ - orderBy: StarOrder - ): StargazerConnection! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this repository - """ - url: URI! - - """ - Indicates whether the viewer has admin permissions on this repository. - """ - viewerCanAdminister: Boolean! - - """ - Can the current viewer create new projects on this owner. - """ - viewerCanCreateProjects: Boolean! - - """ - Check if the viewer is able to change their subscription status for the repository. - """ - viewerCanSubscribe: Boolean! - - """ - Indicates whether the viewer can update the topics of this repository. - """ - viewerCanUpdateTopics: Boolean! - - """ - Returns a boolean indicating whether the viewing user has starred this starrable. - """ - viewerHasStarred: Boolean! - - """ - The users permission level on the repository. Will return null if authenticated as an GitHub App. - """ - viewerPermission: RepositoryPermission - - """ - Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. - """ - viewerSubscription: SubscriptionState - - """ - A list of users watching the repository. - """ - watchers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): UserConnection! -} - -""" -The affiliation of a user to a repository -""" -enum RepositoryAffiliation { - """ - Repositories that are owned by the authenticated user. - """ - OWNER - - """ - Repositories that the user has been added to as a collaborator. - """ - COLLABORATOR - - """ - Repositories that the user has access to through being a member of an - organization. This includes every repository on every team that the user is on. - """ - ORGANIZATION_MEMBER -} - -""" -The affiliation type between collaborator and repository. -""" -enum RepositoryCollaboratorAffiliation { - """ - All collaborators of the repository. - """ - ALL - - """ - All outside collaborators of an organization-owned repository. - """ - OUTSIDE -} - -""" -The connection type for User. -""" -type RepositoryCollaboratorConnection { - """ - A list of edges. - """ - edges: [RepositoryCollaboratorEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a user who is a collaborator of a repository. -""" -type RepositoryCollaboratorEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - node: User! - - """ - The permission the user has on the repository. - """ - permission: RepositoryPermission! - - """ - A list of sources for the user's access to the repository. - """ - permissionSources: [PermissionSource!] -} - -""" -A list of repositories owned by the subject. -""" -type RepositoryConnection { - """ - A list of edges. - """ - edges: [RepositoryEdge] - - """ - A list of nodes. - """ - nodes: [Repository] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! - - """ - The total size in kilobytes of all repositories in the connection. - """ - totalDiskUsage: Int! -} - -""" -The reason a repository is listed as 'contributed'. -""" -enum RepositoryContributionType { - """ - Created a commit - """ - COMMIT - - """ - Created an issue - """ - ISSUE - - """ - Created a pull request - """ - PULL_REQUEST - - """ - Created the repository - """ - REPOSITORY - - """ - Reviewed a pull request - """ - PULL_REQUEST_REVIEW -} - -""" -An edge in a connection. -""" -type RepositoryEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Repository -} - -""" -A subset of repository info. -""" -interface RepositoryInfo { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The description of the repository. - """ - description: String - - """ - The description of the repository rendered to HTML. - """ - descriptionHTML: HTML! - - """ - Returns how many forks there are of this repository in the whole network. - """ - forkCount: Int! - - """ - Indicates if the repository has issues feature enabled. - """ - hasIssuesEnabled: Boolean! - - """ - Indicates if the repository has wiki feature enabled. - """ - hasWikiEnabled: Boolean! - - """ - The repository's URL. - """ - homepageUrl: URI - - """ - Indicates if the repository is unmaintained. - """ - isArchived: Boolean! - - """ - Identifies if the repository is a fork. - """ - isFork: Boolean! - - """ - Indicates if the repository has been locked or not. - """ - isLocked: Boolean! - - """ - Identifies if the repository is a mirror. - """ - isMirror: Boolean! - - """ - Identifies if the repository is private. - """ - isPrivate: Boolean! - - """ - The license associated with the repository - """ - licenseInfo: License - - """ - The reason the repository has been locked. - """ - lockReason: RepositoryLockReason - - """ - The repository's original mirror URL. - """ - mirrorUrl: URI - - """ - The name of the repository. - """ - name: String! - - """ - The repository's name with owner. - """ - nameWithOwner: String! - - """ - The User owner of the repository. - """ - owner: RepositoryOwner! - - """ - Identifies when the repository was last pushed to. - """ - pushedAt: DateTime - - """ - The HTTP path for this repository - """ - resourcePath: URI! - - """ - A description of the repository, rendered to HTML without any links in it. - """ - shortDescriptionHTML( - """ - How many characters to return. - """ - limit: Int = 200 - ): HTML! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this repository - """ - url: URI! -} - -""" -An invitation for a user to be added to a repository. -""" -type RepositoryInvitation implements Node { - id: ID! - - """ - The user who received the invitation. - """ - invitee: User! - - """ - The user who created the invitation. - """ - inviter: User! - - """ - The permission granted on this repository by this invitation. - """ - permission: RepositoryPermission! - - """ - The Repository the user is invited to. - """ - repository: RepositoryInfo -} - -""" -An edge in a connection. -""" -type RepositoryInvitationEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: RepositoryInvitation -} - -""" -The possible reasons a given repository could be in a locked state. -""" -enum RepositoryLockReason { - """ - The repository is locked due to a move. - """ - MOVING - - """ - The repository is locked due to a billing related reason. - """ - BILLING - - """ - The repository is locked due to a rename. - """ - RENAME - - """ - The repository is locked due to a migration. - """ - MIGRATING -} - -""" -Represents a object that belongs to a repository. -""" -interface RepositoryNode { - """ - The repository associated with this node. - """ - repository: Repository! -} - -""" -Ordering options for repository connections -""" -input RepositoryOrder { - """ - The field to order repositories by. - """ - field: RepositoryOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which repository connections can be ordered. -""" -enum RepositoryOrderField { - """ - Order repositories by creation time - """ - CREATED_AT - - """ - Order repositories by update time - """ - UPDATED_AT - - """ - Order repositories by push time - """ - PUSHED_AT - - """ - Order repositories by name - """ - NAME - - """ - Order repositories by number of stargazers - """ - STARGAZERS -} - -""" -Represents an owner of a Repository. -""" -interface RepositoryOwner { - """ - A URL pointing to the owner's public avatar. - """ - avatarUrl( - """ - The size of the resulting square image. - """ - size: Int - ): URI! - id: ID! - - """ - The username used to login. - """ - login: String! - - """ - A list of repositories this user has pinned to their profile - """ - pinnedRepositories( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Array of viewer's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - current viewer owns. - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryConnection! - @deprecated( - reason: "pinnedRepositories will be removed Use ProfileOwner.pinnedItems instead. Removal on 2019-07-01 UTC." - ) - - """ - A list of repositories that the user owns. - """ - repositories( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Array of viewer's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - current viewer owns. - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - If non-null, filters repositories according to whether they are forks of another repository - """ - isFork: Boolean - ): RepositoryConnection! - - """ - Find Repository. - """ - repository( - """ - Name of Repository to find. - """ - name: String! - ): Repository - - """ - The HTTP URL for the owner. - """ - resourcePath: URI! - - """ - The HTTP URL for the owner. - """ - url: URI! -} - -""" -The access level to a repository -""" -enum RepositoryPermission { - """ - Can read, clone, push, and add collaborators - """ - ADMIN - - """ - Can read, clone and push - """ - WRITE - - """ - Can read and clone - """ - READ -} - -""" -The privacy of a repository -""" -enum RepositoryPrivacy { - """ - Public - """ - PUBLIC - - """ - Private - """ - PRIVATE -} - -""" -A repository-topic connects a repository to a topic. -""" -type RepositoryTopic implements Node & UniformResourceLocatable { - id: ID! - - """ - The HTTP path for this repository-topic. - """ - resourcePath: URI! - - """ - The topic. - """ - topic: Topic! - - """ - The HTTP URL for this repository-topic. - """ - url: URI! -} - -""" -The connection type for RepositoryTopic. -""" -type RepositoryTopicConnection { - """ - A list of edges. - """ - edges: [RepositoryTopicEdge] - - """ - A list of nodes. - """ - nodes: [RepositoryTopic] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type RepositoryTopicEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: RepositoryTopic -} - -""" -Types that can be requested reviewers. -""" -union RequestedReviewer = User | Team | Mannequin - -""" -Autogenerated input type of RequestReviews -""" -input RequestReviewsInput { - """ - The Node ID of the pull request to modify. - """ - pullRequestId: ID! - - """ - The Node IDs of the user to request. - """ - userIds: [ID!] - - """ - The Node IDs of the team to request. - """ - teamIds: [ID!] - - """ - Add users to the set rather than replace. - """ - union: Boolean - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of RequestReviews -""" -type RequestReviewsPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The pull request that is getting requests. - """ - pullRequest: PullRequest - - """ - The edge from the pull request to the requested reviewers. - """ - requestedReviewersEdge: UserEdge -} - -""" -Autogenerated input type of ResolveReviewThread -""" -input ResolveReviewThreadInput { - """ - The ID of the thread to resolve - """ - threadId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of ResolveReviewThread -""" -type ResolveReviewThreadPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The thread to resolve. - """ - thread: PullRequestReviewThread -} - -""" -Represents a private contribution a user made on GitHub. -""" -type RestrictedContribution implements Contribution { - """ - Whether this contribution is associated with a record you do not have access to. For - example, your own 'first issue' contribution may have been made on a repository you can no - longer access. - """ - isRestricted: Boolean! - - """ - When this contribution was made. - """ - occurredAt: DateTime! - - """ - The HTTP path for this contribution. - """ - resourcePath: URI! - - """ - The HTTP URL for this contribution. - """ - url: URI! - - """ - The user who made this contribution. - """ - user: User! -} - -""" -A team or user who has the ability to dismiss a review on a protected branch. -""" -type ReviewDismissalAllowance implements Node { - """ - The actor that can dismiss. - """ - actor: ReviewDismissalAllowanceActor - - """ - Identifies the branch protection rule associated with the allowed user or team. - """ - branchProtectionRule: BranchProtectionRule - id: ID! -} - -""" -Types that can be an actor. -""" -union ReviewDismissalAllowanceActor = User | Team - -""" -The connection type for ReviewDismissalAllowance. -""" -type ReviewDismissalAllowanceConnection { - """ - A list of edges. - """ - edges: [ReviewDismissalAllowanceEdge] - - """ - A list of nodes. - """ - nodes: [ReviewDismissalAllowance] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ReviewDismissalAllowanceEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: ReviewDismissalAllowance -} - -""" -Represents a 'review_dismissed' event on a given issue or pull request. -""" -type ReviewDismissedEvent implements Node & UniformResourceLocatable { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - Identifies the optional message associated with the 'review_dismissed' event. - """ - dismissalMessage: String - - """ - Identifies the optional message associated with the event, rendered to HTML. - """ - dismissalMessageHTML: String - id: ID! - - """ - Identifies the message associated with the 'review_dismissed' event. - """ - message: String! - @deprecated( - reason: "`message` is being removed because it not nullable, whereas the underlying field is optional. Use `dismissalMessage` instead. Removal on 2019-07-01 UTC." - ) - - """ - The message associated with the event, rendered to HTML. - """ - messageHtml: HTML! - @deprecated( - reason: "`messageHtml` is being removed because it not nullable, whereas the underlying field is optional. Use `dismissalMessageHTML` instead. Removal on 2019-07-01 UTC." - ) - - """ - Identifies the previous state of the review with the 'review_dismissed' event. - """ - previousReviewState: PullRequestReviewState! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! - - """ - Identifies the commit which caused the review to become stale. - """ - pullRequestCommit: PullRequestCommit - - """ - The HTTP path for this review dismissed event. - """ - resourcePath: URI! - - """ - Identifies the review associated with the 'review_dismissed' event. - """ - review: PullRequestReview - - """ - The HTTP URL for this review dismissed event. - """ - url: URI! -} - -""" -A request for a user to review a pull request. -""" -type ReviewRequest implements Node { - """ - Identifies the primary key from the database. - """ - databaseId: Int - id: ID! - - """ - Identifies the pull request associated with this review request. - """ - pullRequest: PullRequest! - - """ - The reviewer that is requested. - """ - requestedReviewer: RequestedReviewer -} - -""" -The connection type for ReviewRequest. -""" -type ReviewRequestConnection { - """ - A list of edges. - """ - edges: [ReviewRequestEdge] - - """ - A list of nodes. - """ - nodes: [ReviewRequest] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents an 'review_requested' event on a given pull request. -""" -type ReviewRequestedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! - - """ - Identifies the reviewer whose review was requested. - """ - requestedReviewer: RequestedReviewer -} - -""" -An edge in a connection. -""" -type ReviewRequestEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: ReviewRequest -} - -""" -Represents an 'review_request_removed' event on a given pull request. -""" -type ReviewRequestRemovedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - PullRequest referenced by event. - """ - pullRequest: PullRequest! - - """ - Identifies the reviewer whose review request was removed. - """ - requestedReviewer: RequestedReviewer -} - -""" -The results of a search. -""" -union SearchResultItem = - Issue - | PullRequest - | Repository - | User - | Organization - | MarketplaceListing - -""" -A list of results that matched against a search query. -""" -type SearchResultItemConnection { - """ - The number of pieces of code that matched the search query. - """ - codeCount: Int! - - """ - A list of edges. - """ - edges: [SearchResultItemEdge] - - """ - The number of issues that matched the search query. - """ - issueCount: Int! - - """ - A list of nodes. - """ - nodes: [SearchResultItem] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - The number of repositories that matched the search query. - """ - repositoryCount: Int! - - """ - The number of users that matched the search query. - """ - userCount: Int! - - """ - The number of wiki pages that matched the search query. - """ - wikiCount: Int! -} - -""" -An edge in a connection. -""" -type SearchResultItemEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: SearchResultItem - - """ - Text matches on the result found. - """ - textMatches: [TextMatch] -} - -""" -Represents the individual results of a search. -""" -enum SearchType { - """ - Returns results matching issues in repositories. - """ - ISSUE - - """ - Returns results matching repositories. - """ - REPOSITORY - - """ - Returns results matching users and organizations on GitHub. - """ - USER -} - -""" -A GitHub Security Advisory -""" -type SecurityAdvisory implements Node { - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - This is a long plaintext description of the advisory - """ - description: String! - - """ - The GitHub Security Advisory ID - """ - ghsaId: String! - id: ID! - - """ - A list of identifiers for this advisory - """ - identifiers: [SecurityAdvisoryIdentifier!]! - - """ - The organization that originated the advisory - """ - origin: String! - - """ - When the advisory was published - """ - publishedAt: DateTime! - - """ - A list of references for this advisory - """ - references: [SecurityAdvisoryReference!]! - - """ - The severity of the advisory - """ - severity: SecurityAdvisorySeverity! - - """ - A short plaintext summary of the advisory - """ - summary: String! - - """ - When the advisory was last updated - """ - updatedAt: DateTime! - - """ - Vulnerabilities associated with this Advisory - """ - vulnerabilities( - """ - Ordering options for the returned topics. - """ - orderBy: SecurityVulnerabilityOrder - - """ - An ecosystem to filter vulnerabilities by. - """ - ecosystem: SecurityAdvisoryEcosystem - - """ - A package name to filter vulnerabilities by. - """ - package: String - - """ - A list of severities to filter vulnerabilities by. - """ - severities: [SecurityAdvisorySeverity!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): SecurityVulnerabilityConnection! - - """ - When the advisory was withdrawn, if it has been withdrawn - """ - withdrawnAt: DateTime -} - -""" -The connection type for SecurityAdvisory. -""" -type SecurityAdvisoryConnection { - """ - A list of edges. - """ - edges: [SecurityAdvisoryEdge] - - """ - A list of nodes. - """ - nodes: [SecurityAdvisory] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -The possible ecosystems of a security vulnerability's package. -""" -enum SecurityAdvisoryEcosystem { - """ - Ruby gems hosted at RubyGems.org - """ - RUBYGEMS - - """ - JavaScript packages hosted at npmjs.com - """ - NPM - - """ - Python packages hosted at PyPI.org - """ - PIP - - """ - Java artifacts hosted at the Maven central repository - """ - MAVEN - - """ - .NET packages hosted at the NuGet Gallery - """ - NUGET -} - -""" -An edge in a connection. -""" -type SecurityAdvisoryEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: SecurityAdvisory -} - -""" -A GitHub Security Advisory Identifier -""" -type SecurityAdvisoryIdentifier { - """ - The identifier type, e.g. GHSA, CVE - """ - type: String! - - """ - The identifier - """ - value: String! -} - -""" -An advisory identifier to filter results on. -""" -input SecurityAdvisoryIdentifierFilter { - """ - The identifier type. - """ - type: SecurityAdvisoryIdentifierType! - - """ - The identifier string. Supports exact or partial matching. - """ - value: String! -} - -""" -Identifier formats available for advisories. -""" -enum SecurityAdvisoryIdentifierType { - """ - Common Vulnerabilities and Exposures Identifier. - """ - CVE - - """ - GitHub Security Advisory ID. - """ - GHSA -} - -""" -Ordering options for security advisory connections -""" -input SecurityAdvisoryOrder { - """ - The field to order security advisories by. - """ - field: SecurityAdvisoryOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which security advisory connections can be ordered. -""" -enum SecurityAdvisoryOrderField { - """ - Order advisories by publication time - """ - PUBLISHED_AT - - """ - Order advisories by update time - """ - UPDATED_AT -} - -""" -An individual package -""" -type SecurityAdvisoryPackage { - """ - The ecosystem the package belongs to, e.g. RUBYGEMS, NPM - """ - ecosystem: SecurityAdvisoryEcosystem! - - """ - The package name - """ - name: String! -} - -""" -An individual package version -""" -type SecurityAdvisoryPackageVersion { - """ - The package name or version - """ - identifier: String! -} - -""" -A GitHub Security Advisory Reference -""" -type SecurityAdvisoryReference { - """ - A publicly accessible reference - """ - url: URI! -} - -""" -Severity of the vulnerability. -""" -enum SecurityAdvisorySeverity { - """ - Low. - """ - LOW - - """ - Moderate. - """ - MODERATE - - """ - High. - """ - HIGH - - """ - Critical. - """ - CRITICAL -} - -""" -An individual vulnerability within an Advisory -""" -type SecurityVulnerability { - """ - The Advisory associated with this Vulnerability - """ - advisory: SecurityAdvisory! - - """ - The first version containing a fix for the vulnerability - """ - firstPatchedVersion: SecurityAdvisoryPackageVersion - - """ - A description of the vulnerable package - """ - package: SecurityAdvisoryPackage! - - """ - The severity of the vulnerability within this package - """ - severity: SecurityAdvisorySeverity! - - """ - When the vulnerability was last updated - """ - updatedAt: DateTime! - - """ - A string that describes the vulnerable package versions. - This string follows a basic syntax with a few forms. - + `= 0.2.0` denotes a single vulnerable version. - + `<= 1.0.8` denotes a version range up to and including the specified version - + `< 0.1.11` denotes a version range up to, but excluding, the specified version - + `>= 4.3.0, < 4.3.5` denotes a version range with a known minimum and maximum version. - + `>= 0.0.1` denotes a version range with a known minimum, but no known maximum - """ - vulnerableVersionRange: String! -} - -""" -The connection type for SecurityVulnerability. -""" -type SecurityVulnerabilityConnection { - """ - A list of edges. - """ - edges: [SecurityVulnerabilityEdge] - - """ - A list of nodes. - """ - nodes: [SecurityVulnerability] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type SecurityVulnerabilityEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: SecurityVulnerability -} - -""" -Ordering options for security vulnerability connections -""" -input SecurityVulnerabilityOrder { - """ - The field to order security vulnerabilities by. - """ - field: SecurityVulnerabilityOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which security vulnerability connections can be ordered. -""" -enum SecurityVulnerabilityOrderField { - """ - Order vulnerability by update time - """ - UPDATED_AT -} - -""" -Represents an S/MIME signature on a Commit or Tag. -""" -type SmimeSignature implements GitSignature { - """ - Email used to sign this object. - """ - email: String! - - """ - True if the signature is valid and verified by GitHub. - """ - isValid: Boolean! - - """ - Payload for GPG signing object. Raw ODB object without the signature header. - """ - payload: String! - - """ - ASCII-armored signature header from object. - """ - signature: String! - - """ - GitHub user corresponding to the email signing this commit. - """ - signer: User - - """ - The state of this signature. `VALID` if signature is valid and verified by - GitHub, otherwise represents reason why signature is considered invalid. - """ - state: GitSignatureState! - - """ - True if the signature was made with GitHub's signing key. - """ - wasSignedByGitHub: Boolean! -} - -""" -The connection type for User. -""" -type StargazerConnection { - """ - A list of edges. - """ - edges: [StargazerEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a user that's starred a repository. -""" -type StargazerEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - node: User! - - """ - Identifies when the item was starred. - """ - starredAt: DateTime! -} - -""" -Ways in which star connections can be ordered. -""" -input StarOrder { - """ - The field in which to order nodes by. - """ - field: StarOrderField! - - """ - The direction in which to order nodes. - """ - direction: OrderDirection! -} - -""" -Properties by which star connections can be ordered. -""" -enum StarOrderField { - """ - Allows ordering a list of stars by when they were created. - """ - STARRED_AT -} - -""" -Things that can be starred. -""" -interface Starrable { - id: ID! - - """ - A list of users who have starred this starrable. - """ - stargazers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Order for connection - """ - orderBy: StarOrder - ): StargazerConnection! - - """ - Returns a boolean indicating whether the viewing user has starred this starrable. - """ - viewerHasStarred: Boolean! -} - -""" -The connection type for Repository. -""" -type StarredRepositoryConnection { - """ - A list of edges. - """ - edges: [StarredRepositoryEdge] - - """ - A list of nodes. - """ - nodes: [Repository] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a starred repository. -""" -type StarredRepositoryEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - node: Repository! - - """ - Identifies when the item was starred. - """ - starredAt: DateTime! -} - -""" -Represents a commit status. -""" -type Status implements Node { - """ - The commit this status is attached to. - """ - commit: Commit - - """ - Looks up an individual status context by context name. - """ - context( - """ - The context name. - """ - name: String! - ): StatusContext - - """ - The individual status contexts for this commit. - """ - contexts: [StatusContext!]! - id: ID! - - """ - The combined commit status. - """ - state: StatusState! -} - -""" -Represents an individual commit status context -""" -type StatusContext implements Node { - """ - This commit this status context is attached to. - """ - commit: Commit - - """ - The name of this status context. - """ - context: String! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The actor who created this status context. - """ - creator: Actor - - """ - The description for this status context. - """ - description: String - id: ID! - - """ - The state of this status context. - """ - state: StatusState! - - """ - The URL for this status context. - """ - targetUrl: URI -} - -""" -The possible commit status states. -""" -enum StatusState { - """ - Status is expected. - """ - EXPECTED - - """ - Status is errored. - """ - ERROR - - """ - Status is failing. - """ - FAILURE - - """ - Status is pending. - """ - PENDING - - """ - Status is successful. - """ - SUCCESS -} - -""" -Autogenerated input type of SubmitPullRequestReview -""" -input SubmitPullRequestReviewInput { - """ - The Pull Request Review ID to submit. - """ - pullRequestReviewId: ID! - - """ - The event to send to the Pull Request Review. - """ - event: PullRequestReviewEvent! - - """ - The text field to set on the Pull Request Review. - """ - body: String - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of SubmitPullRequestReview -""" -type SubmitPullRequestReviewPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The submitted pull request review. - """ - pullRequestReview: PullRequestReview -} - -""" -Entities that can be subscribed to for web and email notifications. -""" -interface Subscribable { - id: ID! - - """ - Check if the viewer is able to change their subscription status for the repository. - """ - viewerCanSubscribe: Boolean! - - """ - Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. - """ - viewerSubscription: SubscriptionState -} - -""" -Represents a 'subscribed' event on a given `Subscribable`. -""" -type SubscribedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Object referenced by event. - """ - subscribable: Subscribable! -} - -""" -The possible states of a subscription. -""" -enum SubscriptionState { - """ - The User is only notified when participating or @mentioned. - """ - UNSUBSCRIBED - - """ - The User is notified of all conversations. - """ - SUBSCRIBED - - """ - The User is never notified. - """ - IGNORED -} - -""" -A suggestion to review a pull request based on a user's commit history and review comments. -""" -type SuggestedReviewer { - """ - Is this suggestion based on past commits? - """ - isAuthor: Boolean! - - """ - Is this suggestion based on past review comments? - """ - isCommenter: Boolean! - - """ - Identifies the user suggested to review the pull request. - """ - reviewer: User! -} - -""" -Represents a Git tag. -""" -type Tag implements Node & GitObject { - """ - An abbreviated version of the Git object ID - """ - abbreviatedOid: String! - - """ - The HTTP path for this Git object - """ - commitResourcePath: URI! - - """ - The HTTP URL for this Git object - """ - commitUrl: URI! - id: ID! - - """ - The Git tag message. - """ - message: String - - """ - The Git tag name. - """ - name: String! - - """ - The Git object ID - """ - oid: GitObjectID! - - """ - The Repository the Git object belongs to - """ - repository: Repository! - - """ - Details about the tag author. - """ - tagger: GitActor - - """ - The Git object the tag points to. - """ - target: GitObject! -} - -""" -A team of users in an organization. -""" -type Team implements Node & Subscribable & MemberStatusable { - """ - A list of teams that are ancestors of this team. - """ - ancestors( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): TeamConnection! - - """ - A URL pointing to the team's avatar. - """ - avatarUrl( - """ - The size in pixels of the resulting square image. - """ - size: Int = 400 - ): URI - - """ - List of child teams belonging to this team - """ - childTeams( - """ - Order for connection - """ - orderBy: TeamOrder - - """ - User logins to filter by - """ - userLogins: [String!] - - """ - Whether to list immediate child teams or all descendant child teams. - """ - immediateOnly: Boolean = true - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): TeamConnection! - - """ - The slug corresponding to the organization and team. - """ - combinedSlug: String! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The description of the team. - """ - description: String - - """ - The HTTP path for editing this team - """ - editTeamResourcePath: URI! - - """ - The HTTP URL for editing this team - """ - editTeamUrl: URI! - id: ID! - - """ - A list of pending invitations for users to this team - """ - invitations( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): OrganizationInvitationConnection - - """ - Get the status messages members of this entity have set that are either public or visible only to the organization. - """ - memberStatuses( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for user statuses returned from the connection. - """ - orderBy: UserStatusOrder - ): UserStatusConnection! - - """ - A list of users who are members of this team. - """ - members( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - The search string to look for. - """ - query: String - - """ - Filter by membership type - """ - membership: TeamMembershipType = ALL - - """ - Filter by team member role - """ - role: TeamMemberRole - - """ - Order for the connection. - """ - orderBy: TeamMemberOrder - ): TeamMemberConnection! - - """ - The HTTP path for the team' members - """ - membersResourcePath: URI! - - """ - The HTTP URL for the team' members - """ - membersUrl: URI! - - """ - The name of the team. - """ - name: String! - - """ - The HTTP path creating a new team - """ - newTeamResourcePath: URI! - - """ - The HTTP URL creating a new team - """ - newTeamUrl: URI! - - """ - The organization that owns this team. - """ - organization: Organization! - - """ - The parent team of the team. - """ - parentTeam: Team - - """ - The level of privacy the team has. - """ - privacy: TeamPrivacy! - - """ - A list of repositories this team has access to. - """ - repositories( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - The search string to look for. - """ - query: String - - """ - Order for the connection. - """ - orderBy: TeamRepositoryOrder - ): TeamRepositoryConnection! - - """ - The HTTP path for this team's repositories - """ - repositoriesResourcePath: URI! - - """ - The HTTP URL for this team's repositories - """ - repositoriesUrl: URI! - - """ - The HTTP path for this team - """ - resourcePath: URI! - - """ - The slug corresponding to the team. - """ - slug: String! - - """ - The HTTP path for this team's teams - """ - teamsResourcePath: URI! - - """ - The HTTP URL for this team's teams - """ - teamsUrl: URI! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this team - """ - url: URI! - - """ - Team is adminable by the viewer. - """ - viewerCanAdminister: Boolean! - - """ - Check if the viewer is able to change their subscription status for the repository. - """ - viewerCanSubscribe: Boolean! - - """ - Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. - """ - viewerSubscription: SubscriptionState -} - -""" -The connection type for Team. -""" -type TeamConnection { - """ - A list of edges. - """ - edges: [TeamEdge] - - """ - A list of nodes. - """ - nodes: [Team] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type TeamEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Team -} - -""" -The connection type for User. -""" -type TeamMemberConnection { - """ - A list of edges. - """ - edges: [TeamMemberEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a user who is a member of a team. -""" -type TeamMemberEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The HTTP path to the organization's member access page. - """ - memberAccessResourcePath: URI! - - """ - The HTTP URL to the organization's member access page. - """ - memberAccessUrl: URI! - node: User! - - """ - The role the member has on the team. - """ - role: TeamMemberRole! -} - -""" -Ordering options for team member connections -""" -input TeamMemberOrder { - """ - The field to order team members by. - """ - field: TeamMemberOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which team member connections can be ordered. -""" -enum TeamMemberOrderField { - """ - Order team members by login - """ - LOGIN - - """ - Order team members by creation time - """ - CREATED_AT -} - -""" -The possible team member roles; either 'maintainer' or 'member'. -""" -enum TeamMemberRole { - """ - A team maintainer has permission to add and remove team members. - """ - MAINTAINER - - """ - A team member has no administrative permissions on the team. - """ - MEMBER -} - -""" -Defines which types of team members are included in the returned list. Can be one of IMMEDIATE, CHILD_TEAM or ALL. -""" -enum TeamMembershipType { - """ - Includes only immediate members of the team. - """ - IMMEDIATE - - """ - Includes only child team members for the team. - """ - CHILD_TEAM - - """ - Includes immediate and child team members for the team. - """ - ALL -} - -""" -Ways in which team connections can be ordered. -""" -input TeamOrder { - """ - The field in which to order nodes by. - """ - field: TeamOrderField! - - """ - The direction in which to order nodes. - """ - direction: OrderDirection! -} - -""" -Properties by which team connections can be ordered. -""" -enum TeamOrderField { - """ - Allows ordering a list of teams by name. - """ - NAME -} - -""" -The possible team privacy values. -""" -enum TeamPrivacy { - """ - A secret team can only be seen by its members. - """ - SECRET - - """ - A visible team can be seen and @mentioned by every member of the organization. - """ - VISIBLE -} - -""" -The connection type for Repository. -""" -type TeamRepositoryConnection { - """ - A list of edges. - """ - edges: [TeamRepositoryEdge] - - """ - A list of nodes. - """ - nodes: [Repository] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -Represents a team repository. -""" -type TeamRepositoryEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - node: Repository! - - """ - The permission level the team has on the repository - """ - permission: RepositoryPermission! -} - -""" -Ordering options for team repository connections -""" -input TeamRepositoryOrder { - """ - The field to order repositories by. - """ - field: TeamRepositoryOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which team repository connections can be ordered. -""" -enum TeamRepositoryOrderField { - """ - Order repositories by creation time - """ - CREATED_AT - - """ - Order repositories by update time - """ - UPDATED_AT - - """ - Order repositories by push time - """ - PUSHED_AT - - """ - Order repositories by name - """ - NAME - - """ - Order repositories by permission - """ - PERMISSION - - """ - Order repositories by number of stargazers - """ - STARGAZERS -} - -""" -The role of a user on a team. -""" -enum TeamRole { - """ - User has admin rights on the team. - """ - ADMIN - - """ - User is a member of the team. - """ - MEMBER -} - -""" -A text match within a search result. -""" -type TextMatch { - """ - The specific text fragment within the property matched on. - """ - fragment: String! - - """ - Highlights within the matched fragment. - """ - highlights: [TextMatchHighlight!]! - - """ - The property matched on. - """ - property: String! -} - -""" -Represents a single highlight in a search result match. -""" -type TextMatchHighlight { - """ - The indice in the fragment where the matched text begins. - """ - beginIndice: Int! - - """ - The indice in the fragment where the matched text ends. - """ - endIndice: Int! - - """ - The text matched. - """ - text: String! -} - -""" -A topic aggregates entities that are related to a subject. -""" -type Topic implements Node & Starrable { - id: ID! - - """ - The topic's name. - """ - name: String! - - """ - A list of related topics, including aliases of this topic, sorted with the most relevant - first. Returns up to 10 Topics. - """ - relatedTopics( - """ - How many topics to return. - """ - first: Int = 3 - ): [Topic!]! - - """ - A list of users who have starred this starrable. - """ - stargazers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Order for connection - """ - orderBy: StarOrder - ): StargazerConnection! - - """ - Returns a boolean indicating whether the viewing user has starred this starrable. - """ - viewerHasStarred: Boolean! -} - -""" -The connection type for Topic. -""" -type TopicConnection { - """ - A list of edges. - """ - edges: [TopicEdge] - - """ - A list of nodes. - """ - nodes: [Topic] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type TopicEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: Topic -} - -""" -Reason that the suggested topic is declined. -""" -enum TopicSuggestionDeclineReason { - """ - The suggested topic is not relevant to the repository. - """ - NOT_RELEVANT - - """ - The suggested topic is too specific for the repository (e.g. #ruby-on-rails-version-4-2-1). - """ - TOO_SPECIFIC - - """ - The viewer does not like the suggested topic. - """ - PERSONAL_PREFERENCE - - """ - The suggested topic is too general for the repository. - """ - TOO_GENERAL -} - -""" -Represents a 'transferred' event on a given issue or pull request. -""" -type TransferredEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - The repository this came from - """ - fromRepository: Repository - id: ID! - - """ - Identifies the issue associated with the event. - """ - issue: Issue! -} - -""" -Represents a Git tree. -""" -type Tree implements Node & GitObject { - """ - An abbreviated version of the Git object ID - """ - abbreviatedOid: String! - - """ - The HTTP path for this Git object - """ - commitResourcePath: URI! - - """ - The HTTP URL for this Git object - """ - commitUrl: URI! - - """ - A list of tree entries. - """ - entries: [TreeEntry!] - id: ID! - - """ - The Git object ID - """ - oid: GitObjectID! - - """ - The Repository the Git object belongs to - """ - repository: Repository! -} - -""" -Represents a Git tree entry. -""" -type TreeEntry { - """ - Entry file mode. - """ - mode: Int! - - """ - Entry file name. - """ - name: String! - - """ - Entry file object. - """ - object: GitObject - - """ - Entry file Git object ID. - """ - oid: GitObjectID! - - """ - The Repository the tree entry belongs to - """ - repository: Repository! - - """ - Entry file type. - """ - type: String! -} - -""" -Represents an 'unassigned' event on any assignable object. -""" -type UnassignedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the assignable associated with the event. - """ - assignable: Assignable! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the subject (user) who was unassigned. - """ - user: User -} - -""" -Represents a type that can be retrieved by a URL. -""" -interface UniformResourceLocatable { - """ - The HTML path to this resource. - """ - resourcePath: URI! - - """ - The URL to this resource. - """ - url: URI! -} - -""" -Represents an unknown signature on a Commit or Tag. -""" -type UnknownSignature implements GitSignature { - """ - Email used to sign this object. - """ - email: String! - - """ - True if the signature is valid and verified by GitHub. - """ - isValid: Boolean! - - """ - Payload for GPG signing object. Raw ODB object without the signature header. - """ - payload: String! - - """ - ASCII-armored signature header from object. - """ - signature: String! - - """ - GitHub user corresponding to the email signing this commit. - """ - signer: User - - """ - The state of this signature. `VALID` if signature is valid and verified by - GitHub, otherwise represents reason why signature is considered invalid. - """ - state: GitSignatureState! - - """ - True if the signature was made with GitHub's signing key. - """ - wasSignedByGitHub: Boolean! -} - -""" -Represents an 'unlabeled' event on a given issue or pull request. -""" -type UnlabeledEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the label associated with the 'unlabeled' event. - """ - label: Label! - - """ - Identifies the `Labelable` associated with the event. - """ - labelable: Labelable! -} - -""" -Represents an 'unlocked' event on a given issue or pull request. -""" -type UnlockedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Object that was unlocked. - """ - lockable: Lockable! -} - -""" -Autogenerated input type of UnlockLockable -""" -input UnlockLockableInput { - """ - ID of the issue or pull request to be unlocked. - """ - lockableId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UnlockLockable -""" -type UnlockLockablePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The item that was unlocked. - """ - unlockedRecord: Lockable -} - -""" -Autogenerated input type of UnmarkIssueAsDuplicate -""" -input UnmarkIssueAsDuplicateInput { - """ - ID of the issue or pull request currently marked as a duplicate. - """ - duplicateId: ID! - - """ - ID of the issue or pull request currently considered canonical/authoritative/original. - """ - canonicalId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UnmarkIssueAsDuplicate -""" -type UnmarkIssueAsDuplicatePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The issue or pull request that was marked as a duplicate. - """ - duplicate: IssueOrPullRequest -} - -""" -Autogenerated input type of UnminimizeComment -""" -input UnminimizeCommentInput { - """ - The Node ID of the subject to modify. - """ - subjectId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated input type of UnpinIssue -""" -input UnpinIssueInput { - """ - The ID of the issue to be unpinned - """ - issueId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Represents an 'unpinned' event on a given issue or pull request. -""" -type UnpinnedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Identifies the issue associated with the event. - """ - issue: Issue! -} - -""" -Autogenerated input type of UnresolveReviewThread -""" -input UnresolveReviewThreadInput { - """ - The ID of the thread to unresolve - """ - threadId: ID! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UnresolveReviewThread -""" -type UnresolveReviewThreadPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The thread to resolve. - """ - thread: PullRequestReviewThread -} - -""" -Represents an 'unsubscribed' event on a given `Subscribable`. -""" -type UnsubscribedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - Object referenced by event. - """ - subscribable: Subscribable! -} - -""" -Entities that can be updated. -""" -interface Updatable { - """ - Check if the current viewer can update this object. - """ - viewerCanUpdate: Boolean! -} - -""" -Comments that can be updated. -""" -interface UpdatableComment { - """ - Reasons why the current viewer can not update this comment. - """ - viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! -} - -""" -Autogenerated input type of UpdateBranchProtectionRule -""" -input UpdateBranchProtectionRuleInput { - """ - The global relay id of the branch protection rule to be updated. - """ - branchProtectionRuleId: ID! - - """ - The glob-like pattern used to determine matching branches. - """ - pattern: String - - """ - Are approving reviews required to update matching branches. - """ - requiresApprovingReviews: Boolean - - """ - Number of approving reviews required to update matching branches. - """ - requiredApprovingReviewCount: Int - - """ - Are commits required to be signed. - """ - requiresCommitSignatures: Boolean - - """ - Can admins overwrite branch protection. - """ - isAdminEnforced: Boolean - - """ - Are status checks required to update matching branches. - """ - requiresStatusChecks: Boolean - - """ - Are branches required to be up to date before merging. - """ - requiresStrictStatusChecks: Boolean - - """ - Are reviews from code owners required to update matching branches. - """ - requiresCodeOwnerReviews: Boolean - - """ - Will new commits pushed to matching branches dismiss pull request review approvals. - """ - dismissesStaleReviews: Boolean - - """ - Is dismissal of pull request reviews restricted. - """ - restrictsReviewDismissals: Boolean - - """ - A list of User or Team IDs allowed to dismiss reviews on pull requests targeting matching branches. - """ - reviewDismissalActorIds: [ID!] - - """ - Is pushing to matching branches restricted. - """ - restrictsPushes: Boolean - - """ - A list of User or Team IDs allowed to push to matching branches. - """ - pushActorIds: [ID!] - - """ - List of required status check contexts that must pass for commits to be accepted to matching branches. - """ - requiredStatusCheckContexts: [String!] - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateBranchProtectionRule -""" -type UpdateBranchProtectionRulePayload { - """ - The newly created BranchProtectionRule. - """ - branchProtectionRule: BranchProtectionRule - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated input type of UpdateIssueComment -""" -input UpdateIssueCommentInput { - """ - The ID of the IssueComment to modify. - """ - id: ID! - - """ - The updated text of the comment. - """ - body: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateIssueComment -""" -type UpdateIssueCommentPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated comment. - """ - issueComment: IssueComment -} - -""" -Autogenerated input type of UpdateIssue -""" -input UpdateIssueInput { - """ - The ID of the Issue to modify. - """ - id: ID! - - """ - The title for the issue. - """ - title: String - - """ - The body for the issue description. - """ - body: String - - """ - An array of Node IDs of users for this issue. - """ - assigneeIds: [ID!] - - """ - The Node ID of the milestone for this issue. - """ - milestoneId: ID - - """ - An array of Node IDs of labels for this issue. - """ - labelIds: [ID!] - - """ - The desired issue state. - """ - state: IssueState - - """ - An array of Node IDs for projects associated with this issue. - """ - projectIds: [ID!] - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateIssue -""" -type UpdateIssuePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The issue. - """ - issue: Issue -} - -""" -Autogenerated input type of UpdateProjectCard -""" -input UpdateProjectCardInput { - """ - The ProjectCard ID to update. - """ - projectCardId: ID! - - """ - Whether or not the ProjectCard should be archived - """ - isArchived: Boolean - - """ - The note of ProjectCard. - """ - note: String - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateProjectCard -""" -type UpdateProjectCardPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated ProjectCard. - """ - projectCard: ProjectCard -} - -""" -Autogenerated input type of UpdateProjectColumn -""" -input UpdateProjectColumnInput { - """ - The ProjectColumn ID to update. - """ - projectColumnId: ID! - - """ - The name of project column. - """ - name: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateProjectColumn -""" -type UpdateProjectColumnPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated project column. - """ - projectColumn: ProjectColumn -} - -""" -Autogenerated input type of UpdateProject -""" -input UpdateProjectInput { - """ - The Project ID to update. - """ - projectId: ID! - - """ - The name of project. - """ - name: String - - """ - The description of project. - """ - body: String - - """ - Whether the project is open or closed. - """ - state: ProjectState - - """ - Whether the project is public or not. - """ - public: Boolean - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateProject -""" -type UpdateProjectPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated project. - """ - project: Project -} - -""" -Autogenerated input type of UpdatePullRequest -""" -input UpdatePullRequestInput { - """ - The Node ID of the pull request. - """ - pullRequestId: ID! - - """ - The name of the branch you want your changes pulled into. This should be an existing branch - on the current repository. - """ - baseRefName: String - - """ - The title of the pull request. - """ - title: String - - """ - The contents of the pull request. - """ - body: String - - """ - Indicates whether maintainers can modify the pull request. - """ - maintainerCanModify: Boolean - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdatePullRequest -""" -type UpdatePullRequestPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated pull request. - """ - pullRequest: PullRequest -} - -""" -Autogenerated input type of UpdatePullRequestReviewComment -""" -input UpdatePullRequestReviewCommentInput { - """ - The Node ID of the comment to modify. - """ - pullRequestReviewCommentId: ID! - - """ - The text of the comment. - """ - body: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdatePullRequestReviewComment -""" -type UpdatePullRequestReviewCommentPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated comment. - """ - pullRequestReviewComment: PullRequestReviewComment -} - -""" -Autogenerated input type of UpdatePullRequestReview -""" -input UpdatePullRequestReviewInput { - """ - The Node ID of the pull request review to modify. - """ - pullRequestReviewId: ID! - - """ - The contents of the pull request review body. - """ - body: String! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdatePullRequestReview -""" -type UpdatePullRequestReviewPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The updated pull request review. - """ - pullRequestReview: PullRequestReview -} - -""" -Autogenerated input type of UpdateSubscription -""" -input UpdateSubscriptionInput { - """ - The Node ID of the subscribable object to modify. - """ - subscribableId: ID! - - """ - The new state of the subscription. - """ - state: SubscriptionState! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateSubscription -""" -type UpdateSubscriptionPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - The input subscribable entity. - """ - subscribable: Subscribable -} - -""" -Autogenerated input type of UpdateTopics -""" -input UpdateTopicsInput { - """ - The Node ID of the repository. - """ - repositoryId: ID! - - """ - An array of topic names. - """ - topicNames: [String!]! - - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String -} - -""" -Autogenerated return type of UpdateTopics -""" -type UpdateTopicsPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationId: String - - """ - Names of the provided topics that are not valid. - """ - invalidTopicNames: [String!] - - """ - The updated repository. - """ - repository: Repository -} - -""" -An RFC 3986, RFC 3987, and RFC 6570 (level 4) compliant URI string. -""" -scalar URI - -""" -A user is an individual's account on GitHub that owns repositories and can make new content. -""" -type User implements Node & Actor & RegistryPackageOwner & RegistryPackageSearch & ProjectOwner & RepositoryOwner & UniformResourceLocatable & ProfileOwner { - """ - Determine if this repository owner has any items that can be pinned to their profile. - """ - anyPinnableItems( - """ - Filter to only a particular kind of pinnable item. - """ - type: PinnableItemType - ): Boolean! - - """ - A URL pointing to the user's public avatar. - """ - avatarUrl( - """ - The size of the resulting square image. - """ - size: Int - ): URI! - - """ - The user's public profile bio. - """ - bio: String - - """ - The user's public profile bio as HTML. - """ - bioHTML: HTML! - - """ - A list of commit comments made by this user. - """ - commitComments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): CommitCommentConnection! - - """ - The user's public profile company. - """ - company: String - - """ - The user's public profile company as HTML. - """ - companyHTML: HTML! - - """ - The collection of contributions this user has made to different repositories. - """ - contributionsCollection( - """ - The ID of the organization used to filter contributions. - """ - organizationID: ID - - """ - Only contributions made at this time or later will be counted. If omitted, defaults to a year ago. - """ - from: DateTime - - """ - Only contributions made before and up to and including this time will be - counted. If omitted, defaults to the current time. - """ - to: DateTime - ): ContributionsCollection! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the primary key from the database. - """ - databaseId: Int - - """ - The user's publicly visible profile email. - """ - email: String! - - """ - A list of users the given user is followed by. - """ - followers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): FollowerConnection! - - """ - A list of users the given user is following. - """ - following( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): FollowingConnection! - - """ - Find gist by repo name. - """ - gist( - """ - The gist name to find. - """ - name: String! - ): Gist - - """ - A list of gist comments made by this user. - """ - gistComments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): GistCommentConnection! - - """ - A list of the Gists the user has created. - """ - gists( - """ - Filters Gists according to privacy. - """ - privacy: GistPrivacy - - """ - Ordering options for gists returned from the connection - """ - orderBy: GistOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): GistConnection! - id: ID! - - """ - Whether or not this user is a participant in the GitHub Security Bug Bounty. - """ - isBountyHunter: Boolean! - - """ - Whether or not this user is a participant in the GitHub Campus Experts Program. - """ - isCampusExpert: Boolean! - - """ - Whether or not this user is a GitHub Developer Program member. - """ - isDeveloperProgramMember: Boolean! - - """ - Whether or not this user is a GitHub employee. - """ - isEmployee: Boolean! - - """ - Whether or not the user has marked themselves as for hire. - """ - isHireable: Boolean! - - """ - Whether or not this user is a site administrator. - """ - isSiteAdmin: Boolean! - - """ - Whether or not this user is the viewing user. - """ - isViewer: Boolean! - - """ - A list of issue comments made by this user. - """ - issueComments( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueCommentConnection! - - """ - A list of issues associated with this user. - """ - issues( - """ - Ordering options for issues returned from the connection. - """ - orderBy: IssueOrder - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - A list of states to filter the issues by. - """ - states: [IssueState!] - - """ - Filtering options for issues returned from the connection. - """ - filterBy: IssueFilters - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): IssueConnection! - - """ - Showcases a selection of repositories and gists that the profile owner has - either curated or that have been selected automatically based on popularity. - """ - itemShowcase: ProfileItemShowcase! - - """ - The user's public profile location. - """ - location: String - - """ - The username used to login. - """ - login: String! - - """ - The user's public profile name. - """ - name: String - - """ - Find an organization by its login that the user belongs to. - """ - organization( - """ - The login of the organization to find. - """ - login: String! - ): Organization - - """ - A list of organizations the user belongs to. - """ - organizations( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): OrganizationConnection! - - """ - A list of repositories and gists this profile owner can pin to their profile. - """ - pinnableItems( - """ - Filter the types of pinnable items that are returned. - """ - types: [PinnableItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PinnableItemConnection! - - """ - A list of repositories and gists this profile owner has pinned to their profile - """ - pinnedItems( - """ - Filter the types of pinned items that are returned. - """ - types: [PinnableItemType!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PinnableItemConnection! - - """ - Returns how many more items this profile owner can pin to their profile. - """ - pinnedItemsRemaining: Int! - - """ - A list of repositories this user has pinned to their profile - """ - pinnedRepositories( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Array of viewer's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - current viewer owns. - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryConnection! - @deprecated( - reason: "pinnedRepositories will be removed Use ProfileOwner.pinnedItems instead. Removal on 2019-07-01 UTC." - ) - - """ - Find project by number. - """ - project( - """ - The project number to find. - """ - number: Int! - ): Project - - """ - A list of projects under the owner. - """ - projects( - """ - Ordering options for projects returned from the connection - """ - orderBy: ProjectOrder - - """ - Query to search projects by, currently only searching by name. - """ - search: String - - """ - A list of states to filter the projects by. - """ - states: [ProjectState!] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): ProjectConnection! - - """ - The HTTP path listing user's projects - """ - projectsResourcePath: URI! - - """ - The HTTP URL listing user's projects - """ - projectsUrl: URI! - - """ - A list of public keys associated with this user. - """ - publicKeys( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PublicKeyConnection! - - """ - A list of pull requests associated with this user. - """ - pullRequests( - """ - A list of states to filter the pull requests by. - """ - states: [PullRequestState!] - - """ - A list of label names to filter the pull requests by. - """ - labels: [String!] - - """ - The head ref name to filter the pull requests by. - """ - headRefName: String - - """ - The base ref name to filter the pull requests by. - """ - baseRefName: String - - """ - Ordering options for pull requests returned from the connection. - """ - orderBy: IssueOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): PullRequestConnection! - - """ - A list of repositories that the user owns. - """ - repositories( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Array of viewer's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - current viewer owns. - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - If non-null, filters repositories according to whether they are forks of another repository - """ - isFork: Boolean - ): RepositoryConnection! - - """ - A list of repositories that the user recently contributed to. - """ - repositoriesContributedTo( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - If true, include user repositories - """ - includeUserRepositories: Boolean - - """ - If non-null, include only the specified types of contributions. The - GitHub.com UI uses [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY] - """ - contributionTypes: [RepositoryContributionType] - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryConnection! - - """ - Find Repository. - """ - repository( - """ - Name of Repository to find. - """ - name: String! - ): Repository - - """ - The HTTP path for this user - """ - resourcePath: URI! - - """ - Repositories the user has starred. - """ - starredRepositories( - """ - Filters starred repositories to only return repositories owned by the viewer. - """ - ownedByViewer: Boolean - - """ - Order for connection - """ - orderBy: StarOrder - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): StarredRepositoryConnection! - - """ - The user's description of what they're currently doing. - """ - status: UserStatus - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The HTTP URL for this user - """ - url: URI! - - """ - Can the viewer pin repositories and gists to the profile? - """ - viewerCanChangePinnedItems: Boolean! - - """ - Can the current viewer create new projects on this owner. - """ - viewerCanCreateProjects: Boolean! - - """ - Whether or not the viewer is able to follow the user. - """ - viewerCanFollow: Boolean! - - """ - Whether or not this user is followed by the viewer. - """ - viewerIsFollowing: Boolean! - - """ - A list of repositories the given user is watching. - """ - watching( - """ - If non-null, filters repositories according to privacy - """ - privacy: RepositoryPrivacy - - """ - Ordering options for repositories returned from the connection - """ - orderBy: RepositoryOrder - - """ - Affiliation options for repositories returned from the connection - """ - affiliations: [RepositoryAffiliation] - - """ - Array of owner's affiliation options for repositories returned from the - connection. For example, OWNER will include only repositories that the - organization or user being viewed owns. - """ - ownerAffiliations: [RepositoryAffiliation] - - """ - If non-null, filters repositories according to whether they have been locked - """ - isLocked: Boolean - - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - ): RepositoryConnection! - - """ - A URL pointing to the user's public website/blog. - """ - websiteUrl: URI -} - -""" -The possible durations that a user can be blocked for. -""" -enum UserBlockDuration { - """ - The user was blocked for 1 day - """ - ONE_DAY - - """ - The user was blocked for 3 days - """ - THREE_DAYS - - """ - The user was blocked for 7 days - """ - ONE_WEEK - - """ - The user was blocked for 30 days - """ - ONE_MONTH - - """ - The user was blocked permanently - """ - PERMANENT -} - -""" -Represents a 'user_blocked' event on a given user. -""" -type UserBlockedEvent implements Node { - """ - Identifies the actor who performed the event. - """ - actor: Actor - - """ - Number of days that the user was blocked for. - """ - blockDuration: UserBlockDuration! - - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - id: ID! - - """ - The user who was blocked. - """ - subject: User -} - -""" -The connection type for User. -""" -type UserConnection { - """ - A list of edges. - """ - edges: [UserEdge] - - """ - A list of nodes. - """ - nodes: [User] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edit on user content -""" -type UserContentEdit implements Node { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - Identifies the date and time when the object was deleted. - """ - deletedAt: DateTime - - """ - The actor who deleted this content - """ - deletedBy: Actor - - """ - A summary of the changes for this edit - """ - diff: String - - """ - When this content was edited - """ - editedAt: DateTime! - - """ - The actor who edited this content - """ - editor: Actor - id: ID! - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! -} - -""" -A list of edits to content. -""" -type UserContentEditConnection { - """ - A list of edges. - """ - edges: [UserContentEditEdge] - - """ - A list of nodes. - """ - nodes: [UserContentEdit] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type UserContentEditEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: UserContentEdit -} - -""" -Represents a user. -""" -type UserEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: User -} - -""" -The user's description of what they're currently doing. -""" -type UserStatus implements Node { - """ - Identifies the date and time when the object was created. - """ - createdAt: DateTime! - - """ - An emoji summarizing the user's status. - """ - emoji: String - - """ - ID of the object. - """ - id: ID! - - """ - Whether this status indicates the user is not fully available on GitHub. - """ - indicatesLimitedAvailability: Boolean! - - """ - A brief message describing what the user is doing. - """ - message: String - - """ - The organization whose members can see this status. If null, this status is publicly visible. - """ - organization: Organization - - """ - Identifies the date and time when the object was last updated. - """ - updatedAt: DateTime! - - """ - The user who has this status. - """ - user: User! -} - -""" -The connection type for UserStatus. -""" -type UserStatusConnection { - """ - A list of edges. - """ - edges: [UserStatusEdge] - - """ - A list of nodes. - """ - nodes: [UserStatus] - - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type UserStatusEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: UserStatus -} - -""" -Ordering options for user status connections. -""" -input UserStatusOrder { - """ - The field to order user statuses by. - """ - field: UserStatusOrderField! - - """ - The ordering direction. - """ - direction: OrderDirection! -} - -""" -Properties by which user status connections can be ordered. -""" -enum UserStatusOrderField { - """ - Order user statuses by when they were updated. - """ - UPDATED_AT -} - -""" -A valid x509 certificate string -""" -scalar X509Certificate diff --git a/benchmark/github-schema.json b/benchmark/github-schema.json deleted file mode 100644 index 7352a87fa3..0000000000 --- a/benchmark/github-schema.json +++ /dev/null @@ -1,56836 +0,0 @@ -{ - "data": { - "__schema": { - "queryType": { - "name": "Query" - }, - "mutationType": { - "name": "Mutation" - }, - "subscriptionType": null, - "types": [ - { - "kind": "SCALAR", - "name": "Boolean", - "description": "Represents `true` or `false` values.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "String", - "description": "Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Query", - "description": "The query root of GitHub's GraphQL interface.", - "fields": [ - { - "name": "codeOfConduct", - "description": "Look up a code of conduct by its key", - "args": [ - { - "name": "key", - "description": "The code of conduct's key", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "CodeOfConduct", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "codesOfConduct", - "description": "Look up a code of conduct by its key", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CodeOfConduct", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "license", - "description": "Look up an open source license by its key", - "args": [ - { - "name": "key", - "description": "The license's downcased SPDX ID", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "License", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "licenses", - "description": "Return a list of known open source licenses", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "License", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "marketplaceCategories", - "description": "Get alphabetically sorted list of Marketplace categories", - "args": [ - { - "name": "includeCategories", - "description": "Return only the specified categories.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "excludeEmpty", - "description": "Exclude categories with no listings.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "excludeSubcategories", - "description": "Returns top level categories only, excluding any subcategories.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "MarketplaceCategory", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "marketplaceCategory", - "description": "Look up a Marketplace category by its slug.", - "args": [ - { - "name": "slug", - "description": "The URL slug of the category.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "useTopicAliases", - "description": "Also check topic aliases for the category slug", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "MarketplaceCategory", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "marketplaceListing", - "description": "Look up a single Marketplace listing", - "args": [ - { - "name": "slug", - "description": "Select the listing that matches this slug. It's the short name of the listing used in its URL.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "MarketplaceListing", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "marketplaceListings", - "description": "Look up Marketplace listings", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "categorySlug", - "description": "Select only listings with the given category.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "useTopicAliases", - "description": "Also check topic aliases for the category slug", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "viewerCanAdmin", - "description": "Select listings to which user has admin access. If omitted, listings visible to the\nviewer are returned.\n", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "adminId", - "description": "Select listings that can be administered by the specified user.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "organizationId", - "description": "Select listings for products owned by the specified organization.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "allStates", - "description": "Select listings visible to the viewer even if they are not approved. If omitted or\nfalse, only approved listings will be returned.\n", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "slugs", - "description": "Select the listings with these slugs, if they are visible to the viewer.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "primaryCategoryOnly", - "description": "Select only listings where the primary category matches the given category slug.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "withFreeTrialsOnly", - "description": "Select only listings that offer a free trial.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "MarketplaceListingConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "meta", - "description": "Return information about the GitHub instance", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GitHubMetadata", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "Fetches an object given its ID.", - "args": [ - { - "name": "id", - "description": "ID of the object.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "Lookup nodes by a list of IDs.", - "args": [ - { - "name": "ids", - "description": "The list of node IDs.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organization", - "description": "Lookup a organization by login.", - "args": [ - { - "name": "login", - "description": "The organization's login.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "rateLimit", - "description": "The client's rate limit information.", - "args": [ - { - "name": "dryRun", - "description": "If true, calculate the cost for the query without evaluating it", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "OBJECT", - "name": "RateLimit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "relay", - "description": "Hack to workaround https://github.com/facebook/relay/issues/112 re-exposing the root query object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Query", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "Lookup a given repository by the owner and repository name.", - "args": [ - { - "name": "owner", - "description": "The login field of a user or organization", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of the repository", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositoryOwner", - "description": "Lookup a repository owner (ie. either a User or an Organization) by login.", - "args": [ - { - "name": "login", - "description": "The username to lookup the owner by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resource", - "description": "Lookup resource by a URL.", - "args": [ - { - "name": "url", - "description": "The URL.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "search", - "description": "Perform a search across resources.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "query", - "description": "The search string to look for.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "type", - "description": "The types of search items to search within.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SearchType", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SearchResultItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "securityAdvisories", - "description": "GitHub Security Advisories", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for the returned topics.", - "type": { - "kind": "INPUT_OBJECT", - "name": "SecurityAdvisoryOrder", - "ofType": null - }, - "defaultValue": "{field:\"UPDATED_AT\",direction:\"DESC\"}" - }, - { - "name": "identifier", - "description": "Filter advisories by identifier, e.g. GHSA or CVE.", - "type": { - "kind": "INPUT_OBJECT", - "name": "SecurityAdvisoryIdentifierFilter", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "publishedSince", - "description": "Filter advisories to those published since a time in the past.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "updatedSince", - "description": "Filter advisories to those updated since a time in the past.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityAdvisoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "securityAdvisory", - "description": "Fetch a Security Advisory by its GHSA ID", - "args": [ - { - "name": "ghsaId", - "description": "GitHub Security Advisory ID.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "SecurityAdvisory", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "securityVulnerabilities", - "description": "Software Vulnerabilities documented by GitHub Security Advisories", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for the returned topics.", - "type": { - "kind": "INPUT_OBJECT", - "name": "SecurityVulnerabilityOrder", - "ofType": null - }, - "defaultValue": "{field:\"UPDATED_AT\",direction:\"DESC\"}" - }, - { - "name": "ecosystem", - "description": "An ecosystem to filter vulnerabilities by.", - "type": { - "kind": "ENUM", - "name": "SecurityAdvisoryEcosystem", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "package", - "description": "A package name to filter vulnerabilities by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "severities", - "description": "A list of severities to filter vulnerabilities by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityAdvisorySeverity", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityVulnerabilityConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "topic", - "description": "Look up a topic by name.", - "args": [ - { - "name": "name", - "description": "The topic's name.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "Lookup a user by login.", - "args": [ - { - "name": "login", - "description": "The user's login.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewer", - "description": "The currently authenticated user.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Node", - "description": "An object with an ID.", - "fields": [ - { - "name": "id", - "description": "ID of the object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "AddedToProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "App", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "AssignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "BaseRefChangedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "BaseRefForcePushedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Blob", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Bot", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ClosedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CodeOfConduct", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CommentDeletedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CommitCommentThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ConvertedNoteToIssueEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CrossReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DemilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeployKey", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeployedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Deployment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeploymentEnvironmentChangedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeploymentStatus", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ExternalIdentity", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Gist", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "GistComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefDeletedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefForcePushedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefRestoredEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Label", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Language", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "License", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Mannequin", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MarketplaceCategory", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MarketplaceListing", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MentionedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MergedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MovedColumnsInProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "OrganizationIdentityProvider", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "OrganizationInvitation", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PinnedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ProjectCard", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ProjectColumn", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PublicKey", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommitCommentThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PushAllowance", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Reaction", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Release", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReleaseAsset", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RemovedFromProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RenamedTitleEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReopenedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RepositoryInvitation", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RepositoryTopic", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissalAllowance", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestRemovedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisory", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Status", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "StatusContext", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "SubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Tag", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Team", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "TransferredEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Tree", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnassignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnpinnedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnsubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UserBlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UserContentEdit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UserStatus", - "ofType": null - } - ] - }, - { - "kind": "SCALAR", - "name": "ID", - "description": "Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"VXNlci0xMA==\"`) or integer (such as `4`) input value will be accepted as an ID.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "description": "Represents a type that can be retrieved by a URL.", - "fields": [ - { - "name": "resourcePath", - "description": "The HTML path to this resource.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The URL to this resource.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Bot", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ClosedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CrossReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Mannequin", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MergedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Release", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RepositoryTopic", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "SCALAR", - "name": "URI", - "description": "An RFC 3986, RFC 3987, and RFC 6570 (level 4) compliant URI string.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "User", - "description": "A user is an individual's account on GitHub that owns repositories and can make new content.", - "fields": [ - { - "name": "anyPinnableItems", - "description": "Determine if this repository owner has any items that can be pinned to their profile.", - "args": [ - { - "name": "type", - "description": "Filter to only a particular kind of pinnable item.", - "type": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "avatarUrl", - "description": "A URL pointing to the user's public avatar.", - "args": [ - { - "name": "size", - "description": "The size of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bio", - "description": "The user's public profile bio.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bioHTML", - "description": "The user's public profile bio as HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitComments", - "description": "A list of commit comments made by this user.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "company", - "description": "The user's public profile company.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "companyHTML", - "description": "The user's public profile company as HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "contributionsCollection", - "description": "The collection of contributions this user has made to different repositories.", - "args": [ - { - "name": "organizationID", - "description": "The ID of the organization used to filter contributions.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "from", - "description": "Only contributions made at this time or later will be counted. If omitted, defaults to a year ago.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "to", - "description": "Only contributions made before and up to and including this time will be counted. If omitted, defaults to the current time.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ContributionsCollection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": "The user's publicly visible profile email.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "followers", - "description": "A list of users the given user is followed by.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FollowerConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "following", - "description": "A list of users the given user is following.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FollowingConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gist", - "description": "Find gist by repo name.", - "args": [ - { - "name": "name", - "description": "The gist name to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Gist", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gistComments", - "description": "A list of gist comments made by this user.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GistCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gists", - "description": "A list of the Gists the user has created.", - "args": [ - { - "name": "privacy", - "description": "Filters Gists according to privacy.", - "type": { - "kind": "ENUM", - "name": "GistPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for gists returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "GistOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GistConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isBountyHunter", - "description": "Whether or not this user is a participant in the GitHub Security Bug Bounty.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isCampusExpert", - "description": "Whether or not this user is a participant in the GitHub Campus Experts Program.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeveloperProgramMember", - "description": "Whether or not this user is a GitHub Developer Program member.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isEmployee", - "description": "Whether or not this user is a GitHub employee.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isHireable", - "description": "Whether or not the user has marked themselves as for hire.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isSiteAdmin", - "description": "Whether or not this user is a site administrator.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isViewer", - "description": "Whether or not this user is the viewing user.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issueComments", - "description": "A list of issue comments made by this user.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issues", - "description": "A list of issues associated with this user.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the issues by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "filterBy", - "description": "Filtering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueFilters", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "itemShowcase", - "description": "Showcases a selection of repositories and gists that the profile owner has either curated or that have been selected automatically based on popularity.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProfileItemShowcase", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "location", - "description": "The user's public profile location.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "login", - "description": "The username used to login.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The user's public profile name.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organization", - "description": "Find an organization by its login that the user belongs to.", - "args": [ - { - "name": "login", - "description": "The login of the organization to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organizations", - "description": "A list of organizations the user belongs to.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "OrganizationConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnableItems", - "description": "A list of repositories and gists this profile owner can pin to their profile.", - "args": [ - { - "name": "types", - "description": "Filter the types of pinnable items that are returned.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedItems", - "description": "A list of repositories and gists this profile owner has pinned to their profile", - "args": [ - { - "name": "types", - "description": "Filter the types of pinned items that are returned.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedItemsRemaining", - "description": "Returns how many more items this profile owner can pin to their profile.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedRepositories", - "description": "A list of repositories this user has pinned to their profile", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "pinnedRepositories will be removed Use ProfileOwner.pinnedItems instead. Removal on 2019-07-01 UTC." - }, - { - "name": "project", - "description": "Find project by number.", - "args": [ - { - "name": "number", - "description": "The project number to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projects", - "description": "A list of projects under the owner.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for projects returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "ProjectOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "search", - "description": "Query to search projects by, currently only searching by name.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the projects by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsResourcePath", - "description": "The HTTP path listing user's projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsUrl", - "description": "The HTTP URL listing user's projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publicKeys", - "description": "A list of public keys associated with this user.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PublicKeyConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequests", - "description": "A list of pull requests associated with this user.", - "args": [ - { - "name": "states", - "description": "A list of states to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "headRefName", - "description": "The head ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "baseRefName", - "description": "The base ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for pull requests returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositories", - "description": "A list of repositories that the user owns.", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "isFork", - "description": "If non-null, filters repositories according to whether they are forks of another repository", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositoriesContributedTo", - "description": "A list of repositories that the user recently contributed to.", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "includeUserRepositories", - "description": "If true, include user repositories", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "contributionTypes", - "description": "If non-null, include only the specified types of contributions. The GitHub.com UI uses [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryContributionType", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "Find Repository.", - "args": [ - { - "name": "name", - "description": "Name of Repository to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this user", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starredRepositories", - "description": "Repositories the user has starred.", - "args": [ - { - "name": "ownedByViewer", - "description": "Filters starred repositories to only return repositories owned by the viewer.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "StarOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StarredRepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "status", - "description": "The user's description of what they're currently doing.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "UserStatus", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this user", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanChangePinnedItems", - "description": "Can the viewer pin repositories and gists to the profile?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanCreateProjects", - "description": "Can the current viewer create new projects on this owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanFollow", - "description": "Whether or not the viewer is able to follow the user.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerIsFollowing", - "description": "Whether or not this user is followed by the viewer.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "watching", - "description": "A list of repositories the given user is watching.", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Affiliation options for repositories returned from the connection", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\", \"ORGANIZATION_MEMBER\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "websiteUrl", - "description": "A URL pointing to the user's public website/blog.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RegistryPackageOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RegistryPackageSearch", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "ProjectOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "ProfileOwner", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Actor", - "description": "Represents an object which can take actions on GitHub. Typically a User or Bot.", - "fields": [ - { - "name": "avatarUrl", - "description": "A URL pointing to the actor's public avatar.", - "args": [ - { - "name": "size", - "description": "The size of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "login", - "description": "The username of the actor.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this actor.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this actor.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Bot", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Mannequin", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "SCALAR", - "name": "Int", - "description": "Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PageInfo", - "description": "Information about pagination in a connection.", - "fields": [ - { - "name": "endCursor", - "description": "When paginating forwards, the cursor to continue.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasNextPage", - "description": "When paginating forwards, are there more items?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasPreviousPage", - "description": "When paginating backwards, are there more items?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "startCursor", - "description": "When paginating backwards, the cursor to continue.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "DateTime", - "description": "An ISO-8601 encoded UTC date string.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "RegistryPackageOwner", - "description": "Represents an owner of a registry package.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "Repository", - "description": "A repository contains the content for a project.", - "fields": [ - { - "name": "assignableUsers", - "description": "A list of users that can be assigned to issues in this repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "branchProtectionRules", - "description": "A list of branch protection rules for this repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "BranchProtectionRuleConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "codeOfConduct", - "description": "Returns the code of conduct for this repository", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CodeOfConduct", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "collaborators", - "description": "A list of collaborators associated with the repository.", - "args": [ - { - "name": "affiliation", - "description": "Collaborators affiliation level with a repository.", - "type": { - "kind": "ENUM", - "name": "CollaboratorAffiliation", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RepositoryCollaboratorConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitComments", - "description": "A list of commit comments associated with the repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "defaultBranchRef", - "description": "The Ref associated with the repository's default branch.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deployKeys", - "description": "A list of deploy keys that are on this repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeployKeyConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deployments", - "description": "Deployments associated with the repository", - "args": [ - { - "name": "environments", - "description": "Environments to list deployments for", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for deployments returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "DeploymentOrder", - "ofType": null - }, - "defaultValue": "{field:\"CREATED_AT\",direction:\"ASC\"}" - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeploymentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The description of the repository.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "descriptionHTML", - "description": "The description of the repository rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "diskUsage", - "description": "The number of kilobytes this repository occupies on disk.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "forkCount", - "description": "Returns how many forks there are of this repository in the whole network.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "forks", - "description": "A list of direct forked repositories.", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasIssuesEnabled", - "description": "Indicates if the repository has issues feature enabled.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasWikiEnabled", - "description": "Indicates if the repository has wiki feature enabled.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "homepageUrl", - "description": "The repository's URL.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isArchived", - "description": "Indicates if the repository is unmaintained.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDisabled", - "description": "Returns whether or not this repository disabled.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isFork", - "description": "Identifies if the repository is a fork.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isLocked", - "description": "Indicates if the repository has been locked or not.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isMirror", - "description": "Identifies if the repository is a mirror.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isPrivate", - "description": "Identifies if the repository is private.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "Returns a single issue from the current repository by number.", - "args": [ - { - "name": "number", - "description": "The number for the issue to be returned.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issueOrPullRequest", - "description": "Returns a single issue-like object from the current repository by number.", - "args": [ - { - "name": "number", - "description": "The number for the issue to be returned.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "UNION", - "name": "IssueOrPullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issues", - "description": "A list of issues that have been opened in the repository.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the issues by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "filterBy", - "description": "Filtering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueFilters", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "label", - "description": "Returns a single label by name", - "args": [ - { - "name": "name", - "description": "Label name", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Label", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labels", - "description": "A list of labels associated with the repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "query", - "description": "If provided, searches labels by name and description.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LabelConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "languages", - "description": "A list containing a breakdown of the language composition of the repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "LanguageOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LanguageConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "licenseInfo", - "description": "The license associated with the repository", - "args": [], - "type": { - "kind": "OBJECT", - "name": "License", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lockReason", - "description": "The reason the repository has been locked.", - "args": [], - "type": { - "kind": "ENUM", - "name": "RepositoryLockReason", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mentionableUsers", - "description": "A list of Users that can be mentioned in the context of the repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergeCommitAllowed", - "description": "Whether or not PRs are merged with a merge commit on this repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "milestone", - "description": "Returns a single milestone from the current repository by number.", - "args": [ - { - "name": "number", - "description": "The number for the milestone to be returned.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "milestones", - "description": "A list of milestones associated with the repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "states", - "description": "Filter by the state of the milestones.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "MilestoneState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for milestones.", - "type": { - "kind": "INPUT_OBJECT", - "name": "MilestoneOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "MilestoneConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mirrorUrl", - "description": "The repository's original mirror URL.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nameWithOwner", - "description": "The repository's name with owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "object", - "description": "A Git object in the repository", - "args": [ - { - "name": "oid", - "description": "The Git object ID", - "type": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "expression", - "description": "A Git revision expression suitable for rev-parse", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "owner", - "description": "The User owner of the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "parent", - "description": "The repository parent, if this is a fork.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "primaryLanguage", - "description": "The primary language of the repository's code.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Language", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "Find project by number.", - "args": [ - { - "name": "number", - "description": "The project number to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projects", - "description": "A list of projects under the owner.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for projects returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "ProjectOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "search", - "description": "Query to search projects by, currently only searching by name.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the projects by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsResourcePath", - "description": "The HTTP path listing the repository's projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsUrl", - "description": "The HTTP URL listing the repository's projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "Returns a single pull request from the current repository by number.", - "args": [ - { - "name": "number", - "description": "The number for the pull request to be returned.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequests", - "description": "A list of pull requests that have been opened in the repository.", - "args": [ - { - "name": "states", - "description": "A list of states to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "headRefName", - "description": "The head ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "baseRefName", - "description": "The base ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for pull requests returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pushedAt", - "description": "Identifies when the repository was last pushed to.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "rebaseMergeAllowed", - "description": "Whether or not rebase-merging is enabled on this repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ref", - "description": "Fetch a given ref from the repository", - "args": [ - { - "name": "qualifiedName", - "description": "The ref to retrieve. Fully qualified matches are checked in order (`refs/heads/master`) before falling back onto checks for short name matches (`master`).", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "refs", - "description": "Fetch a list of refs from the repository", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "refPrefix", - "description": "A ref name prefix like `refs/heads/`, `refs/tags/`, etc.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "DEPRECATED: use orderBy. The ordering direction.", - "type": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for refs returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "RefOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RefConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "release", - "description": "Lookup a single release given various criteria.", - "args": [ - { - "name": "tagName", - "description": "The name of the Tag the Release was created from", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Release", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "releases", - "description": "List of releases which are dependent on this repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReleaseOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReleaseConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositoryTopics", - "description": "A list of applied repository-topic associations for this repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryTopicConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "shortDescriptionHTML", - "description": "A description of the repository, rendered to HTML without any links in it.", - "args": [ - { - "name": "limit", - "description": "How many characters to return.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "200" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "squashMergeAllowed", - "description": "Whether or not squash-merging is enabled on this repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "sshUrl", - "description": "The SSH URL to clone this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitSSHRemote", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "stargazers", - "description": "A list of users who have starred this starrable.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "StarOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StargazerConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanAdminister", - "description": "Indicates whether the viewer has admin permissions on this repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanCreateProjects", - "description": "Can the current viewer create new projects on this owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanSubscribe", - "description": "Check if the viewer is able to change their subscription status for the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdateTopics", - "description": "Indicates whether the viewer can update the topics of this repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasStarred", - "description": "Returns a boolean indicating whether the viewing user has starred this starrable.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerPermission", - "description": "The users permission level on the repository. Will return null if authenticated as an GitHub App.", - "args": [], - "type": { - "kind": "ENUM", - "name": "RepositoryPermission", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerSubscription", - "description": "Identifies if the viewer is watching, not watching, or ignoring the subscribable entity.", - "args": [], - "type": { - "kind": "ENUM", - "name": "SubscriptionState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "watchers", - "description": "A list of users watching the repository.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "ProjectOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RegistryPackageOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Starrable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryInfo", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "ProjectOwner", - "description": "Represents an owner of a Project.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "Find project by number.", - "args": [ - { - "name": "number", - "description": "The project number to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projects", - "description": "A list of projects under the owner.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for projects returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "ProjectOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "search", - "description": "Query to search projects by, currently only searching by name.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the projects by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsResourcePath", - "description": "The HTTP path listing owners projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsUrl", - "description": "The HTTP URL listing owners projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanCreateProjects", - "description": "Can the current viewer create new projects on this owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "Project", - "description": "Projects manage issues, pull requests and notes within a project owner.", - "fields": [ - { - "name": "body", - "description": "The project's description body.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "The projects description body rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closed", - "description": "`true` if the object is closed (definition of closed may depend on type)", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closedAt", - "description": "Identifies the date and time when the object was closed.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "columns", - "description": "List of columns in the project", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectColumnConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "creator", - "description": "The actor who originally created the project.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The project's name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "number", - "description": "The project's number.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "owner", - "description": "The project's owner. Currently limited to repositories, organizations, and users.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "ProjectOwner", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pendingCards", - "description": "List of pending cards in this project", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "archivedStates", - "description": "A list of archived states to filter the cards by", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectCardArchivedState", - "ofType": null - } - }, - "defaultValue": "[\"ARCHIVED\", \"NOT_ARCHIVED\"]" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectCardConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this project", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "Whether the project is open or closed.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this project", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Closable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Closable", - "description": "An object that can be closed", - "fields": [ - { - "name": "closed", - "description": "`true` if the object is closed (definition of closed may depend on type)", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closedAt", - "description": "Identifies the date and time when the object was closed.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "description": "Entities that can be updated.", - "fields": [ - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "GistComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - } - ] - }, - { - "kind": "ENUM", - "name": "ProjectState", - "description": "State of the project; either 'open' or 'closed'", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OPEN", - "description": "The project is open.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CLOSED", - "description": "The project is closed.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "HTML", - "description": "A string containing HTML code.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectColumnConnection", - "description": "The connection type for ProjectColumn.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectColumnEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectColumn", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectColumnEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectColumn", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectColumn", - "description": "A column inside a project.", - "fields": [ - { - "name": "cards", - "description": "List of cards in the column", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "archivedStates", - "description": "A list of archived states to filter the cards by", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectCardArchivedState", - "ofType": null - } - }, - "defaultValue": "[\"ARCHIVED\", \"NOT_ARCHIVED\"]" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectCardConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The project column's name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "The project that contains this column.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "purpose", - "description": "The semantic purpose of the column", - "args": [], - "type": { - "kind": "ENUM", - "name": "ProjectColumnPurpose", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this project column", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this project column", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ProjectColumnPurpose", - "description": "The semantic purpose of the column - todo, in progress, or done.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "TODO", - "description": "The column contains cards still to be worked on", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "IN_PROGRESS", - "description": "The column contains cards which are currently being worked on", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DONE", - "description": "The column contains cards which are complete", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectCardConnection", - "description": "The connection type for ProjectCard.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectCardEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectCard", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectCardEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectCard", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectCard", - "description": "A card in a project.", - "fields": [ - { - "name": "column", - "description": "The project column this card is associated under. A card may only belong to one\nproject column at a time. The column field will be null if the card is created\nin a pending state and has yet to be associated with a column. Once cards are\nassociated with a column, they will not become pending in the future.\n", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectColumn", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "content", - "description": "The card content item", - "args": [], - "type": { - "kind": "UNION", - "name": "ProjectCardItem", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "creator", - "description": "The actor who created this card", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isArchived", - "description": "Whether the card is archived", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "note", - "description": "The card note", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "The project that contains this card.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this card", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The state of ProjectCard", - "args": [], - "type": { - "kind": "ENUM", - "name": "ProjectCardState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this card", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ProjectCardState", - "description": "Various content states of a ProjectCard", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CONTENT_ONLY", - "description": "The card has content only.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NOTE_ONLY", - "description": "The card has a note only.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REDACTED", - "description": "The card is redacted.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "ProjectCardItem", - "description": "Types that can be inside Project Cards.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "Issue", - "description": "An Issue is a place to discuss ideas, enhancements, tasks, and bugs for a project.", - "fields": [ - { - "name": "activeLockReason", - "description": "Reason that the conversation was locked.", - "args": [], - "type": { - "kind": "ENUM", - "name": "LockReason", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "assignees", - "description": "A list of Users assigned to this object.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the subject of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "Identifies the body of the issue.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "Identifies the body of the issue rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "Identifies the body of the issue rendered to text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closed", - "description": "`true` if the object is closed (definition of closed may depend on type)", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closedAt", - "description": "Identifies the date and time when the object was closed.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "comments", - "description": "A list of comments associated with the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labels", - "description": "A list of labels associated with the object.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LabelConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locked", - "description": "`true` if the object is locked", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "milestone", - "description": "Identifies the milestone associated with the issue.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "number", - "description": "Identifies the issue number.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "participants", - "description": "A list of Users that are participating in the Issue conversation.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectCards", - "description": "List of project cards associated with this issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "archivedStates", - "description": "A list of archived states to filter the cards by", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectCardArchivedState", - "ofType": null - } - }, - "defaultValue": "[\"ARCHIVED\", \"NOT_ARCHIVED\"]" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectCardConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactionGroups", - "description": "A list of reactions grouped by content left on the subject.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionGroup", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactions", - "description": "A list of Reactions left on the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "content", - "description": "Allows filtering Reactions by emoji.", - "type": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Allows specifying the order in which reactions are returned.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this issue", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "Identifies the state of the issue.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "timeline", - "description": "A list of events, comments, commits, etc. associated with the issue.", - "args": [ - { - "name": "since", - "description": "Allows filtering timeline events by a `since` timestamp.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueTimelineConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "timelineItems", - "description": "A list of events, comments, commits, etc. associated with the issue.", - "args": [ - { - "name": "since", - "description": "Filter timeline items by a `since` timestamp.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "skip", - "description": "Skips the first _n_ elements in the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "itemTypes", - "description": "Filter timeline items by type.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueTimelineItemsItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueTimelineItemsConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "title", - "description": "Identifies the issue title.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this issue", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReact", - "description": "Can user react to this subject", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanSubscribe", - "description": "Check if the viewer is able to change their subscription status for the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerSubscription", - "description": "Identifies if the viewer is watching, not watching, or ignoring the subscribable entity.", - "args": [], - "type": { - "kind": "ENUM", - "name": "SubscriptionState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Assignable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Closable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Labelable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Lockable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Assignable", - "description": "An object that can have users assigned to it.", - "fields": [ - { - "name": "assignees", - "description": "A list of Users assigned to this object.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "UserConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UserEdge", - "description": "Represents a user.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "description": "Represents a comment.", - "fields": [ - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the subject of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "The body as Markdown.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "The body rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "The body rendered to text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "GistComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "description": "A list of edits to content.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserContentEditEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserContentEdit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UserContentEditEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "UserContentEdit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UserContentEdit", - "description": "An edit on user content", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletedAt", - "description": "Identifies the date and time when the object was deleted.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletedBy", - "description": "The actor who deleted this content", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "diff", - "description": "A summary of the changes for this edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editedAt", - "description": "When this content was edited", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited this content", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "description": "A comment author association with repository.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "MEMBER", - "description": "Author is a member of the organization that owns the repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OWNER", - "description": "Author is the owner of the repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "COLLABORATOR", - "description": "Author has been invited to collaborate on the repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CONTRIBUTOR", - "description": "Author has previously committed to the repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIRST_TIME_CONTRIBUTOR", - "description": "Author has not previously committed to the repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIRST_TIMER", - "description": "Author has not previously committed to GitHub.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NONE", - "description": "Author has no association with the repository.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "description": "Comments that can be updated.", - "fields": [ - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "GistComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - } - ] - }, - { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "description": "The possible errors that will prevent a user from updating a comment.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "INSUFFICIENT_ACCESS", - "description": "You must be the author or have write access to this repository to update this comment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LOCKED", - "description": "Unable to create comment because issue is locked.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LOGIN_REQUIRED", - "description": "You must be logged in to update this comment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MAINTENANCE", - "description": "Repository is under maintenance.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "VERIFIED_EMAIL_REQUIRED", - "description": "At least one email address must be verified to update this comment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DENIED", - "description": "You cannot update this comment", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Labelable", - "description": "An object that can have labels assigned to it.", - "fields": [ - { - "name": "labels", - "description": "A list of labels associated with the object.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LabelConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "LabelConnection", - "description": "The connection type for Label.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "LabelEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Label", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "LabelEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Label", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Label", - "description": "A label for categorizing Issues or Milestones with a given Repository.", - "fields": [ - { - "name": "color", - "description": "Identifies the label color.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the label was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "A brief description of this label.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDefault", - "description": "Indicates whether or not this is a default label.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issues", - "description": "A list of issues associated with this label.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the issues by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "filterBy", - "description": "Filtering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueFilters", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "Identifies the label name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequests", - "description": "A list of pull requests associated with this label.", - "args": [ - { - "name": "states", - "description": "A list of states to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "headRefName", - "description": "The head ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "baseRefName", - "description": "The base ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for pull requests returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this label.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this label.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the label was last updated.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this label.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueConnection", - "description": "The connection type for Issue.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "description": "Ways in which lists of issues can be ordered upon return.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order issues by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order issues by the specified field.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "IssueOrderField", - "description": "Properties by which issue connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order issues by creation time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order issues by update time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "COMMENTS", - "description": "Order issues by comment count", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "OrderDirection", - "description": "Possible directions in which to order a list of items when provided an `orderBy` argument.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ASC", - "description": "Specifies an ascending order for a given `orderBy` argument.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DESC", - "description": "Specifies a descending order for a given `orderBy` argument.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "IssueState", - "description": "The possible states of an issue.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OPEN", - "description": "An issue that is still open", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CLOSED", - "description": "An issue that has been closed", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "IssueFilters", - "description": "Ways in which to filter lists of issues.", - "fields": null, - "inputFields": [ - { - "name": "assignee", - "description": "List issues assigned to given name. Pass in `null` for issues with no assigned user, and `*` for issues assigned to any user.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "createdBy", - "description": "List issues created by given name.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "List issues where the list of label names exist on the issue.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "mentioned", - "description": "List issues where the given name is mentioned in the issue.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "milestone", - "description": "List issues by given milestone argument. If an string representation of an integer is passed, it should refer to a milestone by its number field. Pass in `null` for issues with no milestone, and `*` for issues that are assigned to any milestone.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "since", - "description": "List issues that have been updated at or after the given date.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "states", - "description": "List issues filtered by the list of states given.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "viewerSubscribed", - "description": "List issues subscribed to by viewer.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestConnection", - "description": "The connection type for PullRequest.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "description": "A repository pull request.", - "fields": [ - { - "name": "activeLockReason", - "description": "Reason that the conversation was locked.", - "args": [], - "type": { - "kind": "ENUM", - "name": "LockReason", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "additions", - "description": "The number of additions in this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "assignees", - "description": "A list of Users assigned to this object.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the subject of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "baseRef", - "description": "Identifies the base Ref associated with the pull request.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "baseRefName", - "description": "Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "baseRefOid", - "description": "Identifies the oid of the base ref associated with the pull request, even if the ref has been deleted.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "baseRepository", - "description": "The repository associated with this pull request's base Ref.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "The body as Markdown.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "The body rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "The body rendered to text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "changedFiles", - "description": "The number of changed files in this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closed", - "description": "`true` if the pull request is closed", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closedAt", - "description": "Identifies the date and time when the object was closed.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "comments", - "description": "A list of comments associated with the pull request.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commits", - "description": "A list of commits present in this pull request's head branch not present in the base branch.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestCommitConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletions", - "description": "The number of deletions in this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited this pull request's body.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "files", - "description": "Lists the files changed within this pull request.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PullRequestChangedFileConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "headRef", - "description": "Identifies the head Ref associated with the pull request.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "headRefName", - "description": "Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "headRefOid", - "description": "Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "headRepository", - "description": "The repository associated with this pull request's head Ref.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "headRepositoryOwner", - "description": "The owner of the repository associated with this pull request's head Ref.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isCrossRepository", - "description": "The head and base repositories are different.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labels", - "description": "A list of labels associated with the object.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LabelConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locked", - "description": "`true` if the pull request is locked", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "maintainerCanModify", - "description": "Indicates whether maintainers can modify the pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergeCommit", - "description": "The commit that was created when this pull request was merged.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergeable", - "description": "Whether or not the pull request can be merged based on the existence of merge conflicts.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "MergeableState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "merged", - "description": "Whether or not the pull request was merged.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergedAt", - "description": "The date and time that the pull request was merged.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergedBy", - "description": "The actor who merged the pull request.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "milestone", - "description": "Identifies the milestone associated with the pull request.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "number", - "description": "Identifies the pull request number.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "participants", - "description": "A list of Users that are participating in the Pull Request conversation.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "permalink", - "description": "The permalink to the pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "potentialMergeCommit", - "description": "The commit that GitHub automatically generated to test if this pull request could be merged. This field will not return a value if the pull request is merged, or if the test merge commit is still being generated. See the `mergeable` field for more details on the mergeability of the pull request.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectCards", - "description": "List of project cards associated with this pull request.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "archivedStates", - "description": "A list of archived states to filter the cards by", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectCardArchivedState", - "ofType": null - } - }, - "defaultValue": "[\"ARCHIVED\", \"NOT_ARCHIVED\"]" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectCardConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactionGroups", - "description": "A list of reactions grouped by content left on the subject.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionGroup", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactions", - "description": "A list of Reactions left on the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "content", - "description": "Allows filtering Reactions by emoji.", - "type": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Allows specifying the order in which reactions are returned.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "revertResourcePath", - "description": "The HTTP path for reverting this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "revertUrl", - "description": "The HTTP URL for reverting this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reviewRequests", - "description": "A list of review requests associated with the pull request.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ReviewRequestConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reviewThreads", - "description": "The list of all review threads for this pull request.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewThreadConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reviews", - "description": "A list of reviews associated with the pull request.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the reviews.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestReviewState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "author", - "description": "Filter by author of the review.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "Identifies the state of the pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "suggestedReviewers", - "description": "A list of reviewer suggestions based on commit history and past review comments.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SuggestedReviewer", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "timeline", - "description": "A list of events, comments, commits, etc. associated with the pull request.", - "args": [ - { - "name": "since", - "description": "Allows filtering timeline events by a `since` timestamp.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestTimelineConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "timelineItems", - "description": "A list of events, comments, commits, etc. associated with the pull request.", - "args": [ - { - "name": "since", - "description": "Filter timeline items by a `since` timestamp.", - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "skip", - "description": "Skips the first _n_ elements in the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "itemTypes", - "description": "Filter timeline items by type.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestTimelineItemsItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestTimelineItemsConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "title", - "description": "Identifies the pull request title.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanApplySuggestion", - "description": "Whether or not the viewer can apply suggestion.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReact", - "description": "Can user react to this subject", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanSubscribe", - "description": "Check if the viewer is able to change their subscription status for the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerSubscription", - "description": "Identifies if the viewer is watching, not watching, or ignoring the subscribable entity.", - "args": [], - "type": { - "kind": "ENUM", - "name": "SubscriptionState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Assignable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Closable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Labelable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Lockable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Lockable", - "description": "An object that can be locked.", - "fields": [ - { - "name": "activeLockReason", - "description": "Reason that the conversation was locked.", - "args": [], - "type": { - "kind": "ENUM", - "name": "LockReason", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locked", - "description": "`true` if the object is locked", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "ENUM", - "name": "LockReason", - "description": "The possible reasons that an issue or pull request was locked.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OFF_TOPIC", - "description": "The issue or pull request was locked because the conversation was off-topic.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TOO_HEATED", - "description": "The issue or pull request was locked because the conversation was too heated.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "RESOLVED", - "description": "The issue or pull request was locked because the conversation was resolved.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SPAM", - "description": "The issue or pull request was locked because the conversation was spam.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "App", - "description": "A GitHub App.", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The description of the app.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "logoBackgroundColor", - "description": "The hex color code, without the leading '#', for the logo background.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "logoUrl", - "description": "A URL pointing to the app's logo.", - "args": [ - { - "name": "size", - "description": "The size of the resulting image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the app.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "slug", - "description": "A slug based on the name of the app for use in URLs.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The URL to the app's homepage.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MarketplaceListing", - "description": "A listing in the GitHub integration marketplace.", - "fields": [ - { - "name": "app", - "description": "The GitHub App this listing represents.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "App", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "companyUrl", - "description": "URL to the listing owner's company site.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "configurationResourcePath", - "description": "The HTTP path for configuring access to the listing's integration or OAuth app", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "configurationUrl", - "description": "The HTTP URL for configuring access to the listing's integration or OAuth app", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "documentationUrl", - "description": "URL to the listing's documentation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "extendedDescription", - "description": "The listing's detailed description.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "extendedDescriptionHTML", - "description": "The listing's detailed description rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fullDescription", - "description": "The listing's introductory description.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fullDescriptionHTML", - "description": "The listing's introductory description rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasApprovalBeenRequested", - "description": "Whether this listing has been submitted for review from GitHub for approval to be displayed in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "`hasApprovalBeenRequested` will be removed. Use `isVerificationPendingFromDraft` instead. Removal on 2019-10-01 UTC." - }, - { - "name": "hasPublishedFreeTrialPlans", - "description": "Does this listing have any plans with a free trial?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasTermsOfService", - "description": "Does this listing have a terms of service link?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "howItWorks", - "description": "A technical description of how this app works with GitHub.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "howItWorksHTML", - "description": "The listing's technical description rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "installationUrl", - "description": "URL to install the product to the viewer's account or organization.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "installedForViewer", - "description": "Whether this listing's app has been installed for the current viewer", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isApproved", - "description": "Whether this listing has been approved for display in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "`isApproved` will be removed. Use `isPublic` instead. Removal on 2019-10-01 UTC." - }, - { - "name": "isArchived", - "description": "Whether this listing has been removed from the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDelisted", - "description": "Whether this listing has been removed from the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "`isDelisted` will be removed. Use `isArchived` instead. Removal on 2019-10-01 UTC." - }, - { - "name": "isDraft", - "description": "Whether this listing is still an editable draft that has not been submitted for review and is not publicly visible in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isPaid", - "description": "Whether the product this listing represents is available as part of a paid plan.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isPublic", - "description": "Whether this listing has been approved for display in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isRejected", - "description": "Whether this listing has been rejected by GitHub for display in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isUnverified", - "description": "Whether this listing has been approved for unverified display in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isUnverifiedPending", - "description": "Whether this draft listing has been submitted for review for approval to be unverified in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isVerificationPendingFromDraft", - "description": "Whether this draft listing has been submitted for review from GitHub for approval to be verified in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isVerificationPendingFromUnverified", - "description": "Whether this unverified listing has been submitted for review from GitHub for approval to be verified in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isVerified", - "description": "Whether this listing has been approved for verified display in the Marketplace.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "logoBackgroundColor", - "description": "The hex color code, without the leading '#', for the logo background.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "logoUrl", - "description": "URL for the listing's logo image.", - "args": [ - { - "name": "size", - "description": "The size in pixels of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "400" - } - ], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The listing's full name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "normalizedShortDescription", - "description": "The listing's very short description without a trailing period or ampersands.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pricingUrl", - "description": "URL to the listing's detailed pricing.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "primaryCategory", - "description": "The category that best describes the listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "MarketplaceCategory", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "privacyPolicyUrl", - "description": "URL to the listing's privacy policy, may return an empty string for listings that do not require a privacy policy URL.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for the Marketplace listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "screenshotUrls", - "description": "The URLs for the listing's screenshots.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "secondaryCategory", - "description": "An alternate category that describes the listing.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "MarketplaceCategory", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "shortDescription", - "description": "The listing's very short description.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "slug", - "description": "The short name of the listing used in its URL.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "statusUrl", - "description": "URL to the listing's status page.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "supportEmail", - "description": "An email address for support for this listing's app.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "supportUrl", - "description": "Either a URL or an email address for support for this listing's app, may return an empty string for listings that do not require a support URL.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "termsOfServiceUrl", - "description": "URL to the listing's terms of service.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for the Marketplace listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanAddPlans", - "description": "Can the current viewer add plans for this Marketplace listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanApprove", - "description": "Can the current viewer approve this Marketplace listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanDelist", - "description": "Can the current viewer delist this Marketplace listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanEdit", - "description": "Can the current viewer edit this Marketplace listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanEditCategories", - "description": "Can the current viewer edit the primary and secondary category of this\nMarketplace listing.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanEditPlans", - "description": "Can the current viewer edit the plans for this Marketplace listing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanRedraft", - "description": "Can the current viewer return this Marketplace listing to draft state\nso it becomes editable again.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReject", - "description": "Can the current viewer reject this Marketplace listing by returning it to\nan editable draft state or rejecting it entirely.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanRequestApproval", - "description": "Can the current viewer request this listing be reviewed for display in\nthe Marketplace as verified.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasPurchased", - "description": "Indicates whether the current user has an active subscription to this Marketplace listing.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasPurchasedForAllOrganizations", - "description": "Indicates if the current user has purchased a subscription to this Marketplace listing\nfor all of the organizations the user owns.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerIsListingAdmin", - "description": "Does the current viewer role allow them to administer this Marketplace listing.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Organization", - "description": "An account on GitHub, with one or more owners, that has repositories, members and teams.", - "fields": [ - { - "name": "anyPinnableItems", - "description": "Determine if this repository owner has any items that can be pinned to their profile.", - "args": [ - { - "name": "type", - "description": "Filter to only a particular kind of pinnable item.", - "type": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "avatarUrl", - "description": "A URL pointing to the organization's public avatar.", - "args": [ - { - "name": "size", - "description": "The size of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The organization's public profile description.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": "The organization's public email.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isVerified", - "description": "Whether the organization has verified its profile email and website.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "itemShowcase", - "description": "Showcases a selection of repositories and gists that the profile owner has either curated or that have been selected automatically based on popularity.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProfileItemShowcase", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "location", - "description": "The organization's public profile location.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "login", - "description": "The organization's login name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "memberStatuses", - "description": "Get the status messages members of this entity have set that are either public or visible only to the organization.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for user statuses returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "UserStatusOrder", - "ofType": null - }, - "defaultValue": "{field:\"UPDATED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserStatusConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "membersWithRole", - "description": "A list of users who are members of this organization.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "OrganizationMemberConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The organization's public profile name.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "newTeamResourcePath", - "description": "The HTTP path creating a new team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "newTeamUrl", - "description": "The HTTP URL creating a new team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organizationBillingEmail", - "description": "The billing email for the organization.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pendingMembers", - "description": "A list of users who have been invited to join this organization.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnableItems", - "description": "A list of repositories and gists this profile owner can pin to their profile.", - "args": [ - { - "name": "types", - "description": "Filter the types of pinnable items that are returned.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedItems", - "description": "A list of repositories and gists this profile owner has pinned to their profile", - "args": [ - { - "name": "types", - "description": "Filter the types of pinned items that are returned.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedItemsRemaining", - "description": "Returns how many more items this profile owner can pin to their profile.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedRepositories", - "description": "A list of repositories this user has pinned to their profile", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "pinnedRepositories will be removed Use ProfileOwner.pinnedItems instead. Removal on 2019-07-01 UTC." - }, - { - "name": "project", - "description": "Find project by number.", - "args": [ - { - "name": "number", - "description": "The project number to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projects", - "description": "A list of projects under the owner.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for projects returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "ProjectOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "search", - "description": "Query to search projects by, currently only searching by name.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the projects by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsResourcePath", - "description": "The HTTP path listing organization's projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectsUrl", - "description": "The HTTP URL listing organization's projects", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositories", - "description": "A list of repositories that the user owns.", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "isFork", - "description": "If non-null, filters repositories according to whether they are forks of another repository", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "Find Repository.", - "args": [ - { - "name": "name", - "description": "Name of Repository to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requiresTwoFactorAuthentication", - "description": "When true the organization requires all members, billing managers, and outside collaborators to enable two-factor authentication.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this organization.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "samlIdentityProvider", - "description": "The Organization's SAML identity providers", - "args": [], - "type": { - "kind": "OBJECT", - "name": "OrganizationIdentityProvider", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "team", - "description": "Find an organization's team by its slug.", - "args": [ - { - "name": "slug", - "description": "The name or slug of the team to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Team", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "teams", - "description": "A list of teams in this organization.", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters teams according to privacy", - "type": { - "kind": "ENUM", - "name": "TeamPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "role", - "description": "If non-null, filters teams according to whether the viewer is an admin or member on team", - "type": { - "kind": "ENUM", - "name": "TeamRole", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "query", - "description": "If non-null, filters teams with query on team name and team slug", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "userLogins", - "description": "User logins to filter by", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for teams returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "TeamOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "ldapMapped", - "description": "If true, filters teams that are mapped to an LDAP Group (Enterprise only)", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "rootTeamsOnly", - "description": "If true, restrict to only root teams", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "teamsResourcePath", - "description": "The HTTP path listing organization's teams", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "teamsUrl", - "description": "The HTTP URL listing organization's teams", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this organization.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanAdminister", - "description": "Organization is adminable by the viewer.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanChangePinnedItems", - "description": "Can the viewer pin repositories and gists to the profile?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanCreateProjects", - "description": "Can the current viewer create new projects on this owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanCreateRepositories", - "description": "Viewer can create repositories on this organization", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanCreateTeams", - "description": "Viewer can create teams on this organization.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerIsAMember", - "description": "Viewer is an active member of this organization.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "websiteUrl", - "description": "The organization's public profile URL.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RegistryPackageOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RegistryPackageSearch", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "ProjectOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "MemberStatusable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "ProfileOwner", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "RegistryPackageSearch", - "description": "Represents an interface to search packages on an object.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "description": "Represents an owner of a Repository.", - "fields": [ - { - "name": "avatarUrl", - "description": "A URL pointing to the owner's public avatar.", - "args": [ - { - "name": "size", - "description": "The size of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "login", - "description": "The username used to login.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedRepositories", - "description": "A list of repositories this user has pinned to their profile", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "pinnedRepositories will be removed Use ProfileOwner.pinnedItems instead. Removal on 2019-07-01 UTC." - }, - { - "name": "repositories", - "description": "A list of repositories that the user owns.", - "args": [ - { - "name": "privacy", - "description": "If non-null, filters repositories according to privacy", - "type": { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for repositories returned from the connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "affiliations", - "description": "Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "ownerAffiliations", - "description": "Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "ofType": null - } - }, - "defaultValue": "[\"OWNER\", \"COLLABORATOR\"]" - }, - { - "name": "isLocked", - "description": "If non-null, filters repositories according to whether they have been locked", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "isFork", - "description": "If non-null, filters repositories according to whether they are forks of another repository", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "Find Repository.", - "args": [ - { - "name": "name", - "description": "Name of Repository to find.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP URL for the owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for the owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "RepositoryConnection", - "description": "A list of repositories owned by the subject.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalDiskUsage", - "description": "The total size in kilobytes of all repositories in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "RepositoryPrivacy", - "description": "The privacy of a repository", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "PUBLIC", - "description": "Public", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PRIVATE", - "description": "Private", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RepositoryOrder", - "description": "Ordering options for repository connections", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order repositories by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "RepositoryOrderField", - "description": "Properties by which repository connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order repositories by creation time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order repositories by update time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PUSHED_AT", - "description": "Order repositories by push time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NAME", - "description": "Order repositories by name", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "STARGAZERS", - "description": "Order repositories by number of stargazers", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "RepositoryAffiliation", - "description": "The affiliation of a user to a repository", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OWNER", - "description": "Repositories that are owned by the authenticated user.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "COLLABORATOR", - "description": "Repositories that the user has been added to as a collaborator.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ORGANIZATION_MEMBER", - "description": "Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Float", - "description": "Represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "MemberStatusable", - "description": "Entities that have members who can set status messages.", - "fields": [ - { - "name": "memberStatuses", - "description": "Get the status messages members of this entity have set that are either public or visible only to the organization.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for user statuses returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "UserStatusOrder", - "ofType": null - }, - "defaultValue": "{field:\"UPDATED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserStatusConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Team", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "UserStatusConnection", - "description": "The connection type for UserStatus.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserStatusEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserStatus", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UserStatusEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "UserStatus", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UserStatus", - "description": "The user's description of what they're currently doing.", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "emoji", - "description": "An emoji summarizing the user's status.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "ID of the object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "indicatesLimitedAvailability", - "description": "Whether this status indicates the user is not fully available on GitHub.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "message", - "description": "A brief message describing what the user is doing.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organization", - "description": "The organization whose members can see this status. If null, this status is publicly visible.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who has this status.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UserStatusOrder", - "description": "Ordering options for user status connections.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order user statuses by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "UserStatusOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "UserStatusOrderField", - "description": "Properties by which user status connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "UPDATED_AT", - "description": "Order user statuses by when they were updated.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "ProfileOwner", - "description": "Represents any entity on GitHub that has a profile page.", - "fields": [ - { - "name": "anyPinnableItems", - "description": "Determine if this repository owner has any items that can be pinned to their profile.", - "args": [ - { - "name": "type", - "description": "Filter to only a particular kind of pinnable item.", - "type": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": "The public profile email.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "itemShowcase", - "description": "Showcases a selection of repositories and gists that the profile owner has either curated or that have been selected automatically based on popularity.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProfileItemShowcase", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "location", - "description": "The public profile location.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "login", - "description": "The username used to login.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The public profile name.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnableItems", - "description": "A list of repositories and gists this profile owner can pin to their profile.", - "args": [ - { - "name": "types", - "description": "Filter the types of pinnable items that are returned.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedItems", - "description": "A list of repositories and gists this profile owner has pinned to their profile", - "args": [ - { - "name": "types", - "description": "Filter the types of pinned items that are returned.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PinnableItemType", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pinnedItemsRemaining", - "description": "Returns how many more items this profile owner can pin to their profile.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanChangePinnedItems", - "description": "Can the viewer pin repositories and gists to the profile?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "websiteUrl", - "description": "The public profile website URL.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "ProfileItemShowcase", - "description": "A curatable list of repositories relating to a repository owner, which defaults to showing the most popular repositories they own.", - "fields": [ - { - "name": "hasPinnedItems", - "description": "Whether or not the owner has pinned any repositories or gists.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "items", - "description": "The repositories and gists in the showcase. If the profile owner has any pinned items, those will be returned. Otherwise, the profile owner's popular repositories will be returned.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PinnableItemConnection", - "description": "The connection type for PinnableItem.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PinnableItemEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "UNION", - "name": "PinnableItem", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PinnableItemEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "UNION", - "name": "PinnableItem", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "PinnableItem", - "description": "Types that can be pinned to a profile page.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Gist", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "Gist", - "description": "A Gist.", - "fields": [ - { - "name": "comments", - "description": "A list of comments associated with the gist", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GistCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The gist description.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "files", - "description": "The files in this gist.", - "args": [ - { - "name": "limit", - "description": "The maximum number of files to return.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "10" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GistFile", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isFork", - "description": "Identifies if the gist is a fork.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isPublic", - "description": "Whether the gist is public or not.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The gist name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "owner", - "description": "The gist owner.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pushedAt", - "description": "Identifies when the gist was last pushed to.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "stargazers", - "description": "A list of users who have starred this starrable.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "StarOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StargazerConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasStarred", - "description": "Returns a boolean indicating whether the viewing user has starred this starrable.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Starrable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Starrable", - "description": "Things that can be starred.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "stargazers", - "description": "A list of users who have starred this starrable.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "StarOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StargazerConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasStarred", - "description": "Returns a boolean indicating whether the viewing user has starred this starrable.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Gist", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "StargazerConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StargazerEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StargazerEdge", - "description": "Represents a user that's starred a repository.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starredAt", - "description": "Identifies when the item was starred.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "StarOrder", - "description": "Ways in which star connections can be ordered.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order nodes by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "StarOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order nodes.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "StarOrderField", - "description": "Properties by which star connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "STARRED_AT", - "description": "Allows ordering a list of stars by when they were created.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "GistCommentConnection", - "description": "The connection type for GistComment.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GistCommentEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GistComment", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "GistCommentEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "GistComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "GistComment", - "description": "Represents a comment on an Gist.", - "fields": [ - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the gist.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "Identifies the comment body.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "The comment body rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "The body rendered to text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gist", - "description": "The associated gist.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Gist", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isMinimized", - "description": "Returns whether or not a comment has been minimized.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "minimizedReason", - "description": "Returns why the comment was minimized.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanDelete", - "description": "Check if the current viewer can delete this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanMinimize", - "description": "Check if the current viewer can minimize this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Deletable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Deletable", - "description": "Entities that can be deleted.", - "fields": [ - { - "name": "viewerCanDelete", - "description": "Check if the current viewer can delete this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "GistComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "GistFile", - "description": "A file in a gist.", - "fields": [ - { - "name": "encodedName", - "description": "The file name encoded to remove characters that are invalid in URL paths.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "encoding", - "description": "The gist file encoding.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "extension", - "description": "The file extension from the file name.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isImage", - "description": "Indicates if this file is an image.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isTruncated", - "description": "Whether the file's contents were truncated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "language", - "description": "The programming language this file is written in.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Language", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The gist file name.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "size", - "description": "The gist file size in bytes.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "text", - "description": "UTF8 text data or null if the file is binary", - "args": [ - { - "name": "truncate", - "description": "Optionally truncate the returned file to this length.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Language", - "description": "Represents a given language found in repositories.", - "fields": [ - { - "name": "color", - "description": "The color defined for the current language.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the current language.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PinnableItemType", - "description": "Represents items that can be pinned to a profile page or dashboard.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "REPOSITORY", - "description": "A repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "GIST", - "description": "A gist.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ISSUE", - "description": "An issue.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectConnection", - "description": "A list of projects associated with the owner.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ProjectEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ProjectEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ProjectOrder", - "description": "Ways in which lists of projects can be ordered upon return.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order projects by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ProjectOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order projects by the specified field.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ProjectOrderField", - "description": "Properties by which project connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order projects by creation time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order projects by update time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NAME", - "description": "Order projects by name", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Bot", - "description": "A special type of user which takes actions on behalf of GitHub Apps.", - "fields": [ - { - "name": "avatarUrl", - "description": "A URL pointing to the GitHub App's public avatar.", - "args": [ - { - "name": "size", - "description": "The size of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "login", - "description": "The username of the actor.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this bot", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this bot", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "description": "Represents a comment on an Issue.", - "fields": [ - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the subject of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "The body as Markdown.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "The body rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "The body rendered to text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isMinimized", - "description": "Returns whether or not a comment has been minimized.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "Identifies the issue associated with the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "minimizedReason", - "description": "Returns why the comment was minimized.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "Returns the pull request associated with the comment, if this comment was made on a\npull request.\n", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactionGroups", - "description": "A list of reactions grouped by content left on the subject.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionGroup", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactions", - "description": "A list of Reactions left on the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "content", - "description": "Allows filtering Reactions by emoji.", - "type": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Allows specifying the order in which reactions are returned.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this issue comment", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this issue comment", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanDelete", - "description": "Check if the current viewer can delete this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanMinimize", - "description": "Check if the current viewer can minimize this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReact", - "description": "Can user react to this subject", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Deletable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Reactable", - "description": "Represents a subject that can be reacted on.", - "fields": [ - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactionGroups", - "description": "A list of reactions grouped by content left on the subject.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionGroup", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactions", - "description": "A list of Reactions left on the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "content", - "description": "Allows filtering Reactions by emoji.", - "type": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Allows specifying the order in which reactions are returned.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReact", - "description": "Can user react to this subject", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "ReactionGroup", - "description": "A group of emoji reactions to a particular piece of content.", - "fields": [ - { - "name": "content", - "description": "Identifies the emoji reaction.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies when the reaction was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "The subject that was reacted to.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "users", - "description": "Users who have reacted to the reaction subject with the emotion represented by this reaction group", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactingUserConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasReacted", - "description": "Whether or not the authenticated user has left a reaction on the subject.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ReactionContent", - "description": "Emojis that can be attached to Issues, Pull Requests and Comments.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "THUMBS_UP", - "description": "Represents the πŸ‘ emoji.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "THUMBS_DOWN", - "description": "Represents the πŸ‘Ž emoji.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LAUGH", - "description": "Represents the πŸ˜„ emoji.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "HOORAY", - "description": "Represents the πŸŽ‰ emoji.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CONFUSED", - "description": "Represents the πŸ˜• emoji.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "HEART", - "description": "Represents the ❀️ emoji.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ROCKET", - "description": "Represents the πŸš€ emoji.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "EYES", - "description": "Represents the πŸ‘€ emoji.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReactingUserConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactingUserEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReactingUserEdge", - "description": "Represents a user that's made a reaction.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactedAt", - "description": "The moment when the user made the reaction.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReactionConnection", - "description": "A list of reactions that have been left on the subject.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Reaction", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasReacted", - "description": "Whether or not the authenticated user has left a reaction on the subject.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReactionEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Reaction", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Reaction", - "description": "An emoji reaction to a particular piece of content.", - "fields": [ - { - "name": "content", - "description": "Identifies the emoji reaction.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactable", - "description": "The reactable piece of content", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "Identifies the user who created this reaction.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "description": "Ways in which lists of reactions can be ordered upon return.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order reactions by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ReactionOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order reactions by the specified field.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ReactionOrderField", - "description": "A list of fields that reactions can be ordered by.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Allows ordering a list of reactions by when they were created.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryInfo", - "description": "A subset of repository info.", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The description of the repository.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "descriptionHTML", - "description": "The description of the repository rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "forkCount", - "description": "Returns how many forks there are of this repository in the whole network.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasIssuesEnabled", - "description": "Indicates if the repository has issues feature enabled.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasWikiEnabled", - "description": "Indicates if the repository has wiki feature enabled.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "homepageUrl", - "description": "The repository's URL.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isArchived", - "description": "Indicates if the repository is unmaintained.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isFork", - "description": "Identifies if the repository is a fork.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isLocked", - "description": "Indicates if the repository has been locked or not.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isMirror", - "description": "Identifies if the repository is a mirror.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isPrivate", - "description": "Identifies if the repository is private.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "licenseInfo", - "description": "The license associated with the repository", - "args": [], - "type": { - "kind": "OBJECT", - "name": "License", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lockReason", - "description": "The reason the repository has been locked.", - "args": [], - "type": { - "kind": "ENUM", - "name": "RepositoryLockReason", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mirrorUrl", - "description": "The repository's original mirror URL.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nameWithOwner", - "description": "The repository's name with owner.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "owner", - "description": "The User owner of the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "RepositoryOwner", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pushedAt", - "description": "Identifies when the repository was last pushed to.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "shortDescriptionHTML", - "description": "A description of the repository, rendered to HTML without any links in it.", - "args": [ - { - "name": "limit", - "description": "How many characters to return.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "200" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - ] - }, - { - "kind": "ENUM", - "name": "RepositoryLockReason", - "description": "The possible reasons a given repository could be in a locked state.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "MOVING", - "description": "The repository is locked due to a move.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "BILLING", - "description": "The repository is locked due to a billing related reason.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "RENAME", - "description": "The repository is locked due to a rename.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MIGRATING", - "description": "The repository is locked due to a migration.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "License", - "description": "A repository's open source license", - "fields": [ - { - "name": "body", - "description": "The full text of the license", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "conditions", - "description": "The conditions set by the license", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "LicenseRule", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "A human-readable description of the license", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "featured", - "description": "Whether the license should be featured", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hidden", - "description": "Whether the license should be displayed in license pickers", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "implementation", - "description": "Instructions on how to implement the license", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "key", - "description": "The lowercased SPDX ID of the license", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "limitations", - "description": "The limitations set by the license", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "LicenseRule", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The license full name specified by ", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nickname", - "description": "Customary short name if applicable (e.g, GPLv3)", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "permissions", - "description": "The permissions set by the license", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "LicenseRule", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pseudoLicense", - "description": "Whether the license is a pseudo-license placeholder (e.g., other, no-license)", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "spdxId", - "description": "Short identifier specified by ", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "URL to the license on ", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "LicenseRule", - "description": "Describes a License's conditions, permissions, and limitations", - "fields": [ - { - "name": "description", - "description": "A description of the rule", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "key", - "description": "The machine-readable rule key", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "label", - "description": "The human-readable rule label", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryTopicConnection", - "description": "The connection type for RepositoryTopic.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryTopicEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryTopic", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryTopicEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "RepositoryTopic", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryTopic", - "description": "A repository-topic connects a repository to a topic.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this repository-topic.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "topic", - "description": "The topic.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this repository-topic.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Topic", - "description": "A topic aggregates entities that are related to a subject.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The topic's name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "relatedTopics", - "description": "A list of related topics, including aliases of this topic, sorted with the most relevant\nfirst. Returns up to 10 Topics.\n", - "args": [ - { - "name": "first", - "description": "How many topics to return.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "3" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "stargazers", - "description": "A list of users who have starred this starrable.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "StarOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StargazerConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerHasStarred", - "description": "Returns a boolean indicating whether the viewing user has starred this starrable.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Starrable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Release", - "description": "A release contains the content for a release.", - "fields": [ - { - "name": "author", - "description": "The author of the release", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "Identifies the description of the release.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDraft", - "description": "Whether or not the release is a draft", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isPrerelease", - "description": "Whether or not the release is a prerelease", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "Identifies the title of the release.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies the date and time when the release was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "releaseAssets", - "description": "List of releases assets which are dependent on this release.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "name", - "description": "A list of names to filter the assets by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReleaseAssetConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this issue", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "tag", - "description": "The Git tag the release points to", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "tagName", - "description": "The name of the release's Git tag", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this issue", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Ref", - "description": "Represents a Git reference.", - "fields": [ - { - "name": "associatedPullRequests", - "description": "A list of pull requests with this ref as the head ref.", - "args": [ - { - "name": "states", - "description": "A list of states to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "headRefName", - "description": "The head ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "baseRefName", - "description": "The base ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for pull requests returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The ref name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "prefix", - "description": "The ref's prefix, such as `refs/heads/` or `refs/tags/`.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository the ref belongs to.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "target", - "description": "The object the ref points to.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "GitObject", - "description": "Represents a Git object.", - "fields": [ - { - "name": "abbreviatedOid", - "description": "An abbreviated version of the Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitResourcePath", - "description": "The HTTP path for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitUrl", - "description": "The HTTP URL for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "oid", - "description": "The Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The Repository the Git object belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Blob", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Tag", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Tree", - "ofType": null - } - ] - }, - { - "kind": "SCALAR", - "name": "GitObjectID", - "description": "A Git object ID.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "description": "Represents a object that belongs to a repository.", - "fields": [ - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CommitCommentThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommitCommentThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "Blob", - "description": "Represents a Git blob.", - "fields": [ - { - "name": "abbreviatedOid", - "description": "An abbreviated version of the Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "byteSize", - "description": "Byte size of Blob object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitResourcePath", - "description": "The HTTP path for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitUrl", - "description": "The HTTP URL for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isBinary", - "description": "Indicates whether the Blob is binary or text", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isTruncated", - "description": "Indicates whether the contents is truncated", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "oid", - "description": "The Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The Repository the Git object belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "text", - "description": "UTF8 text data or null if the Blob is binary", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Commit", - "description": "Represents a Git commit.", - "fields": [ - { - "name": "abbreviatedOid", - "description": "An abbreviated version of the Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "additions", - "description": "The number of additions in this commit.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "associatedPullRequests", - "description": "The pull requests associated with a commit", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for pull requests.", - "type": { - "kind": "INPUT_OBJECT", - "name": "PullRequestOrder", - "ofType": null - }, - "defaultValue": "{field:\"CREATED_AT\",direction:\"ASC\"}" - } - ], - "type": { - "kind": "OBJECT", - "name": "PullRequestConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "author", - "description": "Authorship details of the commit.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "GitActor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authoredByCommitter", - "description": "Check if the committer and the author match.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authoredDate", - "description": "The datetime when this commit was authored.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "blame", - "description": "Fetches `git blame` information.", - "args": [ - { - "name": "path", - "description": "The file whose Git blame information you want.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Blame", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "changedFiles", - "description": "The number of changed files in this commit.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "comments", - "description": "Comments made on the commit.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitResourcePath", - "description": "The HTTP path for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitUrl", - "description": "The HTTP URL for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "committedDate", - "description": "The datetime when this commit was committed.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "committedViaWeb", - "description": "Check if commited via GitHub web UI.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "committer", - "description": "Committership details of the commit.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "GitActor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletions", - "description": "The number of deletions in this commit.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deployments", - "description": "The deployments associated with a commit.", - "args": [ - { - "name": "environments", - "description": "Environments to list deployments for", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for deployments returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "DeploymentOrder", - "ofType": null - }, - "defaultValue": "{field:\"CREATED_AT\",direction:\"ASC\"}" - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeploymentConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "history", - "description": "The linear commit history starting from (and including) this commit, in the same order as `git log`.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "path", - "description": "If non-null, filters history to only show commits touching files under this path.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "author", - "description": "If non-null, filters history to only show commits with matching authorship.", - "type": { - "kind": "INPUT_OBJECT", - "name": "CommitAuthor", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "since", - "description": "Allows specifying a beginning time or date for fetching commits.", - "type": { - "kind": "SCALAR", - "name": "GitTimestamp", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "until", - "description": "Allows specifying an ending time or date for fetching commits.", - "type": { - "kind": "SCALAR", - "name": "GitTimestamp", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitHistoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "message", - "description": "The Git commit message", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "messageBody", - "description": "The Git commit message body", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "messageBodyHTML", - "description": "The commit message body rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "messageHeadline", - "description": "The Git commit message headline", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "messageHeadlineHTML", - "description": "The commit message headline rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "oid", - "description": "The Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "parents", - "description": "The parents of a commit.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pushedDate", - "description": "The datetime when this commit was pushed.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The Repository this commit belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this commit", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signature", - "description": "Commit signing information, if present.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "GitSignature", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "status", - "description": "Status information for this commit", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Status", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "tarballUrl", - "description": "Returns a URL to download a tarball archive for a repository.\nNote: For private repositories, these links are temporary and expire after five minutes.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "tree", - "description": "Commit's root Tree", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Tree", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "treeResourcePath", - "description": "The HTTP path for the tree of this commit", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "treeUrl", - "description": "The HTTP URL for the tree of this commit", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this commit", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanSubscribe", - "description": "Check if the viewer is able to change their subscription status for the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerSubscription", - "description": "Identifies if the viewer is watching, not watching, or ignoring the subscribable entity.", - "args": [], - "type": { - "kind": "ENUM", - "name": "SubscriptionState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "zipballUrl", - "description": "Returns a URL to download a zipball archive for a repository.\nNote: For private repositories, these links are temporary and expire after five minutes.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Subscribable", - "description": "Entities that can be subscribed to for web and email notifications.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanSubscribe", - "description": "Check if the viewer is able to change their subscription status for the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerSubscription", - "description": "Identifies if the viewer is watching, not watching, or ignoring the subscribable entity.", - "args": [], - "type": { - "kind": "ENUM", - "name": "SubscriptionState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Team", - "ofType": null - } - ] - }, - { - "kind": "ENUM", - "name": "SubscriptionState", - "description": "The possible states of a subscription.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "UNSUBSCRIBED", - "description": "The User is only notified when participating or @mentioned.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIBED", - "description": "The User is notified of all conversations.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "IGNORED", - "description": "The User is never notified.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Tree", - "description": "Represents a Git tree.", - "fields": [ - { - "name": "abbreviatedOid", - "description": "An abbreviated version of the Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitResourcePath", - "description": "The HTTP path for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitUrl", - "description": "The HTTP URL for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "entries", - "description": "A list of tree entries.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TreeEntry", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "oid", - "description": "The Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The Repository the Git object belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TreeEntry", - "description": "Represents a Git tree entry.", - "fields": [ - { - "name": "mode", - "description": "Entry file mode.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "Entry file name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "object", - "description": "Entry file object.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "oid", - "description": "Entry file Git object ID.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The Repository the tree entry belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": "Entry file type.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "GitActor", - "description": "Represents an actor in a Git commit (ie. an author or committer).", - "fields": [ - { - "name": "avatarUrl", - "description": "A URL pointing to the author's public avatar.", - "args": [ - { - "name": "size", - "description": "The size of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "date", - "description": "The timestamp of the Git action (authoring or committing).", - "args": [], - "type": { - "kind": "SCALAR", - "name": "GitTimestamp", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": "The email in the Git commit.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name in the Git commit.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The GitHub user corresponding to the email field. Null if no such user exists.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "GitTimestamp", - "description": "An ISO-8601 encoded date string. Unlike the DateTime type, GitTimestamp is not converted in UTC.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommitConnection", - "description": "The connection type for Commit.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommitEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommitHistoryConnection", - "description": "The connection type for Commit.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CommitAuthor", - "description": "Specifies an author for filtering Git commits.", - "fields": null, - "inputFields": [ - { - "name": "id", - "description": "ID of a User to filter by. If non-null, only commits authored by this user will be returned. This field takes precedence over emails.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "emails", - "description": "Email addresses to filter by. Commits authored by any of the specified email addresses will be returned.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommitCommentConnection", - "description": "The connection type for CommitComment.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitCommentEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommitCommentEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CommitComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommitComment", - "description": "Represents a comment on a given Commit.", - "fields": [ - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the subject of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "Identifies the comment body.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "Identifies the comment body rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "The body rendered to text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "Identifies the commit associated with the comment, if the commit exists.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isMinimized", - "description": "Returns whether or not a comment has been minimized.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "minimizedReason", - "description": "Returns why the comment was minimized.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "path", - "description": "Identifies the file path associated with the comment.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "position", - "description": "Identifies the line position associated with the comment.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactionGroups", - "description": "A list of reactions grouped by content left on the subject.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionGroup", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactions", - "description": "A list of Reactions left on the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "content", - "description": "Allows filtering Reactions by emoji.", - "type": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Allows specifying the order in which reactions are returned.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path permalink for this commit comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL permalink for this commit comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanDelete", - "description": "Check if the current viewer can delete this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanMinimize", - "description": "Check if the current viewer can minimize this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReact", - "description": "Can user react to this subject", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Deletable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "GitSignature", - "description": "Information about a signature (GPG or S/MIME) on a Commit or Tag.", - "fields": [ - { - "name": "email", - "description": "Email used to sign this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isValid", - "description": "True if the signature is valid and verified by GitHub.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "payload", - "description": "Payload for GPG signing object. Raw ODB object without the signature header.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signature", - "description": "ASCII-armored signature header from object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signer", - "description": "GitHub user corresponding to the email signing this commit.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "GitSignatureState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "wasSignedByGitHub", - "description": "True if the signature was made with GitHub's signing key.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "GpgSignature", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "SmimeSignature", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnknownSignature", - "ofType": null - } - ] - }, - { - "kind": "ENUM", - "name": "GitSignatureState", - "description": "The state of a Git signature.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "VALID", - "description": "Valid signature and verified by GitHub", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INVALID", - "description": "Invalid signature", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MALFORMED_SIG", - "description": "Malformed signature", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNKNOWN_KEY", - "description": "Key used for signing not known to GitHub", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "BAD_EMAIL", - "description": "Invalid email used for signing", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNVERIFIED_EMAIL", - "description": "Email used for signing unverified on GitHub", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NO_USER", - "description": "Email used for signing not known to GitHub", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNKNOWN_SIG_TYPE", - "description": "Unknown signature type", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNSIGNED", - "description": "Unsigned", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "GPGVERIFY_UNAVAILABLE", - "description": "Internal error - the GPG verification service is unavailable at the moment", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "GPGVERIFY_ERROR", - "description": "Internal error - the GPG verification service misbehaved", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NOT_SIGNING_KEY", - "description": "The usage flags for the key that signed this don't allow signing", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "EXPIRED_KEY", - "description": "Signing key expired", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OCSP_PENDING", - "description": "Valid signature, pending certificate revocation checking", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OCSP_ERROR", - "description": "Valid siganture, though certificate revocation check failed", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "BAD_CERT", - "description": "The signing certificate or its chain could not be verified", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OCSP_REVOKED", - "description": "One or more certificates in chain has been revoked", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Status", - "description": "Represents a commit status.", - "fields": [ - { - "name": "commit", - "description": "The commit this status is attached to.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "context", - "description": "Looks up an individual status context by context name.", - "args": [ - { - "name": "name", - "description": "The context name.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "StatusContext", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "contexts", - "description": "The individual status contexts for this commit.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StatusContext", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The combined commit status.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "StatusState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "StatusState", - "description": "The possible commit status states.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "EXPECTED", - "description": "Status is expected.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ERROR", - "description": "Status is errored.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FAILURE", - "description": "Status is failing.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PENDING", - "description": "Status is pending.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUCCESS", - "description": "Status is successful.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StatusContext", - "description": "Represents an individual commit status context", - "fields": [ - { - "name": "commit", - "description": "This commit this status context is attached to.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "context", - "description": "The name of this status context.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "creator", - "description": "The actor who created this status context.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The description for this status context.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The state of this status context.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "StatusState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "targetUrl", - "description": "The URL for this status context.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PullRequestState", - "description": "The possible states of a pull request.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OPEN", - "description": "A pull request that is still open.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CLOSED", - "description": "A pull request that has been closed without being merged.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MERGED", - "description": "A pull request that has been closed by being merged.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Blame", - "description": "Represents a Git blame.", - "fields": [ - { - "name": "ranges", - "description": "The list of ranges from a Git blame.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "BlameRange", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BlameRange", - "description": "Represents a range of information from a Git blame.", - "fields": [ - { - "name": "age", - "description": "Identifies the recency of the change, from 1 (new) to 10 (old). This is calculated as a 2-quantile and determines the length of distance between the median age of all the changes in the file and the recency of the current range's change.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "Identifies the line author", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "endingLine", - "description": "The ending line for the range", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "startingLine", - "description": "The starting line for the range", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeploymentConnection", - "description": "The connection type for Deployment.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeploymentEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Deployment", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeploymentEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Deployment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Deployment", - "description": "Represents triggered deployment instance.", - "fields": [ - { - "name": "commit", - "description": "Identifies the commit sha of the deployment.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitOid", - "description": "Identifies the oid of the deployment commit, even if the commit has been deleted.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "creator", - "description": "Identifies the actor who triggered the deployment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The deployment description.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "environment", - "description": "The environment to which this deployment was made.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "latestStatus", - "description": "The latest status of this deployment.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "DeploymentStatus", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "payload", - "description": "Extra information that a deployment system might need.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ref", - "description": "Identifies the Ref of the deployment, if the deployment was created by ref.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "Identifies the repository associated with the deployment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The current state of the deployment.", - "args": [], - "type": { - "kind": "ENUM", - "name": "DeploymentState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "statuses", - "description": "A list of statuses associated with the deployment.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeploymentStatusConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "task", - "description": "The deployment task.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeploymentStatusConnection", - "description": "The connection type for DeploymentStatus.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeploymentStatusEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeploymentStatus", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeploymentStatusEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "DeploymentStatus", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeploymentStatus", - "description": "Describes the status of a given deployment attempt.", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "creator", - "description": "Identifies the actor who triggered the deployment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deployment", - "description": "Identifies the deployment associated with status.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Deployment", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "Identifies the description of the deployment.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "environmentUrl", - "description": "Identifies the environment URL of the deployment.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "logUrl", - "description": "Identifies the log URL of the deployment.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "Identifies the current state of the deployment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "DeploymentStatusState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "DeploymentStatusState", - "description": "The possible states for a deployment status.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "PENDING", - "description": "The deployment is pending.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUCCESS", - "description": "The deployment was successful.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FAILURE", - "description": "The deployment has failed.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INACTIVE", - "description": "The deployment is inactive.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ERROR", - "description": "The deployment experienced an error.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "QUEUED", - "description": "The deployment is queued", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "IN_PROGRESS", - "description": "The deployment is in progress.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "DeploymentState", - "description": "The possible states in which a deployment can be.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ABANDONED", - "description": "The pending deployment was not updated after 30 minutes.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ACTIVE", - "description": "The deployment is currently active.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DESTROYED", - "description": "An inactive transient deployment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ERROR", - "description": "The deployment experienced an error.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FAILURE", - "description": "The deployment has failed.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INACTIVE", - "description": "The deployment is inactive.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PENDING", - "description": "The deployment is pending.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "QUEUED", - "description": "The deployment has queued", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "IN_PROGRESS", - "description": "The deployment is in progress.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeploymentOrder", - "description": "Ordering options for deployment connections", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order deployments by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "DeploymentOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "DeploymentOrderField", - "description": "Properties by which deployment connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order collection by creation time", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "PullRequestOrder", - "description": "Ways in which lists of issues can be ordered upon return.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order pull requests by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order pull requests by the specified field.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PullRequestOrderField", - "description": "Properties by which pull_requests connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order pull_requests by creation time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order pull_requests by update time", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReleaseAssetConnection", - "description": "The connection type for ReleaseAsset.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReleaseAssetEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReleaseAsset", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReleaseAssetEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ReleaseAsset", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReleaseAsset", - "description": "A release asset contains the content for a release asset.", - "fields": [ - { - "name": "contentType", - "description": "The asset's content-type", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "downloadCount", - "description": "The number of times this asset was downloaded", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "downloadUrl", - "description": "Identifies the URL where you can download the release asset via the browser.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "Identifies the title of the release asset.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "release", - "description": "Release that the asset is associated with", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Release", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "size", - "description": "The size (in bytes) of the asset", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "uploadedBy", - "description": "The user that performed the upload", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "Identifies the URL of the release asset.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MarketplaceCategory", - "description": "A public description of a Marketplace category.", - "fields": [ - { - "name": "description", - "description": "The category's description.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "howItWorks", - "description": "The technical description of how apps listed in this category work with GitHub.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The category's name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "primaryListingCount", - "description": "How many Marketplace listings have this as their primary category.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this Marketplace category.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "secondaryListingCount", - "description": "How many Marketplace listings have this as their secondary category.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "slug", - "description": "The short name of the category used in its URL.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this Marketplace category.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MarketplaceListingConnection", - "description": "Look up Marketplace Listings", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "MarketplaceListingEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "MarketplaceListing", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MarketplaceListingEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "MarketplaceListing", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReleaseConnection", - "description": "The connection type for Release.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReleaseEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Release", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReleaseEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Release", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReleaseOrder", - "description": "Ways in which lists of releases can be ordered upon return.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order releases by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ReleaseOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order releases by the specified field.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ReleaseOrderField", - "description": "Properties by which release connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order releases by creation time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NAME", - "description": "Order releases alphabetically by name", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "IssuePubSubTopic", - "description": "The possible PubSub channels for an issue.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "UPDATED", - "description": "The channel ID for observing issue updates.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MARKASREAD", - "description": "The channel ID for marking an issue as read.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TIMELINE", - "description": "The channel ID for updating items on the issue timeline.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "STATE", - "description": "The channel ID for observing issue state updates.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationConnection", - "description": "The connection type for Organization.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "OrganizationEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationInvitation", - "description": "An Invitation for a user to an organization.", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": "The email address of the user invited to the organization.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "invitationType", - "description": "The type of invitation that was sent (e.g. email, user).", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrganizationInvitationType", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "invitee", - "description": "The user who was invited to the organization.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inviter", - "description": "The user who created the invitation.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organization", - "description": "The organization the invite is for", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "role", - "description": "The user's pending role in the organization (e.g. member, owner).", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrganizationInvitationRole", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "OrganizationInvitationType", - "description": "The possible organization invitation types.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "USER", - "description": "The invitation was to an existing user.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "EMAIL", - "description": "The invitation was to an email address.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "OrganizationInvitationRole", - "description": "The possible organization invitation roles.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "DIRECT_MEMBER", - "description": "The user is invited to be a direct member of the organization.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ADMIN", - "description": "The user is invited to be an admin of the organization.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "BILLING_MANAGER", - "description": "The user is invited to be a billing manager of the organization.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REINSTATE", - "description": "The user's previous role will be reinstated.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TeamConnection", - "description": "The connection type for Team.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Team", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TeamEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Team", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Team", - "description": "A team of users in an organization.", - "fields": [ - { - "name": "ancestors", - "description": "A list of teams that are ancestors of this team.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "avatarUrl", - "description": "A URL pointing to the team's avatar.", - "args": [ - { - "name": "size", - "description": "The size in pixels of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "400" - } - ], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "childTeams", - "description": "List of child teams belonging to this team", - "args": [ - { - "name": "orderBy", - "description": "Order for connection", - "type": { - "kind": "INPUT_OBJECT", - "name": "TeamOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "userLogins", - "description": "User logins to filter by", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "immediateOnly", - "description": "Whether to list immediate child teams or all descendant child teams.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "true" - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "combinedSlug", - "description": "The slug corresponding to the organization and team.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The description of the team.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editTeamResourcePath", - "description": "The HTTP path for editing this team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editTeamUrl", - "description": "The HTTP URL for editing this team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "invitations", - "description": "A list of pending invitations for users to this team", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "OrganizationInvitationConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "memberStatuses", - "description": "Get the status messages members of this entity have set that are either public or visible only to the organization.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for user statuses returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "UserStatusOrder", - "ofType": null - }, - "defaultValue": "{field:\"UPDATED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserStatusConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "members", - "description": "A list of users who are members of this team.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "query", - "description": "The search string to look for.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "membership", - "description": "Filter by membership type", - "type": { - "kind": "ENUM", - "name": "TeamMembershipType", - "ofType": null - }, - "defaultValue": "ALL" - }, - { - "name": "role", - "description": "Filter by team member role", - "type": { - "kind": "ENUM", - "name": "TeamMemberRole", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "TeamMemberOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamMemberConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "membersResourcePath", - "description": "The HTTP path for the team' members", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "membersUrl", - "description": "The HTTP URL for the team' members", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the team.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "newTeamResourcePath", - "description": "The HTTP path creating a new team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "newTeamUrl", - "description": "The HTTP URL creating a new team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organization", - "description": "The organization that owns this team.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "parentTeam", - "description": "The parent team of the team.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Team", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "privacy", - "description": "The level of privacy the team has.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "TeamPrivacy", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositories", - "description": "A list of repositories this team has access to.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "query", - "description": "The search string to look for.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Order for the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "TeamRepositoryOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamRepositoryConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositoriesResourcePath", - "description": "The HTTP path for this team's repositories", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositoriesUrl", - "description": "The HTTP URL for this team's repositories", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "slug", - "description": "The slug corresponding to the team.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "teamsResourcePath", - "description": "The HTTP path for this team's teams", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "teamsUrl", - "description": "The HTTP URL for this team's teams", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this team", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanAdminister", - "description": "Team is adminable by the viewer.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanSubscribe", - "description": "Check if the viewer is able to change their subscription status for the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerSubscription", - "description": "Identifies if the viewer is watching, not watching, or ignoring the subscribable entity.", - "args": [], - "type": { - "kind": "ENUM", - "name": "SubscriptionState", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "MemberStatusable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TeamPrivacy", - "description": "The possible team privacy values.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SECRET", - "description": "A secret team can only be seen by its members.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "VISIBLE", - "description": "A visible team can be seen and @mentioned by every member of the organization.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TeamMemberConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamMemberEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TeamMemberEdge", - "description": "Represents a user who is a member of a team.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "memberAccessResourcePath", - "description": "The HTTP path to the organization's member access page.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "memberAccessUrl", - "description": "The HTTP URL to the organization's member access page.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "role", - "description": "The role the member has on the team.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "TeamMemberRole", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TeamMemberRole", - "description": "The possible team member roles; either 'maintainer' or 'member'.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "MAINTAINER", - "description": "A team maintainer has permission to add and remove team members.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MEMBER", - "description": "A team member has no administrative permissions on the team.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TeamMembershipType", - "description": "Defines which types of team members are included in the returned list. Can be one of IMMEDIATE, CHILD_TEAM or ALL.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "IMMEDIATE", - "description": "Includes only immediate members of the team.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CHILD_TEAM", - "description": "Includes only child team members for the team.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ALL", - "description": "Includes immediate and child team members for the team.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "TeamMemberOrder", - "description": "Ordering options for team member connections", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order team members by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "TeamMemberOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TeamMemberOrderField", - "description": "Properties by which team member connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "LOGIN", - "description": "Order team members by login", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CREATED_AT", - "description": "Order team members by creation time", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TeamRepositoryConnection", - "description": "The connection type for Repository.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamRepositoryEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TeamRepositoryEdge", - "description": "Represents a team repository.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "permission", - "description": "The permission level the team has on the repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryPermission", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "RepositoryPermission", - "description": "The access level to a repository", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ADMIN", - "description": "Can read, clone, push, and add collaborators", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "WRITE", - "description": "Can read, clone and push", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "READ", - "description": "Can read and clone", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "TeamRepositoryOrder", - "description": "Ordering options for team repository connections", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order repositories by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "TeamRepositoryOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TeamRepositoryOrderField", - "description": "Properties by which team repository connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order repositories by creation time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order repositories by update time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PUSHED_AT", - "description": "Order repositories by push time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NAME", - "description": "Order repositories by name", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PERMISSION", - "description": "Order repositories by permission", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "STARGAZERS", - "description": "Order repositories by number of stargazers", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationInvitationConnection", - "description": "The connection type for OrganizationInvitation.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "OrganizationInvitationEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "OrganizationInvitation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationInvitationEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "OrganizationInvitation", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "TeamOrder", - "description": "Ways in which team connections can be ordered.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order nodes by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "TeamOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order nodes.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TeamOrderField", - "description": "Properties by which team connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "NAME", - "description": "Allows ordering a list of teams by name.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "DefaultRepositoryPermissionField", - "description": "The possible default permissions for repositories.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "NONE", - "description": "No access", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "READ", - "description": "Can read repos by default", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "WRITE", - "description": "Can read and write repos by default", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ADMIN", - "description": "Can read, write, and administrate repos by default", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ExternalIdentityConnection", - "description": "The connection type for ExternalIdentity.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ExternalIdentityEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ExternalIdentity", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ExternalIdentityEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ExternalIdentity", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ExternalIdentity", - "description": "An external identity provisioned by SAML SSO or SCIM.", - "fields": [ - { - "name": "guid", - "description": "The GUID for this identity", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organizationInvitation", - "description": "Organization invitation for this SCIM-provisioned external identity", - "args": [], - "type": { - "kind": "OBJECT", - "name": "OrganizationInvitation", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "samlIdentity", - "description": "SAML Identity attributes", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ExternalIdentitySamlAttributes", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "scimIdentity", - "description": "SCIM Identity attributes", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ExternalIdentityScimAttributes", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "User linked to this external identity. Will be NULL if this identity has not been claimed by an organization member.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ExternalIdentitySamlAttributes", - "description": "SAML attributes for the External Identity", - "fields": [ - { - "name": "nameId", - "description": "The NameID of the SAML identity", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ExternalIdentityScimAttributes", - "description": "SCIM attributes for the External Identity", - "fields": [ - { - "name": "username", - "description": "The userName of the SCIM identity", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PublicKey", - "description": "A user's public key.", - "fields": [ - { - "name": "accessedAt", - "description": "The last time this authorization was used to perform an action", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fingerprint", - "description": "The fingerprint for this PublicKey", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isReadOnly", - "description": "Whether this PublicKey is read-only or not", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "key", - "description": "The public key string", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "X509Certificate", - "description": "A valid x509 certificate string", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "IdentityProviderConfigurationState", - "description": "The possible states in which authentication can be configured with an identity provider.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ENFORCED", - "description": "Authentication with an identity provider is configured and enforced.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CONFIGURED", - "description": "Authentication with an identity provider is configured but not enforced.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNCONFIGURED", - "description": "Authentication with an identity provider is not configured.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Date", - "description": "An ISO-8601 encoded date string.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationIdentityProvider", - "description": "An Identity Provider configured to provision SAML and SCIM identities for Organizations", - "fields": [ - { - "name": "digestMethod", - "description": "The digest algorithm used to sign SAML requests for the Identity Provider.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "externalIdentities", - "description": "External Identities provisioned by this Identity Provider", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ExternalIdentityConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "idpCertificate", - "description": "The x509 certificate used by the Identity Provder to sign assertions and responses.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "X509Certificate", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issuer", - "description": "The Issuer Entity ID for the SAML Identity Provider", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "organization", - "description": "Organization this Identity Provider belongs to", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signatureMethod", - "description": "The signature algorithm used to sign SAML requests for the Identity Provider.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ssoUrl", - "description": "The URL endpoint for the Identity Provider's SAML SSO.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationMemberConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "OrganizationMemberEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OrganizationMemberEdge", - "description": "Represents a user within an organization.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasTwoFactorEnabled", - "description": "Whether the organization member has two factor enabled or not. Returns null if information is not available to viewer.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "role", - "description": "The role this user has in the organization.", - "args": [], - "type": { - "kind": "ENUM", - "name": "OrganizationMemberRole", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "OrganizationMemberRole", - "description": "The possible roles within an organization for its members.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "MEMBER", - "description": "The user is a member of the organization.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ADMIN", - "description": "The user is an administrator of the organization.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TeamRole", - "description": "The role of a user on a team.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ADMIN", - "description": "User has admin rights on the team.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MEMBER", - "description": "User is a member of the team.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "GistConnection", - "description": "The connection type for Gist.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "GistEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Gist", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "GistEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Gist", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "GistPrivacy", - "description": "The privacy of a Gist", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "PUBLIC", - "description": "Public", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SECRET", - "description": "Secret", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ALL", - "description": "Gists that are public and secret", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "GistOrder", - "description": "Ordering options for gist connections", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order repositories by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "GistOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "GistOrderField", - "description": "Properties by which gist connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CREATED_AT", - "description": "Order gists by creation time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order gists by update time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PUSHED_AT", - "description": "Order gists by push time", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryInvitationEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "RepositoryInvitation", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryInvitation", - "description": "An invitation for a user to be added to a repository.", - "fields": [ - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "invitee", - "description": "The user who received the invitation.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inviter", - "description": "The user who created the invitation.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "permission", - "description": "The permission granted on this repository by this invitation.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryPermission", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The Repository the user is invited to.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "RepositoryInfo", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Mannequin", - "description": "A placeholder user for attribution of imported data on GitHub.", - "fields": [ - { - "name": "avatarUrl", - "description": "A URL pointing to the GitHub App's public avatar.", - "args": [ - { - "name": "size", - "description": "The size of the resulting square image.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "login", - "description": "The username of the actor.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTML path to this resource.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The URL to this resource.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "LanguageConnection", - "description": "A list of languages associated with the parent.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "LanguageEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Language", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalSize", - "description": "The total size in bytes of files written in that language.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "LanguageEdge", - "description": "Represents the language of a repository.", - "fields": [ - { - "name": "cursor", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Language", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "size", - "description": "The number of bytes of code written in the language.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Milestone", - "description": "Represents a Milestone object on a given repository.", - "fields": [ - { - "name": "closed", - "description": "`true` if the object is closed (definition of closed may depend on type)", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closedAt", - "description": "Identifies the date and time when the object was closed.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "creator", - "description": "Identifies the actor who created the milestone.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "Identifies the description of the milestone.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "dueOn", - "description": "Identifies the due date of the milestone.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issues", - "description": "A list of issues associated with the milestone.", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "states", - "description": "A list of states to filter the issues by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "IssueState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "filterBy", - "description": "Filtering options for issues returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueFilters", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "number", - "description": "Identifies the number of the milestone.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequests", - "description": "A list of pull requests associated with the milestone.", - "args": [ - { - "name": "states", - "description": "A list of states to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestState", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "labels", - "description": "A list of label names to filter the pull requests by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "headRefName", - "description": "The head ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "baseRefName", - "description": "The base ref name to filter the pull requests by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for pull requests returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "IssueOrder", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this milestone.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this milestone", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "Identifies the state of the milestone.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "MilestoneState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "title", - "description": "Identifies the title of the milestone.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this milestone", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Closable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "MilestoneState", - "description": "The possible states of a milestone.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OPEN", - "description": "A milestone that is still open.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CLOSED", - "description": "A milestone that has been closed.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestChangedFileConnection", - "description": "The connection type for PullRequestChangedFile.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestChangedFileEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestChangedFile", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestChangedFileEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestChangedFile", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestChangedFile", - "description": "A file changed in a pull request.", - "fields": [ - { - "name": "additions", - "description": "The number of additions to the file.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletions", - "description": "The number of deletions to the file.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "path", - "description": "The path of the file.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "MergeableState", - "description": "Whether or not a PullRequest can be merged.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "MERGEABLE", - "description": "The pull request can be merged.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CONFLICTING", - "description": "The pull request cannot be merged due to merge conflicts.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNKNOWN", - "description": "The mergeability of the pull request is still being calculated.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "description": "A review comment associated with a given repository pull request.", - "fields": [ - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the subject of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "The comment body of this review comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "The comment body of this review comment rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "The comment body of this review comment rendered as plain text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "Identifies the commit associated with the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies when the comment was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "diffHunk", - "description": "The diff hunk to which the comment applies.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "draftedAt", - "description": "Identifies when the comment was created in a draft state.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isMinimized", - "description": "Returns whether or not a comment has been minimized.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "minimizedReason", - "description": "Returns why the comment was minimized.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "originalCommit", - "description": "Identifies the original commit associated with the comment.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "originalPosition", - "description": "The original line index in the diff to which the comment applies.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "outdated", - "description": "Identifies when the comment body is outdated", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "path", - "description": "The path to which the comment applies.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "position", - "description": "The line index in the diff to which the comment applies.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request associated with this review comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The pull request review associated with this review comment.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactionGroups", - "description": "A list of reactions grouped by content left on the subject.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionGroup", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactions", - "description": "A list of Reactions left on the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "content", - "description": "Allows filtering Reactions by emoji.", - "type": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Allows specifying the order in which reactions are returned.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "replyTo", - "description": "The comment this is a reply to.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path permalink for this review comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "Identifies the state of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestReviewCommentState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies when the comment was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL permalink for this review comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanDelete", - "description": "Check if the current viewer can delete this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanMinimize", - "description": "Check if the current viewer can minimize this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReact", - "description": "Can user react to this subject", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Deletable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "description": "A review object for a given pull request.", - "fields": [ - { - "name": "author", - "description": "The actor who authored the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "authorAssociation", - "description": "Author's association with the subject of the comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentAuthorAssociation", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "body", - "description": "Identifies the pull request review body.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyHTML", - "description": "The body of this review rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bodyText", - "description": "The body of this review rendered as plain text.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "comments", - "description": "A list of review comments for the current pull request review.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "Identifies the commit associated with this pull request review.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdViaEmail", - "description": "Check if this comment was created via an email reply.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "editor", - "description": "The actor who edited the comment.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "includesCreatedEdit", - "description": "Check if this comment was edited and includes an edit with the creation data", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastEditedAt", - "description": "The moment the editor made the last edit", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onBehalfOf", - "description": "A list of teams that this review was made on behalf of.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TeamConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "Identifies when the comment was published at.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "Identifies the pull request associated with this pull request review.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactionGroups", - "description": "A list of reactions grouped by content left on the subject.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionGroup", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reactions", - "description": "A list of Reactions left on the Issue.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "content", - "description": "Allows filtering Reactions by emoji.", - "type": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Allows specifying the order in which reactions are returned.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReactionOrder", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReactionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path permalink for this PullRequestReview.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "Identifies the current state of the pull request review.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestReviewState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "submittedAt", - "description": "Identifies when the Pull Request Review was submitted", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the object was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL permalink for this PullRequestReview.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userContentEdits", - "description": "A list of edits to this content.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserContentEditConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanDelete", - "description": "Check if the current viewer can delete this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanReact", - "description": "Can user react to this subject", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUpdate", - "description": "Check if the current viewer can update this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCannotUpdateReasons", - "description": "Reasons why the current viewer can not update this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommentCannotUpdateReason", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerDidAuthor", - "description": "Did the viewer author this comment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Comment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Deletable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Updatable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UpdatableComment", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PullRequestReviewState", - "description": "The possible states of a pull request review.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "PENDING", - "description": "A review that has not yet been submitted.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "COMMENTED", - "description": "An informational review.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "APPROVED", - "description": "A review allowing the pull request to merge.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CHANGES_REQUESTED", - "description": "A review blocking the pull request from merging.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DISMISSED", - "description": "A review that has been dismissed.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewCommentConnection", - "description": "The connection type for PullRequestReviewComment.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewCommentEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewCommentEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "description": "A threaded list of comments for a given pull request.", - "fields": [ - { - "name": "comments", - "description": "A list of pull request comments associated with the thread.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isResolved", - "description": "Whether this thread has been resolved", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "Identifies the pull request associated with this thread.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "Identifies the repository associated with this thread.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resolvedBy", - "description": "The user who resolved this thread", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanResolve", - "description": "Whether or not the viewer can resolve this thread", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "viewerCanUnresolve", - "description": "Whether or not the viewer can unresolve this thread", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommit", - "description": "Represents a Git commit part of a pull request.", - "fields": [ - { - "name": "commit", - "description": "The Git commit object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request this commit belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this pull request commit", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this pull request commit", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewThreadConnection", - "description": "Review comment threads for a pull request review.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewThreadEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewThreadEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PullRequestReviewCommentState", - "description": "The possible states of a pull request review comment.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "PENDING", - "description": "A comment that is part of a pending review", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBMITTED", - "description": "A comment that is part of a submitted review", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PullRequestPubSubTopic", - "description": "The possible PubSub channels for a pull request.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "UPDATED", - "description": "The channel ID for observing pull request updates.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MARKASREAD", - "description": "The channel ID for marking an pull request as read.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "HEAD_REF", - "description": "The channel ID for observing head ref updates.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TIMELINE", - "description": "The channel ID for updating items on the pull request timeline.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "STATE", - "description": "The channel ID for observing pull request state updates.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueCommentConnection", - "description": "The connection type for IssueComment.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueCommentEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueCommentEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewConnection", - "description": "The connection type for PullRequestReview.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommitConnection", - "description": "The connection type for PullRequestCommit.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestCommitEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestCommit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommitEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestCommit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestConnection", - "description": "The connection type for ReviewRequest.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReviewRequestEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReviewRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ReviewRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequest", - "description": "A request for a user to review a pull request.", - "fields": [ - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "Identifies the pull request associated with this review request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requestedReviewer", - "description": "The reviewer that is requested.", - "args": [], - "type": { - "kind": "UNION", - "name": "RequestedReviewer", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "RequestedReviewer", - "description": "Types that can be requested reviewers.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Team", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Mannequin", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "PullRequestTimelineConnection", - "description": "The connection type for PullRequestTimelineItem.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestTimelineItemEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "UNION", - "name": "PullRequestTimelineItem", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestTimelineItemEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "UNION", - "name": "PullRequestTimelineItem", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "PullRequestTimelineItem", - "description": "An item in an pull request timeline", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CommitCommentThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ClosedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReopenedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "SubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnsubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MergedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CrossReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "AssignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnassignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DemilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RenamedTitleEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeployedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeploymentEnvironmentChangedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefDeletedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefRestoredEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefForcePushedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "BaseRefForcePushedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestRemovedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UserBlockedEvent", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "CommitCommentThread", - "description": "A thread of comments on a commit.", - "fields": [ - { - "name": "comments", - "description": "The comments that exist in this thread.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "The commit the comments were made on.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "path", - "description": "The file the comments were made on.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "position", - "description": "The position in the diff for the commit that the comment was made on.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ClosedEvent", - "description": "Represents a 'closed' event on any `Closable`.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closable", - "description": "Object that was closed.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Closable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closer", - "description": "Object which triggered the creation of this event.", - "args": [], - "type": { - "kind": "UNION", - "name": "Closer", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this closed event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this closed event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "Closer", - "description": "The object which triggered a `ClosedEvent`.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "ReopenedEvent", - "description": "Represents a 'reopened' event on any `Closable`.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closable", - "description": "Object that was reopened.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Closable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SubscribedEvent", - "description": "Represents a 'subscribed' event on a given `Subscribable`.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscribable", - "description": "Object referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnsubscribedEvent", - "description": "Represents an 'unsubscribed' event on a given `Subscribable`.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscribable", - "description": "Object referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MergedEvent", - "description": "Represents a 'merged' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "Identifies the commit associated with the `merge` event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergeRef", - "description": "Identifies the Ref associated with the `merge` event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergeRefName", - "description": "Identifies the name of the Ref associated with the `merge` event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this merged event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this merged event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReferencedEvent", - "description": "Represents a 'referenced' event on a given `ReferencedSubject`.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "Identifies the commit associated with the 'referenced' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitRepository", - "description": "Identifies the repository associated with the 'referenced' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isCrossRepository", - "description": "Reference originated in a different repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDirectReference", - "description": "Checks if the commit message itself references the subject. Can be false in the case of a commit comment reference.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "Object referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "UNION", - "name": "ReferencedSubject", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "ReferencedSubject", - "description": "Any referencable object", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "CrossReferencedEvent", - "description": "Represents a mention made by one issue or pull request to another.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isCrossRepository", - "description": "Reference originated in a different repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "referencedAt", - "description": "Identifies when the reference was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "source", - "description": "Issue or pull request that made the reference.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "UNION", - "name": "ReferencedSubject", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "target", - "description": "Issue or pull request to which the reference was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "UNION", - "name": "ReferencedSubject", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "willCloseTarget", - "description": "Checks if the target will be closed when the source is merged.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AssignedEvent", - "description": "Represents an 'assigned' event on any assignable object.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "assignable", - "description": "Identifies the assignable associated with the event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Assignable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "Identifies the user who was assigned.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnassignedEvent", - "description": "Represents an 'unassigned' event on any assignable object.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "assignable", - "description": "Identifies the assignable associated with the event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Assignable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "Identifies the subject (user) who was unassigned.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "LabeledEvent", - "description": "Represents a 'labeled' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "label", - "description": "Identifies the label associated with the 'labeled' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Label", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labelable", - "description": "Identifies the `Labelable` associated with the event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Labelable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnlabeledEvent", - "description": "Represents an 'unlabeled' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "label", - "description": "Identifies the label associated with the 'unlabeled' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Label", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labelable", - "description": "Identifies the `Labelable` associated with the event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Labelable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MilestonedEvent", - "description": "Represents a 'milestoned' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "milestoneTitle", - "description": "Identifies the milestone title associated with the 'milestoned' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "Object referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "UNION", - "name": "MilestoneItem", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "MilestoneItem", - "description": "Types that can be inside a Milestone.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "DemilestonedEvent", - "description": "Represents a 'demilestoned' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "milestoneTitle", - "description": "Identifies the milestone title associated with the 'demilestoned' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "Object referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "UNION", - "name": "MilestoneItem", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RenamedTitleEvent", - "description": "Represents a 'renamed' event on a given issue or pull request", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "currentTitle", - "description": "Identifies the current title of the issue or pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "previousTitle", - "description": "Identifies the previous title of the issue or pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "Subject that was renamed.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "UNION", - "name": "RenamedTitleSubject", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "RenamedTitleSubject", - "description": "An object which has a renamable title", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "LockedEvent", - "description": "Represents a 'locked' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lockReason", - "description": "Reason that the conversation was locked (optional).", - "args": [], - "type": { - "kind": "ENUM", - "name": "LockReason", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lockable", - "description": "Object that was locked.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Lockable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnlockedEvent", - "description": "Represents an 'unlocked' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lockable", - "description": "Object that was unlocked.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Lockable", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeployedEvent", - "description": "Represents a 'deployed' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deployment", - "description": "The deployment associated with the 'deployed' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Deployment", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ref", - "description": "The ref associated with the 'deployed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeploymentEnvironmentChangedEvent", - "description": "Represents a 'deployment_environment_changed' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deploymentStatus", - "description": "The deployment status that updated the deployment environment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeploymentStatus", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "HeadRefDeletedEvent", - "description": "Represents a 'head_ref_deleted' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "headRef", - "description": "Identifies the Ref associated with the `head_ref_deleted` event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "headRefName", - "description": "Identifies the name of the Ref associated with the `head_ref_deleted` event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "HeadRefRestoredEvent", - "description": "Represents a 'head_ref_restored' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "HeadRefForcePushedEvent", - "description": "Represents a 'head_ref_force_pushed' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "afterCommit", - "description": "Identifies the after commit SHA for the 'head_ref_force_pushed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "beforeCommit", - "description": "Identifies the before commit SHA for the 'head_ref_force_pushed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ref", - "description": "Identifies the fully qualified ref name for the 'head_ref_force_pushed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BaseRefForcePushedEvent", - "description": "Represents a 'base_ref_force_pushed' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "afterCommit", - "description": "Identifies the after commit SHA for the 'base_ref_force_pushed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "beforeCommit", - "description": "Identifies the before commit SHA for the 'base_ref_force_pushed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ref", - "description": "Identifies the fully qualified ref name for the 'base_ref_force_pushed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestedEvent", - "description": "Represents an 'review_requested' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requestedReviewer", - "description": "Identifies the reviewer whose review was requested.", - "args": [], - "type": { - "kind": "UNION", - "name": "RequestedReviewer", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestRemovedEvent", - "description": "Represents an 'review_request_removed' event on a given pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requestedReviewer", - "description": "Identifies the reviewer whose review request was removed.", - "args": [], - "type": { - "kind": "UNION", - "name": "RequestedReviewer", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissedEvent", - "description": "Represents a 'review_dismissed' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "dismissalMessage", - "description": "Identifies the optional message associated with the 'review_dismissed' event.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "dismissalMessageHTML", - "description": "Identifies the optional message associated with the event, rendered to HTML.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "message", - "description": "Identifies the message associated with the 'review_dismissed' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "`message` is being removed because it not nullable, whereas the underlying field is optional. Use `dismissalMessage` instead. Removal on 2019-07-01 UTC." - }, - { - "name": "messageHtml", - "description": "The message associated with the event, rendered to HTML.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "HTML", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "`messageHtml` is being removed because it not nullable, whereas the underlying field is optional. Use `dismissalMessageHTML` instead. Removal on 2019-07-01 UTC." - }, - { - "name": "previousReviewState", - "description": "Identifies the previous state of the review with the 'review_dismissed' event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestReviewState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "PullRequest referenced by event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestCommit", - "description": "Identifies the commit which caused the review to become stale.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestCommit", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this review dismissed event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "review", - "description": "Identifies the review associated with the 'review_dismissed' event.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this review dismissed event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "UniformResourceLocatable", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UserBlockedEvent", - "description": "Represents a 'user_blocked' event on a given user.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "blockDuration", - "description": "Number of days that the user was blocked for.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "UserBlockDuration", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "The user who was blocked.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "UserBlockDuration", - "description": "The possible durations that a user can be blocked for.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ONE_DAY", - "description": "The user was blocked for 1 day", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "THREE_DAYS", - "description": "The user was blocked for 3 days", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ONE_WEEK", - "description": "The user was blocked for 7 days", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ONE_MONTH", - "description": "The user was blocked for 30 days", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PERMANENT", - "description": "The user was blocked permanently", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestTimelineItemsConnection", - "description": "The connection type for PullRequestTimelineItems.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestTimelineItemsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "filteredCount", - "description": "Identifies the count of items after applying `before` and `after` filters.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "UNION", - "name": "PullRequestTimelineItems", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageCount", - "description": "Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the timeline was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestTimelineItemsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "UNION", - "name": "PullRequestTimelineItems", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "PullRequestTimelineItems", - "description": "An item in a pull request timeline", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "PullRequestCommit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestCommitCommentThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequestRevisionMarker", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "BaseRefChangedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "BaseRefForcePushedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeployedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DeploymentEnvironmentChangedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefDeletedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefForcePushedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "HeadRefRestoredEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MergedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReviewRequestRemovedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CrossReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "AddedToProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "AssignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ClosedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CommentDeletedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ConvertedNoteToIssueEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DemilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MentionedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MovedColumnsInProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PinnedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RemovedFromProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RenamedTitleEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReopenedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "SubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "TransferredEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnassignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UserBlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnpinnedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnsubscribedEvent", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "PullRequestCommitCommentThread", - "description": "Represents a commit comment thread part of a pull request.", - "fields": [ - { - "name": "comments", - "description": "The comments that exist in this thread.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitCommentConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commit", - "description": "The commit the comments were made on.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "path", - "description": "The file the comments were made on.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "position", - "description": "The position in the diff for the commit that the comment was made on.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request this commit comment thread belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this node.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "RepositoryNode", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestRevisionMarker", - "description": "Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits.", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lastSeenCommit", - "description": "The last commit the viewer has seen.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request to which the marker belongs.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BaseRefChangedEvent", - "description": "Represents a 'base_ref_changed' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddedToProjectEvent", - "description": "Represents a 'added_to_project' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommentDeletedEvent", - "description": "Represents a 'comment_deleted' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ConvertedNoteToIssueEvent", - "description": "Represents a 'converted_note_to_issue' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "IssueOrPullRequest", - "description": "Used for return value of Repository.issueOrPullRequest.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "MentionedEvent", - "description": "Represents a 'mentioned' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MovedColumnsInProjectEvent", - "description": "Represents a 'moved_columns_in_project' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PinnedEvent", - "description": "Represents a 'pinned' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "Identifies the issue associated with the event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RemovedFromProjectEvent", - "description": "Represents a 'removed_from_project' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TransferredEvent", - "description": "Represents a 'transferred' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fromRepository", - "description": "The repository this came from", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "Identifies the issue associated with the event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnpinnedEvent", - "description": "Represents an 'unpinned' event on a given issue or pull request.", - "fields": [ - { - "name": "actor", - "description": "Identifies the actor who performed the event.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "Identifies the issue associated with the event.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PullRequestTimelineItemsItemType", - "description": "The possible item types found in a timeline.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "PULL_REQUEST_COMMIT", - "description": "Represents a Git commit part of a pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PULL_REQUEST_COMMIT_COMMENT_THREAD", - "description": "Represents a commit comment thread part of a pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PULL_REQUEST_REVIEW", - "description": "A review object for a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PULL_REQUEST_REVIEW_THREAD", - "description": "A threaded list of comments for a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PULL_REQUEST_REVISION_MARKER", - "description": "Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "BASE_REF_CHANGED_EVENT", - "description": "Represents a 'base_ref_changed' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "BASE_REF_FORCE_PUSHED_EVENT", - "description": "Represents a 'base_ref_force_pushed' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DEPLOYED_EVENT", - "description": "Represents a 'deployed' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DEPLOYMENT_ENVIRONMENT_CHANGED_EVENT", - "description": "Represents a 'deployment_environment_changed' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "HEAD_REF_DELETED_EVENT", - "description": "Represents a 'head_ref_deleted' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "HEAD_REF_FORCE_PUSHED_EVENT", - "description": "Represents a 'head_ref_force_pushed' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "HEAD_REF_RESTORED_EVENT", - "description": "Represents a 'head_ref_restored' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MERGED_EVENT", - "description": "Represents a 'merged' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REVIEW_DISMISSED_EVENT", - "description": "Represents a 'review_dismissed' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REVIEW_REQUESTED_EVENT", - "description": "Represents an 'review_requested' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REVIEW_REQUEST_REMOVED_EVENT", - "description": "Represents an 'review_request_removed' event on a given pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ISSUE_COMMENT", - "description": "Represents a comment on an Issue.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CROSS_REFERENCED_EVENT", - "description": "Represents a mention made by one issue or pull request to another.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ADDED_TO_PROJECT_EVENT", - "description": "Represents a 'added_to_project' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ASSIGNED_EVENT", - "description": "Represents an 'assigned' event on any assignable object.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CLOSED_EVENT", - "description": "Represents a 'closed' event on any `Closable`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "COMMENT_DELETED_EVENT", - "description": "Represents a 'comment_deleted' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CONVERTED_NOTE_TO_ISSUE_EVENT", - "description": "Represents a 'converted_note_to_issue' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DEMILESTONED_EVENT", - "description": "Represents a 'demilestoned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LABELED_EVENT", - "description": "Represents a 'labeled' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LOCKED_EVENT", - "description": "Represents a 'locked' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MENTIONED_EVENT", - "description": "Represents a 'mentioned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MILESTONED_EVENT", - "description": "Represents a 'milestoned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MOVED_COLUMNS_IN_PROJECT_EVENT", - "description": "Represents a 'moved_columns_in_project' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PINNED_EVENT", - "description": "Represents a 'pinned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REFERENCED_EVENT", - "description": "Represents a 'referenced' event on a given `ReferencedSubject`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REMOVED_FROM_PROJECT_EVENT", - "description": "Represents a 'removed_from_project' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "RENAMED_TITLE_EVENT", - "description": "Represents a 'renamed' event on a given issue or pull request", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REOPENED_EVENT", - "description": "Represents a 'reopened' event on any `Closable`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIBED_EVENT", - "description": "Represents a 'subscribed' event on a given `Subscribable`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TRANSFERRED_EVENT", - "description": "Represents a 'transferred' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNASSIGNED_EVENT", - "description": "Represents an 'unassigned' event on any assignable object.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNLABELED_EVENT", - "description": "Represents an 'unlabeled' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNLOCKED_EVENT", - "description": "Represents an 'unlocked' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "USER_BLOCKED_EVENT", - "description": "Represents a 'user_blocked' event on a given user.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNPINNED_EVENT", - "description": "Represents an 'unpinned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNSUBSCRIBED_EVENT", - "description": "Represents an 'unsubscribed' event on a given `Subscribable`.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SuggestedReviewer", - "description": "A suggestion to review a pull request based on a user's commit history and review comments.", - "fields": [ - { - "name": "isAuthor", - "description": "Is this suggestion based on past commits?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isCommenter", - "description": "Is this suggestion based on past review comments?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reviewer", - "description": "Identifies the user suggested to review the pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ProjectCardArchivedState", - "description": "The possible archived states of a project card.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ARCHIVED", - "description": "A project card that is archived", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NOT_ARCHIVED", - "description": "A project card that is not archived", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueTimelineConnection", - "description": "The connection type for IssueTimelineItem.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueTimelineItemEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "UNION", - "name": "IssueTimelineItem", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueTimelineItemEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "UNION", - "name": "IssueTimelineItem", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "IssueTimelineItem", - "description": "An item in an issue timeline", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Commit", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CrossReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ClosedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReopenedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "SubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnsubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "AssignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnassignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UserBlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DemilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RenamedTitleEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "TransferredEvent", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "IssueTimelineItemsConnection", - "description": "The connection type for IssueTimelineItems.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueTimelineItemsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "filteredCount", - "description": "Identifies the count of items after applying `before` and `after` filters.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "UNION", - "name": "IssueTimelineItems", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageCount", - "description": "Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "Identifies the date and time when the timeline was last updated.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueTimelineItemsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "UNION", - "name": "IssueTimelineItems", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "IssueTimelineItems", - "description": "An item in an issue timeline", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CrossReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "AddedToProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "AssignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ClosedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CommentDeletedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ConvertedNoteToIssueEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "DemilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "LockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MentionedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MilestonedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MovedColumnsInProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PinnedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReferencedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RemovedFromProjectEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RenamedTitleEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ReopenedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "SubscribedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "TransferredEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnassignedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlabeledEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UserBlockedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnpinnedEvent", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "UnsubscribedEvent", - "ofType": null - } - ] - }, - { - "kind": "ENUM", - "name": "IssueTimelineItemsItemType", - "description": "The possible item types found in a timeline.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ISSUE_COMMENT", - "description": "Represents a comment on an Issue.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CROSS_REFERENCED_EVENT", - "description": "Represents a mention made by one issue or pull request to another.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ADDED_TO_PROJECT_EVENT", - "description": "Represents a 'added_to_project' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ASSIGNED_EVENT", - "description": "Represents an 'assigned' event on any assignable object.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CLOSED_EVENT", - "description": "Represents a 'closed' event on any `Closable`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "COMMENT_DELETED_EVENT", - "description": "Represents a 'comment_deleted' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CONVERTED_NOTE_TO_ISSUE_EVENT", - "description": "Represents a 'converted_note_to_issue' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DEMILESTONED_EVENT", - "description": "Represents a 'demilestoned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LABELED_EVENT", - "description": "Represents a 'labeled' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LOCKED_EVENT", - "description": "Represents a 'locked' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MENTIONED_EVENT", - "description": "Represents a 'mentioned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MILESTONED_EVENT", - "description": "Represents a 'milestoned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MOVED_COLUMNS_IN_PROJECT_EVENT", - "description": "Represents a 'moved_columns_in_project' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PINNED_EVENT", - "description": "Represents a 'pinned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REFERENCED_EVENT", - "description": "Represents a 'referenced' event on a given `ReferencedSubject`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REMOVED_FROM_PROJECT_EVENT", - "description": "Represents a 'removed_from_project' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "RENAMED_TITLE_EVENT", - "description": "Represents a 'renamed' event on a given issue or pull request", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REOPENED_EVENT", - "description": "Represents a 'reopened' event on any `Closable`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIBED_EVENT", - "description": "Represents a 'subscribed' event on a given `Subscribable`.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TRANSFERRED_EVENT", - "description": "Represents a 'transferred' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNASSIGNED_EVENT", - "description": "Represents an 'unassigned' event on any assignable object.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNLABELED_EVENT", - "description": "Represents an 'unlabeled' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNLOCKED_EVENT", - "description": "Represents an 'unlocked' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "USER_BLOCKED_EVENT", - "description": "Represents a 'user_blocked' event on a given user.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNPINNED_EVENT", - "description": "Represents an 'unpinned' event on a given issue or pull request.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNSUBSCRIBED_EVENT", - "description": "Represents an 'unsubscribed' event on a given `Subscribable`.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "CollaboratorAffiliation", - "description": "Collaborators affiliation level with a subject.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OUTSIDE", - "description": "All outside collaborators of an organization-owned subject.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DIRECT", - "description": "All collaborators with permissions to an organization-owned subject, regardless of organization membership status.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ALL", - "description": "All collaborators the authenticated user can see.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeployKeyConnection", - "description": "The connection type for DeployKey.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeployKeyEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "DeployKey", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeployKeyEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "DeployKey", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeployKey", - "description": "A repository deploy key.", - "fields": [ - { - "name": "createdAt", - "description": "Identifies the date and time when the object was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "key", - "description": "The deploy key.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "readOnly", - "description": "Whether or not the deploy key is read only.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "title", - "description": "The deploy key title.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "verified", - "description": "Whether or not the deploy key has been verified.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "RepositoryCollaboratorAffiliation", - "description": "The affiliation type between collaborator and repository.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ALL", - "description": "All collaborators of the repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OUTSIDE", - "description": "All outside collaborators of an organization-owned repository.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BranchProtectionRuleConnection", - "description": "The connection type for BranchProtectionRule.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "BranchProtectionRuleEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BranchProtectionRuleEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "description": "A branch protection rule.", - "fields": [ - { - "name": "branchProtectionRuleConflicts", - "description": "A list of conflicts matching branches protection rule and other branch protection rules", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "BranchProtectionRuleConflictConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "creator", - "description": "The actor who created this branch protection rule.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Actor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "dismissesStaleReviews", - "description": "Will new commits pushed to matching branches dismiss pull request review approvals.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isAdminEnforced", - "description": "Can admins overwrite branch protection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "matchingRefs", - "description": "Repository refs that are protected by this rule", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RefConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pattern", - "description": "Identifies the protection rule pattern.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pushAllowances", - "description": "A list push allowances for this branch protection rule.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PushAllowanceConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository associated with this branch protection rule.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requiredApprovingReviewCount", - "description": "Number of approving reviews required to update matching branches.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requiredStatusCheckContexts", - "description": "List of required status check contexts that must pass for commits to be accepted to matching branches.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requiresApprovingReviews", - "description": "Are approving reviews required to update matching branches.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requiresCommitSignatures", - "description": "Are commits required to be signed.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requiresStatusChecks", - "description": "Are status checks required to update matching branches.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requiresStrictStatusChecks", - "description": "Are branches required to be up to date before merging.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "restrictsPushes", - "description": "Is pushing to matching branches restricted.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "restrictsReviewDismissals", - "description": "Is dismissal of pull request reviews restricted.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reviewDismissalAllowances", - "description": "A list review dismissal allowances for this branch protection rule.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReviewDismissalAllowanceConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissalAllowanceConnection", - "description": "The connection type for ReviewDismissalAllowance.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReviewDismissalAllowanceEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ReviewDismissalAllowance", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissalAllowanceEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ReviewDismissalAllowance", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReviewDismissalAllowance", - "description": "A team or user who has the ability to dismiss a review on a protected branch.", - "fields": [ - { - "name": "actor", - "description": "The actor that can dismiss.", - "args": [], - "type": { - "kind": "UNION", - "name": "ReviewDismissalAllowanceActor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "branchProtectionRule", - "description": "Identifies the branch protection rule associated with the allowed user or team.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "ReviewDismissalAllowanceActor", - "description": "Types that can be an actor.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Team", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "PushAllowanceConnection", - "description": "The connection type for PushAllowance.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PushAllowanceEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PushAllowance", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PushAllowanceEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PushAllowance", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PushAllowance", - "description": "A team or user who has the ability to push to a protected branch.", - "fields": [ - { - "name": "actor", - "description": "The actor that can push.", - "args": [], - "type": { - "kind": "UNION", - "name": "PushAllowanceActor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "branchProtectionRule", - "description": "Identifies the branch protection rule associated with the allowed user or team.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "PushAllowanceActor", - "description": "Types that can be an actor.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Team", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "RefConnection", - "description": "The connection type for Ref.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RefEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RefEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BranchProtectionRuleConflictConnection", - "description": "The connection type for BranchProtectionRuleConflict.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "BranchProtectionRuleConflictEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "BranchProtectionRuleConflict", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BranchProtectionRuleConflictEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRuleConflict", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "BranchProtectionRuleConflict", - "description": "A conflict between two branch protection rules.", - "fields": [ - { - "name": "branchProtectionRule", - "description": "Identifies the branch protection rule.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "conflictingBranchProtectionRule", - "description": "Identifies the conflicting branch protection rule.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ref", - "description": "Identifies the branch ref that has conflicting rules", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Ref", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MilestoneConnection", - "description": "The connection type for Milestone.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "MilestoneEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MilestoneEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Milestone", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "MilestoneOrder", - "description": "Ordering options for milestone connections.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order milestones by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "MilestoneOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "MilestoneOrderField", - "description": "Properties by which milestone connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "DUE_DATE", - "description": "Order milestones by when they are due.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CREATED_AT", - "description": "Order milestones by when they were created.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order milestones by when they were last updated.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NUMBER", - "description": "Order milestones by their number.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CodeOfConduct", - "description": "The Code of Conduct for a repository", - "fields": [ - { - "name": "body", - "description": "The body of the Code of Conduct", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "key", - "description": "The key for the Code of Conduct", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The formal name of the Code of Conduct", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this Code of Conduct", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this Code of Conduct", - "args": [], - "type": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryCollaboratorConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "RepositoryCollaboratorEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RepositoryCollaboratorEdge", - "description": "Represents a user who is a collaborator of a repository.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "permission", - "description": "The permission the user has on the repository.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RepositoryPermission", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "permissionSources", - "description": "A list of sources for the user's access to the repository.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PermissionSource", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PermissionSource", - "description": "A level of permission and source for a user's access to a repository.", - "fields": [ - { - "name": "organization", - "description": "The organization the repository belongs to.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "permission", - "description": "The level of access this source has granted to the user.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "DefaultRepositoryPermissionField", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "source", - "description": "The source of this permission.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "UNION", - "name": "PermissionGranter", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "PermissionGranter", - "description": "Types that can grant permissions on a repository to a user", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Team", - "ofType": null - } - ] - }, - { - "kind": "INPUT_OBJECT", - "name": "LanguageOrder", - "description": "Ordering options for language connections.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order languages by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "LanguageOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "LanguageOrderField", - "description": "Properties by which language connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SIZE", - "description": "Order languages by the size of all files containing the language", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RefOrder", - "description": "Ways in which lists of git refs can be ordered upon return.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field in which to order refs by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "RefOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The direction in which to order refs by the specified field.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "RefOrderField", - "description": "Properties by which ref connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "TAG_COMMIT_DATE", - "description": "Order refs by underlying commit date if the ref prefix is refs/tags/", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ALPHABETICAL", - "description": "Order refs by their alphanumeric name", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisory", - "description": "A GitHub Security Advisory", - "fields": [ - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "This is a long plaintext description of the advisory", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ghsaId", - "description": "The GitHub Security Advisory ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "identifiers", - "description": "A list of identifiers for this advisory", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityAdvisoryIdentifier", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "origin", - "description": "The organization that originated the advisory", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "publishedAt", - "description": "When the advisory was published", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "references", - "description": "A list of references for this advisory", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityAdvisoryReference", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "severity", - "description": "The severity of the advisory", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityAdvisorySeverity", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "summary", - "description": "A short plaintext summary of the advisory", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "When the advisory was last updated", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vulnerabilities", - "description": "Vulnerabilities associated with this Advisory", - "args": [ - { - "name": "orderBy", - "description": "Ordering options for the returned topics.", - "type": { - "kind": "INPUT_OBJECT", - "name": "SecurityVulnerabilityOrder", - "ofType": null - }, - "defaultValue": "{field:\"UPDATED_AT\",direction:\"DESC\"}" - }, - { - "name": "ecosystem", - "description": "An ecosystem to filter vulnerabilities by.", - "type": { - "kind": "ENUM", - "name": "SecurityAdvisoryEcosystem", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "package", - "description": "A package name to filter vulnerabilities by.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "severities", - "description": "A list of severities to filter vulnerabilities by.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityAdvisorySeverity", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityVulnerabilityConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "withdrawnAt", - "description": "When the advisory was withdrawn, if it has been withdrawn", - "args": [], - "type": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "SecurityAdvisorySeverity", - "description": "Severity of the vulnerability.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "LOW", - "description": "Low.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MODERATE", - "description": "Moderate.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "HIGH", - "description": "High.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CRITICAL", - "description": "Critical.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisoryIdentifier", - "description": "A GitHub Security Advisory Identifier", - "fields": [ - { - "name": "type", - "description": "The identifier type, e.g. GHSA, CVE", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "value", - "description": "The identifier", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisoryReference", - "description": "A GitHub Security Advisory Reference", - "fields": [ - { - "name": "url", - "description": "A publicly accessible reference", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityVulnerabilityConnection", - "description": "The connection type for SecurityVulnerability.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityVulnerabilityEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityVulnerability", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityVulnerabilityEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "SecurityVulnerability", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityVulnerability", - "description": "An individual vulnerability within an Advisory", - "fields": [ - { - "name": "advisory", - "description": "The Advisory associated with this Vulnerability", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityAdvisory", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstPatchedVersion", - "description": "The first version containing a fix for the vulnerability", - "args": [], - "type": { - "kind": "OBJECT", - "name": "SecurityAdvisoryPackageVersion", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "package", - "description": "A description of the vulnerable package", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityAdvisoryPackage", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "severity", - "description": "The severity of the vulnerability within this package", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityAdvisorySeverity", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatedAt", - "description": "When the vulnerability was last updated", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vulnerableVersionRange", - "description": "A string that describes the vulnerable package versions.\nThis string follows a basic syntax with a few forms.\n+ `= 0.2.0` denotes a single vulnerable version.\n+ `<= 1.0.8` denotes a version range up to and including the specified version\n+ `< 0.1.11` denotes a version range up to, but excluding, the specified version\n+ `>= 4.3.0, < 4.3.5` denotes a version range with a known minimum and maximum version.\n+ `>= 0.0.1` denotes a version range with a known minimum, but no known maximum\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisoryPackage", - "description": "An individual package", - "fields": [ - { - "name": "ecosystem", - "description": "The ecosystem the package belongs to, e.g. RUBYGEMS, NPM", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityAdvisoryEcosystem", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The package name", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "SecurityAdvisoryEcosystem", - "description": "The possible ecosystems of a security vulnerability's package.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "RUBYGEMS", - "description": "Ruby gems hosted at RubyGems.org", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NPM", - "description": "JavaScript packages hosted at npmjs.com", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PIP", - "description": "Python packages hosted at PyPI.org", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MAVEN", - "description": "Java artifacts hosted at the Maven central repository", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NUGET", - "description": ".NET packages hosted at the NuGet Gallery", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisoryPackageVersion", - "description": "An individual package version", - "fields": [ - { - "name": "identifier", - "description": "The package name or version", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "SecurityVulnerabilityOrder", - "description": "Ordering options for security vulnerability connections", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order security vulnerabilities by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityVulnerabilityOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "SecurityVulnerabilityOrderField", - "description": "Properties by which security vulnerability connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "UPDATED_AT", - "description": "Order vulnerability by update time", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "GitSSHRemote", - "description": "Git SSH string", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TopicConnection", - "description": "The connection type for Topic.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TopicEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TopicEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ContributionsCollection", - "description": "A contributions collection aggregates contributions such as opened issues and commits created by a user.", - "fields": [ - { - "name": "commitContributionsByRepository", - "description": "Commit contributions made by the user, grouped by repository.", - "args": [ - { - "name": "maxRepositories", - "description": "How many repositories should be included.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "25" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CommitContributionsByRepository", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "contributionCalendar", - "description": "A calendar of this user's contributions on GitHub.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ContributionCalendar", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "contributionYears", - "description": "The years the user has been making contributions with the most recent year first.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "doesEndInCurrentMonth", - "description": "Determine if this collection's time span ends in the current month.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "earliestRestrictedContributionDate", - "description": "The date of the first restricted contribution the user made in this time period. Can only be non-null when the user has enabled private contribution counts.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "endedAt", - "description": "The ending date and time of this collection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstIssueContribution", - "description": "The first issue the user opened on GitHub. This will be null if that issue was opened outside the collection's time range and ignoreTimeRange is false. If the issue is not visible but the user has opted to show private contributions, a RestrictedContribution will be returned.", - "args": [ - { - "name": "ignoreTimeRange", - "description": "If true, the first issue will be returned even if it was opened outside of the collection's time range.\n\n**Upcoming Change on 2019-07-01 UTC**\n**Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back\n**Reason:** ignore_time_range will be removed\n", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "UNION", - "name": "CreatedIssueOrRestrictedContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstPullRequestContribution", - "description": "The first pull request the user opened on GitHub. This will be null if that pull request was opened outside the collection's time range and ignoreTimeRange is not true. If the pull request is not visible but the user has opted to show private contributions, a RestrictedContribution will be returned.", - "args": [ - { - "name": "ignoreTimeRange", - "description": "If true, the first pull request will be returned even if it was opened outside of the collection's time range.\n\n**Upcoming Change on 2019-07-01 UTC**\n**Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back\n**Reason:** ignore_time_range will be removed\n", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "UNION", - "name": "CreatedPullRequestOrRestrictedContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstRepositoryContribution", - "description": "The first repository the user created on GitHub. This will be null if that first repository was created outside the collection's time range and ignoreTimeRange is false. If the repository is not visible, then a RestrictedContribution is returned.", - "args": [ - { - "name": "ignoreTimeRange", - "description": "If true, the first repository will be returned even if it was opened outside of the collection's time range.\n\n**Upcoming Change on 2019-07-01 UTC**\n**Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back\n**Reason:** ignore_time_range will be removed\n", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "UNION", - "name": "CreatedRepositoryOrRestrictedContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasActivityInThePast", - "description": "Does the user have any more activity in the timeline that occurred prior to the collection's time range?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasAnyContributions", - "description": "Determine if there are any contributions in this collection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasAnyRestrictedContributions", - "description": "Determine if the user made any contributions in this time frame whose details are not visible because they were made in a private repository. Can only be true if the user enabled private contribution counts.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isSingleDay", - "description": "Whether or not the collector's time span is all within the same day.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issueContributions", - "description": "A list of issues the user opened.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "excludeFirst", - "description": "Should the user's first issue ever be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented issue be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "orderBy", - "description": "Ordering options for contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedIssueContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issueContributionsByRepository", - "description": "Issue contributions made by the user, grouped by repository.", - "args": [ - { - "name": "maxRepositories", - "description": "How many repositories should be included.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "25" - }, - { - "name": "excludeFirst", - "description": "Should the user's first issue ever be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented issue be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "IssueContributionsByRepository", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "joinedGitHubContribution", - "description": "When the user signed up for GitHub. This will be null if that sign up date falls outside the collection's time range and ignoreTimeRange is false.", - "args": [ - { - "name": "ignoreTimeRange", - "description": "If true, the contribution will be returned even if the user signed up outside of the collection's time range.\n\n**Upcoming Change on 2019-07-01 UTC**\n**Description:** `ignoreTimeRange` will be removed. Use a `ContributionsCollection` starting sufficiently far back\n**Reason:** ignore_time_range will be removed\n", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "OBJECT", - "name": "JoinedGitHubContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "latestRestrictedContributionDate", - "description": "The date of the most recent restricted contribution the user made in this time period. Can only be non-null when the user has enabled private contribution counts.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mostRecentCollectionWithActivity", - "description": "When this collection's time range does not include any activity from the user, use this\nto get a different collection from an earlier time range that does have activity.\n", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ContributionsCollection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mostRecentCollectionWithoutActivity", - "description": "Returns a different contributions collection from an earlier time range than this one\nthat does not have any contributions.\n", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ContributionsCollection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "popularIssueContribution", - "description": "The issue the user opened on GitHub that received the most comments in the specified\ntime frame.\n", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CreatedIssueContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "popularPullRequestContribution", - "description": "The pull request the user opened on GitHub that received the most comments in the\nspecified time frame.\n", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CreatedPullRequestContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestContributions", - "description": "Pull request contributions made by the user.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "excludeFirst", - "description": "Should the user's first pull request ever be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented pull request be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "orderBy", - "description": "Ordering options for contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestContributionsByRepository", - "description": "Pull request contributions made by the user, grouped by repository.", - "args": [ - { - "name": "maxRepositories", - "description": "How many repositories should be included.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "25" - }, - { - "name": "excludeFirst", - "description": "Should the user's first pull request ever be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented pull request be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestContributionsByRepository", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReviewContributions", - "description": "Pull request review contributions made by the user.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReviewContributionsByRepository", - "description": "Pull request review contributions made by the user, grouped by repository.", - "args": [ - { - "name": "maxRepositories", - "description": "How many repositories should be included.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "25" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReviewContributionsByRepository", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositoryContributions", - "description": "A list of repositories owned by the user that the user created in this time range.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "excludeFirst", - "description": "Should the user's first repository ever be excluded from the result.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "orderBy", - "description": "Ordering options for contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedRepositoryContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "restrictedContributionsCount", - "description": "A count of contributions made by the user that the viewer cannot access. Only non-zero when the user has chosen to share their private contribution counts.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "startedAt", - "description": "The beginning date and time of this collection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCommitContributions", - "description": "How many commits were made by the user in this time span.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalIssueContributions", - "description": "How many issues the user opened.", - "args": [ - { - "name": "excludeFirst", - "description": "Should the user's first issue ever be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented issue be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalPullRequestContributions", - "description": "How many pull requests the user opened.", - "args": [ - { - "name": "excludeFirst", - "description": "Should the user's first pull request ever be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented pull request be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalPullRequestReviewContributions", - "description": "How many pull request reviews the user left.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalRepositoriesWithContributedCommits", - "description": "How many different repositories the user committed to.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalRepositoriesWithContributedIssues", - "description": "How many different repositories the user opened issues in.", - "args": [ - { - "name": "excludeFirst", - "description": "Should the user's first issue ever be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented issue be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalRepositoriesWithContributedPullRequestReviews", - "description": "How many different repositories the user left pull request reviews in.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalRepositoriesWithContributedPullRequests", - "description": "How many different repositories the user opened pull requests in.", - "args": [ - { - "name": "excludeFirst", - "description": "Should the user's first pull request ever be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "excludePopular", - "description": "Should the user's most commented pull request be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalRepositoryContributions", - "description": "How many repositories the user created.", - "args": [ - { - "name": "excludeFirst", - "description": "Should the user's first repository ever be excluded from this count.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made the contributions in this collection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedIssueContributionConnection", - "description": "The connection type for CreatedIssueContribution.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedIssueContributionEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedIssueContribution", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedIssueContributionEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CreatedIssueContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedIssueContribution", - "description": "Represents the contribution a user made on GitHub by opening an issue.", - "fields": [ - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "The issue that was opened.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Contribution", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Contribution", - "description": "Represents a contribution a user made on GitHub, such as opening an issue.", - "fields": [ - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CreatedCommitContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CreatedIssueContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "CreatedRepositoryContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "JoinedGitHubContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RestrictedContribution", - "ofType": null - } - ] - }, - { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "description": "Ordering options for contribution connections.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field by which to order contributions.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ContributionOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ContributionOrderField", - "description": "Properties by which contribution connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OCCURRED_AT", - "description": "Order contributions by when they were made.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedRepositoryContributionConnection", - "description": "The connection type for CreatedRepositoryContribution.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedRepositoryContributionEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedRepositoryContribution", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedRepositoryContributionEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CreatedRepositoryContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedRepositoryContribution", - "description": "Represents the contribution a user made on GitHub by creating a repository.", - "fields": [ - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository that was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Contribution", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "JoinedGitHubContribution", - "description": "Represents a user signing up for a GitHub account.", - "fields": [ - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Contribution", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "CreatedRepositoryOrRestrictedContribution", - "description": "Represents either a repository the viewer can access or a restricted contribution.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CreatedRepositoryContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RestrictedContribution", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "RestrictedContribution", - "description": "Represents a private contribution a user made on GitHub.", - "fields": [ - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Contribution", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "CreatedIssueOrRestrictedContribution", - "description": "Represents either a issue the viewer can access or a restricted contribution.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CreatedIssueContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RestrictedContribution", - "ofType": null - } - ] - }, - { - "kind": "UNION", - "name": "CreatedPullRequestOrRestrictedContribution", - "description": "Represents either a pull request the viewer can access or a restricted contribution.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "CreatedPullRequestContribution", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "RestrictedContribution", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestContribution", - "description": "Represents the contribution a user made on GitHub by opening a pull request.", - "fields": [ - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request that was opened.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Contribution", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ContributionCalendar", - "description": "A calendar of contributions made on GitHub by a user.", - "fields": [ - { - "name": "colors", - "description": "A list of hex color codes used in this calendar. The darker the color, the more contributions it represents.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isHalloween", - "description": "Determine if the color set was chosen because it's currently Halloween.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "months", - "description": "A list of the months of contributions in this calendar.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ContributionCalendarMonth", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalContributions", - "description": "The count of total contributions in the calendar.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "weeks", - "description": "A list of the weeks of contributions in this calendar.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ContributionCalendarWeek", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ContributionCalendarWeek", - "description": "A week of contributions in a user's contribution graph.", - "fields": [ - { - "name": "contributionDays", - "description": "The days of contributions in this week.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ContributionCalendarDay", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstDay", - "description": "The date of the earliest square in this week.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ContributionCalendarDay", - "description": "Represents a single day of contributions on GitHub by a user.", - "fields": [ - { - "name": "color", - "description": "The hex color code that represents how many contributions were made on this day compared to others in the calendar.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "contributionCount", - "description": "How many contributions were made by the user on this day.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "date", - "description": "The day this square represents.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "weekday", - "description": "A number representing which day of the week this square represents, e.g., 1 is Monday.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ContributionCalendarMonth", - "description": "A month of contributions in a user's contribution graph.", - "fields": [ - { - "name": "firstDay", - "description": "The date of the first day of this month.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the month.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalWeeks", - "description": "How many weeks started in this month.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "year", - "description": "The year the month occurred in.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContributionConnection", - "description": "The connection type for CreatedPullRequestReviewContribution.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContributionEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContribution", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContributionEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContribution", - "description": "Represents the contribution a user made by leaving a review on a pull request.", - "fields": [ - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request the user reviewed.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The review the user left on the pull request.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository containing the pull request that the user reviewed.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Contribution", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestReviewContributionsByRepository", - "description": "This aggregates pull request reviews made by a user within one repository.", - "fields": [ - { - "name": "contributions", - "description": "The pull request review contributions.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestReviewContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository in which the pull request reviews were made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CommitContributionsByRepository", - "description": "This aggregates commits made by a user within one repository.", - "fields": [ - { - "name": "contributions", - "description": "The commit contributions, each representing a day.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for commit contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "CommitContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedCommitContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository in which the commits were made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for the user's commits to the repository in this time range.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for the user's commits to the repository in this time range.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedCommitContributionConnection", - "description": "The connection type for CreatedCommitContribution.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedCommitContributionEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedCommitContribution", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of commits across days and repositories in the connection.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedCommitContributionEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CreatedCommitContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedCommitContribution", - "description": "Represents the contribution a user made by committing to a repository.", - "fields": [ - { - "name": "commitCount", - "description": "How many commits were made on this day to this repository by the user.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isRestricted", - "description": "Whether this contribution is associated with a record you do not have access to. For\nexample, your own 'first issue' contribution may have been made on a repository you can no\nlonger access.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "occurredAt", - "description": "When this contribution was made.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository the user made a commit in.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resourcePath", - "description": "The HTTP path for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "url", - "description": "The HTTP URL for this contribution.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "user", - "description": "The user who made this contribution.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Contribution", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CommitContributionOrder", - "description": "Ordering options for commit contribution connections.", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field by which to order commit contributions.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "CommitContributionOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "CommitContributionOrderField", - "description": "Properties by which commit contribution connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "OCCURRED_AT", - "description": "Order commit contributions by when they were made.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "COMMIT_COUNT", - "description": "Order commit contributions by how many commits they represent.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestContributionConnection", - "description": "The connection type for CreatedPullRequestContribution.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestContributionEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestContribution", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatedPullRequestContributionEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "CreatedPullRequestContribution", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PullRequestContributionsByRepository", - "description": "This aggregates pull requests opened by a user within one repository.", - "fields": [ - { - "name": "contributions", - "description": "The pull request contributions.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedPullRequestContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository in which the pull requests were opened.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "IssueContributionsByRepository", - "description": "This aggregates issues opened by a user within one repository.", - "fields": [ - { - "name": "contributions", - "description": "The issue contributions.", - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "orderBy", - "description": "Ordering options for contributions returned from the connection.", - "type": { - "kind": "INPUT_OBJECT", - "name": "ContributionOrder", - "ofType": null - }, - "defaultValue": "{field:\"OCCURRED_AT\",direction:\"DESC\"}" - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "CreatedIssueContributionConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository in which the issues were opened.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "RepositoryContributionType", - "description": "The reason a repository is listed as 'contributed'.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "COMMIT", - "description": "Created a commit", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ISSUE", - "description": "Created an issue", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PULL_REQUEST", - "description": "Created a pull request", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REPOSITORY", - "description": "Created the repository", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PULL_REQUEST_REVIEW", - "description": "Reviewed a pull request", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PublicKeyConnection", - "description": "The connection type for PublicKey.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PublicKeyEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PublicKey", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PublicKeyEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PublicKey", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FollowingConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FollowerConnection", - "description": "The connection type for User.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "UserEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarredRepositoryConnection", - "description": "The connection type for Repository.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StarredRepositoryEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarredRepositoryEdge", - "description": "Represents a starred repository.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starredAt", - "description": "Identifies when the item was starred.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AppEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "App", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RateLimit", - "description": "Represents the client's rate limit.", - "fields": [ - { - "name": "cost", - "description": "The point cost for the current query counting against the rate limit.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "limit", - "description": "The maximum number of points the client is permitted to consume in a 60 minute window.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodeCount", - "description": "The maximum number of nodes this query may return", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "remaining", - "description": "The number of points remaining in the current rate limit window.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resetAt", - "description": "The time at which the current rate limit window resets in UTC epoch seconds.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SearchResultItemConnection", - "description": "A list of results that matched against a search query.", - "fields": [ - { - "name": "codeCount", - "description": "The number of pieces of code that matched the search query.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SearchResultItemEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issueCount", - "description": "The number of issues that matched the search query.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "UNION", - "name": "SearchResultItem", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repositoryCount", - "description": "The number of repositories that matched the search query.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "userCount", - "description": "The number of users that matched the search query.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "wikiCount", - "description": "The number of wiki pages that matched the search query.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SearchResultItemEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "UNION", - "name": "SearchResultItem", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "textMatches", - "description": "Text matches on the result found.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TextMatch", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "SearchResultItem", - "description": "The results of a search.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "MarketplaceListing", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "TextMatch", - "description": "A text match within a search result.", - "fields": [ - { - "name": "fragment", - "description": "The specific text fragment within the property matched on.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "highlights", - "description": "Highlights within the matched fragment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "TextMatchHighlight", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "property", - "description": "The property matched on.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "TextMatchHighlight", - "description": "Represents a single highlight in a search result match.", - "fields": [ - { - "name": "beginIndice", - "description": "The indice in the fragment where the matched text begins.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "endIndice", - "description": "The indice in the fragment where the matched text ends.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "text", - "description": "The text matched.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "SearchType", - "description": "Represents the individual results of a search.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "ISSUE", - "description": "Returns results matching issues in repositories.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REPOSITORY", - "description": "Returns results matching repositories.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "USER", - "description": "Returns results matching users and organizations on GitHub.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "CollectionItemContent", - "description": "Types that can be inside Collection Items.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Organization", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "GitHubMetadata", - "description": "Represents information about the GitHub instance.", - "fields": [ - { - "name": "gitHubServicesSha", - "description": "Returns a String that's a SHA of `github-services`", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gitIpAddresses", - "description": "IP addresses that users connect to for git operations", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hookIpAddresses", - "description": "IP addresses that service hooks are sent from", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "importerIpAddresses", - "description": "IP addresses that the importer connects from", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isPasswordAuthenticationVerifiable", - "description": "Whether or not users are verified", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pagesIpAddresses", - "description": "IP addresses for GitHub Pages' A records", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisoryConnection", - "description": "The connection type for SecurityAdvisory.", - "fields": [ - { - "name": "edges", - "description": "A list of edges.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityAdvisoryEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nodes", - "description": "A list of nodes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SecurityAdvisory", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "Identifies the total count of items in the connection.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SecurityAdvisoryEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "cursor", - "description": "A cursor for use in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The item at the end of the edge.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "SecurityAdvisory", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "SecurityAdvisoryOrder", - "description": "Ordering options for security advisory connections", - "fields": null, - "inputFields": [ - { - "name": "field", - "description": "The field to order security advisories by.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityAdvisoryOrderField", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "direction", - "description": "The ordering direction.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "SecurityAdvisoryOrderField", - "description": "Properties by which security advisory connections can be ordered.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "PUBLISHED_AT", - "description": "Order advisories by publication time", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UPDATED_AT", - "description": "Order advisories by update time", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "SecurityAdvisoryIdentifierFilter", - "description": "An advisory identifier to filter results on.", - "fields": null, - "inputFields": [ - { - "name": "type", - "description": "The identifier type.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SecurityAdvisoryIdentifierType", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "value", - "description": "The identifier string. Supports exact or partial matching.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "SecurityAdvisoryIdentifierType", - "description": "Identifier formats available for advisories.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "CVE", - "description": "Common Vulnerabilities and Exposures Identifier.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "GHSA", - "description": "GitHub Security Advisory ID.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Mutation", - "description": "The root query for implementing GraphQL mutations.", - "fields": [ - { - "name": "acceptTopicSuggestion", - "description": "Applies a suggested topic to the repository.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AcceptTopicSuggestionInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AcceptTopicSuggestionPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addAssigneesToAssignable", - "description": "Adds assignees to an assignable object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddAssigneesToAssignableInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddAssigneesToAssignablePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addComment", - "description": "Adds a comment to an Issue or Pull Request.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddCommentInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddCommentPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addLabelsToLabelable", - "description": "Adds labels to a labelable object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddLabelsToLabelableInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddLabelsToLabelablePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addProjectCard", - "description": "Adds a card to a ProjectColumn. Either `contentId` or `note` must be provided but **not** both.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddProjectCardInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddProjectCardPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addProjectColumn", - "description": "Adds a column to a Project.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddProjectColumnInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddProjectColumnPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addPullRequestReview", - "description": "Adds a review to a Pull Request.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddPullRequestReviewInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddPullRequestReviewPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addPullRequestReviewComment", - "description": "Adds a comment to a review.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddPullRequestReviewCommentInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddPullRequestReviewCommentPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addReaction", - "description": "Adds a reaction to a subject.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddReactionInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddReactionPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "addStar", - "description": "Adds a star to a Starrable.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "AddStarInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "AddStarPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "changeUserStatus", - "description": "Update your status on GitHub.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ChangeUserStatusInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ChangeUserStatusPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "clearLabelsFromLabelable", - "description": "Clears all labels from a labelable object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ClearLabelsFromLabelableInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ClearLabelsFromLabelablePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cloneProject", - "description": "Creates a new project by cloning configuration from an existing project.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "CloneProjectInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "CloneProjectPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closeIssue", - "description": "Close an issue.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "CloseIssueInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "CloseIssuePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "closePullRequest", - "description": "Close a pull request.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ClosePullRequestInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ClosePullRequestPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "convertProjectCardNoteToIssue", - "description": "Convert a project note card to one associated with a newly created issue.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ConvertProjectCardNoteToIssueInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ConvertProjectCardNoteToIssuePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createBranchProtectionRule", - "description": "Create a new branch protection rule", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "CreateBranchProtectionRuleInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "CreateBranchProtectionRulePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createIssue", - "description": "Creates a new issue.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "CreateIssueInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "CreateIssuePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createProject", - "description": "Creates a new project.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "CreateProjectInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "CreateProjectPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createPullRequest", - "description": "Create a new pull request", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "CreatePullRequestInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "CreatePullRequestPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "declineTopicSuggestion", - "description": "Rejects a suggested topic for the repository.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeclineTopicSuggestionInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeclineTopicSuggestionPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deleteBranchProtectionRule", - "description": "Delete a branch protection rule", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeleteBranchProtectionRuleInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeleteBranchProtectionRulePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deleteIssue", - "description": "Deletes an Issue object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeleteIssueInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeleteIssuePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deleteIssueComment", - "description": "Deletes an IssueComment object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeleteIssueCommentInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeleteIssueCommentPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deleteProject", - "description": "Deletes a project.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeleteProjectInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeleteProjectPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deleteProjectCard", - "description": "Deletes a project card.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeleteProjectCardInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeleteProjectCardPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deleteProjectColumn", - "description": "Deletes a project column.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeleteProjectColumnInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeleteProjectColumnPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletePullRequestReview", - "description": "Deletes a pull request review.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeletePullRequestReviewInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeletePullRequestReviewPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletePullRequestReviewComment", - "description": "Deletes a pull request review comment.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeletePullRequestReviewCommentInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DeletePullRequestReviewCommentPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "dismissPullRequestReview", - "description": "Dismisses an approved or rejected pull request review.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DismissPullRequestReviewInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "DismissPullRequestReviewPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lockLockable", - "description": "Lock a lockable object", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "LockLockableInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LockLockablePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mergePullRequest", - "description": "Merge a pull request.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "MergePullRequestInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "MergePullRequestPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "moveProjectCard", - "description": "Moves a project card to another place.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "MoveProjectCardInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "MoveProjectCardPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "moveProjectColumn", - "description": "Moves a project column to another place.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "MoveProjectColumnInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "MoveProjectColumnPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "removeAssigneesFromAssignable", - "description": "Removes assignees from an assignable object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "RemoveAssigneesFromAssignableInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RemoveAssigneesFromAssignablePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "removeLabelsFromLabelable", - "description": "Removes labels from a Labelable object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "RemoveLabelsFromLabelableInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RemoveLabelsFromLabelablePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "removeOutsideCollaborator", - "description": "Removes outside collaborator from all repositories in an organization.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "RemoveOutsideCollaboratorInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RemoveOutsideCollaboratorPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "removeReaction", - "description": "Removes a reaction from a subject.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "RemoveReactionInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RemoveReactionPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "removeStar", - "description": "Removes a star from a Starrable.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "RemoveStarInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RemoveStarPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reopenIssue", - "description": "Reopen a issue.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ReopenIssueInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ReopenIssuePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reopenPullRequest", - "description": "Reopen a pull request.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ReopenPullRequestInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ReopenPullRequestPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requestReviews", - "description": "Set review requests on a pull request.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "RequestReviewsInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "RequestReviewsPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "resolveReviewThread", - "description": "Marks a review thread as resolved.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ResolveReviewThreadInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "ResolveReviewThreadPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "submitPullRequestReview", - "description": "Submits a pending pull request review.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "SubmitPullRequestReviewInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "SubmitPullRequestReviewPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "unlockLockable", - "description": "Unlock a lockable object", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UnlockLockableInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UnlockLockablePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "unmarkIssueAsDuplicate", - "description": "Unmark an issue as a duplicate of another issue.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UnmarkIssueAsDuplicateInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UnmarkIssueAsDuplicatePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "unresolveReviewThread", - "description": "Marks a review thread as unresolved.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UnresolveReviewThreadInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UnresolveReviewThreadPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateBranchProtectionRule", - "description": "Create a new branch protection rule", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateBranchProtectionRuleInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateBranchProtectionRulePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateIssue", - "description": "Updates an Issue.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateIssueInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateIssuePayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateIssueComment", - "description": "Updates an IssueComment object.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateIssueCommentInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateIssueCommentPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateProject", - "description": "Updates an existing project.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateProjectInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateProjectPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateProjectCard", - "description": "Updates an existing project card.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateProjectCardInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateProjectCardPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateProjectColumn", - "description": "Updates an existing project column.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateProjectColumnInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateProjectColumnPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatePullRequest", - "description": "Update a pull request", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdatePullRequestInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdatePullRequestPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatePullRequestReview", - "description": "Updates the body of a pull request review.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdatePullRequestReviewInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdatePullRequestReviewPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updatePullRequestReviewComment", - "description": "Updates a pull request review comment.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdatePullRequestReviewCommentInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdatePullRequestReviewCommentPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateSubscription", - "description": "Updates the state for subscribable subjects.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateSubscriptionInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateSubscriptionPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updateTopics", - "description": "Replaces the repository's topics with the given topics.", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "UpdateTopicsInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UpdateTopicsPayload", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddReactionPayload", - "description": "Autogenerated return type of AddReaction", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reaction", - "description": "The reaction object.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Reaction", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "The reactable subject.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddReactionInput", - "description": "Autogenerated input type of AddReaction", - "fields": null, - "inputFields": [ - { - "name": "subjectId", - "description": "The Node ID of the subject to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "content", - "description": "The name of the emoji to react with.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RemoveReactionPayload", - "description": "Autogenerated return type of RemoveReaction", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reaction", - "description": "The reaction object.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Reaction", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "The reactable subject.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Reactable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RemoveReactionInput", - "description": "Autogenerated input type of RemoveReaction", - "fields": null, - "inputFields": [ - { - "name": "subjectId", - "description": "The Node ID of the subject to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "content", - "description": "The name of the emoji reaction to remove.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ReactionContent", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateSubscriptionPayload", - "description": "Autogenerated return type of UpdateSubscription", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscribable", - "description": "The input subscribable entity.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Subscribable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateSubscriptionInput", - "description": "Autogenerated input type of UpdateSubscription", - "fields": null, - "inputFields": [ - { - "name": "subscribableId", - "description": "The Node ID of the subscribable object to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "state", - "description": "The new state of the subscription.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "SubscriptionState", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddCommentPayload", - "description": "Autogenerated return type of AddComment", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commentEdge", - "description": "The edge from the subject's comment connection.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "IssueCommentEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subject", - "description": "The subject", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "timelineEdge", - "description": "The edge from the subject's timeline connection.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "IssueTimelineItemEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddCommentInput", - "description": "Autogenerated input type of AddComment", - "fields": null, - "inputFields": [ - { - "name": "subjectId", - "description": "The Node ID of the subject to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The contents of the comment.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "MinimizeCommentInput", - "description": "Autogenerated input type of MinimizeComment", - "fields": null, - "inputFields": [ - { - "name": "subjectId", - "description": "The Node ID of the subject to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "classifier", - "description": "The classification of comment", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "ReportedContentClassifiers", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "ReportedContentClassifiers", - "description": "The reasons a piece of content can be reported or minimized.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SPAM", - "description": "A spammy piece of content", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ABUSE", - "description": "An abusive or harassing piece of content", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OFF_TOPIC", - "description": "An irrelevant piece of content", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OUTDATED", - "description": "An outdated piece of content", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "RESOLVED", - "description": "The content has been resolved", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UnminimizeCommentInput", - "description": "Autogenerated input type of UnminimizeComment", - "fields": null, - "inputFields": [ - { - "name": "subjectId", - "description": "The Node ID of the subject to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateIssueCommentPayload", - "description": "Autogenerated return type of UpdateIssueComment", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issueComment", - "description": "The updated comment.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "IssueComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateIssueCommentInput", - "description": "Autogenerated input type of UpdateIssueComment", - "fields": null, - "inputFields": [ - { - "name": "id", - "description": "The ID of the IssueComment to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The updated text of the comment.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreateProjectPayload", - "description": "Autogenerated return type of CreateProject", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "The new project.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CreateProjectInput", - "description": "Autogenerated input type of CreateProject", - "fields": null, - "inputFields": [ - { - "name": "ownerId", - "description": "The owner ID to create the project under.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of project.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The description of project.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateProjectPayload", - "description": "Autogenerated return type of UpdateProject", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "The updated project.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateProjectInput", - "description": "Autogenerated input type of UpdateProject", - "fields": null, - "inputFields": [ - { - "name": "projectId", - "description": "The Project ID to update.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of project.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The description of project.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "state", - "description": "Whether the project is open or closed.", - "type": { - "kind": "ENUM", - "name": "ProjectState", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "public", - "description": "Whether the project is public or not.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeleteProjectPayload", - "description": "Autogenerated return type of DeleteProject", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "owner", - "description": "The repository or organization the project was removed from.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "ProjectOwner", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeleteProjectInput", - "description": "Autogenerated input type of DeleteProject", - "fields": null, - "inputFields": [ - { - "name": "projectId", - "description": "The Project ID to update.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CloneProjectPayload", - "description": "Autogenerated return type of CloneProject", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "jobStatusId", - "description": "The id of the JobStatus for populating cloned fields.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "The new cloned project.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CloneProjectInput", - "description": "Autogenerated input type of CloneProject", - "fields": null, - "inputFields": [ - { - "name": "targetOwnerId", - "description": "The owner ID to create the project under.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "sourceId", - "description": "The source project to clone.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "includeWorkflows", - "description": "Whether or not to clone the source project's workflows.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of the project.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The description of the project.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "public", - "description": "The visibility of the project, defaults to false (private).", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ImportProjectInput", - "description": "Autogenerated input type of ImportProject", - "fields": null, - "inputFields": [ - { - "name": "ownerName", - "description": "The name of the Organization or User to create the Project under.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of Project.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The description of Project.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "public", - "description": "Whether the Project is public or not.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "columnImports", - "description": "A list of columns containing issues and pull requests.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ProjectColumnImport", - "ofType": null - } - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ProjectColumnImport", - "description": "A project column and a list of its issues and PRs.", - "fields": null, - "inputFields": [ - { - "name": "columnName", - "description": "The name of the column.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "position", - "description": "The position of the column, starting from 0.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "issues", - "description": "A list of issues and pull requests in the column.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ProjectCardImport", - "ofType": null - } - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ProjectCardImport", - "description": "An issue or PR and its owning repository to be used in a project card.", - "fields": null, - "inputFields": [ - { - "name": "repository", - "description": "Repository name with owner (owner/repository).", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "number", - "description": "The issue or pull request number.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddProjectColumnPayload", - "description": "Autogenerated return type of AddProjectColumn", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "columnEdge", - "description": "The edge from the project's column connection.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectColumnEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "The project", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddProjectColumnInput", - "description": "Autogenerated input type of AddProjectColumn", - "fields": null, - "inputFields": [ - { - "name": "projectId", - "description": "The Node ID of the project.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of the column.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MoveProjectColumnPayload", - "description": "Autogenerated return type of MoveProjectColumn", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "columnEdge", - "description": "The new edge of the moved column.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectColumnEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "MoveProjectColumnInput", - "description": "Autogenerated input type of MoveProjectColumn", - "fields": null, - "inputFields": [ - { - "name": "columnId", - "description": "The id of the column to move.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "afterColumnId", - "description": "Place the new column after the column with this id. Pass null to place it at the front.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateProjectColumnPayload", - "description": "Autogenerated return type of UpdateProjectColumn", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectColumn", - "description": "The updated project column.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectColumn", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateProjectColumnInput", - "description": "Autogenerated input type of UpdateProjectColumn", - "fields": null, - "inputFields": [ - { - "name": "projectColumnId", - "description": "The ProjectColumn ID to update.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of project column.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeleteProjectColumnPayload", - "description": "Autogenerated return type of DeleteProjectColumn", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletedColumnId", - "description": "The deleted column ID.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "project", - "description": "The project the deleted column was in.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Project", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeleteProjectColumnInput", - "description": "Autogenerated input type of DeleteProjectColumn", - "fields": null, - "inputFields": [ - { - "name": "columnId", - "description": "The id of the column to delete.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddProjectCardPayload", - "description": "Autogenerated return type of AddProjectCard", - "fields": [ - { - "name": "cardEdge", - "description": "The edge from the ProjectColumn's card connection.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectCardEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectColumn", - "description": "The ProjectColumn", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectColumn", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddProjectCardInput", - "description": "Autogenerated input type of AddProjectCard", - "fields": null, - "inputFields": [ - { - "name": "projectColumnId", - "description": "The Node ID of the ProjectColumn.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "contentId", - "description": "The content of the card. Must be a member of the ProjectCardItem union", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "note", - "description": "The note on the card.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateProjectCardPayload", - "description": "Autogenerated return type of UpdateProjectCard", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectCard", - "description": "The updated ProjectCard.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectCard", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateProjectCardInput", - "description": "Autogenerated input type of UpdateProjectCard", - "fields": null, - "inputFields": [ - { - "name": "projectCardId", - "description": "The ProjectCard ID to update.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "isArchived", - "description": "Whether or not the ProjectCard should be archived", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "note", - "description": "The note of ProjectCard.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MoveProjectCardPayload", - "description": "Autogenerated return type of MoveProjectCard", - "fields": [ - { - "name": "cardEdge", - "description": "The new edge of the moved card.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectCardEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "MoveProjectCardInput", - "description": "Autogenerated input type of MoveProjectCard", - "fields": null, - "inputFields": [ - { - "name": "cardId", - "description": "The id of the card to move.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "columnId", - "description": "The id of the column to move it into.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "afterCardId", - "description": "Place the new card after the card with this id. Pass null to place it at the top.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeleteProjectCardPayload", - "description": "Autogenerated return type of DeleteProjectCard", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "column", - "description": "The column the deleted card was in.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectColumn", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deletedCardId", - "description": "The deleted card ID.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeleteProjectCardInput", - "description": "Autogenerated input type of DeleteProjectCard", - "fields": null, - "inputFields": [ - { - "name": "cardId", - "description": "The id of the card to delete.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ConvertProjectCardNoteToIssuePayload", - "description": "Autogenerated return type of ConvertProjectCardNoteToIssue", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "projectCard", - "description": "The updated ProjectCard.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "ProjectCard", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ConvertProjectCardNoteToIssueInput", - "description": "Autogenerated input type of ConvertProjectCardNoteToIssue", - "fields": null, - "inputFields": [ - { - "name": "projectCardId", - "description": "The ProjectCard ID to convert.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "repositoryId", - "description": "The ID of the repository to create the issue in.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "title", - "description": "The title of the newly created issue. Defaults to the card's note text.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The body of the newly created issue.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnmarkIssueAsDuplicatePayload", - "description": "Autogenerated return type of UnmarkIssueAsDuplicate", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "duplicate", - "description": "The issue or pull request that was marked as a duplicate.", - "args": [], - "type": { - "kind": "UNION", - "name": "IssueOrPullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UnmarkIssueAsDuplicateInput", - "description": "Autogenerated input type of UnmarkIssueAsDuplicate", - "fields": null, - "inputFields": [ - { - "name": "duplicateId", - "description": "ID of the issue or pull request currently marked as a duplicate.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "canonicalId", - "description": "ID of the issue or pull request currently considered canonical/authoritative/original.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "LockLockablePayload", - "description": "Autogenerated return type of LockLockable", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "lockedRecord", - "description": "The item that was locked.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Lockable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "LockLockableInput", - "description": "Autogenerated input type of LockLockable", - "fields": null, - "inputFields": [ - { - "name": "lockableId", - "description": "ID of the issue or pull request to be locked.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "lockReason", - "description": "A reason for why the issue or pull request will be locked.", - "type": { - "kind": "ENUM", - "name": "LockReason", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnlockLockablePayload", - "description": "Autogenerated return type of UnlockLockable", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "unlockedRecord", - "description": "The item that was unlocked.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Lockable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UnlockLockableInput", - "description": "Autogenerated input type of UnlockLockable", - "fields": null, - "inputFields": [ - { - "name": "lockableId", - "description": "ID of the issue or pull request to be unlocked.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddAssigneesToAssignablePayload", - "description": "Autogenerated return type of AddAssigneesToAssignable", - "fields": [ - { - "name": "assignable", - "description": "The item that was assigned.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Assignable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddAssigneesToAssignableInput", - "description": "Autogenerated input type of AddAssigneesToAssignable", - "fields": null, - "inputFields": [ - { - "name": "assignableId", - "description": "The id of the assignable object to add assignees to.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "assigneeIds", - "description": "The id of users to add as assignees.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RemoveAssigneesFromAssignablePayload", - "description": "Autogenerated return type of RemoveAssigneesFromAssignable", - "fields": [ - { - "name": "assignable", - "description": "The item that was unassigned.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Assignable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RemoveAssigneesFromAssignableInput", - "description": "Autogenerated input type of RemoveAssigneesFromAssignable", - "fields": null, - "inputFields": [ - { - "name": "assignableId", - "description": "The id of the assignable object to remove assignees from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "assigneeIds", - "description": "The id of users to remove as assignees.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddLabelsToLabelablePayload", - "description": "Autogenerated return type of AddLabelsToLabelable", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labelable", - "description": "The item that was labeled.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Labelable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddLabelsToLabelableInput", - "description": "Autogenerated input type of AddLabelsToLabelable", - "fields": null, - "inputFields": [ - { - "name": "labelableId", - "description": "The id of the labelable object to add labels to.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "labelIds", - "description": "The ids of the labels to add.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreateIssuePayload", - "description": "Autogenerated return type of CreateIssue", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "The new issue.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CreateIssueInput", - "description": "Autogenerated input type of CreateIssue", - "fields": null, - "inputFields": [ - { - "name": "repositoryId", - "description": "The Node ID of the repository.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "title", - "description": "The title for the issue.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The body for the issue description.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "assigneeIds", - "description": "The Node ID for the user assignee for this issue.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "milestoneId", - "description": "The Node ID of the milestone for this issue.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "labelIds", - "description": "An array of Node IDs of labels for this issue.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "projectIds", - "description": "An array of Node IDs for projects associated with this issue.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ClearLabelsFromLabelablePayload", - "description": "Autogenerated return type of ClearLabelsFromLabelable", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labelable", - "description": "The item that was unlabeled.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Labelable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ClearLabelsFromLabelableInput", - "description": "Autogenerated input type of ClearLabelsFromLabelable", - "fields": null, - "inputFields": [ - { - "name": "labelableId", - "description": "The id of the labelable object to clear the labels from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RemoveLabelsFromLabelablePayload", - "description": "Autogenerated return type of RemoveLabelsFromLabelable", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "labelable", - "description": "The Labelable the labels were removed from.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Labelable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RemoveLabelsFromLabelableInput", - "description": "Autogenerated input type of RemoveLabelsFromLabelable", - "fields": null, - "inputFields": [ - { - "name": "labelableId", - "description": "The id of the Labelable to remove labels from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "labelIds", - "description": "The ids of labels to remove.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CloseIssuePayload", - "description": "Autogenerated return type of CloseIssue", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "The issue that was closed.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CloseIssueInput", - "description": "Autogenerated input type of CloseIssue", - "fields": null, - "inputFields": [ - { - "name": "issueId", - "description": "ID of the issue to be closed.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReopenIssuePayload", - "description": "Autogenerated return type of ReopenIssue", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "The issue that was opened.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReopenIssueInput", - "description": "Autogenerated input type of ReopenIssue", - "fields": null, - "inputFields": [ - { - "name": "issueId", - "description": "ID of the issue to be opened.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeleteIssueCommentPayload", - "description": "Autogenerated return type of DeleteIssueComment", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeleteIssueCommentInput", - "description": "Autogenerated input type of DeleteIssueComment", - "fields": null, - "inputFields": [ - { - "name": "id", - "description": "The ID of the comment to delete.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateIssuePayload", - "description": "Autogenerated return type of UpdateIssue", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "issue", - "description": "The issue.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Issue", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateIssueInput", - "description": "Autogenerated input type of UpdateIssue", - "fields": null, - "inputFields": [ - { - "name": "id", - "description": "The ID of the Issue to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "title", - "description": "The title for the issue.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The body for the issue description.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "assigneeIds", - "description": "An array of Node IDs of users for this issue.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "milestoneId", - "description": "The Node ID of the milestone for this issue.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "labelIds", - "description": "An array of Node IDs of labels for this issue.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "state", - "description": "The desired issue state.", - "type": { - "kind": "ENUM", - "name": "IssueState", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "projectIds", - "description": "An array of Node IDs for projects associated with this issue.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeleteIssuePayload", - "description": "Autogenerated return type of DeleteIssue", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The repository the issue belonged to", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeleteIssueInput", - "description": "Autogenerated input type of DeleteIssue", - "fields": null, - "inputFields": [ - { - "name": "issueId", - "description": "The ID of the issue to delete.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "PinIssueInput", - "description": "Autogenerated input type of PinIssue", - "fields": null, - "inputFields": [ - { - "name": "issueId", - "description": "The ID of the issue to be pinned", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UnpinIssueInput", - "description": "Autogenerated input type of UnpinIssue", - "fields": null, - "inputFields": [ - { - "name": "issueId", - "description": "The ID of the issue to be unpinned", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreatePullRequestPayload", - "description": "Autogenerated return type of CreatePullRequest", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The new pull request.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CreatePullRequestInput", - "description": "Autogenerated input type of CreatePullRequest", - "fields": null, - "inputFields": [ - { - "name": "repositoryId", - "description": "The Node ID of the repository.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "baseRefName", - "description": "The name of the branch you want your changes pulled into. This should be an existing branch\non the current repository. You cannot update the base branch on a pull request to point\nto another repository.\n", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "headRefName", - "description": "The name of the branch where your changes are implemented. For cross-repository pull requests\nin the same network, namespace `head_ref_name` with a user like this: `username:branch`.\n", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "title", - "description": "The title of the pull request.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The contents of the pull request.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "maintainerCanModify", - "description": "Indicates whether maintainers can modify the pull request.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "true" - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdatePullRequestPayload", - "description": "Autogenerated return type of UpdatePullRequest", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The updated pull request.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdatePullRequestInput", - "description": "Autogenerated input type of UpdatePullRequest", - "fields": null, - "inputFields": [ - { - "name": "pullRequestId", - "description": "The Node ID of the pull request.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "baseRefName", - "description": "The name of the branch you want your changes pulled into. This should be an existing branch\non the current repository.\n", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "title", - "description": "The title of the pull request.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The contents of the pull request.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "maintainerCanModify", - "description": "Indicates whether maintainers can modify the pull request.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ClosePullRequestPayload", - "description": "Autogenerated return type of ClosePullRequest", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request that was closed.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ClosePullRequestInput", - "description": "Autogenerated input type of ClosePullRequest", - "fields": null, - "inputFields": [ - { - "name": "pullRequestId", - "description": "ID of the pull request to be closed.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ReopenPullRequestPayload", - "description": "Autogenerated return type of ReopenPullRequest", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request that was reopened.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReopenPullRequestInput", - "description": "Autogenerated input type of ReopenPullRequest", - "fields": null, - "inputFields": [ - { - "name": "pullRequestId", - "description": "ID of the pull request to be reopened.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "MergePullRequestPayload", - "description": "Autogenerated return type of MergePullRequest", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request that was merged.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "MergePullRequestInput", - "description": "Autogenerated input type of MergePullRequest", - "fields": null, - "inputFields": [ - { - "name": "pullRequestId", - "description": "ID of the pull request to be merged.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "commitHeadline", - "description": "Commit headline to use for the merge commit; if omitted, a default message will be used.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "commitBody", - "description": "Commit body to use for the merge commit; if omitted, a default message will be used", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "expectedHeadOid", - "description": "OID that the pull request head ref must match to allow merge; if omitted, no check is performed.", - "type": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeletePullRequestReviewCommentPayload", - "description": "Autogenerated return type of DeletePullRequestReviewComment", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The pull request review the deleted comment belonged to.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeletePullRequestReviewCommentInput", - "description": "Autogenerated input type of DeletePullRequestReviewComment", - "fields": null, - "inputFields": [ - { - "name": "id", - "description": "The ID of the comment to delete.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddPullRequestReviewPayload", - "description": "Autogenerated return type of AddPullRequestReview", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The newly created pull request review.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reviewEdge", - "description": "The edge from the pull request's review connection.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddPullRequestReviewInput", - "description": "Autogenerated input type of AddPullRequestReview", - "fields": null, - "inputFields": [ - { - "name": "pullRequestId", - "description": "The Node ID of the pull request to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "commitOID", - "description": "The commit OID the review pertains to.", - "type": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The contents of the review body comment.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "event", - "description": "The event to perform on the pull request review.", - "type": { - "kind": "ENUM", - "name": "PullRequestReviewEvent", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "comments", - "description": "The review line comments.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "DraftPullRequestReviewComment", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "PullRequestReviewEvent", - "description": "The possible events to perform on a pull request review.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "COMMENT", - "description": "Submit general feedback without explicit approval.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "APPROVE", - "description": "Submit feedback and approve merging these changes.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "REQUEST_CHANGES", - "description": "Submit feedback that must be addressed before merging.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DISMISS", - "description": "Dismiss review so it now longer effects merging.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DraftPullRequestReviewComment", - "description": "Specifies a review comment to be left with a Pull Request Review.", - "fields": null, - "inputFields": [ - { - "name": "path", - "description": "Path to the file being commented on.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "position", - "description": "Position in the file to leave a comment on.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "Body of the comment to leave.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SubmitPullRequestReviewPayload", - "description": "Autogenerated return type of SubmitPullRequestReview", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The submitted pull request review.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "SubmitPullRequestReviewInput", - "description": "Autogenerated input type of SubmitPullRequestReview", - "fields": null, - "inputFields": [ - { - "name": "pullRequestReviewId", - "description": "The Pull Request Review ID to submit.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "event", - "description": "The event to send to the Pull Request Review.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PullRequestReviewEvent", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The text field to set on the Pull Request Review.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdatePullRequestReviewPayload", - "description": "Autogenerated return type of UpdatePullRequestReview", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The updated pull request review.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdatePullRequestReviewInput", - "description": "Autogenerated input type of UpdatePullRequestReview", - "fields": null, - "inputFields": [ - { - "name": "pullRequestReviewId", - "description": "The Node ID of the pull request review to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The contents of the pull request review body.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DismissPullRequestReviewPayload", - "description": "Autogenerated return type of DismissPullRequestReview", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The dismissed pull request review.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DismissPullRequestReviewInput", - "description": "Autogenerated input type of DismissPullRequestReview", - "fields": null, - "inputFields": [ - { - "name": "pullRequestReviewId", - "description": "The Node ID of the pull request review to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "message", - "description": "The contents of the pull request review dismissal message.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeletePullRequestReviewPayload", - "description": "Autogenerated return type of DeletePullRequestReview", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReview", - "description": "The deleted pull request review.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReview", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeletePullRequestReviewInput", - "description": "Autogenerated input type of DeletePullRequestReview", - "fields": null, - "inputFields": [ - { - "name": "pullRequestReviewId", - "description": "The Node ID of the pull request review to delete.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ResolveReviewThreadPayload", - "description": "Autogenerated return type of ResolveReviewThread", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "thread", - "description": "The thread to resolve.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ResolveReviewThreadInput", - "description": "Autogenerated input type of ResolveReviewThread", - "fields": null, - "inputFields": [ - { - "name": "threadId", - "description": "The ID of the thread to resolve", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnresolveReviewThreadPayload", - "description": "Autogenerated return type of UnresolveReviewThread", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "thread", - "description": "The thread to resolve.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewThread", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UnresolveReviewThreadInput", - "description": "Autogenerated input type of UnresolveReviewThread", - "fields": null, - "inputFields": [ - { - "name": "threadId", - "description": "The ID of the thread to unresolve", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddPullRequestReviewCommentPayload", - "description": "Autogenerated return type of AddPullRequestReviewComment", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "comment", - "description": "The newly created comment.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commentEdge", - "description": "The edge from the review's comment connection.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewCommentEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddPullRequestReviewCommentInput", - "description": "Autogenerated input type of AddPullRequestReviewComment", - "fields": null, - "inputFields": [ - { - "name": "pullRequestReviewId", - "description": "The Node ID of the review to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "commitOID", - "description": "The SHA of the commit to comment on.", - "type": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The text of the comment.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "path", - "description": "The relative path of the file to comment on.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "position", - "description": "The line index in the diff to comment on.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "inReplyTo", - "description": "The comment id to reply to.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdatePullRequestReviewCommentPayload", - "description": "Autogenerated return type of UpdatePullRequestReviewComment", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequestReviewComment", - "description": "The updated comment.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequestReviewComment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdatePullRequestReviewCommentInput", - "description": "Autogenerated input type of UpdatePullRequestReviewComment", - "fields": null, - "inputFields": [ - { - "name": "pullRequestReviewCommentId", - "description": "The Node ID of the comment to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The text of the comment.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RemoveOutsideCollaboratorPayload", - "description": "Autogenerated return type of RemoveOutsideCollaborator", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "removedUser", - "description": "The user that was removed as an outside collaborator.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RemoveOutsideCollaboratorInput", - "description": "Autogenerated input type of RemoveOutsideCollaborator", - "fields": null, - "inputFields": [ - { - "name": "userId", - "description": "The ID of the outside collaborator to remove.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "organizationId", - "description": "The ID of the organization to remove the outside collaborator from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RequestReviewsPayload", - "description": "Autogenerated return type of RequestReviews", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pullRequest", - "description": "The pull request that is getting requests.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "PullRequest", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "requestedReviewersEdge", - "description": "The edge from the pull request to the requested reviewers.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "UserEdge", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RequestReviewsInput", - "description": "Autogenerated input type of RequestReviews", - "fields": null, - "inputFields": [ - { - "name": "pullRequestId", - "description": "The Node ID of the pull request to modify.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "userIds", - "description": "The Node IDs of the user to request.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "teamIds", - "description": "The Node IDs of the team to request.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "union", - "description": "Add users to the set rather than replace.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AddStarPayload", - "description": "Autogenerated return type of AddStar", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starrable", - "description": "The starrable.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Starrable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AddStarInput", - "description": "Autogenerated input type of AddStar", - "fields": null, - "inputFields": [ - { - "name": "starrableId", - "description": "The Starrable ID to star.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "RemoveStarPayload", - "description": "Autogenerated return type of RemoveStar", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starrable", - "description": "The starrable.", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Starrable", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "RemoveStarInput", - "description": "Autogenerated input type of RemoveStar", - "fields": null, - "inputFields": [ - { - "name": "starrableId", - "description": "The Starrable ID to unstar.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "AcceptTopicSuggestionPayload", - "description": "Autogenerated return type of AcceptTopicSuggestion", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "topic", - "description": "The accepted topic.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "AcceptTopicSuggestionInput", - "description": "Autogenerated input type of AcceptTopicSuggestion", - "fields": null, - "inputFields": [ - { - "name": "repositoryId", - "description": "The Node ID of the repository.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of the suggested topic.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeclineTopicSuggestionPayload", - "description": "Autogenerated return type of DeclineTopicSuggestion", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "topic", - "description": "The declined topic.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Topic", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeclineTopicSuggestionInput", - "description": "Autogenerated input type of DeclineTopicSuggestion", - "fields": null, - "inputFields": [ - { - "name": "repositoryId", - "description": "The Node ID of the repository.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "name", - "description": "The name of the suggested topic.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "reason", - "description": "The reason why the suggested topic is declined.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "TopicSuggestionDeclineReason", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "TopicSuggestionDeclineReason", - "description": "Reason that the suggested topic is declined.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "NOT_RELEVANT", - "description": "The suggested topic is not relevant to the repository.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TOO_SPECIFIC", - "description": "The suggested topic is too specific for the repository (e.g. #ruby-on-rails-version-4-2-1).", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "PERSONAL_PREFERENCE", - "description": "The viewer does not like the suggested topic.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TOO_GENERAL", - "description": "The suggested topic is too general for the repository.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateTopicsPayload", - "description": "Autogenerated return type of UpdateTopics", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "invalidTopicNames", - "description": "Names of the provided topics that are not valid.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The updated repository.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateTopicsInput", - "description": "Autogenerated input type of UpdateTopics", - "fields": null, - "inputFields": [ - { - "name": "repositoryId", - "description": "The Node ID of the repository.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "topicNames", - "description": "An array of topic names.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "CreateBranchProtectionRulePayload", - "description": "Autogenerated return type of CreateBranchProtectionRule", - "fields": [ - { - "name": "branchProtectionRule", - "description": "The newly created BranchProtectionRule.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CreateBranchProtectionRuleInput", - "description": "Autogenerated input type of CreateBranchProtectionRule", - "fields": null, - "inputFields": [ - { - "name": "repositoryId", - "description": "The global relay id of the repository in which a new branch protection rule should be created in.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "pattern", - "description": "The glob-like pattern used to determine matching branches.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "requiresApprovingReviews", - "description": "Are approving reviews required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiredApprovingReviewCount", - "description": "Number of approving reviews required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresCommitSignatures", - "description": "Are commits required to be signed.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "isAdminEnforced", - "description": "Can admins overwrite branch protection.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresStatusChecks", - "description": "Are status checks required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresStrictStatusChecks", - "description": "Are branches required to be up to date before merging.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresCodeOwnerReviews", - "description": "Are reviews from code owners required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "dismissesStaleReviews", - "description": "Will new commits pushed to matching branches dismiss pull request review approvals.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "restrictsReviewDismissals", - "description": "Is dismissal of pull request reviews restricted.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "reviewDismissalActorIds", - "description": "A list of User or Team IDs allowed to dismiss reviews on pull requests targeting matching branches.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "restrictsPushes", - "description": "Is pushing to matching branches restricted.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "pushActorIds", - "description": "A list of User or Team IDs allowed to push to matching branches.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "requiredStatusCheckContexts", - "description": "List of required status check contexts that must pass for commits to be accepted to matching branches.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UpdateBranchProtectionRulePayload", - "description": "Autogenerated return type of UpdateBranchProtectionRule", - "fields": [ - { - "name": "branchProtectionRule", - "description": "The newly created BranchProtectionRule.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "BranchProtectionRule", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "UpdateBranchProtectionRuleInput", - "description": "Autogenerated input type of UpdateBranchProtectionRule", - "fields": null, - "inputFields": [ - { - "name": "branchProtectionRuleId", - "description": "The global relay id of the branch protection rule to be updated.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "pattern", - "description": "The glob-like pattern used to determine matching branches.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresApprovingReviews", - "description": "Are approving reviews required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiredApprovingReviewCount", - "description": "Number of approving reviews required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresCommitSignatures", - "description": "Are commits required to be signed.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "isAdminEnforced", - "description": "Can admins overwrite branch protection.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresStatusChecks", - "description": "Are status checks required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresStrictStatusChecks", - "description": "Are branches required to be up to date before merging.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "requiresCodeOwnerReviews", - "description": "Are reviews from code owners required to update matching branches.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "dismissesStaleReviews", - "description": "Will new commits pushed to matching branches dismiss pull request review approvals.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "restrictsReviewDismissals", - "description": "Is dismissal of pull request reviews restricted.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "reviewDismissalActorIds", - "description": "A list of User or Team IDs allowed to dismiss reviews on pull requests targeting matching branches.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "restrictsPushes", - "description": "Is pushing to matching branches restricted.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "pushActorIds", - "description": "A list of User or Team IDs allowed to push to matching branches.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "requiredStatusCheckContexts", - "description": "List of required status check contexts that must pass for commits to be accepted to matching branches.", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DeleteBranchProtectionRulePayload", - "description": "Autogenerated return type of DeleteBranchProtectionRule", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "DeleteBranchProtectionRuleInput", - "description": "Autogenerated input type of DeleteBranchProtectionRule", - "fields": null, - "inputFields": [ - { - "name": "branchProtectionRuleId", - "description": "The global relay id of the branch protection rule to be deleted.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ChangeUserStatusPayload", - "description": "Autogenerated return type of ChangeUserStatus", - "fields": [ - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "status", - "description": "Your updated status.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "UserStatus", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ChangeUserStatusInput", - "description": "Autogenerated input type of ChangeUserStatus", - "fields": null, - "inputFields": [ - { - "name": "emoji", - "description": "The emoji to represent your status. Can either be a native Unicode emoji or an emoji name with colons, e.g., :grinning:.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "message", - "description": "A short description of your current status.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "organizationId", - "description": "The ID of the organization whose members will be allowed to see the status. If omitted, the status will be publicly visible.", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "limitedAvailability", - "description": "Whether this status should indicate you are not fully available on GitHub, e.g., you are away.", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ContentAttachment", - "description": "A content attachment", - "fields": [ - { - "name": "body", - "description": "The body text of the content attachment. This parameter supports markdown.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "contentReference", - "description": "The content reference that the content attachment is attached to.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "ContentReference", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "title", - "description": "The title of the content attachment.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ContentReference", - "description": "A content reference", - "fields": [ - { - "name": "databaseId", - "description": "Identifies the primary key from the database.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reference", - "description": "The reference of the content reference.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "CreateContentAttachmentInput", - "description": "Autogenerated input type of CreateContentAttachment", - "fields": null, - "inputFields": [ - { - "name": "contentReferenceId", - "description": "The node ID of the content_reference.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "title", - "description": "The title of the content attachment.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "body", - "description": "The body of the content attachment, which may contain markdown.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "clientMutationId", - "description": "A unique identifier for the client performing the mutation.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Schema", - "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", - "fields": [ - { - "name": "directives", - "description": "A list of all directives supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Directive", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mutationType", - "description": "If this server supports mutation, the type that mutation operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "queryType", - "description": "The type that query operations will be rooted at.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscriptionType", - "description": "If this server support subscription, the type that subscription operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "types", - "description": "A list of all types supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Type", - "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", - "fields": [ - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "enumValues", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__EnumValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fields", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Field", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inputFields", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "interfaces", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "kind", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__TypeKind", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ofType", - "description": null, - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "possibleTypes", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Field", - "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", - "fields": [ - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Directive", - "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", - "fields": [ - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locations", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__DirectiveLocation", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onField", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onFragment", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onOperation", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__EnumValue", - "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", - "fields": [ - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__InputValue", - "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", - "fields": [ - { - "name": "defaultValue", - "description": "A GraphQL-formatted string representing the default value for this input value.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__TypeKind", - "description": "An enum describing what kind of type a given `__Type` is.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SCALAR", - "description": "Indicates this type is a scalar.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Indicates this type is a union. `possibleTypes` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Indicates this type is an enum. `enumValues` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Indicates this type is an input object. `inputFields` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LIST", - "description": "Indicates this type is a list. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NON_NULL", - "description": "Indicates this type is a non-null. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__DirectiveLocation", - "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "QUERY", - "description": "Location adjacent to a query operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MUTATION", - "description": "Location adjacent to a mutation operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIPTION", - "description": "Location adjacent to a subscription operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD", - "description": "Location adjacent to a field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_DEFINITION", - "description": "Location adjacent to a fragment definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_SPREAD", - "description": "Location adjacent to a fragment spread.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INLINE_FRAGMENT", - "description": "Location adjacent to an inline fragment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCHEMA", - "description": "Location adjacent to a schema definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCALAR", - "description": "Location adjacent to a scalar definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Location adjacent to an object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD_DEFINITION", - "description": "Location adjacent to a field definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ARGUMENT_DEFINITION", - "description": "Location adjacent to an argument definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Location adjacent to an interface definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Location adjacent to a union definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Location adjacent to an enum definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM_VALUE", - "description": "Location adjacent to an enum value definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Location adjacent to an input object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_FIELD_DEFINITION", - "description": "Location adjacent to an input object field definition.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "GpgSignature", - "description": "Represents a GPG signature on a Commit or Tag.", - "fields": [ - { - "name": "email", - "description": "Email used to sign this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isValid", - "description": "True if the signature is valid and verified by GitHub.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "keyId", - "description": "Hex-encoded ID of the key that signed this object.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "payload", - "description": "Payload for GPG signing object. Raw ODB object without the signature header.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signature", - "description": "ASCII-armored signature header from object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signer", - "description": "GitHub user corresponding to the email signing this commit.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "GitSignatureState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "wasSignedByGitHub", - "description": "True if the signature was made with GitHub's signing key.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "GitSignature", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SmimeSignature", - "description": "Represents an S/MIME signature on a Commit or Tag.", - "fields": [ - { - "name": "email", - "description": "Email used to sign this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isValid", - "description": "True if the signature is valid and verified by GitHub.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "payload", - "description": "Payload for GPG signing object. Raw ODB object without the signature header.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signature", - "description": "ASCII-armored signature header from object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signer", - "description": "GitHub user corresponding to the email signing this commit.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "GitSignatureState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "wasSignedByGitHub", - "description": "True if the signature was made with GitHub's signing key.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "GitSignature", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Tag", - "description": "Represents a Git tag.", - "fields": [ - { - "name": "abbreviatedOid", - "description": "An abbreviated version of the Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitResourcePath", - "description": "The HTTP path for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commitUrl", - "description": "The HTTP URL for this Git object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URI", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "message", - "description": "The Git tag message.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The Git tag name.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "oid", - "description": "The Git object ID", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "GitObjectID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repository", - "description": "The Repository the Git object belongs to", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "tagger", - "description": "Details about the tag author.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "GitActor", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "target", - "description": "The Git object the tag points to.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "GitObject", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "UnknownSignature", - "description": "Represents an unknown signature on a Commit or Tag.", - "fields": [ - { - "name": "email", - "description": "Email used to sign this object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isValid", - "description": "True if the signature is valid and verified by GitHub.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "payload", - "description": "Payload for GPG signing object. Raw ODB object without the signature header.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signature", - "description": "ASCII-armored signature header from object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "signer", - "description": "GitHub user corresponding to the email signing this commit.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "state", - "description": "The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "GitSignatureState", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "wasSignedByGitHub", - "description": "True if the signature was made with GitHub's signing key.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "GitSignature", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - } - ], - "directives": [ - { - "name": "include", - "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", - "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], - "args": [ - { - "name": "if", - "description": "Included when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "skip", - "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", - "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], - "args": [ - { - "name": "if", - "description": "Skipped when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "deprecated", - "description": "Marks an element of a GraphQL schema as no longer supported.", - "locations": ["FIELD_DEFINITION", "ENUM_VALUE"], - "args": [ - { - "name": "reason", - "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": "\"No longer supported\"" - } - ] - } - ] - } - } -} diff --git a/benchmark/introspectionFromSchema-benchmark.js b/benchmark/introspectionFromSchema-benchmark.js deleted file mode 100644 index 125ca9c367..0000000000 --- a/benchmark/introspectionFromSchema-benchmark.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { executeSync } = require('graphql/execution/execute.js'); -const { buildSchema } = require('graphql/utilities/buildASTSchema.js'); -const { - getIntrospectionQuery, -} = require('graphql/utilities/getIntrospectionQuery.js'); - -const { bigSchemaSDL } = require('./fixtures.js'); - -const schema = buildSchema(bigSchemaSDL, { assumeValid: true }); -const document = parse(getIntrospectionQuery()); - -module.exports = { - name: 'Execute Introspection Query', - count: 10, - measure() { - executeSync({ schema, document }); - }, -}; diff --git a/benchmark/kitchen-sink.graphql b/benchmark/kitchen-sink.graphql deleted file mode 100644 index 8d9c6ab341..0000000000 --- a/benchmark/kitchen-sink.graphql +++ /dev/null @@ -1,65 +0,0 @@ -query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery { - whoever123is: node(id: [123, 456]) { - id - ... on User @onInlineFragment { - field2 { - id - alias: field1(first: 10, after: $foo) @include(if: $foo) { - id - ...frag @onFragmentSpread - } - } - } - ... @skip(unless: $foo) { - id - } - ... { - id - } - } -} - -mutation likeStory @onMutation { - like(story: 123) @onField { - story { - id @onField - } - } -} - -subscription StoryLikeSubscription( - $input: StoryLikeSubscribeInput @onVariableDefinition -) @onSubscription { - storyLikeSubscribe(input: $input) { - story { - likers { - count - } - likeSentence { - text - } - } - } -} - -fragment frag on Friend @onFragmentDefinition { - foo( - size: $size - bar: $b - obj: { - key: "value" - block: """ - block string uses \""" - """ - } - ) -} - -{ - unnamed(truthy: true, falsy: false, nullish: null) - query -} - -query { - __typename -} diff --git a/benchmark/parser-benchmark.js b/benchmark/parser-benchmark.js deleted file mode 100644 index 7f2e7931eb..0000000000 --- a/benchmark/parser-benchmark.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { - getIntrospectionQuery, -} = require('graphql/utilities/getIntrospectionQuery.js'); - -const introspectionQuery = getIntrospectionQuery(); - -module.exports = { - name: 'Parse introspection query', - count: 1000, - measure() { - parse(introspectionQuery); - }, -}; diff --git a/benchmark/printer-benchmark.js b/benchmark/printer-benchmark.js deleted file mode 100644 index 6227122b89..0000000000 --- a/benchmark/printer-benchmark.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { print } = require('graphql/language/printer.js'); - -const { bigDocumentSDL } = require('./fixtures.js'); - -const document = parse(bigDocumentSDL); - -module.exports = { - name: 'Print kitchen sink document', - count: 1000, - measure() { - print(document); - }, -}; diff --git a/benchmark/repeated-fields-benchmark.js b/benchmark/repeated-fields-benchmark.js deleted file mode 100644 index 7dd5b179b7..0000000000 --- a/benchmark/repeated-fields-benchmark.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -const { graphqlSync } = require('graphql/graphql.js'); -const { buildSchema } = require('graphql/utilities/buildASTSchema.js'); - -const schema = buildSchema('type Query { hello: String! }'); -const source = `{ ${'hello '.repeat(250)}}`; - -module.exports = { - name: 'Many repeated fields', - count: 5, - measure() { - graphqlSync({ schema, source }); - }, -}; diff --git a/benchmark/validateGQL-benchmark.js b/benchmark/validateGQL-benchmark.js deleted file mode 100644 index cc60a7ade0..0000000000 --- a/benchmark/validateGQL-benchmark.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { validate } = require('graphql/validation/validate.js'); -const { buildSchema } = require('graphql/utilities/buildASTSchema.js'); -const { - getIntrospectionQuery, -} = require('graphql/utilities/getIntrospectionQuery.js'); - -const { bigSchemaSDL } = require('./fixtures.js'); - -const schema = buildSchema(bigSchemaSDL, { assumeValid: true }); -const queryAST = parse(getIntrospectionQuery()); - -module.exports = { - name: 'Validate Introspection Query', - count: 50, - measure() { - validate(schema, queryAST); - }, -}; diff --git a/benchmark/validateInvalidGQL-benchmark.js b/benchmark/validateInvalidGQL-benchmark.js deleted file mode 100644 index 1e44b48914..0000000000 --- a/benchmark/validateInvalidGQL-benchmark.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { validate } = require('graphql/validation/validate.js'); -const { buildSchema } = require('graphql/utilities/buildASTSchema.js'); - -const { bigSchemaSDL } = require('./fixtures.js'); - -const schema = buildSchema(bigSchemaSDL, { assumeValid: true }); -const queryAST = parse(` - { - unknownField - ... on unknownType { - anotherUnknownField - ...unknownFragment - } - } - - fragment TestFragment on anotherUnknownType { - yetAnotherUnknownField - } -`); - -module.exports = { - name: 'Validate Invalid Query', - count: 50, - measure() { - validate(schema, queryAST); - }, -}; diff --git a/benchmark/validateSDL-benchmark.js b/benchmark/validateSDL-benchmark.js deleted file mode 100644 index 93c80bbc56..0000000000 --- a/benchmark/validateSDL-benchmark.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { validateSDL } = require('graphql/validation/validate.js'); - -const { bigSchemaSDL } = require('./fixtures.js'); - -const sdlAST = parse(bigSchemaSDL); - -module.exports = { - name: 'Validate SDL Document', - count: 10, - measure() { - validateSDL(sdlAST); - }, -}; diff --git a/benchmark/visit-benchmark.js b/benchmark/visit-benchmark.js deleted file mode 100644 index ab6a2baac2..0000000000 --- a/benchmark/visit-benchmark.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { visit } = require('graphql/language/visitor.js'); - -const { bigSchemaSDL } = require('./fixtures.js'); - -const documentAST = parse(bigSchemaSDL); - -const visitor = { - enter() { - /* do nothing */ - }, - leave() { - /* do nothing */ - }, -}; - -module.exports = { - name: 'Visit all AST nodes', - count: 10, - measure() { - visit(documentAST, visitor); - }, -}; diff --git a/benchmark/visitInParallel-benchmark.js b/benchmark/visitInParallel-benchmark.js deleted file mode 100644 index cd835dd19c..0000000000 --- a/benchmark/visitInParallel-benchmark.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const { parse } = require('graphql/language/parser.js'); -const { visit, visitInParallel } = require('graphql/language/visitor.js'); - -const { bigSchemaSDL } = require('./fixtures.js'); - -const documentAST = parse(bigSchemaSDL); - -const visitors = new Array(50).fill({ - enter() { - /* do nothing */ - }, - leave() { - /* do nothing */ - }, -}); - -module.exports = { - name: 'Visit all AST nodes in parallel', - count: 10, - measure() { - visit(documentAST, visitInParallel(visitors)); - }, -}; diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 7c05fac380..0000000000 --- a/codecov.yml +++ /dev/null @@ -1,14 +0,0 @@ -codecov: - notify: - require_ci_to_pass: true - -parsers: - javascript: - enable_partials: true - -comment: false -coverage: - status: - project: - default: - target: auto diff --git a/cspell.yml b/cspell.yml deleted file mode 100644 index fa53d1eb2d..0000000000 --- a/cspell.yml +++ /dev/null @@ -1,136 +0,0 @@ -language: en -useGitignore: true -# TODO enableGlobDot: true -ignorePaths: - # Excluded from spelling check - - cspell.yml - - package.json - - package-lock.json - - tsconfig.json - - benchmark/github-schema.graphql - - benchmark/github-schema.json - - website/icons - - website/css -overrides: - - filename: 'website/**' - dictionaries: - - fullstack - words: - - clsx - - infima - - noopener - - Vite - - craco - - esbuild - - swcrc - - noreferrer - - xlink - - codegen - - composability - - deduplication - - debuggable - - subschema - - subschemas - - NATS - - benjie - - codegen - - URQL - - tada - - Graphile - - precompiled - - debuggable - -ignoreRegExpList: - - u\{[0-9a-f]{1,8}\} - -words: - - graphiql - - sublinks - - instanceof - - # Different names used inside tests - - Skywalker - - Leia - - Wilhuff - - Tarkin - - Artoo - - Threepio - - Odie - - Odie's - - Damerau - - Alderaan - - Tatooine - - astromech - - # TODO: contribute upstream - - deno - - codecov - - # Website tech - - Nextra - - headlessui - - Fastify - - tailwindcss - - svgr - - ruru - - oneof - - vercel - - unbatched - - # used as href anchors - - graphqlerror - - syntaxerror - - formaterror - - graphqlschema - - graphqlscalartype - - graphqlobjecttype - - graphqlinterfacetype - - graphqluniontype - - graphqlenumtype - - graphqlinputobjecttype - - graphqllist - - graphqlnonnull - - graphqlint - - graphqlfloat - - graphqlstring - - graphqlboolean - - graphqlid - - getlocation - - isinputtype - - isoutputtype - - isleaftype - - iscompositetype - - isabstracttype - - getnullabletype - - getnamedtype - - introspectionquery - - buildclientschema - - buildschema - - printschema - - printintrospectionschema - - buildastschema - - typefromast - - astfromvalue - - typeinfo - - isvalidjsvalue - - isvalidliteralvalue - - specifiedrules - - Wordmark - - codeofconduct - - graphqlconf - - # website words - - runtimes - - # TODO: remove bellow words - - QLID # GraphQLID - - QLJS # GraphQLJS - - iface - - Reqs - - FXXX - - XXXF - - bfnrt - - wrds - - overcomplicating - - cacheable - - pino diff --git a/error/GraphQLError.d.ts b/error/GraphQLError.d.ts new file mode 100644 index 0000000000..b135fa360c --- /dev/null +++ b/error/GraphQLError.d.ts @@ -0,0 +1,120 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ASTNode } from '../language/ast.js'; +import type { SourceLocation } from '../language/location.js'; +import type { Source } from '../language/source.js'; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLErrorExtensions { + [attributeName: string]: unknown; +} +/** + * Custom formatted extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLFormattedErrorExtensions { + [attributeName: string]: unknown; +} +export interface GraphQLErrorOptions { + nodes?: ReadonlyArray | ASTNode | null | undefined; + source?: Maybe; + positions?: Maybe>; + path?: Maybe>; + originalError?: Maybe; + extensions?: Maybe; +} +/** + * A GraphQLError describes an Error found during the parse, validate, or + * execute phases of performing a GraphQL operation. In addition to a message + * and stack trace, it also includes information about the locations in a + * GraphQL document and/or execution result that correspond to the Error. + */ +export declare class GraphQLError extends Error { + /** + * An array of `{ line, column }` locations within the source GraphQL document + * which correspond to this error. + * + * Errors during validation often contain multiple locations, for example to + * point out two things with the same name. Errors during execution include a + * single location, the field which produced the error. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + readonly locations: ReadonlyArray | undefined; + /** + * An array describing the JSON-path into the execution response which + * corresponds to this error. Only included for errors during execution. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + readonly path: ReadonlyArray | undefined; + /** + * An array of GraphQL AST Nodes corresponding to this error. + */ + readonly nodes: ReadonlyArray | undefined; + /** + * The source GraphQL document for the first location of this error. + * + * Note that if this Error represents more than one node, the source may not + * represent nodes after the first node. + */ + readonly source: Source | undefined; + /** + * An array of character offsets within the source GraphQL document + * which correspond to this error. + */ + readonly positions: ReadonlyArray | undefined; + /** + * The original error thrown from a field resolver during execution. + */ + readonly originalError: Error | undefined; + /** + * Extension fields to add to the formatted error. + */ + readonly extensions: GraphQLErrorExtensions; + constructor(message: string, options?: GraphQLErrorOptions); + get [Symbol.toStringTag](): string; + toString(): string; + toJSON(): GraphQLFormattedError; +} +/** + * See: https://spec.graphql.org/draft/#sec-Errors + */ +export interface GraphQLFormattedError { + /** + * A short, human-readable summary of the problem that **SHOULD NOT** change + * from occurrence to occurrence of the problem, except for purposes of + * localization. + */ + readonly message: string; + /** + * If an error can be associated to a particular point in the requested + * GraphQL document, it should contain a list of locations. + */ + readonly locations?: ReadonlyArray; + /** + * If an error can be associated to a particular field in the GraphQL result, + * it _must_ contain an entry with the key `path` that details the path of + * the response field which experienced the error. This allows clients to + * identify whether a null result is intentional or caused by a runtime error. + */ + readonly path?: ReadonlyArray; + /** + * Reserved for implementors to extend the protocol however they see fit, + * and hence there are no additional restrictions on its contents. + */ + readonly extensions?: GraphQLFormattedErrorExtensions; +} diff --git a/error/GraphQLError.js b/error/GraphQLError.js new file mode 100644 index 0000000000..94af67658f --- /dev/null +++ b/error/GraphQLError.js @@ -0,0 +1,110 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GraphQLError = void 0; +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const location_js_1 = require("../language/location.js"); +const printLocation_js_1 = require("../language/printLocation.js"); +/** + * A GraphQLError describes an Error found during the parse, validate, or + * execute phases of performing a GraphQL operation. In addition to a message + * and stack trace, it also includes information about the locations in a + * GraphQL document and/or execution result that correspond to the Error. + */ +class GraphQLError extends Error { + constructor(message, options = {}) { + const { nodes, source, positions, path, originalError, extensions } = options; + super(message); + this.name = 'GraphQLError'; + this.path = path ?? undefined; + this.originalError = originalError ?? undefined; + // Compute list of blame nodes. + this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined); + const nodeLocations = undefinedIfEmpty(this.nodes + ?.map((node) => node.loc) + .filter((loc) => loc != null)); + // Compute locations in the source for the given nodes/positions. + this.source = source ?? nodeLocations?.[0]?.source; + this.positions = positions ?? nodeLocations?.map((loc) => loc.start); + this.locations = + positions && source + ? positions.map((pos) => (0, location_js_1.getLocation)(source, pos)) + : nodeLocations?.map((loc) => (0, location_js_1.getLocation)(loc.source, loc.start)); + const originalExtensions = (0, isObjectLike_js_1.isObjectLike)(originalError?.extensions) + ? originalError?.extensions + : undefined; + this.extensions = extensions ?? originalExtensions ?? Object.create(null); + // Only properties prescribed by the spec should be enumerable. + // Keep the rest as non-enumerable. + Object.defineProperties(this, { + message: { + writable: true, + enumerable: true, + }, + name: { enumerable: false }, + nodes: { enumerable: false }, + source: { enumerable: false }, + positions: { enumerable: false }, + originalError: { enumerable: false }, + }); + // Include (non-enumerable) stack trace. + /* c8 ignore start */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + if (originalError?.stack != null) { + Object.defineProperty(this, 'stack', { + value: originalError.stack, + writable: true, + configurable: true, + }); + } + else if (Error.captureStackTrace != null) { + Error.captureStackTrace(this, GraphQLError); + } + else { + Object.defineProperty(this, 'stack', { + value: Error().stack, + writable: true, + configurable: true, + }); + } + /* c8 ignore stop */ + } + get [Symbol.toStringTag]() { + return 'GraphQLError'; + } + toString() { + let output = this.message; + if (this.nodes) { + for (const node of this.nodes) { + if (node.loc) { + output += '\n\n' + (0, printLocation_js_1.printLocation)(node.loc); + } + } + } + else if (this.source && this.locations) { + for (const location of this.locations) { + output += '\n\n' + (0, printLocation_js_1.printSourceLocation)(this.source, location); + } + } + return output; + } + toJSON() { + const formattedError = { + message: this.message, + }; + if (this.locations != null) { + formattedError.locations = this.locations; + } + if (this.path != null) { + formattedError.path = this.path; + } + if (this.extensions != null && Object.keys(this.extensions).length > 0) { + formattedError.extensions = this.extensions; + } + return formattedError; + } +} +exports.GraphQLError = GraphQLError; +function undefinedIfEmpty(array) { + return array === undefined || array.length === 0 ? undefined : array; +} +//# sourceMappingURL=GraphQLError.js.map \ No newline at end of file diff --git a/error/GraphQLError.js.map b/error/GraphQLError.js.map new file mode 100644 index 0000000000..32d982cad8 --- /dev/null +++ b/error/GraphQLError.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GraphQLError.js","sourceRoot":"","sources":["../../src/error/GraphQLError.ts"],"names":[],"mappings":";;;AAAA,gEAA0D;AAK1D,yDAAsD;AACtD,mEAGsC;AAsCtC;;;;;GAKG;AACH,MAAa,YAAa,SAAQ,KAAK;IAkDrC,YAAY,OAAe,EAAE,UAA+B,EAAE;QAC5D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,GACjE,OAAO,CAAC;QAEV,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,SAAS,CA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esContent":["import { isObjectLike } from '../jsutils/isObjectLike.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ASTNode, Location } from '../language/ast.js';\nimport type { SourceLocation } from '../language/location.js';\nimport { getLocation } from '../language/location.js';\nimport {\n printLocation,\n printSourceLocation,\n} from '../language/printLocation.js';\nimport type { Source } from '../language/source.js';\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLErrorExtensions {\n [attributeName: string]: unknown;\n}\n\n/**\n * Custom formatted extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLFormattedErrorExtensions {\n [attributeName: string]: unknown;\n}\n\nexport interface GraphQLErrorOptions {\n nodes?: ReadonlyArray | ASTNode | null | undefined;\n source?: Maybe;\n positions?: Maybe>;\n path?: Maybe>;\n originalError?: Maybe;\n extensions?: Maybe;\n}\n\n/**\n * A GraphQLError describes an Error found during the parse, validate, or\n * execute phases of performing a GraphQL operation. In addition to a message\n * and stack trace, it also includes information about the locations in a\n * GraphQL document and/or execution result that correspond to the Error.\n */\nexport class GraphQLError extends Error {\n /**\n * An array of `{ line, column }` locations within the source GraphQL document\n * which correspond to this error.\n *\n * Errors during validation often contain multiple locations, for example to\n * point out two things with the same name. Errors during execution include a\n * single location, the field which produced the error.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n readonly locations: ReadonlyArray | undefined;\n\n /**\n * An array describing the JSON-path into the execution response which\n * corresponds to this error. Only included for errors during execution.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n readonly path: ReadonlyArray | undefined;\n\n /**\n * An array of GraphQL AST Nodes corresponding to this error.\n */\n readonly nodes: ReadonlyArray | undefined;\n\n /**\n * The source GraphQL document for the first location of this error.\n *\n * Note that if this Error represents more than one node, the source may not\n * represent nodes after the first node.\n */\n readonly source: Source | undefined;\n\n /**\n * An array of character offsets within the source GraphQL document\n * which correspond to this error.\n */\n readonly positions: ReadonlyArray | undefined;\n\n /**\n * The original error thrown from a field resolver during execution.\n */\n readonly originalError: Error | undefined;\n\n /**\n * Extension fields to add to the formatted error.\n */\n readonly extensions: GraphQLErrorExtensions;\n\n constructor(message: string, options: GraphQLErrorOptions = {}) {\n const { nodes, source, positions, path, originalError, extensions } =\n options;\n\n super(message);\n\n this.name = 'GraphQLError';\n this.path = path ?? undefined;\n this.originalError = originalError ?? undefined;\n\n // Compute list of blame nodes.\n this.nodes = undefinedIfEmpty(\n Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined,\n );\n\n const nodeLocations = undefinedIfEmpty(\n this.nodes\n ?.map((node) => node.loc)\n .filter((loc): loc is Location => loc != null),\n );\n\n // Compute locations in the source for the given nodes/positions.\n this.source = source ?? nodeLocations?.[0]?.source;\n\n this.positions = positions ?? nodeLocations?.map((loc) => loc.start);\n\n this.locations =\n positions && source\n ? positions.map((pos) => getLocation(source, pos))\n : nodeLocations?.map((loc) => getLocation(loc.source, loc.start));\n\n const originalExtensions = isObjectLike(originalError?.extensions)\n ? originalError?.extensions\n : undefined;\n this.extensions = extensions ?? originalExtensions ?? Object.create(null);\n\n // Only properties prescribed by the spec should be enumerable.\n // Keep the rest as non-enumerable.\n Object.defineProperties(this, {\n message: {\n writable: true,\n enumerable: true,\n },\n name: { enumerable: false },\n nodes: { enumerable: false },\n source: { enumerable: false },\n positions: { enumerable: false },\n originalError: { enumerable: false },\n });\n\n // Include (non-enumerable) stack trace.\n /* c8 ignore start */\n // FIXME: https://github.com/graphql/graphql-js/issues/2317\n if (originalError?.stack != null) {\n Object.defineProperty(this, 'stack', {\n value: originalError.stack,\n writable: true,\n configurable: true,\n });\n } else if (Error.captureStackTrace != null) {\n Error.captureStackTrace(this, GraphQLError);\n } else {\n Object.defineProperty(this, 'stack', {\n value: Error().stack,\n writable: true,\n configurable: true,\n });\n }\n /* c8 ignore stop */\n }\n\n get [Symbol.toStringTag](): string {\n return 'GraphQLError';\n }\n\n override toString(): string {\n let output = this.message;\n\n if (this.nodes) {\n for (const node of this.nodes) {\n if (node.loc) {\n output += '\\n\\n' + printLocation(node.loc);\n }\n }\n } else if (this.source && this.locations) {\n for (const location of this.locations) {\n output += '\\n\\n' + printSourceLocation(this.source, location);\n }\n }\n\n return output;\n }\n\n toJSON(): GraphQLFormattedError {\n type WritableFormattedError = {\n -readonly [P in keyof GraphQLFormattedError]: GraphQLFormattedError[P];\n };\n\n const formattedError: WritableFormattedError = {\n message: this.message,\n };\n\n if (this.locations != null) {\n formattedError.locations = this.locations;\n }\n\n if (this.path != null) {\n formattedError.path = this.path;\n }\n\n if (this.extensions != null && Object.keys(this.extensions).length > 0) {\n formattedError.extensions = this.extensions;\n }\n\n return formattedError;\n }\n}\n\nfunction undefinedIfEmpty(\n array: Array | undefined,\n): Array | undefined {\n return array === undefined || array.length === 0 ? undefined : array;\n}\n\n/**\n * See: https://spec.graphql.org/draft/#sec-Errors\n */\nexport interface GraphQLFormattedError {\n /**\n * A short, human-readable summary of the problem that **SHOULD NOT** change\n * from occurrence to occurrence of the problem, except for purposes of\n * localization.\n */\n readonly message: string;\n /**\n * If an error can be associated to a particular point in the requested\n * GraphQL document, it should contain a list of locations.\n */\n readonly locations?: ReadonlyArray;\n /**\n * If an error can be associated to a particular field in the GraphQL result,\n * it _must_ contain an entry with the key `path` that details the path of\n * the response field which experienced the error. This allows clients to\n * identify whether a null result is intentional or caused by a runtime error.\n */\n readonly path?: ReadonlyArray;\n /**\n * Reserved for implementors to extend the protocol however they see fit,\n * and hence there are no additional restrictions on its contents.\n */\n readonly extensions?: GraphQLFormattedErrorExtensions;\n}\n"]} \ No newline at end of file diff --git a/error/GraphQLError.mjs b/error/GraphQLError.mjs new file mode 100644 index 0000000000..01b723de43 --- /dev/null +++ b/error/GraphQLError.mjs @@ -0,0 +1,106 @@ +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { getLocation } from "../language/location.mjs"; +import { printLocation, printSourceLocation, } from "../language/printLocation.mjs"; +/** + * A GraphQLError describes an Error found during the parse, validate, or + * execute phases of performing a GraphQL operation. In addition to a message + * and stack trace, it also includes information about the locations in a + * GraphQL document and/or execution result that correspond to the Error. + */ +export class GraphQLError extends Error { + constructor(message, options = {}) { + const { nodes, source, positions, path, originalError, extensions } = options; + super(message); + this.name = 'GraphQLError'; + this.path = path ?? undefined; + this.originalError = originalError ?? undefined; + // Compute list of blame nodes. + this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined); + const nodeLocations = undefinedIfEmpty(this.nodes + ?.map((node) => node.loc) + .filter((loc) => loc != null)); + // Compute locations in the source for the given nodes/positions. + this.source = source ?? nodeLocations?.[0]?.source; + this.positions = positions ?? nodeLocations?.map((loc) => loc.start); + this.locations = + positions && source + ? positions.map((pos) => getLocation(source, pos)) + : nodeLocations?.map((loc) => getLocation(loc.source, loc.start)); + const originalExtensions = isObjectLike(originalError?.extensions) + ? originalError?.extensions + : undefined; + this.extensions = extensions ?? originalExtensions ?? Object.create(null); + // Only properties prescribed by the spec should be enumerable. + // Keep the rest as non-enumerable. + Object.defineProperties(this, { + message: { + writable: true, + enumerable: true, + }, + name: { enumerable: false }, + nodes: { enumerable: false }, + source: { enumerable: false }, + positions: { enumerable: false }, + originalError: { enumerable: false }, + }); + // Include (non-enumerable) stack trace. + /* c8 ignore start */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + if (originalError?.stack != null) { + Object.defineProperty(this, 'stack', { + value: originalError.stack, + writable: true, + configurable: true, + }); + } + else if (Error.captureStackTrace != null) { + Error.captureStackTrace(this, GraphQLError); + } + else { + Object.defineProperty(this, 'stack', { + value: Error().stack, + writable: true, + configurable: true, + }); + } + /* c8 ignore stop */ + } + get [Symbol.toStringTag]() { + return 'GraphQLError'; + } + toString() { + let output = this.message; + if (this.nodes) { + for (const node of this.nodes) { + if (node.loc) { + output += '\n\n' + printLocation(node.loc); + } + } + } + else if (this.source && this.locations) { + for (const location of this.locations) { + output += '\n\n' + printSourceLocation(this.source, location); + } + } + return output; + } + toJSON() { + const formattedError = { + message: this.message, + }; + if (this.locations != null) { + formattedError.locations = this.locations; + } + if (this.path != null) { + formattedError.path = this.path; + } + if (this.extensions != null && Object.keys(this.extensions).length > 0) { + formattedError.extensions = this.extensions; + } + return formattedError; + } +} +function undefinedIfEmpty(array) { + return array === undefined || array.length === 0 ? undefined : array; +} +//# sourceMappingURL=GraphQLError.js.map \ No newline at end of file diff --git a/error/GraphQLError.mjs.map b/error/GraphQLError.mjs.map new file mode 100644 index 0000000000..ccac2861ed --- /dev/null +++ b/error/GraphQLError.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"GraphQLError.js","sourceRoot":"","sources":["../../src/error/GraphQLError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAK1D,OAAO,EAAE,WAAW,EAAE,iCAAgC;AACtD,OAAO,EACL,aAAa,EACb,mBAAmB,GACpB,sCAAqC;AAsCtC;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAkDrC,YAAY,OAAe,EAAE,UAA+B,EAAE;QAC5D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,GACjE,OAAO,CAAC;QAEV,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,SAAS,CAAC;QAEhD,+BAA+B;QAC/B,IAAI,CAAC,KAAK,GAAG,gBAAgB,CAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,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C,GAAG,CAAC,CAAC;gBAC7C,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACzC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACtC,MAAM,IAAI,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM;QAKJ,MAAM,cAAc,GAA2B;YAC7C,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;QAEF,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC3B,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5C,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACtB,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAClC,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvE,cAAc,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAC9C,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAED,SAAS,gBAAgB,CACvB,KAA2B;IAE3B,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACvE,CAAC","sourcesContent":["import { isObjectLike } from '../jsutils/isObjectLike.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ASTNode, Location } from '../language/ast.js';\nimport type { SourceLocation } from '../language/location.js';\nimport { getLocation } from '../language/location.js';\nimport {\n printLocation,\n printSourceLocation,\n} from '../language/printLocation.js';\nimport type { Source } from '../language/source.js';\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLErrorExtensions {\n [attributeName: string]: unknown;\n}\n\n/**\n * Custom formatted extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLFormattedErrorExtensions {\n [attributeName: string]: unknown;\n}\n\nexport interface GraphQLErrorOptions {\n nodes?: ReadonlyArray | ASTNode | null | undefined;\n source?: Maybe;\n positions?: Maybe>;\n path?: Maybe>;\n originalError?: Maybe;\n extensions?: Maybe;\n}\n\n/**\n * A GraphQLError describes an Error found during the parse, validate, or\n * execute phases of performing a GraphQL operation. In addition to a message\n * and stack trace, it also includes information about the locations in a\n * GraphQL document and/or execution result that correspond to the Error.\n */\nexport class GraphQLError extends Error {\n /**\n * An array of `{ line, column }` locations within the source GraphQL document\n * which correspond to this error.\n *\n * Errors during validation often contain multiple locations, for example to\n * point out two things with the same name. Errors during execution include a\n * single location, the field which produced the error.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n readonly locations: ReadonlyArray | undefined;\n\n /**\n * An array describing the JSON-path into the execution response which\n * corresponds to this error. Only included for errors during execution.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n readonly path: ReadonlyArray | undefined;\n\n /**\n * An array of GraphQL AST Nodes corresponding to this error.\n */\n readonly nodes: ReadonlyArray | undefined;\n\n /**\n * The source GraphQL document for the first location of this error.\n *\n * Note that if this Error represents more than one node, the source may not\n * represent nodes after the first node.\n */\n readonly source: Source | undefined;\n\n /**\n * An array of character offsets within the source GraphQL document\n * which correspond to this error.\n */\n readonly positions: ReadonlyArray | undefined;\n\n /**\n * The original error thrown from a field resolver during execution.\n */\n readonly originalError: Error | undefined;\n\n /**\n * Extension fields to add to the formatted error.\n */\n readonly extensions: GraphQLErrorExtensions;\n\n constructor(message: string, options: GraphQLErrorOptions = {}) {\n const { nodes, source, positions, path, originalError, extensions } =\n options;\n\n super(message);\n\n this.name = 'GraphQLError';\n this.path = path ?? undefined;\n this.originalError = originalError ?? undefined;\n\n // Compute list of blame nodes.\n this.nodes = undefinedIfEmpty(\n Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined,\n );\n\n const nodeLocations = undefinedIfEmpty(\n this.nodes\n ?.map((node) => node.loc)\n .filter((loc): loc is Location => loc != null),\n );\n\n // Compute locations in the source for the given nodes/positions.\n this.source = source ?? nodeLocations?.[0]?.source;\n\n this.positions = positions ?? nodeLocations?.map((loc) => loc.start);\n\n this.locations =\n positions && source\n ? positions.map((pos) => getLocation(source, pos))\n : nodeLocations?.map((loc) => getLocation(loc.source, loc.start));\n\n const originalExtensions = isObjectLike(originalError?.extensions)\n ? originalError?.extensions\n : undefined;\n this.extensions = extensions ?? originalExtensions ?? Object.create(null);\n\n // Only properties prescribed by the spec should be enumerable.\n // Keep the rest as non-enumerable.\n Object.defineProperties(this, {\n message: {\n writable: true,\n enumerable: true,\n },\n name: { enumerable: false },\n nodes: { enumerable: false },\n source: { enumerable: false },\n positions: { enumerable: false },\n originalError: { enumerable: false },\n });\n\n // Include (non-enumerable) stack trace.\n /* c8 ignore start */\n // FIXME: https://github.com/graphql/graphql-js/issues/2317\n if (originalError?.stack != null) {\n Object.defineProperty(this, 'stack', {\n value: originalError.stack,\n writable: true,\n configurable: true,\n });\n } else if (Error.captureStackTrace != null) {\n Error.captureStackTrace(this, GraphQLError);\n } else {\n Object.defineProperty(this, 'stack', {\n value: Error().stack,\n writable: true,\n configurable: true,\n });\n }\n /* c8 ignore stop */\n }\n\n get [Symbol.toStringTag](): string {\n return 'GraphQLError';\n }\n\n override toString(): string {\n let output = this.message;\n\n if (this.nodes) {\n for (const node of this.nodes) {\n if (node.loc) {\n output += '\\n\\n' + printLocation(node.loc);\n }\n }\n } else if (this.source && this.locations) {\n for (const location of this.locations) {\n output += '\\n\\n' + printSourceLocation(this.source, location);\n }\n }\n\n return output;\n }\n\n toJSON(): GraphQLFormattedError {\n type WritableFormattedError = {\n -readonly [P in keyof GraphQLFormattedError]: GraphQLFormattedError[P];\n };\n\n const formattedError: WritableFormattedError = {\n message: this.message,\n };\n\n if (this.locations != null) {\n formattedError.locations = this.locations;\n }\n\n if (this.path != null) {\n formattedError.path = this.path;\n }\n\n if (this.extensions != null && Object.keys(this.extensions).length > 0) {\n formattedError.extensions = this.extensions;\n }\n\n return formattedError;\n }\n}\n\nfunction undefinedIfEmpty(\n array: Array | undefined,\n): Array | undefined {\n return array === undefined || array.length === 0 ? undefined : array;\n}\n\n/**\n * See: https://spec.graphql.org/draft/#sec-Errors\n */\nexport interface GraphQLFormattedError {\n /**\n * A short, human-readable summary of the problem that **SHOULD NOT** change\n * from occurrence to occurrence of the problem, except for purposes of\n * localization.\n */\n readonly message: string;\n /**\n * If an error can be associated to a particular point in the requested\n * GraphQL document, it should contain a list of locations.\n */\n readonly locations?: ReadonlyArray;\n /**\n * If an error can be associated to a particular field in the GraphQL result,\n * it _must_ contain an entry with the key `path` that details the path of\n * the response field which experienced the error. This allows clients to\n * identify whether a null result is intentional or caused by a runtime error.\n */\n readonly path?: ReadonlyArray;\n /**\n * Reserved for implementors to extend the protocol however they see fit,\n * and hence there are no additional restrictions on its contents.\n */\n readonly extensions?: GraphQLFormattedErrorExtensions;\n}\n"]} \ No newline at end of file diff --git a/error/index.d.ts b/error/index.d.ts new file mode 100644 index 0000000000..20a6e44110 --- /dev/null +++ b/error/index.d.ts @@ -0,0 +1,4 @@ +export { GraphQLError } from './GraphQLError.js'; +export type { GraphQLErrorOptions, GraphQLFormattedError, GraphQLErrorExtensions, GraphQLFormattedErrorExtensions, } from './GraphQLError.js'; +export { syntaxError } from './syntaxError.js'; +export { locatedError } from './locatedError.js'; diff --git a/error/index.js b/error/index.js new file mode 100644 index 0000000000..b8365000d5 --- /dev/null +++ b/error/index.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.locatedError = exports.syntaxError = exports.GraphQLError = void 0; +var GraphQLError_js_1 = require("./GraphQLError.js"); +Object.defineProperty(exports, "GraphQLError", { enumerable: true, get: function () { return GraphQLError_js_1.GraphQLError; } }); +var syntaxError_js_1 = require("./syntaxError.js"); +Object.defineProperty(exports, "syntaxError", { enumerable: true, get: function () { return syntaxError_js_1.syntaxError; } }); +var locatedError_js_1 = require("./locatedError.js"); +Object.defineProperty(exports, "locatedError", { enumerable: true, get: function () { return locatedError_js_1.locatedError; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/error/index.js.map b/error/index.js.map new file mode 100644 index 0000000000..89c545c5da --- /dev/null +++ b/error/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAAxC,+GAAA,YAAY,OAAA;AAQrB,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AAEpB,qDAAiD;AAAxC,+GAAA,YAAY,OAAA","sourcesContent":["export { GraphQLError } from './GraphQLError.js';\nexport type {\n GraphQLErrorOptions,\n GraphQLFormattedError,\n GraphQLErrorExtensions,\n GraphQLFormattedErrorExtensions,\n} from './GraphQLError.js';\n\nexport { syntaxError } from './syntaxError.js';\n\nexport { locatedError } from './locatedError.js';\n"]} \ No newline at end of file diff --git a/error/index.mjs b/error/index.mjs new file mode 100644 index 0000000000..982795e076 --- /dev/null +++ b/error/index.mjs @@ -0,0 +1,4 @@ +export { GraphQLError } from "./GraphQLError.mjs"; +export { syntaxError } from "./syntaxError.mjs"; +export { locatedError } from "./locatedError.mjs"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/error/index.mjs.map b/error/index.mjs.map new file mode 100644 index 0000000000..a9c9397af5 --- /dev/null +++ b/error/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,2BAA0B;AAQjD,OAAO,EAAE,WAAW,EAAE,0BAAyB;AAE/C,OAAO,EAAE,YAAY,EAAE,2BAA0B","sourcesContent":["export { GraphQLError } from './GraphQLError.js';\nexport type {\n GraphQLErrorOptions,\n GraphQLFormattedError,\n GraphQLErrorExtensions,\n GraphQLFormattedErrorExtensions,\n} from './GraphQLError.js';\n\nexport { syntaxError } from './syntaxError.js';\n\nexport { locatedError } from './locatedError.js';\n"]} \ No newline at end of file diff --git a/error/locatedError.d.ts b/error/locatedError.d.ts new file mode 100644 index 0000000000..67c0a278d2 --- /dev/null +++ b/error/locatedError.d.ts @@ -0,0 +1,9 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ASTNode } from '../language/ast.js'; +import { GraphQLError } from './GraphQLError.js'; +/** + * Given an arbitrary value, presumably thrown while attempting to execute a + * GraphQL operation, produce a new GraphQLError aware of the location in the + * document responsible for the original Error. + */ +export declare function locatedError(rawOriginalError: unknown, nodes: ASTNode | ReadonlyArray | undefined | null, path?: Maybe>): GraphQLError; diff --git a/error/locatedError.js b/error/locatedError.js new file mode 100644 index 0000000000..54a302906a --- /dev/null +++ b/error/locatedError.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.locatedError = locatedError; +const toError_js_1 = require("../jsutils/toError.js"); +const GraphQLError_js_1 = require("./GraphQLError.js"); +/** + * Given an arbitrary value, presumably thrown while attempting to execute a + * GraphQL operation, produce a new GraphQLError aware of the location in the + * document responsible for the original Error. + */ +function locatedError(rawOriginalError, nodes, path) { + const originalError = (0, toError_js_1.toError)(rawOriginalError); + // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + if (isLocatedGraphQLError(originalError)) { + return originalError; + } + return new GraphQLError_js_1.GraphQLError(originalError.message, { + nodes: originalError.nodes ?? nodes, + source: originalError.source, + positions: originalError.positions, + path, + originalError, + }); +} +function isLocatedGraphQLError(error) { + return Array.isArray(error.path); +} +//# sourceMappingURL=locatedError.js.map \ No newline at end of file diff --git a/error/locatedError.js.map b/error/locatedError.js.map new file mode 100644 index 0000000000..b09fc4ed5f --- /dev/null +++ b/error/locatedError.js.map @@ -0,0 +1 @@ +{"version":3,"file":"locatedError.js","sourceRoot":"","sources":["../../src/error/locatedError.ts"],"names":[],"mappings":";;AAYA,oCAmBC;AA9BD,sDAAgD;AAIhD,uDAAiD;AAEjD;;;;GAIG;AACH,SAAgB,YAAY,CAC1B,gBAAyB,EACzB,KAA0D,EAC1D,IAA4C;IAE5C,MAAM,aAAa,GAAG,IAAA,oBAAO,EAAC,gBAAgB,CAAC,CAAC;IAEhD,2FAA2F;IAC3F,IAAI,qBAAqB,CAAC,aAAa,CAAC,EAAE,CAAC;QACzC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,IAAI,8BAAY,CAAC,aAAa,CAAC,OAAO,EAAE;QAC7C,KAAK,EAAG,aAA8B,CAAC,KAAK,IAAI,KAAK;QACrD,MAAM,EAAG,aAA8B,CAAC,MAAM;QAC9C,SAAS,EAAG,aAA8B,CAAC,SAAS;QACpD,IAAI;QACJ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAU;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\nimport { toError } from '../jsutils/toError.js';\n\nimport type { ASTNode } from '../language/ast.js';\n\nimport { GraphQLError } from './GraphQLError.js';\n\n/**\n * Given an arbitrary value, presumably thrown while attempting to execute a\n * GraphQL operation, produce a new GraphQLError aware of the location in the\n * document responsible for the original Error.\n */\nexport function locatedError(\n rawOriginalError: unknown,\n nodes: ASTNode | ReadonlyArray | undefined | null,\n path?: Maybe>,\n): GraphQLError {\n const originalError = toError(rawOriginalError);\n\n // Note: this uses a brand-check to support GraphQL errors originating from other contexts.\n if (isLocatedGraphQLError(originalError)) {\n return originalError;\n }\n\n return new GraphQLError(originalError.message, {\n nodes: (originalError as GraphQLError).nodes ?? nodes,\n source: (originalError as GraphQLError).source,\n positions: (originalError as GraphQLError).positions,\n path,\n originalError,\n });\n}\n\nfunction isLocatedGraphQLError(error: any): error is GraphQLError {\n return Array.isArray(error.path);\n}\n"]} \ No newline at end of file diff --git a/error/locatedError.mjs b/error/locatedError.mjs new file mode 100644 index 0000000000..107cf2fb3e --- /dev/null +++ b/error/locatedError.mjs @@ -0,0 +1,25 @@ +import { toError } from "../jsutils/toError.mjs"; +import { GraphQLError } from "./GraphQLError.mjs"; +/** + * Given an arbitrary value, presumably thrown while attempting to execute a + * GraphQL operation, produce a new GraphQLError aware of the location in the + * document responsible for the original Error. + */ +export function locatedError(rawOriginalError, nodes, path) { + const originalError = toError(rawOriginalError); + // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + if (isLocatedGraphQLError(originalError)) { + return originalError; + } + return new GraphQLError(originalError.message, { + nodes: originalError.nodes ?? nodes, + source: originalError.source, + positions: originalError.positions, + path, + originalError, + }); +} +function isLocatedGraphQLError(error) { + return Array.isArray(error.path); +} +//# sourceMappingURL=locatedError.js.map \ No newline at end of file diff --git a/error/locatedError.mjs.map b/error/locatedError.mjs.map new file mode 100644 index 0000000000..aebaa6b6b7 --- /dev/null +++ b/error/locatedError.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"locatedError.js","sourceRoot":"","sources":["../../src/error/locatedError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAIhD,OAAO,EAAE,YAAY,EAAE,2BAA0B;AAEjD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,gBAAyB,EACzB,KAA0D,EAC1D,IAA4C;IAE5C,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEhD,2FAA2F;IAC3F,IAAI,qBAAqB,CAAC,aAAa,CAAC,EAAE,CAAC;QACzC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,IAAI,YAAY,CAAC,aAAa,CAAC,OAAO,EAAE;QAC7C,KAAK,EAAG,aAA8B,CAAC,KAAK,IAAI,KAAK;QACrD,MAAM,EAAG,aAA8B,CAAC,MAAM;QAC9C,SAAS,EAAG,aAA8B,CAAC,SAAS;QACpD,IAAI;QACJ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAU;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\nimport { toError } from '../jsutils/toError.js';\n\nimport type { ASTNode } from '../language/ast.js';\n\nimport { GraphQLError } from './GraphQLError.js';\n\n/**\n * Given an arbitrary value, presumably thrown while attempting to execute a\n * GraphQL operation, produce a new GraphQLError aware of the location in the\n * document responsible for the original Error.\n */\nexport function locatedError(\n rawOriginalError: unknown,\n nodes: ASTNode | ReadonlyArray | undefined | null,\n path?: Maybe>,\n): GraphQLError {\n const originalError = toError(rawOriginalError);\n\n // Note: this uses a brand-check to support GraphQL errors originating from other contexts.\n if (isLocatedGraphQLError(originalError)) {\n return originalError;\n }\n\n return new GraphQLError(originalError.message, {\n nodes: (originalError as GraphQLError).nodes ?? nodes,\n source: (originalError as GraphQLError).source,\n positions: (originalError as GraphQLError).positions,\n path,\n originalError,\n });\n}\n\nfunction isLocatedGraphQLError(error: any): error is GraphQLError {\n return Array.isArray(error.path);\n}\n"]} \ No newline at end of file diff --git a/error/syntaxError.d.ts b/error/syntaxError.d.ts new file mode 100644 index 0000000000..0330658f6b --- /dev/null +++ b/error/syntaxError.d.ts @@ -0,0 +1,7 @@ +import type { Source } from '../language/source.js'; +import { GraphQLError } from './GraphQLError.js'; +/** + * Produces a GraphQLError representing a syntax error, containing useful + * descriptive information about the syntax error's position in the source. + */ +export declare function syntaxError(source: Source, position: number, description: string): GraphQLError; diff --git a/error/syntaxError.js b/error/syntaxError.js new file mode 100644 index 0000000000..8b54314605 --- /dev/null +++ b/error/syntaxError.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.syntaxError = syntaxError; +const GraphQLError_js_1 = require("./GraphQLError.js"); +/** + * Produces a GraphQLError representing a syntax error, containing useful + * descriptive information about the syntax error's position in the source. + */ +function syntaxError(source, position, description) { + return new GraphQLError_js_1.GraphQLError(`Syntax Error: ${description}`, { + source, + positions: [position], + }); +} +//# sourceMappingURL=syntaxError.js.map \ No newline at end of file diff --git a/error/syntaxError.js.map b/error/syntaxError.js.map new file mode 100644 index 0000000000..a9d0795426 --- /dev/null +++ b/error/syntaxError.js.map @@ -0,0 +1 @@ +{"version":3,"file":"syntaxError.js","sourceRoot":"","sources":["../../src/error/syntaxError.ts"],"names":[],"mappings":";;AAQA,kCASC;AAfD,uDAAiD;AAEjD;;;GAGG;AACH,SAAgB,WAAW,CACzB,MAAc,EACd,QAAgB,EAChB,WAAmB;IAEnB,OAAO,IAAI,8BAAY,CAAC,iBAAiB,WAAW,EAAE,EAAE;QACtD,MAAM;QACN,SAAS,EAAE,CAAC,QAAQ,CAAC;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Source } from '../language/source.js';\n\nimport { GraphQLError } from './GraphQLError.js';\n\n/**\n * Produces a GraphQLError representing a syntax error, containing useful\n * descriptive information about the syntax error's position in the source.\n */\nexport function syntaxError(\n source: Source,\n position: number,\n description: string,\n): GraphQLError {\n return new GraphQLError(`Syntax Error: ${description}`, {\n source,\n positions: [position],\n });\n}\n"]} \ No newline at end of file diff --git a/error/syntaxError.mjs b/error/syntaxError.mjs new file mode 100644 index 0000000000..ccfe71a1bb --- /dev/null +++ b/error/syntaxError.mjs @@ -0,0 +1,12 @@ +import { GraphQLError } from "./GraphQLError.mjs"; +/** + * Produces a GraphQLError representing a syntax error, containing useful + * descriptive information about the syntax error's position in the source. + */ +export function syntaxError(source, position, description) { + return new GraphQLError(`Syntax Error: ${description}`, { + source, + positions: [position], + }); +} +//# sourceMappingURL=syntaxError.js.map \ No newline at end of file diff --git a/error/syntaxError.mjs.map b/error/syntaxError.mjs.map new file mode 100644 index 0000000000..3547227008 --- /dev/null +++ b/error/syntaxError.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"syntaxError.js","sourceRoot":"","sources":["../../src/error/syntaxError.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,2BAA0B;AAEjD;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,QAAgB,EAChB,WAAmB;IAEnB,OAAO,IAAI,YAAY,CAAC,iBAAiB,WAAW,EAAE,EAAE;QACtD,MAAM;QACN,SAAS,EAAE,CAAC,QAAQ,CAAC;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Source } from '../language/source.js';\n\nimport { GraphQLError } from './GraphQLError.js';\n\n/**\n * Produces a GraphQLError representing a syntax error, containing useful\n * descriptive information about the syntax error's position in the source.\n */\nexport function syntaxError(\n source: Source,\n position: number,\n description: string,\n): GraphQLError {\n return new GraphQLError(`Syntax Error: ${description}`, {\n source,\n positions: [position],\n });\n}\n"]} \ No newline at end of file diff --git a/execution/AbortSignalListener.d.ts b/execution/AbortSignalListener.d.ts new file mode 100644 index 0000000000..8e5f154955 --- /dev/null +++ b/execution/AbortSignalListener.d.ts @@ -0,0 +1,17 @@ +/** + * A AbortSignalListener object can be used to trigger multiple responses + * in response to a single AbortSignal. + * + * @internal + */ +export declare class AbortSignalListener { + abortSignal: AbortSignal; + abort: () => void; + private _onAborts; + constructor(abortSignal: AbortSignal); + add(onAbort: () => void): void; + delete(onAbort: () => void): void; + disconnect(): void; +} +export declare function cancellablePromise(originalPromise: Promise, abortSignalListener: AbortSignalListener): Promise; +export declare function cancellableIterable(iterable: AsyncIterable, abortSignalListener: AbortSignalListener): AsyncIterable; diff --git a/execution/AbortSignalListener.js b/execution/AbortSignalListener.js new file mode 100644 index 0000000000..03fde6e179 --- /dev/null +++ b/execution/AbortSignalListener.js @@ -0,0 +1,71 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AbortSignalListener = void 0; +exports.cancellablePromise = cancellablePromise; +exports.cancellableIterable = cancellableIterable; +const promiseWithResolvers_js_1 = require("../jsutils/promiseWithResolvers.js"); +/** + * A AbortSignalListener object can be used to trigger multiple responses + * in response to a single AbortSignal. + * + * @internal + */ +class AbortSignalListener { + constructor(abortSignal) { + this.abortSignal = abortSignal; + this._onAborts = new Set(); + this.abort = () => { + for (const abort of this._onAborts) { + abort(); + } + }; + abortSignal.addEventListener('abort', this.abort); + } + add(onAbort) { + this._onAborts.add(onAbort); + } + delete(onAbort) { + this._onAborts.delete(onAbort); + } + disconnect() { + this.abortSignal.removeEventListener('abort', this.abort); + } +} +exports.AbortSignalListener = AbortSignalListener; +function cancellablePromise(originalPromise, abortSignalListener) { + const abortSignal = abortSignalListener.abortSignal; + if (abortSignal.aborted) { + // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors + return Promise.reject(abortSignal.reason); + } + const { promise, resolve, reject } = (0, promiseWithResolvers_js_1.promiseWithResolvers)(); + const onAbort = () => reject(abortSignal.reason); + abortSignalListener.add(onAbort); + originalPromise.then((resolved) => { + abortSignalListener.delete(onAbort); + resolve(resolved); + }, (error) => { + abortSignalListener.delete(onAbort); + reject(error); + }); + return promise; +} +function cancellableIterable(iterable, abortSignalListener) { + const iterator = iterable[Symbol.asyncIterator](); + const _next = iterator.next.bind(iterator); + if (iterator.return) { + const _return = iterator.return.bind(iterator); + return { + [Symbol.asyncIterator]: () => ({ + next: () => cancellablePromise(_next(), abortSignalListener), + return: () => cancellablePromise(_return(), abortSignalListener), + }), + }; + } + return { + [Symbol.asyncIterator]: () => ({ + next: () => cancellablePromise(_next(), abortSignalListener), + }), + }; +} +//# sourceMappingURL=AbortSignalListener.js.map \ No newline at end of file diff --git a/execution/AbortSignalListener.js.map b/execution/AbortSignalListener.js.map new file mode 100644 index 0000000000..cea6375d9c --- /dev/null +++ b/execution/AbortSignalListener.js.map @@ -0,0 +1 @@ +{"version":3,"file":"AbortSignalListener.js","sourceRoot":"","sources":["../../src/execution/AbortSignalListener.ts"],"names":[],"mappings":";;;AAuCA,gDAyBC;AAED,kDAwBC;AA1FD,gFAA0E;AAE1E;;;;;GAKG;AACH,MAAa,mBAAmB;IAM9B,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE;YAChB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnC,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC,CAAC;QAEF,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,OAAmB;QACrB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,OAAmB;QACxB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,UAAU;QACR,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;CACF;AA7BD,kDA6BC;AAED,SAAgB,kBAAkB,CAChC,eAA2B,EAC3B,mBAAwC;IAExC,MAAM,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;IACpD,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;QACxB,2EAA2E;QAC3E,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CA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EAAE,GAAG,EAAE,CAAC,CAAC;YAC7B,IAAI,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,mBAAmB,CAAC;SAC7D,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { promiseWithResolvers } from '../jsutils/promiseWithResolvers.js';\n\n/**\n * A AbortSignalListener object can be used to trigger multiple responses\n * in response to a single AbortSignal.\n *\n * @internal\n */\nexport class AbortSignalListener {\n abortSignal: AbortSignal;\n abort: () => void;\n\n private _onAborts: Set<() => void>;\n\n constructor(abortSignal: AbortSignal) {\n this.abortSignal = abortSignal;\n this._onAborts = new Set<() => void>();\n this.abort = () => {\n for (const abort of this._onAborts) {\n abort();\n }\n };\n\n abortSignal.addEventListener('abort', this.abort);\n }\n\n add(onAbort: () => void): void {\n this._onAborts.add(onAbort);\n }\n\n delete(onAbort: () => void): void {\n this._onAborts.delete(onAbort);\n }\n\n disconnect(): void {\n this.abortSignal.removeEventListener('abort', this.abort);\n }\n}\n\nexport function cancellablePromise(\n originalPromise: Promise,\n abortSignalListener: AbortSignalListener,\n): Promise {\n const abortSignal = abortSignalListener.abortSignal;\n if (abortSignal.aborted) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return Promise.reject(abortSignal.reason);\n }\n\n const { promise, resolve, reject } = promiseWithResolvers();\n const onAbort = () => reject(abortSignal.reason);\n abortSignalListener.add(onAbort);\n originalPromise.then(\n (resolved) => {\n abortSignalListener.delete(onAbort);\n resolve(resolved);\n },\n (error: unknown) => {\n abortSignalListener.delete(onAbort);\n reject(error);\n },\n );\n\n return promise;\n}\n\nexport function cancellableIterable(\n iterable: AsyncIterable,\n abortSignalListener: AbortSignalListener,\n): AsyncIterable {\n const iterator = iterable[Symbol.asyncIterator]();\n\n const _next = iterator.next.bind(iterator);\n\n if (iterator.return) {\n const _return = iterator.return.bind(iterator);\n\n return {\n [Symbol.asyncIterator]: () => ({\n next: () => cancellablePromise(_next(), abortSignalListener),\n return: () => cancellablePromise(_return(), abortSignalListener),\n }),\n };\n }\n\n return {\n [Symbol.asyncIterator]: () => ({\n next: () => cancellablePromise(_next(), abortSignalListener),\n }),\n };\n}\n"]} \ No newline at end of file diff --git a/execution/AbortSignalListener.mjs b/execution/AbortSignalListener.mjs new file mode 100644 index 0000000000..33719242d7 --- /dev/null +++ b/execution/AbortSignalListener.mjs @@ -0,0 +1,65 @@ +import { promiseWithResolvers } from "../jsutils/promiseWithResolvers.mjs"; +/** + * A AbortSignalListener object can be used to trigger multiple responses + * in response to a single AbortSignal. + * + * @internal + */ +export class AbortSignalListener { + constructor(abortSignal) { + this.abortSignal = abortSignal; + this._onAborts = new Set(); + this.abort = () => { + for (const abort of this._onAborts) { + abort(); + } + }; + abortSignal.addEventListener('abort', this.abort); + } + add(onAbort) { + this._onAborts.add(onAbort); + } + delete(onAbort) { + this._onAborts.delete(onAbort); + } + disconnect() { + this.abortSignal.removeEventListener('abort', this.abort); + } +} +export function cancellablePromise(originalPromise, abortSignalListener) { + const abortSignal = abortSignalListener.abortSignal; + if (abortSignal.aborted) { + // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors + return Promise.reject(abortSignal.reason); + } + const { promise, resolve, reject } = promiseWithResolvers(); + const onAbort = () => reject(abortSignal.reason); + abortSignalListener.add(onAbort); + originalPromise.then((resolved) => { + abortSignalListener.delete(onAbort); + resolve(resolved); + }, (error) => { + abortSignalListener.delete(onAbort); + reject(error); + }); + return promise; +} +export function cancellableIterable(iterable, abortSignalListener) { + const iterator = iterable[Symbol.asyncIterator](); + const _next = iterator.next.bind(iterator); + if (iterator.return) { + const _return = iterator.return.bind(iterator); + return { + [Symbol.asyncIterator]: () => ({ + next: () => cancellablePromise(_next(), abortSignalListener), + return: () => cancellablePromise(_return(), abortSignalListener), + }), + }; + } + return { + [Symbol.asyncIterator]: () => ({ + next: () => cancellablePromise(_next(), abortSignalListener), + }), + }; +} +//# sourceMappingURL=AbortSignalListener.js.map \ No newline at end of file diff --git a/execution/AbortSignalListener.mjs.map b/execution/AbortSignalListener.mjs.map new file mode 100644 index 0000000000..755f4be76f --- /dev/null +++ b/execution/AbortSignalListener.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"AbortSignalListener.js","sourceRoot":"","sources":["../../src/execution/AbortSignalListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,4CAA2C;AAE1E;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAM9B,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE;YAChB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnC,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC,CAAC;QAEF,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,OAAmB;QACrB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,OAAmB;QACxB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,UAAU;QACR,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAChC,eAA2B,EAC3B,mBAAwC;IAExC,MAAM,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;IACpD,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;QACxB,2EAA2E;QAC3E,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAA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AAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,mBAAmB,CAAC;SAC7D,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { promiseWithResolvers } from '../jsutils/promiseWithResolvers.js';\n\n/**\n * A AbortSignalListener object can be used to trigger multiple responses\n * in response to a single AbortSignal.\n *\n * @internal\n */\nexport class AbortSignalListener {\n abortSignal: AbortSignal;\n abort: () => void;\n\n private _onAborts: Set<() => void>;\n\n constructor(abortSignal: AbortSignal) {\n this.abortSignal = abortSignal;\n this._onAborts = new Set<() => void>();\n this.abort = () => {\n for (const abort of this._onAborts) {\n abort();\n }\n };\n\n abortSignal.addEventListener('abort', this.abort);\n }\n\n add(onAbort: () => void): void {\n this._onAborts.add(onAbort);\n }\n\n delete(onAbort: () => void): void {\n this._onAborts.delete(onAbort);\n }\n\n disconnect(): void {\n this.abortSignal.removeEventListener('abort', this.abort);\n }\n}\n\nexport function cancellablePromise(\n originalPromise: Promise,\n abortSignalListener: AbortSignalListener,\n): Promise {\n const abortSignal = abortSignalListener.abortSignal;\n if (abortSignal.aborted) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return Promise.reject(abortSignal.reason);\n }\n\n const { promise, resolve, reject } = promiseWithResolvers();\n const onAbort = () => reject(abortSignal.reason);\n abortSignalListener.add(onAbort);\n originalPromise.then(\n (resolved) => {\n abortSignalListener.delete(onAbort);\n resolve(resolved);\n },\n (error: unknown) => {\n abortSignalListener.delete(onAbort);\n reject(error);\n },\n );\n\n return promise;\n}\n\nexport function cancellableIterable(\n iterable: AsyncIterable,\n abortSignalListener: AbortSignalListener,\n): AsyncIterable {\n const iterator = iterable[Symbol.asyncIterator]();\n\n const _next = iterator.next.bind(iterator);\n\n if (iterator.return) {\n const _return = iterator.return.bind(iterator);\n\n return {\n [Symbol.asyncIterator]: () => ({\n next: () => cancellablePromise(_next(), abortSignalListener),\n return: () => cancellablePromise(_return(), abortSignalListener),\n }),\n };\n }\n\n return {\n [Symbol.asyncIterator]: () => ({\n next: () => cancellablePromise(_next(), abortSignalListener),\n }),\n };\n}\n"]} \ No newline at end of file diff --git a/execution/IncrementalGraph.d.ts b/execution/IncrementalGraph.d.ts new file mode 100644 index 0000000000..ae53b245ae --- /dev/null +++ b/execution/IncrementalGraph.d.ts @@ -0,0 +1,29 @@ +import type { DeferredFragmentRecord, DeliveryGroup, IncrementalDataRecord, IncrementalDataRecordResult, StreamRecord, SuccessfulExecutionGroup } from './types.js'; +/** + * @internal + */ +export declare class IncrementalGraph { + private _rootNodes; + private _completedQueue; + private _nextQueue; + constructor(); + getNewRootNodes(incrementalDataRecords: ReadonlyArray): ReadonlyArray; + addCompletedSuccessfulExecutionGroup(successfulExecutionGroup: SuccessfulExecutionGroup): void; + currentCompletedBatch(): Generator; + nextCompletedBatch(): Promise | undefined>; + abort(): void; + hasNext(): boolean; + completeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord): { + newRootNodes: ReadonlyArray; + successfulExecutionGroups: ReadonlyArray; + } | undefined; + removeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord): boolean; + removeStream(streamRecord: StreamRecord): void; + private _addIncrementalDataRecords; + private _promoteNonEmptyToRoot; + private _completesRootNode; + private _addDeferredFragment; + private _onExecutionGroup; + private _onStreamItems; + private _enqueue; +} diff --git a/execution/IncrementalGraph.js b/execution/IncrementalGraph.js new file mode 100644 index 0000000000..05fe09a85f --- /dev/null +++ b/execution/IncrementalGraph.js @@ -0,0 +1,232 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IncrementalGraph = void 0; +const BoxedPromiseOrValue_js_1 = require("../jsutils/BoxedPromiseOrValue.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const isPromise_js_1 = require("../jsutils/isPromise.js"); +const promiseWithResolvers_js_1 = require("../jsutils/promiseWithResolvers.js"); +const types_js_1 = require("./types.js"); +/** + * @internal + */ +class IncrementalGraph { + constructor() { + this._rootNodes = new Set(); + this._completedQueue = []; + this._nextQueue = []; + } + getNewRootNodes(incrementalDataRecords) { + const initialResultChildren = new Set(); + this._addIncrementalDataRecords(incrementalDataRecords, undefined, initialResultChildren); + return this._promoteNonEmptyToRoot(initialResultChildren); + } + addCompletedSuccessfulExecutionGroup(successfulExecutionGroup) { + const { pendingExecutionGroup, incrementalDataRecords } = successfulExecutionGroup; + const deferredFragmentRecords = pendingExecutionGroup.deferredFragmentRecords; + for (const deferredFragmentRecord of deferredFragmentRecords) { + const { pendingExecutionGroups, successfulExecutionGroups } = deferredFragmentRecord; + pendingExecutionGroups.delete(pendingExecutionGroup); + successfulExecutionGroups.add(successfulExecutionGroup); + } + if (incrementalDataRecords !== undefined) { + this._addIncrementalDataRecords(incrementalDataRecords, deferredFragmentRecords); + } + } + *currentCompletedBatch() { + let completed; + while ((completed = this._completedQueue.shift()) !== undefined) { + yield completed; + } + if (this._rootNodes.size === 0) { + for (const resolve of this._nextQueue) { + resolve(undefined); + } + } + } + nextCompletedBatch() { + const { promise, resolve } = (0, promiseWithResolvers_js_1.promiseWithResolvers)(); + this._nextQueue.push(resolve); + return promise; + } + abort() { + for (const resolve of this._nextQueue) { + resolve(undefined); + } + } + hasNext() { + return this._rootNodes.size > 0; + } + completeDeferredFragment(deferredFragmentRecord) { + if (!this._rootNodes.has(deferredFragmentRecord) || + deferredFragmentRecord.pendingExecutionGroups.size > 0) { + return; + } + const successfulExecutionGroups = Array.from(deferredFragmentRecord.successfulExecutionGroups); + this._rootNodes.delete(deferredFragmentRecord); + for (const successfulExecutionGroup of successfulExecutionGroups) { + for (const otherDeferredFragmentRecord of successfulExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + otherDeferredFragmentRecord.successfulExecutionGroups.delete(successfulExecutionGroup); + } + } + const newRootNodes = this._promoteNonEmptyToRoot(deferredFragmentRecord.children); + return { newRootNodes, successfulExecutionGroups }; + } + removeDeferredFragment(deferredFragmentRecord) { + if (!this._rootNodes.has(deferredFragmentRecord)) { + return false; + } + this._rootNodes.delete(deferredFragmentRecord); + return true; + } + removeStream(streamRecord) { + this._rootNodes.delete(streamRecord); + } + _addIncrementalDataRecords(incrementalDataRecords, parents, initialResultChildren) { + for (const incrementalDataRecord of incrementalDataRecords) { + if ((0, types_js_1.isPendingExecutionGroup)(incrementalDataRecord)) { + for (const deferredFragmentRecord of incrementalDataRecord.deferredFragmentRecords) { + this._addDeferredFragment(deferredFragmentRecord, initialResultChildren); + deferredFragmentRecord.pendingExecutionGroups.add(incrementalDataRecord); + } + if (this._completesRootNode(incrementalDataRecord)) { + this._onExecutionGroup(incrementalDataRecord); + } + } + else if (parents === undefined) { + (initialResultChildren !== undefined) || (0, invariant_js_1.invariant)(false); + initialResultChildren.add(incrementalDataRecord); + } + else { + for (const parent of parents) { + this._addDeferredFragment(parent, initialResultChildren); + parent.children.add(incrementalDataRecord); + } + } + } + } + _promoteNonEmptyToRoot(maybeEmptyNewRootNodes) { + const newRootNodes = []; + for (const node of maybeEmptyNewRootNodes) { + if ((0, types_js_1.isDeferredFragmentRecord)(node)) { + if (node.pendingExecutionGroups.size > 0) { + for (const pendingExecutionGroup of node.pendingExecutionGroups) { + if (!this._completesRootNode(pendingExecutionGroup)) { + this._onExecutionGroup(pendingExecutionGroup); + } + } + this._rootNodes.add(node); + newRootNodes.push(node); + continue; + } + for (const child of node.children) { + maybeEmptyNewRootNodes.add(child); + } + } + else { + this._rootNodes.add(node); + newRootNodes.push(node); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + this._onStreamItems(node); + } + } + return newRootNodes; + } + _completesRootNode(pendingExecutionGroup) { + return pendingExecutionGroup.deferredFragmentRecords.some((deferredFragmentRecord) => this._rootNodes.has(deferredFragmentRecord)); + } + _addDeferredFragment(deferredFragmentRecord, initialResultChildren) { + if (this._rootNodes.has(deferredFragmentRecord)) { + return; + } + const parent = deferredFragmentRecord.parent; + if (parent === undefined) { + (initialResultChildren !== undefined) || (0, invariant_js_1.invariant)(false); + initialResultChildren.add(deferredFragmentRecord); + return; + } + parent.children.add(deferredFragmentRecord); + this._addDeferredFragment(parent, initialResultChildren); + } + _onExecutionGroup(pendingExecutionGroup) { + let completedExecutionGroup = pendingExecutionGroup.result; + if (!(completedExecutionGroup instanceof BoxedPromiseOrValue_js_1.BoxedPromiseOrValue)) { + completedExecutionGroup = completedExecutionGroup(); + } + const value = completedExecutionGroup.value; + if ((0, isPromise_js_1.isPromise)(value)) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + value.then((resolved) => this._enqueue(resolved)); + } + else { + this._enqueue(value); + } + } + async _onStreamItems(streamRecord) { + let items = []; + let errors = []; + let incrementalDataRecords = []; + const streamItemQueue = streamRecord.streamItemQueue; + let streamItemRecord; + while ((streamItemRecord = streamItemQueue.shift()) !== undefined) { + let result = streamItemRecord instanceof BoxedPromiseOrValue_js_1.BoxedPromiseOrValue + ? streamItemRecord.value + : streamItemRecord().value; + if ((0, isPromise_js_1.isPromise)(result)) { + if (items.length > 0) { + this._enqueue({ + streamRecord, + result: + // TODO add additional test case or rework for coverage + errors.length > 0 /* c8 ignore start */ + ? { items, errors } /* c8 ignore stop */ + : { items }, + incrementalDataRecords, + }); + items = []; + errors = []; + incrementalDataRecords = []; + } + // eslint-disable-next-line no-await-in-loop + result = await result; + // wait an additional tick to coalesce resolving additional promises + // within the queue + // eslint-disable-next-line no-await-in-loop + await Promise.resolve(); + } + if (result.item === undefined) { + if (items.length > 0) { + this._enqueue({ + streamRecord, + result: errors.length > 0 ? { items, errors } : { items }, + incrementalDataRecords, + }); + } + this._enqueue(result.errors === undefined + ? { streamRecord } + : { + streamRecord, + errors: result.errors, + }); + return; + } + items.push(result.item); + if (result.errors !== undefined) { + errors.push(...result.errors); + } + if (result.incrementalDataRecords !== undefined) { + incrementalDataRecords.push(...result.incrementalDataRecords); + } + } + } + _enqueue(completed) { + this._completedQueue.push(completed); + const next = this._nextQueue.shift(); + if (next === undefined) { + return; + } + next(this.currentCompletedBatch()); + } +} +exports.IncrementalGraph = IncrementalGraph; +//# sourceMappingURL=IncrementalGraph.js.map \ No newline at end of file diff --git a/execution/IncrementalGraph.js.map b/execution/IncrementalGraph.js.map new file mode 100644 index 0000000000..cd76d05c83 --- /dev/null +++ b/execution/IncrementalGraph.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IncrementalGraph.js","sourceRoot":"","sources":["../../src/execution/IncrementalGraph.ts"],"names":[],"mappings":";;;AAAA,8EAAwE;AACxE,0DAAoD;AACpD,0DAAoD;AACpD,gFAA0E;AAc1E,yCAA+E;AAE/E;;GAEG;AACH,MAAa,gBAAgB;IAQ3B;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,eAAe,CACb,sBAA4D;QAE5D,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAiB,CAAC;QACvD,IAAI,CAAC,0BAA0B,CAC7B,sBAAsB,EACtB,SAAS,EACT,qBAAqB,CACtB,CAAC;QACF,OAAO,IAAI,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC;IAC5D,CAAC;IAED,oCAAoC,CAClC,wBAAkD;QAElD,MAAM,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,GACrD,wBAAwB,CAAC;QAE3B,MAAM,uBAAuB,GAC3B,qBAAqB,CAAC,uBAAuB,CAAC;QAEhD,KAAK,MAAM,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;YAC7D,MAAM,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,GACzD,sBAAsB,CAAC;YACzB,sBAAsB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;YACrD,yBAAyB,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,sBAAsB,KAAK,SAAS,EAAE,CAAC;YACzC,IAAI,CAAC,0BAA0B,CAC7B,sBAAsB,EACtB,uBAAuB,CACxB,CAAC;QACJ,C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,MAAM,GAAG,CAAC,EAAE,CAAC;oBACrB,IAAI,CAAC,QAAQ,CAAC;wBACZ,YAAY;wBACZ,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;wBACzD,sBAAsB;qBACvB,CAAC,CAAC;gBACL,CAAC;gBACD,IAAI,CAAC,QAAQ,CACX,MAAM,CAAC,MAAM,KAAK,SAAS;oBACzB,CAAC,CAAC,EAAE,YAAY,EAAE;oBAClB,CAAC,CAAC;wBACE,YAAY;wBACZ,MAAM,EAAE,MAAM,CAAC,MAAM;qBACtB,CACN,CAAC;gBACF,OAAO;YACT,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACxB,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;YACD,IAAI,MAAM,CAAC,sBAAsB,KAAK,SAAS,EAAE,CAAC;gBAChD,sBAAsB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAEO,QAAQ,CAAC,SAAsC;QACrD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AAzSD,4CAySC","sourcesContent":["import { BoxedPromiseOrValue } from '../jsutils/BoxedPromiseOrValue.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isPromise } from '../jsutils/isPromise.js';\nimport { promiseWithResolvers } from '../jsutils/promiseWithResolvers.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n DeferredFragmentRecord,\n DeliveryGroup,\n IncrementalDataRecord,\n IncrementalDataRecordResult,\n PendingExecutionGroup,\n StreamItemRecord,\n StreamRecord,\n SuccessfulExecutionGroup,\n} from './types.js';\nimport { isDeferredFragmentRecord, isPendingExecutionGroup } from './types.js';\n\n/**\n * @internal\n */\nexport class IncrementalGraph {\n private _rootNodes: Set;\n\n private _completedQueue: Array;\n private _nextQueue: Array<\n (iterable: Iterable | undefined) => void\n >;\n\n constructor() {\n this._rootNodes = new Set();\n this._completedQueue = [];\n this._nextQueue = [];\n }\n\n getNewRootNodes(\n incrementalDataRecords: ReadonlyArray,\n ): ReadonlyArray {\n const initialResultChildren = new Set();\n this._addIncrementalDataRecords(\n incrementalDataRecords,\n undefined,\n initialResultChildren,\n );\n return this._promoteNonEmptyToRoot(initialResultChildren);\n }\n\n addCompletedSuccessfulExecutionGroup(\n successfulExecutionGroup: SuccessfulExecutionGroup,\n ): void {\n const { pendingExecutionGroup, incrementalDataRecords } =\n successfulExecutionGroup;\n\n const deferredFragmentRecords =\n pendingExecutionGroup.deferredFragmentRecords;\n\n for (const deferredFragmentRecord of deferredFragmentRecords) {\n const { pendingExecutionGroups, successfulExecutionGroups } =\n deferredFragmentRecord;\n pendingExecutionGroups.delete(pendingExecutionGroup);\n successfulExecutionGroups.add(successfulExecutionGroup);\n }\n\n if (incrementalDataRecords !== undefined) {\n this._addIncrementalDataRecords(\n incrementalDataRecords,\n deferredFragmentRecords,\n );\n }\n }\n\n *currentCompletedBatch(): Generator {\n let completed;\n while ((completed = this._completedQueue.shift()) !== undefined) {\n yield completed;\n }\n if (this._rootNodes.size === 0) {\n for (const resolve of this._nextQueue) {\n resolve(undefined);\n }\n }\n }\n\n nextCompletedBatch(): Promise<\n Iterable | undefined\n > {\n const { promise, resolve } = promiseWithResolvers<\n Iterable | undefined\n >();\n this._nextQueue.push(resolve);\n return promise;\n }\n\n abort(): void {\n for (const resolve of this._nextQueue) {\n resolve(undefined);\n }\n }\n\n hasNext(): boolean {\n return this._rootNodes.size > 0;\n }\n\n completeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord):\n | {\n newRootNodes: ReadonlyArray;\n successfulExecutionGroups: ReadonlyArray;\n }\n | undefined {\n if (\n !this._rootNodes.has(deferredFragmentRecord) ||\n deferredFragmentRecord.pendingExecutionGroups.size > 0\n ) {\n return;\n }\n const successfulExecutionGroups = Array.from(\n deferredFragmentRecord.successfulExecutionGroups,\n );\n this._rootNodes.delete(deferredFragmentRecord);\n for (const successfulExecutionGroup of successfulExecutionGroups) {\n for (const otherDeferredFragmentRecord of successfulExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n otherDeferredFragmentRecord.successfulExecutionGroups.delete(\n successfulExecutionGroup,\n );\n }\n }\n const newRootNodes = this._promoteNonEmptyToRoot(\n deferredFragmentRecord.children,\n );\n return { newRootNodes, successfulExecutionGroups };\n }\n\n removeDeferredFragment(\n deferredFragmentRecord: DeferredFragmentRecord,\n ): boolean {\n if (!this._rootNodes.has(deferredFragmentRecord)) {\n return false;\n }\n this._rootNodes.delete(deferredFragmentRecord);\n return true;\n }\n\n removeStream(streamRecord: StreamRecord): void {\n this._rootNodes.delete(streamRecord);\n }\n\n private _addIncrementalDataRecords(\n incrementalDataRecords: ReadonlyArray,\n parents: ReadonlyArray | undefined,\n initialResultChildren?: Set,\n ): void {\n for (const incrementalDataRecord of incrementalDataRecords) {\n if (isPendingExecutionGroup(incrementalDataRecord)) {\n for (const deferredFragmentRecord of incrementalDataRecord.deferredFragmentRecords) {\n this._addDeferredFragment(\n deferredFragmentRecord,\n initialResultChildren,\n );\n deferredFragmentRecord.pendingExecutionGroups.add(\n incrementalDataRecord,\n );\n }\n if (this._completesRootNode(incrementalDataRecord)) {\n this._onExecutionGroup(incrementalDataRecord);\n }\n } else if (parents === undefined) {\n invariant(initialResultChildren !== undefined);\n initialResultChildren.add(incrementalDataRecord);\n } else {\n for (const parent of parents) {\n this._addDeferredFragment(parent, initialResultChildren);\n parent.children.add(incrementalDataRecord);\n }\n }\n }\n }\n\n private _promoteNonEmptyToRoot(\n maybeEmptyNewRootNodes: Set,\n ): ReadonlyArray {\n const newRootNodes: Array = [];\n for (const node of maybeEmptyNewRootNodes) {\n if (isDeferredFragmentRecord(node)) {\n if (node.pendingExecutionGroups.size > 0) {\n for (const pendingExecutionGroup of node.pendingExecutionGroups) {\n if (!this._completesRootNode(pendingExecutionGroup)) {\n this._onExecutionGroup(pendingExecutionGroup);\n }\n }\n this._rootNodes.add(node);\n newRootNodes.push(node);\n continue;\n }\n for (const child of node.children) {\n maybeEmptyNewRootNodes.add(child);\n }\n } else {\n this._rootNodes.add(node);\n newRootNodes.push(node);\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._onStreamItems(node);\n }\n }\n return newRootNodes;\n }\n\n private _completesRootNode(\n pendingExecutionGroup: PendingExecutionGroup,\n ): boolean {\n return pendingExecutionGroup.deferredFragmentRecords.some(\n (deferredFragmentRecord) => this._rootNodes.has(deferredFragmentRecord),\n );\n }\n\n private _addDeferredFragment(\n deferredFragmentRecord: DeferredFragmentRecord,\n initialResultChildren: Set | undefined,\n ): void {\n if (this._rootNodes.has(deferredFragmentRecord)) {\n return;\n }\n const parent = deferredFragmentRecord.parent;\n if (parent === undefined) {\n invariant(initialResultChildren !== undefined);\n initialResultChildren.add(deferredFragmentRecord);\n return;\n }\n parent.children.add(deferredFragmentRecord);\n this._addDeferredFragment(parent, initialResultChildren);\n }\n\n private _onExecutionGroup(\n pendingExecutionGroup: PendingExecutionGroup,\n ): void {\n let completedExecutionGroup = pendingExecutionGroup.result;\n if (!(completedExecutionGroup instanceof BoxedPromiseOrValue)) {\n completedExecutionGroup = completedExecutionGroup();\n }\n const value = completedExecutionGroup.value;\n if (isPromise(value)) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n value.then((resolved) => this._enqueue(resolved));\n } else {\n this._enqueue(value);\n }\n }\n\n private async _onStreamItems(streamRecord: StreamRecord): Promise {\n let items: Array = [];\n let errors: Array = [];\n let incrementalDataRecords: Array = [];\n const streamItemQueue = streamRecord.streamItemQueue;\n let streamItemRecord: StreamItemRecord | undefined;\n while ((streamItemRecord = streamItemQueue.shift()) !== undefined) {\n let result =\n streamItemRecord instanceof BoxedPromiseOrValue\n ? streamItemRecord.value\n : streamItemRecord().value;\n if (isPromise(result)) {\n if (items.length > 0) {\n this._enqueue({\n streamRecord,\n result:\n // TODO add additional test case or rework for coverage\n errors.length > 0 /* c8 ignore start */\n ? { items, errors } /* c8 ignore stop */\n : { items },\n incrementalDataRecords,\n });\n items = [];\n errors = [];\n incrementalDataRecords = [];\n }\n // eslint-disable-next-line no-await-in-loop\n result = await result;\n // wait an additional tick to coalesce resolving additional promises\n // within the queue\n // eslint-disable-next-line no-await-in-loop\n await Promise.resolve();\n }\n if (result.item === undefined) {\n if (items.length > 0) {\n this._enqueue({\n streamRecord,\n result: errors.length > 0 ? { items, errors } : { items },\n incrementalDataRecords,\n });\n }\n this._enqueue(\n result.errors === undefined\n ? { streamRecord }\n : {\n streamRecord,\n errors: result.errors,\n },\n );\n return;\n }\n items.push(result.item);\n if (result.errors !== undefined) {\n errors.push(...result.errors);\n }\n if (result.incrementalDataRecords !== undefined) {\n incrementalDataRecords.push(...result.incrementalDataRecords);\n }\n }\n }\n\n private _enqueue(completed: IncrementalDataRecordResult): void {\n this._completedQueue.push(completed);\n const next = this._nextQueue.shift();\n if (next === undefined) {\n return;\n }\n next(this.currentCompletedBatch());\n }\n}\n"]} \ No newline at end of file diff --git a/execution/IncrementalGraph.mjs b/execution/IncrementalGraph.mjs new file mode 100644 index 0000000000..7a94bff4e6 --- /dev/null +++ b/execution/IncrementalGraph.mjs @@ -0,0 +1,228 @@ +import { BoxedPromiseOrValue } from "../jsutils/BoxedPromiseOrValue.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { isPromise } from "../jsutils/isPromise.mjs"; +import { promiseWithResolvers } from "../jsutils/promiseWithResolvers.mjs"; +import { isDeferredFragmentRecord, isPendingExecutionGroup } from "./types.mjs"; +/** + * @internal + */ +export class IncrementalGraph { + constructor() { + this._rootNodes = new Set(); + this._completedQueue = []; + this._nextQueue = []; + } + getNewRootNodes(incrementalDataRecords) { + const initialResultChildren = new Set(); + this._addIncrementalDataRecords(incrementalDataRecords, undefined, initialResultChildren); + return this._promoteNonEmptyToRoot(initialResultChildren); + } + addCompletedSuccessfulExecutionGroup(successfulExecutionGroup) { + const { pendingExecutionGroup, incrementalDataRecords } = successfulExecutionGroup; + const deferredFragmentRecords = pendingExecutionGroup.deferredFragmentRecords; + for (const deferredFragmentRecord of deferredFragmentRecords) { + const { pendingExecutionGroups, successfulExecutionGroups } = deferredFragmentRecord; + pendingExecutionGroups.delete(pendingExecutionGroup); + successfulExecutionGroups.add(successfulExecutionGroup); + } + if (incrementalDataRecords !== undefined) { + this._addIncrementalDataRecords(incrementalDataRecords, deferredFragmentRecords); + } + } + *currentCompletedBatch() { + let completed; + while ((completed = this._completedQueue.shift()) !== undefined) { + yield completed; + } + if (this._rootNodes.size === 0) { + for (const resolve of this._nextQueue) { + resolve(undefined); + } + } + } + nextCompletedBatch() { + const { promise, resolve } = promiseWithResolvers(); + this._nextQueue.push(resolve); + return promise; + } + abort() { + for (const resolve of this._nextQueue) { + resolve(undefined); + } + } + hasNext() { + return this._rootNodes.size > 0; + } + completeDeferredFragment(deferredFragmentRecord) { + if (!this._rootNodes.has(deferredFragmentRecord) || + deferredFragmentRecord.pendingExecutionGroups.size > 0) { + return; + } + const successfulExecutionGroups = Array.from(deferredFragmentRecord.successfulExecutionGroups); + this._rootNodes.delete(deferredFragmentRecord); + for (const successfulExecutionGroup of successfulExecutionGroups) { + for (const otherDeferredFragmentRecord of successfulExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + otherDeferredFragmentRecord.successfulExecutionGroups.delete(successfulExecutionGroup); + } + } + const newRootNodes = this._promoteNonEmptyToRoot(deferredFragmentRecord.children); + return { newRootNodes, successfulExecutionGroups }; + } + removeDeferredFragment(deferredFragmentRecord) { + if (!this._rootNodes.has(deferredFragmentRecord)) { + return false; + } + this._rootNodes.delete(deferredFragmentRecord); + return true; + } + removeStream(streamRecord) { + this._rootNodes.delete(streamRecord); + } + _addIncrementalDataRecords(incrementalDataRecords, parents, initialResultChildren) { + for (const incrementalDataRecord of incrementalDataRecords) { + if (isPendingExecutionGroup(incrementalDataRecord)) { + for (const deferredFragmentRecord of incrementalDataRecord.deferredFragmentRecords) { + this._addDeferredFragment(deferredFragmentRecord, initialResultChildren); + deferredFragmentRecord.pendingExecutionGroups.add(incrementalDataRecord); + } + if (this._completesRootNode(incrementalDataRecord)) { + this._onExecutionGroup(incrementalDataRecord); + } + } + else if (parents === undefined) { + (initialResultChildren !== undefined) || invariant(false); + initialResultChildren.add(incrementalDataRecord); + } + else { + for (const parent of parents) { + this._addDeferredFragment(parent, initialResultChildren); + parent.children.add(incrementalDataRecord); + } + } + } + } + _promoteNonEmptyToRoot(maybeEmptyNewRootNodes) { + const newRootNodes = []; + for (const node of maybeEmptyNewRootNodes) { + if (isDeferredFragmentRecord(node)) { + if (node.pendingExecutionGroups.size > 0) { + for (const pendingExecutionGroup of node.pendingExecutionGroups) { + if (!this._completesRootNode(pendingExecutionGroup)) { + this._onExecutionGroup(pendingExecutionGroup); + } + } + this._rootNodes.add(node); + newRootNodes.push(node); + continue; + } + for (const child of node.children) { + maybeEmptyNewRootNodes.add(child); + } + } + else { + this._rootNodes.add(node); + newRootNodes.push(node); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + this._onStreamItems(node); + } + } + return newRootNodes; + } + _completesRootNode(pendingExecutionGroup) { + return pendingExecutionGroup.deferredFragmentRecords.some((deferredFragmentRecord) => this._rootNodes.has(deferredFragmentRecord)); + } + _addDeferredFragment(deferredFragmentRecord, initialResultChildren) { + if (this._rootNodes.has(deferredFragmentRecord)) { + return; + } + const parent = deferredFragmentRecord.parent; + if (parent === undefined) { + (initialResultChildren !== undefined) || invariant(false); + initialResultChildren.add(deferredFragmentRecord); + return; + } + parent.children.add(deferredFragmentRecord); + this._addDeferredFragment(parent, initialResultChildren); + } + _onExecutionGroup(pendingExecutionGroup) { + let completedExecutionGroup = pendingExecutionGroup.result; + if (!(completedExecutionGroup instanceof BoxedPromiseOrValue)) { + completedExecutionGroup = completedExecutionGroup(); + } + const value = completedExecutionGroup.value; + if (isPromise(value)) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + value.then((resolved) => this._enqueue(resolved)); + } + else { + this._enqueue(value); + } + } + async _onStreamItems(streamRecord) { + let items = []; + let errors = []; + let incrementalDataRecords = []; + const streamItemQueue = streamRecord.streamItemQueue; + let streamItemRecord; + while ((streamItemRecord = streamItemQueue.shift()) !== undefined) { + let result = streamItemRecord instanceof BoxedPromiseOrValue + ? streamItemRecord.value + : streamItemRecord().value; + if (isPromise(result)) { + if (items.length > 0) { + this._enqueue({ + streamRecord, + result: + // TODO add additional test case or rework for coverage + errors.length > 0 /* c8 ignore start */ + ? { items, errors } /* c8 ignore stop */ + : { items }, + incrementalDataRecords, + }); + items = []; + errors = []; + incrementalDataRecords = []; + } + // eslint-disable-next-line no-await-in-loop + result = await result; + // wait an additional tick to coalesce resolving additional promises + // within the queue + // eslint-disable-next-line no-await-in-loop + await Promise.resolve(); + } + if (result.item === undefined) { + if (items.length > 0) { + this._enqueue({ + streamRecord, + result: errors.length > 0 ? { items, errors } : { items }, + incrementalDataRecords, + }); + } + this._enqueue(result.errors === undefined + ? { streamRecord } + : { + streamRecord, + errors: result.errors, + }); + return; + } + items.push(result.item); + if (result.errors !== undefined) { + errors.push(...result.errors); + } + if (result.incrementalDataRecords !== undefined) { + incrementalDataRecords.push(...result.incrementalDataRecords); + } + } + } + _enqueue(completed) { + this._completedQueue.push(completed); + const next = this._nextQueue.shift(); + if (next === undefined) { + return; + } + next(this.currentCompletedBatch()); + } +} +//# sourceMappingURL=IncrementalGraph.js.map \ No newline at end of file diff --git a/execution/IncrementalGraph.mjs.map b/execution/IncrementalGraph.mjs.map new file mode 100644 index 0000000000..3933798544 --- /dev/null +++ b/execution/IncrementalGraph.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"IncrementalGraph.js","sourceRoot":"","sources":["../../src/execution/IncrementalGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,2CAA0C;AACxE,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,oBAAoB,EAAE,4CAA2C;AAc1E,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,oBAAmB;AAE/E;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAQ3B;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,eAAe,CACb,sBAA4D;QAE5D,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAiB,CAAC;QACvD,IAAI,CAAC,0BAA0B,CAC7B,sBAAsB,EACtB,SAAS,EACT,qBAAqB,CACtB,CAAC;QACF,OAAO,IAAI,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC;IAC5D,CAAC;IAED,oCAAoC,CAClC,wBAAkD;QAElD,MAAM,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,GACrD,wBAAwB,CAAC;QAE3B,MAAM,uBAAuB,GAC3B,qBAAqB,CAAC,uBAAuB,CAAC;QAEhD,KAAK,MAAM,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;YAC7D,MAAM,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,GACzD,sBAAsB,CAAC;YACzB,sBAAsB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;YACrD,yBA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IACrC,CAAC;CACF","sourcesContent":["import { BoxedPromiseOrValue } from '../jsutils/BoxedPromiseOrValue.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isPromise } from '../jsutils/isPromise.js';\nimport { promiseWithResolvers } from '../jsutils/promiseWithResolvers.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n DeferredFragmentRecord,\n DeliveryGroup,\n IncrementalDataRecord,\n IncrementalDataRecordResult,\n PendingExecutionGroup,\n StreamItemRecord,\n StreamRecord,\n SuccessfulExecutionGroup,\n} from './types.js';\nimport { isDeferredFragmentRecord, isPendingExecutionGroup } from './types.js';\n\n/**\n * @internal\n */\nexport class IncrementalGraph {\n private _rootNodes: Set;\n\n private _completedQueue: Array;\n private _nextQueue: Array<\n (iterable: Iterable | undefined) => void\n >;\n\n constructor() {\n this._rootNodes = new Set();\n this._completedQueue = [];\n this._nextQueue = [];\n }\n\n getNewRootNodes(\n incrementalDataRecords: ReadonlyArray,\n ): ReadonlyArray {\n const initialResultChildren = new Set();\n this._addIncrementalDataRecords(\n incrementalDataRecords,\n undefined,\n initialResultChildren,\n );\n return this._promoteNonEmptyToRoot(initialResultChildren);\n }\n\n addCompletedSuccessfulExecutionGroup(\n successfulExecutionGroup: SuccessfulExecutionGroup,\n ): void {\n const { pendingExecutionGroup, incrementalDataRecords } =\n successfulExecutionGroup;\n\n const deferredFragmentRecords =\n pendingExecutionGroup.deferredFragmentRecords;\n\n for (const deferredFragmentRecord of deferredFragmentRecords) {\n const { pendingExecutionGroups, successfulExecutionGroups } =\n deferredFragmentRecord;\n pendingExecutionGroups.delete(pendingExecutionGroup);\n successfulExecutionGroups.add(successfulExecutionGroup);\n }\n\n if (incrementalDataRecords !== undefined) {\n this._addIncrementalDataRecords(\n incrementalDataRecords,\n deferredFragmentRecords,\n );\n }\n }\n\n *currentCompletedBatch(): Generator {\n let completed;\n while ((completed = this._completedQueue.shift()) !== undefined) {\n yield completed;\n }\n if (this._rootNodes.size === 0) {\n for (const resolve of this._nextQueue) {\n resolve(undefined);\n }\n }\n }\n\n nextCompletedBatch(): Promise<\n Iterable | undefined\n > {\n const { promise, resolve } = promiseWithResolvers<\n Iterable | undefined\n >();\n this._nextQueue.push(resolve);\n return promise;\n }\n\n abort(): void {\n for (const resolve of this._nextQueue) {\n resolve(undefined);\n }\n }\n\n hasNext(): boolean {\n return this._rootNodes.size > 0;\n }\n\n completeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord):\n | {\n newRootNodes: ReadonlyArray;\n successfulExecutionGroups: ReadonlyArray;\n }\n | undefined {\n if (\n !this._rootNodes.has(deferredFragmentRecord) ||\n deferredFragmentRecord.pendingExecutionGroups.size > 0\n ) {\n return;\n }\n const successfulExecutionGroups = Array.from(\n deferredFragmentRecord.successfulExecutionGroups,\n );\n this._rootNodes.delete(deferredFragmentRecord);\n for (const successfulExecutionGroup of successfulExecutionGroups) {\n for (const otherDeferredFragmentRecord of successfulExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n otherDeferredFragmentRecord.successfulExecutionGroups.delete(\n successfulExecutionGroup,\n );\n }\n }\n const newRootNodes = this._promoteNonEmptyToRoot(\n deferredFragmentRecord.children,\n );\n return { newRootNodes, successfulExecutionGroups };\n }\n\n removeDeferredFragment(\n deferredFragmentRecord: DeferredFragmentRecord,\n ): boolean {\n if (!this._rootNodes.has(deferredFragmentRecord)) {\n return false;\n }\n this._rootNodes.delete(deferredFragmentRecord);\n return true;\n }\n\n removeStream(streamRecord: StreamRecord): void {\n this._rootNodes.delete(streamRecord);\n }\n\n private _addIncrementalDataRecords(\n incrementalDataRecords: ReadonlyArray,\n parents: ReadonlyArray | undefined,\n initialResultChildren?: Set,\n ): void {\n for (const incrementalDataRecord of incrementalDataRecords) {\n if (isPendingExecutionGroup(incrementalDataRecord)) {\n for (const deferredFragmentRecord of incrementalDataRecord.deferredFragmentRecords) {\n this._addDeferredFragment(\n deferredFragmentRecord,\n initialResultChildren,\n );\n deferredFragmentRecord.pendingExecutionGroups.add(\n incrementalDataRecord,\n );\n }\n if (this._completesRootNode(incrementalDataRecord)) {\n this._onExecutionGroup(incrementalDataRecord);\n }\n } else if (parents === undefined) {\n invariant(initialResultChildren !== undefined);\n initialResultChildren.add(incrementalDataRecord);\n } else {\n for (const parent of parents) {\n this._addDeferredFragment(parent, initialResultChildren);\n parent.children.add(incrementalDataRecord);\n }\n }\n }\n }\n\n private _promoteNonEmptyToRoot(\n maybeEmptyNewRootNodes: Set,\n ): ReadonlyArray {\n const newRootNodes: Array = [];\n for (const node of maybeEmptyNewRootNodes) {\n if (isDeferredFragmentRecord(node)) {\n if (node.pendingExecutionGroups.size > 0) {\n for (const pendingExecutionGroup of node.pendingExecutionGroups) {\n if (!this._completesRootNode(pendingExecutionGroup)) {\n this._onExecutionGroup(pendingExecutionGroup);\n }\n }\n this._rootNodes.add(node);\n newRootNodes.push(node);\n continue;\n }\n for (const child of node.children) {\n maybeEmptyNewRootNodes.add(child);\n }\n } else {\n this._rootNodes.add(node);\n newRootNodes.push(node);\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._onStreamItems(node);\n }\n }\n return newRootNodes;\n }\n\n private _completesRootNode(\n pendingExecutionGroup: PendingExecutionGroup,\n ): boolean {\n return pendingExecutionGroup.deferredFragmentRecords.some(\n (deferredFragmentRecord) => this._rootNodes.has(deferredFragmentRecord),\n );\n }\n\n private _addDeferredFragment(\n deferredFragmentRecord: DeferredFragmentRecord,\n initialResultChildren: Set | undefined,\n ): void {\n if (this._rootNodes.has(deferredFragmentRecord)) {\n return;\n }\n const parent = deferredFragmentRecord.parent;\n if (parent === undefined) {\n invariant(initialResultChildren !== undefined);\n initialResultChildren.add(deferredFragmentRecord);\n return;\n }\n parent.children.add(deferredFragmentRecord);\n this._addDeferredFragment(parent, initialResultChildren);\n }\n\n private _onExecutionGroup(\n pendingExecutionGroup: PendingExecutionGroup,\n ): void {\n let completedExecutionGroup = pendingExecutionGroup.result;\n if (!(completedExecutionGroup instanceof BoxedPromiseOrValue)) {\n completedExecutionGroup = completedExecutionGroup();\n }\n const value = completedExecutionGroup.value;\n if (isPromise(value)) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n value.then((resolved) => this._enqueue(resolved));\n } else {\n this._enqueue(value);\n }\n }\n\n private async _onStreamItems(streamRecord: StreamRecord): Promise {\n let items: Array = [];\n let errors: Array = [];\n let incrementalDataRecords: Array = [];\n const streamItemQueue = streamRecord.streamItemQueue;\n let streamItemRecord: StreamItemRecord | undefined;\n while ((streamItemRecord = streamItemQueue.shift()) !== undefined) {\n let result =\n streamItemRecord instanceof BoxedPromiseOrValue\n ? streamItemRecord.value\n : streamItemRecord().value;\n if (isPromise(result)) {\n if (items.length > 0) {\n this._enqueue({\n streamRecord,\n result:\n // TODO add additional test case or rework for coverage\n errors.length > 0 /* c8 ignore start */\n ? { items, errors } /* c8 ignore stop */\n : { items },\n incrementalDataRecords,\n });\n items = [];\n errors = [];\n incrementalDataRecords = [];\n }\n // eslint-disable-next-line no-await-in-loop\n result = await result;\n // wait an additional tick to coalesce resolving additional promises\n // within the queue\n // eslint-disable-next-line no-await-in-loop\n await Promise.resolve();\n }\n if (result.item === undefined) {\n if (items.length > 0) {\n this._enqueue({\n streamRecord,\n result: errors.length > 0 ? { items, errors } : { items },\n incrementalDataRecords,\n });\n }\n this._enqueue(\n result.errors === undefined\n ? { streamRecord }\n : {\n streamRecord,\n errors: result.errors,\n },\n );\n return;\n }\n items.push(result.item);\n if (result.errors !== undefined) {\n errors.push(...result.errors);\n }\n if (result.incrementalDataRecords !== undefined) {\n incrementalDataRecords.push(...result.incrementalDataRecords);\n }\n }\n }\n\n private _enqueue(completed: IncrementalDataRecordResult): void {\n this._completedQueue.push(completed);\n const next = this._nextQueue.shift();\n if (next === undefined) {\n return;\n }\n next(this.currentCompletedBatch());\n }\n}\n"]} \ No newline at end of file diff --git a/execution/IncrementalPublisher.d.ts b/execution/IncrementalPublisher.d.ts new file mode 100644 index 0000000000..f00c96dc5a --- /dev/null +++ b/execution/IncrementalPublisher.d.ts @@ -0,0 +1,10 @@ +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { GraphQLError } from '../error/GraphQLError.js'; +import type { AbortSignalListener } from './AbortSignalListener.js'; +import type { CancellableStreamRecord, ExperimentalIncrementalExecutionResults, IncrementalDataRecord } from './types.js'; +export declare function buildIncrementalResponse(context: IncrementalPublisherContext, result: ObjMap, errors: ReadonlyArray | undefined, incrementalDataRecords: ReadonlyArray): ExperimentalIncrementalExecutionResults; +interface IncrementalPublisherContext { + abortSignalListener: AbortSignalListener | undefined; + cancellableStreams: Set | undefined; +} +export {}; diff --git a/execution/IncrementalPublisher.js b/execution/IncrementalPublisher.js new file mode 100644 index 0000000000..f5c796a47a --- /dev/null +++ b/execution/IncrementalPublisher.js @@ -0,0 +1,259 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.buildIncrementalResponse = buildIncrementalResponse; +const invariant_js_1 = require("../jsutils/invariant.js"); +const Path_js_1 = require("../jsutils/Path.js"); +const IncrementalGraph_js_1 = require("./IncrementalGraph.js"); +const types_js_1 = require("./types.js"); +function buildIncrementalResponse(context, result, errors, incrementalDataRecords) { + const incrementalPublisher = new IncrementalPublisher(context); + return incrementalPublisher.buildResponse(result, errors, incrementalDataRecords); +} +/** + * This class is used to publish incremental results to the client, enabling semi-concurrent + * execution while preserving result order. + * + * @internal + */ +class IncrementalPublisher { + constructor(context) { + this._context = context; + this._nextId = 0; + this._incrementalGraph = new IncrementalGraph_js_1.IncrementalGraph(); + } + buildResponse(data, errors, incrementalDataRecords) { + const newRootNodes = this._incrementalGraph.getNewRootNodes(incrementalDataRecords); + const pending = this._toPendingResults(newRootNodes); + const initialResult = errors === undefined + ? { data, pending, hasNext: true } + : { errors, data, pending, hasNext: true }; + return { + initialResult, + subsequentResults: this._subscribe(), + }; + } + _toPendingResults(newRootNodes) { + const pendingResults = []; + for (const node of newRootNodes) { + const id = String(this._getNextId()); + node.id = id; + const pendingResult = { + id, + path: (0, Path_js_1.pathToArray)(node.path), + }; + if (node.label !== undefined) { + pendingResult.label = node.label; + } + pendingResults.push(pendingResult); + } + return pendingResults; + } + _getNextId() { + return String(this._nextId++); + } + _subscribe() { + let isDone = false; + const _next = async () => { + if (isDone) { + this._context.abortSignalListener?.disconnect(); + await this._returnAsyncIteratorsIgnoringErrors(); + return { value: undefined, done: true }; + } + const context = { + pending: [], + incremental: [], + completed: [], + }; + let batch = this._incrementalGraph.currentCompletedBatch(); + do { + for (const completedResult of batch) { + this._handleCompletedIncrementalData(completedResult, context); + } + const { incremental, completed } = context; + if (incremental.length > 0 || completed.length > 0) { + const hasNext = this._incrementalGraph.hasNext(); + if (!hasNext) { + isDone = true; + } + const subsequentIncrementalExecutionResult = { hasNext }; + const pending = context.pending; + if (pending.length > 0) { + subsequentIncrementalExecutionResult.pending = pending; + } + if (incremental.length > 0) { + subsequentIncrementalExecutionResult.incremental = incremental; + } + if (completed.length > 0) { + subsequentIncrementalExecutionResult.completed = completed; + } + return { value: subsequentIncrementalExecutionResult, done: false }; + } + // eslint-disable-next-line no-await-in-loop + batch = await this._incrementalGraph.nextCompletedBatch(); + } while (batch !== undefined); + // TODO: add test for this case + /* c8 ignore next */ + this._context.abortSignalListener?.disconnect(); + await this._returnAsyncIteratorsIgnoringErrors(); + return { value: undefined, done: true }; + }; + const _return = async () => { + isDone = true; + this._incrementalGraph.abort(); + await this._returnAsyncIterators(); + return { value: undefined, done: true }; + }; + const _throw = async (error) => { + isDone = true; + this._incrementalGraph.abort(); + await this._returnAsyncIterators(); + // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors + return Promise.reject(error); + }; + return { + [Symbol.asyncIterator]() { + return this; + }, + next: _next, + return: _return, + throw: _throw, + }; + } + _handleCompletedIncrementalData(completedIncrementalData, context) { + if ((0, types_js_1.isCompletedExecutionGroup)(completedIncrementalData)) { + this._handleCompletedExecutionGroup(completedIncrementalData, context); + } + else { + this._handleCompletedStreamItems(completedIncrementalData, context); + } + } + _handleCompletedExecutionGroup(completedExecutionGroup, context) { + if ((0, types_js_1.isFailedExecutionGroup)(completedExecutionGroup)) { + for (const deferredFragmentRecord of completedExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + const id = deferredFragmentRecord.id; + if (!this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)) { + // This can occur if multiple deferred grouped field sets error for a fragment. + continue; + } + (id !== undefined) || (0, invariant_js_1.invariant)(false); + context.completed.push({ + id, + errors: completedExecutionGroup.errors, + }); + } + return; + } + this._incrementalGraph.addCompletedSuccessfulExecutionGroup(completedExecutionGroup); + for (const deferredFragmentRecord of completedExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + const completion = this._incrementalGraph.completeDeferredFragment(deferredFragmentRecord); + if (completion === undefined) { + continue; + } + const id = deferredFragmentRecord.id; + (id !== undefined) || (0, invariant_js_1.invariant)(false); + const incremental = context.incremental; + const { newRootNodes, successfulExecutionGroups } = completion; + context.pending.push(...this._toPendingResults(newRootNodes)); + for (const successfulExecutionGroup of successfulExecutionGroups) { + const { bestId, subPath } = this._getBestIdAndSubPath(id, deferredFragmentRecord, successfulExecutionGroup); + const incrementalEntry = { + ...successfulExecutionGroup.result, + id: bestId, + }; + if (subPath !== undefined) { + incrementalEntry.subPath = subPath; + } + incremental.push(incrementalEntry); + } + context.completed.push({ id }); + } + } + _handleCompletedStreamItems(streamItemsResult, context) { + const streamRecord = streamItemsResult.streamRecord; + const id = streamRecord.id; + (id !== undefined) || (0, invariant_js_1.invariant)(false); + if (streamItemsResult.errors !== undefined) { + context.completed.push({ + id, + errors: streamItemsResult.errors, + }); + this._incrementalGraph.removeStream(streamRecord); + if ((0, types_js_1.isCancellableStreamRecord)(streamRecord)) { + (this._context.cancellableStreams !== undefined) || (0, invariant_js_1.invariant)(false); + this._context.cancellableStreams.delete(streamRecord); + streamRecord.earlyReturn().catch(() => { + /* c8 ignore next 1 */ + // ignore error + }); + } + } + else if (streamItemsResult.result === undefined) { + context.completed.push({ id }); + this._incrementalGraph.removeStream(streamRecord); + if ((0, types_js_1.isCancellableStreamRecord)(streamRecord)) { + (this._context.cancellableStreams !== undefined) || (0, invariant_js_1.invariant)(false); + this._context.cancellableStreams.delete(streamRecord); + } + } + else { + const incrementalEntry = { + id, + ...streamItemsResult.result, + }; + context.incremental.push(incrementalEntry); + const incrementalDataRecords = streamItemsResult.incrementalDataRecords; + if (incrementalDataRecords !== undefined) { + const newRootNodes = this._incrementalGraph.getNewRootNodes(incrementalDataRecords); + context.pending.push(...this._toPendingResults(newRootNodes)); + } + } + } + _getBestIdAndSubPath(initialId, initialDeferredFragmentRecord, completedExecutionGroup) { + let maxLength = (0, Path_js_1.pathToArray)(initialDeferredFragmentRecord.path).length; + let bestId = initialId; + for (const deferredFragmentRecord of completedExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + if (deferredFragmentRecord === initialDeferredFragmentRecord) { + continue; + } + const id = deferredFragmentRecord.id; + // TODO: add test case for when an fragment has not been released, but might be processed for the shortest path. + /* c8 ignore next 3 */ + if (id === undefined) { + continue; + } + const fragmentPath = (0, Path_js_1.pathToArray)(deferredFragmentRecord.path); + const length = fragmentPath.length; + if (length > maxLength) { + maxLength = length; + bestId = id; + } + } + const subPath = completedExecutionGroup.path.slice(maxLength); + return { + bestId, + subPath: subPath.length > 0 ? subPath : undefined, + }; + } + async _returnAsyncIterators() { + const cancellableStreams = this._context.cancellableStreams; + if (cancellableStreams === undefined) { + return; + } + const promises = []; + for (const streamRecord of cancellableStreams) { + if (streamRecord.earlyReturn !== undefined) { + promises.push(streamRecord.earlyReturn()); + } + } + await Promise.all(promises); + } + async _returnAsyncIteratorsIgnoringErrors() { + await this._returnAsyncIterators().catch(() => { + // Ignore errors + }); + } +} +//# sourceMappingURL=IncrementalPublisher.js.map \ No newline at end of file diff --git a/execution/IncrementalPublisher.js.map b/execution/IncrementalPublisher.js.map new file mode 100644 index 0000000000..bd44a17776 --- /dev/null +++ b/execution/IncrementalPublisher.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IncrementalPublisher.js","sourceRoot":"","sources":["../../src/execution/IncrementalPublisher.ts"],"names":[],"mappings":";;AA+BA,4DAYC;AA3CD,0DAAoD;AAEpD,gDAAiD;AAKjD,+DAAyD;AAkBzD,yCAIoB;AAEpB,SAAgB,wBAAwB,CACtC,OAAoC,EACpC,MAAuB,EACvB,MAA+C,EAC/C,sBAA4D;IAE5D,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/D,OAAO,oBAAoB,CAAC,aAAa,CACvC,MAAM,EACN,MAAM,EACN,sBAAsB,CACvB,CAAC;AACJ,CAAC;AAaD;;;;;GAKG;AACH,MAAM,oBAAoB;IAKxB,YAAY,OAAoC;QAC9C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,sCAAgB,EAAE,CAAC;IAClD,CAAC;IAED,aAAa,CACX,IAAqB,EACrB,MAA+C,EAC/C,sBAA4D;QAE5D,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,eAAe,CACzD,sBAAsB,CACvB,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAErD,MAAM,aAAa,GACjB,MAAM,KAAK,SAAS;YAClB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;YAClC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAE/C,OAAO;YACL,aAAa;YACb,iBAAiB,EAAE,IAAI,CAAC,UAAU,EAAE;SACrC,CAAC;IACJ,CAAC;IAEO,iBAAiB,CACvB,YAA0C;QAE1C,MAAM,cAAc,GAAyB,EAAE,CAAC;QAChD,KAAK,MAAM,IAAI,IA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AAG,SAAS,EAAE,CAAC;gBACvB,SAAS,GAAG,MAAM,CAAC;gBACnB,MAAM,GAAG,EAAE,CAAC;YACd,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC9D,OAAO;YACL,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;SAClD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,qBAAqB;QACjC,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC5D,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO;QACT,CAAC;QACD,MAAM,QAAQ,GAA4B,EAAE,CAAC;QAC7C,KAAK,MAAM,YAAY,IAAI,kBAAkB,EAAE,CAAC;YAC9C,IAAI,YAAY,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC3C,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAEO,KAAK,CAAC,mCAAmC;QAC/C,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YAC5C,gBAAgB;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { pathToArray } from '../jsutils/Path.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type { AbortSignalListener } from './AbortSignalListener.js';\nimport { IncrementalGraph } from './IncrementalGraph.js';\nimport type {\n CancellableStreamRecord,\n CompletedExecutionGroup,\n CompletedResult,\n DeferredFragmentRecord,\n DeliveryGroup,\n ExperimentalIncrementalExecutionResults,\n IncrementalDataRecord,\n IncrementalDataRecordResult,\n IncrementalDeferResult,\n IncrementalResult,\n IncrementalStreamResult,\n InitialIncrementalExecutionResult,\n PendingResult,\n StreamItemsResult,\n SubsequentIncrementalExecutionResult,\n} from './types.js';\nimport {\n isCancellableStreamRecord,\n isCompletedExecutionGroup,\n isFailedExecutionGroup,\n} from './types.js';\n\nexport function buildIncrementalResponse(\n context: IncrementalPublisherContext,\n result: ObjMap,\n errors: ReadonlyArray | undefined,\n incrementalDataRecords: ReadonlyArray,\n): ExperimentalIncrementalExecutionResults {\n const incrementalPublisher = new IncrementalPublisher(context);\n return incrementalPublisher.buildResponse(\n result,\n errors,\n incrementalDataRecords,\n );\n}\n\ninterface IncrementalPublisherContext {\n abortSignalListener: AbortSignalListener | undefined;\n cancellableStreams: Set | undefined;\n}\n\ninterface SubsequentIncrementalExecutionResultContext {\n pending: Array;\n incremental: Array;\n completed: Array;\n}\n\n/**\n * This class is used to publish incremental results to the client, enabling semi-concurrent\n * execution while preserving result order.\n *\n * @internal\n */\nclass IncrementalPublisher {\n private _context: IncrementalPublisherContext;\n private _nextId: number;\n private _incrementalGraph: IncrementalGraph;\n\n constructor(context: IncrementalPublisherContext) {\n this._context = context;\n this._nextId = 0;\n this._incrementalGraph = new IncrementalGraph();\n }\n\n buildResponse(\n data: ObjMap,\n errors: ReadonlyArray | undefined,\n incrementalDataRecords: ReadonlyArray,\n ): ExperimentalIncrementalExecutionResults {\n const newRootNodes = this._incrementalGraph.getNewRootNodes(\n incrementalDataRecords,\n );\n\n const pending = this._toPendingResults(newRootNodes);\n\n const initialResult: InitialIncrementalExecutionResult =\n errors === undefined\n ? { data, pending, hasNext: true }\n : { errors, data, pending, hasNext: true };\n\n return {\n initialResult,\n subsequentResults: this._subscribe(),\n };\n }\n\n private _toPendingResults(\n newRootNodes: ReadonlyArray,\n ): Array {\n const pendingResults: Array = [];\n for (const node of newRootNodes) {\n const id = String(this._getNextId());\n node.id = id;\n const pendingResult: PendingResult = {\n id,\n path: pathToArray(node.path),\n };\n if (node.label !== undefined) {\n pendingResult.label = node.label;\n }\n pendingResults.push(pendingResult);\n }\n return pendingResults;\n }\n\n private _getNextId(): string {\n return String(this._nextId++);\n }\n\n private _subscribe(): AsyncGenerator<\n SubsequentIncrementalExecutionResult,\n void,\n void\n > {\n let isDone = false;\n\n const _next = async (): Promise<\n IteratorResult\n > => {\n if (isDone) {\n this._context.abortSignalListener?.disconnect();\n await this._returnAsyncIteratorsIgnoringErrors();\n return { value: undefined, done: true };\n }\n\n const context: SubsequentIncrementalExecutionResultContext = {\n pending: [],\n incremental: [],\n completed: [],\n };\n\n let batch: Iterable | undefined =\n this._incrementalGraph.currentCompletedBatch();\n do {\n for (const completedResult of batch) {\n this._handleCompletedIncrementalData(completedResult, context);\n }\n\n const { incremental, completed } = context;\n if (incremental.length > 0 || completed.length > 0) {\n const hasNext = this._incrementalGraph.hasNext();\n\n if (!hasNext) {\n isDone = true;\n }\n\n const subsequentIncrementalExecutionResult: SubsequentIncrementalExecutionResult =\n { hasNext };\n\n const pending = context.pending;\n if (pending.length > 0) {\n subsequentIncrementalExecutionResult.pending = pending;\n }\n if (incremental.length > 0) {\n subsequentIncrementalExecutionResult.incremental = incremental;\n }\n if (completed.length > 0) {\n subsequentIncrementalExecutionResult.completed = completed;\n }\n\n return { value: subsequentIncrementalExecutionResult, done: false };\n }\n\n // eslint-disable-next-line no-await-in-loop\n batch = await this._incrementalGraph.nextCompletedBatch();\n } while (batch !== undefined);\n\n // TODO: add test for this case\n /* c8 ignore next */\n this._context.abortSignalListener?.disconnect();\n await this._returnAsyncIteratorsIgnoringErrors();\n return { value: undefined, done: true };\n };\n\n const _return = async (): Promise<\n IteratorResult\n > => {\n isDone = true;\n this._incrementalGraph.abort();\n await this._returnAsyncIterators();\n return { value: undefined, done: true };\n };\n\n const _throw = async (\n error?: unknown,\n ): Promise> => {\n isDone = true;\n this._incrementalGraph.abort();\n await this._returnAsyncIterators();\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return Promise.reject(error);\n };\n\n return {\n [Symbol.asyncIterator]() {\n return this;\n },\n next: _next,\n return: _return,\n throw: _throw,\n };\n }\n\n private _handleCompletedIncrementalData(\n completedIncrementalData: IncrementalDataRecordResult,\n context: SubsequentIncrementalExecutionResultContext,\n ): void {\n if (isCompletedExecutionGroup(completedIncrementalData)) {\n this._handleCompletedExecutionGroup(completedIncrementalData, context);\n } else {\n this._handleCompletedStreamItems(completedIncrementalData, context);\n }\n }\n\n private _handleCompletedExecutionGroup(\n completedExecutionGroup: CompletedExecutionGroup,\n context: SubsequentIncrementalExecutionResultContext,\n ): void {\n if (isFailedExecutionGroup(completedExecutionGroup)) {\n for (const deferredFragmentRecord of completedExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n const id = deferredFragmentRecord.id;\n if (\n !this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)\n ) {\n // This can occur if multiple deferred grouped field sets error for a fragment.\n continue;\n }\n invariant(id !== undefined);\n context.completed.push({\n id,\n errors: completedExecutionGroup.errors,\n });\n }\n return;\n }\n\n this._incrementalGraph.addCompletedSuccessfulExecutionGroup(\n completedExecutionGroup,\n );\n\n for (const deferredFragmentRecord of completedExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n const completion = this._incrementalGraph.completeDeferredFragment(\n deferredFragmentRecord,\n );\n if (completion === undefined) {\n continue;\n }\n const id = deferredFragmentRecord.id;\n invariant(id !== undefined);\n const incremental = context.incremental;\n const { newRootNodes, successfulExecutionGroups } = completion;\n context.pending.push(...this._toPendingResults(newRootNodes));\n for (const successfulExecutionGroup of successfulExecutionGroups) {\n const { bestId, subPath } = this._getBestIdAndSubPath(\n id,\n deferredFragmentRecord,\n successfulExecutionGroup,\n );\n const incrementalEntry: IncrementalDeferResult = {\n ...successfulExecutionGroup.result,\n id: bestId,\n };\n if (subPath !== undefined) {\n incrementalEntry.subPath = subPath;\n }\n incremental.push(incrementalEntry);\n }\n context.completed.push({ id });\n }\n }\n\n private _handleCompletedStreamItems(\n streamItemsResult: StreamItemsResult,\n context: SubsequentIncrementalExecutionResultContext,\n ): void {\n const streamRecord = streamItemsResult.streamRecord;\n const id = streamRecord.id;\n invariant(id !== undefined);\n if (streamItemsResult.errors !== undefined) {\n context.completed.push({\n id,\n errors: streamItemsResult.errors,\n });\n this._incrementalGraph.removeStream(streamRecord);\n if (isCancellableStreamRecord(streamRecord)) {\n invariant(this._context.cancellableStreams !== undefined);\n this._context.cancellableStreams.delete(streamRecord);\n streamRecord.earlyReturn().catch(() => {\n /* c8 ignore next 1 */\n // ignore error\n });\n }\n } else if (streamItemsResult.result === undefined) {\n context.completed.push({ id });\n this._incrementalGraph.removeStream(streamRecord);\n if (isCancellableStreamRecord(streamRecord)) {\n invariant(this._context.cancellableStreams !== undefined);\n this._context.cancellableStreams.delete(streamRecord);\n }\n } else {\n const incrementalEntry: IncrementalStreamResult = {\n id,\n ...streamItemsResult.result,\n };\n\n context.incremental.push(incrementalEntry);\n\n const incrementalDataRecords = streamItemsResult.incrementalDataRecords;\n if (incrementalDataRecords !== undefined) {\n const newRootNodes = this._incrementalGraph.getNewRootNodes(\n incrementalDataRecords,\n );\n context.pending.push(...this._toPendingResults(newRootNodes));\n }\n }\n }\n\n private _getBestIdAndSubPath(\n initialId: string,\n initialDeferredFragmentRecord: DeferredFragmentRecord,\n completedExecutionGroup: CompletedExecutionGroup,\n ): { bestId: string; subPath: ReadonlyArray | undefined } {\n let maxLength = pathToArray(initialDeferredFragmentRecord.path).length;\n let bestId = initialId;\n\n for (const deferredFragmentRecord of completedExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n if (deferredFragmentRecord === initialDeferredFragmentRecord) {\n continue;\n }\n const id = deferredFragmentRecord.id;\n // TODO: add test case for when an fragment has not been released, but might be processed for the shortest path.\n /* c8 ignore next 3 */\n if (id === undefined) {\n continue;\n }\n const fragmentPath = pathToArray(deferredFragmentRecord.path);\n const length = fragmentPath.length;\n if (length > maxLength) {\n maxLength = length;\n bestId = id;\n }\n }\n const subPath = completedExecutionGroup.path.slice(maxLength);\n return {\n bestId,\n subPath: subPath.length > 0 ? subPath : undefined,\n };\n }\n\n private async _returnAsyncIterators(): Promise {\n const cancellableStreams = this._context.cancellableStreams;\n if (cancellableStreams === undefined) {\n return;\n }\n const promises: Array> = [];\n for (const streamRecord of cancellableStreams) {\n if (streamRecord.earlyReturn !== undefined) {\n promises.push(streamRecord.earlyReturn());\n }\n }\n await Promise.all(promises);\n }\n\n private async _returnAsyncIteratorsIgnoringErrors(): Promise {\n await this._returnAsyncIterators().catch(() => {\n // Ignore errors\n });\n }\n}\n"]} \ No newline at end of file diff --git a/execution/IncrementalPublisher.mjs b/execution/IncrementalPublisher.mjs new file mode 100644 index 0000000000..b85ebe3293 --- /dev/null +++ b/execution/IncrementalPublisher.mjs @@ -0,0 +1,256 @@ +import { invariant } from "../jsutils/invariant.mjs"; +import { pathToArray } from "../jsutils/Path.mjs"; +import { IncrementalGraph } from "./IncrementalGraph.mjs"; +import { isCancellableStreamRecord, isCompletedExecutionGroup, isFailedExecutionGroup, } from "./types.mjs"; +export function buildIncrementalResponse(context, result, errors, incrementalDataRecords) { + const incrementalPublisher = new IncrementalPublisher(context); + return incrementalPublisher.buildResponse(result, errors, incrementalDataRecords); +} +/** + * This class is used to publish incremental results to the client, enabling semi-concurrent + * execution while preserving result order. + * + * @internal + */ +class IncrementalPublisher { + constructor(context) { + this._context = context; + this._nextId = 0; + this._incrementalGraph = new IncrementalGraph(); + } + buildResponse(data, errors, incrementalDataRecords) { + const newRootNodes = this._incrementalGraph.getNewRootNodes(incrementalDataRecords); + const pending = this._toPendingResults(newRootNodes); + const initialResult = errors === undefined + ? { data, pending, hasNext: true } + : { errors, data, pending, hasNext: true }; + return { + initialResult, + subsequentResults: this._subscribe(), + }; + } + _toPendingResults(newRootNodes) { + const pendingResults = []; + for (const node of newRootNodes) { + const id = String(this._getNextId()); + node.id = id; + const pendingResult = { + id, + path: pathToArray(node.path), + }; + if (node.label !== undefined) { + pendingResult.label = node.label; + } + pendingResults.push(pendingResult); + } + return pendingResults; + } + _getNextId() { + return String(this._nextId++); + } + _subscribe() { + let isDone = false; + const _next = async () => { + if (isDone) { + this._context.abortSignalListener?.disconnect(); + await this._returnAsyncIteratorsIgnoringErrors(); + return { value: undefined, done: true }; + } + const context = { + pending: [], + incremental: [], + completed: [], + }; + let batch = this._incrementalGraph.currentCompletedBatch(); + do { + for (const completedResult of batch) { + this._handleCompletedIncrementalData(completedResult, context); + } + const { incremental, completed } = context; + if (incremental.length > 0 || completed.length > 0) { + const hasNext = this._incrementalGraph.hasNext(); + if (!hasNext) { + isDone = true; + } + const subsequentIncrementalExecutionResult = { hasNext }; + const pending = context.pending; + if (pending.length > 0) { + subsequentIncrementalExecutionResult.pending = pending; + } + if (incremental.length > 0) { + subsequentIncrementalExecutionResult.incremental = incremental; + } + if (completed.length > 0) { + subsequentIncrementalExecutionResult.completed = completed; + } + return { value: subsequentIncrementalExecutionResult, done: false }; + } + // eslint-disable-next-line no-await-in-loop + batch = await this._incrementalGraph.nextCompletedBatch(); + } while (batch !== undefined); + // TODO: add test for this case + /* c8 ignore next */ + this._context.abortSignalListener?.disconnect(); + await this._returnAsyncIteratorsIgnoringErrors(); + return { value: undefined, done: true }; + }; + const _return = async () => { + isDone = true; + this._incrementalGraph.abort(); + await this._returnAsyncIterators(); + return { value: undefined, done: true }; + }; + const _throw = async (error) => { + isDone = true; + this._incrementalGraph.abort(); + await this._returnAsyncIterators(); + // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors + return Promise.reject(error); + }; + return { + [Symbol.asyncIterator]() { + return this; + }, + next: _next, + return: _return, + throw: _throw, + }; + } + _handleCompletedIncrementalData(completedIncrementalData, context) { + if (isCompletedExecutionGroup(completedIncrementalData)) { + this._handleCompletedExecutionGroup(completedIncrementalData, context); + } + else { + this._handleCompletedStreamItems(completedIncrementalData, context); + } + } + _handleCompletedExecutionGroup(completedExecutionGroup, context) { + if (isFailedExecutionGroup(completedExecutionGroup)) { + for (const deferredFragmentRecord of completedExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + const id = deferredFragmentRecord.id; + if (!this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)) { + // This can occur if multiple deferred grouped field sets error for a fragment. + continue; + } + (id !== undefined) || invariant(false); + context.completed.push({ + id, + errors: completedExecutionGroup.errors, + }); + } + return; + } + this._incrementalGraph.addCompletedSuccessfulExecutionGroup(completedExecutionGroup); + for (const deferredFragmentRecord of completedExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + const completion = this._incrementalGraph.completeDeferredFragment(deferredFragmentRecord); + if (completion === undefined) { + continue; + } + const id = deferredFragmentRecord.id; + (id !== undefined) || invariant(false); + const incremental = context.incremental; + const { newRootNodes, successfulExecutionGroups } = completion; + context.pending.push(...this._toPendingResults(newRootNodes)); + for (const successfulExecutionGroup of successfulExecutionGroups) { + const { bestId, subPath } = this._getBestIdAndSubPath(id, deferredFragmentRecord, successfulExecutionGroup); + const incrementalEntry = { + ...successfulExecutionGroup.result, + id: bestId, + }; + if (subPath !== undefined) { + incrementalEntry.subPath = subPath; + } + incremental.push(incrementalEntry); + } + context.completed.push({ id }); + } + } + _handleCompletedStreamItems(streamItemsResult, context) { + const streamRecord = streamItemsResult.streamRecord; + const id = streamRecord.id; + (id !== undefined) || invariant(false); + if (streamItemsResult.errors !== undefined) { + context.completed.push({ + id, + errors: streamItemsResult.errors, + }); + this._incrementalGraph.removeStream(streamRecord); + if (isCancellableStreamRecord(streamRecord)) { + (this._context.cancellableStreams !== undefined) || invariant(false); + this._context.cancellableStreams.delete(streamRecord); + streamRecord.earlyReturn().catch(() => { + /* c8 ignore next 1 */ + // ignore error + }); + } + } + else if (streamItemsResult.result === undefined) { + context.completed.push({ id }); + this._incrementalGraph.removeStream(streamRecord); + if (isCancellableStreamRecord(streamRecord)) { + (this._context.cancellableStreams !== undefined) || invariant(false); + this._context.cancellableStreams.delete(streamRecord); + } + } + else { + const incrementalEntry = { + id, + ...streamItemsResult.result, + }; + context.incremental.push(incrementalEntry); + const incrementalDataRecords = streamItemsResult.incrementalDataRecords; + if (incrementalDataRecords !== undefined) { + const newRootNodes = this._incrementalGraph.getNewRootNodes(incrementalDataRecords); + context.pending.push(...this._toPendingResults(newRootNodes)); + } + } + } + _getBestIdAndSubPath(initialId, initialDeferredFragmentRecord, completedExecutionGroup) { + let maxLength = pathToArray(initialDeferredFragmentRecord.path).length; + let bestId = initialId; + for (const deferredFragmentRecord of completedExecutionGroup + .pendingExecutionGroup.deferredFragmentRecords) { + if (deferredFragmentRecord === initialDeferredFragmentRecord) { + continue; + } + const id = deferredFragmentRecord.id; + // TODO: add test case for when an fragment has not been released, but might be processed for the shortest path. + /* c8 ignore next 3 */ + if (id === undefined) { + continue; + } + const fragmentPath = pathToArray(deferredFragmentRecord.path); + const length = fragmentPath.length; + if (length > maxLength) { + maxLength = length; + bestId = id; + } + } + const subPath = completedExecutionGroup.path.slice(maxLength); + return { + bestId, + subPath: subPath.length > 0 ? subPath : undefined, + }; + } + async _returnAsyncIterators() { + const cancellableStreams = this._context.cancellableStreams; + if (cancellableStreams === undefined) { + return; + } + const promises = []; + for (const streamRecord of cancellableStreams) { + if (streamRecord.earlyReturn !== undefined) { + promises.push(streamRecord.earlyReturn()); + } + } + await Promise.all(promises); + } + async _returnAsyncIteratorsIgnoringErrors() { + await this._returnAsyncIterators().catch(() => { + // Ignore errors + }); + } +} +//# sourceMappingURL=IncrementalPublisher.js.map \ No newline at end of file diff --git a/execution/IncrementalPublisher.mjs.map b/execution/IncrementalPublisher.mjs.map new file mode 100644 index 0000000000..fa78e75d48 --- /dev/null +++ b/execution/IncrementalPublisher.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"IncrementalPublisher.js","sourceRoot":"","sources":["../../src/execution/IncrementalPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAE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;YACd,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC9D,OAAO;YACL,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;SAClD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,qBAAqB;QACjC,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC5D,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO;QACT,CAAC;QACD,MAAM,QAAQ,GAA4B,EAAE,CAAC;QAC7C,KAAK,MAAM,YAAY,IAAI,kBAAkB,EAAE,CAAC;YAC9C,IAAI,YAAY,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC3C,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAEO,KAAK,CAAC,mCAAmC;QAC/C,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YAC5C,gBAAgB;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { pathToArray } from '../jsutils/Path.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type { AbortSignalListener } from './AbortSignalListener.js';\nimport { IncrementalGraph } from './IncrementalGraph.js';\nimport type {\n CancellableStreamRecord,\n CompletedExecutionGroup,\n CompletedResult,\n DeferredFragmentRecord,\n DeliveryGroup,\n ExperimentalIncrementalExecutionResults,\n IncrementalDataRecord,\n IncrementalDataRecordResult,\n IncrementalDeferResult,\n IncrementalResult,\n IncrementalStreamResult,\n InitialIncrementalExecutionResult,\n PendingResult,\n StreamItemsResult,\n SubsequentIncrementalExecutionResult,\n} from './types.js';\nimport {\n isCancellableStreamRecord,\n isCompletedExecutionGroup,\n isFailedExecutionGroup,\n} from './types.js';\n\nexport function buildIncrementalResponse(\n context: IncrementalPublisherContext,\n result: ObjMap,\n errors: ReadonlyArray | undefined,\n incrementalDataRecords: ReadonlyArray,\n): ExperimentalIncrementalExecutionResults {\n const incrementalPublisher = new IncrementalPublisher(context);\n return incrementalPublisher.buildResponse(\n result,\n errors,\n incrementalDataRecords,\n );\n}\n\ninterface IncrementalPublisherContext {\n abortSignalListener: AbortSignalListener | undefined;\n cancellableStreams: Set | undefined;\n}\n\ninterface SubsequentIncrementalExecutionResultContext {\n pending: Array;\n incremental: Array;\n completed: Array;\n}\n\n/**\n * This class is used to publish incremental results to the client, enabling semi-concurrent\n * execution while preserving result order.\n *\n * @internal\n */\nclass IncrementalPublisher {\n private _context: IncrementalPublisherContext;\n private _nextId: number;\n private _incrementalGraph: IncrementalGraph;\n\n constructor(context: IncrementalPublisherContext) {\n this._context = context;\n this._nextId = 0;\n this._incrementalGraph = new IncrementalGraph();\n }\n\n buildResponse(\n data: ObjMap,\n errors: ReadonlyArray | undefined,\n incrementalDataRecords: ReadonlyArray,\n ): ExperimentalIncrementalExecutionResults {\n const newRootNodes = this._incrementalGraph.getNewRootNodes(\n incrementalDataRecords,\n );\n\n const pending = this._toPendingResults(newRootNodes);\n\n const initialResult: InitialIncrementalExecutionResult =\n errors === undefined\n ? { data, pending, hasNext: true }\n : { errors, data, pending, hasNext: true };\n\n return {\n initialResult,\n subsequentResults: this._subscribe(),\n };\n }\n\n private _toPendingResults(\n newRootNodes: ReadonlyArray,\n ): Array {\n const pendingResults: Array = [];\n for (const node of newRootNodes) {\n const id = String(this._getNextId());\n node.id = id;\n const pendingResult: PendingResult = {\n id,\n path: pathToArray(node.path),\n };\n if (node.label !== undefined) {\n pendingResult.label = node.label;\n }\n pendingResults.push(pendingResult);\n }\n return pendingResults;\n }\n\n private _getNextId(): string {\n return String(this._nextId++);\n }\n\n private _subscribe(): AsyncGenerator<\n SubsequentIncrementalExecutionResult,\n void,\n void\n > {\n let isDone = false;\n\n const _next = async (): Promise<\n IteratorResult\n > => {\n if (isDone) {\n this._context.abortSignalListener?.disconnect();\n await this._returnAsyncIteratorsIgnoringErrors();\n return { value: undefined, done: true };\n }\n\n const context: SubsequentIncrementalExecutionResultContext = {\n pending: [],\n incremental: [],\n completed: [],\n };\n\n let batch: Iterable | undefined =\n this._incrementalGraph.currentCompletedBatch();\n do {\n for (const completedResult of batch) {\n this._handleCompletedIncrementalData(completedResult, context);\n }\n\n const { incremental, completed } = context;\n if (incremental.length > 0 || completed.length > 0) {\n const hasNext = this._incrementalGraph.hasNext();\n\n if (!hasNext) {\n isDone = true;\n }\n\n const subsequentIncrementalExecutionResult: SubsequentIncrementalExecutionResult =\n { hasNext };\n\n const pending = context.pending;\n if (pending.length > 0) {\n subsequentIncrementalExecutionResult.pending = pending;\n }\n if (incremental.length > 0) {\n subsequentIncrementalExecutionResult.incremental = incremental;\n }\n if (completed.length > 0) {\n subsequentIncrementalExecutionResult.completed = completed;\n }\n\n return { value: subsequentIncrementalExecutionResult, done: false };\n }\n\n // eslint-disable-next-line no-await-in-loop\n batch = await this._incrementalGraph.nextCompletedBatch();\n } while (batch !== undefined);\n\n // TODO: add test for this case\n /* c8 ignore next */\n this._context.abortSignalListener?.disconnect();\n await this._returnAsyncIteratorsIgnoringErrors();\n return { value: undefined, done: true };\n };\n\n const _return = async (): Promise<\n IteratorResult\n > => {\n isDone = true;\n this._incrementalGraph.abort();\n await this._returnAsyncIterators();\n return { value: undefined, done: true };\n };\n\n const _throw = async (\n error?: unknown,\n ): Promise> => {\n isDone = true;\n this._incrementalGraph.abort();\n await this._returnAsyncIterators();\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return Promise.reject(error);\n };\n\n return {\n [Symbol.asyncIterator]() {\n return this;\n },\n next: _next,\n return: _return,\n throw: _throw,\n };\n }\n\n private _handleCompletedIncrementalData(\n completedIncrementalData: IncrementalDataRecordResult,\n context: SubsequentIncrementalExecutionResultContext,\n ): void {\n if (isCompletedExecutionGroup(completedIncrementalData)) {\n this._handleCompletedExecutionGroup(completedIncrementalData, context);\n } else {\n this._handleCompletedStreamItems(completedIncrementalData, context);\n }\n }\n\n private _handleCompletedExecutionGroup(\n completedExecutionGroup: CompletedExecutionGroup,\n context: SubsequentIncrementalExecutionResultContext,\n ): void {\n if (isFailedExecutionGroup(completedExecutionGroup)) {\n for (const deferredFragmentRecord of completedExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n const id = deferredFragmentRecord.id;\n if (\n !this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)\n ) {\n // This can occur if multiple deferred grouped field sets error for a fragment.\n continue;\n }\n invariant(id !== undefined);\n context.completed.push({\n id,\n errors: completedExecutionGroup.errors,\n });\n }\n return;\n }\n\n this._incrementalGraph.addCompletedSuccessfulExecutionGroup(\n completedExecutionGroup,\n );\n\n for (const deferredFragmentRecord of completedExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n const completion = this._incrementalGraph.completeDeferredFragment(\n deferredFragmentRecord,\n );\n if (completion === undefined) {\n continue;\n }\n const id = deferredFragmentRecord.id;\n invariant(id !== undefined);\n const incremental = context.incremental;\n const { newRootNodes, successfulExecutionGroups } = completion;\n context.pending.push(...this._toPendingResults(newRootNodes));\n for (const successfulExecutionGroup of successfulExecutionGroups) {\n const { bestId, subPath } = this._getBestIdAndSubPath(\n id,\n deferredFragmentRecord,\n successfulExecutionGroup,\n );\n const incrementalEntry: IncrementalDeferResult = {\n ...successfulExecutionGroup.result,\n id: bestId,\n };\n if (subPath !== undefined) {\n incrementalEntry.subPath = subPath;\n }\n incremental.push(incrementalEntry);\n }\n context.completed.push({ id });\n }\n }\n\n private _handleCompletedStreamItems(\n streamItemsResult: StreamItemsResult,\n context: SubsequentIncrementalExecutionResultContext,\n ): void {\n const streamRecord = streamItemsResult.streamRecord;\n const id = streamRecord.id;\n invariant(id !== undefined);\n if (streamItemsResult.errors !== undefined) {\n context.completed.push({\n id,\n errors: streamItemsResult.errors,\n });\n this._incrementalGraph.removeStream(streamRecord);\n if (isCancellableStreamRecord(streamRecord)) {\n invariant(this._context.cancellableStreams !== undefined);\n this._context.cancellableStreams.delete(streamRecord);\n streamRecord.earlyReturn().catch(() => {\n /* c8 ignore next 1 */\n // ignore error\n });\n }\n } else if (streamItemsResult.result === undefined) {\n context.completed.push({ id });\n this._incrementalGraph.removeStream(streamRecord);\n if (isCancellableStreamRecord(streamRecord)) {\n invariant(this._context.cancellableStreams !== undefined);\n this._context.cancellableStreams.delete(streamRecord);\n }\n } else {\n const incrementalEntry: IncrementalStreamResult = {\n id,\n ...streamItemsResult.result,\n };\n\n context.incremental.push(incrementalEntry);\n\n const incrementalDataRecords = streamItemsResult.incrementalDataRecords;\n if (incrementalDataRecords !== undefined) {\n const newRootNodes = this._incrementalGraph.getNewRootNodes(\n incrementalDataRecords,\n );\n context.pending.push(...this._toPendingResults(newRootNodes));\n }\n }\n }\n\n private _getBestIdAndSubPath(\n initialId: string,\n initialDeferredFragmentRecord: DeferredFragmentRecord,\n completedExecutionGroup: CompletedExecutionGroup,\n ): { bestId: string; subPath: ReadonlyArray | undefined } {\n let maxLength = pathToArray(initialDeferredFragmentRecord.path).length;\n let bestId = initialId;\n\n for (const deferredFragmentRecord of completedExecutionGroup\n .pendingExecutionGroup.deferredFragmentRecords) {\n if (deferredFragmentRecord === initialDeferredFragmentRecord) {\n continue;\n }\n const id = deferredFragmentRecord.id;\n // TODO: add test case for when an fragment has not been released, but might be processed for the shortest path.\n /* c8 ignore next 3 */\n if (id === undefined) {\n continue;\n }\n const fragmentPath = pathToArray(deferredFragmentRecord.path);\n const length = fragmentPath.length;\n if (length > maxLength) {\n maxLength = length;\n bestId = id;\n }\n }\n const subPath = completedExecutionGroup.path.slice(maxLength);\n return {\n bestId,\n subPath: subPath.length > 0 ? subPath : undefined,\n };\n }\n\n private async _returnAsyncIterators(): Promise {\n const cancellableStreams = this._context.cancellableStreams;\n if (cancellableStreams === undefined) {\n return;\n }\n const promises: Array> = [];\n for (const streamRecord of cancellableStreams) {\n if (streamRecord.earlyReturn !== undefined) {\n promises.push(streamRecord.earlyReturn());\n }\n }\n await Promise.all(promises);\n }\n\n private async _returnAsyncIteratorsIgnoringErrors(): Promise {\n await this._returnAsyncIterators().catch(() => {\n // Ignore errors\n });\n }\n}\n"]} \ No newline at end of file diff --git a/execution/buildExecutionPlan.d.ts b/execution/buildExecutionPlan.d.ts new file mode 100644 index 0000000000..58370a8f4a --- /dev/null +++ b/execution/buildExecutionPlan.d.ts @@ -0,0 +1,7 @@ +import type { DeferUsage, GroupedFieldSet } from './collectFields.js'; +export type DeferUsageSet = ReadonlySet; +export interface ExecutionPlan { + groupedFieldSet: GroupedFieldSet; + newGroupedFieldSets: Map; +} +export declare function buildExecutionPlan(originalGroupedFieldSet: GroupedFieldSet, parentDeferUsages?: DeferUsageSet): ExecutionPlan; diff --git a/execution/buildExecutionPlan.js b/execution/buildExecutionPlan.js new file mode 100644 index 0000000000..1b68e0f1c5 --- /dev/null +++ b/execution/buildExecutionPlan.js @@ -0,0 +1,49 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.buildExecutionPlan = buildExecutionPlan; +const getBySet_js_1 = require("../jsutils/getBySet.js"); +const isSameSet_js_1 = require("../jsutils/isSameSet.js"); +function buildExecutionPlan(originalGroupedFieldSet, parentDeferUsages = new Set()) { + const groupedFieldSet = new Map(); + const newGroupedFieldSets = new Map(); + for (const [responseKey, fieldDetailsList] of originalGroupedFieldSet) { + const filteredDeferUsageSet = getFilteredDeferUsageSet(fieldDetailsList); + if ((0, isSameSet_js_1.isSameSet)(filteredDeferUsageSet, parentDeferUsages)) { + groupedFieldSet.set(responseKey, fieldDetailsList); + continue; + } + let newGroupedFieldSet = (0, getBySet_js_1.getBySet)(newGroupedFieldSets, filteredDeferUsageSet); + if (newGroupedFieldSet === undefined) { + newGroupedFieldSet = new Map(); + newGroupedFieldSets.set(filteredDeferUsageSet, newGroupedFieldSet); + } + newGroupedFieldSet.set(responseKey, fieldDetailsList); + } + return { + groupedFieldSet, + newGroupedFieldSets, + }; +} +function getFilteredDeferUsageSet(fieldDetailsList) { + const filteredDeferUsageSet = new Set(); + for (const fieldDetails of fieldDetailsList) { + const deferUsage = fieldDetails.deferUsage; + if (deferUsage === undefined) { + filteredDeferUsageSet.clear(); + return filteredDeferUsageSet; + } + filteredDeferUsageSet.add(deferUsage); + } + for (const deferUsage of filteredDeferUsageSet) { + let parentDeferUsage = deferUsage.parentDeferUsage; + while (parentDeferUsage !== undefined) { + if (filteredDeferUsageSet.has(parentDeferUsage)) { + filteredDeferUsageSet.delete(deferUsage); + break; + } + parentDeferUsage = parentDeferUsage.parentDeferUsage; + } + } + return filteredDeferUsageSet; +} +//# sourceMappingURL=buildExecutionPlan.js.map \ No newline at end of file diff --git a/execution/buildExecutionPlan.js.map b/execution/buildExecutionPlan.js.map new file mode 100644 index 0000000000..8e576b47e4 --- /dev/null +++ b/execution/buildExecutionPlan.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buildExecutionPlan.js","sourceRoot":"","sources":["../../src/execution/buildExecutionPlan.ts"],"names":[],"mappings":";;AAgBA,gDAgCC;AAhDD,wDAAkD;AAClD,0DAAoD;AAepD,SAAgB,kBAAkB,CAChC,uBAAwC,EACxC,oBAAmC,IAAI,GAAG,EAAc;IAExD,MAAM,eAAe,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC5D,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAGhC,CAAC;IACJ,KAAK,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,IAAI,uBAAuB,EAAE,CAAC;QACtE,MAAM,qBAAqB,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;QAEzE,IAAI,IAAA,wBAAS,E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CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC","sourcesContent":["import { getBySet } from '../jsutils/getBySet.js';\nimport { isSameSet } from '../jsutils/isSameSet.js';\n\nimport type {\n DeferUsage,\n FieldDetailsList,\n GroupedFieldSet,\n} from './collectFields.js';\n\nexport type DeferUsageSet = ReadonlySet;\n\nexport interface ExecutionPlan {\n groupedFieldSet: GroupedFieldSet;\n newGroupedFieldSets: Map;\n}\n\nexport function buildExecutionPlan(\n originalGroupedFieldSet: GroupedFieldSet,\n parentDeferUsages: DeferUsageSet = new Set(),\n): ExecutionPlan {\n const groupedFieldSet = new Map();\n const newGroupedFieldSets = new Map<\n DeferUsageSet,\n Map\n >();\n for (const [responseKey, fieldDetailsList] of originalGroupedFieldSet) {\n const filteredDeferUsageSet = getFilteredDeferUsageSet(fieldDetailsList);\n\n if (isSameSet(filteredDeferUsageSet, parentDeferUsages)) {\n groupedFieldSet.set(responseKey, fieldDetailsList);\n continue;\n }\n\n let newGroupedFieldSet = getBySet(\n newGroupedFieldSets,\n filteredDeferUsageSet,\n );\n if (newGroupedFieldSet === undefined) {\n newGroupedFieldSet = new Map();\n newGroupedFieldSets.set(filteredDeferUsageSet, newGroupedFieldSet);\n }\n newGroupedFieldSet.set(responseKey, fieldDetailsList);\n }\n\n return {\n groupedFieldSet,\n newGroupedFieldSets,\n };\n}\n\nfunction getFilteredDeferUsageSet(\n fieldDetailsList: FieldDetailsList,\n): ReadonlySet {\n const filteredDeferUsageSet = new Set();\n for (const fieldDetails of fieldDetailsList) {\n const deferUsage = fieldDetails.deferUsage;\n if (deferUsage === undefined) {\n filteredDeferUsageSet.clear();\n return filteredDeferUsageSet;\n }\n filteredDeferUsageSet.add(deferUsage);\n }\n\n for (const deferUsage of filteredDeferUsageSet) {\n let parentDeferUsage: DeferUsage | undefined = deferUsage.parentDeferUsage;\n while (parentDeferUsage !== undefined) {\n if (filteredDeferUsageSet.has(parentDeferUsage)) {\n filteredDeferUsageSet.delete(deferUsage);\n break;\n }\n parentDeferUsage = parentDeferUsage.parentDeferUsage;\n }\n }\n return filteredDeferUsageSet;\n}\n"]} \ No newline at end of file diff --git a/execution/buildExecutionPlan.mjs b/execution/buildExecutionPlan.mjs new file mode 100644 index 0000000000..aaabf24a23 --- /dev/null +++ b/execution/buildExecutionPlan.mjs @@ -0,0 +1,46 @@ +import { getBySet } from "../jsutils/getBySet.mjs"; +import { isSameSet } from "../jsutils/isSameSet.mjs"; +export function buildExecutionPlan(originalGroupedFieldSet, parentDeferUsages = new Set()) { + const groupedFieldSet = new Map(); + const newGroupedFieldSets = new Map(); + for (const [responseKey, fieldDetailsList] of originalGroupedFieldSet) { + const filteredDeferUsageSet = getFilteredDeferUsageSet(fieldDetailsList); + if (isSameSet(filteredDeferUsageSet, parentDeferUsages)) { + groupedFieldSet.set(responseKey, fieldDetailsList); + continue; + } + let newGroupedFieldSet = getBySet(newGroupedFieldSets, filteredDeferUsageSet); + if (newGroupedFieldSet === undefined) { + newGroupedFieldSet = new Map(); + newGroupedFieldSets.set(filteredDeferUsageSet, newGroupedFieldSet); + } + newGroupedFieldSet.set(responseKey, fieldDetailsList); + } + return { + groupedFieldSet, + newGroupedFieldSets, + }; +} +function getFilteredDeferUsageSet(fieldDetailsList) { + const filteredDeferUsageSet = new Set(); + for (const fieldDetails of fieldDetailsList) { + const deferUsage = fieldDetails.deferUsage; + if (deferUsage === undefined) { + filteredDeferUsageSet.clear(); + return filteredDeferUsageSet; + } + filteredDeferUsageSet.add(deferUsage); + } + for (const deferUsage of filteredDeferUsageSet) { + let parentDeferUsage = deferUsage.parentDeferUsage; + while (parentDeferUsage !== undefined) { + if (filteredDeferUsageSet.has(parentDeferUsage)) { + filteredDeferUsageSet.delete(deferUsage); + break; + } + parentDeferUsage = parentDeferUsage.parentDeferUsage; + } + } + return filteredDeferUsageSet; +} +//# sourceMappingURL=buildExecutionPlan.js.map \ No newline at end of file diff --git a/execution/buildExecutionPlan.mjs.map b/execution/buildExecutionPlan.mjs.map new file mode 100644 index 0000000000..d5e8038f86 --- /dev/null +++ b/execution/buildExecutionPlan.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"buildExecutionPlan.js","sourceRoot":"","sources":["../../src/execution/buildExecutionPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gCAA+B;AAClD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAepD,MAAM,UAAU,kBAAkB,CAChC,uBAAwC,EACxC,oBAAmC,IAAI,GAAG,EAAc;IAExD,MAAM,eAAe,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC5D,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAGhC,CAAC;IACJ,KAAK,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,IAAI,uBAAuB,EAAE,CAAC;QACtE,MAAM,qBAAqB,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;QAEzE,IAAI,SAAS,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,EAAE,CAAC;YACxD,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;YACnD,SAAS;QACX,CAAC;QAED,IAAI,kBAAkB,GAAG,QAAQ,CAC/B,mBAAmB,EACnB,qBAAqB,CACtB,CAAC;QACF,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACrC,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAC;YAC/B,mBAAmB,CAAC,GAAG,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAC;QACrE,CAAC;QACD,kBAAkB,CAAC,GAAG,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IACxD,CAAC;IAED,OAAO;QACL,eAAe;QACf,mBAAmB;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAC/B,gBAAkC;IAElC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAc,CAAC;IACpD,KAAK,MAAM,YAAY,IAAI,gBAAgB,EAAE,CAAC;QAC5C,MAAM,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;QAC3C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,qBAAqB,CAAC,KAAK,EAAE,CAAC;YAC9B,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QACD,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE,CAAC;QAC/C,IAAI,gBAAgB,GAA2B,UAAU,CAAC,gBAAgB,CAAC;QAC3E,OAAO,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACtC,IAAI,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAChD,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBACzC,MAAM;YACR,CAAC;YACD,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC;QACvD,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC","sourcesContent":["import { getBySet } from '../jsutils/getBySet.js';\nimport { isSameSet } from '../jsutils/isSameSet.js';\n\nimport type {\n DeferUsage,\n FieldDetailsList,\n GroupedFieldSet,\n} from './collectFields.js';\n\nexport type DeferUsageSet = ReadonlySet;\n\nexport interface ExecutionPlan {\n groupedFieldSet: GroupedFieldSet;\n newGroupedFieldSets: Map;\n}\n\nexport function buildExecutionPlan(\n originalGroupedFieldSet: GroupedFieldSet,\n parentDeferUsages: DeferUsageSet = new Set(),\n): ExecutionPlan {\n const groupedFieldSet = new Map();\n const newGroupedFieldSets = new Map<\n DeferUsageSet,\n Map\n >();\n for (const [responseKey, fieldDetailsList] of originalGroupedFieldSet) {\n const filteredDeferUsageSet = getFilteredDeferUsageSet(fieldDetailsList);\n\n if (isSameSet(filteredDeferUsageSet, parentDeferUsages)) {\n groupedFieldSet.set(responseKey, fieldDetailsList);\n continue;\n }\n\n let newGroupedFieldSet = getBySet(\n newGroupedFieldSets,\n filteredDeferUsageSet,\n );\n if (newGroupedFieldSet === undefined) {\n newGroupedFieldSet = new Map();\n newGroupedFieldSets.set(filteredDeferUsageSet, newGroupedFieldSet);\n }\n newGroupedFieldSet.set(responseKey, fieldDetailsList);\n }\n\n return {\n groupedFieldSet,\n newGroupedFieldSets,\n };\n}\n\nfunction getFilteredDeferUsageSet(\n fieldDetailsList: FieldDetailsList,\n): ReadonlySet {\n const filteredDeferUsageSet = new Set();\n for (const fieldDetails of fieldDetailsList) {\n const deferUsage = fieldDetails.deferUsage;\n if (deferUsage === undefined) {\n filteredDeferUsageSet.clear();\n return filteredDeferUsageSet;\n }\n filteredDeferUsageSet.add(deferUsage);\n }\n\n for (const deferUsage of filteredDeferUsageSet) {\n let parentDeferUsage: DeferUsage | undefined = deferUsage.parentDeferUsage;\n while (parentDeferUsage !== undefined) {\n if (filteredDeferUsageSet.has(parentDeferUsage)) {\n filteredDeferUsageSet.delete(deferUsage);\n break;\n }\n parentDeferUsage = parentDeferUsage.parentDeferUsage;\n }\n }\n return filteredDeferUsageSet;\n}\n"]} \ No newline at end of file diff --git a/execution/collectFields.d.ts b/execution/collectFields.d.ts new file mode 100644 index 0000000000..fa35bcd65d --- /dev/null +++ b/execution/collectFields.d.ts @@ -0,0 +1,59 @@ +import type { ObjMap, ReadOnlyObjMap } from '../jsutils/ObjMap.js'; +import type { ConstValueNode, DirectiveNode, FieldNode, FragmentDefinitionNode, SelectionSetNode } from '../language/ast.js'; +import type { GraphQLObjectType } from '../type/definition.js'; +import type { GraphQLSchema } from '../type/schema.js'; +import type { GraphQLVariableSignature } from './getVariableSignature.js'; +import type { VariableValues } from './values.js'; +export interface DeferUsage { + label: string | undefined; + parentDeferUsage: DeferUsage | undefined; +} +export interface FragmentVariableValues { + readonly sources: ReadOnlyObjMap; + readonly coerced: ReadOnlyObjMap; +} +interface FragmentVariableValueSource { + readonly signature: GraphQLVariableSignature; + readonly value?: ConstValueNode; + readonly fragmentVariableValues?: FragmentVariableValues; +} +export interface FieldDetails { + node: FieldNode; + deferUsage?: DeferUsage | undefined; + fragmentVariableValues?: FragmentVariableValues | undefined; +} +export type FieldDetailsList = ReadonlyArray; +export type GroupedFieldSet = ReadonlyMap; +export interface FragmentDetails { + definition: FragmentDefinitionNode; + variableSignatures?: ObjMap | undefined; +} +/** + * Given a selectionSet, collects all of the fields and returns them. + * + * CollectFields requires the "runtime type" of an object. For a field that + * returns an Interface or Union type, the "runtime type" will be the actual + * object type returned by that field. + * + * @internal + */ +export declare function collectFields(schema: GraphQLSchema, fragments: ObjMap, variableValues: VariableValues, runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode, hideSuggestions: boolean, forbidSkipAndInclude?: boolean): { + groupedFieldSet: GroupedFieldSet; + newDeferUsages: ReadonlyArray; + forbiddenDirectiveInstances: ReadonlyArray; +}; +/** + * Given an array of field nodes, collects all of the subfields of the passed + * in fields, and returns them at the end. + * + * CollectSubFields requires the "return type" of an object. For a field that + * returns an Interface or Union type, the "return type" will be the actual + * object type returned by that field. + * + * @internal + */ +export declare function collectSubfields(schema: GraphQLSchema, fragments: ObjMap, variableValues: VariableValues, returnType: GraphQLObjectType, fieldDetailsList: FieldDetailsList, hideSuggestions: boolean): { + groupedFieldSet: GroupedFieldSet; + newDeferUsages: ReadonlyArray; +}; +export {}; diff --git a/execution/collectFields.js b/execution/collectFields.js new file mode 100644 index 0000000000..6b4b7344a1 --- /dev/null +++ b/execution/collectFields.js @@ -0,0 +1,208 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.collectFields = collectFields; +exports.collectSubfields = collectSubfields; +const AccumulatorMap_js_1 = require("../jsutils/AccumulatorMap.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +const directives_js_1 = require("../type/directives.js"); +const typeFromAST_js_1 = require("../utilities/typeFromAST.js"); +const values_js_1 = require("./values.js"); +/** + * Given a selectionSet, collects all of the fields and returns them. + * + * CollectFields requires the "runtime type" of an object. For a field that + * returns an Interface or Union type, the "runtime type" will be the actual + * object type returned by that field. + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/max-params +function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, hideSuggestions, forbidSkipAndInclude = false) { + const groupedFieldSet = new AccumulatorMap_js_1.AccumulatorMap(); + const newDeferUsages = []; + const context = { + schema, + fragments, + variableValues, + runtimeType, + visitedFragmentNames: new Set(), + hideSuggestions, + forbiddenDirectiveInstances: [], + forbidSkipAndInclude, + }; + collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages); + return { + groupedFieldSet, + newDeferUsages, + forbiddenDirectiveInstances: context.forbiddenDirectiveInstances, + }; +} +/** + * Given an array of field nodes, collects all of the subfields of the passed + * in fields, and returns them at the end. + * + * CollectSubFields requires the "return type" of an object. For a field that + * returns an Interface or Union type, the "return type" will be the actual + * object type returned by that field. + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/max-params +function collectSubfields(schema, fragments, variableValues, returnType, fieldDetailsList, hideSuggestions) { + const context = { + schema, + fragments, + variableValues, + runtimeType: returnType, + visitedFragmentNames: new Set(), + hideSuggestions, + forbiddenDirectiveInstances: [], + forbidSkipAndInclude: false, + }; + const subGroupedFieldSet = new AccumulatorMap_js_1.AccumulatorMap(); + const newDeferUsages = []; + for (const fieldDetail of fieldDetailsList) { + const selectionSet = fieldDetail.node.selectionSet; + if (selectionSet) { + const { deferUsage, fragmentVariableValues } = fieldDetail; + collectFieldsImpl(context, selectionSet, subGroupedFieldSet, newDeferUsages, deferUsage, fragmentVariableValues); + } + } + return { + groupedFieldSet: subGroupedFieldSet, + newDeferUsages, + }; +} +// eslint-disable-next-line @typescript-eslint/max-params +function collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages, deferUsage, fragmentVariableValues) { + const { schema, fragments, variableValues, runtimeType, visitedFragmentNames, hideSuggestions, } = context; + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case kinds_js_1.Kind.FIELD: { + if (!shouldIncludeNode(context, selection, variableValues, fragmentVariableValues)) { + continue; + } + groupedFieldSet.add(getFieldEntryKey(selection), { + node: selection, + deferUsage, + fragmentVariableValues, + }); + break; + } + case kinds_js_1.Kind.INLINE_FRAGMENT: { + if (!shouldIncludeNode(context, selection, variableValues, fragmentVariableValues) || + !doesFragmentConditionMatch(schema, selection, runtimeType)) { + continue; + } + const newDeferUsage = getDeferUsage(variableValues, fragmentVariableValues, selection, deferUsage); + if (!newDeferUsage) { + collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, deferUsage, fragmentVariableValues); + } + else { + newDeferUsages.push(newDeferUsage); + collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, newDeferUsage, fragmentVariableValues); + } + break; + } + case kinds_js_1.Kind.FRAGMENT_SPREAD: { + const fragName = selection.name.value; + if (visitedFragmentNames.has(fragName) || + !shouldIncludeNode(context, selection, variableValues, fragmentVariableValues)) { + continue; + } + const fragment = fragments[fragName]; + if (fragment == null || + !doesFragmentConditionMatch(schema, fragment.definition, runtimeType)) { + continue; + } + const newDeferUsage = getDeferUsage(variableValues, fragmentVariableValues, selection, deferUsage); + const fragmentVariableSignatures = fragment.variableSignatures; + let newFragmentVariableValues; + if (fragmentVariableSignatures) { + newFragmentVariableValues = (0, values_js_1.getFragmentVariableValues)(selection, fragmentVariableSignatures, variableValues, fragmentVariableValues, hideSuggestions); + } + if (!newDeferUsage) { + visitedFragmentNames.add(fragName); + collectFieldsImpl(context, fragment.definition.selectionSet, groupedFieldSet, newDeferUsages, deferUsage, newFragmentVariableValues); + } + else { + newDeferUsages.push(newDeferUsage); + collectFieldsImpl(context, fragment.definition.selectionSet, groupedFieldSet, newDeferUsages, newDeferUsage, newFragmentVariableValues); + } + break; + } + } + } +} +/** + * Returns an object containing the `@defer` arguments if a field should be + * deferred based on the experimental flag, defer directive present and + * not disabled by the "if" argument. + */ +function getDeferUsage(variableValues, fragmentVariableValues, node, parentDeferUsage) { + const defer = (0, values_js_1.getDirectiveValues)(directives_js_1.GraphQLDeferDirective, node, variableValues, fragmentVariableValues); + if (!defer) { + return; + } + if (defer.if === false) { + return; + } + return { + label: typeof defer.label === 'string' ? defer.label : undefined, + parentDeferUsage, + }; +} +/** + * Determines if a field should be included based on the `@include` and `@skip` + * directives, where `@skip` has higher precedence than `@include`. + */ +function shouldIncludeNode(context, node, variableValues, fragmentVariableValues) { + const skipDirectiveNode = node.directives?.find((directive) => directive.name.value === directives_js_1.GraphQLSkipDirective.name); + if (skipDirectiveNode && context.forbidSkipAndInclude) { + context.forbiddenDirectiveInstances.push(skipDirectiveNode); + return false; + } + const skip = skipDirectiveNode + ? (0, values_js_1.getArgumentValues)(directives_js_1.GraphQLSkipDirective, skipDirectiveNode, variableValues, fragmentVariableValues, context.hideSuggestions) + : undefined; + if (skip?.if === true) { + return false; + } + const includeDirectiveNode = node.directives?.find((directive) => directive.name.value === directives_js_1.GraphQLIncludeDirective.name); + if (includeDirectiveNode && context.forbidSkipAndInclude) { + context.forbiddenDirectiveInstances.push(includeDirectiveNode); + return false; + } + const include = includeDirectiveNode + ? (0, values_js_1.getArgumentValues)(directives_js_1.GraphQLIncludeDirective, includeDirectiveNode, variableValues, fragmentVariableValues, context.hideSuggestions) + : undefined; + if (include?.if === false) { + return false; + } + return true; +} +/** + * Determines if a fragment is applicable to the given type. + */ +function doesFragmentConditionMatch(schema, fragment, type) { + const typeConditionNode = fragment.typeCondition; + if (!typeConditionNode) { + return true; + } + const conditionalType = (0, typeFromAST_js_1.typeFromAST)(schema, typeConditionNode); + if (conditionalType === type) { + return true; + } + if ((0, definition_js_1.isAbstractType)(conditionalType)) { + return schema.isSubType(conditionalType, type); + } + return false; +} +/** + * Implements the logic to compute the key of a given field's entry + */ +function getFieldEntryKey(node) { + return node.alias ? node.alias.value : node.name.value; +} +//# sourceMappingURL=collectFields.js.map \ No newline at end of file diff --git a/execution/collectFields.js.map b/execution/collectFields.js.map new file mode 100644 index 0000000000..5298e1738d --- /dev/null +++ b/execution/collectFields.js.map @@ -0,0 +1 @@ +{"version":3,"file":"collectFields.js","sourceRoot":"","sources":["../../src/execution/collectFields.ts"],"names":[],"mappings":";;AAqFA,sCAgCC;AAaD,4CA2CC;AA7KD,oEAA8D;AAY9D,mDAA4C;AAG5C,yDAAuD;AACvD,yDAI+B;AAG/B,gEAA0D;AAI1D,2CAIqB;AA4CrB;;;;;;;;GAQG;AACH,yDAAyD;AACzD,SAAgB,aAAa,CAC3B,MAAqB,EACrB,SAAkC,EAClC,cAA8B,EAC9B,WAA8B,EAC9B,YAA8B,EAC9B,eAAwB,EACxB,oBAAoB,GAAG,KAAK;IAM5B,MAAM,eAAe,GAAG,IAAI,kCAAc,EAAwB,CAAC;IACnE,MAAM,cAAc,GAAsB,EAAE,CAAC;IAC7C,MAAM,OAAO,GAAyB;QACpC,MAAM;QACN,SAAS;QACT,cAAc;QACd,WAAW;QACX,oBAAoB,EAAE,IAAI,GAAG,EAAE;QAC/B,eAAe;QACf,2BAA2B,EAAE,EAAE;QAC/B,oBAAoB;KACrB,CAAC;IAEF,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;IAC1E,OAAO;QACL,eAAe;QACf,cAAc;QACd,2BAA2B,EAAE,OAAO,CAAC,2BAA2B;KACjE,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,yDAAyD;AACzD,SAAgB,gBAAgB,CAC9B,MAAqB,EACrB,SAAkC,EAClC,cAA8B,EAC9B,UAA6B,EAC7B,gBAAkC,EAClC,eAAwB;IAKxB,MAAM,OAAO,GAAyB;QACpC,MAAM;QACN,SAAS;QACT,cAAc;QACd,WAAW,EAAE,UAAU;QACvB,oBAAoB,EAAE,IAAI,GAAG,EAAE;QAC/B,eAAe;QACf,2BAA2B,EAAE,EAAE;QAC/B,oBAAoB,EAAE,KAAK;KAC5B,CAAC;IACF,MAAM,kBAAkB,GAAG,IAAI,kCAAc,EAAwB,CAAC;IACtE,MAAM,cAAc,GAA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Aa,CAAC;IACjD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,eAAe,GAAG,IAAA,4BAAW,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC/D,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAA,8BAAc,EAAC,eAAe,CAAC,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAe;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;AACzD,CAAC","sourcesContent":["import { AccumulatorMap } from '../jsutils/AccumulatorMap.js';\nimport type { ObjMap, ReadOnlyObjMap } from '../jsutils/ObjMap.js';\n\nimport type {\n ConstValueNode,\n DirectiveNode,\n FieldNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n SelectionSetNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLObjectType } from '../type/definition.js';\nimport { isAbstractType } from '../type/definition.js';\nimport {\n GraphQLDeferDirective,\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n} from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { typeFromAST } from '../utilities/typeFromAST.js';\n\nimport type { GraphQLVariableSignature } from './getVariableSignature.js';\nimport type { VariableValues } from './values.js';\nimport {\n getArgumentValues,\n getDirectiveValues,\n getFragmentVariableValues,\n} from './values.js';\n\nexport interface DeferUsage {\n label: string | undefined;\n parentDeferUsage: DeferUsage | undefined;\n}\n\nexport interface FragmentVariableValues {\n readonly sources: ReadOnlyObjMap;\n readonly coerced: ReadOnlyObjMap;\n}\n\ninterface FragmentVariableValueSource {\n readonly signature: GraphQLVariableSignature;\n readonly value?: ConstValueNode;\n readonly fragmentVariableValues?: FragmentVariableValues;\n}\n\nexport interface FieldDetails {\n node: FieldNode;\n deferUsage?: DeferUsage | undefined;\n fragmentVariableValues?: FragmentVariableValues | undefined;\n}\n\nexport type FieldDetailsList = ReadonlyArray;\n\nexport type GroupedFieldSet = ReadonlyMap;\n\nexport interface FragmentDetails {\n definition: FragmentDefinitionNode;\n variableSignatures?: ObjMap | undefined;\n}\n\ninterface CollectFieldsContext {\n schema: GraphQLSchema;\n fragments: ObjMap;\n variableValues: VariableValues;\n runtimeType: GraphQLObjectType;\n visitedFragmentNames: Set;\n hideSuggestions: boolean;\n forbiddenDirectiveInstances: Array;\n forbidSkipAndInclude: boolean;\n}\n\n/**\n * Given a selectionSet, collects all of the fields and returns them.\n *\n * CollectFields requires the \"runtime type\" of an object. For a field that\n * returns an Interface or Union type, the \"runtime type\" will be the actual\n * object type returned by that field.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/max-params\nexport function collectFields(\n schema: GraphQLSchema,\n fragments: ObjMap,\n variableValues: VariableValues,\n runtimeType: GraphQLObjectType,\n selectionSet: SelectionSetNode,\n hideSuggestions: boolean,\n forbidSkipAndInclude = false,\n): {\n groupedFieldSet: GroupedFieldSet;\n newDeferUsages: ReadonlyArray;\n forbiddenDirectiveInstances: ReadonlyArray;\n} {\n const groupedFieldSet = new AccumulatorMap();\n const newDeferUsages: Array = [];\n const context: CollectFieldsContext = {\n schema,\n fragments,\n variableValues,\n runtimeType,\n visitedFragmentNames: new Set(),\n hideSuggestions,\n forbiddenDirectiveInstances: [],\n forbidSkipAndInclude,\n };\n\n collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages);\n return {\n groupedFieldSet,\n newDeferUsages,\n forbiddenDirectiveInstances: context.forbiddenDirectiveInstances,\n };\n}\n\n/**\n * Given an array of field nodes, collects all of the subfields of the passed\n * in fields, and returns them at the end.\n *\n * CollectSubFields requires the \"return type\" of an object. For a field that\n * returns an Interface or Union type, the \"return type\" will be the actual\n * object type returned by that field.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/max-params\nexport function collectSubfields(\n schema: GraphQLSchema,\n fragments: ObjMap,\n variableValues: VariableValues,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n hideSuggestions: boolean,\n): {\n groupedFieldSet: GroupedFieldSet;\n newDeferUsages: ReadonlyArray;\n} {\n const context: CollectFieldsContext = {\n schema,\n fragments,\n variableValues,\n runtimeType: returnType,\n visitedFragmentNames: new Set(),\n hideSuggestions,\n forbiddenDirectiveInstances: [],\n forbidSkipAndInclude: false,\n };\n const subGroupedFieldSet = new AccumulatorMap();\n const newDeferUsages: Array = [];\n\n for (const fieldDetail of fieldDetailsList) {\n const selectionSet = fieldDetail.node.selectionSet;\n if (selectionSet) {\n const { deferUsage, fragmentVariableValues } = fieldDetail;\n collectFieldsImpl(\n context,\n selectionSet,\n subGroupedFieldSet,\n newDeferUsages,\n deferUsage,\n fragmentVariableValues,\n );\n }\n }\n\n return {\n groupedFieldSet: subGroupedFieldSet,\n newDeferUsages,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/max-params\nfunction collectFieldsImpl(\n context: CollectFieldsContext,\n selectionSet: SelectionSetNode,\n groupedFieldSet: AccumulatorMap,\n newDeferUsages: Array,\n deferUsage?: DeferUsage,\n fragmentVariableValues?: FragmentVariableValues,\n): void {\n const {\n schema,\n fragments,\n variableValues,\n runtimeType,\n visitedFragmentNames,\n hideSuggestions,\n } = context;\n\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n if (\n !shouldIncludeNode(\n context,\n selection,\n variableValues,\n fragmentVariableValues,\n )\n ) {\n continue;\n }\n groupedFieldSet.add(getFieldEntryKey(selection), {\n node: selection,\n deferUsage,\n fragmentVariableValues,\n });\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n if (\n !shouldIncludeNode(\n context,\n selection,\n variableValues,\n fragmentVariableValues,\n ) ||\n !doesFragmentConditionMatch(schema, selection, runtimeType)\n ) {\n continue;\n }\n\n const newDeferUsage = getDeferUsage(\n variableValues,\n fragmentVariableValues,\n selection,\n deferUsage,\n );\n\n if (!newDeferUsage) {\n collectFieldsImpl(\n context,\n selection.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n deferUsage,\n fragmentVariableValues,\n );\n } else {\n newDeferUsages.push(newDeferUsage);\n collectFieldsImpl(\n context,\n selection.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n newDeferUsage,\n fragmentVariableValues,\n );\n }\n\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragName = selection.name.value;\n\n if (\n visitedFragmentNames.has(fragName) ||\n !shouldIncludeNode(\n context,\n selection,\n variableValues,\n fragmentVariableValues,\n )\n ) {\n continue;\n }\n\n const fragment = fragments[fragName];\n if (\n fragment == null ||\n !doesFragmentConditionMatch(schema, fragment.definition, runtimeType)\n ) {\n continue;\n }\n\n const newDeferUsage = getDeferUsage(\n variableValues,\n fragmentVariableValues,\n selection,\n deferUsage,\n );\n\n const fragmentVariableSignatures = fragment.variableSignatures;\n let newFragmentVariableValues: FragmentVariableValues | undefined;\n if (fragmentVariableSignatures) {\n newFragmentVariableValues = getFragmentVariableValues(\n selection,\n fragmentVariableSignatures,\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n\n if (!newDeferUsage) {\n visitedFragmentNames.add(fragName);\n collectFieldsImpl(\n context,\n fragment.definition.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n deferUsage,\n newFragmentVariableValues,\n );\n } else {\n newDeferUsages.push(newDeferUsage);\n collectFieldsImpl(\n context,\n fragment.definition.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n newDeferUsage,\n newFragmentVariableValues,\n );\n }\n break;\n }\n }\n }\n}\n\n/**\n * Returns an object containing the `@defer` arguments if a field should be\n * deferred based on the experimental flag, defer directive present and\n * not disabled by the \"if\" argument.\n */\nfunction getDeferUsage(\n variableValues: VariableValues,\n fragmentVariableValues: FragmentVariableValues | undefined,\n node: FragmentSpreadNode | InlineFragmentNode,\n parentDeferUsage: DeferUsage | undefined,\n): DeferUsage | undefined {\n const defer = getDirectiveValues(\n GraphQLDeferDirective,\n node,\n variableValues,\n fragmentVariableValues,\n );\n\n if (!defer) {\n return;\n }\n\n if (defer.if === false) {\n return;\n }\n\n return {\n label: typeof defer.label === 'string' ? defer.label : undefined,\n parentDeferUsage,\n };\n}\n\n/**\n * Determines if a field should be included based on the `@include` and `@skip`\n * directives, where `@skip` has higher precedence than `@include`.\n */\nfunction shouldIncludeNode(\n context: CollectFieldsContext,\n node: FragmentSpreadNode | FieldNode | InlineFragmentNode,\n variableValues: VariableValues,\n fragmentVariableValues: FragmentVariableValues | undefined,\n): boolean {\n const skipDirectiveNode = node.directives?.find(\n (directive) => directive.name.value === GraphQLSkipDirective.name,\n );\n if (skipDirectiveNode && context.forbidSkipAndInclude) {\n context.forbiddenDirectiveInstances.push(skipDirectiveNode);\n return false;\n }\n const skip = skipDirectiveNode\n ? getArgumentValues(\n GraphQLSkipDirective,\n skipDirectiveNode,\n variableValues,\n fragmentVariableValues,\n context.hideSuggestions,\n )\n : undefined;\n if (skip?.if === true) {\n return false;\n }\n\n const includeDirectiveNode = node.directives?.find(\n (directive) => directive.name.value === GraphQLIncludeDirective.name,\n );\n if (includeDirectiveNode && context.forbidSkipAndInclude) {\n context.forbiddenDirectiveInstances.push(includeDirectiveNode);\n return false;\n }\n const include = includeDirectiveNode\n ? getArgumentValues(\n GraphQLIncludeDirective,\n includeDirectiveNode,\n variableValues,\n fragmentVariableValues,\n context.hideSuggestions,\n )\n : undefined;\n if (include?.if === false) {\n return false;\n }\n return true;\n}\n\n/**\n * Determines if a fragment is applicable to the given type.\n */\nfunction doesFragmentConditionMatch(\n schema: GraphQLSchema,\n fragment: FragmentDefinitionNode | InlineFragmentNode,\n type: GraphQLObjectType,\n): boolean {\n const typeConditionNode = fragment.typeCondition;\n if (!typeConditionNode) {\n return true;\n }\n const conditionalType = typeFromAST(schema, typeConditionNode);\n if (conditionalType === type) {\n return true;\n }\n if (isAbstractType(conditionalType)) {\n return schema.isSubType(conditionalType, type);\n }\n return false;\n}\n\n/**\n * Implements the logic to compute the key of a given field's entry\n */\nfunction getFieldEntryKey(node: FieldNode): string {\n return node.alias ? node.alias.value : node.name.value;\n}\n"]} \ No newline at end of file diff --git a/execution/collectFields.mjs b/execution/collectFields.mjs new file mode 100644 index 0000000000..7786f9e1b0 --- /dev/null +++ b/execution/collectFields.mjs @@ -0,0 +1,204 @@ +import { AccumulatorMap } from "../jsutils/AccumulatorMap.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { isAbstractType } from "../type/definition.mjs"; +import { GraphQLDeferDirective, GraphQLIncludeDirective, GraphQLSkipDirective, } from "../type/directives.mjs"; +import { typeFromAST } from "../utilities/typeFromAST.mjs"; +import { getArgumentValues, getDirectiveValues, getFragmentVariableValues, } from "./values.mjs"; +/** + * Given a selectionSet, collects all of the fields and returns them. + * + * CollectFields requires the "runtime type" of an object. For a field that + * returns an Interface or Union type, the "runtime type" will be the actual + * object type returned by that field. + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/max-params +export function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, hideSuggestions, forbidSkipAndInclude = false) { + const groupedFieldSet = new AccumulatorMap(); + const newDeferUsages = []; + const context = { + schema, + fragments, + variableValues, + runtimeType, + visitedFragmentNames: new Set(), + hideSuggestions, + forbiddenDirectiveInstances: [], + forbidSkipAndInclude, + }; + collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages); + return { + groupedFieldSet, + newDeferUsages, + forbiddenDirectiveInstances: context.forbiddenDirectiveInstances, + }; +} +/** + * Given an array of field nodes, collects all of the subfields of the passed + * in fields, and returns them at the end. + * + * CollectSubFields requires the "return type" of an object. For a field that + * returns an Interface or Union type, the "return type" will be the actual + * object type returned by that field. + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/max-params +export function collectSubfields(schema, fragments, variableValues, returnType, fieldDetailsList, hideSuggestions) { + const context = { + schema, + fragments, + variableValues, + runtimeType: returnType, + visitedFragmentNames: new Set(), + hideSuggestions, + forbiddenDirectiveInstances: [], + forbidSkipAndInclude: false, + }; + const subGroupedFieldSet = new AccumulatorMap(); + const newDeferUsages = []; + for (const fieldDetail of fieldDetailsList) { + const selectionSet = fieldDetail.node.selectionSet; + if (selectionSet) { + const { deferUsage, fragmentVariableValues } = fieldDetail; + collectFieldsImpl(context, selectionSet, subGroupedFieldSet, newDeferUsages, deferUsage, fragmentVariableValues); + } + } + return { + groupedFieldSet: subGroupedFieldSet, + newDeferUsages, + }; +} +// eslint-disable-next-line @typescript-eslint/max-params +function collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages, deferUsage, fragmentVariableValues) { + const { schema, fragments, variableValues, runtimeType, visitedFragmentNames, hideSuggestions, } = context; + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case Kind.FIELD: { + if (!shouldIncludeNode(context, selection, variableValues, fragmentVariableValues)) { + continue; + } + groupedFieldSet.add(getFieldEntryKey(selection), { + node: selection, + deferUsage, + fragmentVariableValues, + }); + break; + } + case Kind.INLINE_FRAGMENT: { + if (!shouldIncludeNode(context, selection, variableValues, fragmentVariableValues) || + !doesFragmentConditionMatch(schema, selection, runtimeType)) { + continue; + } + const newDeferUsage = getDeferUsage(variableValues, fragmentVariableValues, selection, deferUsage); + if (!newDeferUsage) { + collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, deferUsage, fragmentVariableValues); + } + else { + newDeferUsages.push(newDeferUsage); + collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, newDeferUsage, fragmentVariableValues); + } + break; + } + case Kind.FRAGMENT_SPREAD: { + const fragName = selection.name.value; + if (visitedFragmentNames.has(fragName) || + !shouldIncludeNode(context, selection, variableValues, fragmentVariableValues)) { + continue; + } + const fragment = fragments[fragName]; + if (fragment == null || + !doesFragmentConditionMatch(schema, fragment.definition, runtimeType)) { + continue; + } + const newDeferUsage = getDeferUsage(variableValues, fragmentVariableValues, selection, deferUsage); + const fragmentVariableSignatures = fragment.variableSignatures; + let newFragmentVariableValues; + if (fragmentVariableSignatures) { + newFragmentVariableValues = getFragmentVariableValues(selection, fragmentVariableSignatures, variableValues, fragmentVariableValues, hideSuggestions); + } + if (!newDeferUsage) { + visitedFragmentNames.add(fragName); + collectFieldsImpl(context, fragment.definition.selectionSet, groupedFieldSet, newDeferUsages, deferUsage, newFragmentVariableValues); + } + else { + newDeferUsages.push(newDeferUsage); + collectFieldsImpl(context, fragment.definition.selectionSet, groupedFieldSet, newDeferUsages, newDeferUsage, newFragmentVariableValues); + } + break; + } + } + } +} +/** + * Returns an object containing the `@defer` arguments if a field should be + * deferred based on the experimental flag, defer directive present and + * not disabled by the "if" argument. + */ +function getDeferUsage(variableValues, fragmentVariableValues, node, parentDeferUsage) { + const defer = getDirectiveValues(GraphQLDeferDirective, node, variableValues, fragmentVariableValues); + if (!defer) { + return; + } + if (defer.if === false) { + return; + } + return { + label: typeof defer.label === 'string' ? defer.label : undefined, + parentDeferUsage, + }; +} +/** + * Determines if a field should be included based on the `@include` and `@skip` + * directives, where `@skip` has higher precedence than `@include`. + */ +function shouldIncludeNode(context, node, variableValues, fragmentVariableValues) { + const skipDirectiveNode = node.directives?.find((directive) => directive.name.value === GraphQLSkipDirective.name); + if (skipDirectiveNode && context.forbidSkipAndInclude) { + context.forbiddenDirectiveInstances.push(skipDirectiveNode); + return false; + } + const skip = skipDirectiveNode + ? getArgumentValues(GraphQLSkipDirective, skipDirectiveNode, variableValues, fragmentVariableValues, context.hideSuggestions) + : undefined; + if (skip?.if === true) { + return false; + } + const includeDirectiveNode = node.directives?.find((directive) => directive.name.value === GraphQLIncludeDirective.name); + if (includeDirectiveNode && context.forbidSkipAndInclude) { + context.forbiddenDirectiveInstances.push(includeDirectiveNode); + return false; + } + const include = includeDirectiveNode + ? getArgumentValues(GraphQLIncludeDirective, includeDirectiveNode, variableValues, fragmentVariableValues, context.hideSuggestions) + : undefined; + if (include?.if === false) { + return false; + } + return true; +} +/** + * Determines if a fragment is applicable to the given type. + */ +function doesFragmentConditionMatch(schema, fragment, type) { + const typeConditionNode = fragment.typeCondition; + if (!typeConditionNode) { + return true; + } + const conditionalType = typeFromAST(schema, typeConditionNode); + if (conditionalType === type) { + return true; + } + if (isAbstractType(conditionalType)) { + return schema.isSubType(conditionalType, type); + } + return false; +} +/** + * Implements the logic to compute the key of a given field's entry + */ +function getFieldEntryKey(node) { + return node.alias ? node.alias.value : node.name.value; +} +//# sourceMappingURL=collectFields.js.map \ No newline at end of file diff --git a/execution/collectFields.mjs.map b/execution/collectFields.mjs.map new file mode 100644 index 0000000000..268c0f9fe4 --- /dev/null +++ b/execution/collectFields.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"collectFields.js","sourceRoot":"","sources":["../../src/execution/collectFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAY9D,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAG5C,OAAO,EAAE,cAAc,EAAE,+BAA8B;AACvD,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,+BAA8B;AAG/B,OAAO,EAAE,WAAW,EAAE,qCAAoC;AAI1D,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,GAC1B,qBAAoB;AA4CrB;;;;;;;;GAQG;AACH,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAC3B,MAAqB,EACrB,SAAkC,EAClC,cAA8B,EAC9B,WAA8B,EAC9B,YAA8B,EAC9B,eAAwB,EACxB,oBAAoB,GAAG,KAAK;IAM5B,MAAM,eAAe,GAAG,IAAI,cAAc,EAAwB,CAAC;IACnE,MAAM,cAAc,GAAsB,EAAE,CAAC;IAC7C,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AAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;AACzD,CAAC","sourcesContent":["import { AccumulatorMap } from '../jsutils/AccumulatorMap.js';\nimport type { ObjMap, ReadOnlyObjMap } from '../jsutils/ObjMap.js';\n\nimport type {\n ConstValueNode,\n DirectiveNode,\n FieldNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n SelectionSetNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLObjectType } from '../type/definition.js';\nimport { isAbstractType } from '../type/definition.js';\nimport {\n GraphQLDeferDirective,\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n} from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { typeFromAST } from '../utilities/typeFromAST.js';\n\nimport type { GraphQLVariableSignature } from './getVariableSignature.js';\nimport type { VariableValues } from './values.js';\nimport {\n getArgumentValues,\n getDirectiveValues,\n getFragmentVariableValues,\n} from './values.js';\n\nexport interface DeferUsage {\n label: string | undefined;\n parentDeferUsage: DeferUsage | undefined;\n}\n\nexport interface FragmentVariableValues {\n readonly sources: ReadOnlyObjMap;\n readonly coerced: ReadOnlyObjMap;\n}\n\ninterface FragmentVariableValueSource {\n readonly signature: GraphQLVariableSignature;\n readonly value?: ConstValueNode;\n readonly fragmentVariableValues?: FragmentVariableValues;\n}\n\nexport interface FieldDetails {\n node: FieldNode;\n deferUsage?: DeferUsage | undefined;\n fragmentVariableValues?: FragmentVariableValues | undefined;\n}\n\nexport type FieldDetailsList = ReadonlyArray;\n\nexport type GroupedFieldSet = ReadonlyMap;\n\nexport interface FragmentDetails {\n definition: FragmentDefinitionNode;\n variableSignatures?: ObjMap | undefined;\n}\n\ninterface CollectFieldsContext {\n schema: GraphQLSchema;\n fragments: ObjMap;\n variableValues: VariableValues;\n runtimeType: GraphQLObjectType;\n visitedFragmentNames: Set;\n hideSuggestions: boolean;\n forbiddenDirectiveInstances: Array;\n forbidSkipAndInclude: boolean;\n}\n\n/**\n * Given a selectionSet, collects all of the fields and returns them.\n *\n * CollectFields requires the \"runtime type\" of an object. For a field that\n * returns an Interface or Union type, the \"runtime type\" will be the actual\n * object type returned by that field.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/max-params\nexport function collectFields(\n schema: GraphQLSchema,\n fragments: ObjMap,\n variableValues: VariableValues,\n runtimeType: GraphQLObjectType,\n selectionSet: SelectionSetNode,\n hideSuggestions: boolean,\n forbidSkipAndInclude = false,\n): {\n groupedFieldSet: GroupedFieldSet;\n newDeferUsages: ReadonlyArray;\n forbiddenDirectiveInstances: ReadonlyArray;\n} {\n const groupedFieldSet = new AccumulatorMap();\n const newDeferUsages: Array = [];\n const context: CollectFieldsContext = {\n schema,\n fragments,\n variableValues,\n runtimeType,\n visitedFragmentNames: new Set(),\n hideSuggestions,\n forbiddenDirectiveInstances: [],\n forbidSkipAndInclude,\n };\n\n collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages);\n return {\n groupedFieldSet,\n newDeferUsages,\n forbiddenDirectiveInstances: context.forbiddenDirectiveInstances,\n };\n}\n\n/**\n * Given an array of field nodes, collects all of the subfields of the passed\n * in fields, and returns them at the end.\n *\n * CollectSubFields requires the \"return type\" of an object. For a field that\n * returns an Interface or Union type, the \"return type\" will be the actual\n * object type returned by that field.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/max-params\nexport function collectSubfields(\n schema: GraphQLSchema,\n fragments: ObjMap,\n variableValues: VariableValues,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n hideSuggestions: boolean,\n): {\n groupedFieldSet: GroupedFieldSet;\n newDeferUsages: ReadonlyArray;\n} {\n const context: CollectFieldsContext = {\n schema,\n fragments,\n variableValues,\n runtimeType: returnType,\n visitedFragmentNames: new Set(),\n hideSuggestions,\n forbiddenDirectiveInstances: [],\n forbidSkipAndInclude: false,\n };\n const subGroupedFieldSet = new AccumulatorMap();\n const newDeferUsages: Array = [];\n\n for (const fieldDetail of fieldDetailsList) {\n const selectionSet = fieldDetail.node.selectionSet;\n if (selectionSet) {\n const { deferUsage, fragmentVariableValues } = fieldDetail;\n collectFieldsImpl(\n context,\n selectionSet,\n subGroupedFieldSet,\n newDeferUsages,\n deferUsage,\n fragmentVariableValues,\n );\n }\n }\n\n return {\n groupedFieldSet: subGroupedFieldSet,\n newDeferUsages,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/max-params\nfunction collectFieldsImpl(\n context: CollectFieldsContext,\n selectionSet: SelectionSetNode,\n groupedFieldSet: AccumulatorMap,\n newDeferUsages: Array,\n deferUsage?: DeferUsage,\n fragmentVariableValues?: FragmentVariableValues,\n): void {\n const {\n schema,\n fragments,\n variableValues,\n runtimeType,\n visitedFragmentNames,\n hideSuggestions,\n } = context;\n\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n if (\n !shouldIncludeNode(\n context,\n selection,\n variableValues,\n fragmentVariableValues,\n )\n ) {\n continue;\n }\n groupedFieldSet.add(getFieldEntryKey(selection), {\n node: selection,\n deferUsage,\n fragmentVariableValues,\n });\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n if (\n !shouldIncludeNode(\n context,\n selection,\n variableValues,\n fragmentVariableValues,\n ) ||\n !doesFragmentConditionMatch(schema, selection, runtimeType)\n ) {\n continue;\n }\n\n const newDeferUsage = getDeferUsage(\n variableValues,\n fragmentVariableValues,\n selection,\n deferUsage,\n );\n\n if (!newDeferUsage) {\n collectFieldsImpl(\n context,\n selection.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n deferUsage,\n fragmentVariableValues,\n );\n } else {\n newDeferUsages.push(newDeferUsage);\n collectFieldsImpl(\n context,\n selection.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n newDeferUsage,\n fragmentVariableValues,\n );\n }\n\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragName = selection.name.value;\n\n if (\n visitedFragmentNames.has(fragName) ||\n !shouldIncludeNode(\n context,\n selection,\n variableValues,\n fragmentVariableValues,\n )\n ) {\n continue;\n }\n\n const fragment = fragments[fragName];\n if (\n fragment == null ||\n !doesFragmentConditionMatch(schema, fragment.definition, runtimeType)\n ) {\n continue;\n }\n\n const newDeferUsage = getDeferUsage(\n variableValues,\n fragmentVariableValues,\n selection,\n deferUsage,\n );\n\n const fragmentVariableSignatures = fragment.variableSignatures;\n let newFragmentVariableValues: FragmentVariableValues | undefined;\n if (fragmentVariableSignatures) {\n newFragmentVariableValues = getFragmentVariableValues(\n selection,\n fragmentVariableSignatures,\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n\n if (!newDeferUsage) {\n visitedFragmentNames.add(fragName);\n collectFieldsImpl(\n context,\n fragment.definition.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n deferUsage,\n newFragmentVariableValues,\n );\n } else {\n newDeferUsages.push(newDeferUsage);\n collectFieldsImpl(\n context,\n fragment.definition.selectionSet,\n groupedFieldSet,\n newDeferUsages,\n newDeferUsage,\n newFragmentVariableValues,\n );\n }\n break;\n }\n }\n }\n}\n\n/**\n * Returns an object containing the `@defer` arguments if a field should be\n * deferred based on the experimental flag, defer directive present and\n * not disabled by the \"if\" argument.\n */\nfunction getDeferUsage(\n variableValues: VariableValues,\n fragmentVariableValues: FragmentVariableValues | undefined,\n node: FragmentSpreadNode | InlineFragmentNode,\n parentDeferUsage: DeferUsage | undefined,\n): DeferUsage | undefined {\n const defer = getDirectiveValues(\n GraphQLDeferDirective,\n node,\n variableValues,\n fragmentVariableValues,\n );\n\n if (!defer) {\n return;\n }\n\n if (defer.if === false) {\n return;\n }\n\n return {\n label: typeof defer.label === 'string' ? defer.label : undefined,\n parentDeferUsage,\n };\n}\n\n/**\n * Determines if a field should be included based on the `@include` and `@skip`\n * directives, where `@skip` has higher precedence than `@include`.\n */\nfunction shouldIncludeNode(\n context: CollectFieldsContext,\n node: FragmentSpreadNode | FieldNode | InlineFragmentNode,\n variableValues: VariableValues,\n fragmentVariableValues: FragmentVariableValues | undefined,\n): boolean {\n const skipDirectiveNode = node.directives?.find(\n (directive) => directive.name.value === GraphQLSkipDirective.name,\n );\n if (skipDirectiveNode && context.forbidSkipAndInclude) {\n context.forbiddenDirectiveInstances.push(skipDirectiveNode);\n return false;\n }\n const skip = skipDirectiveNode\n ? getArgumentValues(\n GraphQLSkipDirective,\n skipDirectiveNode,\n variableValues,\n fragmentVariableValues,\n context.hideSuggestions,\n )\n : undefined;\n if (skip?.if === true) {\n return false;\n }\n\n const includeDirectiveNode = node.directives?.find(\n (directive) => directive.name.value === GraphQLIncludeDirective.name,\n );\n if (includeDirectiveNode && context.forbidSkipAndInclude) {\n context.forbiddenDirectiveInstances.push(includeDirectiveNode);\n return false;\n }\n const include = includeDirectiveNode\n ? getArgumentValues(\n GraphQLIncludeDirective,\n includeDirectiveNode,\n variableValues,\n fragmentVariableValues,\n context.hideSuggestions,\n )\n : undefined;\n if (include?.if === false) {\n return false;\n }\n return true;\n}\n\n/**\n * Determines if a fragment is applicable to the given type.\n */\nfunction doesFragmentConditionMatch(\n schema: GraphQLSchema,\n fragment: FragmentDefinitionNode | InlineFragmentNode,\n type: GraphQLObjectType,\n): boolean {\n const typeConditionNode = fragment.typeCondition;\n if (!typeConditionNode) {\n return true;\n }\n const conditionalType = typeFromAST(schema, typeConditionNode);\n if (conditionalType === type) {\n return true;\n }\n if (isAbstractType(conditionalType)) {\n return schema.isSubType(conditionalType, type);\n }\n return false;\n}\n\n/**\n * Implements the logic to compute the key of a given field's entry\n */\nfunction getFieldEntryKey(node: FieldNode): string {\n return node.alias ? node.alias.value : node.name.value;\n}\n"]} \ No newline at end of file diff --git a/execution/execute.d.ts b/execution/execute.d.ts new file mode 100644 index 0000000000..a225060f17 --- /dev/null +++ b/execution/execute.d.ts @@ -0,0 +1,226 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { Path } from '../jsutils/Path.js'; +import type { PromiseOrValue } from '../jsutils/PromiseOrValue.js'; +import { GraphQLError } from '../error/GraphQLError.js'; +import type { DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode } from '../language/ast.js'; +import type { GraphQLField, GraphQLFieldResolver, GraphQLObjectType, GraphQLResolveInfo, GraphQLTypeResolver } from '../type/definition.js'; +import type { GraphQLSchema } from '../type/schema.js'; +import { AbortSignalListener } from './AbortSignalListener.js'; +import type { FieldDetailsList, FragmentDetails } from './collectFields.js'; +import type { CancellableStreamRecord, ExecutionResult, ExperimentalIncrementalExecutionResults } from './types.js'; +import type { VariableValues } from './values.js'; +/** + * Terminology + * + * "Definitions" are the generic name for top-level statements in the document. + * Examples of this include: + * 1) Operations (such as a query) + * 2) Fragments + * + * "Operations" are a generic name for requests in the document. + * Examples of this include: + * 1) query, + * 2) mutation + * + * "Selections" are the definitions that can appear legally and at + * single level of the query. These include: + * 1) field references e.g `a` + * 2) fragment "spreads" e.g. `...c` + * 3) inline fragment "spreads" e.g. `...on Type { a }` + */ +/** + * Data that must be available at all points during query execution. + * + * Namely, schema of the type system that is currently executing, + * and the fragments defined in the query document + */ +export interface ValidatedExecutionArgs { + schema: GraphQLSchema; + fragmentDefinitions: ObjMap; + fragments: ObjMap; + rootValue: unknown; + contextValue: unknown; + operation: OperationDefinitionNode; + variableValues: VariableValues; + fieldResolver: GraphQLFieldResolver; + typeResolver: GraphQLTypeResolver; + subscribeFieldResolver: GraphQLFieldResolver; + perEventExecutor: (validatedExecutionArgs: ValidatedExecutionArgs) => PromiseOrValue; + enableEarlyExecution: boolean; + hideSuggestions: boolean; + abortSignal: AbortSignal | undefined; +} +export interface ExecutionContext { + validatedExecutionArgs: ValidatedExecutionArgs; + errors: Array | undefined; + abortSignalListener: AbortSignalListener | undefined; + completed: boolean; + cancellableStreams: Set | undefined; + errorPropagation: boolean; +} +export interface ExecutionArgs { + schema: GraphQLSchema; + document: DocumentNode; + rootValue?: unknown; + contextValue?: unknown; + variableValues?: Maybe<{ + readonly [variable: string]: unknown; + }>; + operationName?: Maybe; + fieldResolver?: Maybe>; + typeResolver?: Maybe>; + subscribeFieldResolver?: Maybe>; + perEventExecutor?: Maybe<(validatedExecutionArgs: ValidatedExecutionArgs) => PromiseOrValue>; + enableEarlyExecution?: Maybe; + hideSuggestions?: Maybe; + abortSignal?: Maybe; +} +export interface StreamUsage { + label: string | undefined; + initialCount: number; + fieldDetailsList: FieldDetailsList; +} +/** + * Implements the "Executing requests" section of the GraphQL specification. + * + * Returns either a synchronous ExecutionResult (if all encountered resolvers + * are synchronous), or a Promise of an ExecutionResult that will eventually be + * resolved and never rejected. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + * + * This function does not support incremental delivery (`@defer` and `@stream`). + * If an operation which would defer or stream data is executed with this + * function, it will throw or return a rejected promise. + * Use `experimentalExecuteIncrementally` if you want to support incremental + * delivery. + */ +export declare function execute(args: ExecutionArgs): PromiseOrValue; +/** + * Implements the "Executing requests" section of the GraphQL specification, + * including `@defer` and `@stream` as proposed in + * https://github.com/graphql/graphql-spec/pull/742 + * + * This function returns a Promise of an ExperimentalIncrementalExecutionResults + * object. This object either consists of a single ExecutionResult, or an + * object containing an `initialResult` and a stream of `subsequentResults`. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + */ +export declare function experimentalExecuteIncrementally(args: ExecutionArgs): PromiseOrValue; +/** + * Implements the "Executing operations" section of the spec. + * + * Returns a Promise that will eventually resolve to the data described by + * The "Response" section of the GraphQL specification. + * + * If errors are encountered while executing a GraphQL field, only that + * field and its descendants will be omitted, and sibling fields will still + * be executed. An execution which encounters errors will still result in a + * resolved Promise. + * + * Errors from sub-fields of a NonNull type may propagate to the top level, + * at which point we still log the error and null the parent field, which + * in this case is the entire response. + */ +export declare function executeQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs: ValidatedExecutionArgs): PromiseOrValue; +export declare function experimentalExecuteQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs: ValidatedExecutionArgs): PromiseOrValue; +/** + * Also implements the "Executing requests" section of the GraphQL specification. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ +export declare function executeSync(args: ExecutionArgs): ExecutionResult; +/** + * Constructs a ExecutionContext object from the arguments passed to + * execute, which we will pass throughout the other execution methods. + * + * Throws a GraphQLError if a valid execution context cannot be created. + * + * TODO: consider no longer exporting this function + * @internal + */ +export declare function validateExecutionArgs(args: ExecutionArgs): ReadonlyArray | ValidatedExecutionArgs; +/** + * TODO: consider no longer exporting this function + * @internal + */ +export declare function buildResolveInfo(validatedExecutionArgs: ValidatedExecutionArgs, fieldDef: GraphQLField, fieldNodes: ReadonlyArray, parentType: GraphQLObjectType, path: Path): GraphQLResolveInfo; +/** + * If a resolveType function is not given, then a default resolve behavior is + * used which attempts two strategies: + * + * First, See if the provided value has a `__typename` field defined, if so, use + * that value as name of the resolved type. + * + * Otherwise, test each possible type for the abstract type by calling + * isTypeOf for the object being coerced, returning the first type that matches. + */ +export declare const defaultTypeResolver: GraphQLTypeResolver; +/** + * If a resolve function is not given, then a default resolve behavior is used + * which takes the property of the source object of the same name as the field + * and returns it as the result, or if it's a function, returns the result + * of calling that function while passing along args and context value. + */ +export declare const defaultFieldResolver: GraphQLFieldResolver; +/** + * Implements the "Subscribe" algorithm described in the GraphQL specification. + * + * Returns a Promise which resolves to either an AsyncIterator (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with descriptive + * errors and no data will be returned. + * + * If the source stream could not be created due to faulty subscription resolver + * logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to an AsyncIterator, which + * yields a stream of ExecutionResults representing the response stream. + * + * This function does not support incremental delivery (`@defer` and `@stream`). + * If an operation which would defer or stream data is executed with this + * function, a field error will be raised at the location of the `@defer` or + * `@stream` directive. + * + * Accepts an object with named arguments. + */ +export declare function subscribe(args: ExecutionArgs): PromiseOrValue | ExecutionResult>; +export declare function executeSubscriptionEvent(validatedExecutionArgs: ValidatedExecutionArgs): PromiseOrValue; +/** + * Implements the "CreateSourceEventStream" algorithm described in the + * GraphQL specification, resolving the subscription source event stream. + * + * Returns a Promise which resolves to either an AsyncIterable (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with + * descriptive errors and no data will be returned. + * + * If the the source stream could not be created due to faulty subscription + * resolver logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to the AsyncIterable for the + * event stream returned by the resolver. + * + * A Source Event Stream represents a sequence of events, each of which triggers + * a GraphQL execution for that event. + * + * This may be useful when hosting the stateful subscription service in a + * different process or machine than the stateless GraphQL execution engine, + * or otherwise separating these two steps. For more on this, see the + * "Supporting Subscriptions at Scale" information in the GraphQL specification. + */ +export declare function createSourceEventStream(args: ExecutionArgs): PromiseOrValue | ExecutionResult>; diff --git a/execution/execute.js b/execution/execute.js new file mode 100644 index 0000000000..77d634dc64 --- /dev/null +++ b/execution/execute.js @@ -0,0 +1,1413 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultFieldResolver = exports.defaultTypeResolver = void 0; +exports.execute = execute; +exports.experimentalExecuteIncrementally = experimentalExecuteIncrementally; +exports.executeQueryOrMutationOrSubscriptionEvent = executeQueryOrMutationOrSubscriptionEvent; +exports.experimentalExecuteQueryOrMutationOrSubscriptionEvent = experimentalExecuteQueryOrMutationOrSubscriptionEvent; +exports.executeSync = executeSync; +exports.validateExecutionArgs = validateExecutionArgs; +exports.buildResolveInfo = buildResolveInfo; +exports.subscribe = subscribe; +exports.executeSubscriptionEvent = executeSubscriptionEvent; +exports.createSourceEventStream = createSourceEventStream; +const BoxedPromiseOrValue_js_1 = require("../jsutils/BoxedPromiseOrValue.js"); +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const isAsyncIterable_js_1 = require("../jsutils/isAsyncIterable.js"); +const isIterableObject_js_1 = require("../jsutils/isIterableObject.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const isPromise_js_1 = require("../jsutils/isPromise.js"); +const memoize3_js_1 = require("../jsutils/memoize3.js"); +const Path_js_1 = require("../jsutils/Path.js"); +const promiseForObject_js_1 = require("../jsutils/promiseForObject.js"); +const promiseReduce_js_1 = require("../jsutils/promiseReduce.js"); +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const locatedError_js_1 = require("../error/locatedError.js"); +const ast_js_1 = require("../language/ast.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +const directives_js_1 = require("../type/directives.js"); +const validate_js_1 = require("../type/validate.js"); +const AbortSignalListener_js_1 = require("./AbortSignalListener.js"); +const buildExecutionPlan_js_1 = require("./buildExecutionPlan.js"); +const collectFields_js_1 = require("./collectFields.js"); +const getVariableSignature_js_1 = require("./getVariableSignature.js"); +const IncrementalPublisher_js_1 = require("./IncrementalPublisher.js"); +const mapAsyncIterable_js_1 = require("./mapAsyncIterable.js"); +const types_js_1 = require("./types.js"); +const values_js_1 = require("./values.js"); +/* eslint-disable @typescript-eslint/max-params */ +// This file contains a lot of such errors but we plan to refactor it anyway +// so just disable it for entire file. +/** + * A memoized collection of relevant subfields with regard to the return + * type. Memoizing ensures the subfields are not repeatedly calculated, which + * saves overhead when resolving lists of values. + */ +const collectSubfields = (0, memoize3_js_1.memoize3)((validatedExecutionArgs, returnType, fieldDetailsList) => { + const { schema, fragments, variableValues, hideSuggestions } = validatedExecutionArgs; + return (0, collectFields_js_1.collectSubfields)(schema, fragments, variableValues, returnType, fieldDetailsList, hideSuggestions); +}); +const UNEXPECTED_EXPERIMENTAL_DIRECTIVES = 'The provided schema unexpectedly contains experimental directives (@defer or @stream). These directives may only be utilized if experimental execution features are explicitly enabled.'; +const UNEXPECTED_MULTIPLE_PAYLOADS = 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)'; +/** + * Implements the "Executing requests" section of the GraphQL specification. + * + * Returns either a synchronous ExecutionResult (if all encountered resolvers + * are synchronous), or a Promise of an ExecutionResult that will eventually be + * resolved and never rejected. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + * + * This function does not support incremental delivery (`@defer` and `@stream`). + * If an operation which would defer or stream data is executed with this + * function, it will throw or return a rejected promise. + * Use `experimentalExecuteIncrementally` if you want to support incremental + * delivery. + */ +function execute(args) { + if (args.schema.getDirective('defer') || args.schema.getDirective('stream')) { + throw new Error(UNEXPECTED_EXPERIMENTAL_DIRECTIVES); + } + const result = experimentalExecuteIncrementally(args); + // Multiple payloads could be encountered if the operation contains @defer or + // @stream directives and is not validated prior to execution + return ensureSinglePayload(result); +} +function ensureSinglePayload(result) { + if ((0, isPromise_js_1.isPromise)(result)) { + return result.then((resolved) => { + if ('initialResult' in resolved) { + throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS); + } + return resolved; + }); + } + if ('initialResult' in result) { + throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS); + } + return result; +} +/** + * Implements the "Executing requests" section of the GraphQL specification, + * including `@defer` and `@stream` as proposed in + * https://github.com/graphql/graphql-spec/pull/742 + * + * This function returns a Promise of an ExperimentalIncrementalExecutionResults + * object. This object either consists of a single ExecutionResult, or an + * object containing an `initialResult` and a stream of `subsequentResults`. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + */ +function experimentalExecuteIncrementally(args) { + // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + const validatedExecutionArgs = validateExecutionArgs(args); + // Return early errors if execution context failed. + if (!('schema' in validatedExecutionArgs)) { + return { errors: validatedExecutionArgs }; + } + return experimentalExecuteQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs); +} +/** + * Implements the "Executing operations" section of the spec. + * + * Returns a Promise that will eventually resolve to the data described by + * The "Response" section of the GraphQL specification. + * + * If errors are encountered while executing a GraphQL field, only that + * field and its descendants will be omitted, and sibling fields will still + * be executed. An execution which encounters errors will still result in a + * resolved Promise. + * + * Errors from sub-fields of a NonNull type may propagate to the top level, + * at which point we still log the error and null the parent field, which + * in this case is the entire response. + */ +function executeQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs) { + const result = experimentalExecuteQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs); + return ensureSinglePayload(result); +} +function errorPropagation(operation) { + const directiveNode = operation.directives?.find((directive) => directive.name.value === directives_js_1.GraphQLDisableErrorPropagationDirective.name); + return directiveNode === undefined; +} +function experimentalExecuteQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs) { + const abortSignal = validatedExecutionArgs.abortSignal; + const exeContext = { + validatedExecutionArgs, + errors: undefined, + abortSignalListener: abortSignal + ? new AbortSignalListener_js_1.AbortSignalListener(abortSignal) + : undefined, + completed: false, + cancellableStreams: undefined, + errorPropagation: errorPropagation(validatedExecutionArgs.operation), + }; + try { + const { schema, fragments, rootValue, operation, variableValues, hideSuggestions, } = validatedExecutionArgs; + const { operation: operationType, selectionSet } = operation; + const rootType = schema.getRootType(operationType); + if (rootType == null) { + throw new GraphQLError_js_1.GraphQLError(`Schema is not configured to execute ${operationType} operation.`, { nodes: operation }); + } + const { groupedFieldSet, newDeferUsages } = (0, collectFields_js_1.collectFields)(schema, fragments, variableValues, rootType, selectionSet, hideSuggestions); + const graphqlWrappedResult = executeRootExecutionPlan(exeContext, operation.operation, rootType, rootValue, groupedFieldSet, newDeferUsages); + if ((0, isPromise_js_1.isPromise)(graphqlWrappedResult)) { + return graphqlWrappedResult.then((resolved) => { + exeContext.completed = true; + return buildDataResponse(exeContext, resolved); + }, (error) => { + exeContext.completed = true; + exeContext.abortSignalListener?.disconnect(); + return { + data: null, + errors: withError(exeContext.errors, error), + }; + }); + } + exeContext.completed = true; + return buildDataResponse(exeContext, graphqlWrappedResult); + } + catch (error) { + exeContext.completed = true; + // TODO: add test case for synchronous null bubbling to root with cancellation + /* c8 ignore next */ + exeContext.abortSignalListener?.disconnect(); + return { data: null, errors: withError(exeContext.errors, error) }; + } +} +function withError(errors, error) { + return errors === undefined ? [error] : [...errors, error]; +} +function buildDataResponse(exeContext, graphqlWrappedResult) { + const { rawResult: data, incrementalDataRecords } = graphqlWrappedResult; + const errors = exeContext.errors; + if (incrementalDataRecords === undefined) { + exeContext.abortSignalListener?.disconnect(); + return errors !== undefined ? { errors, data } : { data }; + } + return (0, IncrementalPublisher_js_1.buildIncrementalResponse)(exeContext, data, errors, incrementalDataRecords); +} +/** + * Also implements the "Executing requests" section of the GraphQL specification. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ +function executeSync(args) { + const result = experimentalExecuteIncrementally(args); + // Assert that the execution was synchronous. + if ((0, isPromise_js_1.isPromise)(result) || 'initialResult' in result) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + return result; +} +/** + * Constructs a ExecutionContext object from the arguments passed to + * execute, which we will pass throughout the other execution methods. + * + * Throws a GraphQLError if a valid execution context cannot be created. + * + * TODO: consider no longer exporting this function + * @internal + */ +function validateExecutionArgs(args) { + const { schema, document, rootValue, contextValue, variableValues: rawVariableValues, operationName, fieldResolver, typeResolver, subscribeFieldResolver, perEventExecutor, enableEarlyExecution, abortSignal, } = args; + if (abortSignal?.aborted) { + return [(0, locatedError_js_1.locatedError)(abortSignal.reason, undefined)]; + } + // If the schema used for execution is invalid, throw an error. + (0, validate_js_1.assertValidSchema)(schema); + let operation; + const fragmentDefinitions = Object.create(null); + const fragments = Object.create(null); + for (const definition of document.definitions) { + switch (definition.kind) { + case kinds_js_1.Kind.OPERATION_DEFINITION: + if (operationName == null) { + if (operation !== undefined) { + return [ + new GraphQLError_js_1.GraphQLError('Must provide operation name if query contains multiple operations.'), + ]; + } + operation = definition; + } + else if (definition.name?.value === operationName) { + operation = definition; + } + break; + case kinds_js_1.Kind.FRAGMENT_DEFINITION: { + fragmentDefinitions[definition.name.value] = definition; + let variableSignatures; + if (definition.variableDefinitions) { + variableSignatures = Object.create(null); + for (const varDef of definition.variableDefinitions) { + const signature = (0, getVariableSignature_js_1.getVariableSignature)(schema, varDef); + variableSignatures[signature.name] = signature; + } + } + fragments[definition.name.value] = { definition, variableSignatures }; + break; + } + default: + // ignore non-executable definitions + } + } + if (!operation) { + if (operationName != null) { + return [new GraphQLError_js_1.GraphQLError(`Unknown operation named "${operationName}".`)]; + } + return [new GraphQLError_js_1.GraphQLError('Must provide an operation.')]; + } + const variableDefinitions = operation.variableDefinitions ?? []; + const hideSuggestions = args.hideSuggestions ?? false; + const variableValuesOrErrors = (0, values_js_1.getVariableValues)(schema, variableDefinitions, rawVariableValues ?? {}, { + maxErrors: 50, + hideSuggestions, + }); + if (variableValuesOrErrors.errors) { + return variableValuesOrErrors.errors; + } + return { + schema, + fragmentDefinitions, + fragments, + rootValue, + contextValue, + operation, + variableValues: variableValuesOrErrors.variableValues, + fieldResolver: fieldResolver ?? exports.defaultFieldResolver, + typeResolver: typeResolver ?? exports.defaultTypeResolver, + subscribeFieldResolver: subscribeFieldResolver ?? exports.defaultFieldResolver, + perEventExecutor: perEventExecutor ?? executeSubscriptionEvent, + enableEarlyExecution: enableEarlyExecution === true, + hideSuggestions, + abortSignal: args.abortSignal ?? undefined, + }; +} +function executeRootExecutionPlan(exeContext, operation, rootType, rootValue, originalGroupedFieldSet, newDeferUsages) { + if (newDeferUsages.length === 0) { + return executeRootGroupedFieldSet(exeContext, operation, rootType, rootValue, originalGroupedFieldSet, undefined); + } + const newDeferMap = getNewDeferMap(newDeferUsages, undefined, undefined); + const { groupedFieldSet, newGroupedFieldSets } = (0, buildExecutionPlan_js_1.buildExecutionPlan)(originalGroupedFieldSet); + const graphqlWrappedResult = executeRootGroupedFieldSet(exeContext, operation, rootType, rootValue, groupedFieldSet, newDeferMap); + if (newGroupedFieldSets.size > 0) { + const newPendingExecutionGroups = collectExecutionGroups(exeContext, rootType, rootValue, undefined, undefined, newGroupedFieldSets, newDeferMap); + return withNewExecutionGroups(graphqlWrappedResult, newPendingExecutionGroups); + } + return graphqlWrappedResult; +} +function withNewExecutionGroups(result, newPendingExecutionGroups) { + if ((0, isPromise_js_1.isPromise)(result)) { + return result.then((resolved) => { + addIncrementalDataRecords(resolved, newPendingExecutionGroups); + return resolved; + }); + } + addIncrementalDataRecords(result, newPendingExecutionGroups); + return result; +} +function executeRootGroupedFieldSet(exeContext, operation, rootType, rootValue, groupedFieldSet, deferMap) { + switch (operation) { + case ast_js_1.OperationTypeNode.QUERY: + return executeFields(exeContext, rootType, rootValue, undefined, groupedFieldSet, undefined, deferMap); + case ast_js_1.OperationTypeNode.MUTATION: + return executeFieldsSerially(exeContext, rootType, rootValue, undefined, groupedFieldSet, undefined, deferMap); + case ast_js_1.OperationTypeNode.SUBSCRIPTION: + // TODO: deprecate `subscribe` and move all logic here + // Temporary solution until we finish merging execute and subscribe together + return executeFields(exeContext, rootType, rootValue, undefined, groupedFieldSet, undefined, deferMap); + } +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that must be executed serially. + */ +function executeFieldsSerially(exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap) { + const abortSignal = exeContext.validatedExecutionArgs.abortSignal; + return (0, promiseReduce_js_1.promiseReduce)(groupedFieldSet, (graphqlWrappedResult, [responseName, fieldDetailsList]) => { + const fieldPath = (0, Path_js_1.addPath)(path, responseName, parentType.name); + if (abortSignal?.aborted) { + handleFieldError(abortSignal.reason, exeContext, parentType, fieldDetailsList, fieldPath, incrementalContext); + graphqlWrappedResult.rawResult[responseName] = null; + return graphqlWrappedResult; + } + const result = executeField(exeContext, parentType, sourceValue, fieldDetailsList, fieldPath, incrementalContext, deferMap); + if (result === undefined) { + return graphqlWrappedResult; + } + if ((0, isPromise_js_1.isPromise)(result)) { + return result.then((resolved) => { + graphqlWrappedResult.rawResult[responseName] = resolved.rawResult; + addIncrementalDataRecords(graphqlWrappedResult, resolved.incrementalDataRecords); + return graphqlWrappedResult; + }); + } + graphqlWrappedResult.rawResult[responseName] = result.rawResult; + addIncrementalDataRecords(graphqlWrappedResult, result.incrementalDataRecords); + return graphqlWrappedResult; + }, { + rawResult: Object.create(null), + incrementalDataRecords: undefined, + }); +} +function addIncrementalDataRecords(graphqlWrappedResult, incrementalDataRecords) { + if (incrementalDataRecords === undefined) { + return; + } + if (graphqlWrappedResult.incrementalDataRecords === undefined) { + graphqlWrappedResult.incrementalDataRecords = [...incrementalDataRecords]; + } + else { + graphqlWrappedResult.incrementalDataRecords.push(...incrementalDataRecords); + } +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that may be executed in parallel. + */ +function executeFields(exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap) { + const results = Object.create(null); + const graphqlWrappedResult = { + rawResult: results, + incrementalDataRecords: undefined, + }; + let containsPromise = false; + try { + for (const [responseName, fieldDetailsList] of groupedFieldSet) { + const fieldPath = (0, Path_js_1.addPath)(path, responseName, parentType.name); + const result = executeField(exeContext, parentType, sourceValue, fieldDetailsList, fieldPath, incrementalContext, deferMap); + if (result !== undefined) { + if ((0, isPromise_js_1.isPromise)(result)) { + results[responseName] = result.then((resolved) => { + addIncrementalDataRecords(graphqlWrappedResult, resolved.incrementalDataRecords); + return resolved.rawResult; + }); + containsPromise = true; + } + else { + results[responseName] = result.rawResult; + addIncrementalDataRecords(graphqlWrappedResult, result.incrementalDataRecords); + } + } + } + } + catch (error) { + if (containsPromise) { + // Ensure that any promises returned by other fields are handled, as they may also reject. + return (0, promiseForObject_js_1.promiseForObject)(results, () => { + /* noop */ + }).finally(() => { + throw error; + }); + } + throw error; + } + // If there are no promises, we can just return the object and any incrementalDataRecords + if (!containsPromise) { + return graphqlWrappedResult; + } + // Otherwise, results is a map from field name to the result of resolving that + // field, which is possibly a promise. Return a promise that will return this + // same map, but with any promises replaced with the values they resolved to. + return (0, promiseForObject_js_1.promiseForObject)(results, (resolved) => ({ + rawResult: resolved, + incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords, + })); +} +function toNodes(fieldDetailsList) { + return fieldDetailsList.map((fieldDetails) => fieldDetails.node); +} +/** + * Implements the "Executing fields" section of the spec + * In particular, this function figures out the value that the field returns by + * calling its resolve function, then calls completeValue to complete promises, + * coercing scalars, or execute the sub-selection-set for objects. + */ +function executeField(exeContext, parentType, source, fieldDetailsList, path, incrementalContext, deferMap) { + const { validatedExecutionArgs, abortSignalListener } = exeContext; + const { schema, contextValue, variableValues, hideSuggestions, abortSignal } = validatedExecutionArgs; + const fieldName = fieldDetailsList[0].node.name.value; + const fieldDef = schema.getField(parentType, fieldName); + if (!fieldDef) { + return; + } + const returnType = fieldDef.type; + const resolveFn = fieldDef.resolve ?? validatedExecutionArgs.fieldResolver; + const info = buildResolveInfo(validatedExecutionArgs, fieldDef, toNodes(fieldDetailsList), parentType, path); + // Get the resolve function, regardless of if its result is normal or abrupt (error). + try { + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + // TODO: find a way to memoize, in case this field is within a List type. + const args = (0, values_js_1.getArgumentValues)(fieldDef, fieldDetailsList[0].node, variableValues, fieldDetailsList[0].fragmentVariableValues, hideSuggestions); + // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + const result = resolveFn(source, args, contextValue, info, abortSignal); + if ((0, isPromise_js_1.isPromise)(result)) { + return completePromisedValue(exeContext, returnType, fieldDetailsList, info, path, abortSignalListener + ? (0, AbortSignalListener_js_1.cancellablePromise)(result, abortSignalListener) + : result, incrementalContext, deferMap); + } + const completed = completeValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + if ((0, isPromise_js_1.isPromise)(completed)) { + // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + return completed.then(undefined, (rawError) => { + handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + }); + } + return completed; + } + catch (rawError) { + handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + } +} +/** + * TODO: consider no longer exporting this function + * @internal + */ +function buildResolveInfo(validatedExecutionArgs, fieldDef, fieldNodes, parentType, path) { + const { schema, fragmentDefinitions, rootValue, operation, variableValues } = validatedExecutionArgs; + // The resolve function's optional fourth argument is a collection of + // information about the current execution state. + return { + fieldName: fieldDef.name, + fieldNodes, + returnType: fieldDef.type, + parentType, + path, + schema, + fragments: fragmentDefinitions, + rootValue, + operation, + variableValues, + }; +} +function handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext) { + const error = (0, locatedError_js_1.locatedError)(rawError, toNodes(fieldDetailsList), (0, Path_js_1.pathToArray)(path)); + // If the field type is non-nullable, then it is resolved without any + // protection from errors, however it still properly locates the error. + if (exeContext.errorPropagation && (0, definition_js_1.isNonNullType)(returnType)) { + throw error; + } + // Otherwise, error protection is applied, logging the error and resolving + // a null value for this field if one is encountered. + const context = incrementalContext ?? exeContext; + let errors = context.errors; + if (errors === undefined) { + errors = []; + context.errors = errors; + } + errors.push(error); +} +/** + * Implements the instructions for completeValue as defined in the + * "Value Completion" section of the spec. + * + * If the field type is Non-Null, then this recursively completes the value + * for the inner type. It throws a field error if that completion returns null, + * as per the "Nullability" section of the spec. + * + * If the field type is a List, then this recursively completes the value + * for the inner type on each item in the list. + * + * If the field type is a Scalar or Enum, ensures the completed value is a legal + * value of the type by calling the `coerceOutputValue` method of GraphQL type + * definition. + * + * If the field is an abstract type, determine the runtime type of the value + * and then complete based on that type + * + * Otherwise, the field type expects a sub-selection set, and will complete the + * value by executing all sub-selections. + */ +function completeValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + // If result is an Error, throw a located error. + if (result instanceof Error) { + throw result; + } + // If field type is NonNull, complete for inner type, and throw field error + // if result is null. + if ((0, definition_js_1.isNonNullType)(returnType)) { + const completed = completeValue(exeContext, returnType.ofType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + if (completed.rawResult === null) { + throw new Error(`Cannot return null for non-nullable field ${info.parentType}.${info.fieldName}.`); + } + return completed; + } + // If result value is null or undefined then return null. + if (result == null) { + return { rawResult: null, incrementalDataRecords: undefined }; + } + // If field type is List, complete each item in the list with the inner type + if ((0, definition_js_1.isListType)(returnType)) { + return completeListValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + } + // If field type is a leaf type, Scalar or Enum, coerce to a valid value, + // returning null if coercion is not possible. + if ((0, definition_js_1.isLeafType)(returnType)) { + return { + rawResult: completeLeafValue(returnType, result), + incrementalDataRecords: undefined, + }; + } + // If field type is an abstract type, Interface or Union, determine the + // runtime Object type and complete for that type. + if ((0, definition_js_1.isAbstractType)(returnType)) { + return completeAbstractValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + } + // If field type is Object, execute and complete all sub-selections. + if ((0, definition_js_1.isObjectType)(returnType)) { + return completeObjectValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + } + /* c8 ignore next 6 */ + // Not reachable, all possible output types have been considered. + (false) || (0, invariant_js_1.invariant)(false, 'Cannot complete value of unexpected output type: ' + (0, inspect_js_1.inspect)(returnType)); +} +async function completePromisedValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + try { + const resolved = await result; + let completed = completeValue(exeContext, returnType, fieldDetailsList, info, path, resolved, incrementalContext, deferMap); + if ((0, isPromise_js_1.isPromise)(completed)) { + completed = await completed; + } + return completed; + } + catch (rawError) { + handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + } +} +/** + * Returns an object containing info for streaming if a field should be + * streamed based on the experimental flag, stream directive present and + * not disabled by the "if" argument. + */ +function getStreamUsage(validatedExecutionArgs, fieldDetailsList, path) { + // do not stream inner lists of multi-dimensional lists + if (typeof path.key === 'number') { + return; + } + // TODO: add test for this case (a streamed list nested under a list). + /* c8 ignore next 7 */ + if (fieldDetailsList + ._streamUsage !== undefined) { + return fieldDetailsList + ._streamUsage; + } + const { operation, variableValues } = validatedExecutionArgs; + // validation only allows equivalent streams on multiple fields, so it is + // safe to only check the first fieldNode for the stream directive + const stream = (0, values_js_1.getDirectiveValues)(directives_js_1.GraphQLStreamDirective, fieldDetailsList[0].node, variableValues, fieldDetailsList[0].fragmentVariableValues); + if (!stream) { + return; + } + if (stream.if === false) { + return; + } + (typeof stream.initialCount === 'number') || (0, invariant_js_1.invariant)(false, 'initialCount must be a number'); + (stream.initialCount >= 0) || (0, invariant_js_1.invariant)(false, 'initialCount must be a positive integer'); + (operation.operation !== ast_js_1.OperationTypeNode.SUBSCRIPTION) || (0, invariant_js_1.invariant)(false, '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.'); + const streamedFieldDetailsList = fieldDetailsList.map((fieldDetails) => ({ + node: fieldDetails.node, + deferUsage: undefined, + fragmentVariableValues: fieldDetails.fragmentVariableValues, + })); + const streamUsage = { + initialCount: stream.initialCount, + label: typeof stream.label === 'string' ? stream.label : undefined, + fieldDetailsList: streamedFieldDetailsList, + }; + fieldDetailsList._streamUsage = + streamUsage; + return streamUsage; +} +/** + * Complete a async iterator value by completing the result and calling + * recursively until all the results are completed. + */ +async function completeAsyncIteratorValue(exeContext, itemType, fieldDetailsList, info, path, asyncIterator, incrementalContext, deferMap) { + let containsPromise = false; + const completedResults = []; + const graphqlWrappedResult = { + rawResult: completedResults, + incrementalDataRecords: undefined, + }; + let index = 0; + const streamUsage = getStreamUsage(exeContext.validatedExecutionArgs, fieldDetailsList, path); + const earlyReturn = asyncIterator.return === undefined + ? undefined + : asyncIterator.return.bind(asyncIterator); + try { + while (true) { + if (streamUsage && index >= streamUsage.initialCount) { + const streamItemQueue = buildAsyncStreamItemQueue(index, path, asyncIterator, exeContext, streamUsage.fieldDetailsList, info, itemType); + let streamRecord; + if (earlyReturn === undefined) { + streamRecord = { + label: streamUsage.label, + path, + streamItemQueue, + }; + } + else { + streamRecord = { + label: streamUsage.label, + path, + earlyReturn, + streamItemQueue, + }; + if (exeContext.cancellableStreams === undefined) { + exeContext.cancellableStreams = new Set(); + } + exeContext.cancellableStreams.add(streamRecord); + } + addIncrementalDataRecords(graphqlWrappedResult, [streamRecord]); + break; + } + const itemPath = (0, Path_js_1.addPath)(path, index, undefined); + let iteration; + try { + // eslint-disable-next-line no-await-in-loop + iteration = await asyncIterator.next(); + } + catch (rawError) { + throw (0, locatedError_js_1.locatedError)(rawError, toNodes(fieldDetailsList), (0, Path_js_1.pathToArray)(path)); + } + // TODO: add test case for stream returning done before initialCount + /* c8 ignore next 3 */ + if (iteration.done) { + break; + } + const item = iteration.value; + // TODO: add tests for stream backed by asyncIterator that returns a promise + /* c8 ignore start */ + if ((0, isPromise_js_1.isPromise)(item)) { + completedResults.push(completePromisedListItemValue(item, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap)); + containsPromise = true; + } + else if ( + /* c8 ignore stop */ + completeListItemValue(item, completedResults, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap) + // TODO: add tests for stream backed by asyncIterator that completes to a promise + /* c8 ignore start */ + ) { + containsPromise = true; + } + /* c8 ignore stop */ + index++; + } + } + catch (error) { + if (earlyReturn !== undefined) { + earlyReturn().catch(() => { + /* c8 ignore next 1 */ + // ignore error + }); + } + throw error; + } + return containsPromise + ? /* c8 ignore start */ Promise.all(completedResults).then((resolved) => ({ + rawResult: resolved, + incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords, + })) + : /* c8 ignore stop */ graphqlWrappedResult; +} +/** + * Complete a list value by completing each item in the list with the + * inner type + */ +function completeListValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + const itemType = returnType.ofType; + if ((0, isAsyncIterable_js_1.isAsyncIterable)(result)) { + const abortSignalListener = exeContext.abortSignalListener; + const maybeCancellableIterable = abortSignalListener + ? (0, AbortSignalListener_js_1.cancellableIterable)(result, abortSignalListener) + : result; + const asyncIterator = maybeCancellableIterable[Symbol.asyncIterator](); + return completeAsyncIteratorValue(exeContext, itemType, fieldDetailsList, info, path, asyncIterator, incrementalContext, deferMap); + } + if (!(0, isIterableObject_js_1.isIterableObject)(result)) { + throw new GraphQLError_js_1.GraphQLError(`Expected Iterable, but did not find one for field "${info.parentType}.${info.fieldName}".`); + } + return completeIterableValue(exeContext, itemType, fieldDetailsList, info, path, result, incrementalContext, deferMap); +} +function completeIterableValue(exeContext, itemType, fieldDetailsList, info, path, items, incrementalContext, deferMap) { + // This is specified as a simple map, however we're optimizing the path + // where the list contains no Promises by avoiding creating another Promise. + let containsPromise = false; + const completedResults = []; + const graphqlWrappedResult = { + rawResult: completedResults, + incrementalDataRecords: undefined, + }; + let index = 0; + const streamUsage = getStreamUsage(exeContext.validatedExecutionArgs, fieldDetailsList, path); + const iterator = items[Symbol.iterator](); + let iteration = iterator.next(); + while (!iteration.done) { + const item = iteration.value; + if (streamUsage && index >= streamUsage.initialCount) { + const syncStreamRecord = { + label: streamUsage.label, + path, + streamItemQueue: buildSyncStreamItemQueue(item, index, path, iterator, exeContext, streamUsage.fieldDetailsList, info, itemType), + }; + addIncrementalDataRecords(graphqlWrappedResult, [syncStreamRecord]); + break; + } + // No need to modify the info object containing the path, + // since from here on it is not ever accessed by resolver functions. + const itemPath = (0, Path_js_1.addPath)(path, index, undefined); + if ((0, isPromise_js_1.isPromise)(item)) { + completedResults.push(completePromisedListItemValue(item, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap)); + containsPromise = true; + } + else if (completeListItemValue(item, completedResults, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap)) { + containsPromise = true; + } + index++; + iteration = iterator.next(); + } + return containsPromise + ? Promise.all(completedResults).then((resolved) => ({ + rawResult: resolved, + incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords, + })) + : graphqlWrappedResult; +} +/** + * Complete a list item value by adding it to the completed results. + * + * Returns true if the value is a Promise. + */ +function completeListItemValue(item, completedResults, parent, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap) { + try { + const completedItem = completeValue(exeContext, itemType, fieldDetailsList, info, itemPath, item, incrementalContext, deferMap); + if ((0, isPromise_js_1.isPromise)(completedItem)) { + // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + completedResults.push(completedItem.then((resolved) => { + addIncrementalDataRecords(parent, resolved.incrementalDataRecords); + return resolved.rawResult; + }, (rawError) => { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + return null; + })); + return true; + } + completedResults.push(completedItem.rawResult); + addIncrementalDataRecords(parent, completedItem.incrementalDataRecords); + } + catch (rawError) { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + completedResults.push(null); + } + return false; +} +async function completePromisedListItemValue(item, parent, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap) { + try { + const abortSignalListener = exeContext.abortSignalListener; + const maybeCancellableItem = abortSignalListener + ? (0, AbortSignalListener_js_1.cancellablePromise)(item, abortSignalListener) + : item; + const resolved = await maybeCancellableItem; + let completed = completeValue(exeContext, itemType, fieldDetailsList, info, itemPath, resolved, incrementalContext, deferMap); + if ((0, isPromise_js_1.isPromise)(completed)) { + completed = await completed; + } + addIncrementalDataRecords(parent, completed.incrementalDataRecords); + return completed.rawResult; + } + catch (rawError) { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + return null; + } +} +/** + * Complete a Scalar or Enum by serializing to a valid value, returning + * null if serialization is not possible. + */ +function completeLeafValue(returnType, result) { + const coerced = returnType.coerceOutputValue(result); + if (coerced == null) { + throw new Error(`Expected \`${(0, inspect_js_1.inspect)(returnType)}.coerceOutputValue(${(0, inspect_js_1.inspect)(result)})\` to ` + + `return non-nullable value, returned: ${(0, inspect_js_1.inspect)(coerced)}`); + } + return coerced; +} +/** + * Complete a value of an abstract type by determining the runtime object type + * of that value, then complete the value for that type. + */ +function completeAbstractValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + const validatedExecutionArgs = exeContext.validatedExecutionArgs; + const { schema, contextValue } = validatedExecutionArgs; + const resolveTypeFn = returnType.resolveType ?? validatedExecutionArgs.typeResolver; + const runtimeType = resolveTypeFn(result, contextValue, info, returnType); + if ((0, isPromise_js_1.isPromise)(runtimeType)) { + return runtimeType.then((resolvedRuntimeType) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, schema, returnType, fieldDetailsList, info, result), fieldDetailsList, info, path, result, incrementalContext, deferMap)); + } + return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, schema, returnType, fieldDetailsList, info, result), fieldDetailsList, info, path, result, incrementalContext, deferMap); +} +function ensureValidRuntimeType(runtimeTypeName, schema, returnType, fieldDetailsList, info, result) { + if (runtimeTypeName == null) { + throw new GraphQLError_js_1.GraphQLError(`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}". Either the "${returnType}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`, { nodes: toNodes(fieldDetailsList) }); + } + if (typeof runtimeTypeName !== 'string') { + throw new GraphQLError_js_1.GraphQLError(`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}" with ` + + `value ${(0, inspect_js_1.inspect)(result)}, received "${(0, inspect_js_1.inspect)(runtimeTypeName)}", which is not a valid Object type name.`); + } + const runtimeType = schema.getType(runtimeTypeName); + if (runtimeType == null) { + throw new GraphQLError_js_1.GraphQLError(`Abstract type "${returnType}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`, { nodes: toNodes(fieldDetailsList) }); + } + if (!(0, definition_js_1.isObjectType)(runtimeType)) { + throw new GraphQLError_js_1.GraphQLError(`Abstract type "${returnType}" was resolved to a non-object type "${runtimeTypeName}".`, { nodes: toNodes(fieldDetailsList) }); + } + if (!schema.isSubType(returnType, runtimeType)) { + throw new GraphQLError_js_1.GraphQLError(`Runtime Object type "${runtimeType}" is not a possible type for "${returnType}".`, { nodes: toNodes(fieldDetailsList) }); + } + return runtimeType; +} +/** + * Complete an Object value by executing all sub-selections. + */ +function completeObjectValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + if ((incrementalContext ?? exeContext).completed) { + throw new Error('Completed, aborting.'); + } + // If there is an isTypeOf predicate function, call it with the + // current result. If isTypeOf returns false, then raise an error rather + // than continuing execution. + if (returnType.isTypeOf) { + const isTypeOf = returnType.isTypeOf(result, exeContext.validatedExecutionArgs.contextValue, info); + if ((0, isPromise_js_1.isPromise)(isTypeOf)) { + return isTypeOf.then((resolvedIsTypeOf) => { + if (!resolvedIsTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldDetailsList); + } + return collectAndExecuteSubfields(exeContext, returnType, fieldDetailsList, path, result, incrementalContext, deferMap); + }); + } + if (!isTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldDetailsList); + } + } + return collectAndExecuteSubfields(exeContext, returnType, fieldDetailsList, path, result, incrementalContext, deferMap); +} +function invalidReturnTypeError(returnType, result, fieldDetailsList) { + return new GraphQLError_js_1.GraphQLError(`Expected value of type "${returnType}" but got: ${(0, inspect_js_1.inspect)(result)}.`, { nodes: toNodes(fieldDetailsList) }); +} +/** + * Instantiates new DeferredFragmentRecords for the given path within an + * incremental data record, returning an updated map of DeferUsage + * objects to DeferredFragmentRecords. + * + * Note: As defer directives may be used with operations returning lists, + * a DeferUsage object may correspond to many DeferredFragmentRecords. + */ +function getNewDeferMap(newDeferUsages, deferMap, path) { + const newDeferMap = new Map(deferMap); + // For each new deferUsage object: + for (const newDeferUsage of newDeferUsages) { + const parentDeferUsage = newDeferUsage.parentDeferUsage; + const parent = parentDeferUsage === undefined + ? undefined + : deferredFragmentRecordFromDeferUsage(parentDeferUsage, newDeferMap); + // Instantiate the new record. + const deferredFragmentRecord = new types_js_1.DeferredFragmentRecord(path, newDeferUsage.label, parent); + // Update the map. + newDeferMap.set(newDeferUsage, deferredFragmentRecord); + } + return newDeferMap; +} +function deferredFragmentRecordFromDeferUsage(deferUsage, deferMap) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return deferMap.get(deferUsage); +} +function collectAndExecuteSubfields(exeContext, returnType, fieldDetailsList, path, result, incrementalContext, deferMap) { + const validatedExecutionArgs = exeContext.validatedExecutionArgs; + // Collect sub-fields to execute to complete this value. + const collectedSubfields = collectSubfields(validatedExecutionArgs, returnType, fieldDetailsList); + const { groupedFieldSet, newDeferUsages } = collectedSubfields; + if (newDeferUsages.length > 0) { + (validatedExecutionArgs.operation.operation !== + ast_js_1.OperationTypeNode.SUBSCRIPTION) || (0, invariant_js_1.invariant)(false, '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.'); + } + return executeSubExecutionPlan(exeContext, returnType, result, groupedFieldSet, newDeferUsages, path, incrementalContext, deferMap); +} +function executeSubExecutionPlan(exeContext, returnType, sourceValue, originalGroupedFieldSet, newDeferUsages, path, incrementalContext, deferMap) { + if (deferMap === undefined && newDeferUsages.length === 0) { + return executeFields(exeContext, returnType, sourceValue, path, originalGroupedFieldSet, incrementalContext, deferMap); + } + const newDeferMap = getNewDeferMap(newDeferUsages, deferMap, path); + const { groupedFieldSet, newGroupedFieldSets } = buildSubExecutionPlan(originalGroupedFieldSet, incrementalContext?.deferUsageSet); + const graphqlWrappedResult = executeFields(exeContext, returnType, sourceValue, path, groupedFieldSet, incrementalContext, newDeferMap); + if (newGroupedFieldSets.size > 0) { + const newPendingExecutionGroups = collectExecutionGroups(exeContext, returnType, sourceValue, path, incrementalContext?.deferUsageSet, newGroupedFieldSets, newDeferMap); + return withNewExecutionGroups(graphqlWrappedResult, newPendingExecutionGroups); + } + return graphqlWrappedResult; +} +function buildSubExecutionPlan(originalGroupedFieldSet, deferUsageSet) { + let executionPlan = originalGroupedFieldSet._executionPlan; + if (executionPlan !== undefined) { + return executionPlan; + } + executionPlan = (0, buildExecutionPlan_js_1.buildExecutionPlan)(originalGroupedFieldSet, deferUsageSet); + originalGroupedFieldSet._executionPlan = executionPlan; + return executionPlan; +} +/** + * If a resolveType function is not given, then a default resolve behavior is + * used which attempts two strategies: + * + * First, See if the provided value has a `__typename` field defined, if so, use + * that value as name of the resolved type. + * + * Otherwise, test each possible type for the abstract type by calling + * isTypeOf for the object being coerced, returning the first type that matches. + */ +const defaultTypeResolver = function (value, contextValue, info, abstractType) { + // First, look for `__typename`. + if ((0, isObjectLike_js_1.isObjectLike)(value) && typeof value.__typename === 'string') { + return value.__typename; + } + // Otherwise, test each possible type. + const possibleTypes = info.schema.getPossibleTypes(abstractType); + const promisedIsTypeOfResults = []; + for (let i = 0; i < possibleTypes.length; i++) { + const type = possibleTypes[i]; + if (type.isTypeOf) { + const isTypeOfResult = type.isTypeOf(value, contextValue, info); + if ((0, isPromise_js_1.isPromise)(isTypeOfResult)) { + promisedIsTypeOfResults[i] = isTypeOfResult; + } + else if (isTypeOfResult) { + if (promisedIsTypeOfResults.length > 0) { + Promise.all(promisedIsTypeOfResults).then(undefined, () => { + /* ignore errors */ + }); + } + return type.name; + } + } + } + if (promisedIsTypeOfResults.length) { + return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => { + for (let i = 0; i < isTypeOfResults.length; i++) { + if (isTypeOfResults[i]) { + return possibleTypes[i].name; + } + } + }); + } +}; +exports.defaultTypeResolver = defaultTypeResolver; +/** + * If a resolve function is not given, then a default resolve behavior is used + * which takes the property of the source object of the same name as the field + * and returns it as the result, or if it's a function, returns the result + * of calling that function while passing along args and context value. + */ +const defaultFieldResolver = function (source, args, contextValue, info, abortSignal) { + // ensure source is a value for which property access is acceptable. + if ((0, isObjectLike_js_1.isObjectLike)(source) || typeof source === 'function') { + const property = source[info.fieldName]; + if (typeof property === 'function') { + return source[info.fieldName](args, contextValue, info, abortSignal); + } + return property; + } +}; +exports.defaultFieldResolver = defaultFieldResolver; +/** + * Implements the "Subscribe" algorithm described in the GraphQL specification. + * + * Returns a Promise which resolves to either an AsyncIterator (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with descriptive + * errors and no data will be returned. + * + * If the source stream could not be created due to faulty subscription resolver + * logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to an AsyncIterator, which + * yields a stream of ExecutionResults representing the response stream. + * + * This function does not support incremental delivery (`@defer` and `@stream`). + * If an operation which would defer or stream data is executed with this + * function, a field error will be raised at the location of the `@defer` or + * `@stream` directive. + * + * Accepts an object with named arguments. + */ +function subscribe(args) { + // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + const validatedExecutionArgs = validateExecutionArgs(args); + // Return early errors if execution context failed. + if (!('schema' in validatedExecutionArgs)) { + return { errors: validatedExecutionArgs }; + } + const resultOrStream = createSourceEventStreamImpl(validatedExecutionArgs); + if ((0, isPromise_js_1.isPromise)(resultOrStream)) { + return resultOrStream.then((resolvedResultOrStream) => mapSourceToResponse(validatedExecutionArgs, resolvedResultOrStream)); + } + return mapSourceToResponse(validatedExecutionArgs, resultOrStream); +} +function mapSourceToResponse(validatedExecutionArgs, resultOrStream) { + if (!(0, isAsyncIterable_js_1.isAsyncIterable)(resultOrStream)) { + return resultOrStream; + } + const abortSignal = validatedExecutionArgs.abortSignal; + const abortSignalListener = abortSignal + ? new AbortSignalListener_js_1.AbortSignalListener(abortSignal) + : undefined; + // For each payload yielded from a subscription, map it over the normal + // GraphQL `execute` function, with `payload` as the rootValue. + // This implements the "MapSourceToResponseEvent" algorithm described in + // the GraphQL specification.. + return (0, mapAsyncIterable_js_1.mapAsyncIterable)(abortSignalListener + ? (0, AbortSignalListener_js_1.cancellableIterable)(resultOrStream, abortSignalListener) + : resultOrStream, (payload) => { + const perEventExecutionArgs = { + ...validatedExecutionArgs, + rootValue: payload, + }; + return validatedExecutionArgs.perEventExecutor(perEventExecutionArgs); + }, () => abortSignalListener?.disconnect()); +} +function executeSubscriptionEvent(validatedExecutionArgs) { + return executeQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs); +} +/** + * Implements the "CreateSourceEventStream" algorithm described in the + * GraphQL specification, resolving the subscription source event stream. + * + * Returns a Promise which resolves to either an AsyncIterable (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with + * descriptive errors and no data will be returned. + * + * If the the source stream could not be created due to faulty subscription + * resolver logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to the AsyncIterable for the + * event stream returned by the resolver. + * + * A Source Event Stream represents a sequence of events, each of which triggers + * a GraphQL execution for that event. + * + * This may be useful when hosting the stateful subscription service in a + * different process or machine than the stateless GraphQL execution engine, + * or otherwise separating these two steps. For more on this, see the + * "Supporting Subscriptions at Scale" information in the GraphQL specification. + */ +function createSourceEventStream(args) { + // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + const validatedExecutionArgs = validateExecutionArgs(args); + // Return early errors if execution context failed. + if (!('schema' in validatedExecutionArgs)) { + return { errors: validatedExecutionArgs }; + } + return createSourceEventStreamImpl(validatedExecutionArgs); +} +function createSourceEventStreamImpl(validatedExecutionArgs) { + try { + const eventStream = executeSubscription(validatedExecutionArgs); + if ((0, isPromise_js_1.isPromise)(eventStream)) { + return eventStream.then(undefined, (error) => ({ + errors: [error], + })); + } + return eventStream; + } + catch (error) { + return { errors: [error] }; + } +} +function executeSubscription(validatedExecutionArgs) { + const { schema, fragments, rootValue, contextValue, operation, variableValues, hideSuggestions, abortSignal, } = validatedExecutionArgs; + const rootType = schema.getSubscriptionType(); + if (rootType == null) { + throw new GraphQLError_js_1.GraphQLError('Schema is not configured to execute subscription operation.', { nodes: operation }); + } + const { groupedFieldSet } = (0, collectFields_js_1.collectFields)(schema, fragments, variableValues, rootType, operation.selectionSet, hideSuggestions); + const firstRootField = groupedFieldSet.entries().next().value; + const [responseName, fieldDetailsList] = firstRootField; + const fieldName = fieldDetailsList[0].node.name.value; + const fieldDef = schema.getField(rootType, fieldName); + const fieldNodes = fieldDetailsList.map((fieldDetails) => fieldDetails.node); + if (!fieldDef) { + throw new GraphQLError_js_1.GraphQLError(`The subscription field "${fieldName}" is not defined.`, { nodes: fieldNodes }); + } + const path = (0, Path_js_1.addPath)(undefined, responseName, rootType.name); + const info = buildResolveInfo(validatedExecutionArgs, fieldDef, fieldNodes, rootType, path); + try { + // Implements the "ResolveFieldEventStream" algorithm from GraphQL specification. + // It differs from "ResolveFieldValue" due to providing a different `resolveFn`. + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + const args = (0, values_js_1.getArgumentValues)(fieldDef, fieldNodes[0], variableValues, fieldDetailsList[0].fragmentVariableValues, hideSuggestions); + // Call the `subscribe()` resolver or the default resolver to produce an + // AsyncIterable yielding raw payloads. + const resolveFn = fieldDef.subscribe ?? validatedExecutionArgs.subscribeFieldResolver; + // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + const result = resolveFn(rootValue, args, contextValue, info, abortSignal); + if ((0, isPromise_js_1.isPromise)(result)) { + const abortSignalListener = abortSignal + ? new AbortSignalListener_js_1.AbortSignalListener(abortSignal) + : undefined; + const promise = abortSignalListener + ? (0, AbortSignalListener_js_1.cancellablePromise)(result, abortSignalListener) + : result; + return promise.then(assertEventStream).then((resolved) => { + abortSignalListener?.disconnect(); + return resolved; + }, (error) => { + abortSignalListener?.disconnect(); + throw (0, locatedError_js_1.locatedError)(error, fieldNodes, (0, Path_js_1.pathToArray)(path)); + }); + } + return assertEventStream(result); + } + catch (error) { + throw (0, locatedError_js_1.locatedError)(error, fieldNodes, (0, Path_js_1.pathToArray)(path)); + } +} +function assertEventStream(result) { + if (result instanceof Error) { + throw result; + } + // Assert field returned an event stream, otherwise yield an error. + if (!(0, isAsyncIterable_js_1.isAsyncIterable)(result)) { + throw new GraphQLError_js_1.GraphQLError('Subscription field must return Async Iterable. ' + + `Received: ${(0, inspect_js_1.inspect)(result)}.`); + } + return result; +} +function collectExecutionGroups(exeContext, parentType, sourceValue, path, parentDeferUsages, newGroupedFieldSets, deferMap) { + const newPendingExecutionGroups = []; + for (const [deferUsageSet, groupedFieldSet] of newGroupedFieldSets) { + const deferredFragmentRecords = getDeferredFragmentRecords(deferUsageSet, deferMap); + const pendingExecutionGroup = { + deferredFragmentRecords, + result: undefined, + }; + const executor = () => executeExecutionGroup(pendingExecutionGroup, exeContext, parentType, sourceValue, path, groupedFieldSet, { + errors: undefined, + completed: false, + deferUsageSet, + }, deferMap); + if (exeContext.validatedExecutionArgs.enableEarlyExecution) { + pendingExecutionGroup.result = new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(shouldDefer(parentDeferUsages, deferUsageSet) + ? Promise.resolve().then(executor) + : executor()); + } + else { + pendingExecutionGroup.result = () => new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(executor()); + } + newPendingExecutionGroups.push(pendingExecutionGroup); + } + return newPendingExecutionGroups; +} +function shouldDefer(parentDeferUsages, deferUsages) { + // If we have a new child defer usage, defer. + // Otherwise, this defer usage was already deferred when it was initially + // encountered, and is now in the midst of executing early, so the new + // deferred grouped fields set can be executed immediately. + return (parentDeferUsages === undefined || + !Array.from(deferUsages).every((deferUsage) => parentDeferUsages.has(deferUsage))); +} +function executeExecutionGroup(pendingExecutionGroup, exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap) { + let result; + try { + result = executeFields(exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap); + } + catch (error) { + incrementalContext.completed = true; + return { + pendingExecutionGroup, + path: (0, Path_js_1.pathToArray)(path), + errors: withError(incrementalContext.errors, error), + }; + } + if ((0, isPromise_js_1.isPromise)(result)) { + return result.then((resolved) => { + incrementalContext.completed = true; + return buildCompletedExecutionGroup(incrementalContext.errors, pendingExecutionGroup, path, resolved); + }, (error) => { + incrementalContext.completed = true; + return { + pendingExecutionGroup, + path: (0, Path_js_1.pathToArray)(path), + errors: withError(incrementalContext.errors, error), + }; + }); + } + incrementalContext.completed = true; + return buildCompletedExecutionGroup(incrementalContext.errors, pendingExecutionGroup, path, result); +} +function buildCompletedExecutionGroup(errors, pendingExecutionGroup, path, result) { + const { rawResult: data, incrementalDataRecords } = result; + return { + pendingExecutionGroup, + path: (0, Path_js_1.pathToArray)(path), + result: errors === undefined ? { data } : { data, errors }, + incrementalDataRecords, + }; +} +function getDeferredFragmentRecords(deferUsages, deferMap) { + return Array.from(deferUsages).map((deferUsage) => deferredFragmentRecordFromDeferUsage(deferUsage, deferMap)); +} +function buildSyncStreamItemQueue(initialItem, initialIndex, streamPath, iterator, exeContext, fieldDetailsList, info, itemType) { + const streamItemQueue = []; + const enableEarlyExecution = exeContext.validatedExecutionArgs.enableEarlyExecution; + const firstExecutor = () => { + const initialPath = (0, Path_js_1.addPath)(streamPath, initialIndex, undefined); + const firstStreamItem = new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(completeStreamItem(initialPath, initialItem, exeContext, { errors: undefined, completed: false }, fieldDetailsList, info, itemType)); + let iteration = iterator.next(); + let currentIndex = initialIndex + 1; + let currentStreamItem = firstStreamItem; + while (!iteration.done) { + // TODO: add test case for early sync termination + /* c8 ignore next 6 */ + if (currentStreamItem instanceof BoxedPromiseOrValue_js_1.BoxedPromiseOrValue) { + const result = currentStreamItem.value; + if (!(0, isPromise_js_1.isPromise)(result) && result.errors !== undefined) { + break; + } + } + const itemPath = (0, Path_js_1.addPath)(streamPath, currentIndex, undefined); + const value = iteration.value; + const currentExecutor = () => completeStreamItem(itemPath, value, exeContext, { errors: undefined, completed: false }, fieldDetailsList, info, itemType); + currentStreamItem = enableEarlyExecution + ? new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(currentExecutor()) + : () => new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(currentExecutor()); + streamItemQueue.push(currentStreamItem); + iteration = iterator.next(); + currentIndex = initialIndex + 1; + } + streamItemQueue.push(new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue({})); + return firstStreamItem.value; + }; + streamItemQueue.push(enableEarlyExecution + ? new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(Promise.resolve().then(firstExecutor)) + : () => new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(firstExecutor())); + return streamItemQueue; +} +function buildAsyncStreamItemQueue(initialIndex, streamPath, asyncIterator, exeContext, fieldDetailsList, info, itemType) { + const streamItemQueue = []; + const executor = () => getNextAsyncStreamItemResult(streamItemQueue, streamPath, initialIndex, asyncIterator, exeContext, fieldDetailsList, info, itemType); + streamItemQueue.push(exeContext.validatedExecutionArgs.enableEarlyExecution + ? new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(executor()) + : () => new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(executor())); + return streamItemQueue; +} +async function getNextAsyncStreamItemResult(streamItemQueue, streamPath, index, asyncIterator, exeContext, fieldDetailsList, info, itemType) { + let iteration; + try { + iteration = await asyncIterator.next(); + } + catch (error) { + return { + errors: [ + (0, locatedError_js_1.locatedError)(error, toNodes(fieldDetailsList), (0, Path_js_1.pathToArray)(streamPath)), + ], + }; + } + if (iteration.done) { + return {}; + } + const itemPath = (0, Path_js_1.addPath)(streamPath, index, undefined); + const result = completeStreamItem(itemPath, iteration.value, exeContext, { errors: undefined, completed: false }, fieldDetailsList, info, itemType); + const executor = () => getNextAsyncStreamItemResult(streamItemQueue, streamPath, index + 1, asyncIterator, exeContext, fieldDetailsList, info, itemType); + streamItemQueue.push(exeContext.validatedExecutionArgs.enableEarlyExecution + ? new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(executor()) + : () => new BoxedPromiseOrValue_js_1.BoxedPromiseOrValue(executor())); + return result; +} +function completeStreamItem(itemPath, item, exeContext, incrementalContext, fieldDetailsList, info, itemType) { + if ((0, isPromise_js_1.isPromise)(item)) { + const abortSignalListener = exeContext.abortSignalListener; + const maybeCancellableItem = abortSignalListener + ? (0, AbortSignalListener_js_1.cancellablePromise)(item, abortSignalListener) + : item; + return completePromisedValue(exeContext, itemType, fieldDetailsList, info, itemPath, maybeCancellableItem, incrementalContext, new Map()).then((resolvedItem) => { + incrementalContext.completed = true; + return buildStreamItemResult(incrementalContext.errors, resolvedItem); + }, (error) => { + incrementalContext.completed = true; + return { + errors: withError(incrementalContext.errors, error), + }; + }); + } + let result; + try { + try { + result = completeValue(exeContext, itemType, fieldDetailsList, info, itemPath, item, incrementalContext, new Map()); + } + catch (rawError) { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + result = { rawResult: null, incrementalDataRecords: undefined }; + } + } + catch (error) { + incrementalContext.completed = true; + return { + errors: withError(incrementalContext.errors, error), + }; + } + if ((0, isPromise_js_1.isPromise)(result)) { + return result + .then(undefined, (rawError) => { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + }) + .then((resolvedItem) => { + incrementalContext.completed = true; + return buildStreamItemResult(incrementalContext.errors, resolvedItem); + }, (error) => { + incrementalContext.completed = true; + return { + errors: withError(incrementalContext.errors, error), + }; + }); + } + incrementalContext.completed = true; + return buildStreamItemResult(incrementalContext.errors, result); +} +function buildStreamItemResult(errors, result) { + const { rawResult: item, incrementalDataRecords } = result; + return { + item, + errors, + incrementalDataRecords, + }; +} +//# sourceMappingURL=execute.js.map \ No newline at end of file diff --git a/execution/execute.js.map b/execution/execute.js.map new file mode 100644 index 0000000000..7f18bc01d9 --- /dev/null +++ b/execution/execute.js.map @@ -0,0 +1 @@ +{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/execution/execute.ts"],"names":[],"mappings":";;;AA4OA,0BASC;AAiCD,4EAeC;AAiBD,8FAOC;AAWD,sHA6EC;AAiCD,kCASC;AAWD,sDAuGC;AAqYD,4CAuBC;AAinCD,8BAuBC;AAkCD,4DAIC;AA8BD,0DAaC;AAtqED,8EAAwE;AACxE,sDAAgD;AAChD,0DAAoD;AACpD,sEAAgE;AAChE,wEAAkE;AAClE,gEAA0D;AAC1D,0DAAoD;AAEpD,wDAAkD;AAGlD,gDAA0D;AAC1D,wEAAkE;AAElE,kEAA4D;AAE5D,8DAAwD;AACxD,8DAAwD;AAQxD,+CAAuD;AACvD,mDAA4C;AAa5C,yDAM+B;AAC/B,yDAG+B;AAE/B,qDAAwD;AAExD,qEAIkC;AAElC,mEAA6D;AAO7D,yDAG4B;AAC5B,uEAAiE;AACjE,uEAAqE;AACrE,+DAAyD;AAYzD,yCAAoD;AAEpD,2CAIqB;AAErB,kDAAkD;AAClD,4EAA4E;AAC5E,sCAAsC;AAEtC;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,IAAA,sBAAQ,EAC/B,CACE,sBAA8C,EAC9C,UAA6B,EAC7B,gBAAkC,EAClC,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,GAC1D,sBAAsB,CAAC;IACzB,OAAO,IAAA,mCAAiB,EACtB,MAAM,EACN,SAAS,EACT,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,CAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAgGF,MAAM,kCAAkC,GACtC,yLAAyL,CAAC;AAE5L,MAAM,4BAA4B,GAChC,oHAAoH,CA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AY,CAAC,CAAC;QACxE,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;YACjB,kBAAkB,CAAC,SAAS,GAAG,IAAI,CAAC;YACpC,OAAO;gBACL,MAAM,EAAE,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAqB,CAAC;aACpE,CAAC;QACJ,CAAC,CACF,CAAC;IACN,CAAC;IAED,kBAAkB,CAAC,SAAS,GAAG,IAAI,CAAC;IACpC,OAAO,qBAAqB,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,qBAAqB,CAC5B,MAA+C,EAC/C,MAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,sBAAsB,EAAE,GAAG,MAAM,CAAC;IAC3D,OAAO;QACL,IAAI;QACJ,MAAM;QACN,sBAAsB;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import { BoxedPromiseOrValue } from '../jsutils/BoxedPromiseOrValue.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isAsyncIterable } from '../jsutils/isAsyncIterable.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { isPromise } from '../jsutils/isPromise.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport { memoize3 } from '../jsutils/memoize3.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport type { Path } from '../jsutils/Path.js';\nimport { addPath, pathToArray } from '../jsutils/Path.js';\nimport { promiseForObject } from '../jsutils/promiseForObject.js';\nimport type { PromiseOrValue } from '../jsutils/PromiseOrValue.js';\nimport { promiseReduce } from '../jsutils/promiseReduce.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\nimport { locatedError } from '../error/locatedError.js';\n\nimport type {\n DocumentNode,\n FieldNode,\n FragmentDefinitionNode,\n OperationDefinitionNode,\n} from '../language/ast.js';\nimport { OperationTypeNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type {\n GraphQLAbstractType,\n GraphQLField,\n GraphQLFieldResolver,\n GraphQLLeafType,\n GraphQLList,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLResolveInfo,\n GraphQLTypeResolver,\n} from '../type/definition.js';\nimport {\n isAbstractType,\n isLeafType,\n isListType,\n isNonNullType,\n isObjectType,\n} from '../type/definition.js';\nimport {\n GraphQLDisableErrorPropagationDirective,\n GraphQLStreamDirective,\n} from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\nimport { assertValidSchema } from '../type/validate.js';\n\nimport {\n AbortSignalListener,\n cancellableIterable,\n cancellablePromise,\n} from './AbortSignalListener.js';\nimport type { DeferUsageSet, ExecutionPlan } from './buildExecutionPlan.js';\nimport { buildExecutionPlan } from './buildExecutionPlan.js';\nimport type {\n DeferUsage,\n FieldDetailsList,\n FragmentDetails,\n GroupedFieldSet,\n} from './collectFields.js';\nimport {\n collectFields,\n collectSubfields as _collectSubfields,\n} from './collectFields.js';\nimport { getVariableSignature } from './getVariableSignature.js';\nimport { buildIncrementalResponse } from './IncrementalPublisher.js';\nimport { mapAsyncIterable } from './mapAsyncIterable.js';\nimport type {\n CancellableStreamRecord,\n CompletedExecutionGroup,\n ExecutionResult,\n ExperimentalIncrementalExecutionResults,\n IncrementalDataRecord,\n PendingExecutionGroup,\n StreamItemRecord,\n StreamItemResult,\n StreamRecord,\n} from './types.js';\nimport { DeferredFragmentRecord } from './types.js';\nimport type { VariableValues } from './values.js';\nimport {\n getArgumentValues,\n getDirectiveValues,\n getVariableValues,\n} from './values.js';\n\n/* eslint-disable @typescript-eslint/max-params */\n// This file contains a lot of such errors but we plan to refactor it anyway\n// so just disable it for entire file.\n\n/**\n * A memoized collection of relevant subfields with regard to the return\n * type. Memoizing ensures the subfields are not repeatedly calculated, which\n * saves overhead when resolving lists of values.\n */\nconst collectSubfields = memoize3(\n (\n validatedExecutionArgs: ValidatedExecutionArgs,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n ) => {\n const { schema, fragments, variableValues, hideSuggestions } =\n validatedExecutionArgs;\n return _collectSubfields(\n schema,\n fragments,\n variableValues,\n returnType,\n fieldDetailsList,\n hideSuggestions,\n );\n },\n);\n\n/**\n * Terminology\n *\n * \"Definitions\" are the generic name for top-level statements in the document.\n * Examples of this include:\n * 1) Operations (such as a query)\n * 2) Fragments\n *\n * \"Operations\" are a generic name for requests in the document.\n * Examples of this include:\n * 1) query,\n * 2) mutation\n *\n * \"Selections\" are the definitions that can appear legally and at\n * single level of the query. These include:\n * 1) field references e.g `a`\n * 2) fragment \"spreads\" e.g. `...c`\n * 3) inline fragment \"spreads\" e.g. `...on Type { a }`\n */\n\n/**\n * Data that must be available at all points during query execution.\n *\n * Namely, schema of the type system that is currently executing,\n * and the fragments defined in the query document\n */\nexport interface ValidatedExecutionArgs {\n schema: GraphQLSchema;\n // TODO: consider deprecating/removing fragmentDefinitions if/when fragment\n // arguments are officially supported and/or the full fragment details are\n // exposed within GraphQLResolveInfo.\n fragmentDefinitions: ObjMap;\n fragments: ObjMap;\n rootValue: unknown;\n contextValue: unknown;\n operation: OperationDefinitionNode;\n variableValues: VariableValues;\n fieldResolver: GraphQLFieldResolver;\n typeResolver: GraphQLTypeResolver;\n subscribeFieldResolver: GraphQLFieldResolver;\n perEventExecutor: (\n validatedExecutionArgs: ValidatedExecutionArgs,\n ) => PromiseOrValue;\n enableEarlyExecution: boolean;\n hideSuggestions: boolean;\n abortSignal: AbortSignal | undefined;\n}\n\nexport interface ExecutionContext {\n validatedExecutionArgs: ValidatedExecutionArgs;\n errors: Array | undefined;\n abortSignalListener: AbortSignalListener | undefined;\n completed: boolean;\n cancellableStreams: Set | undefined;\n errorPropagation: boolean;\n}\n\ninterface IncrementalContext {\n errors: Array | undefined;\n completed: boolean;\n deferUsageSet?: DeferUsageSet | undefined;\n}\n\nexport interface ExecutionArgs {\n schema: GraphQLSchema;\n document: DocumentNode;\n rootValue?: unknown;\n contextValue?: unknown;\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>;\n operationName?: Maybe;\n fieldResolver?: Maybe>;\n typeResolver?: Maybe>;\n subscribeFieldResolver?: Maybe>;\n perEventExecutor?: Maybe<\n (\n validatedExecutionArgs: ValidatedExecutionArgs,\n ) => PromiseOrValue\n >;\n enableEarlyExecution?: Maybe;\n hideSuggestions?: Maybe;\n abortSignal?: Maybe;\n}\n\nexport interface StreamUsage {\n label: string | undefined;\n initialCount: number;\n fieldDetailsList: FieldDetailsList;\n}\n\ninterface GraphQLWrappedResult {\n rawResult: T;\n incrementalDataRecords: Array | undefined;\n}\n\nconst UNEXPECTED_EXPERIMENTAL_DIRECTIVES =\n 'The provided schema unexpectedly contains experimental directives (@defer or @stream). These directives may only be utilized if experimental execution features are explicitly enabled.';\n\nconst UNEXPECTED_MULTIPLE_PAYLOADS =\n 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)';\n\n/**\n * Implements the \"Executing requests\" section of the GraphQL specification.\n *\n * Returns either a synchronous ExecutionResult (if all encountered resolvers\n * are synchronous), or a Promise of an ExecutionResult that will eventually be\n * resolved and never rejected.\n *\n * If the arguments to this function do not result in a legal execution context,\n * a GraphQLError will be thrown immediately explaining the invalid input.\n *\n * This function does not support incremental delivery (`@defer` and `@stream`).\n * If an operation which would defer or stream data is executed with this\n * function, it will throw or return a rejected promise.\n * Use `experimentalExecuteIncrementally` if you want to support incremental\n * delivery.\n */\nexport function execute(args: ExecutionArgs): PromiseOrValue {\n if (args.schema.getDirective('defer') || args.schema.getDirective('stream')) {\n throw new Error(UNEXPECTED_EXPERIMENTAL_DIRECTIVES);\n }\n\n const result = experimentalExecuteIncrementally(args);\n // Multiple payloads could be encountered if the operation contains @defer or\n // @stream directives and is not validated prior to execution\n return ensureSinglePayload(result);\n}\n\nfunction ensureSinglePayload(\n result: PromiseOrValue<\n ExecutionResult | ExperimentalIncrementalExecutionResults\n >,\n): PromiseOrValue {\n if (isPromise(result)) {\n return result.then((resolved) => {\n if ('initialResult' in resolved) {\n throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS);\n }\n return resolved;\n });\n }\n if ('initialResult' in result) {\n throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS);\n }\n return result;\n}\n\n/**\n * Implements the \"Executing requests\" section of the GraphQL specification,\n * including `@defer` and `@stream` as proposed in\n * https://github.com/graphql/graphql-spec/pull/742\n *\n * This function returns a Promise of an ExperimentalIncrementalExecutionResults\n * object. This object either consists of a single ExecutionResult, or an\n * object containing an `initialResult` and a stream of `subsequentResults`.\n *\n * If the arguments to this function do not result in a legal execution context,\n * a GraphQLError will be thrown immediately explaining the invalid input.\n */\nexport function experimentalExecuteIncrementally(\n args: ExecutionArgs,\n): PromiseOrValue {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const validatedExecutionArgs = validateExecutionArgs(args);\n\n // Return early errors if execution context failed.\n if (!('schema' in validatedExecutionArgs)) {\n return { errors: validatedExecutionArgs };\n }\n\n return experimentalExecuteQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs,\n );\n}\n\n/**\n * Implements the \"Executing operations\" section of the spec.\n *\n * Returns a Promise that will eventually resolve to the data described by\n * The \"Response\" section of the GraphQL specification.\n *\n * If errors are encountered while executing a GraphQL field, only that\n * field and its descendants will be omitted, and sibling fields will still\n * be executed. An execution which encounters errors will still result in a\n * resolved Promise.\n *\n * Errors from sub-fields of a NonNull type may propagate to the top level,\n * at which point we still log the error and null the parent field, which\n * in this case is the entire response.\n */\nexport function executeQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue {\n const result = experimentalExecuteQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs,\n );\n return ensureSinglePayload(result);\n}\n\nfunction errorPropagation(operation: OperationDefinitionNode): boolean {\n const directiveNode = operation.directives?.find(\n (directive) =>\n directive.name.value === GraphQLDisableErrorPropagationDirective.name,\n );\n\n return directiveNode === undefined;\n}\n\nexport function experimentalExecuteQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue {\n const abortSignal = validatedExecutionArgs.abortSignal;\n const exeContext: ExecutionContext = {\n validatedExecutionArgs,\n errors: undefined,\n abortSignalListener: abortSignal\n ? new AbortSignalListener(abortSignal)\n : undefined,\n completed: false,\n cancellableStreams: undefined,\n errorPropagation: errorPropagation(validatedExecutionArgs.operation),\n };\n try {\n const {\n schema,\n fragments,\n rootValue,\n operation,\n variableValues,\n hideSuggestions,\n } = validatedExecutionArgs;\n\n const { operation: operationType, selectionSet } = operation;\n\n const rootType = schema.getRootType(operationType);\n if (rootType == null) {\n throw new GraphQLError(\n `Schema is not configured to execute ${operationType} operation.`,\n { nodes: operation },\n );\n }\n\n const { groupedFieldSet, newDeferUsages } = collectFields(\n schema,\n fragments,\n variableValues,\n rootType,\n selectionSet,\n hideSuggestions,\n );\n\n const graphqlWrappedResult = executeRootExecutionPlan(\n exeContext,\n operation.operation,\n rootType,\n rootValue,\n groupedFieldSet,\n newDeferUsages,\n );\n\n if (isPromise(graphqlWrappedResult)) {\n return graphqlWrappedResult.then(\n (resolved) => {\n exeContext.completed = true;\n return buildDataResponse(exeContext, resolved);\n },\n (error: unknown) => {\n exeContext.completed = true;\n exeContext.abortSignalListener?.disconnect();\n return {\n data: null,\n errors: withError(exeContext.errors, error as GraphQLError),\n };\n },\n );\n }\n exeContext.completed = true;\n return buildDataResponse(exeContext, graphqlWrappedResult);\n } catch (error) {\n exeContext.completed = true;\n // TODO: add test case for synchronous null bubbling to root with cancellation\n /* c8 ignore next */\n exeContext.abortSignalListener?.disconnect();\n return { data: null, errors: withError(exeContext.errors, error) };\n }\n}\n\nfunction withError(\n errors: Array | undefined,\n error: GraphQLError,\n): ReadonlyArray {\n return errors === undefined ? [error] : [...errors, error];\n}\n\nfunction buildDataResponse(\n exeContext: ExecutionContext,\n graphqlWrappedResult: GraphQLWrappedResult>,\n): ExecutionResult | ExperimentalIncrementalExecutionResults {\n const { rawResult: data, incrementalDataRecords } = graphqlWrappedResult;\n const errors = exeContext.errors;\n if (incrementalDataRecords === undefined) {\n exeContext.abortSignalListener?.disconnect();\n return errors !== undefined ? { errors, data } : { data };\n }\n\n return buildIncrementalResponse(\n exeContext,\n data,\n errors,\n incrementalDataRecords,\n );\n}\n\n/**\n * Also implements the \"Executing requests\" section of the GraphQL specification.\n * However, it guarantees to complete synchronously (or throw an error) assuming\n * that all field resolvers are also synchronous.\n */\nexport function executeSync(args: ExecutionArgs): ExecutionResult {\n const result = experimentalExecuteIncrementally(args);\n\n // Assert that the execution was synchronous.\n if (isPromise(result) || 'initialResult' in result) {\n throw new Error('GraphQL execution failed to complete synchronously.');\n }\n\n return result;\n}\n\n/**\n * Constructs a ExecutionContext object from the arguments passed to\n * execute, which we will pass throughout the other execution methods.\n *\n * Throws a GraphQLError if a valid execution context cannot be created.\n *\n * TODO: consider no longer exporting this function\n * @internal\n */\nexport function validateExecutionArgs(\n args: ExecutionArgs,\n): ReadonlyArray | ValidatedExecutionArgs {\n const {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues: rawVariableValues,\n operationName,\n fieldResolver,\n typeResolver,\n subscribeFieldResolver,\n perEventExecutor,\n enableEarlyExecution,\n abortSignal,\n } = args;\n\n if (abortSignal?.aborted) {\n return [locatedError(abortSignal.reason, undefined)];\n }\n\n // If the schema used for execution is invalid, throw an error.\n assertValidSchema(schema);\n\n let operation: OperationDefinitionNode | undefined;\n const fragmentDefinitions: ObjMap =\n Object.create(null);\n const fragments: ObjMap = Object.create(null);\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n return [\n new GraphQLError(\n 'Must provide operation name if query contains multiple operations.',\n ),\n ];\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n case Kind.FRAGMENT_DEFINITION: {\n fragmentDefinitions[definition.name.value] = definition;\n let variableSignatures;\n if (definition.variableDefinitions) {\n variableSignatures = Object.create(null);\n for (const varDef of definition.variableDefinitions) {\n const signature = getVariableSignature(schema, varDef);\n variableSignatures[signature.name] = signature;\n }\n }\n fragments[definition.name.value] = { definition, variableSignatures };\n break;\n }\n default:\n // ignore non-executable definitions\n }\n }\n\n if (!operation) {\n if (operationName != null) {\n return [new GraphQLError(`Unknown operation named \"${operationName}\".`)];\n }\n return [new GraphQLError('Must provide an operation.')];\n }\n\n const variableDefinitions = operation.variableDefinitions ?? [];\n const hideSuggestions = args.hideSuggestions ?? false;\n\n const variableValuesOrErrors = getVariableValues(\n schema,\n variableDefinitions,\n rawVariableValues ?? {},\n {\n maxErrors: 50,\n hideSuggestions,\n },\n );\n\n if (variableValuesOrErrors.errors) {\n return variableValuesOrErrors.errors;\n }\n\n return {\n schema,\n fragmentDefinitions,\n fragments,\n rootValue,\n contextValue,\n operation,\n variableValues: variableValuesOrErrors.variableValues,\n fieldResolver: fieldResolver ?? defaultFieldResolver,\n typeResolver: typeResolver ?? defaultTypeResolver,\n subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver,\n perEventExecutor: perEventExecutor ?? executeSubscriptionEvent,\n enableEarlyExecution: enableEarlyExecution === true,\n hideSuggestions,\n abortSignal: args.abortSignal ?? undefined,\n };\n}\n\nfunction executeRootExecutionPlan(\n exeContext: ExecutionContext,\n operation: OperationTypeNode,\n rootType: GraphQLObjectType,\n rootValue: unknown,\n originalGroupedFieldSet: GroupedFieldSet,\n newDeferUsages: ReadonlyArray,\n): PromiseOrValue>> {\n if (newDeferUsages.length === 0) {\n return executeRootGroupedFieldSet(\n exeContext,\n operation,\n rootType,\n rootValue,\n originalGroupedFieldSet,\n undefined,\n );\n }\n const newDeferMap = getNewDeferMap(newDeferUsages, undefined, undefined);\n\n const { groupedFieldSet, newGroupedFieldSets } = buildExecutionPlan(\n originalGroupedFieldSet,\n );\n\n const graphqlWrappedResult = executeRootGroupedFieldSet(\n exeContext,\n operation,\n rootType,\n rootValue,\n groupedFieldSet,\n newDeferMap,\n );\n\n if (newGroupedFieldSets.size > 0) {\n const newPendingExecutionGroups = collectExecutionGroups(\n exeContext,\n rootType,\n rootValue,\n undefined,\n undefined,\n newGroupedFieldSets,\n newDeferMap,\n );\n\n return withNewExecutionGroups(\n graphqlWrappedResult,\n newPendingExecutionGroups,\n );\n }\n return graphqlWrappedResult;\n}\n\nfunction withNewExecutionGroups(\n result: PromiseOrValue>>,\n newPendingExecutionGroups: ReadonlyArray,\n): PromiseOrValue>> {\n if (isPromise(result)) {\n return result.then((resolved) => {\n addIncrementalDataRecords(resolved, newPendingExecutionGroups);\n return resolved;\n });\n }\n\n addIncrementalDataRecords(result, newPendingExecutionGroups);\n return result;\n}\n\nfunction executeRootGroupedFieldSet(\n exeContext: ExecutionContext,\n operation: OperationTypeNode,\n rootType: GraphQLObjectType,\n rootValue: unknown,\n groupedFieldSet: GroupedFieldSet,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return executeFields(\n exeContext,\n rootType,\n rootValue,\n undefined,\n groupedFieldSet,\n undefined,\n deferMap,\n );\n case OperationTypeNode.MUTATION:\n return executeFieldsSerially(\n exeContext,\n rootType,\n rootValue,\n undefined,\n groupedFieldSet,\n undefined,\n deferMap,\n );\n case OperationTypeNode.SUBSCRIPTION:\n // TODO: deprecate `subscribe` and move all logic here\n // Temporary solution until we finish merging execute and subscribe together\n return executeFields(\n exeContext,\n rootType,\n rootValue,\n undefined,\n groupedFieldSet,\n undefined,\n deferMap,\n );\n }\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that must be executed serially.\n */\nfunction executeFieldsSerially(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const abortSignal = exeContext.validatedExecutionArgs.abortSignal;\n return promiseReduce(\n groupedFieldSet,\n (graphqlWrappedResult, [responseName, fieldDetailsList]) => {\n const fieldPath = addPath(path, responseName, parentType.name);\n\n if (abortSignal?.aborted) {\n handleFieldError(\n abortSignal.reason,\n exeContext,\n parentType,\n fieldDetailsList,\n fieldPath,\n incrementalContext,\n );\n graphqlWrappedResult.rawResult[responseName] = null;\n return graphqlWrappedResult;\n }\n\n const result = executeField(\n exeContext,\n parentType,\n sourceValue,\n fieldDetailsList,\n fieldPath,\n incrementalContext,\n deferMap,\n );\n if (result === undefined) {\n return graphqlWrappedResult;\n }\n if (isPromise(result)) {\n return result.then((resolved) => {\n graphqlWrappedResult.rawResult[responseName] = resolved.rawResult;\n addIncrementalDataRecords(\n graphqlWrappedResult,\n resolved.incrementalDataRecords,\n );\n return graphqlWrappedResult;\n });\n }\n graphqlWrappedResult.rawResult[responseName] = result.rawResult;\n addIncrementalDataRecords(\n graphqlWrappedResult,\n result.incrementalDataRecords,\n );\n return graphqlWrappedResult;\n },\n {\n rawResult: Object.create(null),\n incrementalDataRecords: undefined,\n },\n );\n}\n\nfunction addIncrementalDataRecords(\n graphqlWrappedResult: GraphQLWrappedResult,\n incrementalDataRecords: ReadonlyArray | undefined,\n): void {\n if (incrementalDataRecords === undefined) {\n return;\n }\n if (graphqlWrappedResult.incrementalDataRecords === undefined) {\n graphqlWrappedResult.incrementalDataRecords = [...incrementalDataRecords];\n } else {\n graphqlWrappedResult.incrementalDataRecords.push(...incrementalDataRecords);\n }\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that may be executed in parallel.\n */\nfunction executeFields(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const results = Object.create(null);\n const graphqlWrappedResult: GraphQLWrappedResult> = {\n rawResult: results,\n incrementalDataRecords: undefined,\n };\n let containsPromise = false;\n\n try {\n for (const [responseName, fieldDetailsList] of groupedFieldSet) {\n const fieldPath = addPath(path, responseName, parentType.name);\n const result = executeField(\n exeContext,\n parentType,\n sourceValue,\n fieldDetailsList,\n fieldPath,\n incrementalContext,\n deferMap,\n );\n\n if (result !== undefined) {\n if (isPromise(result)) {\n results[responseName] = result.then((resolved) => {\n addIncrementalDataRecords(\n graphqlWrappedResult,\n resolved.incrementalDataRecords,\n );\n return resolved.rawResult;\n });\n containsPromise = true;\n } else {\n results[responseName] = result.rawResult;\n addIncrementalDataRecords(\n graphqlWrappedResult,\n result.incrementalDataRecords,\n );\n }\n }\n }\n } catch (error) {\n if (containsPromise) {\n // Ensure that any promises returned by other fields are handled, as they may also reject.\n return promiseForObject(results, () => {\n /* noop */\n }).finally(() => {\n throw error;\n }) as never;\n }\n throw error;\n }\n\n // If there are no promises, we can just return the object and any incrementalDataRecords\n if (!containsPromise) {\n return graphqlWrappedResult;\n }\n\n // Otherwise, results is a map from field name to the result of resolving that\n // field, which is possibly a promise. Return a promise that will return this\n // same map, but with any promises replaced with the values they resolved to.\n return promiseForObject(results, (resolved) => ({\n rawResult: resolved,\n incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords,\n }));\n}\n\nfunction toNodes(fieldDetailsList: FieldDetailsList): ReadonlyArray {\n return fieldDetailsList.map((fieldDetails) => fieldDetails.node);\n}\n\n/**\n * Implements the \"Executing fields\" section of the spec\n * In particular, this function figures out the value that the field returns by\n * calling its resolve function, then calls completeValue to complete promises,\n * coercing scalars, or execute the sub-selection-set for objects.\n */\nfunction executeField(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n source: unknown,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue> | undefined {\n const { validatedExecutionArgs, abortSignalListener } = exeContext;\n const { schema, contextValue, variableValues, hideSuggestions, abortSignal } =\n validatedExecutionArgs;\n const fieldName = fieldDetailsList[0].node.name.value;\n const fieldDef = schema.getField(parentType, fieldName);\n if (!fieldDef) {\n return;\n }\n\n const returnType = fieldDef.type;\n const resolveFn = fieldDef.resolve ?? validatedExecutionArgs.fieldResolver;\n\n const info = buildResolveInfo(\n validatedExecutionArgs,\n fieldDef,\n toNodes(fieldDetailsList),\n parentType,\n path,\n );\n\n // Get the resolve function, regardless of if its result is normal or abrupt (error).\n try {\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n // TODO: find a way to memoize, in case this field is within a List type.\n const args = getArgumentValues(\n fieldDef,\n fieldDetailsList[0].node,\n variableValues,\n fieldDetailsList[0].fragmentVariableValues,\n hideSuggestions,\n );\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const result = resolveFn(source, args, contextValue, info, abortSignal);\n\n if (isPromise(result)) {\n return completePromisedValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n abortSignalListener\n ? cancellablePromise(result, abortSignalListener)\n : result,\n incrementalContext,\n deferMap,\n );\n }\n\n const completed = completeValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n\n if (isPromise(completed)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n return completed.then(undefined, (rawError: unknown) => {\n handleFieldError(\n rawError,\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n });\n }\n return completed;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n }\n}\n\n/**\n * TODO: consider no longer exporting this function\n * @internal\n */\nexport function buildResolveInfo(\n validatedExecutionArgs: ValidatedExecutionArgs,\n fieldDef: GraphQLField,\n fieldNodes: ReadonlyArray,\n parentType: GraphQLObjectType,\n path: Path,\n): GraphQLResolveInfo {\n const { schema, fragmentDefinitions, rootValue, operation, variableValues } =\n validatedExecutionArgs;\n // The resolve function's optional fourth argument is a collection of\n // information about the current execution state.\n return {\n fieldName: fieldDef.name,\n fieldNodes,\n returnType: fieldDef.type,\n parentType,\n path,\n schema,\n fragments: fragmentDefinitions,\n rootValue,\n operation,\n variableValues,\n };\n}\n\nfunction handleFieldError(\n rawError: unknown,\n exeContext: ExecutionContext,\n returnType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n incrementalContext: IncrementalContext | undefined,\n): void {\n const error = locatedError(\n rawError,\n toNodes(fieldDetailsList),\n pathToArray(path),\n );\n\n // If the field type is non-nullable, then it is resolved without any\n // protection from errors, however it still properly locates the error.\n if (exeContext.errorPropagation && isNonNullType(returnType)) {\n throw error;\n }\n\n // Otherwise, error protection is applied, logging the error and resolving\n // a null value for this field if one is encountered.\n const context = incrementalContext ?? exeContext;\n let errors = context.errors;\n if (errors === undefined) {\n errors = [];\n context.errors = errors;\n }\n errors.push(error);\n}\n\n/**\n * Implements the instructions for completeValue as defined in the\n * \"Value Completion\" section of the spec.\n *\n * If the field type is Non-Null, then this recursively completes the value\n * for the inner type. It throws a field error if that completion returns null,\n * as per the \"Nullability\" section of the spec.\n *\n * If the field type is a List, then this recursively completes the value\n * for the inner type on each item in the list.\n *\n * If the field type is a Scalar or Enum, ensures the completed value is a legal\n * value of the type by calling the `coerceOutputValue` method of GraphQL type\n * definition.\n *\n * If the field is an abstract type, determine the runtime type of the value\n * and then complete based on that type\n *\n * Otherwise, the field type expects a sub-selection set, and will complete the\n * value by executing all sub-selections.\n */\nfunction completeValue(\n exeContext: ExecutionContext,\n returnType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue> {\n // If result is an Error, throw a located error.\n if (result instanceof Error) {\n throw result;\n }\n\n // If field type is NonNull, complete for inner type, and throw field error\n // if result is null.\n if (isNonNullType(returnType)) {\n const completed = completeValue(\n exeContext,\n returnType.ofType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n if ((completed as GraphQLWrappedResult).rawResult === null) {\n throw new Error(\n `Cannot return null for non-nullable field ${info.parentType}.${info.fieldName}.`,\n );\n }\n return completed;\n }\n\n // If result value is null or undefined then return null.\n if (result == null) {\n return { rawResult: null, incrementalDataRecords: undefined };\n }\n\n // If field type is List, complete each item in the list with the inner type\n if (isListType(returnType)) {\n return completeListValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n }\n\n // If field type is a leaf type, Scalar or Enum, coerce to a valid value,\n // returning null if coercion is not possible.\n if (isLeafType(returnType)) {\n return {\n rawResult: completeLeafValue(returnType, result),\n incrementalDataRecords: undefined,\n };\n }\n\n // If field type is an abstract type, Interface or Union, determine the\n // runtime Object type and complete for that type.\n if (isAbstractType(returnType)) {\n return completeAbstractValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n }\n\n // If field type is Object, execute and complete all sub-selections.\n if (isObjectType(returnType)) {\n return completeObjectValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n }\n /* c8 ignore next 6 */\n // Not reachable, all possible output types have been considered.\n invariant(\n false,\n 'Cannot complete value of unexpected output type: ' + inspect(returnType),\n );\n}\n\nasync function completePromisedValue(\n exeContext: ExecutionContext,\n returnType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: Promise,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): Promise> {\n try {\n const resolved = await result;\n let completed = completeValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n resolved,\n incrementalContext,\n deferMap,\n );\n\n if (isPromise(completed)) {\n completed = await completed;\n }\n\n return completed;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n }\n}\n\n/**\n * Returns an object containing info for streaming if a field should be\n * streamed based on the experimental flag, stream directive present and\n * not disabled by the \"if\" argument.\n */\nfunction getStreamUsage(\n validatedExecutionArgs: ValidatedExecutionArgs,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n): StreamUsage | undefined {\n // do not stream inner lists of multi-dimensional lists\n if (typeof path.key === 'number') {\n return;\n }\n\n // TODO: add test for this case (a streamed list nested under a list).\n /* c8 ignore next 7 */\n if (\n (fieldDetailsList as unknown as { _streamUsage: StreamUsage })\n ._streamUsage !== undefined\n ) {\n return (fieldDetailsList as unknown as { _streamUsage: StreamUsage })\n ._streamUsage;\n }\n\n const { operation, variableValues } = validatedExecutionArgs;\n // validation only allows equivalent streams on multiple fields, so it is\n // safe to only check the first fieldNode for the stream directive\n const stream = getDirectiveValues(\n GraphQLStreamDirective,\n fieldDetailsList[0].node,\n variableValues,\n fieldDetailsList[0].fragmentVariableValues,\n );\n\n if (!stream) {\n return;\n }\n\n if (stream.if === false) {\n return;\n }\n\n invariant(\n typeof stream.initialCount === 'number',\n 'initialCount must be a number',\n );\n\n invariant(\n stream.initialCount >= 0,\n 'initialCount must be a positive integer',\n );\n\n invariant(\n operation.operation !== OperationTypeNode.SUBSCRIPTION,\n '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.',\n );\n\n const streamedFieldDetailsList: FieldDetailsList = fieldDetailsList.map(\n (fieldDetails) => ({\n node: fieldDetails.node,\n deferUsage: undefined,\n fragmentVariableValues: fieldDetails.fragmentVariableValues,\n }),\n );\n\n const streamUsage = {\n initialCount: stream.initialCount,\n label: typeof stream.label === 'string' ? stream.label : undefined,\n fieldDetailsList: streamedFieldDetailsList,\n };\n\n (fieldDetailsList as unknown as { _streamUsage: StreamUsage })._streamUsage =\n streamUsage;\n\n return streamUsage;\n}\n\n/**\n * Complete a async iterator value by completing the result and calling\n * recursively until all the results are completed.\n */\nasync function completeAsyncIteratorValue(\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n asyncIterator: AsyncIterator,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): Promise>> {\n let containsPromise = false;\n const completedResults: Array = [];\n const graphqlWrappedResult: GraphQLWrappedResult> = {\n rawResult: completedResults,\n incrementalDataRecords: undefined,\n };\n let index = 0;\n const streamUsage = getStreamUsage(\n exeContext.validatedExecutionArgs,\n fieldDetailsList,\n path,\n );\n const earlyReturn =\n asyncIterator.return === undefined\n ? undefined\n : asyncIterator.return.bind(asyncIterator);\n try {\n while (true) {\n if (streamUsage && index >= streamUsage.initialCount) {\n const streamItemQueue = buildAsyncStreamItemQueue(\n index,\n path,\n asyncIterator,\n exeContext,\n streamUsage.fieldDetailsList,\n info,\n itemType,\n );\n\n let streamRecord: StreamRecord | CancellableStreamRecord;\n if (earlyReturn === undefined) {\n streamRecord = {\n label: streamUsage.label,\n path,\n streamItemQueue,\n };\n } else {\n streamRecord = {\n label: streamUsage.label,\n path,\n earlyReturn,\n streamItemQueue,\n };\n if (exeContext.cancellableStreams === undefined) {\n exeContext.cancellableStreams = new Set();\n }\n exeContext.cancellableStreams.add(streamRecord);\n }\n\n addIncrementalDataRecords(graphqlWrappedResult, [streamRecord]);\n break;\n }\n\n const itemPath = addPath(path, index, undefined);\n let iteration;\n try {\n // eslint-disable-next-line no-await-in-loop\n iteration = await asyncIterator.next();\n } catch (rawError) {\n throw locatedError(\n rawError,\n toNodes(fieldDetailsList),\n pathToArray(path),\n );\n }\n\n // TODO: add test case for stream returning done before initialCount\n /* c8 ignore next 3 */\n if (iteration.done) {\n break;\n }\n\n const item = iteration.value;\n // TODO: add tests for stream backed by asyncIterator that returns a promise\n /* c8 ignore start */\n if (isPromise(item)) {\n completedResults.push(\n completePromisedListItemValue(\n item,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n ),\n );\n containsPromise = true;\n } else if (\n /* c8 ignore stop */\n completeListItemValue(\n item,\n completedResults,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n )\n // TODO: add tests for stream backed by asyncIterator that completes to a promise\n /* c8 ignore start */\n ) {\n containsPromise = true;\n }\n /* c8 ignore stop */\n index++;\n }\n } catch (error) {\n if (earlyReturn !== undefined) {\n earlyReturn().catch(() => {\n /* c8 ignore next 1 */\n // ignore error\n });\n }\n throw error;\n }\n\n return containsPromise\n ? /* c8 ignore start */ Promise.all(completedResults).then((resolved) => ({\n rawResult: resolved,\n incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords,\n }))\n : /* c8 ignore stop */ graphqlWrappedResult;\n}\n\n/**\n * Complete a list value by completing each item in the list with the\n * inner type\n */\nfunction completeListValue(\n exeContext: ExecutionContext,\n returnType: GraphQLList,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const itemType = returnType.ofType;\n\n if (isAsyncIterable(result)) {\n const abortSignalListener = exeContext.abortSignalListener;\n const maybeCancellableIterable = abortSignalListener\n ? cancellableIterable(result, abortSignalListener)\n : result;\n const asyncIterator = maybeCancellableIterable[Symbol.asyncIterator]();\n\n return completeAsyncIteratorValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n path,\n asyncIterator,\n incrementalContext,\n deferMap,\n );\n }\n\n if (!isIterableObject(result)) {\n throw new GraphQLError(\n `Expected Iterable, but did not find one for field \"${info.parentType}.${info.fieldName}\".`,\n );\n }\n\n return completeIterableValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction completeIterableValue(\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n items: Iterable,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n // This is specified as a simple map, however we're optimizing the path\n // where the list contains no Promises by avoiding creating another Promise.\n let containsPromise = false;\n const completedResults: Array = [];\n const graphqlWrappedResult: GraphQLWrappedResult> = {\n rawResult: completedResults,\n incrementalDataRecords: undefined,\n };\n let index = 0;\n const streamUsage = getStreamUsage(\n exeContext.validatedExecutionArgs,\n fieldDetailsList,\n path,\n );\n const iterator = items[Symbol.iterator]();\n let iteration = iterator.next();\n while (!iteration.done) {\n const item = iteration.value;\n\n if (streamUsage && index >= streamUsage.initialCount) {\n const syncStreamRecord: StreamRecord = {\n label: streamUsage.label,\n path,\n streamItemQueue: buildSyncStreamItemQueue(\n item,\n index,\n path,\n iterator,\n exeContext,\n streamUsage.fieldDetailsList,\n info,\n itemType,\n ),\n };\n\n addIncrementalDataRecords(graphqlWrappedResult, [syncStreamRecord]);\n break;\n }\n\n // No need to modify the info object containing the path,\n // since from here on it is not ever accessed by resolver functions.\n const itemPath = addPath(path, index, undefined);\n\n if (isPromise(item)) {\n completedResults.push(\n completePromisedListItemValue(\n item,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n ),\n );\n containsPromise = true;\n } else if (\n completeListItemValue(\n item,\n completedResults,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n )\n ) {\n containsPromise = true;\n }\n index++;\n\n iteration = iterator.next();\n }\n\n return containsPromise\n ? Promise.all(completedResults).then((resolved) => ({\n rawResult: resolved,\n incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords,\n }))\n : graphqlWrappedResult;\n}\n\n/**\n * Complete a list item value by adding it to the completed results.\n *\n * Returns true if the value is a Promise.\n */\nfunction completeListItemValue(\n item: unknown,\n completedResults: Array,\n parent: GraphQLWrappedResult>,\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemPath: Path,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): boolean {\n try {\n const completedItem = completeValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n item,\n incrementalContext,\n deferMap,\n );\n\n if (isPromise(completedItem)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n completedResults.push(\n completedItem.then(\n (resolved) => {\n addIncrementalDataRecords(parent, resolved.incrementalDataRecords);\n return resolved.rawResult;\n },\n (rawError: unknown) => {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n return null;\n },\n ),\n );\n return true;\n }\n\n completedResults.push(completedItem.rawResult);\n addIncrementalDataRecords(parent, completedItem.incrementalDataRecords);\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n completedResults.push(null);\n }\n return false;\n}\n\nasync function completePromisedListItemValue(\n item: Promise,\n parent: GraphQLWrappedResult>,\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemPath: Path,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): Promise {\n try {\n const abortSignalListener = exeContext.abortSignalListener;\n const maybeCancellableItem = abortSignalListener\n ? cancellablePromise(item, abortSignalListener)\n : item;\n const resolved = await maybeCancellableItem;\n let completed = completeValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n resolved,\n incrementalContext,\n deferMap,\n );\n if (isPromise(completed)) {\n completed = await completed;\n }\n addIncrementalDataRecords(parent, completed.incrementalDataRecords);\n return completed.rawResult;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n return null;\n }\n}\n\n/**\n * Complete a Scalar or Enum by serializing to a valid value, returning\n * null if serialization is not possible.\n */\nfunction completeLeafValue(\n returnType: GraphQLLeafType,\n result: unknown,\n): unknown {\n const coerced = returnType.coerceOutputValue(result);\n if (coerced == null) {\n throw new Error(\n `Expected \\`${inspect(returnType)}.coerceOutputValue(${inspect(result)})\\` to ` +\n `return non-nullable value, returned: ${inspect(coerced)}`,\n );\n }\n return coerced;\n}\n\n/**\n * Complete a value of an abstract type by determining the runtime object type\n * of that value, then complete the value for that type.\n */\nfunction completeAbstractValue(\n exeContext: ExecutionContext,\n returnType: GraphQLAbstractType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const validatedExecutionArgs = exeContext.validatedExecutionArgs;\n const { schema, contextValue } = validatedExecutionArgs;\n const resolveTypeFn =\n returnType.resolveType ?? validatedExecutionArgs.typeResolver;\n const runtimeType = resolveTypeFn(result, contextValue, info, returnType);\n\n if (isPromise(runtimeType)) {\n return runtimeType.then((resolvedRuntimeType) =>\n completeObjectValue(\n exeContext,\n ensureValidRuntimeType(\n resolvedRuntimeType,\n schema,\n returnType,\n fieldDetailsList,\n info,\n result,\n ),\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n ),\n );\n }\n\n return completeObjectValue(\n exeContext,\n ensureValidRuntimeType(\n runtimeType,\n schema,\n returnType,\n fieldDetailsList,\n info,\n result,\n ),\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction ensureValidRuntimeType(\n runtimeTypeName: unknown,\n schema: GraphQLSchema,\n returnType: GraphQLAbstractType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n result: unknown,\n): GraphQLObjectType {\n if (runtimeTypeName == null) {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" must resolve to an Object type at runtime for field \"${info.parentType}.${info.fieldName}\". Either the \"${returnType}\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n if (typeof runtimeTypeName !== 'string') {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" must resolve to an Object type at runtime for field \"${info.parentType}.${info.fieldName}\" with ` +\n `value ${inspect(result)}, received \"${inspect(\n runtimeTypeName,\n )}\", which is not a valid Object type name.`,\n );\n }\n\n const runtimeType = schema.getType(runtimeTypeName);\n if (runtimeType == null) {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" was resolved to a type \"${runtimeTypeName}\" that does not exist inside the schema.`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n if (!isObjectType(runtimeType)) {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" was resolved to a non-object type \"${runtimeTypeName}\".`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n if (!schema.isSubType(returnType, runtimeType)) {\n throw new GraphQLError(\n `Runtime Object type \"${runtimeType}\" is not a possible type for \"${returnType}\".`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n return runtimeType;\n}\n\n/**\n * Complete an Object value by executing all sub-selections.\n */\nfunction completeObjectValue(\n exeContext: ExecutionContext,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n if ((incrementalContext ?? exeContext).completed) {\n throw new Error('Completed, aborting.');\n }\n\n // If there is an isTypeOf predicate function, call it with the\n // current result. If isTypeOf returns false, then raise an error rather\n // than continuing execution.\n if (returnType.isTypeOf) {\n const isTypeOf = returnType.isTypeOf(\n result,\n exeContext.validatedExecutionArgs.contextValue,\n info,\n );\n\n if (isPromise(isTypeOf)) {\n return isTypeOf.then((resolvedIsTypeOf) => {\n if (!resolvedIsTypeOf) {\n throw invalidReturnTypeError(returnType, result, fieldDetailsList);\n }\n return collectAndExecuteSubfields(\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n });\n }\n\n if (!isTypeOf) {\n throw invalidReturnTypeError(returnType, result, fieldDetailsList);\n }\n }\n\n return collectAndExecuteSubfields(\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction invalidReturnTypeError(\n returnType: GraphQLObjectType,\n result: unknown,\n fieldDetailsList: FieldDetailsList,\n): GraphQLError {\n return new GraphQLError(\n `Expected value of type \"${returnType}\" but got: ${inspect(result)}.`,\n { nodes: toNodes(fieldDetailsList) },\n );\n}\n\n/**\n * Instantiates new DeferredFragmentRecords for the given path within an\n * incremental data record, returning an updated map of DeferUsage\n * objects to DeferredFragmentRecords.\n *\n * Note: As defer directives may be used with operations returning lists,\n * a DeferUsage object may correspond to many DeferredFragmentRecords.\n */\nfunction getNewDeferMap(\n newDeferUsages: ReadonlyArray,\n deferMap?: ReadonlyMap,\n path?: Path,\n): ReadonlyMap {\n const newDeferMap = new Map(deferMap);\n\n // For each new deferUsage object:\n for (const newDeferUsage of newDeferUsages) {\n const parentDeferUsage = newDeferUsage.parentDeferUsage;\n\n const parent =\n parentDeferUsage === undefined\n ? undefined\n : deferredFragmentRecordFromDeferUsage(parentDeferUsage, newDeferMap);\n\n // Instantiate the new record.\n const deferredFragmentRecord = new DeferredFragmentRecord(\n path,\n newDeferUsage.label,\n parent,\n );\n\n // Update the map.\n newDeferMap.set(newDeferUsage, deferredFragmentRecord);\n }\n\n return newDeferMap;\n}\n\nfunction deferredFragmentRecordFromDeferUsage(\n deferUsage: DeferUsage,\n deferMap: ReadonlyMap,\n): DeferredFragmentRecord {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return deferMap.get(deferUsage)!;\n}\n\nfunction collectAndExecuteSubfields(\n exeContext: ExecutionContext,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const validatedExecutionArgs = exeContext.validatedExecutionArgs;\n\n // Collect sub-fields to execute to complete this value.\n const collectedSubfields = collectSubfields(\n validatedExecutionArgs,\n returnType,\n fieldDetailsList,\n );\n const { groupedFieldSet, newDeferUsages } = collectedSubfields;\n\n if (newDeferUsages.length > 0) {\n invariant(\n validatedExecutionArgs.operation.operation !==\n OperationTypeNode.SUBSCRIPTION,\n '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.',\n );\n }\n\n return executeSubExecutionPlan(\n exeContext,\n returnType,\n result,\n groupedFieldSet,\n newDeferUsages,\n path,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction executeSubExecutionPlan(\n exeContext: ExecutionContext,\n returnType: GraphQLObjectType,\n sourceValue: unknown,\n originalGroupedFieldSet: GroupedFieldSet,\n newDeferUsages: ReadonlyArray,\n path?: Path,\n incrementalContext?: IncrementalContext,\n deferMap?: ReadonlyMap,\n): PromiseOrValue>> {\n if (deferMap === undefined && newDeferUsages.length === 0) {\n return executeFields(\n exeContext,\n returnType,\n sourceValue,\n path,\n originalGroupedFieldSet,\n incrementalContext,\n deferMap,\n );\n }\n\n const newDeferMap = getNewDeferMap(newDeferUsages, deferMap, path);\n\n const { groupedFieldSet, newGroupedFieldSets } = buildSubExecutionPlan(\n originalGroupedFieldSet,\n incrementalContext?.deferUsageSet,\n );\n\n const graphqlWrappedResult = executeFields(\n exeContext,\n returnType,\n sourceValue,\n path,\n groupedFieldSet,\n incrementalContext,\n newDeferMap,\n );\n\n if (newGroupedFieldSets.size > 0) {\n const newPendingExecutionGroups = collectExecutionGroups(\n exeContext,\n returnType,\n sourceValue,\n path,\n incrementalContext?.deferUsageSet,\n newGroupedFieldSets,\n newDeferMap,\n );\n\n return withNewExecutionGroups(\n graphqlWrappedResult,\n newPendingExecutionGroups,\n );\n }\n return graphqlWrappedResult;\n}\n\nfunction buildSubExecutionPlan(\n originalGroupedFieldSet: GroupedFieldSet,\n deferUsageSet: DeferUsageSet | undefined,\n): ExecutionPlan {\n let executionPlan = (\n originalGroupedFieldSet as unknown as { _executionPlan: ExecutionPlan }\n )._executionPlan;\n if (executionPlan !== undefined) {\n return executionPlan;\n }\n executionPlan = buildExecutionPlan(originalGroupedFieldSet, deferUsageSet);\n (\n originalGroupedFieldSet as unknown as { _executionPlan: ExecutionPlan }\n )._executionPlan = executionPlan;\n return executionPlan;\n}\n\n/**\n * If a resolveType function is not given, then a default resolve behavior is\n * used which attempts two strategies:\n *\n * First, See if the provided value has a `__typename` field defined, if so, use\n * that value as name of the resolved type.\n *\n * Otherwise, test each possible type for the abstract type by calling\n * isTypeOf for the object being coerced, returning the first type that matches.\n */\nexport const defaultTypeResolver: GraphQLTypeResolver =\n function (value, contextValue, info, abstractType) {\n // First, look for `__typename`.\n if (isObjectLike(value) && typeof value.__typename === 'string') {\n return value.__typename;\n }\n\n // Otherwise, test each possible type.\n const possibleTypes = info.schema.getPossibleTypes(abstractType);\n const promisedIsTypeOfResults = [];\n\n for (let i = 0; i < possibleTypes.length; i++) {\n const type = possibleTypes[i];\n\n if (type.isTypeOf) {\n const isTypeOfResult = type.isTypeOf(value, contextValue, info);\n\n if (isPromise(isTypeOfResult)) {\n promisedIsTypeOfResults[i] = isTypeOfResult;\n } else if (isTypeOfResult) {\n if (promisedIsTypeOfResults.length > 0) {\n Promise.all(promisedIsTypeOfResults).then(undefined, () => {\n /* ignore errors */\n });\n }\n\n return type.name;\n }\n }\n }\n\n if (promisedIsTypeOfResults.length) {\n return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => {\n for (let i = 0; i < isTypeOfResults.length; i++) {\n if (isTypeOfResults[i]) {\n return possibleTypes[i].name;\n }\n }\n });\n }\n };\n\n/**\n * If a resolve function is not given, then a default resolve behavior is used\n * which takes the property of the source object of the same name as the field\n * and returns it as the result, or if it's a function, returns the result\n * of calling that function while passing along args and context value.\n */\nexport const defaultFieldResolver: GraphQLFieldResolver =\n function (source: any, args, contextValue, info, abortSignal) {\n // ensure source is a value for which property access is acceptable.\n if (isObjectLike(source) || typeof source === 'function') {\n const property = source[info.fieldName];\n if (typeof property === 'function') {\n return source[info.fieldName](args, contextValue, info, abortSignal);\n }\n return property;\n }\n };\n\n/**\n * Implements the \"Subscribe\" algorithm described in the GraphQL specification.\n *\n * Returns a Promise which resolves to either an AsyncIterator (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with descriptive\n * errors and no data will be returned.\n *\n * If the source stream could not be created due to faulty subscription resolver\n * logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to an AsyncIterator, which\n * yields a stream of ExecutionResults representing the response stream.\n *\n * This function does not support incremental delivery (`@defer` and `@stream`).\n * If an operation which would defer or stream data is executed with this\n * function, a field error will be raised at the location of the `@defer` or\n * `@stream` directive.\n *\n * Accepts an object with named arguments.\n */\nexport function subscribe(\n args: ExecutionArgs,\n): PromiseOrValue<\n AsyncGenerator | ExecutionResult\n> {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const validatedExecutionArgs = validateExecutionArgs(args);\n\n // Return early errors if execution context failed.\n if (!('schema' in validatedExecutionArgs)) {\n return { errors: validatedExecutionArgs };\n }\n\n const resultOrStream = createSourceEventStreamImpl(validatedExecutionArgs);\n\n if (isPromise(resultOrStream)) {\n return resultOrStream.then((resolvedResultOrStream) =>\n mapSourceToResponse(validatedExecutionArgs, resolvedResultOrStream),\n );\n }\n\n return mapSourceToResponse(validatedExecutionArgs, resultOrStream);\n}\n\nfunction mapSourceToResponse(\n validatedExecutionArgs: ValidatedExecutionArgs,\n resultOrStream: ExecutionResult | AsyncIterable,\n): AsyncGenerator | ExecutionResult {\n if (!isAsyncIterable(resultOrStream)) {\n return resultOrStream;\n }\n\n const abortSignal = validatedExecutionArgs.abortSignal;\n const abortSignalListener = abortSignal\n ? new AbortSignalListener(abortSignal)\n : undefined;\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification..\n return mapAsyncIterable(\n abortSignalListener\n ? cancellableIterable(resultOrStream, abortSignalListener)\n : resultOrStream,\n (payload: unknown) => {\n const perEventExecutionArgs: ValidatedExecutionArgs = {\n ...validatedExecutionArgs,\n rootValue: payload,\n };\n return validatedExecutionArgs.perEventExecutor(perEventExecutionArgs);\n },\n () => abortSignalListener?.disconnect(),\n );\n}\n\nexport function executeSubscriptionEvent(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue {\n return executeQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs);\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nexport function createSourceEventStream(\n args: ExecutionArgs,\n): PromiseOrValue | ExecutionResult> {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const validatedExecutionArgs = validateExecutionArgs(args);\n\n // Return early errors if execution context failed.\n if (!('schema' in validatedExecutionArgs)) {\n return { errors: validatedExecutionArgs };\n }\n\n return createSourceEventStreamImpl(validatedExecutionArgs);\n}\n\nfunction createSourceEventStreamImpl(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue | ExecutionResult> {\n try {\n const eventStream = executeSubscription(validatedExecutionArgs);\n if (isPromise(eventStream)) {\n return eventStream.then(undefined, (error: unknown) => ({\n errors: [error as GraphQLError],\n }));\n }\n\n return eventStream;\n } catch (error) {\n return { errors: [error] };\n }\n}\n\nfunction executeSubscription(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue> {\n const {\n schema,\n fragments,\n rootValue,\n contextValue,\n operation,\n variableValues,\n hideSuggestions,\n abortSignal,\n } = validatedExecutionArgs;\n\n const rootType = schema.getSubscriptionType();\n if (rootType == null) {\n throw new GraphQLError(\n 'Schema is not configured to execute subscription operation.',\n { nodes: operation },\n );\n }\n\n const { groupedFieldSet } = collectFields(\n schema,\n fragments,\n variableValues,\n rootType,\n operation.selectionSet,\n hideSuggestions,\n );\n\n const firstRootField = groupedFieldSet.entries().next().value as [\n string,\n FieldDetailsList,\n ];\n const [responseName, fieldDetailsList] = firstRootField;\n const fieldName = fieldDetailsList[0].node.name.value;\n const fieldDef = schema.getField(rootType, fieldName);\n\n const fieldNodes = fieldDetailsList.map((fieldDetails) => fieldDetails.node);\n if (!fieldDef) {\n throw new GraphQLError(\n `The subscription field \"${fieldName}\" is not defined.`,\n { nodes: fieldNodes },\n );\n }\n\n const path = addPath(undefined, responseName, rootType.name);\n const info = buildResolveInfo(\n validatedExecutionArgs,\n fieldDef,\n fieldNodes,\n rootType,\n path,\n );\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n const args = getArgumentValues(\n fieldDef,\n fieldNodes[0],\n variableValues,\n fieldDetailsList[0].fragmentVariableValues,\n hideSuggestions,\n );\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n const resolveFn =\n fieldDef.subscribe ?? validatedExecutionArgs.subscribeFieldResolver;\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const result = resolveFn(rootValue, args, contextValue, info, abortSignal);\n\n if (isPromise(result)) {\n const abortSignalListener = abortSignal\n ? new AbortSignalListener(abortSignal)\n : undefined;\n\n const promise = abortSignalListener\n ? cancellablePromise(result, abortSignalListener)\n : result;\n return promise.then(assertEventStream).then(\n (resolved) => {\n abortSignalListener?.disconnect();\n return resolved;\n },\n (error: unknown) => {\n abortSignalListener?.disconnect();\n throw locatedError(error, fieldNodes, pathToArray(path));\n },\n );\n }\n\n return assertEventStream(result);\n } catch (error) {\n throw locatedError(error, fieldNodes, pathToArray(path));\n }\n}\n\nfunction assertEventStream(result: unknown): AsyncIterable {\n if (result instanceof Error) {\n throw result;\n }\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(result)) {\n throw new GraphQLError(\n 'Subscription field must return Async Iterable. ' +\n `Received: ${inspect(result)}.`,\n );\n }\n\n return result;\n}\n\nfunction collectExecutionGroups(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n parentDeferUsages: DeferUsageSet | undefined,\n newGroupedFieldSets: Map,\n deferMap: ReadonlyMap,\n): ReadonlyArray {\n const newPendingExecutionGroups: Array = [];\n\n for (const [deferUsageSet, groupedFieldSet] of newGroupedFieldSets) {\n const deferredFragmentRecords = getDeferredFragmentRecords(\n deferUsageSet,\n deferMap,\n );\n\n const pendingExecutionGroup: PendingExecutionGroup = {\n deferredFragmentRecords,\n result:\n undefined as unknown as BoxedPromiseOrValue,\n };\n\n const executor = () =>\n executeExecutionGroup(\n pendingExecutionGroup,\n exeContext,\n parentType,\n sourceValue,\n path,\n groupedFieldSet,\n {\n errors: undefined,\n completed: false,\n deferUsageSet,\n },\n deferMap,\n );\n\n if (exeContext.validatedExecutionArgs.enableEarlyExecution) {\n pendingExecutionGroup.result = new BoxedPromiseOrValue(\n shouldDefer(parentDeferUsages, deferUsageSet)\n ? Promise.resolve().then(executor)\n : executor(),\n );\n } else {\n pendingExecutionGroup.result = () => new BoxedPromiseOrValue(executor());\n }\n\n newPendingExecutionGroups.push(pendingExecutionGroup);\n }\n\n return newPendingExecutionGroups;\n}\n\nfunction shouldDefer(\n parentDeferUsages: undefined | DeferUsageSet,\n deferUsages: DeferUsageSet,\n): boolean {\n // If we have a new child defer usage, defer.\n // Otherwise, this defer usage was already deferred when it was initially\n // encountered, and is now in the midst of executing early, so the new\n // deferred grouped fields set can be executed immediately.\n return (\n parentDeferUsages === undefined ||\n !Array.from(deferUsages).every((deferUsage) =>\n parentDeferUsages.has(deferUsage),\n )\n );\n}\n\nfunction executeExecutionGroup(\n pendingExecutionGroup: PendingExecutionGroup,\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalContext: IncrementalContext,\n deferMap: ReadonlyMap,\n): PromiseOrValue {\n let result;\n try {\n result = executeFields(\n exeContext,\n parentType,\n sourceValue,\n path,\n groupedFieldSet,\n incrementalContext,\n deferMap,\n );\n } catch (error) {\n incrementalContext.completed = true;\n return {\n pendingExecutionGroup,\n path: pathToArray(path),\n errors: withError(incrementalContext.errors, error),\n };\n }\n\n if (isPromise(result)) {\n return result.then(\n (resolved) => {\n incrementalContext.completed = true;\n return buildCompletedExecutionGroup(\n incrementalContext.errors,\n pendingExecutionGroup,\n path,\n resolved,\n );\n },\n (error: unknown) => {\n incrementalContext.completed = true;\n return {\n pendingExecutionGroup,\n path: pathToArray(path),\n errors: withError(incrementalContext.errors, error as GraphQLError),\n };\n },\n );\n }\n\n incrementalContext.completed = true;\n return buildCompletedExecutionGroup(\n incrementalContext.errors,\n pendingExecutionGroup,\n path,\n result,\n );\n}\n\nfunction buildCompletedExecutionGroup(\n errors: ReadonlyArray | undefined,\n pendingExecutionGroup: PendingExecutionGroup,\n path: Path | undefined,\n result: GraphQLWrappedResult>,\n): CompletedExecutionGroup {\n const { rawResult: data, incrementalDataRecords } = result;\n return {\n pendingExecutionGroup,\n path: pathToArray(path),\n result: errors === undefined ? { data } : { data, errors },\n incrementalDataRecords,\n };\n}\n\nfunction getDeferredFragmentRecords(\n deferUsages: DeferUsageSet,\n deferMap: ReadonlyMap,\n): ReadonlyArray {\n return Array.from(deferUsages).map((deferUsage) =>\n deferredFragmentRecordFromDeferUsage(deferUsage, deferMap),\n );\n}\n\nfunction buildSyncStreamItemQueue(\n initialItem: PromiseOrValue,\n initialIndex: number,\n streamPath: Path,\n iterator: Iterator,\n exeContext: ExecutionContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): Array {\n const streamItemQueue: Array = [];\n\n const enableEarlyExecution =\n exeContext.validatedExecutionArgs.enableEarlyExecution;\n\n const firstExecutor = () => {\n const initialPath = addPath(streamPath, initialIndex, undefined);\n const firstStreamItem = new BoxedPromiseOrValue(\n completeStreamItem(\n initialPath,\n initialItem,\n exeContext,\n { errors: undefined, completed: false },\n fieldDetailsList,\n info,\n itemType,\n ),\n );\n\n let iteration = iterator.next();\n let currentIndex = initialIndex + 1;\n let currentStreamItem:\n | BoxedPromiseOrValue\n | (() => BoxedPromiseOrValue) = firstStreamItem;\n while (!iteration.done) {\n // TODO: add test case for early sync termination\n /* c8 ignore next 6 */\n if (currentStreamItem instanceof BoxedPromiseOrValue) {\n const result = currentStreamItem.value;\n if (!isPromise(result) && result.errors !== undefined) {\n break;\n }\n }\n\n const itemPath = addPath(streamPath, currentIndex, undefined);\n\n const value = iteration.value;\n\n const currentExecutor = () =>\n completeStreamItem(\n itemPath,\n value,\n exeContext,\n { errors: undefined, completed: false },\n fieldDetailsList,\n info,\n itemType,\n );\n\n currentStreamItem = enableEarlyExecution\n ? new BoxedPromiseOrValue(currentExecutor())\n : () => new BoxedPromiseOrValue(currentExecutor());\n\n streamItemQueue.push(currentStreamItem);\n\n iteration = iterator.next();\n currentIndex = initialIndex + 1;\n }\n\n streamItemQueue.push(new BoxedPromiseOrValue({}));\n\n return firstStreamItem.value;\n };\n\n streamItemQueue.push(\n enableEarlyExecution\n ? new BoxedPromiseOrValue(Promise.resolve().then(firstExecutor))\n : () => new BoxedPromiseOrValue(firstExecutor()),\n );\n\n return streamItemQueue;\n}\n\nfunction buildAsyncStreamItemQueue(\n initialIndex: number,\n streamPath: Path,\n asyncIterator: AsyncIterator,\n exeContext: ExecutionContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): Array {\n const streamItemQueue: Array = [];\n const executor = () =>\n getNextAsyncStreamItemResult(\n streamItemQueue,\n streamPath,\n initialIndex,\n asyncIterator,\n exeContext,\n fieldDetailsList,\n info,\n itemType,\n );\n\n streamItemQueue.push(\n exeContext.validatedExecutionArgs.enableEarlyExecution\n ? new BoxedPromiseOrValue(executor())\n : () => new BoxedPromiseOrValue(executor()),\n );\n\n return streamItemQueue;\n}\n\nasync function getNextAsyncStreamItemResult(\n streamItemQueue: Array,\n streamPath: Path,\n index: number,\n asyncIterator: AsyncIterator,\n exeContext: ExecutionContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): Promise {\n let iteration;\n try {\n iteration = await asyncIterator.next();\n } catch (error) {\n return {\n errors: [\n locatedError(error, toNodes(fieldDetailsList), pathToArray(streamPath)),\n ],\n };\n }\n\n if (iteration.done) {\n return {};\n }\n\n const itemPath = addPath(streamPath, index, undefined);\n\n const result = completeStreamItem(\n itemPath,\n iteration.value,\n exeContext,\n { errors: undefined, completed: false },\n fieldDetailsList,\n info,\n itemType,\n );\n\n const executor = () =>\n getNextAsyncStreamItemResult(\n streamItemQueue,\n streamPath,\n index + 1,\n asyncIterator,\n exeContext,\n fieldDetailsList,\n info,\n itemType,\n );\n\n streamItemQueue.push(\n exeContext.validatedExecutionArgs.enableEarlyExecution\n ? new BoxedPromiseOrValue(executor())\n : () => new BoxedPromiseOrValue(executor()),\n );\n\n return result;\n}\n\nfunction completeStreamItem(\n itemPath: Path,\n item: unknown,\n exeContext: ExecutionContext,\n incrementalContext: IncrementalContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): PromiseOrValue {\n if (isPromise(item)) {\n const abortSignalListener = exeContext.abortSignalListener;\n const maybeCancellableItem = abortSignalListener\n ? cancellablePromise(item, abortSignalListener)\n : item;\n return completePromisedValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n maybeCancellableItem,\n incrementalContext,\n new Map(),\n ).then(\n (resolvedItem) => {\n incrementalContext.completed = true;\n return buildStreamItemResult(incrementalContext.errors, resolvedItem);\n },\n (error: unknown) => {\n incrementalContext.completed = true;\n return {\n errors: withError(incrementalContext.errors, error as GraphQLError),\n };\n },\n );\n }\n\n let result: PromiseOrValue>;\n try {\n try {\n result = completeValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n item,\n incrementalContext,\n new Map(),\n );\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n result = { rawResult: null, incrementalDataRecords: undefined };\n }\n } catch (error) {\n incrementalContext.completed = true;\n return {\n errors: withError(incrementalContext.errors, error),\n };\n }\n\n if (isPromise(result)) {\n return result\n .then(undefined, (rawError: unknown) => {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n })\n .then(\n (resolvedItem) => {\n incrementalContext.completed = true;\n return buildStreamItemResult(incrementalContext.errors, resolvedItem);\n },\n (error: unknown) => {\n incrementalContext.completed = true;\n return {\n errors: withError(incrementalContext.errors, error as GraphQLError),\n };\n },\n );\n }\n\n incrementalContext.completed = true;\n return buildStreamItemResult(incrementalContext.errors, result);\n}\n\nfunction buildStreamItemResult(\n errors: ReadonlyArray | undefined,\n result: GraphQLWrappedResult,\n): StreamItemResult {\n const { rawResult: item, incrementalDataRecords } = result;\n return {\n item,\n errors,\n incrementalDataRecords,\n };\n}\n"]} \ No newline at end of file diff --git a/execution/execute.mjs b/execution/execute.mjs new file mode 100644 index 0000000000..e2ed2d58cc --- /dev/null +++ b/execution/execute.mjs @@ -0,0 +1,1398 @@ +import { BoxedPromiseOrValue } from "../jsutils/BoxedPromiseOrValue.mjs"; +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { isAsyncIterable } from "../jsutils/isAsyncIterable.mjs"; +import { isIterableObject } from "../jsutils/isIterableObject.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { isPromise } from "../jsutils/isPromise.mjs"; +import { memoize3 } from "../jsutils/memoize3.mjs"; +import { addPath, pathToArray } from "../jsutils/Path.mjs"; +import { promiseForObject } from "../jsutils/promiseForObject.mjs"; +import { promiseReduce } from "../jsutils/promiseReduce.mjs"; +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { locatedError } from "../error/locatedError.mjs"; +import { OperationTypeNode } from "../language/ast.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { isAbstractType, isLeafType, isListType, isNonNullType, isObjectType, } from "../type/definition.mjs"; +import { GraphQLDisableErrorPropagationDirective, GraphQLStreamDirective, } from "../type/directives.mjs"; +import { assertValidSchema } from "../type/validate.mjs"; +import { AbortSignalListener, cancellableIterable, cancellablePromise, } from "./AbortSignalListener.mjs"; +import { buildExecutionPlan } from "./buildExecutionPlan.mjs"; +import { collectFields, collectSubfields as _collectSubfields, } from "./collectFields.mjs"; +import { getVariableSignature } from "./getVariableSignature.mjs"; +import { buildIncrementalResponse } from "./IncrementalPublisher.mjs"; +import { mapAsyncIterable } from "./mapAsyncIterable.mjs"; +import { DeferredFragmentRecord } from "./types.mjs"; +import { getArgumentValues, getDirectiveValues, getVariableValues, } from "./values.mjs"; +/* eslint-disable @typescript-eslint/max-params */ +// This file contains a lot of such errors but we plan to refactor it anyway +// so just disable it for entire file. +/** + * A memoized collection of relevant subfields with regard to the return + * type. Memoizing ensures the subfields are not repeatedly calculated, which + * saves overhead when resolving lists of values. + */ +const collectSubfields = memoize3((validatedExecutionArgs, returnType, fieldDetailsList) => { + const { schema, fragments, variableValues, hideSuggestions } = validatedExecutionArgs; + return _collectSubfields(schema, fragments, variableValues, returnType, fieldDetailsList, hideSuggestions); +}); +const UNEXPECTED_EXPERIMENTAL_DIRECTIVES = 'The provided schema unexpectedly contains experimental directives (@defer or @stream). These directives may only be utilized if experimental execution features are explicitly enabled.'; +const UNEXPECTED_MULTIPLE_PAYLOADS = 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)'; +/** + * Implements the "Executing requests" section of the GraphQL specification. + * + * Returns either a synchronous ExecutionResult (if all encountered resolvers + * are synchronous), or a Promise of an ExecutionResult that will eventually be + * resolved and never rejected. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + * + * This function does not support incremental delivery (`@defer` and `@stream`). + * If an operation which would defer or stream data is executed with this + * function, it will throw or return a rejected promise. + * Use `experimentalExecuteIncrementally` if you want to support incremental + * delivery. + */ +export function execute(args) { + if (args.schema.getDirective('defer') || args.schema.getDirective('stream')) { + throw new Error(UNEXPECTED_EXPERIMENTAL_DIRECTIVES); + } + const result = experimentalExecuteIncrementally(args); + // Multiple payloads could be encountered if the operation contains @defer or + // @stream directives and is not validated prior to execution + return ensureSinglePayload(result); +} +function ensureSinglePayload(result) { + if (isPromise(result)) { + return result.then((resolved) => { + if ('initialResult' in resolved) { + throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS); + } + return resolved; + }); + } + if ('initialResult' in result) { + throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS); + } + return result; +} +/** + * Implements the "Executing requests" section of the GraphQL specification, + * including `@defer` and `@stream` as proposed in + * https://github.com/graphql/graphql-spec/pull/742 + * + * This function returns a Promise of an ExperimentalIncrementalExecutionResults + * object. This object either consists of a single ExecutionResult, or an + * object containing an `initialResult` and a stream of `subsequentResults`. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + */ +export function experimentalExecuteIncrementally(args) { + // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + const validatedExecutionArgs = validateExecutionArgs(args); + // Return early errors if execution context failed. + if (!('schema' in validatedExecutionArgs)) { + return { errors: validatedExecutionArgs }; + } + return experimentalExecuteQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs); +} +/** + * Implements the "Executing operations" section of the spec. + * + * Returns a Promise that will eventually resolve to the data described by + * The "Response" section of the GraphQL specification. + * + * If errors are encountered while executing a GraphQL field, only that + * field and its descendants will be omitted, and sibling fields will still + * be executed. An execution which encounters errors will still result in a + * resolved Promise. + * + * Errors from sub-fields of a NonNull type may propagate to the top level, + * at which point we still log the error and null the parent field, which + * in this case is the entire response. + */ +export function executeQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs) { + const result = experimentalExecuteQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs); + return ensureSinglePayload(result); +} +function errorPropagation(operation) { + const directiveNode = operation.directives?.find((directive) => directive.name.value === GraphQLDisableErrorPropagationDirective.name); + return directiveNode === undefined; +} +export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs) { + const abortSignal = validatedExecutionArgs.abortSignal; + const exeContext = { + validatedExecutionArgs, + errors: undefined, + abortSignalListener: abortSignal + ? new AbortSignalListener(abortSignal) + : undefined, + completed: false, + cancellableStreams: undefined, + errorPropagation: errorPropagation(validatedExecutionArgs.operation), + }; + try { + const { schema, fragments, rootValue, operation, variableValues, hideSuggestions, } = validatedExecutionArgs; + const { operation: operationType, selectionSet } = operation; + const rootType = schema.getRootType(operationType); + if (rootType == null) { + throw new GraphQLError(`Schema is not configured to execute ${operationType} operation.`, { nodes: operation }); + } + const { groupedFieldSet, newDeferUsages } = collectFields(schema, fragments, variableValues, rootType, selectionSet, hideSuggestions); + const graphqlWrappedResult = executeRootExecutionPlan(exeContext, operation.operation, rootType, rootValue, groupedFieldSet, newDeferUsages); + if (isPromise(graphqlWrappedResult)) { + return graphqlWrappedResult.then((resolved) => { + exeContext.completed = true; + return buildDataResponse(exeContext, resolved); + }, (error) => { + exeContext.completed = true; + exeContext.abortSignalListener?.disconnect(); + return { + data: null, + errors: withError(exeContext.errors, error), + }; + }); + } + exeContext.completed = true; + return buildDataResponse(exeContext, graphqlWrappedResult); + } + catch (error) { + exeContext.completed = true; + // TODO: add test case for synchronous null bubbling to root with cancellation + /* c8 ignore next */ + exeContext.abortSignalListener?.disconnect(); + return { data: null, errors: withError(exeContext.errors, error) }; + } +} +function withError(errors, error) { + return errors === undefined ? [error] : [...errors, error]; +} +function buildDataResponse(exeContext, graphqlWrappedResult) { + const { rawResult: data, incrementalDataRecords } = graphqlWrappedResult; + const errors = exeContext.errors; + if (incrementalDataRecords === undefined) { + exeContext.abortSignalListener?.disconnect(); + return errors !== undefined ? { errors, data } : { data }; + } + return buildIncrementalResponse(exeContext, data, errors, incrementalDataRecords); +} +/** + * Also implements the "Executing requests" section of the GraphQL specification. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ +export function executeSync(args) { + const result = experimentalExecuteIncrementally(args); + // Assert that the execution was synchronous. + if (isPromise(result) || 'initialResult' in result) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + return result; +} +/** + * Constructs a ExecutionContext object from the arguments passed to + * execute, which we will pass throughout the other execution methods. + * + * Throws a GraphQLError if a valid execution context cannot be created. + * + * TODO: consider no longer exporting this function + * @internal + */ +export function validateExecutionArgs(args) { + const { schema, document, rootValue, contextValue, variableValues: rawVariableValues, operationName, fieldResolver, typeResolver, subscribeFieldResolver, perEventExecutor, enableEarlyExecution, abortSignal, } = args; + if (abortSignal?.aborted) { + return [locatedError(abortSignal.reason, undefined)]; + } + // If the schema used for execution is invalid, throw an error. + assertValidSchema(schema); + let operation; + const fragmentDefinitions = Object.create(null); + const fragments = Object.create(null); + for (const definition of document.definitions) { + switch (definition.kind) { + case Kind.OPERATION_DEFINITION: + if (operationName == null) { + if (operation !== undefined) { + return [ + new GraphQLError('Must provide operation name if query contains multiple operations.'), + ]; + } + operation = definition; + } + else if (definition.name?.value === operationName) { + operation = definition; + } + break; + case Kind.FRAGMENT_DEFINITION: { + fragmentDefinitions[definition.name.value] = definition; + let variableSignatures; + if (definition.variableDefinitions) { + variableSignatures = Object.create(null); + for (const varDef of definition.variableDefinitions) { + const signature = getVariableSignature(schema, varDef); + variableSignatures[signature.name] = signature; + } + } + fragments[definition.name.value] = { definition, variableSignatures }; + break; + } + default: + // ignore non-executable definitions + } + } + if (!operation) { + if (operationName != null) { + return [new GraphQLError(`Unknown operation named "${operationName}".`)]; + } + return [new GraphQLError('Must provide an operation.')]; + } + const variableDefinitions = operation.variableDefinitions ?? []; + const hideSuggestions = args.hideSuggestions ?? false; + const variableValuesOrErrors = getVariableValues(schema, variableDefinitions, rawVariableValues ?? {}, { + maxErrors: 50, + hideSuggestions, + }); + if (variableValuesOrErrors.errors) { + return variableValuesOrErrors.errors; + } + return { + schema, + fragmentDefinitions, + fragments, + rootValue, + contextValue, + operation, + variableValues: variableValuesOrErrors.variableValues, + fieldResolver: fieldResolver ?? defaultFieldResolver, + typeResolver: typeResolver ?? defaultTypeResolver, + subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver, + perEventExecutor: perEventExecutor ?? executeSubscriptionEvent, + enableEarlyExecution: enableEarlyExecution === true, + hideSuggestions, + abortSignal: args.abortSignal ?? undefined, + }; +} +function executeRootExecutionPlan(exeContext, operation, rootType, rootValue, originalGroupedFieldSet, newDeferUsages) { + if (newDeferUsages.length === 0) { + return executeRootGroupedFieldSet(exeContext, operation, rootType, rootValue, originalGroupedFieldSet, undefined); + } + const newDeferMap = getNewDeferMap(newDeferUsages, undefined, undefined); + const { groupedFieldSet, newGroupedFieldSets } = buildExecutionPlan(originalGroupedFieldSet); + const graphqlWrappedResult = executeRootGroupedFieldSet(exeContext, operation, rootType, rootValue, groupedFieldSet, newDeferMap); + if (newGroupedFieldSets.size > 0) { + const newPendingExecutionGroups = collectExecutionGroups(exeContext, rootType, rootValue, undefined, undefined, newGroupedFieldSets, newDeferMap); + return withNewExecutionGroups(graphqlWrappedResult, newPendingExecutionGroups); + } + return graphqlWrappedResult; +} +function withNewExecutionGroups(result, newPendingExecutionGroups) { + if (isPromise(result)) { + return result.then((resolved) => { + addIncrementalDataRecords(resolved, newPendingExecutionGroups); + return resolved; + }); + } + addIncrementalDataRecords(result, newPendingExecutionGroups); + return result; +} +function executeRootGroupedFieldSet(exeContext, operation, rootType, rootValue, groupedFieldSet, deferMap) { + switch (operation) { + case OperationTypeNode.QUERY: + return executeFields(exeContext, rootType, rootValue, undefined, groupedFieldSet, undefined, deferMap); + case OperationTypeNode.MUTATION: + return executeFieldsSerially(exeContext, rootType, rootValue, undefined, groupedFieldSet, undefined, deferMap); + case OperationTypeNode.SUBSCRIPTION: + // TODO: deprecate `subscribe` and move all logic here + // Temporary solution until we finish merging execute and subscribe together + return executeFields(exeContext, rootType, rootValue, undefined, groupedFieldSet, undefined, deferMap); + } +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that must be executed serially. + */ +function executeFieldsSerially(exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap) { + const abortSignal = exeContext.validatedExecutionArgs.abortSignal; + return promiseReduce(groupedFieldSet, (graphqlWrappedResult, [responseName, fieldDetailsList]) => { + const fieldPath = addPath(path, responseName, parentType.name); + if (abortSignal?.aborted) { + handleFieldError(abortSignal.reason, exeContext, parentType, fieldDetailsList, fieldPath, incrementalContext); + graphqlWrappedResult.rawResult[responseName] = null; + return graphqlWrappedResult; + } + const result = executeField(exeContext, parentType, sourceValue, fieldDetailsList, fieldPath, incrementalContext, deferMap); + if (result === undefined) { + return graphqlWrappedResult; + } + if (isPromise(result)) { + return result.then((resolved) => { + graphqlWrappedResult.rawResult[responseName] = resolved.rawResult; + addIncrementalDataRecords(graphqlWrappedResult, resolved.incrementalDataRecords); + return graphqlWrappedResult; + }); + } + graphqlWrappedResult.rawResult[responseName] = result.rawResult; + addIncrementalDataRecords(graphqlWrappedResult, result.incrementalDataRecords); + return graphqlWrappedResult; + }, { + rawResult: Object.create(null), + incrementalDataRecords: undefined, + }); +} +function addIncrementalDataRecords(graphqlWrappedResult, incrementalDataRecords) { + if (incrementalDataRecords === undefined) { + return; + } + if (graphqlWrappedResult.incrementalDataRecords === undefined) { + graphqlWrappedResult.incrementalDataRecords = [...incrementalDataRecords]; + } + else { + graphqlWrappedResult.incrementalDataRecords.push(...incrementalDataRecords); + } +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that may be executed in parallel. + */ +function executeFields(exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap) { + const results = Object.create(null); + const graphqlWrappedResult = { + rawResult: results, + incrementalDataRecords: undefined, + }; + let containsPromise = false; + try { + for (const [responseName, fieldDetailsList] of groupedFieldSet) { + const fieldPath = addPath(path, responseName, parentType.name); + const result = executeField(exeContext, parentType, sourceValue, fieldDetailsList, fieldPath, incrementalContext, deferMap); + if (result !== undefined) { + if (isPromise(result)) { + results[responseName] = result.then((resolved) => { + addIncrementalDataRecords(graphqlWrappedResult, resolved.incrementalDataRecords); + return resolved.rawResult; + }); + containsPromise = true; + } + else { + results[responseName] = result.rawResult; + addIncrementalDataRecords(graphqlWrappedResult, result.incrementalDataRecords); + } + } + } + } + catch (error) { + if (containsPromise) { + // Ensure that any promises returned by other fields are handled, as they may also reject. + return promiseForObject(results, () => { + /* noop */ + }).finally(() => { + throw error; + }); + } + throw error; + } + // If there are no promises, we can just return the object and any incrementalDataRecords + if (!containsPromise) { + return graphqlWrappedResult; + } + // Otherwise, results is a map from field name to the result of resolving that + // field, which is possibly a promise. Return a promise that will return this + // same map, but with any promises replaced with the values they resolved to. + return promiseForObject(results, (resolved) => ({ + rawResult: resolved, + incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords, + })); +} +function toNodes(fieldDetailsList) { + return fieldDetailsList.map((fieldDetails) => fieldDetails.node); +} +/** + * Implements the "Executing fields" section of the spec + * In particular, this function figures out the value that the field returns by + * calling its resolve function, then calls completeValue to complete promises, + * coercing scalars, or execute the sub-selection-set for objects. + */ +function executeField(exeContext, parentType, source, fieldDetailsList, path, incrementalContext, deferMap) { + const { validatedExecutionArgs, abortSignalListener } = exeContext; + const { schema, contextValue, variableValues, hideSuggestions, abortSignal } = validatedExecutionArgs; + const fieldName = fieldDetailsList[0].node.name.value; + const fieldDef = schema.getField(parentType, fieldName); + if (!fieldDef) { + return; + } + const returnType = fieldDef.type; + const resolveFn = fieldDef.resolve ?? validatedExecutionArgs.fieldResolver; + const info = buildResolveInfo(validatedExecutionArgs, fieldDef, toNodes(fieldDetailsList), parentType, path); + // Get the resolve function, regardless of if its result is normal or abrupt (error). + try { + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + // TODO: find a way to memoize, in case this field is within a List type. + const args = getArgumentValues(fieldDef, fieldDetailsList[0].node, variableValues, fieldDetailsList[0].fragmentVariableValues, hideSuggestions); + // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + const result = resolveFn(source, args, contextValue, info, abortSignal); + if (isPromise(result)) { + return completePromisedValue(exeContext, returnType, fieldDetailsList, info, path, abortSignalListener + ? cancellablePromise(result, abortSignalListener) + : result, incrementalContext, deferMap); + } + const completed = completeValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + if (isPromise(completed)) { + // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + return completed.then(undefined, (rawError) => { + handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + }); + } + return completed; + } + catch (rawError) { + handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + } +} +/** + * TODO: consider no longer exporting this function + * @internal + */ +export function buildResolveInfo(validatedExecutionArgs, fieldDef, fieldNodes, parentType, path) { + const { schema, fragmentDefinitions, rootValue, operation, variableValues } = validatedExecutionArgs; + // The resolve function's optional fourth argument is a collection of + // information about the current execution state. + return { + fieldName: fieldDef.name, + fieldNodes, + returnType: fieldDef.type, + parentType, + path, + schema, + fragments: fragmentDefinitions, + rootValue, + operation, + variableValues, + }; +} +function handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext) { + const error = locatedError(rawError, toNodes(fieldDetailsList), pathToArray(path)); + // If the field type is non-nullable, then it is resolved without any + // protection from errors, however it still properly locates the error. + if (exeContext.errorPropagation && isNonNullType(returnType)) { + throw error; + } + // Otherwise, error protection is applied, logging the error and resolving + // a null value for this field if one is encountered. + const context = incrementalContext ?? exeContext; + let errors = context.errors; + if (errors === undefined) { + errors = []; + context.errors = errors; + } + errors.push(error); +} +/** + * Implements the instructions for completeValue as defined in the + * "Value Completion" section of the spec. + * + * If the field type is Non-Null, then this recursively completes the value + * for the inner type. It throws a field error if that completion returns null, + * as per the "Nullability" section of the spec. + * + * If the field type is a List, then this recursively completes the value + * for the inner type on each item in the list. + * + * If the field type is a Scalar or Enum, ensures the completed value is a legal + * value of the type by calling the `coerceOutputValue` method of GraphQL type + * definition. + * + * If the field is an abstract type, determine the runtime type of the value + * and then complete based on that type + * + * Otherwise, the field type expects a sub-selection set, and will complete the + * value by executing all sub-selections. + */ +function completeValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + // If result is an Error, throw a located error. + if (result instanceof Error) { + throw result; + } + // If field type is NonNull, complete for inner type, and throw field error + // if result is null. + if (isNonNullType(returnType)) { + const completed = completeValue(exeContext, returnType.ofType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + if (completed.rawResult === null) { + throw new Error(`Cannot return null for non-nullable field ${info.parentType}.${info.fieldName}.`); + } + return completed; + } + // If result value is null or undefined then return null. + if (result == null) { + return { rawResult: null, incrementalDataRecords: undefined }; + } + // If field type is List, complete each item in the list with the inner type + if (isListType(returnType)) { + return completeListValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + } + // If field type is a leaf type, Scalar or Enum, coerce to a valid value, + // returning null if coercion is not possible. + if (isLeafType(returnType)) { + return { + rawResult: completeLeafValue(returnType, result), + incrementalDataRecords: undefined, + }; + } + // If field type is an abstract type, Interface or Union, determine the + // runtime Object type and complete for that type. + if (isAbstractType(returnType)) { + return completeAbstractValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + } + // If field type is Object, execute and complete all sub-selections. + if (isObjectType(returnType)) { + return completeObjectValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap); + } + /* c8 ignore next 6 */ + // Not reachable, all possible output types have been considered. + (false) || invariant(false, 'Cannot complete value of unexpected output type: ' + inspect(returnType)); +} +async function completePromisedValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + try { + const resolved = await result; + let completed = completeValue(exeContext, returnType, fieldDetailsList, info, path, resolved, incrementalContext, deferMap); + if (isPromise(completed)) { + completed = await completed; + } + return completed; + } + catch (rawError) { + handleFieldError(rawError, exeContext, returnType, fieldDetailsList, path, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + } +} +/** + * Returns an object containing info for streaming if a field should be + * streamed based on the experimental flag, stream directive present and + * not disabled by the "if" argument. + */ +function getStreamUsage(validatedExecutionArgs, fieldDetailsList, path) { + // do not stream inner lists of multi-dimensional lists + if (typeof path.key === 'number') { + return; + } + // TODO: add test for this case (a streamed list nested under a list). + /* c8 ignore next 7 */ + if (fieldDetailsList + ._streamUsage !== undefined) { + return fieldDetailsList + ._streamUsage; + } + const { operation, variableValues } = validatedExecutionArgs; + // validation only allows equivalent streams on multiple fields, so it is + // safe to only check the first fieldNode for the stream directive + const stream = getDirectiveValues(GraphQLStreamDirective, fieldDetailsList[0].node, variableValues, fieldDetailsList[0].fragmentVariableValues); + if (!stream) { + return; + } + if (stream.if === false) { + return; + } + (typeof stream.initialCount === 'number') || invariant(false, 'initialCount must be a number'); + (stream.initialCount >= 0) || invariant(false, 'initialCount must be a positive integer'); + (operation.operation !== OperationTypeNode.SUBSCRIPTION) || invariant(false, '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.'); + const streamedFieldDetailsList = fieldDetailsList.map((fieldDetails) => ({ + node: fieldDetails.node, + deferUsage: undefined, + fragmentVariableValues: fieldDetails.fragmentVariableValues, + })); + const streamUsage = { + initialCount: stream.initialCount, + label: typeof stream.label === 'string' ? stream.label : undefined, + fieldDetailsList: streamedFieldDetailsList, + }; + fieldDetailsList._streamUsage = + streamUsage; + return streamUsage; +} +/** + * Complete a async iterator value by completing the result and calling + * recursively until all the results are completed. + */ +async function completeAsyncIteratorValue(exeContext, itemType, fieldDetailsList, info, path, asyncIterator, incrementalContext, deferMap) { + let containsPromise = false; + const completedResults = []; + const graphqlWrappedResult = { + rawResult: completedResults, + incrementalDataRecords: undefined, + }; + let index = 0; + const streamUsage = getStreamUsage(exeContext.validatedExecutionArgs, fieldDetailsList, path); + const earlyReturn = asyncIterator.return === undefined + ? undefined + : asyncIterator.return.bind(asyncIterator); + try { + while (true) { + if (streamUsage && index >= streamUsage.initialCount) { + const streamItemQueue = buildAsyncStreamItemQueue(index, path, asyncIterator, exeContext, streamUsage.fieldDetailsList, info, itemType); + let streamRecord; + if (earlyReturn === undefined) { + streamRecord = { + label: streamUsage.label, + path, + streamItemQueue, + }; + } + else { + streamRecord = { + label: streamUsage.label, + path, + earlyReturn, + streamItemQueue, + }; + if (exeContext.cancellableStreams === undefined) { + exeContext.cancellableStreams = new Set(); + } + exeContext.cancellableStreams.add(streamRecord); + } + addIncrementalDataRecords(graphqlWrappedResult, [streamRecord]); + break; + } + const itemPath = addPath(path, index, undefined); + let iteration; + try { + // eslint-disable-next-line no-await-in-loop + iteration = await asyncIterator.next(); + } + catch (rawError) { + throw locatedError(rawError, toNodes(fieldDetailsList), pathToArray(path)); + } + // TODO: add test case for stream returning done before initialCount + /* c8 ignore next 3 */ + if (iteration.done) { + break; + } + const item = iteration.value; + // TODO: add tests for stream backed by asyncIterator that returns a promise + /* c8 ignore start */ + if (isPromise(item)) { + completedResults.push(completePromisedListItemValue(item, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap)); + containsPromise = true; + } + else if ( + /* c8 ignore stop */ + completeListItemValue(item, completedResults, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap) + // TODO: add tests for stream backed by asyncIterator that completes to a promise + /* c8 ignore start */ + ) { + containsPromise = true; + } + /* c8 ignore stop */ + index++; + } + } + catch (error) { + if (earlyReturn !== undefined) { + earlyReturn().catch(() => { + /* c8 ignore next 1 */ + // ignore error + }); + } + throw error; + } + return containsPromise + ? /* c8 ignore start */ Promise.all(completedResults).then((resolved) => ({ + rawResult: resolved, + incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords, + })) + : /* c8 ignore stop */ graphqlWrappedResult; +} +/** + * Complete a list value by completing each item in the list with the + * inner type + */ +function completeListValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + const itemType = returnType.ofType; + if (isAsyncIterable(result)) { + const abortSignalListener = exeContext.abortSignalListener; + const maybeCancellableIterable = abortSignalListener + ? cancellableIterable(result, abortSignalListener) + : result; + const asyncIterator = maybeCancellableIterable[Symbol.asyncIterator](); + return completeAsyncIteratorValue(exeContext, itemType, fieldDetailsList, info, path, asyncIterator, incrementalContext, deferMap); + } + if (!isIterableObject(result)) { + throw new GraphQLError(`Expected Iterable, but did not find one for field "${info.parentType}.${info.fieldName}".`); + } + return completeIterableValue(exeContext, itemType, fieldDetailsList, info, path, result, incrementalContext, deferMap); +} +function completeIterableValue(exeContext, itemType, fieldDetailsList, info, path, items, incrementalContext, deferMap) { + // This is specified as a simple map, however we're optimizing the path + // where the list contains no Promises by avoiding creating another Promise. + let containsPromise = false; + const completedResults = []; + const graphqlWrappedResult = { + rawResult: completedResults, + incrementalDataRecords: undefined, + }; + let index = 0; + const streamUsage = getStreamUsage(exeContext.validatedExecutionArgs, fieldDetailsList, path); + const iterator = items[Symbol.iterator](); + let iteration = iterator.next(); + while (!iteration.done) { + const item = iteration.value; + if (streamUsage && index >= streamUsage.initialCount) { + const syncStreamRecord = { + label: streamUsage.label, + path, + streamItemQueue: buildSyncStreamItemQueue(item, index, path, iterator, exeContext, streamUsage.fieldDetailsList, info, itemType), + }; + addIncrementalDataRecords(graphqlWrappedResult, [syncStreamRecord]); + break; + } + // No need to modify the info object containing the path, + // since from here on it is not ever accessed by resolver functions. + const itemPath = addPath(path, index, undefined); + if (isPromise(item)) { + completedResults.push(completePromisedListItemValue(item, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap)); + containsPromise = true; + } + else if (completeListItemValue(item, completedResults, graphqlWrappedResult, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap)) { + containsPromise = true; + } + index++; + iteration = iterator.next(); + } + return containsPromise + ? Promise.all(completedResults).then((resolved) => ({ + rawResult: resolved, + incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords, + })) + : graphqlWrappedResult; +} +/** + * Complete a list item value by adding it to the completed results. + * + * Returns true if the value is a Promise. + */ +function completeListItemValue(item, completedResults, parent, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap) { + try { + const completedItem = completeValue(exeContext, itemType, fieldDetailsList, info, itemPath, item, incrementalContext, deferMap); + if (isPromise(completedItem)) { + // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + completedResults.push(completedItem.then((resolved) => { + addIncrementalDataRecords(parent, resolved.incrementalDataRecords); + return resolved.rawResult; + }, (rawError) => { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + return null; + })); + return true; + } + completedResults.push(completedItem.rawResult); + addIncrementalDataRecords(parent, completedItem.incrementalDataRecords); + } + catch (rawError) { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + completedResults.push(null); + } + return false; +} +async function completePromisedListItemValue(item, parent, exeContext, itemType, fieldDetailsList, info, itemPath, incrementalContext, deferMap) { + try { + const abortSignalListener = exeContext.abortSignalListener; + const maybeCancellableItem = abortSignalListener + ? cancellablePromise(item, abortSignalListener) + : item; + const resolved = await maybeCancellableItem; + let completed = completeValue(exeContext, itemType, fieldDetailsList, info, itemPath, resolved, incrementalContext, deferMap); + if (isPromise(completed)) { + completed = await completed; + } + addIncrementalDataRecords(parent, completed.incrementalDataRecords); + return completed.rawResult; + } + catch (rawError) { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + return null; + } +} +/** + * Complete a Scalar or Enum by serializing to a valid value, returning + * null if serialization is not possible. + */ +function completeLeafValue(returnType, result) { + const coerced = returnType.coerceOutputValue(result); + if (coerced == null) { + throw new Error(`Expected \`${inspect(returnType)}.coerceOutputValue(${inspect(result)})\` to ` + + `return non-nullable value, returned: ${inspect(coerced)}`); + } + return coerced; +} +/** + * Complete a value of an abstract type by determining the runtime object type + * of that value, then complete the value for that type. + */ +function completeAbstractValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + const validatedExecutionArgs = exeContext.validatedExecutionArgs; + const { schema, contextValue } = validatedExecutionArgs; + const resolveTypeFn = returnType.resolveType ?? validatedExecutionArgs.typeResolver; + const runtimeType = resolveTypeFn(result, contextValue, info, returnType); + if (isPromise(runtimeType)) { + return runtimeType.then((resolvedRuntimeType) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, schema, returnType, fieldDetailsList, info, result), fieldDetailsList, info, path, result, incrementalContext, deferMap)); + } + return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, schema, returnType, fieldDetailsList, info, result), fieldDetailsList, info, path, result, incrementalContext, deferMap); +} +function ensureValidRuntimeType(runtimeTypeName, schema, returnType, fieldDetailsList, info, result) { + if (runtimeTypeName == null) { + throw new GraphQLError(`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}". Either the "${returnType}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`, { nodes: toNodes(fieldDetailsList) }); + } + if (typeof runtimeTypeName !== 'string') { + throw new GraphQLError(`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}" with ` + + `value ${inspect(result)}, received "${inspect(runtimeTypeName)}", which is not a valid Object type name.`); + } + const runtimeType = schema.getType(runtimeTypeName); + if (runtimeType == null) { + throw new GraphQLError(`Abstract type "${returnType}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`, { nodes: toNodes(fieldDetailsList) }); + } + if (!isObjectType(runtimeType)) { + throw new GraphQLError(`Abstract type "${returnType}" was resolved to a non-object type "${runtimeTypeName}".`, { nodes: toNodes(fieldDetailsList) }); + } + if (!schema.isSubType(returnType, runtimeType)) { + throw new GraphQLError(`Runtime Object type "${runtimeType}" is not a possible type for "${returnType}".`, { nodes: toNodes(fieldDetailsList) }); + } + return runtimeType; +} +/** + * Complete an Object value by executing all sub-selections. + */ +function completeObjectValue(exeContext, returnType, fieldDetailsList, info, path, result, incrementalContext, deferMap) { + if ((incrementalContext ?? exeContext).completed) { + throw new Error('Completed, aborting.'); + } + // If there is an isTypeOf predicate function, call it with the + // current result. If isTypeOf returns false, then raise an error rather + // than continuing execution. + if (returnType.isTypeOf) { + const isTypeOf = returnType.isTypeOf(result, exeContext.validatedExecutionArgs.contextValue, info); + if (isPromise(isTypeOf)) { + return isTypeOf.then((resolvedIsTypeOf) => { + if (!resolvedIsTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldDetailsList); + } + return collectAndExecuteSubfields(exeContext, returnType, fieldDetailsList, path, result, incrementalContext, deferMap); + }); + } + if (!isTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldDetailsList); + } + } + return collectAndExecuteSubfields(exeContext, returnType, fieldDetailsList, path, result, incrementalContext, deferMap); +} +function invalidReturnTypeError(returnType, result, fieldDetailsList) { + return new GraphQLError(`Expected value of type "${returnType}" but got: ${inspect(result)}.`, { nodes: toNodes(fieldDetailsList) }); +} +/** + * Instantiates new DeferredFragmentRecords for the given path within an + * incremental data record, returning an updated map of DeferUsage + * objects to DeferredFragmentRecords. + * + * Note: As defer directives may be used with operations returning lists, + * a DeferUsage object may correspond to many DeferredFragmentRecords. + */ +function getNewDeferMap(newDeferUsages, deferMap, path) { + const newDeferMap = new Map(deferMap); + // For each new deferUsage object: + for (const newDeferUsage of newDeferUsages) { + const parentDeferUsage = newDeferUsage.parentDeferUsage; + const parent = parentDeferUsage === undefined + ? undefined + : deferredFragmentRecordFromDeferUsage(parentDeferUsage, newDeferMap); + // Instantiate the new record. + const deferredFragmentRecord = new DeferredFragmentRecord(path, newDeferUsage.label, parent); + // Update the map. + newDeferMap.set(newDeferUsage, deferredFragmentRecord); + } + return newDeferMap; +} +function deferredFragmentRecordFromDeferUsage(deferUsage, deferMap) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return deferMap.get(deferUsage); +} +function collectAndExecuteSubfields(exeContext, returnType, fieldDetailsList, path, result, incrementalContext, deferMap) { + const validatedExecutionArgs = exeContext.validatedExecutionArgs; + // Collect sub-fields to execute to complete this value. + const collectedSubfields = collectSubfields(validatedExecutionArgs, returnType, fieldDetailsList); + const { groupedFieldSet, newDeferUsages } = collectedSubfields; + if (newDeferUsages.length > 0) { + (validatedExecutionArgs.operation.operation !== + OperationTypeNode.SUBSCRIPTION) || invariant(false, '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.'); + } + return executeSubExecutionPlan(exeContext, returnType, result, groupedFieldSet, newDeferUsages, path, incrementalContext, deferMap); +} +function executeSubExecutionPlan(exeContext, returnType, sourceValue, originalGroupedFieldSet, newDeferUsages, path, incrementalContext, deferMap) { + if (deferMap === undefined && newDeferUsages.length === 0) { + return executeFields(exeContext, returnType, sourceValue, path, originalGroupedFieldSet, incrementalContext, deferMap); + } + const newDeferMap = getNewDeferMap(newDeferUsages, deferMap, path); + const { groupedFieldSet, newGroupedFieldSets } = buildSubExecutionPlan(originalGroupedFieldSet, incrementalContext?.deferUsageSet); + const graphqlWrappedResult = executeFields(exeContext, returnType, sourceValue, path, groupedFieldSet, incrementalContext, newDeferMap); + if (newGroupedFieldSets.size > 0) { + const newPendingExecutionGroups = collectExecutionGroups(exeContext, returnType, sourceValue, path, incrementalContext?.deferUsageSet, newGroupedFieldSets, newDeferMap); + return withNewExecutionGroups(graphqlWrappedResult, newPendingExecutionGroups); + } + return graphqlWrappedResult; +} +function buildSubExecutionPlan(originalGroupedFieldSet, deferUsageSet) { + let executionPlan = originalGroupedFieldSet._executionPlan; + if (executionPlan !== undefined) { + return executionPlan; + } + executionPlan = buildExecutionPlan(originalGroupedFieldSet, deferUsageSet); + originalGroupedFieldSet._executionPlan = executionPlan; + return executionPlan; +} +/** + * If a resolveType function is not given, then a default resolve behavior is + * used which attempts two strategies: + * + * First, See if the provided value has a `__typename` field defined, if so, use + * that value as name of the resolved type. + * + * Otherwise, test each possible type for the abstract type by calling + * isTypeOf for the object being coerced, returning the first type that matches. + */ +export const defaultTypeResolver = function (value, contextValue, info, abstractType) { + // First, look for `__typename`. + if (isObjectLike(value) && typeof value.__typename === 'string') { + return value.__typename; + } + // Otherwise, test each possible type. + const possibleTypes = info.schema.getPossibleTypes(abstractType); + const promisedIsTypeOfResults = []; + for (let i = 0; i < possibleTypes.length; i++) { + const type = possibleTypes[i]; + if (type.isTypeOf) { + const isTypeOfResult = type.isTypeOf(value, contextValue, info); + if (isPromise(isTypeOfResult)) { + promisedIsTypeOfResults[i] = isTypeOfResult; + } + else if (isTypeOfResult) { + if (promisedIsTypeOfResults.length > 0) { + Promise.all(promisedIsTypeOfResults).then(undefined, () => { + /* ignore errors */ + }); + } + return type.name; + } + } + } + if (promisedIsTypeOfResults.length) { + return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => { + for (let i = 0; i < isTypeOfResults.length; i++) { + if (isTypeOfResults[i]) { + return possibleTypes[i].name; + } + } + }); + } +}; +/** + * If a resolve function is not given, then a default resolve behavior is used + * which takes the property of the source object of the same name as the field + * and returns it as the result, or if it's a function, returns the result + * of calling that function while passing along args and context value. + */ +export const defaultFieldResolver = function (source, args, contextValue, info, abortSignal) { + // ensure source is a value for which property access is acceptable. + if (isObjectLike(source) || typeof source === 'function') { + const property = source[info.fieldName]; + if (typeof property === 'function') { + return source[info.fieldName](args, contextValue, info, abortSignal); + } + return property; + } +}; +/** + * Implements the "Subscribe" algorithm described in the GraphQL specification. + * + * Returns a Promise which resolves to either an AsyncIterator (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with descriptive + * errors and no data will be returned. + * + * If the source stream could not be created due to faulty subscription resolver + * logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to an AsyncIterator, which + * yields a stream of ExecutionResults representing the response stream. + * + * This function does not support incremental delivery (`@defer` and `@stream`). + * If an operation which would defer or stream data is executed with this + * function, a field error will be raised at the location of the `@defer` or + * `@stream` directive. + * + * Accepts an object with named arguments. + */ +export function subscribe(args) { + // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + const validatedExecutionArgs = validateExecutionArgs(args); + // Return early errors if execution context failed. + if (!('schema' in validatedExecutionArgs)) { + return { errors: validatedExecutionArgs }; + } + const resultOrStream = createSourceEventStreamImpl(validatedExecutionArgs); + if (isPromise(resultOrStream)) { + return resultOrStream.then((resolvedResultOrStream) => mapSourceToResponse(validatedExecutionArgs, resolvedResultOrStream)); + } + return mapSourceToResponse(validatedExecutionArgs, resultOrStream); +} +function mapSourceToResponse(validatedExecutionArgs, resultOrStream) { + if (!isAsyncIterable(resultOrStream)) { + return resultOrStream; + } + const abortSignal = validatedExecutionArgs.abortSignal; + const abortSignalListener = abortSignal + ? new AbortSignalListener(abortSignal) + : undefined; + // For each payload yielded from a subscription, map it over the normal + // GraphQL `execute` function, with `payload` as the rootValue. + // This implements the "MapSourceToResponseEvent" algorithm described in + // the GraphQL specification.. + return mapAsyncIterable(abortSignalListener + ? cancellableIterable(resultOrStream, abortSignalListener) + : resultOrStream, (payload) => { + const perEventExecutionArgs = { + ...validatedExecutionArgs, + rootValue: payload, + }; + return validatedExecutionArgs.perEventExecutor(perEventExecutionArgs); + }, () => abortSignalListener?.disconnect()); +} +export function executeSubscriptionEvent(validatedExecutionArgs) { + return executeQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs); +} +/** + * Implements the "CreateSourceEventStream" algorithm described in the + * GraphQL specification, resolving the subscription source event stream. + * + * Returns a Promise which resolves to either an AsyncIterable (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with + * descriptive errors and no data will be returned. + * + * If the the source stream could not be created due to faulty subscription + * resolver logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to the AsyncIterable for the + * event stream returned by the resolver. + * + * A Source Event Stream represents a sequence of events, each of which triggers + * a GraphQL execution for that event. + * + * This may be useful when hosting the stateful subscription service in a + * different process or machine than the stateless GraphQL execution engine, + * or otherwise separating these two steps. For more on this, see the + * "Supporting Subscriptions at Scale" information in the GraphQL specification. + */ +export function createSourceEventStream(args) { + // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + const validatedExecutionArgs = validateExecutionArgs(args); + // Return early errors if execution context failed. + if (!('schema' in validatedExecutionArgs)) { + return { errors: validatedExecutionArgs }; + } + return createSourceEventStreamImpl(validatedExecutionArgs); +} +function createSourceEventStreamImpl(validatedExecutionArgs) { + try { + const eventStream = executeSubscription(validatedExecutionArgs); + if (isPromise(eventStream)) { + return eventStream.then(undefined, (error) => ({ + errors: [error], + })); + } + return eventStream; + } + catch (error) { + return { errors: [error] }; + } +} +function executeSubscription(validatedExecutionArgs) { + const { schema, fragments, rootValue, contextValue, operation, variableValues, hideSuggestions, abortSignal, } = validatedExecutionArgs; + const rootType = schema.getSubscriptionType(); + if (rootType == null) { + throw new GraphQLError('Schema is not configured to execute subscription operation.', { nodes: operation }); + } + const { groupedFieldSet } = collectFields(schema, fragments, variableValues, rootType, operation.selectionSet, hideSuggestions); + const firstRootField = groupedFieldSet.entries().next().value; + const [responseName, fieldDetailsList] = firstRootField; + const fieldName = fieldDetailsList[0].node.name.value; + const fieldDef = schema.getField(rootType, fieldName); + const fieldNodes = fieldDetailsList.map((fieldDetails) => fieldDetails.node); + if (!fieldDef) { + throw new GraphQLError(`The subscription field "${fieldName}" is not defined.`, { nodes: fieldNodes }); + } + const path = addPath(undefined, responseName, rootType.name); + const info = buildResolveInfo(validatedExecutionArgs, fieldDef, fieldNodes, rootType, path); + try { + // Implements the "ResolveFieldEventStream" algorithm from GraphQL specification. + // It differs from "ResolveFieldValue" due to providing a different `resolveFn`. + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + const args = getArgumentValues(fieldDef, fieldNodes[0], variableValues, fieldDetailsList[0].fragmentVariableValues, hideSuggestions); + // Call the `subscribe()` resolver or the default resolver to produce an + // AsyncIterable yielding raw payloads. + const resolveFn = fieldDef.subscribe ?? validatedExecutionArgs.subscribeFieldResolver; + // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + const result = resolveFn(rootValue, args, contextValue, info, abortSignal); + if (isPromise(result)) { + const abortSignalListener = abortSignal + ? new AbortSignalListener(abortSignal) + : undefined; + const promise = abortSignalListener + ? cancellablePromise(result, abortSignalListener) + : result; + return promise.then(assertEventStream).then((resolved) => { + abortSignalListener?.disconnect(); + return resolved; + }, (error) => { + abortSignalListener?.disconnect(); + throw locatedError(error, fieldNodes, pathToArray(path)); + }); + } + return assertEventStream(result); + } + catch (error) { + throw locatedError(error, fieldNodes, pathToArray(path)); + } +} +function assertEventStream(result) { + if (result instanceof Error) { + throw result; + } + // Assert field returned an event stream, otherwise yield an error. + if (!isAsyncIterable(result)) { + throw new GraphQLError('Subscription field must return Async Iterable. ' + + `Received: ${inspect(result)}.`); + } + return result; +} +function collectExecutionGroups(exeContext, parentType, sourceValue, path, parentDeferUsages, newGroupedFieldSets, deferMap) { + const newPendingExecutionGroups = []; + for (const [deferUsageSet, groupedFieldSet] of newGroupedFieldSets) { + const deferredFragmentRecords = getDeferredFragmentRecords(deferUsageSet, deferMap); + const pendingExecutionGroup = { + deferredFragmentRecords, + result: undefined, + }; + const executor = () => executeExecutionGroup(pendingExecutionGroup, exeContext, parentType, sourceValue, path, groupedFieldSet, { + errors: undefined, + completed: false, + deferUsageSet, + }, deferMap); + if (exeContext.validatedExecutionArgs.enableEarlyExecution) { + pendingExecutionGroup.result = new BoxedPromiseOrValue(shouldDefer(parentDeferUsages, deferUsageSet) + ? Promise.resolve().then(executor) + : executor()); + } + else { + pendingExecutionGroup.result = () => new BoxedPromiseOrValue(executor()); + } + newPendingExecutionGroups.push(pendingExecutionGroup); + } + return newPendingExecutionGroups; +} +function shouldDefer(parentDeferUsages, deferUsages) { + // If we have a new child defer usage, defer. + // Otherwise, this defer usage was already deferred when it was initially + // encountered, and is now in the midst of executing early, so the new + // deferred grouped fields set can be executed immediately. + return (parentDeferUsages === undefined || + !Array.from(deferUsages).every((deferUsage) => parentDeferUsages.has(deferUsage))); +} +function executeExecutionGroup(pendingExecutionGroup, exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap) { + let result; + try { + result = executeFields(exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap); + } + catch (error) { + incrementalContext.completed = true; + return { + pendingExecutionGroup, + path: pathToArray(path), + errors: withError(incrementalContext.errors, error), + }; + } + if (isPromise(result)) { + return result.then((resolved) => { + incrementalContext.completed = true; + return buildCompletedExecutionGroup(incrementalContext.errors, pendingExecutionGroup, path, resolved); + }, (error) => { + incrementalContext.completed = true; + return { + pendingExecutionGroup, + path: pathToArray(path), + errors: withError(incrementalContext.errors, error), + }; + }); + } + incrementalContext.completed = true; + return buildCompletedExecutionGroup(incrementalContext.errors, pendingExecutionGroup, path, result); +} +function buildCompletedExecutionGroup(errors, pendingExecutionGroup, path, result) { + const { rawResult: data, incrementalDataRecords } = result; + return { + pendingExecutionGroup, + path: pathToArray(path), + result: errors === undefined ? { data } : { data, errors }, + incrementalDataRecords, + }; +} +function getDeferredFragmentRecords(deferUsages, deferMap) { + return Array.from(deferUsages).map((deferUsage) => deferredFragmentRecordFromDeferUsage(deferUsage, deferMap)); +} +function buildSyncStreamItemQueue(initialItem, initialIndex, streamPath, iterator, exeContext, fieldDetailsList, info, itemType) { + const streamItemQueue = []; + const enableEarlyExecution = exeContext.validatedExecutionArgs.enableEarlyExecution; + const firstExecutor = () => { + const initialPath = addPath(streamPath, initialIndex, undefined); + const firstStreamItem = new BoxedPromiseOrValue(completeStreamItem(initialPath, initialItem, exeContext, { errors: undefined, completed: false }, fieldDetailsList, info, itemType)); + let iteration = iterator.next(); + let currentIndex = initialIndex + 1; + let currentStreamItem = firstStreamItem; + while (!iteration.done) { + // TODO: add test case for early sync termination + /* c8 ignore next 6 */ + if (currentStreamItem instanceof BoxedPromiseOrValue) { + const result = currentStreamItem.value; + if (!isPromise(result) && result.errors !== undefined) { + break; + } + } + const itemPath = addPath(streamPath, currentIndex, undefined); + const value = iteration.value; + const currentExecutor = () => completeStreamItem(itemPath, value, exeContext, { errors: undefined, completed: false }, fieldDetailsList, info, itemType); + currentStreamItem = enableEarlyExecution + ? new BoxedPromiseOrValue(currentExecutor()) + : () => new BoxedPromiseOrValue(currentExecutor()); + streamItemQueue.push(currentStreamItem); + iteration = iterator.next(); + currentIndex = initialIndex + 1; + } + streamItemQueue.push(new BoxedPromiseOrValue({})); + return firstStreamItem.value; + }; + streamItemQueue.push(enableEarlyExecution + ? new BoxedPromiseOrValue(Promise.resolve().then(firstExecutor)) + : () => new BoxedPromiseOrValue(firstExecutor())); + return streamItemQueue; +} +function buildAsyncStreamItemQueue(initialIndex, streamPath, asyncIterator, exeContext, fieldDetailsList, info, itemType) { + const streamItemQueue = []; + const executor = () => getNextAsyncStreamItemResult(streamItemQueue, streamPath, initialIndex, asyncIterator, exeContext, fieldDetailsList, info, itemType); + streamItemQueue.push(exeContext.validatedExecutionArgs.enableEarlyExecution + ? new BoxedPromiseOrValue(executor()) + : () => new BoxedPromiseOrValue(executor())); + return streamItemQueue; +} +async function getNextAsyncStreamItemResult(streamItemQueue, streamPath, index, asyncIterator, exeContext, fieldDetailsList, info, itemType) { + let iteration; + try { + iteration = await asyncIterator.next(); + } + catch (error) { + return { + errors: [ + locatedError(error, toNodes(fieldDetailsList), pathToArray(streamPath)), + ], + }; + } + if (iteration.done) { + return {}; + } + const itemPath = addPath(streamPath, index, undefined); + const result = completeStreamItem(itemPath, iteration.value, exeContext, { errors: undefined, completed: false }, fieldDetailsList, info, itemType); + const executor = () => getNextAsyncStreamItemResult(streamItemQueue, streamPath, index + 1, asyncIterator, exeContext, fieldDetailsList, info, itemType); + streamItemQueue.push(exeContext.validatedExecutionArgs.enableEarlyExecution + ? new BoxedPromiseOrValue(executor()) + : () => new BoxedPromiseOrValue(executor())); + return result; +} +function completeStreamItem(itemPath, item, exeContext, incrementalContext, fieldDetailsList, info, itemType) { + if (isPromise(item)) { + const abortSignalListener = exeContext.abortSignalListener; + const maybeCancellableItem = abortSignalListener + ? cancellablePromise(item, abortSignalListener) + : item; + return completePromisedValue(exeContext, itemType, fieldDetailsList, info, itemPath, maybeCancellableItem, incrementalContext, new Map()).then((resolvedItem) => { + incrementalContext.completed = true; + return buildStreamItemResult(incrementalContext.errors, resolvedItem); + }, (error) => { + incrementalContext.completed = true; + return { + errors: withError(incrementalContext.errors, error), + }; + }); + } + let result; + try { + try { + result = completeValue(exeContext, itemType, fieldDetailsList, info, itemPath, item, incrementalContext, new Map()); + } + catch (rawError) { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + result = { rawResult: null, incrementalDataRecords: undefined }; + } + } + catch (error) { + incrementalContext.completed = true; + return { + errors: withError(incrementalContext.errors, error), + }; + } + if (isPromise(result)) { + return result + .then(undefined, (rawError) => { + handleFieldError(rawError, exeContext, itemType, fieldDetailsList, itemPath, incrementalContext); + return { rawResult: null, incrementalDataRecords: undefined }; + }) + .then((resolvedItem) => { + incrementalContext.completed = true; + return buildStreamItemResult(incrementalContext.errors, resolvedItem); + }, (error) => { + incrementalContext.completed = true; + return { + errors: withError(incrementalContext.errors, error), + }; + }); + } + incrementalContext.completed = true; + return buildStreamItemResult(incrementalContext.errors, result); +} +function buildStreamItemResult(errors, result) { + const { rawResult: item, incrementalDataRecords } = result; + return { + item, + errors, + incrementalDataRecords, + }; +} +//# sourceMappingURL=execute.js.map \ No newline at end of file diff --git a/execution/execute.mjs.map b/execution/execute.mjs.map new file mode 100644 index 0000000000..a9ee189287 --- /dev/null +++ b/execution/execute.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/execution/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,2CAA0C;AACxE,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,eAAe,EAAE,uCAAsC;AAChE,OAAO,EAAE,gBAAgB,EAAE,wCAAuC;AAClE,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAEpD,OAAO,EAAE,QAAQ,EAAE,gCAA+B;AAGlD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,4BAA2B;AAC1D,OAAO,EAAE,gBAAgB,EAAE,wCAAuC;AAElE,OAAO,EAAE,aAAa,EAAE,qCAAoC;AAE5D,OAAO,EAAE,YAAY,EAAE,kCAAiC;AACxD,OAAO,EAAE,YAAY,EAAE,kCAAiC;AAQxD,OAAO,EAAE,iBAAiB,EAAE,4BAA2B;AACvD,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAa5C,OAAO,EACL,cAAc,EACd,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,GACb,+BAA8B;AAC/B,OAAO,EACL,uCAAuC,EACvC,sBAAsB,GACvB,+BAA8B;AAE/B,OAAO,EAAE,iBAAiB,EAAE,6BAA4B;AAExD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GACnB,kCAAiC;AAElC,OAAO,EAAE,kBAAkB,EAAE,iCAAgC;AAO7D,OAAO,EACL,aAAa,EACb,gBAAgB,IAAI,iBAAiB,GACtC,4BAA2B;AAC5B,OAAO,EAAE,oBAAoB,EAAE,mCAAkC;AACjE,OAAO,EAAE,wBAAwB,EAAE,mCAAkC;AACrE,OA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AAC,EACD,CAAC,KAAc,EAAE,EAAE;YACjB,kBAAkB,CAAC,SAAS,GAAG,IAAI,CAAC;YACpC,OAAO;gBACL,MAAM,EAAE,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAqB,CAAC;aACpE,CAAC;QACJ,CAAC,CACF,CAAC;IACN,CAAC;IAED,kBAAkB,CAAC,SAAS,GAAG,IAAI,CAAC;IACpC,OAAO,qBAAqB,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,qBAAqB,CAC5B,MAA+C,EAC/C,MAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,sBAAsB,EAAE,GAAG,MAAM,CAAC;IAC3D,OAAO;QACL,IAAI;QACJ,MAAM;QACN,sBAAsB;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import { BoxedPromiseOrValue } from '../jsutils/BoxedPromiseOrValue.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isAsyncIterable } from '../jsutils/isAsyncIterable.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { isPromise } from '../jsutils/isPromise.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport { memoize3 } from '../jsutils/memoize3.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport type { Path } from '../jsutils/Path.js';\nimport { addPath, pathToArray } from '../jsutils/Path.js';\nimport { promiseForObject } from '../jsutils/promiseForObject.js';\nimport type { PromiseOrValue } from '../jsutils/PromiseOrValue.js';\nimport { promiseReduce } from '../jsutils/promiseReduce.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\nimport { locatedError } from '../error/locatedError.js';\n\nimport type {\n DocumentNode,\n FieldNode,\n FragmentDefinitionNode,\n OperationDefinitionNode,\n} from '../language/ast.js';\nimport { OperationTypeNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type {\n GraphQLAbstractType,\n GraphQLField,\n GraphQLFieldResolver,\n GraphQLLeafType,\n GraphQLList,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLResolveInfo,\n GraphQLTypeResolver,\n} from '../type/definition.js';\nimport {\n isAbstractType,\n isLeafType,\n isListType,\n isNonNullType,\n isObjectType,\n} from '../type/definition.js';\nimport {\n GraphQLDisableErrorPropagationDirective,\n GraphQLStreamDirective,\n} from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\nimport { assertValidSchema } from '../type/validate.js';\n\nimport {\n AbortSignalListener,\n cancellableIterable,\n cancellablePromise,\n} from './AbortSignalListener.js';\nimport type { DeferUsageSet, ExecutionPlan } from './buildExecutionPlan.js';\nimport { buildExecutionPlan } from './buildExecutionPlan.js';\nimport type {\n DeferUsage,\n FieldDetailsList,\n FragmentDetails,\n GroupedFieldSet,\n} from './collectFields.js';\nimport {\n collectFields,\n collectSubfields as _collectSubfields,\n} from './collectFields.js';\nimport { getVariableSignature } from './getVariableSignature.js';\nimport { buildIncrementalResponse } from './IncrementalPublisher.js';\nimport { mapAsyncIterable } from './mapAsyncIterable.js';\nimport type {\n CancellableStreamRecord,\n CompletedExecutionGroup,\n ExecutionResult,\n ExperimentalIncrementalExecutionResults,\n IncrementalDataRecord,\n PendingExecutionGroup,\n StreamItemRecord,\n StreamItemResult,\n StreamRecord,\n} from './types.js';\nimport { DeferredFragmentRecord } from './types.js';\nimport type { VariableValues } from './values.js';\nimport {\n getArgumentValues,\n getDirectiveValues,\n getVariableValues,\n} from './values.js';\n\n/* eslint-disable @typescript-eslint/max-params */\n// This file contains a lot of such errors but we plan to refactor it anyway\n// so just disable it for entire file.\n\n/**\n * A memoized collection of relevant subfields with regard to the return\n * type. Memoizing ensures the subfields are not repeatedly calculated, which\n * saves overhead when resolving lists of values.\n */\nconst collectSubfields = memoize3(\n (\n validatedExecutionArgs: ValidatedExecutionArgs,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n ) => {\n const { schema, fragments, variableValues, hideSuggestions } =\n validatedExecutionArgs;\n return _collectSubfields(\n schema,\n fragments,\n variableValues,\n returnType,\n fieldDetailsList,\n hideSuggestions,\n );\n },\n);\n\n/**\n * Terminology\n *\n * \"Definitions\" are the generic name for top-level statements in the document.\n * Examples of this include:\n * 1) Operations (such as a query)\n * 2) Fragments\n *\n * \"Operations\" are a generic name for requests in the document.\n * Examples of this include:\n * 1) query,\n * 2) mutation\n *\n * \"Selections\" are the definitions that can appear legally and at\n * single level of the query. These include:\n * 1) field references e.g `a`\n * 2) fragment \"spreads\" e.g. `...c`\n * 3) inline fragment \"spreads\" e.g. `...on Type { a }`\n */\n\n/**\n * Data that must be available at all points during query execution.\n *\n * Namely, schema of the type system that is currently executing,\n * and the fragments defined in the query document\n */\nexport interface ValidatedExecutionArgs {\n schema: GraphQLSchema;\n // TODO: consider deprecating/removing fragmentDefinitions if/when fragment\n // arguments are officially supported and/or the full fragment details are\n // exposed within GraphQLResolveInfo.\n fragmentDefinitions: ObjMap;\n fragments: ObjMap;\n rootValue: unknown;\n contextValue: unknown;\n operation: OperationDefinitionNode;\n variableValues: VariableValues;\n fieldResolver: GraphQLFieldResolver;\n typeResolver: GraphQLTypeResolver;\n subscribeFieldResolver: GraphQLFieldResolver;\n perEventExecutor: (\n validatedExecutionArgs: ValidatedExecutionArgs,\n ) => PromiseOrValue;\n enableEarlyExecution: boolean;\n hideSuggestions: boolean;\n abortSignal: AbortSignal | undefined;\n}\n\nexport interface ExecutionContext {\n validatedExecutionArgs: ValidatedExecutionArgs;\n errors: Array | undefined;\n abortSignalListener: AbortSignalListener | undefined;\n completed: boolean;\n cancellableStreams: Set | undefined;\n errorPropagation: boolean;\n}\n\ninterface IncrementalContext {\n errors: Array | undefined;\n completed: boolean;\n deferUsageSet?: DeferUsageSet | undefined;\n}\n\nexport interface ExecutionArgs {\n schema: GraphQLSchema;\n document: DocumentNode;\n rootValue?: unknown;\n contextValue?: unknown;\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>;\n operationName?: Maybe;\n fieldResolver?: Maybe>;\n typeResolver?: Maybe>;\n subscribeFieldResolver?: Maybe>;\n perEventExecutor?: Maybe<\n (\n validatedExecutionArgs: ValidatedExecutionArgs,\n ) => PromiseOrValue\n >;\n enableEarlyExecution?: Maybe;\n hideSuggestions?: Maybe;\n abortSignal?: Maybe;\n}\n\nexport interface StreamUsage {\n label: string | undefined;\n initialCount: number;\n fieldDetailsList: FieldDetailsList;\n}\n\ninterface GraphQLWrappedResult {\n rawResult: T;\n incrementalDataRecords: Array | undefined;\n}\n\nconst UNEXPECTED_EXPERIMENTAL_DIRECTIVES =\n 'The provided schema unexpectedly contains experimental directives (@defer or @stream). These directives may only be utilized if experimental execution features are explicitly enabled.';\n\nconst UNEXPECTED_MULTIPLE_PAYLOADS =\n 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)';\n\n/**\n * Implements the \"Executing requests\" section of the GraphQL specification.\n *\n * Returns either a synchronous ExecutionResult (if all encountered resolvers\n * are synchronous), or a Promise of an ExecutionResult that will eventually be\n * resolved and never rejected.\n *\n * If the arguments to this function do not result in a legal execution context,\n * a GraphQLError will be thrown immediately explaining the invalid input.\n *\n * This function does not support incremental delivery (`@defer` and `@stream`).\n * If an operation which would defer or stream data is executed with this\n * function, it will throw or return a rejected promise.\n * Use `experimentalExecuteIncrementally` if you want to support incremental\n * delivery.\n */\nexport function execute(args: ExecutionArgs): PromiseOrValue {\n if (args.schema.getDirective('defer') || args.schema.getDirective('stream')) {\n throw new Error(UNEXPECTED_EXPERIMENTAL_DIRECTIVES);\n }\n\n const result = experimentalExecuteIncrementally(args);\n // Multiple payloads could be encountered if the operation contains @defer or\n // @stream directives and is not validated prior to execution\n return ensureSinglePayload(result);\n}\n\nfunction ensureSinglePayload(\n result: PromiseOrValue<\n ExecutionResult | ExperimentalIncrementalExecutionResults\n >,\n): PromiseOrValue {\n if (isPromise(result)) {\n return result.then((resolved) => {\n if ('initialResult' in resolved) {\n throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS);\n }\n return resolved;\n });\n }\n if ('initialResult' in result) {\n throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS);\n }\n return result;\n}\n\n/**\n * Implements the \"Executing requests\" section of the GraphQL specification,\n * including `@defer` and `@stream` as proposed in\n * https://github.com/graphql/graphql-spec/pull/742\n *\n * This function returns a Promise of an ExperimentalIncrementalExecutionResults\n * object. This object either consists of a single ExecutionResult, or an\n * object containing an `initialResult` and a stream of `subsequentResults`.\n *\n * If the arguments to this function do not result in a legal execution context,\n * a GraphQLError will be thrown immediately explaining the invalid input.\n */\nexport function experimentalExecuteIncrementally(\n args: ExecutionArgs,\n): PromiseOrValue {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const validatedExecutionArgs = validateExecutionArgs(args);\n\n // Return early errors if execution context failed.\n if (!('schema' in validatedExecutionArgs)) {\n return { errors: validatedExecutionArgs };\n }\n\n return experimentalExecuteQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs,\n );\n}\n\n/**\n * Implements the \"Executing operations\" section of the spec.\n *\n * Returns a Promise that will eventually resolve to the data described by\n * The \"Response\" section of the GraphQL specification.\n *\n * If errors are encountered while executing a GraphQL field, only that\n * field and its descendants will be omitted, and sibling fields will still\n * be executed. An execution which encounters errors will still result in a\n * resolved Promise.\n *\n * Errors from sub-fields of a NonNull type may propagate to the top level,\n * at which point we still log the error and null the parent field, which\n * in this case is the entire response.\n */\nexport function executeQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue {\n const result = experimentalExecuteQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs,\n );\n return ensureSinglePayload(result);\n}\n\nfunction errorPropagation(operation: OperationDefinitionNode): boolean {\n const directiveNode = operation.directives?.find(\n (directive) =>\n directive.name.value === GraphQLDisableErrorPropagationDirective.name,\n );\n\n return directiveNode === undefined;\n}\n\nexport function experimentalExecuteQueryOrMutationOrSubscriptionEvent(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue {\n const abortSignal = validatedExecutionArgs.abortSignal;\n const exeContext: ExecutionContext = {\n validatedExecutionArgs,\n errors: undefined,\n abortSignalListener: abortSignal\n ? new AbortSignalListener(abortSignal)\n : undefined,\n completed: false,\n cancellableStreams: undefined,\n errorPropagation: errorPropagation(validatedExecutionArgs.operation),\n };\n try {\n const {\n schema,\n fragments,\n rootValue,\n operation,\n variableValues,\n hideSuggestions,\n } = validatedExecutionArgs;\n\n const { operation: operationType, selectionSet } = operation;\n\n const rootType = schema.getRootType(operationType);\n if (rootType == null) {\n throw new GraphQLError(\n `Schema is not configured to execute ${operationType} operation.`,\n { nodes: operation },\n );\n }\n\n const { groupedFieldSet, newDeferUsages } = collectFields(\n schema,\n fragments,\n variableValues,\n rootType,\n selectionSet,\n hideSuggestions,\n );\n\n const graphqlWrappedResult = executeRootExecutionPlan(\n exeContext,\n operation.operation,\n rootType,\n rootValue,\n groupedFieldSet,\n newDeferUsages,\n );\n\n if (isPromise(graphqlWrappedResult)) {\n return graphqlWrappedResult.then(\n (resolved) => {\n exeContext.completed = true;\n return buildDataResponse(exeContext, resolved);\n },\n (error: unknown) => {\n exeContext.completed = true;\n exeContext.abortSignalListener?.disconnect();\n return {\n data: null,\n errors: withError(exeContext.errors, error as GraphQLError),\n };\n },\n );\n }\n exeContext.completed = true;\n return buildDataResponse(exeContext, graphqlWrappedResult);\n } catch (error) {\n exeContext.completed = true;\n // TODO: add test case for synchronous null bubbling to root with cancellation\n /* c8 ignore next */\n exeContext.abortSignalListener?.disconnect();\n return { data: null, errors: withError(exeContext.errors, error) };\n }\n}\n\nfunction withError(\n errors: Array | undefined,\n error: GraphQLError,\n): ReadonlyArray {\n return errors === undefined ? [error] : [...errors, error];\n}\n\nfunction buildDataResponse(\n exeContext: ExecutionContext,\n graphqlWrappedResult: GraphQLWrappedResult>,\n): ExecutionResult | ExperimentalIncrementalExecutionResults {\n const { rawResult: data, incrementalDataRecords } = graphqlWrappedResult;\n const errors = exeContext.errors;\n if (incrementalDataRecords === undefined) {\n exeContext.abortSignalListener?.disconnect();\n return errors !== undefined ? { errors, data } : { data };\n }\n\n return buildIncrementalResponse(\n exeContext,\n data,\n errors,\n incrementalDataRecords,\n );\n}\n\n/**\n * Also implements the \"Executing requests\" section of the GraphQL specification.\n * However, it guarantees to complete synchronously (or throw an error) assuming\n * that all field resolvers are also synchronous.\n */\nexport function executeSync(args: ExecutionArgs): ExecutionResult {\n const result = experimentalExecuteIncrementally(args);\n\n // Assert that the execution was synchronous.\n if (isPromise(result) || 'initialResult' in result) {\n throw new Error('GraphQL execution failed to complete synchronously.');\n }\n\n return result;\n}\n\n/**\n * Constructs a ExecutionContext object from the arguments passed to\n * execute, which we will pass throughout the other execution methods.\n *\n * Throws a GraphQLError if a valid execution context cannot be created.\n *\n * TODO: consider no longer exporting this function\n * @internal\n */\nexport function validateExecutionArgs(\n args: ExecutionArgs,\n): ReadonlyArray | ValidatedExecutionArgs {\n const {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues: rawVariableValues,\n operationName,\n fieldResolver,\n typeResolver,\n subscribeFieldResolver,\n perEventExecutor,\n enableEarlyExecution,\n abortSignal,\n } = args;\n\n if (abortSignal?.aborted) {\n return [locatedError(abortSignal.reason, undefined)];\n }\n\n // If the schema used for execution is invalid, throw an error.\n assertValidSchema(schema);\n\n let operation: OperationDefinitionNode | undefined;\n const fragmentDefinitions: ObjMap =\n Object.create(null);\n const fragments: ObjMap = Object.create(null);\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n return [\n new GraphQLError(\n 'Must provide operation name if query contains multiple operations.',\n ),\n ];\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n case Kind.FRAGMENT_DEFINITION: {\n fragmentDefinitions[definition.name.value] = definition;\n let variableSignatures;\n if (definition.variableDefinitions) {\n variableSignatures = Object.create(null);\n for (const varDef of definition.variableDefinitions) {\n const signature = getVariableSignature(schema, varDef);\n variableSignatures[signature.name] = signature;\n }\n }\n fragments[definition.name.value] = { definition, variableSignatures };\n break;\n }\n default:\n // ignore non-executable definitions\n }\n }\n\n if (!operation) {\n if (operationName != null) {\n return [new GraphQLError(`Unknown operation named \"${operationName}\".`)];\n }\n return [new GraphQLError('Must provide an operation.')];\n }\n\n const variableDefinitions = operation.variableDefinitions ?? [];\n const hideSuggestions = args.hideSuggestions ?? false;\n\n const variableValuesOrErrors = getVariableValues(\n schema,\n variableDefinitions,\n rawVariableValues ?? {},\n {\n maxErrors: 50,\n hideSuggestions,\n },\n );\n\n if (variableValuesOrErrors.errors) {\n return variableValuesOrErrors.errors;\n }\n\n return {\n schema,\n fragmentDefinitions,\n fragments,\n rootValue,\n contextValue,\n operation,\n variableValues: variableValuesOrErrors.variableValues,\n fieldResolver: fieldResolver ?? defaultFieldResolver,\n typeResolver: typeResolver ?? defaultTypeResolver,\n subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver,\n perEventExecutor: perEventExecutor ?? executeSubscriptionEvent,\n enableEarlyExecution: enableEarlyExecution === true,\n hideSuggestions,\n abortSignal: args.abortSignal ?? undefined,\n };\n}\n\nfunction executeRootExecutionPlan(\n exeContext: ExecutionContext,\n operation: OperationTypeNode,\n rootType: GraphQLObjectType,\n rootValue: unknown,\n originalGroupedFieldSet: GroupedFieldSet,\n newDeferUsages: ReadonlyArray,\n): PromiseOrValue>> {\n if (newDeferUsages.length === 0) {\n return executeRootGroupedFieldSet(\n exeContext,\n operation,\n rootType,\n rootValue,\n originalGroupedFieldSet,\n undefined,\n );\n }\n const newDeferMap = getNewDeferMap(newDeferUsages, undefined, undefined);\n\n const { groupedFieldSet, newGroupedFieldSets } = buildExecutionPlan(\n originalGroupedFieldSet,\n );\n\n const graphqlWrappedResult = executeRootGroupedFieldSet(\n exeContext,\n operation,\n rootType,\n rootValue,\n groupedFieldSet,\n newDeferMap,\n );\n\n if (newGroupedFieldSets.size > 0) {\n const newPendingExecutionGroups = collectExecutionGroups(\n exeContext,\n rootType,\n rootValue,\n undefined,\n undefined,\n newGroupedFieldSets,\n newDeferMap,\n );\n\n return withNewExecutionGroups(\n graphqlWrappedResult,\n newPendingExecutionGroups,\n );\n }\n return graphqlWrappedResult;\n}\n\nfunction withNewExecutionGroups(\n result: PromiseOrValue>>,\n newPendingExecutionGroups: ReadonlyArray,\n): PromiseOrValue>> {\n if (isPromise(result)) {\n return result.then((resolved) => {\n addIncrementalDataRecords(resolved, newPendingExecutionGroups);\n return resolved;\n });\n }\n\n addIncrementalDataRecords(result, newPendingExecutionGroups);\n return result;\n}\n\nfunction executeRootGroupedFieldSet(\n exeContext: ExecutionContext,\n operation: OperationTypeNode,\n rootType: GraphQLObjectType,\n rootValue: unknown,\n groupedFieldSet: GroupedFieldSet,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return executeFields(\n exeContext,\n rootType,\n rootValue,\n undefined,\n groupedFieldSet,\n undefined,\n deferMap,\n );\n case OperationTypeNode.MUTATION:\n return executeFieldsSerially(\n exeContext,\n rootType,\n rootValue,\n undefined,\n groupedFieldSet,\n undefined,\n deferMap,\n );\n case OperationTypeNode.SUBSCRIPTION:\n // TODO: deprecate `subscribe` and move all logic here\n // Temporary solution until we finish merging execute and subscribe together\n return executeFields(\n exeContext,\n rootType,\n rootValue,\n undefined,\n groupedFieldSet,\n undefined,\n deferMap,\n );\n }\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that must be executed serially.\n */\nfunction executeFieldsSerially(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const abortSignal = exeContext.validatedExecutionArgs.abortSignal;\n return promiseReduce(\n groupedFieldSet,\n (graphqlWrappedResult, [responseName, fieldDetailsList]) => {\n const fieldPath = addPath(path, responseName, parentType.name);\n\n if (abortSignal?.aborted) {\n handleFieldError(\n abortSignal.reason,\n exeContext,\n parentType,\n fieldDetailsList,\n fieldPath,\n incrementalContext,\n );\n graphqlWrappedResult.rawResult[responseName] = null;\n return graphqlWrappedResult;\n }\n\n const result = executeField(\n exeContext,\n parentType,\n sourceValue,\n fieldDetailsList,\n fieldPath,\n incrementalContext,\n deferMap,\n );\n if (result === undefined) {\n return graphqlWrappedResult;\n }\n if (isPromise(result)) {\n return result.then((resolved) => {\n graphqlWrappedResult.rawResult[responseName] = resolved.rawResult;\n addIncrementalDataRecords(\n graphqlWrappedResult,\n resolved.incrementalDataRecords,\n );\n return graphqlWrappedResult;\n });\n }\n graphqlWrappedResult.rawResult[responseName] = result.rawResult;\n addIncrementalDataRecords(\n graphqlWrappedResult,\n result.incrementalDataRecords,\n );\n return graphqlWrappedResult;\n },\n {\n rawResult: Object.create(null),\n incrementalDataRecords: undefined,\n },\n );\n}\n\nfunction addIncrementalDataRecords(\n graphqlWrappedResult: GraphQLWrappedResult,\n incrementalDataRecords: ReadonlyArray | undefined,\n): void {\n if (incrementalDataRecords === undefined) {\n return;\n }\n if (graphqlWrappedResult.incrementalDataRecords === undefined) {\n graphqlWrappedResult.incrementalDataRecords = [...incrementalDataRecords];\n } else {\n graphqlWrappedResult.incrementalDataRecords.push(...incrementalDataRecords);\n }\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that may be executed in parallel.\n */\nfunction executeFields(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const results = Object.create(null);\n const graphqlWrappedResult: GraphQLWrappedResult> = {\n rawResult: results,\n incrementalDataRecords: undefined,\n };\n let containsPromise = false;\n\n try {\n for (const [responseName, fieldDetailsList] of groupedFieldSet) {\n const fieldPath = addPath(path, responseName, parentType.name);\n const result = executeField(\n exeContext,\n parentType,\n sourceValue,\n fieldDetailsList,\n fieldPath,\n incrementalContext,\n deferMap,\n );\n\n if (result !== undefined) {\n if (isPromise(result)) {\n results[responseName] = result.then((resolved) => {\n addIncrementalDataRecords(\n graphqlWrappedResult,\n resolved.incrementalDataRecords,\n );\n return resolved.rawResult;\n });\n containsPromise = true;\n } else {\n results[responseName] = result.rawResult;\n addIncrementalDataRecords(\n graphqlWrappedResult,\n result.incrementalDataRecords,\n );\n }\n }\n }\n } catch (error) {\n if (containsPromise) {\n // Ensure that any promises returned by other fields are handled, as they may also reject.\n return promiseForObject(results, () => {\n /* noop */\n }).finally(() => {\n throw error;\n }) as never;\n }\n throw error;\n }\n\n // If there are no promises, we can just return the object and any incrementalDataRecords\n if (!containsPromise) {\n return graphqlWrappedResult;\n }\n\n // Otherwise, results is a map from field name to the result of resolving that\n // field, which is possibly a promise. Return a promise that will return this\n // same map, but with any promises replaced with the values they resolved to.\n return promiseForObject(results, (resolved) => ({\n rawResult: resolved,\n incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords,\n }));\n}\n\nfunction toNodes(fieldDetailsList: FieldDetailsList): ReadonlyArray {\n return fieldDetailsList.map((fieldDetails) => fieldDetails.node);\n}\n\n/**\n * Implements the \"Executing fields\" section of the spec\n * In particular, this function figures out the value that the field returns by\n * calling its resolve function, then calls completeValue to complete promises,\n * coercing scalars, or execute the sub-selection-set for objects.\n */\nfunction executeField(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n source: unknown,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue> | undefined {\n const { validatedExecutionArgs, abortSignalListener } = exeContext;\n const { schema, contextValue, variableValues, hideSuggestions, abortSignal } =\n validatedExecutionArgs;\n const fieldName = fieldDetailsList[0].node.name.value;\n const fieldDef = schema.getField(parentType, fieldName);\n if (!fieldDef) {\n return;\n }\n\n const returnType = fieldDef.type;\n const resolveFn = fieldDef.resolve ?? validatedExecutionArgs.fieldResolver;\n\n const info = buildResolveInfo(\n validatedExecutionArgs,\n fieldDef,\n toNodes(fieldDetailsList),\n parentType,\n path,\n );\n\n // Get the resolve function, regardless of if its result is normal or abrupt (error).\n try {\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n // TODO: find a way to memoize, in case this field is within a List type.\n const args = getArgumentValues(\n fieldDef,\n fieldDetailsList[0].node,\n variableValues,\n fieldDetailsList[0].fragmentVariableValues,\n hideSuggestions,\n );\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const result = resolveFn(source, args, contextValue, info, abortSignal);\n\n if (isPromise(result)) {\n return completePromisedValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n abortSignalListener\n ? cancellablePromise(result, abortSignalListener)\n : result,\n incrementalContext,\n deferMap,\n );\n }\n\n const completed = completeValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n\n if (isPromise(completed)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n return completed.then(undefined, (rawError: unknown) => {\n handleFieldError(\n rawError,\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n });\n }\n return completed;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n }\n}\n\n/**\n * TODO: consider no longer exporting this function\n * @internal\n */\nexport function buildResolveInfo(\n validatedExecutionArgs: ValidatedExecutionArgs,\n fieldDef: GraphQLField,\n fieldNodes: ReadonlyArray,\n parentType: GraphQLObjectType,\n path: Path,\n): GraphQLResolveInfo {\n const { schema, fragmentDefinitions, rootValue, operation, variableValues } =\n validatedExecutionArgs;\n // The resolve function's optional fourth argument is a collection of\n // information about the current execution state.\n return {\n fieldName: fieldDef.name,\n fieldNodes,\n returnType: fieldDef.type,\n parentType,\n path,\n schema,\n fragments: fragmentDefinitions,\n rootValue,\n operation,\n variableValues,\n };\n}\n\nfunction handleFieldError(\n rawError: unknown,\n exeContext: ExecutionContext,\n returnType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n incrementalContext: IncrementalContext | undefined,\n): void {\n const error = locatedError(\n rawError,\n toNodes(fieldDetailsList),\n pathToArray(path),\n );\n\n // If the field type is non-nullable, then it is resolved without any\n // protection from errors, however it still properly locates the error.\n if (exeContext.errorPropagation && isNonNullType(returnType)) {\n throw error;\n }\n\n // Otherwise, error protection is applied, logging the error and resolving\n // a null value for this field if one is encountered.\n const context = incrementalContext ?? exeContext;\n let errors = context.errors;\n if (errors === undefined) {\n errors = [];\n context.errors = errors;\n }\n errors.push(error);\n}\n\n/**\n * Implements the instructions for completeValue as defined in the\n * \"Value Completion\" section of the spec.\n *\n * If the field type is Non-Null, then this recursively completes the value\n * for the inner type. It throws a field error if that completion returns null,\n * as per the \"Nullability\" section of the spec.\n *\n * If the field type is a List, then this recursively completes the value\n * for the inner type on each item in the list.\n *\n * If the field type is a Scalar or Enum, ensures the completed value is a legal\n * value of the type by calling the `coerceOutputValue` method of GraphQL type\n * definition.\n *\n * If the field is an abstract type, determine the runtime type of the value\n * and then complete based on that type\n *\n * Otherwise, the field type expects a sub-selection set, and will complete the\n * value by executing all sub-selections.\n */\nfunction completeValue(\n exeContext: ExecutionContext,\n returnType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue> {\n // If result is an Error, throw a located error.\n if (result instanceof Error) {\n throw result;\n }\n\n // If field type is NonNull, complete for inner type, and throw field error\n // if result is null.\n if (isNonNullType(returnType)) {\n const completed = completeValue(\n exeContext,\n returnType.ofType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n if ((completed as GraphQLWrappedResult).rawResult === null) {\n throw new Error(\n `Cannot return null for non-nullable field ${info.parentType}.${info.fieldName}.`,\n );\n }\n return completed;\n }\n\n // If result value is null or undefined then return null.\n if (result == null) {\n return { rawResult: null, incrementalDataRecords: undefined };\n }\n\n // If field type is List, complete each item in the list with the inner type\n if (isListType(returnType)) {\n return completeListValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n }\n\n // If field type is a leaf type, Scalar or Enum, coerce to a valid value,\n // returning null if coercion is not possible.\n if (isLeafType(returnType)) {\n return {\n rawResult: completeLeafValue(returnType, result),\n incrementalDataRecords: undefined,\n };\n }\n\n // If field type is an abstract type, Interface or Union, determine the\n // runtime Object type and complete for that type.\n if (isAbstractType(returnType)) {\n return completeAbstractValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n }\n\n // If field type is Object, execute and complete all sub-selections.\n if (isObjectType(returnType)) {\n return completeObjectValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n }\n /* c8 ignore next 6 */\n // Not reachable, all possible output types have been considered.\n invariant(\n false,\n 'Cannot complete value of unexpected output type: ' + inspect(returnType),\n );\n}\n\nasync function completePromisedValue(\n exeContext: ExecutionContext,\n returnType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: Promise,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): Promise> {\n try {\n const resolved = await result;\n let completed = completeValue(\n exeContext,\n returnType,\n fieldDetailsList,\n info,\n path,\n resolved,\n incrementalContext,\n deferMap,\n );\n\n if (isPromise(completed)) {\n completed = await completed;\n }\n\n return completed;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n }\n}\n\n/**\n * Returns an object containing info for streaming if a field should be\n * streamed based on the experimental flag, stream directive present and\n * not disabled by the \"if\" argument.\n */\nfunction getStreamUsage(\n validatedExecutionArgs: ValidatedExecutionArgs,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n): StreamUsage | undefined {\n // do not stream inner lists of multi-dimensional lists\n if (typeof path.key === 'number') {\n return;\n }\n\n // TODO: add test for this case (a streamed list nested under a list).\n /* c8 ignore next 7 */\n if (\n (fieldDetailsList as unknown as { _streamUsage: StreamUsage })\n ._streamUsage !== undefined\n ) {\n return (fieldDetailsList as unknown as { _streamUsage: StreamUsage })\n ._streamUsage;\n }\n\n const { operation, variableValues } = validatedExecutionArgs;\n // validation only allows equivalent streams on multiple fields, so it is\n // safe to only check the first fieldNode for the stream directive\n const stream = getDirectiveValues(\n GraphQLStreamDirective,\n fieldDetailsList[0].node,\n variableValues,\n fieldDetailsList[0].fragmentVariableValues,\n );\n\n if (!stream) {\n return;\n }\n\n if (stream.if === false) {\n return;\n }\n\n invariant(\n typeof stream.initialCount === 'number',\n 'initialCount must be a number',\n );\n\n invariant(\n stream.initialCount >= 0,\n 'initialCount must be a positive integer',\n );\n\n invariant(\n operation.operation !== OperationTypeNode.SUBSCRIPTION,\n '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.',\n );\n\n const streamedFieldDetailsList: FieldDetailsList = fieldDetailsList.map(\n (fieldDetails) => ({\n node: fieldDetails.node,\n deferUsage: undefined,\n fragmentVariableValues: fieldDetails.fragmentVariableValues,\n }),\n );\n\n const streamUsage = {\n initialCount: stream.initialCount,\n label: typeof stream.label === 'string' ? stream.label : undefined,\n fieldDetailsList: streamedFieldDetailsList,\n };\n\n (fieldDetailsList as unknown as { _streamUsage: StreamUsage })._streamUsage =\n streamUsage;\n\n return streamUsage;\n}\n\n/**\n * Complete a async iterator value by completing the result and calling\n * recursively until all the results are completed.\n */\nasync function completeAsyncIteratorValue(\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n asyncIterator: AsyncIterator,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): Promise>> {\n let containsPromise = false;\n const completedResults: Array = [];\n const graphqlWrappedResult: GraphQLWrappedResult> = {\n rawResult: completedResults,\n incrementalDataRecords: undefined,\n };\n let index = 0;\n const streamUsage = getStreamUsage(\n exeContext.validatedExecutionArgs,\n fieldDetailsList,\n path,\n );\n const earlyReturn =\n asyncIterator.return === undefined\n ? undefined\n : asyncIterator.return.bind(asyncIterator);\n try {\n while (true) {\n if (streamUsage && index >= streamUsage.initialCount) {\n const streamItemQueue = buildAsyncStreamItemQueue(\n index,\n path,\n asyncIterator,\n exeContext,\n streamUsage.fieldDetailsList,\n info,\n itemType,\n );\n\n let streamRecord: StreamRecord | CancellableStreamRecord;\n if (earlyReturn === undefined) {\n streamRecord = {\n label: streamUsage.label,\n path,\n streamItemQueue,\n };\n } else {\n streamRecord = {\n label: streamUsage.label,\n path,\n earlyReturn,\n streamItemQueue,\n };\n if (exeContext.cancellableStreams === undefined) {\n exeContext.cancellableStreams = new Set();\n }\n exeContext.cancellableStreams.add(streamRecord);\n }\n\n addIncrementalDataRecords(graphqlWrappedResult, [streamRecord]);\n break;\n }\n\n const itemPath = addPath(path, index, undefined);\n let iteration;\n try {\n // eslint-disable-next-line no-await-in-loop\n iteration = await asyncIterator.next();\n } catch (rawError) {\n throw locatedError(\n rawError,\n toNodes(fieldDetailsList),\n pathToArray(path),\n );\n }\n\n // TODO: add test case for stream returning done before initialCount\n /* c8 ignore next 3 */\n if (iteration.done) {\n break;\n }\n\n const item = iteration.value;\n // TODO: add tests for stream backed by asyncIterator that returns a promise\n /* c8 ignore start */\n if (isPromise(item)) {\n completedResults.push(\n completePromisedListItemValue(\n item,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n ),\n );\n containsPromise = true;\n } else if (\n /* c8 ignore stop */\n completeListItemValue(\n item,\n completedResults,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n )\n // TODO: add tests for stream backed by asyncIterator that completes to a promise\n /* c8 ignore start */\n ) {\n containsPromise = true;\n }\n /* c8 ignore stop */\n index++;\n }\n } catch (error) {\n if (earlyReturn !== undefined) {\n earlyReturn().catch(() => {\n /* c8 ignore next 1 */\n // ignore error\n });\n }\n throw error;\n }\n\n return containsPromise\n ? /* c8 ignore start */ Promise.all(completedResults).then((resolved) => ({\n rawResult: resolved,\n incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords,\n }))\n : /* c8 ignore stop */ graphqlWrappedResult;\n}\n\n/**\n * Complete a list value by completing each item in the list with the\n * inner type\n */\nfunction completeListValue(\n exeContext: ExecutionContext,\n returnType: GraphQLList,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const itemType = returnType.ofType;\n\n if (isAsyncIterable(result)) {\n const abortSignalListener = exeContext.abortSignalListener;\n const maybeCancellableIterable = abortSignalListener\n ? cancellableIterable(result, abortSignalListener)\n : result;\n const asyncIterator = maybeCancellableIterable[Symbol.asyncIterator]();\n\n return completeAsyncIteratorValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n path,\n asyncIterator,\n incrementalContext,\n deferMap,\n );\n }\n\n if (!isIterableObject(result)) {\n throw new GraphQLError(\n `Expected Iterable, but did not find one for field \"${info.parentType}.${info.fieldName}\".`,\n );\n }\n\n return completeIterableValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction completeIterableValue(\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n items: Iterable,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n // This is specified as a simple map, however we're optimizing the path\n // where the list contains no Promises by avoiding creating another Promise.\n let containsPromise = false;\n const completedResults: Array = [];\n const graphqlWrappedResult: GraphQLWrappedResult> = {\n rawResult: completedResults,\n incrementalDataRecords: undefined,\n };\n let index = 0;\n const streamUsage = getStreamUsage(\n exeContext.validatedExecutionArgs,\n fieldDetailsList,\n path,\n );\n const iterator = items[Symbol.iterator]();\n let iteration = iterator.next();\n while (!iteration.done) {\n const item = iteration.value;\n\n if (streamUsage && index >= streamUsage.initialCount) {\n const syncStreamRecord: StreamRecord = {\n label: streamUsage.label,\n path,\n streamItemQueue: buildSyncStreamItemQueue(\n item,\n index,\n path,\n iterator,\n exeContext,\n streamUsage.fieldDetailsList,\n info,\n itemType,\n ),\n };\n\n addIncrementalDataRecords(graphqlWrappedResult, [syncStreamRecord]);\n break;\n }\n\n // No need to modify the info object containing the path,\n // since from here on it is not ever accessed by resolver functions.\n const itemPath = addPath(path, index, undefined);\n\n if (isPromise(item)) {\n completedResults.push(\n completePromisedListItemValue(\n item,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n ),\n );\n containsPromise = true;\n } else if (\n completeListItemValue(\n item,\n completedResults,\n graphqlWrappedResult,\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n incrementalContext,\n deferMap,\n )\n ) {\n containsPromise = true;\n }\n index++;\n\n iteration = iterator.next();\n }\n\n return containsPromise\n ? Promise.all(completedResults).then((resolved) => ({\n rawResult: resolved,\n incrementalDataRecords: graphqlWrappedResult.incrementalDataRecords,\n }))\n : graphqlWrappedResult;\n}\n\n/**\n * Complete a list item value by adding it to the completed results.\n *\n * Returns true if the value is a Promise.\n */\nfunction completeListItemValue(\n item: unknown,\n completedResults: Array,\n parent: GraphQLWrappedResult>,\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemPath: Path,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): boolean {\n try {\n const completedItem = completeValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n item,\n incrementalContext,\n deferMap,\n );\n\n if (isPromise(completedItem)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n completedResults.push(\n completedItem.then(\n (resolved) => {\n addIncrementalDataRecords(parent, resolved.incrementalDataRecords);\n return resolved.rawResult;\n },\n (rawError: unknown) => {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n return null;\n },\n ),\n );\n return true;\n }\n\n completedResults.push(completedItem.rawResult);\n addIncrementalDataRecords(parent, completedItem.incrementalDataRecords);\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n completedResults.push(null);\n }\n return false;\n}\n\nasync function completePromisedListItemValue(\n item: Promise,\n parent: GraphQLWrappedResult>,\n exeContext: ExecutionContext,\n itemType: GraphQLOutputType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemPath: Path,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): Promise {\n try {\n const abortSignalListener = exeContext.abortSignalListener;\n const maybeCancellableItem = abortSignalListener\n ? cancellablePromise(item, abortSignalListener)\n : item;\n const resolved = await maybeCancellableItem;\n let completed = completeValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n resolved,\n incrementalContext,\n deferMap,\n );\n if (isPromise(completed)) {\n completed = await completed;\n }\n addIncrementalDataRecords(parent, completed.incrementalDataRecords);\n return completed.rawResult;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n return null;\n }\n}\n\n/**\n * Complete a Scalar or Enum by serializing to a valid value, returning\n * null if serialization is not possible.\n */\nfunction completeLeafValue(\n returnType: GraphQLLeafType,\n result: unknown,\n): unknown {\n const coerced = returnType.coerceOutputValue(result);\n if (coerced == null) {\n throw new Error(\n `Expected \\`${inspect(returnType)}.coerceOutputValue(${inspect(result)})\\` to ` +\n `return non-nullable value, returned: ${inspect(coerced)}`,\n );\n }\n return coerced;\n}\n\n/**\n * Complete a value of an abstract type by determining the runtime object type\n * of that value, then complete the value for that type.\n */\nfunction completeAbstractValue(\n exeContext: ExecutionContext,\n returnType: GraphQLAbstractType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const validatedExecutionArgs = exeContext.validatedExecutionArgs;\n const { schema, contextValue } = validatedExecutionArgs;\n const resolveTypeFn =\n returnType.resolveType ?? validatedExecutionArgs.typeResolver;\n const runtimeType = resolveTypeFn(result, contextValue, info, returnType);\n\n if (isPromise(runtimeType)) {\n return runtimeType.then((resolvedRuntimeType) =>\n completeObjectValue(\n exeContext,\n ensureValidRuntimeType(\n resolvedRuntimeType,\n schema,\n returnType,\n fieldDetailsList,\n info,\n result,\n ),\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n ),\n );\n }\n\n return completeObjectValue(\n exeContext,\n ensureValidRuntimeType(\n runtimeType,\n schema,\n returnType,\n fieldDetailsList,\n info,\n result,\n ),\n fieldDetailsList,\n info,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction ensureValidRuntimeType(\n runtimeTypeName: unknown,\n schema: GraphQLSchema,\n returnType: GraphQLAbstractType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n result: unknown,\n): GraphQLObjectType {\n if (runtimeTypeName == null) {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" must resolve to an Object type at runtime for field \"${info.parentType}.${info.fieldName}\". Either the \"${returnType}\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n if (typeof runtimeTypeName !== 'string') {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" must resolve to an Object type at runtime for field \"${info.parentType}.${info.fieldName}\" with ` +\n `value ${inspect(result)}, received \"${inspect(\n runtimeTypeName,\n )}\", which is not a valid Object type name.`,\n );\n }\n\n const runtimeType = schema.getType(runtimeTypeName);\n if (runtimeType == null) {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" was resolved to a type \"${runtimeTypeName}\" that does not exist inside the schema.`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n if (!isObjectType(runtimeType)) {\n throw new GraphQLError(\n `Abstract type \"${returnType}\" was resolved to a non-object type \"${runtimeTypeName}\".`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n if (!schema.isSubType(returnType, runtimeType)) {\n throw new GraphQLError(\n `Runtime Object type \"${runtimeType}\" is not a possible type for \"${returnType}\".`,\n { nodes: toNodes(fieldDetailsList) },\n );\n }\n\n return runtimeType;\n}\n\n/**\n * Complete an Object value by executing all sub-selections.\n */\nfunction completeObjectValue(\n exeContext: ExecutionContext,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n if ((incrementalContext ?? exeContext).completed) {\n throw new Error('Completed, aborting.');\n }\n\n // If there is an isTypeOf predicate function, call it with the\n // current result. If isTypeOf returns false, then raise an error rather\n // than continuing execution.\n if (returnType.isTypeOf) {\n const isTypeOf = returnType.isTypeOf(\n result,\n exeContext.validatedExecutionArgs.contextValue,\n info,\n );\n\n if (isPromise(isTypeOf)) {\n return isTypeOf.then((resolvedIsTypeOf) => {\n if (!resolvedIsTypeOf) {\n throw invalidReturnTypeError(returnType, result, fieldDetailsList);\n }\n return collectAndExecuteSubfields(\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n });\n }\n\n if (!isTypeOf) {\n throw invalidReturnTypeError(returnType, result, fieldDetailsList);\n }\n }\n\n return collectAndExecuteSubfields(\n exeContext,\n returnType,\n fieldDetailsList,\n path,\n result,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction invalidReturnTypeError(\n returnType: GraphQLObjectType,\n result: unknown,\n fieldDetailsList: FieldDetailsList,\n): GraphQLError {\n return new GraphQLError(\n `Expected value of type \"${returnType}\" but got: ${inspect(result)}.`,\n { nodes: toNodes(fieldDetailsList) },\n );\n}\n\n/**\n * Instantiates new DeferredFragmentRecords for the given path within an\n * incremental data record, returning an updated map of DeferUsage\n * objects to DeferredFragmentRecords.\n *\n * Note: As defer directives may be used with operations returning lists,\n * a DeferUsage object may correspond to many DeferredFragmentRecords.\n */\nfunction getNewDeferMap(\n newDeferUsages: ReadonlyArray,\n deferMap?: ReadonlyMap,\n path?: Path,\n): ReadonlyMap {\n const newDeferMap = new Map(deferMap);\n\n // For each new deferUsage object:\n for (const newDeferUsage of newDeferUsages) {\n const parentDeferUsage = newDeferUsage.parentDeferUsage;\n\n const parent =\n parentDeferUsage === undefined\n ? undefined\n : deferredFragmentRecordFromDeferUsage(parentDeferUsage, newDeferMap);\n\n // Instantiate the new record.\n const deferredFragmentRecord = new DeferredFragmentRecord(\n path,\n newDeferUsage.label,\n parent,\n );\n\n // Update the map.\n newDeferMap.set(newDeferUsage, deferredFragmentRecord);\n }\n\n return newDeferMap;\n}\n\nfunction deferredFragmentRecordFromDeferUsage(\n deferUsage: DeferUsage,\n deferMap: ReadonlyMap,\n): DeferredFragmentRecord {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return deferMap.get(deferUsage)!;\n}\n\nfunction collectAndExecuteSubfields(\n exeContext: ExecutionContext,\n returnType: GraphQLObjectType,\n fieldDetailsList: FieldDetailsList,\n path: Path,\n result: unknown,\n incrementalContext: IncrementalContext | undefined,\n deferMap: ReadonlyMap | undefined,\n): PromiseOrValue>> {\n const validatedExecutionArgs = exeContext.validatedExecutionArgs;\n\n // Collect sub-fields to execute to complete this value.\n const collectedSubfields = collectSubfields(\n validatedExecutionArgs,\n returnType,\n fieldDetailsList,\n );\n const { groupedFieldSet, newDeferUsages } = collectedSubfields;\n\n if (newDeferUsages.length > 0) {\n invariant(\n validatedExecutionArgs.operation.operation !==\n OperationTypeNode.SUBSCRIPTION,\n '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.',\n );\n }\n\n return executeSubExecutionPlan(\n exeContext,\n returnType,\n result,\n groupedFieldSet,\n newDeferUsages,\n path,\n incrementalContext,\n deferMap,\n );\n}\n\nfunction executeSubExecutionPlan(\n exeContext: ExecutionContext,\n returnType: GraphQLObjectType,\n sourceValue: unknown,\n originalGroupedFieldSet: GroupedFieldSet,\n newDeferUsages: ReadonlyArray,\n path?: Path,\n incrementalContext?: IncrementalContext,\n deferMap?: ReadonlyMap,\n): PromiseOrValue>> {\n if (deferMap === undefined && newDeferUsages.length === 0) {\n return executeFields(\n exeContext,\n returnType,\n sourceValue,\n path,\n originalGroupedFieldSet,\n incrementalContext,\n deferMap,\n );\n }\n\n const newDeferMap = getNewDeferMap(newDeferUsages, deferMap, path);\n\n const { groupedFieldSet, newGroupedFieldSets } = buildSubExecutionPlan(\n originalGroupedFieldSet,\n incrementalContext?.deferUsageSet,\n );\n\n const graphqlWrappedResult = executeFields(\n exeContext,\n returnType,\n sourceValue,\n path,\n groupedFieldSet,\n incrementalContext,\n newDeferMap,\n );\n\n if (newGroupedFieldSets.size > 0) {\n const newPendingExecutionGroups = collectExecutionGroups(\n exeContext,\n returnType,\n sourceValue,\n path,\n incrementalContext?.deferUsageSet,\n newGroupedFieldSets,\n newDeferMap,\n );\n\n return withNewExecutionGroups(\n graphqlWrappedResult,\n newPendingExecutionGroups,\n );\n }\n return graphqlWrappedResult;\n}\n\nfunction buildSubExecutionPlan(\n originalGroupedFieldSet: GroupedFieldSet,\n deferUsageSet: DeferUsageSet | undefined,\n): ExecutionPlan {\n let executionPlan = (\n originalGroupedFieldSet as unknown as { _executionPlan: ExecutionPlan }\n )._executionPlan;\n if (executionPlan !== undefined) {\n return executionPlan;\n }\n executionPlan = buildExecutionPlan(originalGroupedFieldSet, deferUsageSet);\n (\n originalGroupedFieldSet as unknown as { _executionPlan: ExecutionPlan }\n )._executionPlan = executionPlan;\n return executionPlan;\n}\n\n/**\n * If a resolveType function is not given, then a default resolve behavior is\n * used which attempts two strategies:\n *\n * First, See if the provided value has a `__typename` field defined, if so, use\n * that value as name of the resolved type.\n *\n * Otherwise, test each possible type for the abstract type by calling\n * isTypeOf for the object being coerced, returning the first type that matches.\n */\nexport const defaultTypeResolver: GraphQLTypeResolver =\n function (value, contextValue, info, abstractType) {\n // First, look for `__typename`.\n if (isObjectLike(value) && typeof value.__typename === 'string') {\n return value.__typename;\n }\n\n // Otherwise, test each possible type.\n const possibleTypes = info.schema.getPossibleTypes(abstractType);\n const promisedIsTypeOfResults = [];\n\n for (let i = 0; i < possibleTypes.length; i++) {\n const type = possibleTypes[i];\n\n if (type.isTypeOf) {\n const isTypeOfResult = type.isTypeOf(value, contextValue, info);\n\n if (isPromise(isTypeOfResult)) {\n promisedIsTypeOfResults[i] = isTypeOfResult;\n } else if (isTypeOfResult) {\n if (promisedIsTypeOfResults.length > 0) {\n Promise.all(promisedIsTypeOfResults).then(undefined, () => {\n /* ignore errors */\n });\n }\n\n return type.name;\n }\n }\n }\n\n if (promisedIsTypeOfResults.length) {\n return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => {\n for (let i = 0; i < isTypeOfResults.length; i++) {\n if (isTypeOfResults[i]) {\n return possibleTypes[i].name;\n }\n }\n });\n }\n };\n\n/**\n * If a resolve function is not given, then a default resolve behavior is used\n * which takes the property of the source object of the same name as the field\n * and returns it as the result, or if it's a function, returns the result\n * of calling that function while passing along args and context value.\n */\nexport const defaultFieldResolver: GraphQLFieldResolver =\n function (source: any, args, contextValue, info, abortSignal) {\n // ensure source is a value for which property access is acceptable.\n if (isObjectLike(source) || typeof source === 'function') {\n const property = source[info.fieldName];\n if (typeof property === 'function') {\n return source[info.fieldName](args, contextValue, info, abortSignal);\n }\n return property;\n }\n };\n\n/**\n * Implements the \"Subscribe\" algorithm described in the GraphQL specification.\n *\n * Returns a Promise which resolves to either an AsyncIterator (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with descriptive\n * errors and no data will be returned.\n *\n * If the source stream could not be created due to faulty subscription resolver\n * logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to an AsyncIterator, which\n * yields a stream of ExecutionResults representing the response stream.\n *\n * This function does not support incremental delivery (`@defer` and `@stream`).\n * If an operation which would defer or stream data is executed with this\n * function, a field error will be raised at the location of the `@defer` or\n * `@stream` directive.\n *\n * Accepts an object with named arguments.\n */\nexport function subscribe(\n args: ExecutionArgs,\n): PromiseOrValue<\n AsyncGenerator | ExecutionResult\n> {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const validatedExecutionArgs = validateExecutionArgs(args);\n\n // Return early errors if execution context failed.\n if (!('schema' in validatedExecutionArgs)) {\n return { errors: validatedExecutionArgs };\n }\n\n const resultOrStream = createSourceEventStreamImpl(validatedExecutionArgs);\n\n if (isPromise(resultOrStream)) {\n return resultOrStream.then((resolvedResultOrStream) =>\n mapSourceToResponse(validatedExecutionArgs, resolvedResultOrStream),\n );\n }\n\n return mapSourceToResponse(validatedExecutionArgs, resultOrStream);\n}\n\nfunction mapSourceToResponse(\n validatedExecutionArgs: ValidatedExecutionArgs,\n resultOrStream: ExecutionResult | AsyncIterable,\n): AsyncGenerator | ExecutionResult {\n if (!isAsyncIterable(resultOrStream)) {\n return resultOrStream;\n }\n\n const abortSignal = validatedExecutionArgs.abortSignal;\n const abortSignalListener = abortSignal\n ? new AbortSignalListener(abortSignal)\n : undefined;\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification..\n return mapAsyncIterable(\n abortSignalListener\n ? cancellableIterable(resultOrStream, abortSignalListener)\n : resultOrStream,\n (payload: unknown) => {\n const perEventExecutionArgs: ValidatedExecutionArgs = {\n ...validatedExecutionArgs,\n rootValue: payload,\n };\n return validatedExecutionArgs.perEventExecutor(perEventExecutionArgs);\n },\n () => abortSignalListener?.disconnect(),\n );\n}\n\nexport function executeSubscriptionEvent(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue {\n return executeQueryOrMutationOrSubscriptionEvent(validatedExecutionArgs);\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nexport function createSourceEventStream(\n args: ExecutionArgs,\n): PromiseOrValue | ExecutionResult> {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const validatedExecutionArgs = validateExecutionArgs(args);\n\n // Return early errors if execution context failed.\n if (!('schema' in validatedExecutionArgs)) {\n return { errors: validatedExecutionArgs };\n }\n\n return createSourceEventStreamImpl(validatedExecutionArgs);\n}\n\nfunction createSourceEventStreamImpl(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue | ExecutionResult> {\n try {\n const eventStream = executeSubscription(validatedExecutionArgs);\n if (isPromise(eventStream)) {\n return eventStream.then(undefined, (error: unknown) => ({\n errors: [error as GraphQLError],\n }));\n }\n\n return eventStream;\n } catch (error) {\n return { errors: [error] };\n }\n}\n\nfunction executeSubscription(\n validatedExecutionArgs: ValidatedExecutionArgs,\n): PromiseOrValue> {\n const {\n schema,\n fragments,\n rootValue,\n contextValue,\n operation,\n variableValues,\n hideSuggestions,\n abortSignal,\n } = validatedExecutionArgs;\n\n const rootType = schema.getSubscriptionType();\n if (rootType == null) {\n throw new GraphQLError(\n 'Schema is not configured to execute subscription operation.',\n { nodes: operation },\n );\n }\n\n const { groupedFieldSet } = collectFields(\n schema,\n fragments,\n variableValues,\n rootType,\n operation.selectionSet,\n hideSuggestions,\n );\n\n const firstRootField = groupedFieldSet.entries().next().value as [\n string,\n FieldDetailsList,\n ];\n const [responseName, fieldDetailsList] = firstRootField;\n const fieldName = fieldDetailsList[0].node.name.value;\n const fieldDef = schema.getField(rootType, fieldName);\n\n const fieldNodes = fieldDetailsList.map((fieldDetails) => fieldDetails.node);\n if (!fieldDef) {\n throw new GraphQLError(\n `The subscription field \"${fieldName}\" is not defined.`,\n { nodes: fieldNodes },\n );\n }\n\n const path = addPath(undefined, responseName, rootType.name);\n const info = buildResolveInfo(\n validatedExecutionArgs,\n fieldDef,\n fieldNodes,\n rootType,\n path,\n );\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n const args = getArgumentValues(\n fieldDef,\n fieldNodes[0],\n variableValues,\n fieldDetailsList[0].fragmentVariableValues,\n hideSuggestions,\n );\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n const resolveFn =\n fieldDef.subscribe ?? validatedExecutionArgs.subscribeFieldResolver;\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const result = resolveFn(rootValue, args, contextValue, info, abortSignal);\n\n if (isPromise(result)) {\n const abortSignalListener = abortSignal\n ? new AbortSignalListener(abortSignal)\n : undefined;\n\n const promise = abortSignalListener\n ? cancellablePromise(result, abortSignalListener)\n : result;\n return promise.then(assertEventStream).then(\n (resolved) => {\n abortSignalListener?.disconnect();\n return resolved;\n },\n (error: unknown) => {\n abortSignalListener?.disconnect();\n throw locatedError(error, fieldNodes, pathToArray(path));\n },\n );\n }\n\n return assertEventStream(result);\n } catch (error) {\n throw locatedError(error, fieldNodes, pathToArray(path));\n }\n}\n\nfunction assertEventStream(result: unknown): AsyncIterable {\n if (result instanceof Error) {\n throw result;\n }\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(result)) {\n throw new GraphQLError(\n 'Subscription field must return Async Iterable. ' +\n `Received: ${inspect(result)}.`,\n );\n }\n\n return result;\n}\n\nfunction collectExecutionGroups(\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n parentDeferUsages: DeferUsageSet | undefined,\n newGroupedFieldSets: Map,\n deferMap: ReadonlyMap,\n): ReadonlyArray {\n const newPendingExecutionGroups: Array = [];\n\n for (const [deferUsageSet, groupedFieldSet] of newGroupedFieldSets) {\n const deferredFragmentRecords = getDeferredFragmentRecords(\n deferUsageSet,\n deferMap,\n );\n\n const pendingExecutionGroup: PendingExecutionGroup = {\n deferredFragmentRecords,\n result:\n undefined as unknown as BoxedPromiseOrValue,\n };\n\n const executor = () =>\n executeExecutionGroup(\n pendingExecutionGroup,\n exeContext,\n parentType,\n sourceValue,\n path,\n groupedFieldSet,\n {\n errors: undefined,\n completed: false,\n deferUsageSet,\n },\n deferMap,\n );\n\n if (exeContext.validatedExecutionArgs.enableEarlyExecution) {\n pendingExecutionGroup.result = new BoxedPromiseOrValue(\n shouldDefer(parentDeferUsages, deferUsageSet)\n ? Promise.resolve().then(executor)\n : executor(),\n );\n } else {\n pendingExecutionGroup.result = () => new BoxedPromiseOrValue(executor());\n }\n\n newPendingExecutionGroups.push(pendingExecutionGroup);\n }\n\n return newPendingExecutionGroups;\n}\n\nfunction shouldDefer(\n parentDeferUsages: undefined | DeferUsageSet,\n deferUsages: DeferUsageSet,\n): boolean {\n // If we have a new child defer usage, defer.\n // Otherwise, this defer usage was already deferred when it was initially\n // encountered, and is now in the midst of executing early, so the new\n // deferred grouped fields set can be executed immediately.\n return (\n parentDeferUsages === undefined ||\n !Array.from(deferUsages).every((deferUsage) =>\n parentDeferUsages.has(deferUsage),\n )\n );\n}\n\nfunction executeExecutionGroup(\n pendingExecutionGroup: PendingExecutionGroup,\n exeContext: ExecutionContext,\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalContext: IncrementalContext,\n deferMap: ReadonlyMap,\n): PromiseOrValue {\n let result;\n try {\n result = executeFields(\n exeContext,\n parentType,\n sourceValue,\n path,\n groupedFieldSet,\n incrementalContext,\n deferMap,\n );\n } catch (error) {\n incrementalContext.completed = true;\n return {\n pendingExecutionGroup,\n path: pathToArray(path),\n errors: withError(incrementalContext.errors, error),\n };\n }\n\n if (isPromise(result)) {\n return result.then(\n (resolved) => {\n incrementalContext.completed = true;\n return buildCompletedExecutionGroup(\n incrementalContext.errors,\n pendingExecutionGroup,\n path,\n resolved,\n );\n },\n (error: unknown) => {\n incrementalContext.completed = true;\n return {\n pendingExecutionGroup,\n path: pathToArray(path),\n errors: withError(incrementalContext.errors, error as GraphQLError),\n };\n },\n );\n }\n\n incrementalContext.completed = true;\n return buildCompletedExecutionGroup(\n incrementalContext.errors,\n pendingExecutionGroup,\n path,\n result,\n );\n}\n\nfunction buildCompletedExecutionGroup(\n errors: ReadonlyArray | undefined,\n pendingExecutionGroup: PendingExecutionGroup,\n path: Path | undefined,\n result: GraphQLWrappedResult>,\n): CompletedExecutionGroup {\n const { rawResult: data, incrementalDataRecords } = result;\n return {\n pendingExecutionGroup,\n path: pathToArray(path),\n result: errors === undefined ? { data } : { data, errors },\n incrementalDataRecords,\n };\n}\n\nfunction getDeferredFragmentRecords(\n deferUsages: DeferUsageSet,\n deferMap: ReadonlyMap,\n): ReadonlyArray {\n return Array.from(deferUsages).map((deferUsage) =>\n deferredFragmentRecordFromDeferUsage(deferUsage, deferMap),\n );\n}\n\nfunction buildSyncStreamItemQueue(\n initialItem: PromiseOrValue,\n initialIndex: number,\n streamPath: Path,\n iterator: Iterator,\n exeContext: ExecutionContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): Array {\n const streamItemQueue: Array = [];\n\n const enableEarlyExecution =\n exeContext.validatedExecutionArgs.enableEarlyExecution;\n\n const firstExecutor = () => {\n const initialPath = addPath(streamPath, initialIndex, undefined);\n const firstStreamItem = new BoxedPromiseOrValue(\n completeStreamItem(\n initialPath,\n initialItem,\n exeContext,\n { errors: undefined, completed: false },\n fieldDetailsList,\n info,\n itemType,\n ),\n );\n\n let iteration = iterator.next();\n let currentIndex = initialIndex + 1;\n let currentStreamItem:\n | BoxedPromiseOrValue\n | (() => BoxedPromiseOrValue) = firstStreamItem;\n while (!iteration.done) {\n // TODO: add test case for early sync termination\n /* c8 ignore next 6 */\n if (currentStreamItem instanceof BoxedPromiseOrValue) {\n const result = currentStreamItem.value;\n if (!isPromise(result) && result.errors !== undefined) {\n break;\n }\n }\n\n const itemPath = addPath(streamPath, currentIndex, undefined);\n\n const value = iteration.value;\n\n const currentExecutor = () =>\n completeStreamItem(\n itemPath,\n value,\n exeContext,\n { errors: undefined, completed: false },\n fieldDetailsList,\n info,\n itemType,\n );\n\n currentStreamItem = enableEarlyExecution\n ? new BoxedPromiseOrValue(currentExecutor())\n : () => new BoxedPromiseOrValue(currentExecutor());\n\n streamItemQueue.push(currentStreamItem);\n\n iteration = iterator.next();\n currentIndex = initialIndex + 1;\n }\n\n streamItemQueue.push(new BoxedPromiseOrValue({}));\n\n return firstStreamItem.value;\n };\n\n streamItemQueue.push(\n enableEarlyExecution\n ? new BoxedPromiseOrValue(Promise.resolve().then(firstExecutor))\n : () => new BoxedPromiseOrValue(firstExecutor()),\n );\n\n return streamItemQueue;\n}\n\nfunction buildAsyncStreamItemQueue(\n initialIndex: number,\n streamPath: Path,\n asyncIterator: AsyncIterator,\n exeContext: ExecutionContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): Array {\n const streamItemQueue: Array = [];\n const executor = () =>\n getNextAsyncStreamItemResult(\n streamItemQueue,\n streamPath,\n initialIndex,\n asyncIterator,\n exeContext,\n fieldDetailsList,\n info,\n itemType,\n );\n\n streamItemQueue.push(\n exeContext.validatedExecutionArgs.enableEarlyExecution\n ? new BoxedPromiseOrValue(executor())\n : () => new BoxedPromiseOrValue(executor()),\n );\n\n return streamItemQueue;\n}\n\nasync function getNextAsyncStreamItemResult(\n streamItemQueue: Array,\n streamPath: Path,\n index: number,\n asyncIterator: AsyncIterator,\n exeContext: ExecutionContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): Promise {\n let iteration;\n try {\n iteration = await asyncIterator.next();\n } catch (error) {\n return {\n errors: [\n locatedError(error, toNodes(fieldDetailsList), pathToArray(streamPath)),\n ],\n };\n }\n\n if (iteration.done) {\n return {};\n }\n\n const itemPath = addPath(streamPath, index, undefined);\n\n const result = completeStreamItem(\n itemPath,\n iteration.value,\n exeContext,\n { errors: undefined, completed: false },\n fieldDetailsList,\n info,\n itemType,\n );\n\n const executor = () =>\n getNextAsyncStreamItemResult(\n streamItemQueue,\n streamPath,\n index + 1,\n asyncIterator,\n exeContext,\n fieldDetailsList,\n info,\n itemType,\n );\n\n streamItemQueue.push(\n exeContext.validatedExecutionArgs.enableEarlyExecution\n ? new BoxedPromiseOrValue(executor())\n : () => new BoxedPromiseOrValue(executor()),\n );\n\n return result;\n}\n\nfunction completeStreamItem(\n itemPath: Path,\n item: unknown,\n exeContext: ExecutionContext,\n incrementalContext: IncrementalContext,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n itemType: GraphQLOutputType,\n): PromiseOrValue {\n if (isPromise(item)) {\n const abortSignalListener = exeContext.abortSignalListener;\n const maybeCancellableItem = abortSignalListener\n ? cancellablePromise(item, abortSignalListener)\n : item;\n return completePromisedValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n maybeCancellableItem,\n incrementalContext,\n new Map(),\n ).then(\n (resolvedItem) => {\n incrementalContext.completed = true;\n return buildStreamItemResult(incrementalContext.errors, resolvedItem);\n },\n (error: unknown) => {\n incrementalContext.completed = true;\n return {\n errors: withError(incrementalContext.errors, error as GraphQLError),\n };\n },\n );\n }\n\n let result: PromiseOrValue>;\n try {\n try {\n result = completeValue(\n exeContext,\n itemType,\n fieldDetailsList,\n info,\n itemPath,\n item,\n incrementalContext,\n new Map(),\n );\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n result = { rawResult: null, incrementalDataRecords: undefined };\n }\n } catch (error) {\n incrementalContext.completed = true;\n return {\n errors: withError(incrementalContext.errors, error),\n };\n }\n\n if (isPromise(result)) {\n return result\n .then(undefined, (rawError: unknown) => {\n handleFieldError(\n rawError,\n exeContext,\n itemType,\n fieldDetailsList,\n itemPath,\n incrementalContext,\n );\n return { rawResult: null, incrementalDataRecords: undefined };\n })\n .then(\n (resolvedItem) => {\n incrementalContext.completed = true;\n return buildStreamItemResult(incrementalContext.errors, resolvedItem);\n },\n (error: unknown) => {\n incrementalContext.completed = true;\n return {\n errors: withError(incrementalContext.errors, error as GraphQLError),\n };\n },\n );\n }\n\n incrementalContext.completed = true;\n return buildStreamItemResult(incrementalContext.errors, result);\n}\n\nfunction buildStreamItemResult(\n errors: ReadonlyArray | undefined,\n result: GraphQLWrappedResult,\n): StreamItemResult {\n const { rawResult: item, incrementalDataRecords } = result;\n return {\n item,\n errors,\n incrementalDataRecords,\n };\n}\n"]} \ No newline at end of file diff --git a/execution/getVariableSignature.d.ts b/execution/getVariableSignature.d.ts new file mode 100644 index 0000000000..957bf6ed81 --- /dev/null +++ b/execution/getVariableSignature.d.ts @@ -0,0 +1,18 @@ +import { GraphQLError } from '../error/GraphQLError.js'; +import type { ConstValueNode, VariableDefinitionNode } from '../language/ast.js'; +import type { GraphQLInputType, GraphQLSchema } from '../type/index.js'; +/** + * A GraphQLVariableSignature is required to coerce a variable value. + * + * Designed to have comparable interface to GraphQLArgument so that + * getArgumentValues() can be reused for fragment arguments. + * */ +export interface GraphQLVariableSignature { + name: string; + type: GraphQLInputType; + defaultValue?: never; + default: { + literal: ConstValueNode; + } | undefined; +} +export declare function getVariableSignature(schema: GraphQLSchema, varDefNode: VariableDefinitionNode): GraphQLVariableSignature | GraphQLError; diff --git a/execution/getVariableSignature.js b/execution/getVariableSignature.js new file mode 100644 index 0000000000..7fd5509fbf --- /dev/null +++ b/execution/getVariableSignature.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getVariableSignature = getVariableSignature; +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const printer_js_1 = require("../language/printer.js"); +const definition_js_1 = require("../type/definition.js"); +const typeFromAST_js_1 = require("../utilities/typeFromAST.js"); +function getVariableSignature(schema, varDefNode) { + const varName = varDefNode.variable.name.value; + const varType = (0, typeFromAST_js_1.typeFromAST)(schema, varDefNode.type); + if (!(0, definition_js_1.isInputType)(varType)) { + // Must use input types for variables. This should be caught during + // validation, however is checked again here for safety. + const varTypeStr = (0, printer_js_1.print)(varDefNode.type); + return new GraphQLError_js_1.GraphQLError(`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, { nodes: varDefNode.type }); + } + const defaultValue = varDefNode.defaultValue; + return { + name: varName, + type: varType, + default: defaultValue && { literal: defaultValue }, + }; +} +//# sourceMappingURL=getVariableSignature.js.map \ No newline at end of file diff --git a/execution/getVariableSignature.js.map b/execution/getVariableSignature.js.map new file mode 100644 index 0000000000..e78aef3841 --- /dev/null +++ b/execution/getVariableSignature.js.map @@ -0,0 +1 @@ +{"version":3,"file":"getVariableSignature.js","sourceRoot":"","sources":["../../src/execution/getVariableSignature.ts"],"names":[],"mappings":";;AA0BA,oDAwBC;AAlDD,8DAAwD;AAMxD,uDAA+C;AAE/C,yDAAoD;AAGpD,gEAA0D;AAe1D,SAAgB,oBAAoB,CAClC,MAAqB,EACrB,UAAkC;IAElC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAA,4BAAW,EAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAErD,IAAI,CAAC,IAAA,2BAAW,EAAC,OAAO,CAAC,EAAE,CAAC;QAC1B,mEAAmE;QACnE,wDAAwD;QACxD,MAAM,UAAU,GAAG,IAAA,kBAAK,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1C,OAAO,IAAI,8BAAY,CACrB,cAAc,OAAO,6BAA6B,UAAU,0CAA0C,EACtG,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,CAC3B,CAAC;IACJ,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,YAAY,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ConstValueNode,\n VariableDefinitionNode,\n} from '../language/ast.js';\nimport { print } from '../language/printer.js';\n\nimport { isInputType } from '../type/definition.js';\nimport type { GraphQLInputType, GraphQLSchema } from '../type/index.js';\n\nimport { typeFromAST } from '../utilities/typeFromAST.js';\n\n/**\n * A GraphQLVariableSignature is required to coerce a variable value.\n *\n * Designed to have comparable interface to GraphQLArgument so that\n * getArgumentValues() can be reused for fragment arguments.\n * */\nexport interface GraphQLVariableSignature {\n name: string;\n type: GraphQLInputType;\n defaultValue?: never;\n default: { literal: ConstValueNode } | undefined;\n}\n\nexport function getVariableSignature(\n schema: GraphQLSchema,\n varDefNode: VariableDefinitionNode,\n): GraphQLVariableSignature | GraphQLError {\n const varName = varDefNode.variable.name.value;\n const varType = typeFromAST(schema, varDefNode.type);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = print(varDefNode.type);\n return new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n { nodes: varDefNode.type },\n );\n }\n\n const defaultValue = varDefNode.defaultValue;\n\n return {\n name: varName,\n type: varType,\n default: defaultValue && { literal: defaultValue },\n };\n}\n"]} \ No newline at end of file diff --git a/execution/getVariableSignature.mjs b/execution/getVariableSignature.mjs new file mode 100644 index 0000000000..92452792c4 --- /dev/null +++ b/execution/getVariableSignature.mjs @@ -0,0 +1,21 @@ +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { print } from "../language/printer.mjs"; +import { isInputType } from "../type/definition.mjs"; +import { typeFromAST } from "../utilities/typeFromAST.mjs"; +export function getVariableSignature(schema, varDefNode) { + const varName = varDefNode.variable.name.value; + const varType = typeFromAST(schema, varDefNode.type); + if (!isInputType(varType)) { + // Must use input types for variables. This should be caught during + // validation, however is checked again here for safety. + const varTypeStr = print(varDefNode.type); + return new GraphQLError(`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, { nodes: varDefNode.type }); + } + const defaultValue = varDefNode.defaultValue; + return { + name: varName, + type: varType, + default: defaultValue && { literal: defaultValue }, + }; +} +//# sourceMappingURL=getVariableSignature.js.map \ No newline at end of file diff --git a/execution/getVariableSignature.mjs.map b/execution/getVariableSignature.mjs.map new file mode 100644 index 0000000000..c8f5607e8f --- /dev/null +++ b/execution/getVariableSignature.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"getVariableSignature.js","sourceRoot":"","sources":["../../src/execution/getVariableSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kCAAiC;AAMxD,OAAO,EAAE,KAAK,EAAE,gCAA+B;AAE/C,OAAO,EAAE,WAAW,EAAE,+BAA8B;AAGpD,OAAO,EAAE,WAAW,EAAE,qCAAoC;AAe1D,MAAM,UAAU,oBAAoB,CAClC,MAAqB,EACrB,UAAkC;IAElC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IAC/C,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAErD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1B,mEAAmE;QACnE,wDAAwD;QACxD,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1C,OAAO,IAAI,YAAY,CACrB,cAAc,OAAO,6BAA6B,UAAU,0CAA0C,EACtG,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,CAC3B,CAAC;IACJ,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,YAAY,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ConstValueNode,\n VariableDefinitionNode,\n} from '../language/ast.js';\nimport { print } from '../language/printer.js';\n\nimport { isInputType } from '../type/definition.js';\nimport type { GraphQLInputType, GraphQLSchema } from '../type/index.js';\n\nimport { typeFromAST } from '../utilities/typeFromAST.js';\n\n/**\n * A GraphQLVariableSignature is required to coerce a variable value.\n *\n * Designed to have comparable interface to GraphQLArgument so that\n * getArgumentValues() can be reused for fragment arguments.\n * */\nexport interface GraphQLVariableSignature {\n name: string;\n type: GraphQLInputType;\n defaultValue?: never;\n default: { literal: ConstValueNode } | undefined;\n}\n\nexport function getVariableSignature(\n schema: GraphQLSchema,\n varDefNode: VariableDefinitionNode,\n): GraphQLVariableSignature | GraphQLError {\n const varName = varDefNode.variable.name.value;\n const varType = typeFromAST(schema, varDefNode.type);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = print(varDefNode.type);\n return new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n { nodes: varDefNode.type },\n );\n }\n\n const defaultValue = varDefNode.defaultValue;\n\n return {\n name: varName,\n type: varType,\n default: defaultValue && { literal: defaultValue },\n };\n}\n"]} \ No newline at end of file diff --git a/execution/index.d.ts b/execution/index.d.ts new file mode 100644 index 0000000000..65e6efbe17 --- /dev/null +++ b/execution/index.d.ts @@ -0,0 +1,5 @@ +export { pathToArray as responsePathAsArray } from '../jsutils/Path.js'; +export { createSourceEventStream, execute, executeQueryOrMutationOrSubscriptionEvent, executeSubscriptionEvent, experimentalExecuteIncrementally, experimentalExecuteQueryOrMutationOrSubscriptionEvent, executeSync, defaultFieldResolver, defaultTypeResolver, subscribe, } from './execute.js'; +export type { ExecutionArgs, ValidatedExecutionArgs } from './execute.js'; +export type { ExecutionResult, ExperimentalIncrementalExecutionResults, InitialIncrementalExecutionResult, SubsequentIncrementalExecutionResult, IncrementalDeferResult, IncrementalStreamResult, IncrementalResult, FormattedExecutionResult, FormattedInitialIncrementalExecutionResult, FormattedSubsequentIncrementalExecutionResult, FormattedIncrementalDeferResult, FormattedIncrementalStreamResult, FormattedIncrementalResult, } from './types.js'; +export { getArgumentValues, getVariableValues, getDirectiveValues, } from './values.js'; diff --git a/execution/index.js b/execution/index.js new file mode 100644 index 0000000000..fa23e82499 --- /dev/null +++ b/execution/index.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getDirectiveValues = exports.getVariableValues = exports.getArgumentValues = exports.subscribe = exports.defaultTypeResolver = exports.defaultFieldResolver = exports.executeSync = exports.experimentalExecuteQueryOrMutationOrSubscriptionEvent = exports.experimentalExecuteIncrementally = exports.executeSubscriptionEvent = exports.executeQueryOrMutationOrSubscriptionEvent = exports.execute = exports.createSourceEventStream = exports.responsePathAsArray = void 0; +var Path_js_1 = require("../jsutils/Path.js"); +Object.defineProperty(exports, "responsePathAsArray", { enumerable: true, get: function () { return Path_js_1.pathToArray; } }); +var execute_js_1 = require("./execute.js"); +Object.defineProperty(exports, "createSourceEventStream", { enumerable: true, get: function () { return execute_js_1.createSourceEventStream; } }); +Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return execute_js_1.execute; } }); +Object.defineProperty(exports, "executeQueryOrMutationOrSubscriptionEvent", { enumerable: true, get: function () { return execute_js_1.executeQueryOrMutationOrSubscriptionEvent; } }); +Object.defineProperty(exports, "executeSubscriptionEvent", { enumerable: true, get: function () { return execute_js_1.executeSubscriptionEvent; } }); +Object.defineProperty(exports, "experimentalExecuteIncrementally", { enumerable: true, get: function () { return execute_js_1.experimentalExecuteIncrementally; } }); +Object.defineProperty(exports, "experimentalExecuteQueryOrMutationOrSubscriptionEvent", { enumerable: true, get: function () { return execute_js_1.experimentalExecuteQueryOrMutationOrSubscriptionEvent; } }); +Object.defineProperty(exports, "executeSync", { enumerable: true, get: function () { return execute_js_1.executeSync; } }); +Object.defineProperty(exports, "defaultFieldResolver", { enumerable: true, get: function () { return execute_js_1.defaultFieldResolver; } }); +Object.defineProperty(exports, "defaultTypeResolver", { enumerable: true, get: function () { return execute_js_1.defaultTypeResolver; } }); +Object.defineProperty(exports, "subscribe", { enumerable: true, get: function () { return execute_js_1.subscribe; } }); +var values_js_1 = require("./values.js"); +Object.defineProperty(exports, "getArgumentValues", { enumerable: true, get: function () { return values_js_1.getArgumentValues; } }); +Object.defineProperty(exports, "getVariableValues", { enumerable: true, get: function () { return values_js_1.getVariableValues; } }); +Object.defineProperty(exports, "getDirectiveValues", { enumerable: true, get: function () { return values_js_1.getDirectiveValues; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/execution/index.js.map b/execution/index.js.map new file mode 100644 index 0000000000..03fba01d9b --- /dev/null +++ b/execution/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":";;;AAAA,8CAAwE;AAA/D,8GAAA,WAAW,OAAuB;AAE3C,2CAWsB;AAVpB,qHAAA,uBAAuB,OAAA;AACvB,qGAAA,OAAO,OAAA;AACP,uIAAA,yCAAyC,OAAA;AACzC,sHAAA,wBAAwB,OAAA;AACxB,8HAAA,gCAAgC,OAAA;AAChC,mJAAA,qDAAqD,OAAA;AACrD,yGAAA,WAAW,OAAA;AACX,kHAAA,oBAAoB,OAAA;AACpB,iHAAA,mBAAmB,OAAA;AACnB,uGAAA,SAAS,OAAA;AAqBX,yCAIqB;AAHnB,8GAAA,iBAAiB,OAAA;AACjB,8GAAA,iBAAiB,OAAA;AACjB,+GAAA,kBAAkB,OAAA","sourcesContent":["export { pathToArray as responsePathAsArray } from '../jsutils/Path.js';\n\nexport {\n createSourceEventStream,\n execute,\n executeQueryOrMutationOrSubscriptionEvent,\n executeSubscriptionEvent,\n experimentalExecuteIncrementally,\n experimentalExecuteQueryOrMutationOrSubscriptionEvent,\n executeSync,\n defaultFieldResolver,\n defaultTypeResolver,\n subscribe,\n} from './execute.js';\n\nexport type { ExecutionArgs, ValidatedExecutionArgs } from './execute.js';\n\nexport type {\n ExecutionResult,\n ExperimentalIncrementalExecutionResults,\n InitialIncrementalExecutionResult,\n SubsequentIncrementalExecutionResult,\n IncrementalDeferResult,\n IncrementalStreamResult,\n IncrementalResult,\n FormattedExecutionResult,\n FormattedInitialIncrementalExecutionResult,\n FormattedSubsequentIncrementalExecutionResult,\n FormattedIncrementalDeferResult,\n FormattedIncrementalStreamResult,\n FormattedIncrementalResult,\n} from './types.js';\n\nexport {\n getArgumentValues,\n getVariableValues,\n getDirectiveValues,\n} from './values.js';\n"]} \ No newline at end of file diff --git a/execution/index.mjs b/execution/index.mjs new file mode 100644 index 0000000000..8f5d235137 --- /dev/null +++ b/execution/index.mjs @@ -0,0 +1,4 @@ +export { pathToArray as responsePathAsArray } from "../jsutils/Path.mjs"; +export { createSourceEventStream, execute, executeQueryOrMutationOrSubscriptionEvent, executeSubscriptionEvent, experimentalExecuteIncrementally, experimentalExecuteQueryOrMutationOrSubscriptionEvent, executeSync, defaultFieldResolver, defaultTypeResolver, subscribe, } from "./execute.mjs"; +export { getArgumentValues, getVariableValues, getDirectiveValues, } from "./values.mjs"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/execution/index.mjs.map b/execution/index.mjs.map new file mode 100644 index 0000000000..3375cabcd4 --- /dev/null +++ b/execution/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,4BAA2B;AAExE,OAAO,EACL,uBAAuB,EACvB,OAAO,EACP,yCAAyC,EACzC,wBAAwB,EACxB,gCAAgC,EAChC,qDAAqD,EACrD,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,GACV,sBAAqB;AAoBtB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,qBAAoB","sourcesContent":["export { pathToArray as responsePathAsArray } from '../jsutils/Path.js';\n\nexport {\n createSourceEventStream,\n execute,\n executeQueryOrMutationOrSubscriptionEvent,\n executeSubscriptionEvent,\n experimentalExecuteIncrementally,\n experimentalExecuteQueryOrMutationOrSubscriptionEvent,\n executeSync,\n defaultFieldResolver,\n defaultTypeResolver,\n subscribe,\n} from './execute.js';\n\nexport type { ExecutionArgs, ValidatedExecutionArgs } from './execute.js';\n\nexport type {\n ExecutionResult,\n ExperimentalIncrementalExecutionResults,\n InitialIncrementalExecutionResult,\n SubsequentIncrementalExecutionResult,\n IncrementalDeferResult,\n IncrementalStreamResult,\n IncrementalResult,\n FormattedExecutionResult,\n FormattedInitialIncrementalExecutionResult,\n FormattedSubsequentIncrementalExecutionResult,\n FormattedIncrementalDeferResult,\n FormattedIncrementalStreamResult,\n FormattedIncrementalResult,\n} from './types.js';\n\nexport {\n getArgumentValues,\n getVariableValues,\n getDirectiveValues,\n} from './values.js';\n"]} \ No newline at end of file diff --git a/execution/mapAsyncIterable.d.ts b/execution/mapAsyncIterable.d.ts new file mode 100644 index 0000000000..7f1be65095 --- /dev/null +++ b/execution/mapAsyncIterable.d.ts @@ -0,0 +1,6 @@ +import type { PromiseOrValue } from '../jsutils/PromiseOrValue.js'; +/** + * Given an AsyncIterable and a callback function, return an AsyncIterator + * which produces values mapped via calling the callback function. + */ +export declare function mapAsyncIterable(iterable: AsyncGenerator | AsyncIterable, callback: (value: T) => PromiseOrValue, onDone?: () => void): AsyncGenerator; diff --git a/execution/mapAsyncIterable.js b/execution/mapAsyncIterable.js new file mode 100644 index 0000000000..d79cdfbc79 --- /dev/null +++ b/execution/mapAsyncIterable.js @@ -0,0 +1,63 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapAsyncIterable = mapAsyncIterable; +/** + * Given an AsyncIterable and a callback function, return an AsyncIterator + * which produces values mapped via calling the callback function. + */ +function mapAsyncIterable(iterable, callback, onDone) { + const iterator = iterable[Symbol.asyncIterator](); + async function mapResult(promise) { + let value; + try { + const result = await promise; + if (result.done) { + onDone?.(); + return result; + } + value = result.value; + } + catch (error) { + onDone?.(); + throw error; + } + try { + return { value: await callback(value), done: false }; + } + catch (error) { + /* c8 ignore start */ + // FIXME: add test case + if (typeof iterator.return === 'function') { + try { + await iterator.return(); + } + catch (_e) { + /* ignore error */ + } + } + throw error; + /* c8 ignore stop */ + } + } + return { + async next() { + return mapResult(iterator.next()); + }, + async return() { + // If iterator.return() does not exist, then type R must be undefined. + return typeof iterator.return === 'function' + ? mapResult(iterator.return()) + : { value: undefined, done: true }; + }, + async throw(error) { + if (typeof iterator.throw === 'function') { + return mapResult(iterator.throw(error)); + } + throw error; + }, + [Symbol.asyncIterator]() { + return this; + }, + }; +} +//# sourceMappingURL=mapAsyncIterable.js.map \ No newline at end of file diff --git a/execution/mapAsyncIterable.js.map b/execution/mapAsyncIterable.js.map new file mode 100644 index 0000000000..907e0726e1 --- /dev/null +++ b/execution/mapAsyncIterable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mapAsyncIterable.js","sourceRoot":"","sources":["../../src/execution/mapAsyncIterable.ts"],"names":[],"mappings":";;AAMA,4CA4DC;AAhED;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,QAAuD,EACvD,QAAyC,EACzC,MAAmB;IAEnB,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAElD,KAAK,UAAU,SAAS,CACtB,OAAsC;QAEt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AC;gBACzC,OAAO,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { PromiseOrValue } from '../jsutils/PromiseOrValue.js';\n\n/**\n * Given an AsyncIterable and a callback function, return an AsyncIterator\n * which produces values mapped via calling the callback function.\n */\nexport function mapAsyncIterable(\n iterable: AsyncGenerator | AsyncIterable,\n callback: (value: T) => PromiseOrValue,\n onDone?: () => void,\n): AsyncGenerator {\n const iterator = iterable[Symbol.asyncIterator]();\n\n async function mapResult(\n promise: Promise>,\n ): Promise> {\n let value: T;\n try {\n const result = await promise;\n if (result.done) {\n onDone?.();\n return result;\n }\n value = result.value;\n } catch (error) {\n onDone?.();\n throw error;\n }\n\n try {\n return { value: await callback(value), done: false };\n } catch (error) {\n /* c8 ignore start */\n // FIXME: add test case\n if (typeof iterator.return === 'function') {\n try {\n await iterator.return();\n } catch (_e) {\n /* ignore error */\n }\n }\n throw error;\n /* c8 ignore stop */\n }\n }\n\n return {\n async next() {\n return mapResult(iterator.next());\n },\n async return(): Promise> {\n // If iterator.return() does not exist, then type R must be undefined.\n return typeof iterator.return === 'function'\n ? mapResult(iterator.return())\n : { value: undefined as any, done: true };\n },\n async throw(error?: unknown) {\n if (typeof iterator.throw === 'function') {\n return mapResult(iterator.throw(error));\n }\n throw error;\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/execution/mapAsyncIterable.mjs b/execution/mapAsyncIterable.mjs new file mode 100644 index 0000000000..1ab283e201 --- /dev/null +++ b/execution/mapAsyncIterable.mjs @@ -0,0 +1,60 @@ +/** + * Given an AsyncIterable and a callback function, return an AsyncIterator + * which produces values mapped via calling the callback function. + */ +export function mapAsyncIterable(iterable, callback, onDone) { + const iterator = iterable[Symbol.asyncIterator](); + async function mapResult(promise) { + let value; + try { + const result = await promise; + if (result.done) { + onDone?.(); + return result; + } + value = result.value; + } + catch (error) { + onDone?.(); + throw error; + } + try { + return { value: await callback(value), done: false }; + } + catch (error) { + /* c8 ignore start */ + // FIXME: add test case + if (typeof iterator.return === 'function') { + try { + await iterator.return(); + } + catch (_e) { + /* ignore error */ + } + } + throw error; + /* c8 ignore stop */ + } + } + return { + async next() { + return mapResult(iterator.next()); + }, + async return() { + // If iterator.return() does not exist, then type R must be undefined. + return typeof iterator.return === 'function' + ? mapResult(iterator.return()) + : { value: undefined, done: true }; + }, + async throw(error) { + if (typeof iterator.throw === 'function') { + return mapResult(iterator.throw(error)); + } + throw error; + }, + [Symbol.asyncIterator]() { + return this; + }, + }; +} +//# sourceMappingURL=mapAsyncIterable.js.map \ No newline at end of file diff --git a/execution/mapAsyncIterable.mjs.map b/execution/mapAsyncIterable.mjs.map new file mode 100644 index 0000000000..817690a226 --- /dev/null +++ b/execution/mapAsyncIterable.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"mapAsyncIterable.js","sourceRoot":"","sources":["../../src/execution/mapAsyncIterable.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAuD,EACvD,QAAyC,EACzC,MAAmB;IAEnB,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAElD,KAAK,UAAU,SAAS,CACtB,OAAsC;QAEtC,IAAI,KAAQ,CAAC;QACb,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;YAC7B,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;gBAChB,MAAM,EAAE,EAAE,CAAC;gBACX,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,EAA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and a callback function, return an AsyncIterator\n * which produces values mapped via calling the callback function.\n */\nexport function mapAsyncIterable(\n iterable: AsyncGenerator | AsyncIterable,\n callback: (value: T) => PromiseOrValue,\n onDone?: () => void,\n): AsyncGenerator {\n const iterator = iterable[Symbol.asyncIterator]();\n\n async function mapResult(\n promise: Promise>,\n ): Promise> {\n let value: T;\n try {\n const result = await promise;\n if (result.done) {\n onDone?.();\n return result;\n }\n value = result.value;\n } catch (error) {\n onDone?.();\n throw error;\n }\n\n try {\n return { value: await callback(value), done: false };\n } catch (error) {\n /* c8 ignore start */\n // FIXME: add test case\n if (typeof iterator.return === 'function') {\n try {\n await iterator.return();\n } catch (_e) {\n /* ignore error */\n }\n }\n throw error;\n /* c8 ignore stop */\n }\n }\n\n return {\n async next() {\n return mapResult(iterator.next());\n },\n async return(): Promise> {\n // If iterator.return() does not exist, then type R must be undefined.\n return typeof iterator.return === 'function'\n ? mapResult(iterator.return())\n : { value: undefined as any, done: true };\n },\n async throw(error?: unknown) {\n if (typeof iterator.throw === 'function') {\n return mapResult(iterator.throw(error));\n }\n throw error;\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/execution/types.d.ts b/execution/types.d.ts new file mode 100644 index 0000000000..48ef2e95a0 --- /dev/null +++ b/execution/types.d.ts @@ -0,0 +1,161 @@ +import type { BoxedPromiseOrValue } from '../jsutils/BoxedPromiseOrValue.js'; +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { Path } from '../jsutils/Path.js'; +import type { GraphQLError, GraphQLFormattedError } from '../error/GraphQLError.js'; +/** + * The result of GraphQL execution. + * + * - `errors` is included when any errors occurred as a non-empty array. + * - `data` is the result of a successful execution of the query. + * - `hasNext` is true if a future payload is expected. + * - `extensions` is reserved for adding non-standard properties. + * - `incremental` is a list of the results from defer/stream directives. + */ +export interface ExecutionResult, TExtensions = ObjMap> { + errors?: ReadonlyArray; + data?: TData | null; + extensions?: TExtensions; +} +export interface FormattedExecutionResult, TExtensions = ObjMap> { + errors?: ReadonlyArray; + data?: TData | null; + extensions?: TExtensions; +} +export interface ExperimentalIncrementalExecutionResults, TSubsequent = unknown, TExtensions = ObjMap> { + initialResult: InitialIncrementalExecutionResult; + subsequentResults: AsyncGenerator, void, void>; +} +export interface InitialIncrementalExecutionResult, TExtensions = ObjMap> extends ExecutionResult { + data: TData; + pending: ReadonlyArray; + hasNext: true; + extensions?: TExtensions; +} +export interface FormattedInitialIncrementalExecutionResult, TExtensions = ObjMap> extends FormattedExecutionResult { + data: TData; + pending: ReadonlyArray; + hasNext: boolean; + extensions?: TExtensions; +} +export interface SubsequentIncrementalExecutionResult> { + pending?: ReadonlyArray; + incremental?: ReadonlyArray>; + completed?: ReadonlyArray; + hasNext: boolean; + extensions?: TExtensions; +} +export interface FormattedSubsequentIncrementalExecutionResult> { + hasNext: boolean; + pending?: ReadonlyArray; + incremental?: ReadonlyArray>; + completed?: ReadonlyArray; + extensions?: TExtensions; +} +interface ExecutionGroupResult> { + errors?: ReadonlyArray; + data: TData; +} +export interface IncrementalDeferResult, TExtensions = ObjMap> extends ExecutionGroupResult { + id: string; + subPath?: ReadonlyArray; + extensions?: TExtensions; +} +export interface FormattedIncrementalDeferResult, TExtensions = ObjMap> { + errors?: ReadonlyArray; + data: TData; + id: string; + subPath?: ReadonlyArray; + extensions?: TExtensions; +} +interface StreamItemsRecordResult> { + errors?: ReadonlyArray; + items: TData; +} +export interface IncrementalStreamResult, TExtensions = ObjMap> extends StreamItemsRecordResult { + id: string; + subPath?: ReadonlyArray; + extensions?: TExtensions; +} +export interface FormattedIncrementalStreamResult, TExtensions = ObjMap> { + errors?: ReadonlyArray; + items: TData; + id: string; + subPath?: ReadonlyArray; + extensions?: TExtensions; +} +export type IncrementalResult> = IncrementalDeferResult | IncrementalStreamResult; +export type FormattedIncrementalResult> = FormattedIncrementalDeferResult | FormattedIncrementalStreamResult; +export interface PendingResult { + id: string; + path: ReadonlyArray; + label?: string; +} +export interface CompletedResult { + id: string; + errors?: ReadonlyArray; +} +export interface FormattedCompletedResult { + path: ReadonlyArray; + label?: string; + errors?: ReadonlyArray; +} +export declare function isPendingExecutionGroup(incrementalDataRecord: IncrementalDataRecord): incrementalDataRecord is PendingExecutionGroup; +export type CompletedExecutionGroup = SuccessfulExecutionGroup | FailedExecutionGroup; +export declare function isCompletedExecutionGroup(incrementalDataRecordResult: IncrementalDataRecordResult): incrementalDataRecordResult is CompletedExecutionGroup; +export interface SuccessfulExecutionGroup { + pendingExecutionGroup: PendingExecutionGroup; + path: Array; + result: ExecutionGroupResult; + incrementalDataRecords: ReadonlyArray | undefined; + errors?: never; +} +interface FailedExecutionGroup { + pendingExecutionGroup: PendingExecutionGroup; + path: Array; + errors: ReadonlyArray; + result?: never; +} +export declare function isFailedExecutionGroup(completedExecutionGroup: CompletedExecutionGroup): completedExecutionGroup is FailedExecutionGroup; +type ThunkIncrementalResult = BoxedPromiseOrValue | (() => BoxedPromiseOrValue); +export interface PendingExecutionGroup { + deferredFragmentRecords: ReadonlyArray; + result: ThunkIncrementalResult; +} +export type DeliveryGroup = DeferredFragmentRecord | StreamRecord; +/** @internal */ +export declare class DeferredFragmentRecord { + path: Path | undefined; + label: string | undefined; + id?: string | undefined; + parent: DeferredFragmentRecord | undefined; + pendingExecutionGroups: Set; + successfulExecutionGroups: Set; + children: Set; + constructor(path: Path | undefined, label: string | undefined, parent: DeferredFragmentRecord | undefined); +} +export declare function isDeferredFragmentRecord(deliveryGroup: DeliveryGroup): deliveryGroup is DeferredFragmentRecord; +export interface StreamItemResult { + item?: unknown; + incrementalDataRecords?: ReadonlyArray | undefined; + errors?: ReadonlyArray | undefined; +} +export type StreamItemRecord = ThunkIncrementalResult; +export interface StreamRecord { + path: Path; + label: string | undefined; + id?: string | undefined; + streamItemQueue: Array; +} +export interface StreamItemsResult { + streamRecord: StreamRecord; + errors?: ReadonlyArray; + result?: StreamItemsRecordResult; + incrementalDataRecords?: ReadonlyArray | undefined; +} +export interface CancellableStreamRecord extends StreamRecord { + earlyReturn: () => Promise; +} +export declare function isCancellableStreamRecord(deliveryGroup: DeliveryGroup): deliveryGroup is CancellableStreamRecord; +export type IncrementalDataRecord = PendingExecutionGroup | StreamRecord; +export type IncrementalDataRecordResult = CompletedExecutionGroup | StreamItemsResult; +export {}; diff --git a/execution/types.js b/execution/types.js new file mode 100644 index 0000000000..5a5f0d219a --- /dev/null +++ b/execution/types.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeferredFragmentRecord = void 0; +exports.isPendingExecutionGroup = isPendingExecutionGroup; +exports.isCompletedExecutionGroup = isCompletedExecutionGroup; +exports.isFailedExecutionGroup = isFailedExecutionGroup; +exports.isDeferredFragmentRecord = isDeferredFragmentRecord; +exports.isCancellableStreamRecord = isCancellableStreamRecord; +function isPendingExecutionGroup(incrementalDataRecord) { + return 'deferredFragmentRecords' in incrementalDataRecord; +} +function isCompletedExecutionGroup(incrementalDataRecordResult) { + return 'pendingExecutionGroup' in incrementalDataRecordResult; +} +function isFailedExecutionGroup(completedExecutionGroup) { + return completedExecutionGroup.errors !== undefined; +} +/** @internal */ +class DeferredFragmentRecord { + constructor(path, label, parent) { + this.path = path; + this.label = label; + this.parent = parent; + this.pendingExecutionGroups = new Set(); + this.successfulExecutionGroups = new Set(); + this.children = new Set(); + } +} +exports.DeferredFragmentRecord = DeferredFragmentRecord; +function isDeferredFragmentRecord(deliveryGroup) { + return deliveryGroup instanceof DeferredFragmentRecord; +} +function isCancellableStreamRecord(deliveryGroup) { + return 'earlyReturn' in deliveryGroup; +} +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/execution/types.js.map b/execution/types.js.map new file mode 100644 index 0000000000..e57995da0f --- /dev/null +++ b/execution/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/execution/types.ts"],"names":[],"mappings":";;;AAyKA,0DAIC;AAMD,8DAIC;AAiBD,wDAIC;AAqCD,4DAIC;AA4BD,8DAIC;AA5GD,SAAgB,uBAAuB,CACrC,qBAA4C;IAE5C,OAAO,yBAAyB,IAAI,qBAAqB,CAAC;AAC5D,CAAC;AAMD,SAAgB,yBAAyB,CACvC,2BAAwD;IAExD,OAAO,uBAAuB,IAAI,2BAA2B,CAAC;AAChE,CAAC;AAiBD,SAAgB,sBAAsB,CACpC,uBAAgD;IAEhD,OAAO,uBAAuB,CAAC,MAAM,KAAK,SAAS,CAAC;AACtD,CAAC;AAaD,gBAAgB;AAChB,MAAa,sBAAsB;IASjC,YACE,IAAsB,EACtB,KAAyB,EACzB,MAA0C;QAE1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,sBAAsB,GAAG,IAAI,GAAG,EAAE,CAAC;QACxC,IAAI,CAAC,yBAAyB,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;IAC5B,CAAC;CACF;AArBD,wDAqBC;AAED,SAAgB,wBAAwB,CACtC,aAA4B;IAE5B,OAAO,aAAa,YAAY,sBAAsB,CAAC;AACzD,CAAC;AA4BD,SAAgB,yBAAyB,CACvC,aAA4B;IAE5B,OAAO,aAAa,IAAI,aAAa,CAAC;AACxC,CAAC","sourcesContent":["import type { BoxedPromiseOrValue } from '../jsutils/BoxedPromiseOrValue.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport type { Path } from '../jsutils/Path.js';\n\nimport type {\n GraphQLError,\n GraphQLFormattedError,\n} from '../error/GraphQLError.js';\n\n/**\n * The result of GraphQL execution.\n *\n * - `errors` is included when any errors occurred as a non-empty array.\n * - `data` is the result of a successful execution of the query.\n * - `hasNext` is true if a future payload is expected.\n * - `extensions` is reserved for adding non-standard properties.\n * - `incremental` is a list of the results from defer/stream directives.\n */\nexport interface ExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface FormattedExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface ExperimentalIncrementalExecutionResults<\n TInitial = ObjMap,\n TSubsequent = unknown,\n TExtensions = ObjMap,\n> {\n initialResult: InitialIncrementalExecutionResult;\n subsequentResults: AsyncGenerator<\n SubsequentIncrementalExecutionResult,\n void,\n void\n >;\n}\n\nexport interface InitialIncrementalExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> extends ExecutionResult {\n data: TData;\n pending: ReadonlyArray;\n hasNext: true;\n extensions?: TExtensions;\n}\n\nexport interface FormattedInitialIncrementalExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> extends FormattedExecutionResult {\n data: TData;\n pending: ReadonlyArray;\n hasNext: boolean;\n extensions?: TExtensions;\n}\n\nexport interface SubsequentIncrementalExecutionResult<\n TData = unknown,\n TExtensions = ObjMap,\n> {\n pending?: ReadonlyArray;\n incremental?: ReadonlyArray>;\n completed?: ReadonlyArray;\n hasNext: boolean;\n extensions?: TExtensions;\n}\n\nexport interface FormattedSubsequentIncrementalExecutionResult<\n TData = unknown,\n TExtensions = ObjMap,\n> {\n hasNext: boolean;\n pending?: ReadonlyArray;\n incremental?: ReadonlyArray>;\n completed?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\ninterface ExecutionGroupResult> {\n errors?: ReadonlyArray;\n data: TData;\n}\n\nexport interface IncrementalDeferResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> extends ExecutionGroupResult {\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\nexport interface FormattedIncrementalDeferResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n data: TData;\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\ninterface StreamItemsRecordResult> {\n errors?: ReadonlyArray;\n items: TData;\n}\n\nexport interface IncrementalStreamResult<\n TData = ReadonlyArray,\n TExtensions = ObjMap,\n> extends StreamItemsRecordResult {\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\nexport interface FormattedIncrementalStreamResult<\n TData = Array,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n items: TData;\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\nexport type IncrementalResult> =\n | IncrementalDeferResult\n | IncrementalStreamResult;\n\nexport type FormattedIncrementalResult<\n TData = unknown,\n TExtensions = ObjMap,\n> =\n | FormattedIncrementalDeferResult\n | FormattedIncrementalStreamResult;\n\nexport interface PendingResult {\n id: string;\n path: ReadonlyArray;\n label?: string;\n}\n\nexport interface CompletedResult {\n id: string;\n errors?: ReadonlyArray;\n}\n\nexport interface FormattedCompletedResult {\n path: ReadonlyArray;\n label?: string;\n errors?: ReadonlyArray;\n}\n\nexport function isPendingExecutionGroup(\n incrementalDataRecord: IncrementalDataRecord,\n): incrementalDataRecord is PendingExecutionGroup {\n return 'deferredFragmentRecords' in incrementalDataRecord;\n}\n\nexport type CompletedExecutionGroup =\n | SuccessfulExecutionGroup\n | FailedExecutionGroup;\n\nexport function isCompletedExecutionGroup(\n incrementalDataRecordResult: IncrementalDataRecordResult,\n): incrementalDataRecordResult is CompletedExecutionGroup {\n return 'pendingExecutionGroup' in incrementalDataRecordResult;\n}\n\nexport interface SuccessfulExecutionGroup {\n pendingExecutionGroup: PendingExecutionGroup;\n path: Array;\n result: ExecutionGroupResult;\n incrementalDataRecords: ReadonlyArray | undefined;\n errors?: never;\n}\n\ninterface FailedExecutionGroup {\n pendingExecutionGroup: PendingExecutionGroup;\n path: Array;\n errors: ReadonlyArray;\n result?: never;\n}\n\nexport function isFailedExecutionGroup(\n completedExecutionGroup: CompletedExecutionGroup,\n): completedExecutionGroup is FailedExecutionGroup {\n return completedExecutionGroup.errors !== undefined;\n}\n\ntype ThunkIncrementalResult =\n | BoxedPromiseOrValue\n | (() => BoxedPromiseOrValue);\n\nexport interface PendingExecutionGroup {\n deferredFragmentRecords: ReadonlyArray;\n result: ThunkIncrementalResult;\n}\n\nexport type DeliveryGroup = DeferredFragmentRecord | StreamRecord;\n\n/** @internal */\nexport class DeferredFragmentRecord {\n path: Path | undefined;\n label: string | undefined;\n id?: string | undefined;\n parent: DeferredFragmentRecord | undefined;\n pendingExecutionGroups: Set;\n successfulExecutionGroups: Set;\n children: Set;\n\n constructor(\n path: Path | undefined,\n label: string | undefined,\n parent: DeferredFragmentRecord | undefined,\n ) {\n this.path = path;\n this.label = label;\n this.parent = parent;\n this.pendingExecutionGroups = new Set();\n this.successfulExecutionGroups = new Set();\n this.children = new Set();\n }\n}\n\nexport function isDeferredFragmentRecord(\n deliveryGroup: DeliveryGroup,\n): deliveryGroup is DeferredFragmentRecord {\n return deliveryGroup instanceof DeferredFragmentRecord;\n}\n\nexport interface StreamItemResult {\n item?: unknown;\n incrementalDataRecords?: ReadonlyArray | undefined;\n errors?: ReadonlyArray | undefined;\n}\n\nexport type StreamItemRecord = ThunkIncrementalResult;\n\nexport interface StreamRecord {\n path: Path;\n label: string | undefined;\n id?: string | undefined;\n streamItemQueue: Array;\n}\n\nexport interface StreamItemsResult {\n streamRecord: StreamRecord;\n errors?: ReadonlyArray;\n result?: StreamItemsRecordResult;\n incrementalDataRecords?: ReadonlyArray | undefined;\n}\n\nexport interface CancellableStreamRecord extends StreamRecord {\n earlyReturn: () => Promise;\n}\n\nexport function isCancellableStreamRecord(\n deliveryGroup: DeliveryGroup,\n): deliveryGroup is CancellableStreamRecord {\n return 'earlyReturn' in deliveryGroup;\n}\n\nexport type IncrementalDataRecord = PendingExecutionGroup | StreamRecord;\n\nexport type IncrementalDataRecordResult =\n | CompletedExecutionGroup\n | StreamItemsResult;\n"]} \ No newline at end of file diff --git a/execution/types.mjs b/execution/types.mjs new file mode 100644 index 0000000000..511cda0d1a --- /dev/null +++ b/execution/types.mjs @@ -0,0 +1,27 @@ +export function isPendingExecutionGroup(incrementalDataRecord) { + return 'deferredFragmentRecords' in incrementalDataRecord; +} +export function isCompletedExecutionGroup(incrementalDataRecordResult) { + return 'pendingExecutionGroup' in incrementalDataRecordResult; +} +export function isFailedExecutionGroup(completedExecutionGroup) { + return completedExecutionGroup.errors !== undefined; +} +/** @internal */ +export class DeferredFragmentRecord { + constructor(path, label, parent) { + this.path = path; + this.label = label; + this.parent = parent; + this.pendingExecutionGroups = new Set(); + this.successfulExecutionGroups = new Set(); + this.children = new Set(); + } +} +export function isDeferredFragmentRecord(deliveryGroup) { + return deliveryGroup instanceof DeferredFragmentRecord; +} +export function isCancellableStreamRecord(deliveryGroup) { + return 'earlyReturn' in deliveryGroup; +} +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/execution/types.mjs.map b/execution/types.mjs.map new file mode 100644 index 0000000000..9ef325f291 --- /dev/null +++ b/execution/types.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/execution/types.ts"],"names":[],"mappings":"AAyKA,MAAM,UAAU,uBAAuB,CACrC,qBAA4C;IAE5C,OAAO,yBAAyB,IAAI,qBAAqB,CAAC;AAC5D,CAAC;AAMD,MAAM,UAAU,yBAAyB,CACvC,2BAAwD;IAExD,OAAO,uBAAuB,IAAI,2BAA2B,CAAC;AAChE,CAAC;AAiBD,MAAM,UAAU,sBAAsB,CACpC,uBAAgD;IAEhD,OAAO,uBAAuB,CAAC,MAAM,KAAK,SAAS,CAAC;AACtD,CAAC;AAaD,gBAAgB;AAChB,MAAM,OAAO,sBAAsB;IASjC,YACE,IAAsB,EACtB,KAAyB,EACzB,MAA0C;QAE1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,sBAAsB,GAAG,IAAI,GAAG,EAAE,CAAC;QACxC,IAAI,CAAC,yBAAyB,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,UAAU,wBAAwB,CACtC,aAA4B;IAE5B,OAAO,aAAa,YAAY,sBAAsB,CAAC;AACzD,CAAC;AA4BD,MAAM,UAAU,yBAAyB,CACvC,aAA4B;IAE5B,OAAO,aAAa,IAAI,aAAa,CAAC;AACxC,CAAC","sourcesContent":["import type { BoxedPromiseOrValue } from '../jsutils/BoxedPromiseOrValue.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport type { Path } from '../jsutils/Path.js';\n\nimport type {\n GraphQLError,\n GraphQLFormattedError,\n} from '../error/GraphQLError.js';\n\n/**\n * The result of GraphQL execution.\n *\n * - `errors` is included when any errors occurred as a non-empty array.\n * - `data` is the result of a successful execution of the query.\n * - `hasNext` is true if a future payload is expected.\n * - `extensions` is reserved for adding non-standard properties.\n * - `incremental` is a list of the results from defer/stream directives.\n */\nexport interface ExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface FormattedExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface ExperimentalIncrementalExecutionResults<\n TInitial = ObjMap,\n TSubsequent = unknown,\n TExtensions = ObjMap,\n> {\n initialResult: InitialIncrementalExecutionResult;\n subsequentResults: AsyncGenerator<\n SubsequentIncrementalExecutionResult,\n void,\n void\n >;\n}\n\nexport interface InitialIncrementalExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> extends ExecutionResult {\n data: TData;\n pending: ReadonlyArray;\n hasNext: true;\n extensions?: TExtensions;\n}\n\nexport interface FormattedInitialIncrementalExecutionResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> extends FormattedExecutionResult {\n data: TData;\n pending: ReadonlyArray;\n hasNext: boolean;\n extensions?: TExtensions;\n}\n\nexport interface SubsequentIncrementalExecutionResult<\n TData = unknown,\n TExtensions = ObjMap,\n> {\n pending?: ReadonlyArray;\n incremental?: ReadonlyArray>;\n completed?: ReadonlyArray;\n hasNext: boolean;\n extensions?: TExtensions;\n}\n\nexport interface FormattedSubsequentIncrementalExecutionResult<\n TData = unknown,\n TExtensions = ObjMap,\n> {\n hasNext: boolean;\n pending?: ReadonlyArray;\n incremental?: ReadonlyArray>;\n completed?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\ninterface ExecutionGroupResult> {\n errors?: ReadonlyArray;\n data: TData;\n}\n\nexport interface IncrementalDeferResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> extends ExecutionGroupResult {\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\nexport interface FormattedIncrementalDeferResult<\n TData = ObjMap,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n data: TData;\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\ninterface StreamItemsRecordResult> {\n errors?: ReadonlyArray;\n items: TData;\n}\n\nexport interface IncrementalStreamResult<\n TData = ReadonlyArray,\n TExtensions = ObjMap,\n> extends StreamItemsRecordResult {\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\nexport interface FormattedIncrementalStreamResult<\n TData = Array,\n TExtensions = ObjMap,\n> {\n errors?: ReadonlyArray;\n items: TData;\n id: string;\n subPath?: ReadonlyArray;\n extensions?: TExtensions;\n}\n\nexport type IncrementalResult> =\n | IncrementalDeferResult\n | IncrementalStreamResult;\n\nexport type FormattedIncrementalResult<\n TData = unknown,\n TExtensions = ObjMap,\n> =\n | FormattedIncrementalDeferResult\n | FormattedIncrementalStreamResult;\n\nexport interface PendingResult {\n id: string;\n path: ReadonlyArray;\n label?: string;\n}\n\nexport interface CompletedResult {\n id: string;\n errors?: ReadonlyArray;\n}\n\nexport interface FormattedCompletedResult {\n path: ReadonlyArray;\n label?: string;\n errors?: ReadonlyArray;\n}\n\nexport function isPendingExecutionGroup(\n incrementalDataRecord: IncrementalDataRecord,\n): incrementalDataRecord is PendingExecutionGroup {\n return 'deferredFragmentRecords' in incrementalDataRecord;\n}\n\nexport type CompletedExecutionGroup =\n | SuccessfulExecutionGroup\n | FailedExecutionGroup;\n\nexport function isCompletedExecutionGroup(\n incrementalDataRecordResult: IncrementalDataRecordResult,\n): incrementalDataRecordResult is CompletedExecutionGroup {\n return 'pendingExecutionGroup' in incrementalDataRecordResult;\n}\n\nexport interface SuccessfulExecutionGroup {\n pendingExecutionGroup: PendingExecutionGroup;\n path: Array;\n result: ExecutionGroupResult;\n incrementalDataRecords: ReadonlyArray | undefined;\n errors?: never;\n}\n\ninterface FailedExecutionGroup {\n pendingExecutionGroup: PendingExecutionGroup;\n path: Array;\n errors: ReadonlyArray;\n result?: never;\n}\n\nexport function isFailedExecutionGroup(\n completedExecutionGroup: CompletedExecutionGroup,\n): completedExecutionGroup is FailedExecutionGroup {\n return completedExecutionGroup.errors !== undefined;\n}\n\ntype ThunkIncrementalResult =\n | BoxedPromiseOrValue\n | (() => BoxedPromiseOrValue);\n\nexport interface PendingExecutionGroup {\n deferredFragmentRecords: ReadonlyArray;\n result: ThunkIncrementalResult;\n}\n\nexport type DeliveryGroup = DeferredFragmentRecord | StreamRecord;\n\n/** @internal */\nexport class DeferredFragmentRecord {\n path: Path | undefined;\n label: string | undefined;\n id?: string | undefined;\n parent: DeferredFragmentRecord | undefined;\n pendingExecutionGroups: Set;\n successfulExecutionGroups: Set;\n children: Set;\n\n constructor(\n path: Path | undefined,\n label: string | undefined,\n parent: DeferredFragmentRecord | undefined,\n ) {\n this.path = path;\n this.label = label;\n this.parent = parent;\n this.pendingExecutionGroups = new Set();\n this.successfulExecutionGroups = new Set();\n this.children = new Set();\n }\n}\n\nexport function isDeferredFragmentRecord(\n deliveryGroup: DeliveryGroup,\n): deliveryGroup is DeferredFragmentRecord {\n return deliveryGroup instanceof DeferredFragmentRecord;\n}\n\nexport interface StreamItemResult {\n item?: unknown;\n incrementalDataRecords?: ReadonlyArray | undefined;\n errors?: ReadonlyArray | undefined;\n}\n\nexport type StreamItemRecord = ThunkIncrementalResult;\n\nexport interface StreamRecord {\n path: Path;\n label: string | undefined;\n id?: string | undefined;\n streamItemQueue: Array;\n}\n\nexport interface StreamItemsResult {\n streamRecord: StreamRecord;\n errors?: ReadonlyArray;\n result?: StreamItemsRecordResult;\n incrementalDataRecords?: ReadonlyArray | undefined;\n}\n\nexport interface CancellableStreamRecord extends StreamRecord {\n earlyReturn: () => Promise;\n}\n\nexport function isCancellableStreamRecord(\n deliveryGroup: DeliveryGroup,\n): deliveryGroup is CancellableStreamRecord {\n return 'earlyReturn' in deliveryGroup;\n}\n\nexport type IncrementalDataRecord = PendingExecutionGroup | StreamRecord;\n\nexport type IncrementalDataRecordResult =\n | CompletedExecutionGroup\n | StreamItemsResult;\n"]} \ No newline at end of file diff --git a/execution/values.d.ts b/execution/values.d.ts new file mode 100644 index 0000000000..bbc4145cdb --- /dev/null +++ b/execution/values.d.ts @@ -0,0 +1,68 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ReadOnlyObjMap } from '../jsutils/ObjMap.js'; +import { GraphQLError } from '../error/GraphQLError.js'; +import type { DirectiveNode, FieldNode, FragmentSpreadNode, VariableDefinitionNode } from '../language/ast.js'; +import type { GraphQLField } from '../type/definition.js'; +import type { GraphQLDirective } from '../type/directives.js'; +import type { GraphQLSchema } from '../type/schema.js'; +import type { FragmentVariableValues } from './collectFields.js'; +import type { GraphQLVariableSignature } from './getVariableSignature.js'; +export interface VariableValues { + readonly sources: ReadOnlyObjMap; + readonly coerced: ReadOnlyObjMap; +} +interface VariableValueSource { + readonly signature: GraphQLVariableSignature; + readonly value?: unknown; +} +type VariableValuesOrErrors = { + variableValues: VariableValues; + errors?: never; +} | { + errors: ReadonlyArray; + variableValues?: never; +}; +/** + * Prepares an object map of variableValues of the correct type based on the + * provided variable definitions and arbitrary input. If the input cannot be + * parsed to match the variable definitions, a GraphQLError will be thrown. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +export declare function getVariableValues(schema: GraphQLSchema, varDefNodes: ReadonlyArray, inputs: { + readonly [variable: string]: unknown; +}, options?: { + maxErrors?: number; + hideSuggestions?: boolean; +}): VariableValuesOrErrors; +export declare function getFragmentVariableValues(fragmentSpreadNode: FragmentSpreadNode, fragmentSignatures: ReadOnlyObjMap, variableValues: VariableValues, fragmentVariableValues?: Maybe, hideSuggestions?: Maybe): FragmentVariableValues; +/** + * Prepares an object map of argument values given a list of argument + * definitions and list of argument AST nodes. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +export declare function getArgumentValues(def: GraphQLField | GraphQLDirective, node: FieldNode | DirectiveNode, variableValues?: Maybe, fragmentVariableValues?: Maybe, hideSuggestions?: Maybe): { + [argument: string]: unknown; +}; +/** + * Prepares an object map of argument values given a directive definition + * and a AST node which may contain directives. Optionally also accepts a map + * of variable values. + * + * If the directive does not exist on the node, returns undefined. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +export declare function getDirectiveValues(directiveDef: GraphQLDirective, node: { + readonly directives?: ReadonlyArray | undefined; +}, variableValues?: Maybe, fragmentVariableValues?: Maybe, hideSuggestions?: Maybe): undefined | { + [argument: string]: unknown; +}; +export {}; diff --git a/execution/values.js b/execution/values.js new file mode 100644 index 0000000000..1ca2b56173 --- /dev/null +++ b/execution/values.js @@ -0,0 +1,186 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getVariableValues = getVariableValues; +exports.getFragmentVariableValues = getFragmentVariableValues; +exports.getArgumentValues = getArgumentValues; +exports.getDirectiveValues = getDirectiveValues; +const invariant_js_1 = require("../jsutils/invariant.js"); +const printPathArray_js_1 = require("../jsutils/printPathArray.js"); +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +const coerceInputValue_js_1 = require("../utilities/coerceInputValue.js"); +const validateInputValue_js_1 = require("../utilities/validateInputValue.js"); +const getVariableSignature_js_1 = require("./getVariableSignature.js"); +/** + * Prepares an object map of variableValues of the correct type based on the + * provided variable definitions and arbitrary input. If the input cannot be + * parsed to match the variable definitions, a GraphQLError will be thrown. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +function getVariableValues(schema, varDefNodes, inputs, options) { + const errors = []; + const maxErrors = options?.maxErrors; + try { + const variableValues = coerceVariableValues(schema, varDefNodes, inputs, (error) => { + if (maxErrors != null && errors.length >= maxErrors) { + throw new GraphQLError_js_1.GraphQLError('Too many errors processing variables, error limit reached. Execution aborted.'); + } + errors.push(error); + }, options?.hideSuggestions); + if (errors.length === 0) { + return { variableValues }; + } + } + catch (error) { + errors.push(error); + } + return { errors }; +} +function coerceVariableValues(schema, varDefNodes, inputs, onError, hideSuggestions) { + const sources = Object.create(null); + const coerced = Object.create(null); + for (const varDefNode of varDefNodes) { + const varSignature = (0, getVariableSignature_js_1.getVariableSignature)(schema, varDefNode); + if (varSignature instanceof GraphQLError_js_1.GraphQLError) { + onError(varSignature); + continue; + } + const { name: varName, type: varType } = varSignature; + let value; + if (!Object.hasOwn(inputs, varName)) { + sources[varName] = { signature: varSignature }; + if (varDefNode.defaultValue) { + coerced[varName] = (0, coerceInputValue_js_1.coerceInputLiteral)(varDefNode.defaultValue, varType); + continue; + } + else if (!(0, definition_js_1.isNonNullType)(varType)) { + // Non-provided values for nullable variables are omitted. + continue; + } + } + else { + value = inputs[varName]; + sources[varName] = { signature: varSignature, value }; + } + const coercedValue = (0, coerceInputValue_js_1.coerceInputValue)(value, varType); + if (coercedValue !== undefined) { + coerced[varName] = coercedValue; + } + else { + (0, validateInputValue_js_1.validateInputValue)(value, varType, (error, path) => { + onError(new GraphQLError_js_1.GraphQLError(`Variable "$${varName}" has invalid value${(0, printPathArray_js_1.printPathArray)(path)}: ${error.message}`, { nodes: varDefNode, originalError: error })); + }, hideSuggestions); + } + } + return { sources, coerced }; +} +function getFragmentVariableValues(fragmentSpreadNode, fragmentSignatures, variableValues, fragmentVariableValues, hideSuggestions) { + const argumentNodes = fragmentSpreadNode.arguments ?? []; + const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg])); + const sources = Object.create(null); + const coerced = Object.create(null); + for (const [varName, varSignature] of Object.entries(fragmentSignatures)) { + sources[varName] = { + signature: varSignature, + }; + const argumentNode = argNodeMap.get(varName); + if (argumentNode !== undefined) { + const source = sources[varName]; + source.value = argumentNode.value; + source.fragmentVariableValues = fragmentVariableValues; + } + coerceArgument(coerced, fragmentSpreadNode, varName, varSignature, argumentNode, variableValues, fragmentVariableValues, hideSuggestions); + } + return { sources, coerced }; +} +/** + * Prepares an object map of argument values given a list of argument + * definitions and list of argument AST nodes. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +function getArgumentValues(def, node, variableValues, fragmentVariableValues, hideSuggestions) { + const coercedValues = {}; + const argumentNodes = node.arguments ?? []; + const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg])); + for (const argDef of def.args) { + const name = argDef.name; + coerceArgument(coercedValues, node, name, argDef, argNodeMap.get(argDef.name), variableValues, fragmentVariableValues, hideSuggestions); + } + return coercedValues; +} +// eslint-disable-next-line @typescript-eslint/max-params +function coerceArgument(coercedValues, node, argName, argDef, argumentNode, variableValues, fragmentVariableValues, hideSuggestions) { + const argType = argDef.type; + if (!argumentNode) { + if ((0, definition_js_1.isRequiredArgument)(argDef)) { + // Note: ProvidedRequiredArgumentsRule validation should catch this before + // execution. This is a runtime check to ensure execution does not + // continue with an invalid argument value. + throw new GraphQLError_js_1.GraphQLError( + // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged + `Argument "${(0, definition_js_1.isArgument)(argDef) ? argDef : argName}" of required type "${argType}" was not provided.`, { nodes: node }); + } + const coercedDefaultValue = (0, coerceInputValue_js_1.coerceDefaultValue)(argDef); + if (coercedDefaultValue !== undefined) { + coercedValues[argName] = coercedDefaultValue; + } + return; + } + const valueNode = argumentNode.value; + // Variables without a value are treated as if no argument was provided if + // the argument is not required. + if (valueNode.kind === kinds_js_1.Kind.VARIABLE) { + const variableName = valueNode.name.value; + const scopedVariableValues = fragmentVariableValues?.sources[variableName] + ? fragmentVariableValues + : variableValues; + if ((scopedVariableValues == null || + !Object.hasOwn(scopedVariableValues.coerced, variableName)) && + !(0, definition_js_1.isRequiredArgument)(argDef)) { + const coercedDefaultValue = (0, coerceInputValue_js_1.coerceDefaultValue)(argDef); + if (coercedDefaultValue !== undefined) { + coercedValues[argName] = coercedDefaultValue; + } + return; + } + } + const coercedValue = (0, coerceInputValue_js_1.coerceInputLiteral)(valueNode, argType, variableValues, fragmentVariableValues); + if (coercedValue === undefined) { + // Note: ValuesOfCorrectTypeRule validation should catch this before + // execution. This is a runtime check to ensure execution does not + // continue with an invalid argument value. + (0, validateInputValue_js_1.validateInputLiteral)(valueNode, argType, (error, path) => { + // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged + error.message = `Argument "${(0, definition_js_1.isArgument)(argDef) ? argDef : argDef.name}" has invalid value${(0, printPathArray_js_1.printPathArray)(path)}: ${error.message}`; + throw error; + }, variableValues, fragmentVariableValues, hideSuggestions); + /* c8 ignore next */ + (false) || (0, invariant_js_1.invariant)(false, 'Invalid argument'); + } + coercedValues[argName] = coercedValue; +} +/** + * Prepares an object map of argument values given a directive definition + * and a AST node which may contain directives. Optionally also accepts a map + * of variable values. + * + * If the directive does not exist on the node, returns undefined. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +function getDirectiveValues(directiveDef, node, variableValues, fragmentVariableValues, hideSuggestions) { + const directiveNode = node.directives?.find((directive) => directive.name.value === directiveDef.name); + if (directiveNode) { + return getArgumentValues(directiveDef, directiveNode, variableValues, fragmentVariableValues, hideSuggestions); + } +} +//# sourceMappingURL=values.js.map \ No newline at end of file diff --git a/execution/values.js.map b/execution/values.js.map new file mode 100644 index 0000000000..8fc848cdf1 --- /dev/null +++ b/execution/values.js.map @@ -0,0 +1 @@ +{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/execution/values.ts"],"names":[],"mappings":";;AA+DA,8CAgCC;AA4DD,8DAmCC;AAUD,8CA0BC;AA+FD,gDAoBC;AArVD,0DAAoD;AAGpD,oEAA8D;AAE9D,8DAAwD;AAUxD,mDAA4C;AAG5C,yDAI+B;AAI/B,0EAI0C;AAC1C,8EAG4C;AAI5C,uEAAiE;AAgBjE;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAC/B,MAAqB,EACrB,WAAkD,EAClD,MAAgD,EAChD,OAA2D;IAE3D,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,cAAc,GAAG,oBAAoB,CACzC,MAAM,EACN,WAAW,EACX,MAAM,EACN,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,SAAS,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;gBACpD,MAAM,IAAI,8BAAY,CACpB,+EAA+E,CAChF,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,EACD,OAAO,EAAE,eAAe,CACzB,CAAC;QAEF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,EAAE,cAAc,EAAE,CAAC;QAC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B,YAAY,EACZ,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,eAAe,CAChB,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap, ReadOnlyObjMap } from '../jsutils/ObjMap.js';\nimport { printPathArray } from '../jsutils/printPathArray.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ArgumentNode,\n DirectiveNode,\n FieldNode,\n FragmentArgumentNode,\n FragmentSpreadNode,\n VariableDefinitionNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLArgument, GraphQLField } from '../type/definition.js';\nimport {\n isArgument,\n isNonNullType,\n isRequiredArgument,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport {\n coerceDefaultValue,\n coerceInputLiteral,\n coerceInputValue,\n} from '../utilities/coerceInputValue.js';\nimport {\n validateInputLiteral,\n validateInputValue,\n} from '../utilities/validateInputValue.js';\n\nimport type { FragmentVariableValues } from './collectFields.js';\nimport type { GraphQLVariableSignature } from './getVariableSignature.js';\nimport { getVariableSignature } from './getVariableSignature.js';\n\nexport interface VariableValues {\n readonly sources: ReadOnlyObjMap;\n readonly coerced: ReadOnlyObjMap;\n}\n\ninterface VariableValueSource {\n readonly signature: GraphQLVariableSignature;\n readonly value?: unknown;\n}\n\ntype VariableValuesOrErrors =\n | { variableValues: VariableValues; errors?: never }\n | { errors: ReadonlyArray; variableValues?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getVariableValues(\n schema: GraphQLSchema,\n varDefNodes: ReadonlyArray,\n inputs: { readonly [variable: string]: unknown },\n options?: { maxErrors?: number; hideSuggestions?: boolean },\n): VariableValuesOrErrors {\n const errors: Array = [];\n const maxErrors = options?.maxErrors;\n try {\n const variableValues = coerceVariableValues(\n schema,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n 'Too many errors processing variables, error limit reached. Execution aborted.',\n );\n }\n errors.push(error);\n },\n options?.hideSuggestions,\n );\n\n if (errors.length === 0) {\n return { variableValues };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return { errors };\n}\n\nfunction coerceVariableValues(\n schema: GraphQLSchema,\n varDefNodes: ReadonlyArray,\n inputs: { readonly [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n hideSuggestions?: Maybe,\n): VariableValues {\n const sources: ObjMap = Object.create(null);\n const coerced: ObjMap = Object.create(null);\n for (const varDefNode of varDefNodes) {\n const varSignature = getVariableSignature(schema, varDefNode);\n\n if (varSignature instanceof GraphQLError) {\n onError(varSignature);\n continue;\n }\n\n const { name: varName, type: varType } = varSignature;\n let value: unknown;\n if (!Object.hasOwn(inputs, varName)) {\n sources[varName] = { signature: varSignature };\n if (varDefNode.defaultValue) {\n coerced[varName] = coerceInputLiteral(varDefNode.defaultValue, varType);\n continue;\n } else if (!isNonNullType(varType)) {\n // Non-provided values for nullable variables are omitted.\n continue;\n }\n } else {\n value = inputs[varName];\n sources[varName] = { signature: varSignature, value };\n }\n\n const coercedValue = coerceInputValue(value, varType);\n if (coercedValue !== undefined) {\n coerced[varName] = coercedValue;\n } else {\n validateInputValue(\n value,\n varType,\n (error, path) => {\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" has invalid value${printPathArray(path)}: ${\n error.message\n }`,\n { nodes: varDefNode, originalError: error },\n ),\n );\n },\n hideSuggestions,\n );\n }\n }\n\n return { sources, coerced };\n}\n\nexport function getFragmentVariableValues(\n fragmentSpreadNode: FragmentSpreadNode,\n fragmentSignatures: ReadOnlyObjMap,\n variableValues: VariableValues,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): FragmentVariableValues {\n const argumentNodes = fragmentSpreadNode.arguments ?? [];\n const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));\n const sources = Object.create(null);\n const coerced = Object.create(null);\n for (const [varName, varSignature] of Object.entries(fragmentSignatures)) {\n sources[varName] = {\n signature: varSignature,\n };\n const argumentNode = argNodeMap.get(varName);\n if (argumentNode !== undefined) {\n const source = sources[varName];\n source.value = argumentNode.value;\n source.fragmentVariableValues = fragmentVariableValues;\n }\n\n coerceArgument(\n coerced,\n fragmentSpreadNode,\n varName,\n varSignature,\n argumentNode,\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n\n return { sources, coerced };\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getArgumentValues(\n def: GraphQLField | GraphQLDirective,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n const argumentNodes = node.arguments ?? [];\n const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));\n\n for (const argDef of def.args) {\n const name = argDef.name;\n coerceArgument(\n coercedValues,\n node,\n name,\n argDef,\n argNodeMap.get(argDef.name),\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n return coercedValues;\n}\n\n// eslint-disable-next-line @typescript-eslint/max-params\nfunction coerceArgument(\n coercedValues: ObjMap,\n node: FieldNode | DirectiveNode | FragmentSpreadNode,\n argName: string,\n argDef: GraphQLArgument | GraphQLVariableSignature,\n argumentNode: ArgumentNode | FragmentArgumentNode | undefined,\n variableValues: Maybe,\n fragmentVariableValues: Maybe,\n hideSuggestions?: Maybe,\n): void {\n const argType = argDef.type;\n\n if (!argumentNode) {\n if (isRequiredArgument(argDef)) {\n // Note: ProvidedRequiredArgumentsRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged\n `Argument \"${isArgument(argDef) ? argDef : argName}\" of required type \"${argType}\" was not provided.`,\n { nodes: node },\n );\n }\n const coercedDefaultValue = coerceDefaultValue(argDef);\n if (coercedDefaultValue !== undefined) {\n coercedValues[argName] = coercedDefaultValue;\n }\n return;\n }\n\n const valueNode = argumentNode.value;\n\n // Variables without a value are treated as if no argument was provided if\n // the argument is not required.\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n const scopedVariableValues = fragmentVariableValues?.sources[variableName]\n ? fragmentVariableValues\n : variableValues;\n if (\n (scopedVariableValues == null ||\n !Object.hasOwn(scopedVariableValues.coerced, variableName)) &&\n !isRequiredArgument(argDef)\n ) {\n const coercedDefaultValue = coerceDefaultValue(argDef);\n if (coercedDefaultValue !== undefined) {\n coercedValues[argName] = coercedDefaultValue;\n }\n return;\n }\n }\n const coercedValue = coerceInputLiteral(\n valueNode,\n argType,\n variableValues,\n fragmentVariableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n validateInputLiteral(\n valueNode,\n argType,\n (error, path) => {\n // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged\n error.message = `Argument \"${isArgument(argDef) ? argDef : argDef.name}\" has invalid value${printPathArray(\n path,\n )}: ${error.message}`;\n throw error;\n },\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n /* c8 ignore next */\n invariant(false, 'Invalid argument');\n }\n coercedValues[argName] = coercedValue;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n directiveDef: GraphQLDirective,\n node: { readonly directives?: ReadonlyArray | undefined },\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): undefined | { [argument: string]: unknown } {\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(\n directiveDef,\n directiveNode,\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n}\n"]} \ No newline at end of file diff --git a/execution/values.mjs b/execution/values.mjs new file mode 100644 index 0000000000..c3b05aade6 --- /dev/null +++ b/execution/values.mjs @@ -0,0 +1,180 @@ +import { invariant } from "../jsutils/invariant.mjs"; +import { printPathArray } from "../jsutils/printPathArray.mjs"; +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { isArgument, isNonNullType, isRequiredArgument, } from "../type/definition.mjs"; +import { coerceDefaultValue, coerceInputLiteral, coerceInputValue, } from "../utilities/coerceInputValue.mjs"; +import { validateInputLiteral, validateInputValue, } from "../utilities/validateInputValue.mjs"; +import { getVariableSignature } from "./getVariableSignature.mjs"; +/** + * Prepares an object map of variableValues of the correct type based on the + * provided variable definitions and arbitrary input. If the input cannot be + * parsed to match the variable definitions, a GraphQLError will be thrown. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +export function getVariableValues(schema, varDefNodes, inputs, options) { + const errors = []; + const maxErrors = options?.maxErrors; + try { + const variableValues = coerceVariableValues(schema, varDefNodes, inputs, (error) => { + if (maxErrors != null && errors.length >= maxErrors) { + throw new GraphQLError('Too many errors processing variables, error limit reached. Execution aborted.'); + } + errors.push(error); + }, options?.hideSuggestions); + if (errors.length === 0) { + return { variableValues }; + } + } + catch (error) { + errors.push(error); + } + return { errors }; +} +function coerceVariableValues(schema, varDefNodes, inputs, onError, hideSuggestions) { + const sources = Object.create(null); + const coerced = Object.create(null); + for (const varDefNode of varDefNodes) { + const varSignature = getVariableSignature(schema, varDefNode); + if (varSignature instanceof GraphQLError) { + onError(varSignature); + continue; + } + const { name: varName, type: varType } = varSignature; + let value; + if (!Object.hasOwn(inputs, varName)) { + sources[varName] = { signature: varSignature }; + if (varDefNode.defaultValue) { + coerced[varName] = coerceInputLiteral(varDefNode.defaultValue, varType); + continue; + } + else if (!isNonNullType(varType)) { + // Non-provided values for nullable variables are omitted. + continue; + } + } + else { + value = inputs[varName]; + sources[varName] = { signature: varSignature, value }; + } + const coercedValue = coerceInputValue(value, varType); + if (coercedValue !== undefined) { + coerced[varName] = coercedValue; + } + else { + validateInputValue(value, varType, (error, path) => { + onError(new GraphQLError(`Variable "$${varName}" has invalid value${printPathArray(path)}: ${error.message}`, { nodes: varDefNode, originalError: error })); + }, hideSuggestions); + } + } + return { sources, coerced }; +} +export function getFragmentVariableValues(fragmentSpreadNode, fragmentSignatures, variableValues, fragmentVariableValues, hideSuggestions) { + const argumentNodes = fragmentSpreadNode.arguments ?? []; + const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg])); + const sources = Object.create(null); + const coerced = Object.create(null); + for (const [varName, varSignature] of Object.entries(fragmentSignatures)) { + sources[varName] = { + signature: varSignature, + }; + const argumentNode = argNodeMap.get(varName); + if (argumentNode !== undefined) { + const source = sources[varName]; + source.value = argumentNode.value; + source.fragmentVariableValues = fragmentVariableValues; + } + coerceArgument(coerced, fragmentSpreadNode, varName, varSignature, argumentNode, variableValues, fragmentVariableValues, hideSuggestions); + } + return { sources, coerced }; +} +/** + * Prepares an object map of argument values given a list of argument + * definitions and list of argument AST nodes. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +export function getArgumentValues(def, node, variableValues, fragmentVariableValues, hideSuggestions) { + const coercedValues = {}; + const argumentNodes = node.arguments ?? []; + const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg])); + for (const argDef of def.args) { + const name = argDef.name; + coerceArgument(coercedValues, node, name, argDef, argNodeMap.get(argDef.name), variableValues, fragmentVariableValues, hideSuggestions); + } + return coercedValues; +} +// eslint-disable-next-line @typescript-eslint/max-params +function coerceArgument(coercedValues, node, argName, argDef, argumentNode, variableValues, fragmentVariableValues, hideSuggestions) { + const argType = argDef.type; + if (!argumentNode) { + if (isRequiredArgument(argDef)) { + // Note: ProvidedRequiredArgumentsRule validation should catch this before + // execution. This is a runtime check to ensure execution does not + // continue with an invalid argument value. + throw new GraphQLError( + // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged + `Argument "${isArgument(argDef) ? argDef : argName}" of required type "${argType}" was not provided.`, { nodes: node }); + } + const coercedDefaultValue = coerceDefaultValue(argDef); + if (coercedDefaultValue !== undefined) { + coercedValues[argName] = coercedDefaultValue; + } + return; + } + const valueNode = argumentNode.value; + // Variables without a value are treated as if no argument was provided if + // the argument is not required. + if (valueNode.kind === Kind.VARIABLE) { + const variableName = valueNode.name.value; + const scopedVariableValues = fragmentVariableValues?.sources[variableName] + ? fragmentVariableValues + : variableValues; + if ((scopedVariableValues == null || + !Object.hasOwn(scopedVariableValues.coerced, variableName)) && + !isRequiredArgument(argDef)) { + const coercedDefaultValue = coerceDefaultValue(argDef); + if (coercedDefaultValue !== undefined) { + coercedValues[argName] = coercedDefaultValue; + } + return; + } + } + const coercedValue = coerceInputLiteral(valueNode, argType, variableValues, fragmentVariableValues); + if (coercedValue === undefined) { + // Note: ValuesOfCorrectTypeRule validation should catch this before + // execution. This is a runtime check to ensure execution does not + // continue with an invalid argument value. + validateInputLiteral(valueNode, argType, (error, path) => { + // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged + error.message = `Argument "${isArgument(argDef) ? argDef : argDef.name}" has invalid value${printPathArray(path)}: ${error.message}`; + throw error; + }, variableValues, fragmentVariableValues, hideSuggestions); + /* c8 ignore next */ + (false) || invariant(false, 'Invalid argument'); + } + coercedValues[argName] = coercedValue; +} +/** + * Prepares an object map of argument values given a directive definition + * and a AST node which may contain directives. Optionally also accepts a map + * of variable values. + * + * If the directive does not exist on the node, returns undefined. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +export function getDirectiveValues(directiveDef, node, variableValues, fragmentVariableValues, hideSuggestions) { + const directiveNode = node.directives?.find((directive) => directive.name.value === directiveDef.name); + if (directiveNode) { + return getArgumentValues(directiveDef, directiveNode, variableValues, fragmentVariableValues, hideSuggestions); + } +} +//# sourceMappingURL=values.js.map \ No newline at end of file diff --git a/execution/values.mjs.map b/execution/values.mjs.map new file mode 100644 index 0000000000..37ea916377 --- /dev/null +++ b/execution/values.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/execution/values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAGpD,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAE9D,OAAO,EAAE,YAAY,EAAE,kCAAiC;AAUxD,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAG5C,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,GACnB,+BAA8B;AAI/B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,0CAAyC;AAC1C,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,4CAA2C;AAI5C,OAAO,EAAE,oBAAoB,EAAE,mCAAkC;AAgBjE;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAqB,EACrB,WAAkD,EAClD,MAAgD,EAChD,OAA2D;IAE3D,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,CAAC;IACrC,IAAI,CAAC;QACH,M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;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAChC,YAA8B,EAC9B,IAAwE,EACxE,cAAsC,EACtC,sBAAsD,EACtD,eAAgC;IAEhC,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CACzC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,YAAY,CAAC,IAAI,CAC1D,CAAC;IAEF,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,iBAAiB,CACtB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,eAAe,CAChB,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap, ReadOnlyObjMap } from '../jsutils/ObjMap.js';\nimport { printPathArray } from '../jsutils/printPathArray.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ArgumentNode,\n DirectiveNode,\n FieldNode,\n FragmentArgumentNode,\n FragmentSpreadNode,\n VariableDefinitionNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLArgument, GraphQLField } from '../type/definition.js';\nimport {\n isArgument,\n isNonNullType,\n isRequiredArgument,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport {\n coerceDefaultValue,\n coerceInputLiteral,\n coerceInputValue,\n} from '../utilities/coerceInputValue.js';\nimport {\n validateInputLiteral,\n validateInputValue,\n} from '../utilities/validateInputValue.js';\n\nimport type { FragmentVariableValues } from './collectFields.js';\nimport type { GraphQLVariableSignature } from './getVariableSignature.js';\nimport { getVariableSignature } from './getVariableSignature.js';\n\nexport interface VariableValues {\n readonly sources: ReadOnlyObjMap;\n readonly coerced: ReadOnlyObjMap;\n}\n\ninterface VariableValueSource {\n readonly signature: GraphQLVariableSignature;\n readonly value?: unknown;\n}\n\ntype VariableValuesOrErrors =\n | { variableValues: VariableValues; errors?: never }\n | { errors: ReadonlyArray; variableValues?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getVariableValues(\n schema: GraphQLSchema,\n varDefNodes: ReadonlyArray,\n inputs: { readonly [variable: string]: unknown },\n options?: { maxErrors?: number; hideSuggestions?: boolean },\n): VariableValuesOrErrors {\n const errors: Array = [];\n const maxErrors = options?.maxErrors;\n try {\n const variableValues = coerceVariableValues(\n schema,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n 'Too many errors processing variables, error limit reached. Execution aborted.',\n );\n }\n errors.push(error);\n },\n options?.hideSuggestions,\n );\n\n if (errors.length === 0) {\n return { variableValues };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return { errors };\n}\n\nfunction coerceVariableValues(\n schema: GraphQLSchema,\n varDefNodes: ReadonlyArray,\n inputs: { readonly [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n hideSuggestions?: Maybe,\n): VariableValues {\n const sources: ObjMap = Object.create(null);\n const coerced: ObjMap = Object.create(null);\n for (const varDefNode of varDefNodes) {\n const varSignature = getVariableSignature(schema, varDefNode);\n\n if (varSignature instanceof GraphQLError) {\n onError(varSignature);\n continue;\n }\n\n const { name: varName, type: varType } = varSignature;\n let value: unknown;\n if (!Object.hasOwn(inputs, varName)) {\n sources[varName] = { signature: varSignature };\n if (varDefNode.defaultValue) {\n coerced[varName] = coerceInputLiteral(varDefNode.defaultValue, varType);\n continue;\n } else if (!isNonNullType(varType)) {\n // Non-provided values for nullable variables are omitted.\n continue;\n }\n } else {\n value = inputs[varName];\n sources[varName] = { signature: varSignature, value };\n }\n\n const coercedValue = coerceInputValue(value, varType);\n if (coercedValue !== undefined) {\n coerced[varName] = coercedValue;\n } else {\n validateInputValue(\n value,\n varType,\n (error, path) => {\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" has invalid value${printPathArray(path)}: ${\n error.message\n }`,\n { nodes: varDefNode, originalError: error },\n ),\n );\n },\n hideSuggestions,\n );\n }\n }\n\n return { sources, coerced };\n}\n\nexport function getFragmentVariableValues(\n fragmentSpreadNode: FragmentSpreadNode,\n fragmentSignatures: ReadOnlyObjMap,\n variableValues: VariableValues,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): FragmentVariableValues {\n const argumentNodes = fragmentSpreadNode.arguments ?? [];\n const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));\n const sources = Object.create(null);\n const coerced = Object.create(null);\n for (const [varName, varSignature] of Object.entries(fragmentSignatures)) {\n sources[varName] = {\n signature: varSignature,\n };\n const argumentNode = argNodeMap.get(varName);\n if (argumentNode !== undefined) {\n const source = sources[varName];\n source.value = argumentNode.value;\n source.fragmentVariableValues = fragmentVariableValues;\n }\n\n coerceArgument(\n coerced,\n fragmentSpreadNode,\n varName,\n varSignature,\n argumentNode,\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n\n return { sources, coerced };\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getArgumentValues(\n def: GraphQLField | GraphQLDirective,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n const argumentNodes = node.arguments ?? [];\n const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));\n\n for (const argDef of def.args) {\n const name = argDef.name;\n coerceArgument(\n coercedValues,\n node,\n name,\n argDef,\n argNodeMap.get(argDef.name),\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n return coercedValues;\n}\n\n// eslint-disable-next-line @typescript-eslint/max-params\nfunction coerceArgument(\n coercedValues: ObjMap,\n node: FieldNode | DirectiveNode | FragmentSpreadNode,\n argName: string,\n argDef: GraphQLArgument | GraphQLVariableSignature,\n argumentNode: ArgumentNode | FragmentArgumentNode | undefined,\n variableValues: Maybe,\n fragmentVariableValues: Maybe,\n hideSuggestions?: Maybe,\n): void {\n const argType = argDef.type;\n\n if (!argumentNode) {\n if (isRequiredArgument(argDef)) {\n // Note: ProvidedRequiredArgumentsRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged\n `Argument \"${isArgument(argDef) ? argDef : argName}\" of required type \"${argType}\" was not provided.`,\n { nodes: node },\n );\n }\n const coercedDefaultValue = coerceDefaultValue(argDef);\n if (coercedDefaultValue !== undefined) {\n coercedValues[argName] = coercedDefaultValue;\n }\n return;\n }\n\n const valueNode = argumentNode.value;\n\n // Variables without a value are treated as if no argument was provided if\n // the argument is not required.\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n const scopedVariableValues = fragmentVariableValues?.sources[variableName]\n ? fragmentVariableValues\n : variableValues;\n if (\n (scopedVariableValues == null ||\n !Object.hasOwn(scopedVariableValues.coerced, variableName)) &&\n !isRequiredArgument(argDef)\n ) {\n const coercedDefaultValue = coerceDefaultValue(argDef);\n if (coercedDefaultValue !== undefined) {\n coercedValues[argName] = coercedDefaultValue;\n }\n return;\n }\n }\n const coercedValue = coerceInputLiteral(\n valueNode,\n argType,\n variableValues,\n fragmentVariableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n validateInputLiteral(\n valueNode,\n argType,\n (error, path) => {\n // TODO: clean up the naming of isRequiredArgument(), isArgument(), and argDef if/when experimental fragment variables are merged\n error.message = `Argument \"${isArgument(argDef) ? argDef : argDef.name}\" has invalid value${printPathArray(\n path,\n )}: ${error.message}`;\n throw error;\n },\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n /* c8 ignore next */\n invariant(false, 'Invalid argument');\n }\n coercedValues[argName] = coercedValue;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n directiveDef: GraphQLDirective,\n node: { readonly directives?: ReadonlyArray | undefined },\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): undefined | { [argument: string]: unknown } {\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(\n directiveDef,\n directiveNode,\n variableValues,\n fragmentVariableValues,\n hideSuggestions,\n );\n }\n}\n"]} \ No newline at end of file diff --git a/graphql.d.ts b/graphql.d.ts new file mode 100644 index 0000000000..7c9148d9be --- /dev/null +++ b/graphql.d.ts @@ -0,0 +1,68 @@ +import type { Maybe } from './jsutils/Maybe.js'; +import type { Source } from './language/source.js'; +import type { GraphQLFieldResolver, GraphQLTypeResolver } from './type/definition.js'; +import type { GraphQLSchema } from './type/schema.js'; +import type { ExecutionResult } from './execution/types.js'; +/** + * This is the primary entry point function for fulfilling GraphQL operations + * by parsing, validating, and executing a GraphQL document along side a + * GraphQL schema. + * + * More sophisticated GraphQL servers, such as those which persist queries, + * may wish to separate the validation and execution phases to a static time + * tooling step, and a server runtime step. + * + * This function does not support incremental delivery (`@defer` and `@stream`). + * + * Accepts either an object with named arguments, or individual arguments: + * + * schema: + * The GraphQL type system to use when validating and executing a query. + * source: + * A GraphQL language formatted string representing the requested operation. + * rootValue: + * The value provided as the first argument to resolver functions on the top + * level type (e.g. the query object type). + * contextValue: + * The context value is provided as an argument to resolver functions after + * field arguments. It is used to pass shared information useful at any point + * during executing this query, for example the currently logged in user and + * connections to databases or other services. + * variableValues: + * A mapping of variable name to runtime value to use for all variables + * defined in the requestString. + * operationName: + * The name of the operation to use if requestString contains multiple + * possible operations. Can be omitted if requestString contains only + * one operation. + * fieldResolver: + * A resolver function to use when one is not provided by the schema. + * If not provided, the default field resolver is used (which looks for a + * value or method on the source value with the field's name). + * typeResolver: + * A type resolver function to use when none is provided by the schema. + * If not provided, the default type resolver is used (which looks for a + * `__typename` field or alternatively calls the `isTypeOf` method). + */ +export interface GraphQLArgs { + schema: GraphQLSchema; + source: string | Source; + hideSuggestions?: Maybe; + rootValue?: unknown; + contextValue?: unknown; + variableValues?: Maybe<{ + readonly [variable: string]: unknown; + }>; + operationName?: Maybe; + fieldResolver?: Maybe>; + typeResolver?: Maybe>; + abortSignal?: Maybe; +} +export declare function graphql(args: GraphQLArgs): Promise; +/** + * The graphqlSync function also fulfills GraphQL operations by parsing, + * validating, and executing a GraphQL document along side a GraphQL schema. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ +export declare function graphqlSync(args: GraphQLArgs): ExecutionResult; diff --git a/graphql.js b/graphql.js new file mode 100644 index 0000000000..49b0d872ec --- /dev/null +++ b/graphql.js @@ -0,0 +1,63 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.graphql = graphql; +exports.graphqlSync = graphqlSync; +const isPromise_js_1 = require("./jsutils/isPromise.js"); +const parser_js_1 = require("./language/parser.js"); +const validate_js_1 = require("./type/validate.js"); +const validate_js_2 = require("./validation/validate.js"); +const execute_js_1 = require("./execution/execute.js"); +function graphql(args) { + // Always return a Promise for a consistent API. + return new Promise((resolve) => resolve(graphqlImpl(args))); +} +/** + * The graphqlSync function also fulfills GraphQL operations by parsing, + * validating, and executing a GraphQL document along side a GraphQL schema. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ +function graphqlSync(args) { + const result = graphqlImpl(args); + // Assert that the execution was synchronous. + if ((0, isPromise_js_1.isPromise)(result)) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + return result; +} +function graphqlImpl(args) { + const { schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, hideSuggestions, } = args; + // Validate Schema + const schemaValidationErrors = (0, validate_js_1.validateSchema)(schema); + if (schemaValidationErrors.length > 0) { + return { errors: schemaValidationErrors }; + } + // Parse + let document; + try { + document = (0, parser_js_1.parse)(source); + } + catch (syntaxError) { + return { errors: [syntaxError] }; + } + // Validate + const validationErrors = (0, validate_js_2.validate)(schema, document, undefined, { + hideSuggestions, + }); + if (validationErrors.length > 0) { + return { errors: validationErrors }; + } + // Execute + return (0, execute_js_1.execute)({ + schema, + document, + rootValue, + contextValue, + variableValues, + operationName, + fieldResolver, + typeResolver, + hideSuggestions, + }); +} +//# sourceMappingURL=graphql.js.map \ No newline at end of file diff --git a/graphql.js.map b/graphql.js.map new file mode 100644 index 0000000000..059a85fe0c --- /dev/null +++ b/graphql.js.map @@ -0,0 +1 @@ +{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":";;AAyEA,0BAGC;AAQD,kCASC;AA7FD,yDAAmD;AAInD,oDAA6C;AAQ7C,oDAAoD;AAEpD,0DAAoD;AAEpD,uDAAiD;AAyDjD,SAAgB,OAAO,CAAC,IAAiB;IACvC,gDAAgD;IAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,IAAiB;IAC3C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAEjC,6CAA6C;IAC7C,IAAI,IAAA,wBAAS,EAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,IAAiB;IACpC,MAAM,EACJ,MAAM,EACN,MAAM,EACN,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,GAChB,GAAG,IAAI,CAAC;IAET,kBAAkB;IAClB,MAAM,sBAAsB,GAAG,IAAA,4BAAc,EAAC,MAAM,CAAC,CAAC;IACtD,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC;IAC5C,CAAC;IAED,QAAQ;IACR,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC;QACH,QAAQ,GAAG,IAAA,iBAAK,EAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,WAAW,EAAE,CAAC;QACrB,OAAO,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;IACnC,CAAC;IAED,WAAW;IACX,MAAM,gBAAgB,GAAG,IAAA,sBAAQ,EAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE;QAC7D,eAAe;KAChB,CAAC,CAAC;IACH,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;IACtC,CAAC;IAED,UAAU;IACV,OAAO,IAAA,oBAAO,EAAC;QACb,MAAM;QACN,QAAQ;QACR,SAAS;QACT,YAAY;QACZ,cAAc;QACd,aAAa;QACb,aAAa;QACb,YAAY;QACZ,eAAe;KAChB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isPromise } from './jsutils/isPromise.js';\nimport type { Maybe } from './jsutils/Maybe.js';\nimport type { PromiseOrValue } from './jsutils/PromiseOrValue.js';\n\nimport { parse } from './language/parser.js';\nimport type { Source } from './language/source.js';\n\nimport type {\n GraphQLFieldResolver,\n GraphQLTypeResolver,\n} from './type/definition.js';\nimport type { GraphQLSchema } from './type/schema.js';\nimport { validateSchema } from './type/validate.js';\n\nimport { validate } from './validation/validate.js';\n\nimport { execute } from './execution/execute.js';\nimport type { ExecutionResult } from './execution/types.js';\n\n/**\n * This is the primary entry point function for fulfilling GraphQL operations\n * by parsing, validating, and executing a GraphQL document along side a\n * GraphQL schema.\n *\n * More sophisticated GraphQL servers, such as those which persist queries,\n * may wish to separate the validation and execution phases to a static time\n * tooling step, and a server runtime step.\n *\n * This function does not support incremental delivery (`@defer` and `@stream`).\n *\n * Accepts either an object with named arguments, or individual arguments:\n *\n * schema:\n * The GraphQL type system to use when validating and executing a query.\n * source:\n * A GraphQL language formatted string representing the requested operation.\n * rootValue:\n * The value provided as the first argument to resolver functions on the top\n * level type (e.g. the query object type).\n * contextValue:\n * The context value is provided as an argument to resolver functions after\n * field arguments. It is used to pass shared information useful at any point\n * during executing this query, for example the currently logged in user and\n * connections to databases or other services.\n * variableValues:\n * A mapping of variable name to runtime value to use for all variables\n * defined in the requestString.\n * operationName:\n * The name of the operation to use if requestString contains multiple\n * possible operations. Can be omitted if requestString contains only\n * one operation.\n * fieldResolver:\n * A resolver function to use when one is not provided by the schema.\n * If not provided, the default field resolver is used (which looks for a\n * value or method on the source value with the field's name).\n * typeResolver:\n * A type resolver function to use when none is provided by the schema.\n * If not provided, the default type resolver is used (which looks for a\n * `__typename` field or alternatively calls the `isTypeOf` method).\n */\nexport interface GraphQLArgs {\n schema: GraphQLSchema;\n source: string | Source;\n hideSuggestions?: Maybe;\n rootValue?: unknown;\n contextValue?: unknown;\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>;\n operationName?: Maybe;\n fieldResolver?: Maybe>;\n typeResolver?: Maybe>;\n abortSignal?: Maybe;\n}\n\nexport function graphql(args: GraphQLArgs): Promise {\n // Always return a Promise for a consistent API.\n return new Promise((resolve) => resolve(graphqlImpl(args)));\n}\n\n/**\n * The graphqlSync function also fulfills GraphQL operations by parsing,\n * validating, and executing a GraphQL document along side a GraphQL schema.\n * However, it guarantees to complete synchronously (or throw an error) assuming\n * that all field resolvers are also synchronous.\n */\nexport function graphqlSync(args: GraphQLArgs): ExecutionResult {\n const result = graphqlImpl(args);\n\n // Assert that the execution was synchronous.\n if (isPromise(result)) {\n throw new Error('GraphQL execution failed to complete synchronously.');\n }\n\n return result;\n}\n\nfunction graphqlImpl(args: GraphQLArgs): PromiseOrValue {\n const {\n schema,\n source,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n hideSuggestions,\n } = args;\n\n // Validate Schema\n const schemaValidationErrors = validateSchema(schema);\n if (schemaValidationErrors.length > 0) {\n return { errors: schemaValidationErrors };\n }\n\n // Parse\n let document;\n try {\n document = parse(source);\n } catch (syntaxError) {\n return { errors: [syntaxError] };\n }\n\n // Validate\n const validationErrors = validate(schema, document, undefined, {\n hideSuggestions,\n });\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n\n // Execute\n return execute({\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n hideSuggestions,\n });\n}\n"]} \ No newline at end of file diff --git a/graphql.mjs b/graphql.mjs new file mode 100644 index 0000000000..4def690bcd --- /dev/null +++ b/graphql.mjs @@ -0,0 +1,59 @@ +import { isPromise } from "./jsutils/isPromise.mjs"; +import { parse } from "./language/parser.mjs"; +import { validateSchema } from "./type/validate.mjs"; +import { validate } from "./validation/validate.mjs"; +import { execute } from "./execution/execute.mjs"; +export function graphql(args) { + // Always return a Promise for a consistent API. + return new Promise((resolve) => resolve(graphqlImpl(args))); +} +/** + * The graphqlSync function also fulfills GraphQL operations by parsing, + * validating, and executing a GraphQL document along side a GraphQL schema. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ +export function graphqlSync(args) { + const result = graphqlImpl(args); + // Assert that the execution was synchronous. + if (isPromise(result)) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + return result; +} +function graphqlImpl(args) { + const { schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, hideSuggestions, } = args; + // Validate Schema + const schemaValidationErrors = validateSchema(schema); + if (schemaValidationErrors.length > 0) { + return { errors: schemaValidationErrors }; + } + // Parse + let document; + try { + document = parse(source); + } + catch (syntaxError) { + return { errors: [syntaxError] }; + } + // Validate + const validationErrors = validate(schema, document, undefined, { + hideSuggestions, + }); + if (validationErrors.length > 0) { + return { errors: validationErrors }; + } + // Execute + return execute({ + schema, + document, + rootValue, + contextValue, + variableValues, + operationName, + fieldResolver, + typeResolver, + hideSuggestions, + }); +} +//# sourceMappingURL=graphql.mjs.map \ No newline at end of file diff --git a/graphql.mjs.map b/graphql.mjs.map new file mode 100644 index 0000000000..1db0658eef --- /dev/null +++ b/graphql.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAInD,OAAO,EAAE,KAAK,EAAE,8BAA6B;AAQ7C,OAAO,EAAE,cAAc,EAAE,4BAA2B;AAEpD,OAAO,EAAE,QAAQ,EAAE,kCAAiC;AAEpD,OAAO,EAAE,OAAO,EAAE,gCAA+B;AAyDjD,MAAM,UAAU,OAAO,CAAC,IAAiB;IACvC,gDAAgD;IAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAiB;IAC3C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAEjC,6CAA6C;IAC7C,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,IAAiB;IACpC,MAAM,EACJ,MAAM,EACN,MAAM,EACN,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,GAChB,GAAG,IAAI,CAAC;IAET,kBAAkB;IAClB,MAAM,sBAAsB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC;IAC5C,CAAC;IAED,QAAQ;IACR,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC;QACH,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,WAAW,EAAE,CAAC;QACrB,OAAO,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;IACnC,CAAC;IAED,WAAW;IACX,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE;QAC7D,eAAe;KAChB,CAAC,CAAC;IACH,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;IACtC,CAAC;IAED,UAAU;IACV,OAAO,OAAO,CAAC;QACb,MAAM;QACN,QAAQ;QACR,SAAS;QACT,YAAY;QACZ,cAAc;QACd,aAAa;QACb,aAAa;QACb,YAAY;QACZ,eAAe;KAChB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isPromise } from './jsutils/isPromise.js';\nimport type { Maybe } from './jsutils/Maybe.js';\nimport type { PromiseOrValue } from './jsutils/PromiseOrValue.js';\n\nimport { parse } from './language/parser.js';\nimport type { Source } from './language/source.js';\n\nimport type {\n GraphQLFieldResolver,\n GraphQLTypeResolver,\n} from './type/definition.js';\nimport type { GraphQLSchema } from './type/schema.js';\nimport { validateSchema } from './type/validate.js';\n\nimport { validate } from './validation/validate.js';\n\nimport { execute } from './execution/execute.js';\nimport type { ExecutionResult } from './execution/types.js';\n\n/**\n * This is the primary entry point function for fulfilling GraphQL operations\n * by parsing, validating, and executing a GraphQL document along side a\n * GraphQL schema.\n *\n * More sophisticated GraphQL servers, such as those which persist queries,\n * may wish to separate the validation and execution phases to a static time\n * tooling step, and a server runtime step.\n *\n * This function does not support incremental delivery (`@defer` and `@stream`).\n *\n * Accepts either an object with named arguments, or individual arguments:\n *\n * schema:\n * The GraphQL type system to use when validating and executing a query.\n * source:\n * A GraphQL language formatted string representing the requested operation.\n * rootValue:\n * The value provided as the first argument to resolver functions on the top\n * level type (e.g. the query object type).\n * contextValue:\n * The context value is provided as an argument to resolver functions after\n * field arguments. It is used to pass shared information useful at any point\n * during executing this query, for example the currently logged in user and\n * connections to databases or other services.\n * variableValues:\n * A mapping of variable name to runtime value to use for all variables\n * defined in the requestString.\n * operationName:\n * The name of the operation to use if requestString contains multiple\n * possible operations. Can be omitted if requestString contains only\n * one operation.\n * fieldResolver:\n * A resolver function to use when one is not provided by the schema.\n * If not provided, the default field resolver is used (which looks for a\n * value or method on the source value with the field's name).\n * typeResolver:\n * A type resolver function to use when none is provided by the schema.\n * If not provided, the default type resolver is used (which looks for a\n * `__typename` field or alternatively calls the `isTypeOf` method).\n */\nexport interface GraphQLArgs {\n schema: GraphQLSchema;\n source: string | Source;\n hideSuggestions?: Maybe;\n rootValue?: unknown;\n contextValue?: unknown;\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>;\n operationName?: Maybe;\n fieldResolver?: Maybe>;\n typeResolver?: Maybe>;\n abortSignal?: Maybe;\n}\n\nexport function graphql(args: GraphQLArgs): Promise {\n // Always return a Promise for a consistent API.\n return new Promise((resolve) => resolve(graphqlImpl(args)));\n}\n\n/**\n * The graphqlSync function also fulfills GraphQL operations by parsing,\n * validating, and executing a GraphQL document along side a GraphQL schema.\n * However, it guarantees to complete synchronously (or throw an error) assuming\n * that all field resolvers are also synchronous.\n */\nexport function graphqlSync(args: GraphQLArgs): ExecutionResult {\n const result = graphqlImpl(args);\n\n // Assert that the execution was synchronous.\n if (isPromise(result)) {\n throw new Error('GraphQL execution failed to complete synchronously.');\n }\n\n return result;\n}\n\nfunction graphqlImpl(args: GraphQLArgs): PromiseOrValue {\n const {\n schema,\n source,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n hideSuggestions,\n } = args;\n\n // Validate Schema\n const schemaValidationErrors = validateSchema(schema);\n if (schemaValidationErrors.length > 0) {\n return { errors: schemaValidationErrors };\n }\n\n // Parse\n let document;\n try {\n document = parse(source);\n } catch (syntaxError) {\n return { errors: [syntaxError] };\n }\n\n // Validate\n const validationErrors = validate(schema, document, undefined, {\n hideSuggestions,\n });\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n\n // Execute\n return execute({\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n hideSuggestions,\n });\n}\n"]} \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000000..5aca67def3 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,48 @@ +/** + * GraphQL.js provides a reference implementation for the GraphQL specification + * but is also a useful utility for operating on GraphQL files and building + * sophisticated tools. + * + * This primary module exports a general purpose function for fulfilling all + * steps of the GraphQL specification in a single operation, but also includes + * utilities for every part of the GraphQL specification: + * + * - Parsing the GraphQL language. + * - Building a GraphQL type schema. + * - Validating a GraphQL request against a type schema. + * - Executing a GraphQL request against a type schema. + * + * This also includes utility functions for operating on GraphQL types and + * GraphQL documents to facilitate building tools. + * + * You may also import from each sub-directory directly. For example, the + * following two import statements are equivalent: + * + * ```ts + * import { parse } from 'graphql'; + * import { parse } from 'graphql/language'; + * ``` + * + * @packageDocumentation + */ +export { version, versionInfo } from './version.js'; +export type { GraphQLArgs } from './graphql.js'; +export { graphql, graphqlSync } from './graphql.js'; +export type { GraphQLField, GraphQLArgument, GraphQLEnumValue, GraphQLInputField, } from './type/index.js'; +export { resolveObjMapThunk, resolveReadonlyArrayThunk, GraphQLSchema, GraphQLDirective, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, GraphQLList, GraphQLNonNull, specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID, GRAPHQL_MAX_INT, GRAPHQL_MIN_INT, specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeferDirective, GraphQLStreamDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective, GraphQLOneOfDirective, TypeKind, DEFAULT_DEPRECATION_REASON, introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, isSchema, isDirective, isType, isScalarType, isObjectType, isField, isArgument, isInterfaceType, isUnionType, isEnumType, isEnumValue, isInputObjectType, isInputField, isListType, isNonNullType, isInputType, isOutputType, isLeafType, isCompositeType, isAbstractType, isWrappingType, isNullableType, isNamedType, isRequiredArgument, isRequiredInputField, isSpecifiedScalarType, isIntrospectionType, isSpecifiedDirective, assertSchema, assertDirective, assertType, assertScalarType, assertObjectType, assertField, assertArgument, assertInterfaceType, assertUnionType, assertEnumType, assertEnumValue, assertInputObjectType, assertInputField, assertListType, assertNonNullType, assertInputType, assertOutputType, assertLeafType, assertCompositeType, assertAbstractType, assertWrappingType, assertNullableType, assertNamedType, getNullableType, getNamedType, validateSchema, assertValidSchema, assertName, assertEnumValueName, } from './type/index.js'; +export type { GraphQLType, GraphQLInputType, GraphQLOutputType, GraphQLLeafType, GraphQLCompositeType, GraphQLAbstractType, GraphQLWrappingType, GraphQLNullableType, GraphQLNullableInputType, GraphQLNullableOutputType, GraphQLNamedType, GraphQLNamedInputType, GraphQLNamedOutputType, ThunkReadonlyArray, ThunkObjMap, GraphQLSchemaConfig, GraphQLSchemaExtensions, GraphQLDirectiveConfig, GraphQLDirectiveExtensions, GraphQLArgumentConfig, GraphQLArgumentExtensions, GraphQLEnumTypeConfig, GraphQLEnumTypeExtensions, GraphQLEnumValueConfig, GraphQLEnumValueConfigMap, GraphQLEnumValueExtensions, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLFieldExtensions, GraphQLFieldMap, GraphQLFieldResolver, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputFieldExtensions, GraphQLInputFieldMap, GraphQLInputObjectTypeConfig, GraphQLInputObjectTypeExtensions, GraphQLInterfaceTypeConfig, GraphQLInterfaceTypeExtensions, GraphQLIsTypeOfFn, GraphQLObjectTypeConfig, GraphQLObjectTypeExtensions, GraphQLResolveInfo, ResponsePath, GraphQLScalarTypeConfig, GraphQLScalarTypeExtensions, GraphQLTypeResolver, GraphQLUnionTypeConfig, GraphQLUnionTypeExtensions, GraphQLScalarSerializer, GraphQLScalarValueParser, GraphQLScalarLiteralParser, GraphQLScalarOutputValueCoercer, GraphQLScalarInputValueCoercer, GraphQLScalarInputLiteralCoercer, GraphQLDefaultInput, } from './type/index.js'; +export { Kind } from './language/kinds.js'; +export { Token, Source, Location, OperationTypeNode, getLocation, printLocation, printSourceLocation, Lexer, TokenKind, parse, parseValue, parseConstValue, parseType, print, visit, visitInParallel, getEnterLeaveForKind, BREAK, DirectiveLocation, isDefinitionNode, isExecutableDefinitionNode, isSelectionNode, isValueNode, isConstValueNode, isTypeNode, isTypeSystemDefinitionNode, isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode, } from './language/index.js'; +export type { ParseOptions, SourceLocation, ASTVisitor, ASTVisitFn, ASTVisitorKeyMap, ASTNode, ASTKindToNode, NameNode, DocumentNode, DefinitionNode, ExecutableDefinitionNode, OperationDefinitionNode, VariableDefinitionNode, VariableNode, SelectionSetNode, SelectionNode, FieldNode, ArgumentNode, FragmentArgumentNode, ConstArgumentNode, FragmentSpreadNode, InlineFragmentNode, FragmentDefinitionNode, ValueNode, ConstValueNode, IntValueNode, FloatValueNode, StringValueNode, BooleanValueNode, NullValueNode, EnumValueNode, ListValueNode, ConstListValueNode, ObjectValueNode, ConstObjectValueNode, ObjectFieldNode, ConstObjectFieldNode, DirectiveNode, ConstDirectiveNode, TypeNode, NamedTypeNode, ListTypeNode, NonNullTypeNode, TypeSystemDefinitionNode, SchemaDefinitionNode, OperationTypeDefinitionNode, TypeDefinitionNode, ScalarTypeDefinitionNode, ObjectTypeDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, UnionTypeDefinitionNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, InputObjectTypeDefinitionNode, DirectiveDefinitionNode, TypeSystemExtensionNode, SchemaExtensionNode, TypeExtensionNode, ScalarTypeExtensionNode, ObjectTypeExtensionNode, InterfaceTypeExtensionNode, UnionTypeExtensionNode, EnumTypeExtensionNode, InputObjectTypeExtensionNode, } from './language/index.js'; +export { execute, executeQueryOrMutationOrSubscriptionEvent, executeSubscriptionEvent, experimentalExecuteIncrementally, experimentalExecuteQueryOrMutationOrSubscriptionEvent, executeSync, defaultFieldResolver, defaultTypeResolver, responsePathAsArray, getArgumentValues, getVariableValues, getDirectiveValues, subscribe, createSourceEventStream, } from './execution/index.js'; +export type { ExecutionArgs, ValidatedExecutionArgs, ExecutionResult, ExperimentalIncrementalExecutionResults, InitialIncrementalExecutionResult, SubsequentIncrementalExecutionResult, IncrementalDeferResult, IncrementalStreamResult, IncrementalResult, FormattedExecutionResult, FormattedInitialIncrementalExecutionResult, FormattedSubsequentIncrementalExecutionResult, FormattedIncrementalDeferResult, FormattedIncrementalStreamResult, FormattedIncrementalResult, } from './execution/index.js'; +export { validate, ValidationContext, specifiedRules, recommendedRules, ExecutableDefinitionsRule, FieldsOnCorrectTypeRule, FragmentsOnCompositeTypesRule, KnownArgumentNamesRule, KnownDirectivesRule, KnownFragmentNamesRule, KnownOperationTypesRule, KnownTypeNamesRule, LoneAnonymousOperationRule, NoFragmentCyclesRule, NoUndefinedVariablesRule, NoUnusedFragmentsRule, NoUnusedVariablesRule, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, ProvidedRequiredArgumentsRule, ScalarLeafsRule, SingleFieldSubscriptionsRule, UniqueArgumentNamesRule, UniqueDirectivesPerLocationRule, UniqueFragmentNamesRule, UniqueInputFieldNamesRule, UniqueOperationNamesRule, UniqueVariableNamesRule, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule, MaxIntrospectionDepthRule, LoneSchemaDefinitionRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueArgumentDefinitionNamesRule, UniqueDirectiveNamesRule, PossibleTypeExtensionsRule, NoDeprecatedCustomRule, NoSchemaIntrospectionCustomRule, } from './validation/index.js'; +export type { ValidationRule } from './validation/index.js'; +export { GraphQLError, syntaxError, locatedError } from './error/index.js'; +export type { GraphQLErrorOptions, GraphQLFormattedError, GraphQLErrorExtensions, GraphQLFormattedErrorExtensions, } from './error/index.js'; +export { getIntrospectionQuery, getOperationAST, introspectionFromSchema, buildClientSchema, buildASTSchema, buildSchema, extendSchema, lexicographicSortSchema, printSchema, printType, printDirective, printIntrospectionSchema, typeFromAST, +/** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */ +valueFromAST, valueFromASTUntyped, +/** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */ +astFromValue, TypeInfo, visitWithTypeInfo, replaceVariables, valueToLiteral, coerceInputValue, coerceInputLiteral, validateInputValue, validateInputLiteral, concatAST, separateOperations, stripIgnoredCharacters, isEqualType, isTypeSubTypeOf, doTypesOverlap, BreakingChangeType, DangerousChangeType, SafeChangeType, findBreakingChanges, findDangerousChanges, findSchemaChanges, } from './utilities/index.js'; +export type { IntrospectionOptions, IntrospectionQuery, IntrospectionSchema, IntrospectionType, IntrospectionInputType, IntrospectionOutputType, IntrospectionScalarType, IntrospectionObjectType, IntrospectionInterfaceType, IntrospectionUnionType, IntrospectionEnumType, IntrospectionInputObjectType, IntrospectionTypeRef, IntrospectionInputTypeRef, IntrospectionOutputTypeRef, IntrospectionNamedTypeRef, IntrospectionListTypeRef, IntrospectionNonNullTypeRef, IntrospectionField, IntrospectionInputValue, IntrospectionEnumValue, IntrospectionDirective, BuildSchemaOptions, BreakingChange, SafeChange, DangerousChange, TypedQueryDocumentNode, } from './utilities/index.js'; diff --git a/index.js b/index.js new file mode 100644 index 0000000000..30c9da7787 --- /dev/null +++ b/index.js @@ -0,0 +1,334 @@ +"use strict"; +/** + * GraphQL.js provides a reference implementation for the GraphQL specification + * but is also a useful utility for operating on GraphQL files and building + * sophisticated tools. + * + * This primary module exports a general purpose function for fulfilling all + * steps of the GraphQL specification in a single operation, but also includes + * utilities for every part of the GraphQL specification: + * + * - Parsing the GraphQL language. + * - Building a GraphQL type schema. + * - Validating a GraphQL request against a type schema. + * - Executing a GraphQL request against a type schema. + * + * This also includes utility functions for operating on GraphQL types and + * GraphQL documents to facilitate building tools. + * + * You may also import from each sub-directory directly. For example, the + * following two import statements are equivalent: + * + * ```ts + * import { parse } from 'graphql'; + * import { parse } from 'graphql/language'; + * ``` + * + * @packageDocumentation + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isScalarType = exports.isType = exports.isDirective = exports.isSchema = exports.TypeNameMetaFieldDef = exports.TypeMetaFieldDef = exports.SchemaMetaFieldDef = exports.__TypeKind = exports.__EnumValue = exports.__InputValue = exports.__Field = exports.__Type = exports.__DirectiveLocation = exports.__Directive = exports.__Schema = exports.introspectionTypes = exports.DEFAULT_DEPRECATION_REASON = exports.TypeKind = exports.GraphQLOneOfDirective = exports.GraphQLSpecifiedByDirective = exports.GraphQLDeprecatedDirective = exports.GraphQLStreamDirective = exports.GraphQLDeferDirective = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.specifiedDirectives = exports.GRAPHQL_MIN_INT = exports.GRAPHQL_MAX_INT = exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = exports.specifiedScalarTypes = exports.GraphQLNonNull = exports.GraphQLList = exports.GraphQLInputObjectType = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLObjectType = exports.GraphQLScalarType = exports.GraphQLDirective = exports.GraphQLSchema = exports.resolveReadonlyArrayThunk = exports.resolveObjMapThunk = exports.graphqlSync = exports.graphql = exports.versionInfo = exports.version = void 0; +exports.validateSchema = exports.getNamedType = exports.getNullableType = exports.assertNamedType = exports.assertNullableType = exports.assertWrappingType = exports.assertAbstractType = exports.assertCompositeType = exports.assertLeafType = exports.assertOutputType = exports.assertInputType = exports.assertNonNullType = exports.assertListType = exports.assertInputField = exports.assertInputObjectType = exports.assertEnumValue = exports.assertEnumType = exports.assertUnionType = exports.assertInterfaceType = exports.assertArgument = exports.assertField = exports.assertObjectType = exports.assertScalarType = exports.assertType = exports.assertDirective = exports.assertSchema = exports.isSpecifiedDirective = exports.isIntrospectionType = exports.isSpecifiedScalarType = exports.isRequiredInputField = exports.isRequiredArgument = exports.isNamedType = exports.isNullableType = exports.isWrappingType = exports.isAbstractType = exports.isCompositeType = exports.isLeafType = exports.isOutputType = exports.isInputType = exports.isNonNullType = exports.isListType = exports.isInputField = exports.isInputObjectType = exports.isEnumValue = exports.isEnumType = exports.isUnionType = exports.isInterfaceType = exports.isArgument = exports.isField = exports.isObjectType = void 0; +exports.recommendedRules = exports.specifiedRules = exports.ValidationContext = exports.validate = exports.createSourceEventStream = exports.subscribe = exports.getDirectiveValues = exports.getVariableValues = exports.getArgumentValues = exports.responsePathAsArray = exports.defaultTypeResolver = exports.defaultFieldResolver = exports.executeSync = exports.experimentalExecuteQueryOrMutationOrSubscriptionEvent = exports.experimentalExecuteIncrementally = exports.executeSubscriptionEvent = exports.executeQueryOrMutationOrSubscriptionEvent = exports.execute = exports.isTypeExtensionNode = exports.isTypeSystemExtensionNode = exports.isTypeDefinitionNode = exports.isTypeSystemDefinitionNode = exports.isTypeNode = exports.isConstValueNode = exports.isValueNode = exports.isSelectionNode = exports.isExecutableDefinitionNode = exports.isDefinitionNode = exports.DirectiveLocation = exports.BREAK = exports.getEnterLeaveForKind = exports.visitInParallel = exports.visit = exports.parseType = exports.parseConstValue = exports.parseValue = exports.parse = exports.TokenKind = exports.Lexer = exports.printSourceLocation = exports.printLocation = exports.getLocation = exports.OperationTypeNode = exports.Location = exports.Source = exports.Token = exports.Kind = exports.assertEnumValueName = exports.assertName = exports.assertValidSchema = void 0; +exports.printSchema = exports.lexicographicSortSchema = exports.extendSchema = exports.buildSchema = exports.buildASTSchema = exports.buildClientSchema = exports.introspectionFromSchema = exports.getOperationAST = exports.getIntrospectionQuery = exports.locatedError = exports.syntaxError = exports.GraphQLError = exports.NoSchemaIntrospectionCustomRule = exports.NoDeprecatedCustomRule = exports.PossibleTypeExtensionsRule = exports.UniqueDirectiveNamesRule = exports.UniqueArgumentDefinitionNamesRule = exports.UniqueFieldDefinitionNamesRule = exports.UniqueEnumValueNamesRule = exports.UniqueTypeNamesRule = exports.UniqueOperationTypesRule = exports.LoneSchemaDefinitionRule = exports.MaxIntrospectionDepthRule = exports.VariablesInAllowedPositionRule = exports.VariablesAreInputTypesRule = exports.ValuesOfCorrectTypeRule = exports.UniqueVariableNamesRule = exports.UniqueOperationNamesRule = exports.UniqueInputFieldNamesRule = exports.UniqueFragmentNamesRule = exports.UniqueDirectivesPerLocationRule = exports.UniqueArgumentNamesRule = exports.SingleFieldSubscriptionsRule = exports.ScalarLeafsRule = exports.ProvidedRequiredArgumentsRule = exports.PossibleFragmentSpreadsRule = exports.OverlappingFieldsCanBeMergedRule = exports.NoUnusedVariablesRule = exports.NoUnusedFragmentsRule = exports.NoUndefinedVariablesRule = exports.NoFragmentCyclesRule = exports.LoneAnonymousOperationRule = exports.KnownTypeNamesRule = exports.KnownOperationTypesRule = exports.KnownFragmentNamesRule = exports.KnownDirectivesRule = exports.KnownArgumentNamesRule = exports.FragmentsOnCompositeTypesRule = exports.FieldsOnCorrectTypeRule = exports.ExecutableDefinitionsRule = void 0; +exports.findSchemaChanges = exports.findDangerousChanges = exports.findBreakingChanges = exports.SafeChangeType = exports.DangerousChangeType = exports.BreakingChangeType = exports.doTypesOverlap = exports.isTypeSubTypeOf = exports.isEqualType = exports.stripIgnoredCharacters = exports.separateOperations = exports.concatAST = exports.validateInputLiteral = exports.validateInputValue = exports.coerceInputLiteral = exports.coerceInputValue = exports.valueToLiteral = exports.replaceVariables = exports.visitWithTypeInfo = exports.TypeInfo = exports.astFromValue = exports.valueFromASTUntyped = exports.valueFromAST = exports.typeFromAST = exports.printIntrospectionSchema = exports.printDirective = exports.printType = void 0; +// The GraphQL.js version info. +var version_js_1 = require("./version.js"); +Object.defineProperty(exports, "version", { enumerable: true, get: function () { return version_js_1.version; } }); +Object.defineProperty(exports, "versionInfo", { enumerable: true, get: function () { return version_js_1.versionInfo; } }); +var graphql_js_1 = require("./graphql.js"); +Object.defineProperty(exports, "graphql", { enumerable: true, get: function () { return graphql_js_1.graphql; } }); +Object.defineProperty(exports, "graphqlSync", { enumerable: true, get: function () { return graphql_js_1.graphqlSync; } }); +var index_js_1 = require("./type/index.js"); +Object.defineProperty(exports, "resolveObjMapThunk", { enumerable: true, get: function () { return index_js_1.resolveObjMapThunk; } }); +Object.defineProperty(exports, "resolveReadonlyArrayThunk", { enumerable: true, get: function () { return index_js_1.resolveReadonlyArrayThunk; } }); +// Definitions +Object.defineProperty(exports, "GraphQLSchema", { enumerable: true, get: function () { return index_js_1.GraphQLSchema; } }); +Object.defineProperty(exports, "GraphQLDirective", { enumerable: true, get: function () { return index_js_1.GraphQLDirective; } }); +Object.defineProperty(exports, "GraphQLScalarType", { enumerable: true, get: function () { return index_js_1.GraphQLScalarType; } }); +Object.defineProperty(exports, "GraphQLObjectType", { enumerable: true, get: function () { return index_js_1.GraphQLObjectType; } }); +Object.defineProperty(exports, "GraphQLInterfaceType", { enumerable: true, get: function () { return index_js_1.GraphQLInterfaceType; } }); +Object.defineProperty(exports, "GraphQLUnionType", { enumerable: true, get: function () { return index_js_1.GraphQLUnionType; } }); +Object.defineProperty(exports, "GraphQLEnumType", { enumerable: true, get: function () { return index_js_1.GraphQLEnumType; } }); +Object.defineProperty(exports, "GraphQLInputObjectType", { enumerable: true, get: function () { return index_js_1.GraphQLInputObjectType; } }); +Object.defineProperty(exports, "GraphQLList", { enumerable: true, get: function () { return index_js_1.GraphQLList; } }); +Object.defineProperty(exports, "GraphQLNonNull", { enumerable: true, get: function () { return index_js_1.GraphQLNonNull; } }); +// Standard GraphQL Scalars +Object.defineProperty(exports, "specifiedScalarTypes", { enumerable: true, get: function () { return index_js_1.specifiedScalarTypes; } }); +Object.defineProperty(exports, "GraphQLInt", { enumerable: true, get: function () { return index_js_1.GraphQLInt; } }); +Object.defineProperty(exports, "GraphQLFloat", { enumerable: true, get: function () { return index_js_1.GraphQLFloat; } }); +Object.defineProperty(exports, "GraphQLString", { enumerable: true, get: function () { return index_js_1.GraphQLString; } }); +Object.defineProperty(exports, "GraphQLBoolean", { enumerable: true, get: function () { return index_js_1.GraphQLBoolean; } }); +Object.defineProperty(exports, "GraphQLID", { enumerable: true, get: function () { return index_js_1.GraphQLID; } }); +// Int boundaries constants +Object.defineProperty(exports, "GRAPHQL_MAX_INT", { enumerable: true, get: function () { return index_js_1.GRAPHQL_MAX_INT; } }); +Object.defineProperty(exports, "GRAPHQL_MIN_INT", { enumerable: true, get: function () { return index_js_1.GRAPHQL_MIN_INT; } }); +// Built-in Directives defined by the Spec +Object.defineProperty(exports, "specifiedDirectives", { enumerable: true, get: function () { return index_js_1.specifiedDirectives; } }); +Object.defineProperty(exports, "GraphQLIncludeDirective", { enumerable: true, get: function () { return index_js_1.GraphQLIncludeDirective; } }); +Object.defineProperty(exports, "GraphQLSkipDirective", { enumerable: true, get: function () { return index_js_1.GraphQLSkipDirective; } }); +Object.defineProperty(exports, "GraphQLDeferDirective", { enumerable: true, get: function () { return index_js_1.GraphQLDeferDirective; } }); +Object.defineProperty(exports, "GraphQLStreamDirective", { enumerable: true, get: function () { return index_js_1.GraphQLStreamDirective; } }); +Object.defineProperty(exports, "GraphQLDeprecatedDirective", { enumerable: true, get: function () { return index_js_1.GraphQLDeprecatedDirective; } }); +Object.defineProperty(exports, "GraphQLSpecifiedByDirective", { enumerable: true, get: function () { return index_js_1.GraphQLSpecifiedByDirective; } }); +Object.defineProperty(exports, "GraphQLOneOfDirective", { enumerable: true, get: function () { return index_js_1.GraphQLOneOfDirective; } }); +// "Enum" of Type Kinds +Object.defineProperty(exports, "TypeKind", { enumerable: true, get: function () { return index_js_1.TypeKind; } }); +// Constant Deprecation Reason +Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", { enumerable: true, get: function () { return index_js_1.DEFAULT_DEPRECATION_REASON; } }); +// GraphQL Types for introspection. +Object.defineProperty(exports, "introspectionTypes", { enumerable: true, get: function () { return index_js_1.introspectionTypes; } }); +Object.defineProperty(exports, "__Schema", { enumerable: true, get: function () { return index_js_1.__Schema; } }); +Object.defineProperty(exports, "__Directive", { enumerable: true, get: function () { return index_js_1.__Directive; } }); +Object.defineProperty(exports, "__DirectiveLocation", { enumerable: true, get: function () { return index_js_1.__DirectiveLocation; } }); +Object.defineProperty(exports, "__Type", { enumerable: true, get: function () { return index_js_1.__Type; } }); +Object.defineProperty(exports, "__Field", { enumerable: true, get: function () { return index_js_1.__Field; } }); +Object.defineProperty(exports, "__InputValue", { enumerable: true, get: function () { return index_js_1.__InputValue; } }); +Object.defineProperty(exports, "__EnumValue", { enumerable: true, get: function () { return index_js_1.__EnumValue; } }); +Object.defineProperty(exports, "__TypeKind", { enumerable: true, get: function () { return index_js_1.__TypeKind; } }); +// Meta-field definitions. +Object.defineProperty(exports, "SchemaMetaFieldDef", { enumerable: true, get: function () { return index_js_1.SchemaMetaFieldDef; } }); +Object.defineProperty(exports, "TypeMetaFieldDef", { enumerable: true, get: function () { return index_js_1.TypeMetaFieldDef; } }); +Object.defineProperty(exports, "TypeNameMetaFieldDef", { enumerable: true, get: function () { return index_js_1.TypeNameMetaFieldDef; } }); +// Predicates +Object.defineProperty(exports, "isSchema", { enumerable: true, get: function () { return index_js_1.isSchema; } }); +Object.defineProperty(exports, "isDirective", { enumerable: true, get: function () { return index_js_1.isDirective; } }); +Object.defineProperty(exports, "isType", { enumerable: true, get: function () { return index_js_1.isType; } }); +Object.defineProperty(exports, "isScalarType", { enumerable: true, get: function () { return index_js_1.isScalarType; } }); +Object.defineProperty(exports, "isObjectType", { enumerable: true, get: function () { return index_js_1.isObjectType; } }); +Object.defineProperty(exports, "isField", { enumerable: true, get: function () { return index_js_1.isField; } }); +Object.defineProperty(exports, "isArgument", { enumerable: true, get: function () { return index_js_1.isArgument; } }); +Object.defineProperty(exports, "isInterfaceType", { enumerable: true, get: function () { return index_js_1.isInterfaceType; } }); +Object.defineProperty(exports, "isUnionType", { enumerable: true, get: function () { return index_js_1.isUnionType; } }); +Object.defineProperty(exports, "isEnumType", { enumerable: true, get: function () { return index_js_1.isEnumType; } }); +Object.defineProperty(exports, "isEnumValue", { enumerable: true, get: function () { return index_js_1.isEnumValue; } }); +Object.defineProperty(exports, "isInputObjectType", { enumerable: true, get: function () { return index_js_1.isInputObjectType; } }); +Object.defineProperty(exports, "isInputField", { enumerable: true, get: function () { return index_js_1.isInputField; } }); +Object.defineProperty(exports, "isListType", { enumerable: true, get: function () { return index_js_1.isListType; } }); +Object.defineProperty(exports, "isNonNullType", { enumerable: true, get: function () { return index_js_1.isNonNullType; } }); +Object.defineProperty(exports, "isInputType", { enumerable: true, get: function () { return index_js_1.isInputType; } }); +Object.defineProperty(exports, "isOutputType", { enumerable: true, get: function () { return index_js_1.isOutputType; } }); +Object.defineProperty(exports, "isLeafType", { enumerable: true, get: function () { return index_js_1.isLeafType; } }); +Object.defineProperty(exports, "isCompositeType", { enumerable: true, get: function () { return index_js_1.isCompositeType; } }); +Object.defineProperty(exports, "isAbstractType", { enumerable: true, get: function () { return index_js_1.isAbstractType; } }); +Object.defineProperty(exports, "isWrappingType", { enumerable: true, get: function () { return index_js_1.isWrappingType; } }); +Object.defineProperty(exports, "isNullableType", { enumerable: true, get: function () { return index_js_1.isNullableType; } }); +Object.defineProperty(exports, "isNamedType", { enumerable: true, get: function () { return index_js_1.isNamedType; } }); +Object.defineProperty(exports, "isRequiredArgument", { enumerable: true, get: function () { return index_js_1.isRequiredArgument; } }); +Object.defineProperty(exports, "isRequiredInputField", { enumerable: true, get: function () { return index_js_1.isRequiredInputField; } }); +Object.defineProperty(exports, "isSpecifiedScalarType", { enumerable: true, get: function () { return index_js_1.isSpecifiedScalarType; } }); +Object.defineProperty(exports, "isIntrospectionType", { enumerable: true, get: function () { return index_js_1.isIntrospectionType; } }); +Object.defineProperty(exports, "isSpecifiedDirective", { enumerable: true, get: function () { return index_js_1.isSpecifiedDirective; } }); +// Assertions +Object.defineProperty(exports, "assertSchema", { enumerable: true, get: function () { return index_js_1.assertSchema; } }); +Object.defineProperty(exports, "assertDirective", { enumerable: true, get: function () { return index_js_1.assertDirective; } }); +Object.defineProperty(exports, "assertType", { enumerable: true, get: function () { return index_js_1.assertType; } }); +Object.defineProperty(exports, "assertScalarType", { enumerable: true, get: function () { return index_js_1.assertScalarType; } }); +Object.defineProperty(exports, "assertObjectType", { enumerable: true, get: function () { return index_js_1.assertObjectType; } }); +Object.defineProperty(exports, "assertField", { enumerable: true, get: function () { return index_js_1.assertField; } }); +Object.defineProperty(exports, "assertArgument", { enumerable: true, get: function () { return index_js_1.assertArgument; } }); +Object.defineProperty(exports, "assertInterfaceType", { enumerable: true, get: function () { return index_js_1.assertInterfaceType; } }); +Object.defineProperty(exports, "assertUnionType", { enumerable: true, get: function () { return index_js_1.assertUnionType; } }); +Object.defineProperty(exports, "assertEnumType", { enumerable: true, get: function () { return index_js_1.assertEnumType; } }); +Object.defineProperty(exports, "assertEnumValue", { enumerable: true, get: function () { return index_js_1.assertEnumValue; } }); +Object.defineProperty(exports, "assertInputObjectType", { enumerable: true, get: function () { return index_js_1.assertInputObjectType; } }); +Object.defineProperty(exports, "assertInputField", { enumerable: true, get: function () { return index_js_1.assertInputField; } }); +Object.defineProperty(exports, "assertListType", { enumerable: true, get: function () { return index_js_1.assertListType; } }); +Object.defineProperty(exports, "assertNonNullType", { enumerable: true, get: function () { return index_js_1.assertNonNullType; } }); +Object.defineProperty(exports, "assertInputType", { enumerable: true, get: function () { return index_js_1.assertInputType; } }); +Object.defineProperty(exports, "assertOutputType", { enumerable: true, get: function () { return index_js_1.assertOutputType; } }); +Object.defineProperty(exports, "assertLeafType", { enumerable: true, get: function () { return index_js_1.assertLeafType; } }); +Object.defineProperty(exports, "assertCompositeType", { enumerable: true, get: function () { return index_js_1.assertCompositeType; } }); +Object.defineProperty(exports, "assertAbstractType", { enumerable: true, get: function () { return index_js_1.assertAbstractType; } }); +Object.defineProperty(exports, "assertWrappingType", { enumerable: true, get: function () { return index_js_1.assertWrappingType; } }); +Object.defineProperty(exports, "assertNullableType", { enumerable: true, get: function () { return index_js_1.assertNullableType; } }); +Object.defineProperty(exports, "assertNamedType", { enumerable: true, get: function () { return index_js_1.assertNamedType; } }); +// Un-modifiers +Object.defineProperty(exports, "getNullableType", { enumerable: true, get: function () { return index_js_1.getNullableType; } }); +Object.defineProperty(exports, "getNamedType", { enumerable: true, get: function () { return index_js_1.getNamedType; } }); +// Validate GraphQL schema. +Object.defineProperty(exports, "validateSchema", { enumerable: true, get: function () { return index_js_1.validateSchema; } }); +Object.defineProperty(exports, "assertValidSchema", { enumerable: true, get: function () { return index_js_1.assertValidSchema; } }); +// Upholds the spec rules about naming. +Object.defineProperty(exports, "assertName", { enumerable: true, get: function () { return index_js_1.assertName; } }); +Object.defineProperty(exports, "assertEnumValueName", { enumerable: true, get: function () { return index_js_1.assertEnumValueName; } }); +// Parse and operate on GraphQL language source files. +// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313 +// eslint-disable-next-line @typescript-eslint/consistent-type-exports +var kinds_js_1 = require("./language/kinds.js"); +Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return kinds_js_1.Kind; } }); +var index_js_2 = require("./language/index.js"); +Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return index_js_2.Token; } }); +Object.defineProperty(exports, "Source", { enumerable: true, get: function () { return index_js_2.Source; } }); +Object.defineProperty(exports, "Location", { enumerable: true, get: function () { return index_js_2.Location; } }); +Object.defineProperty(exports, "OperationTypeNode", { enumerable: true, get: function () { return index_js_2.OperationTypeNode; } }); +Object.defineProperty(exports, "getLocation", { enumerable: true, get: function () { return index_js_2.getLocation; } }); +// Print source location. +Object.defineProperty(exports, "printLocation", { enumerable: true, get: function () { return index_js_2.printLocation; } }); +Object.defineProperty(exports, "printSourceLocation", { enumerable: true, get: function () { return index_js_2.printSourceLocation; } }); +// Lex +Object.defineProperty(exports, "Lexer", { enumerable: true, get: function () { return index_js_2.Lexer; } }); +Object.defineProperty(exports, "TokenKind", { enumerable: true, get: function () { return index_js_2.TokenKind; } }); +// Parse +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return index_js_2.parse; } }); +Object.defineProperty(exports, "parseValue", { enumerable: true, get: function () { return index_js_2.parseValue; } }); +Object.defineProperty(exports, "parseConstValue", { enumerable: true, get: function () { return index_js_2.parseConstValue; } }); +Object.defineProperty(exports, "parseType", { enumerable: true, get: function () { return index_js_2.parseType; } }); +// Print +Object.defineProperty(exports, "print", { enumerable: true, get: function () { return index_js_2.print; } }); +// Visit +Object.defineProperty(exports, "visit", { enumerable: true, get: function () { return index_js_2.visit; } }); +Object.defineProperty(exports, "visitInParallel", { enumerable: true, get: function () { return index_js_2.visitInParallel; } }); +Object.defineProperty(exports, "getEnterLeaveForKind", { enumerable: true, get: function () { return index_js_2.getEnterLeaveForKind; } }); +Object.defineProperty(exports, "BREAK", { enumerable: true, get: function () { return index_js_2.BREAK; } }); +Object.defineProperty(exports, "DirectiveLocation", { enumerable: true, get: function () { return index_js_2.DirectiveLocation; } }); +// Predicates +Object.defineProperty(exports, "isDefinitionNode", { enumerable: true, get: function () { return index_js_2.isDefinitionNode; } }); +Object.defineProperty(exports, "isExecutableDefinitionNode", { enumerable: true, get: function () { return index_js_2.isExecutableDefinitionNode; } }); +Object.defineProperty(exports, "isSelectionNode", { enumerable: true, get: function () { return index_js_2.isSelectionNode; } }); +Object.defineProperty(exports, "isValueNode", { enumerable: true, get: function () { return index_js_2.isValueNode; } }); +Object.defineProperty(exports, "isConstValueNode", { enumerable: true, get: function () { return index_js_2.isConstValueNode; } }); +Object.defineProperty(exports, "isTypeNode", { enumerable: true, get: function () { return index_js_2.isTypeNode; } }); +Object.defineProperty(exports, "isTypeSystemDefinitionNode", { enumerable: true, get: function () { return index_js_2.isTypeSystemDefinitionNode; } }); +Object.defineProperty(exports, "isTypeDefinitionNode", { enumerable: true, get: function () { return index_js_2.isTypeDefinitionNode; } }); +Object.defineProperty(exports, "isTypeSystemExtensionNode", { enumerable: true, get: function () { return index_js_2.isTypeSystemExtensionNode; } }); +Object.defineProperty(exports, "isTypeExtensionNode", { enumerable: true, get: function () { return index_js_2.isTypeExtensionNode; } }); +// Execute GraphQL queries. +var index_js_3 = require("./execution/index.js"); +Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return index_js_3.execute; } }); +Object.defineProperty(exports, "executeQueryOrMutationOrSubscriptionEvent", { enumerable: true, get: function () { return index_js_3.executeQueryOrMutationOrSubscriptionEvent; } }); +Object.defineProperty(exports, "executeSubscriptionEvent", { enumerable: true, get: function () { return index_js_3.executeSubscriptionEvent; } }); +Object.defineProperty(exports, "experimentalExecuteIncrementally", { enumerable: true, get: function () { return index_js_3.experimentalExecuteIncrementally; } }); +Object.defineProperty(exports, "experimentalExecuteQueryOrMutationOrSubscriptionEvent", { enumerable: true, get: function () { return index_js_3.experimentalExecuteQueryOrMutationOrSubscriptionEvent; } }); +Object.defineProperty(exports, "executeSync", { enumerable: true, get: function () { return index_js_3.executeSync; } }); +Object.defineProperty(exports, "defaultFieldResolver", { enumerable: true, get: function () { return index_js_3.defaultFieldResolver; } }); +Object.defineProperty(exports, "defaultTypeResolver", { enumerable: true, get: function () { return index_js_3.defaultTypeResolver; } }); +Object.defineProperty(exports, "responsePathAsArray", { enumerable: true, get: function () { return index_js_3.responsePathAsArray; } }); +Object.defineProperty(exports, "getArgumentValues", { enumerable: true, get: function () { return index_js_3.getArgumentValues; } }); +Object.defineProperty(exports, "getVariableValues", { enumerable: true, get: function () { return index_js_3.getVariableValues; } }); +Object.defineProperty(exports, "getDirectiveValues", { enumerable: true, get: function () { return index_js_3.getDirectiveValues; } }); +Object.defineProperty(exports, "subscribe", { enumerable: true, get: function () { return index_js_3.subscribe; } }); +Object.defineProperty(exports, "createSourceEventStream", { enumerable: true, get: function () { return index_js_3.createSourceEventStream; } }); +// Validate GraphQL documents. +var index_js_4 = require("./validation/index.js"); +Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return index_js_4.validate; } }); +Object.defineProperty(exports, "ValidationContext", { enumerable: true, get: function () { return index_js_4.ValidationContext; } }); +// All validation rules in the GraphQL Specification. +Object.defineProperty(exports, "specifiedRules", { enumerable: true, get: function () { return index_js_4.specifiedRules; } }); +Object.defineProperty(exports, "recommendedRules", { enumerable: true, get: function () { return index_js_4.recommendedRules; } }); +// Individual validation rules. +Object.defineProperty(exports, "ExecutableDefinitionsRule", { enumerable: true, get: function () { return index_js_4.ExecutableDefinitionsRule; } }); +Object.defineProperty(exports, "FieldsOnCorrectTypeRule", { enumerable: true, get: function () { return index_js_4.FieldsOnCorrectTypeRule; } }); +Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", { enumerable: true, get: function () { return index_js_4.FragmentsOnCompositeTypesRule; } }); +Object.defineProperty(exports, "KnownArgumentNamesRule", { enumerable: true, get: function () { return index_js_4.KnownArgumentNamesRule; } }); +Object.defineProperty(exports, "KnownDirectivesRule", { enumerable: true, get: function () { return index_js_4.KnownDirectivesRule; } }); +Object.defineProperty(exports, "KnownFragmentNamesRule", { enumerable: true, get: function () { return index_js_4.KnownFragmentNamesRule; } }); +Object.defineProperty(exports, "KnownOperationTypesRule", { enumerable: true, get: function () { return index_js_4.KnownOperationTypesRule; } }); +Object.defineProperty(exports, "KnownTypeNamesRule", { enumerable: true, get: function () { return index_js_4.KnownTypeNamesRule; } }); +Object.defineProperty(exports, "LoneAnonymousOperationRule", { enumerable: true, get: function () { return index_js_4.LoneAnonymousOperationRule; } }); +Object.defineProperty(exports, "NoFragmentCyclesRule", { enumerable: true, get: function () { return index_js_4.NoFragmentCyclesRule; } }); +Object.defineProperty(exports, "NoUndefinedVariablesRule", { enumerable: true, get: function () { return index_js_4.NoUndefinedVariablesRule; } }); +Object.defineProperty(exports, "NoUnusedFragmentsRule", { enumerable: true, get: function () { return index_js_4.NoUnusedFragmentsRule; } }); +Object.defineProperty(exports, "NoUnusedVariablesRule", { enumerable: true, get: function () { return index_js_4.NoUnusedVariablesRule; } }); +Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", { enumerable: true, get: function () { return index_js_4.OverlappingFieldsCanBeMergedRule; } }); +Object.defineProperty(exports, "PossibleFragmentSpreadsRule", { enumerable: true, get: function () { return index_js_4.PossibleFragmentSpreadsRule; } }); +Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", { enumerable: true, get: function () { return index_js_4.ProvidedRequiredArgumentsRule; } }); +Object.defineProperty(exports, "ScalarLeafsRule", { enumerable: true, get: function () { return index_js_4.ScalarLeafsRule; } }); +Object.defineProperty(exports, "SingleFieldSubscriptionsRule", { enumerable: true, get: function () { return index_js_4.SingleFieldSubscriptionsRule; } }); +Object.defineProperty(exports, "UniqueArgumentNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueArgumentNamesRule; } }); +Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", { enumerable: true, get: function () { return index_js_4.UniqueDirectivesPerLocationRule; } }); +Object.defineProperty(exports, "UniqueFragmentNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueFragmentNamesRule; } }); +Object.defineProperty(exports, "UniqueInputFieldNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueInputFieldNamesRule; } }); +Object.defineProperty(exports, "UniqueOperationNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueOperationNamesRule; } }); +Object.defineProperty(exports, "UniqueVariableNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueVariableNamesRule; } }); +Object.defineProperty(exports, "ValuesOfCorrectTypeRule", { enumerable: true, get: function () { return index_js_4.ValuesOfCorrectTypeRule; } }); +Object.defineProperty(exports, "VariablesAreInputTypesRule", { enumerable: true, get: function () { return index_js_4.VariablesAreInputTypesRule; } }); +Object.defineProperty(exports, "VariablesInAllowedPositionRule", { enumerable: true, get: function () { return index_js_4.VariablesInAllowedPositionRule; } }); +Object.defineProperty(exports, "MaxIntrospectionDepthRule", { enumerable: true, get: function () { return index_js_4.MaxIntrospectionDepthRule; } }); +// SDL-specific validation rules +Object.defineProperty(exports, "LoneSchemaDefinitionRule", { enumerable: true, get: function () { return index_js_4.LoneSchemaDefinitionRule; } }); +Object.defineProperty(exports, "UniqueOperationTypesRule", { enumerable: true, get: function () { return index_js_4.UniqueOperationTypesRule; } }); +Object.defineProperty(exports, "UniqueTypeNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueTypeNamesRule; } }); +Object.defineProperty(exports, "UniqueEnumValueNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueEnumValueNamesRule; } }); +Object.defineProperty(exports, "UniqueFieldDefinitionNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueFieldDefinitionNamesRule; } }); +Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueArgumentDefinitionNamesRule; } }); +Object.defineProperty(exports, "UniqueDirectiveNamesRule", { enumerable: true, get: function () { return index_js_4.UniqueDirectiveNamesRule; } }); +Object.defineProperty(exports, "PossibleTypeExtensionsRule", { enumerable: true, get: function () { return index_js_4.PossibleTypeExtensionsRule; } }); +// Custom validation rules +Object.defineProperty(exports, "NoDeprecatedCustomRule", { enumerable: true, get: function () { return index_js_4.NoDeprecatedCustomRule; } }); +Object.defineProperty(exports, "NoSchemaIntrospectionCustomRule", { enumerable: true, get: function () { return index_js_4.NoSchemaIntrospectionCustomRule; } }); +// Create, format, and print GraphQL errors. +var index_js_5 = require("./error/index.js"); +Object.defineProperty(exports, "GraphQLError", { enumerable: true, get: function () { return index_js_5.GraphQLError; } }); +Object.defineProperty(exports, "syntaxError", { enumerable: true, get: function () { return index_js_5.syntaxError; } }); +Object.defineProperty(exports, "locatedError", { enumerable: true, get: function () { return index_js_5.locatedError; } }); +// Utilities for operating on GraphQL type schema and parsed sources. +var index_js_6 = require("./utilities/index.js"); +// Produce the GraphQL query recommended for a full schema introspection. +// Accepts optional IntrospectionOptions. +Object.defineProperty(exports, "getIntrospectionQuery", { enumerable: true, get: function () { return index_js_6.getIntrospectionQuery; } }); +// Gets the target Operation from a Document. +Object.defineProperty(exports, "getOperationAST", { enumerable: true, get: function () { return index_js_6.getOperationAST; } }); +// Convert a GraphQLSchema to an IntrospectionQuery. +Object.defineProperty(exports, "introspectionFromSchema", { enumerable: true, get: function () { return index_js_6.introspectionFromSchema; } }); +// Build a GraphQLSchema from an introspection result. +Object.defineProperty(exports, "buildClientSchema", { enumerable: true, get: function () { return index_js_6.buildClientSchema; } }); +// Build a GraphQLSchema from a parsed GraphQL Schema language AST. +Object.defineProperty(exports, "buildASTSchema", { enumerable: true, get: function () { return index_js_6.buildASTSchema; } }); +// Build a GraphQLSchema from a GraphQL schema language document. +Object.defineProperty(exports, "buildSchema", { enumerable: true, get: function () { return index_js_6.buildSchema; } }); +// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. +Object.defineProperty(exports, "extendSchema", { enumerable: true, get: function () { return index_js_6.extendSchema; } }); +// Sort a GraphQLSchema. +Object.defineProperty(exports, "lexicographicSortSchema", { enumerable: true, get: function () { return index_js_6.lexicographicSortSchema; } }); +// Print a GraphQLSchema to GraphQL Schema language. +Object.defineProperty(exports, "printSchema", { enumerable: true, get: function () { return index_js_6.printSchema; } }); +// Print a GraphQLType to GraphQL Schema language. +Object.defineProperty(exports, "printType", { enumerable: true, get: function () { return index_js_6.printType; } }); +// Print a GraphQLDirective to GraphQL Schema language. +Object.defineProperty(exports, "printDirective", { enumerable: true, get: function () { return index_js_6.printDirective; } }); +// Prints the built-in introspection schema in the Schema Language format. +Object.defineProperty(exports, "printIntrospectionSchema", { enumerable: true, get: function () { return index_js_6.printIntrospectionSchema; } }); +// Create a GraphQLType from a GraphQL language AST. +Object.defineProperty(exports, "typeFromAST", { enumerable: true, get: function () { return index_js_6.typeFromAST; } }); +// Create a JavaScript value from a GraphQL language AST with a Type. +/** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */ +Object.defineProperty(exports, "valueFromAST", { enumerable: true, get: function () { return index_js_6.valueFromAST; } }); +// Create a JavaScript value from a GraphQL language AST without a Type. +Object.defineProperty(exports, "valueFromASTUntyped", { enumerable: true, get: function () { return index_js_6.valueFromASTUntyped; } }); +// Create a GraphQL language AST from a JavaScript value. +/** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */ +Object.defineProperty(exports, "astFromValue", { enumerable: true, get: function () { return index_js_6.astFromValue; } }); +// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. +Object.defineProperty(exports, "TypeInfo", { enumerable: true, get: function () { return index_js_6.TypeInfo; } }); +Object.defineProperty(exports, "visitWithTypeInfo", { enumerable: true, get: function () { return index_js_6.visitWithTypeInfo; } }); +// Converts a value to a const value by replacing variables. +Object.defineProperty(exports, "replaceVariables", { enumerable: true, get: function () { return index_js_6.replaceVariables; } }); +// Create a GraphQL literal (AST) from a JavaScript input value. +Object.defineProperty(exports, "valueToLiteral", { enumerable: true, get: function () { return index_js_6.valueToLiteral; } }); +// Coerces a JavaScript value to a GraphQL type, or returns undefined. +Object.defineProperty(exports, "coerceInputValue", { enumerable: true, get: function () { return index_js_6.coerceInputValue; } }); +// Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined. +Object.defineProperty(exports, "coerceInputLiteral", { enumerable: true, get: function () { return index_js_6.coerceInputLiteral; } }); +// Validate a JavaScript value with a GraphQL type, collecting all errors. +Object.defineProperty(exports, "validateInputValue", { enumerable: true, get: function () { return index_js_6.validateInputValue; } }); +// Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors. +Object.defineProperty(exports, "validateInputLiteral", { enumerable: true, get: function () { return index_js_6.validateInputLiteral; } }); +// Concatenates multiple AST together. +Object.defineProperty(exports, "concatAST", { enumerable: true, get: function () { return index_js_6.concatAST; } }); +// Separates an AST into an AST per Operation. +Object.defineProperty(exports, "separateOperations", { enumerable: true, get: function () { return index_js_6.separateOperations; } }); +// Strips characters that are not significant to the validity or execution of a GraphQL document. +Object.defineProperty(exports, "stripIgnoredCharacters", { enumerable: true, get: function () { return index_js_6.stripIgnoredCharacters; } }); +// Comparators for types +Object.defineProperty(exports, "isEqualType", { enumerable: true, get: function () { return index_js_6.isEqualType; } }); +Object.defineProperty(exports, "isTypeSubTypeOf", { enumerable: true, get: function () { return index_js_6.isTypeSubTypeOf; } }); +Object.defineProperty(exports, "doTypesOverlap", { enumerable: true, get: function () { return index_js_6.doTypesOverlap; } }); +// Compares two GraphQLSchemas and detects breaking changes. +Object.defineProperty(exports, "BreakingChangeType", { enumerable: true, get: function () { return index_js_6.BreakingChangeType; } }); +Object.defineProperty(exports, "DangerousChangeType", { enumerable: true, get: function () { return index_js_6.DangerousChangeType; } }); +Object.defineProperty(exports, "SafeChangeType", { enumerable: true, get: function () { return index_js_6.SafeChangeType; } }); +Object.defineProperty(exports, "findBreakingChanges", { enumerable: true, get: function () { return index_js_6.findBreakingChanges; } }); +Object.defineProperty(exports, "findDangerousChanges", { enumerable: true, get: function () { return index_js_6.findDangerousChanges; } }); +Object.defineProperty(exports, "findSchemaChanges", { enumerable: true, get: function () { return index_js_6.findSchemaChanges; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000000..5145f3e3ba --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;AAEH,+BAA+B;AAC/B,2CAAoD;AAA3C,qGAAA,OAAO,OAAA;AAAE,yGAAA,WAAW,OAAA;AAI7B,2CAAoD;AAA3C,qGAAA,OAAO,OAAA;AAAE,yGAAA,WAAW,OAAA;AAS7B,4CAiHyB;AAhHvB,8GAAA,kBAAkB,OAAA;AAClB,qHAAA,yBAAyB,OAAA;AACzB,cAAc;AACd,yGAAA,aAAa,OAAA;AACb,4GAAA,gBAAgB,OAAA;AAChB,6GAAA,iBAAiB,OAAA;AACjB,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AACpB,4GAAA,gBAAgB,OAAA;AAChB,2GAAA,eAAe,OAAA;AACf,kHAAA,sBAAsB,OAAA;AACtB,uGAAA,WAAW,OAAA;AACX,0GAAA,cAAc,OAAA;AACd,2BAA2B;AAC3B,gHAAA,oBAAoB,OAAA;AACpB,sGAAA,UAAU,OAAA;AACV,wGAAA,YAAY,OAAA;AACZ,yGAAA,aAAa,OAAA;AACb,0GAAA,cAAc,OAAA;AACd,qGAAA,SAAS,OAAA;AACT,2BAA2B;AAC3B,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,0CAA0C;AAC1C,+GAAA,mBAAmB,OAAA;AACnB,mHAAA,uBAAuB,OAAA;AACvB,gHAAA,oBAAoB,OAAA;AACpB,iHAAA,qBAAqB,OAAA;AACrB,kHAAA,sBAAsB,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Content":["/**\n * GraphQL.js provides a reference implementation for the GraphQL specification\n * but is also a useful utility for operating on GraphQL files and building\n * sophisticated tools.\n *\n * This primary module exports a general purpose function for fulfilling all\n * steps of the GraphQL specification in a single operation, but also includes\n * utilities for every part of the GraphQL specification:\n *\n * - Parsing the GraphQL language.\n * - Building a GraphQL type schema.\n * - Validating a GraphQL request against a type schema.\n * - Executing a GraphQL request against a type schema.\n *\n * This also includes utility functions for operating on GraphQL types and\n * GraphQL documents to facilitate building tools.\n *\n * You may also import from each sub-directory directly. For example, the\n * following two import statements are equivalent:\n *\n * ```ts\n * import { parse } from 'graphql';\n * import { parse } from 'graphql/language';\n * ```\n *\n * @packageDocumentation\n */\n\n// The GraphQL.js version info.\nexport { version, versionInfo } from './version.js';\n\n// The primary entry point into fulfilling a GraphQL request.\nexport type { GraphQLArgs } from './graphql.js';\nexport { graphql, graphqlSync } from './graphql.js';\n\n// Create and operate on GraphQL type definitions and schema.\nexport type {\n GraphQLField,\n GraphQLArgument,\n GraphQLEnumValue,\n GraphQLInputField,\n} from './type/index.js';\nexport {\n resolveObjMapThunk,\n resolveReadonlyArrayThunk,\n // Definitions\n GraphQLSchema,\n GraphQLDirective,\n GraphQLScalarType,\n GraphQLObjectType,\n GraphQLInterfaceType,\n GraphQLUnionType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLList,\n GraphQLNonNull,\n // Standard GraphQL Scalars\n specifiedScalarTypes,\n GraphQLInt,\n GraphQLFloat,\n GraphQLString,\n GraphQLBoolean,\n GraphQLID,\n // Int boundaries constants\n GRAPHQL_MAX_INT,\n GRAPHQL_MIN_INT,\n // Built-in Directives defined by the Spec\n specifiedDirectives,\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n // \"Enum\" of Type Kinds\n TypeKind,\n // Constant Deprecation Reason\n DEFAULT_DEPRECATION_REASON,\n // GraphQL Types for introspection.\n introspectionTypes,\n __Schema,\n __Directive,\n __DirectiveLocation,\n __Type,\n __Field,\n __InputValue,\n __EnumValue,\n __TypeKind,\n // Meta-field definitions.\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n // Predicates\n isSchema,\n isDirective,\n isType,\n isScalarType,\n isObjectType,\n isField,\n isArgument,\n isInterfaceType,\n isUnionType,\n isEnumType,\n isEnumValue,\n isInputObjectType,\n isInputField,\n isListType,\n isNonNullType,\n isInputType,\n isOutputType,\n isLeafType,\n isCompositeType,\n isAbstractType,\n isWrappingType,\n isNullableType,\n isNamedType,\n isRequiredArgument,\n isRequiredInputField,\n isSpecifiedScalarType,\n isIntrospectionType,\n isSpecifiedDirective,\n // Assertions\n assertSchema,\n assertDirective,\n assertType,\n assertScalarType,\n assertObjectType,\n assertField,\n assertArgument,\n assertInterfaceType,\n assertUnionType,\n assertEnumType,\n assertEnumValue,\n assertInputObjectType,\n assertInputField,\n assertListType,\n assertNonNullType,\n assertInputType,\n assertOutputType,\n assertLeafType,\n assertCompositeType,\n assertAbstractType,\n assertWrappingType,\n assertNullableType,\n assertNamedType,\n // Un-modifiers\n getNullableType,\n getNamedType,\n // Validate GraphQL schema.\n validateSchema,\n assertValidSchema,\n // Upholds the spec rules about naming.\n assertName,\n assertEnumValueName,\n} from './type/index.js';\n\nexport type {\n GraphQLType,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLLeafType,\n GraphQLCompositeType,\n GraphQLAbstractType,\n GraphQLWrappingType,\n GraphQLNullableType,\n GraphQLNullableInputType,\n GraphQLNullableOutputType,\n GraphQLNamedType,\n GraphQLNamedInputType,\n GraphQLNamedOutputType,\n ThunkReadonlyArray,\n ThunkObjMap,\n GraphQLSchemaConfig,\n GraphQLSchemaExtensions,\n GraphQLDirectiveConfig,\n GraphQLDirectiveExtensions,\n GraphQLArgumentConfig,\n GraphQLArgumentExtensions,\n GraphQLEnumTypeConfig,\n GraphQLEnumTypeExtensions,\n GraphQLEnumValueConfig,\n GraphQLEnumValueConfigMap,\n GraphQLEnumValueExtensions,\n GraphQLFieldConfig,\n GraphQLFieldConfigArgumentMap,\n GraphQLFieldConfigMap,\n GraphQLFieldExtensions,\n GraphQLFieldMap,\n GraphQLFieldResolver,\n GraphQLInputFieldConfig,\n GraphQLInputFieldConfigMap,\n GraphQLInputFieldExtensions,\n GraphQLInputFieldMap,\n GraphQLInputObjectTypeConfig,\n GraphQLInputObjectTypeExtensions,\n GraphQLInterfaceTypeConfig,\n GraphQLInterfaceTypeExtensions,\n GraphQLIsTypeOfFn,\n GraphQLObjectTypeConfig,\n GraphQLObjectTypeExtensions,\n GraphQLResolveInfo,\n ResponsePath,\n GraphQLScalarTypeConfig,\n GraphQLScalarTypeExtensions,\n GraphQLTypeResolver,\n GraphQLUnionTypeConfig,\n GraphQLUnionTypeExtensions,\n GraphQLScalarSerializer,\n GraphQLScalarValueParser,\n GraphQLScalarLiteralParser,\n GraphQLScalarOutputValueCoercer,\n GraphQLScalarInputValueCoercer,\n GraphQLScalarInputLiteralCoercer,\n GraphQLDefaultInput,\n} from './type/index.js';\n\n// Parse and operate on GraphQL language source files.\n// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313\n// eslint-disable-next-line @typescript-eslint/consistent-type-exports\nexport { Kind } from './language/kinds.js';\nexport {\n Token,\n Source,\n Location,\n OperationTypeNode,\n getLocation,\n // Print source location.\n printLocation,\n printSourceLocation,\n // Lex\n Lexer,\n TokenKind,\n // Parse\n parse,\n parseValue,\n parseConstValue,\n parseType,\n // Print\n print,\n // Visit\n visit,\n visitInParallel,\n getEnterLeaveForKind,\n BREAK,\n DirectiveLocation,\n // Predicates\n isDefinitionNode,\n isExecutableDefinitionNode,\n isSelectionNode,\n isValueNode,\n isConstValueNode,\n isTypeNode,\n isTypeSystemDefinitionNode,\n isTypeDefinitionNode,\n isTypeSystemExtensionNode,\n isTypeExtensionNode,\n} from './language/index.js';\n\nexport type {\n ParseOptions,\n SourceLocation,\n // Visitor utilities\n ASTVisitor,\n ASTVisitFn,\n ASTVisitorKeyMap,\n // AST nodes\n ASTNode,\n ASTKindToNode,\n // Each kind of AST node\n NameNode,\n DocumentNode,\n DefinitionNode,\n ExecutableDefinitionNode,\n OperationDefinitionNode,\n VariableDefinitionNode,\n VariableNode,\n SelectionSetNode,\n SelectionNode,\n FieldNode,\n ArgumentNode,\n FragmentArgumentNode,\n ConstArgumentNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n FragmentDefinitionNode,\n ValueNode,\n ConstValueNode,\n IntValueNode,\n FloatValueNode,\n StringValueNode,\n BooleanValueNode,\n NullValueNode,\n EnumValueNode,\n ListValueNode,\n ConstListValueNode,\n ObjectValueNode,\n ConstObjectValueNode,\n ObjectFieldNode,\n ConstObjectFieldNode,\n DirectiveNode,\n ConstDirectiveNode,\n TypeNode,\n NamedTypeNode,\n ListTypeNode,\n NonNullTypeNode,\n TypeSystemDefinitionNode,\n SchemaDefinitionNode,\n OperationTypeDefinitionNode,\n TypeDefinitionNode,\n ScalarTypeDefinitionNode,\n ObjectTypeDefinitionNode,\n FieldDefinitionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n UnionTypeDefinitionNode,\n EnumTypeDefinitionNode,\n EnumValueDefinitionNode,\n InputObjectTypeDefinitionNode,\n DirectiveDefinitionNode,\n TypeSystemExtensionNode,\n SchemaExtensionNode,\n TypeExtensionNode,\n ScalarTypeExtensionNode,\n ObjectTypeExtensionNode,\n InterfaceTypeExtensionNode,\n UnionTypeExtensionNode,\n EnumTypeExtensionNode,\n InputObjectTypeExtensionNode,\n} from './language/index.js';\n\n// Execute GraphQL queries.\nexport {\n execute,\n executeQueryOrMutationOrSubscriptionEvent,\n executeSubscriptionEvent,\n experimentalExecuteIncrementally,\n experimentalExecuteQueryOrMutationOrSubscriptionEvent,\n executeSync,\n defaultFieldResolver,\n defaultTypeResolver,\n responsePathAsArray,\n getArgumentValues,\n getVariableValues,\n getDirectiveValues,\n subscribe,\n createSourceEventStream,\n} from './execution/index.js';\n\nexport type {\n ExecutionArgs,\n ValidatedExecutionArgs,\n ExecutionResult,\n ExperimentalIncrementalExecutionResults,\n InitialIncrementalExecutionResult,\n SubsequentIncrementalExecutionResult,\n IncrementalDeferResult,\n IncrementalStreamResult,\n IncrementalResult,\n FormattedExecutionResult,\n FormattedInitialIncrementalExecutionResult,\n FormattedSubsequentIncrementalExecutionResult,\n FormattedIncrementalDeferResult,\n FormattedIncrementalStreamResult,\n FormattedIncrementalResult,\n} from './execution/index.js';\n\n// Validate GraphQL documents.\nexport {\n validate,\n ValidationContext,\n // All validation rules in the GraphQL Specification.\n specifiedRules,\n recommendedRules,\n // Individual validation rules.\n ExecutableDefinitionsRule,\n FieldsOnCorrectTypeRule,\n FragmentsOnCompositeTypesRule,\n KnownArgumentNamesRule,\n KnownDirectivesRule,\n KnownFragmentNamesRule,\n KnownOperationTypesRule,\n KnownTypeNamesRule,\n LoneAnonymousOperationRule,\n NoFragmentCyclesRule,\n NoUndefinedVariablesRule,\n NoUnusedFragmentsRule,\n NoUnusedVariablesRule,\n OverlappingFieldsCanBeMergedRule,\n PossibleFragmentSpreadsRule,\n ProvidedRequiredArgumentsRule,\n ScalarLeafsRule,\n SingleFieldSubscriptionsRule,\n UniqueArgumentNamesRule,\n UniqueDirectivesPerLocationRule,\n UniqueFragmentNamesRule,\n UniqueInputFieldNamesRule,\n UniqueOperationNamesRule,\n UniqueVariableNamesRule,\n ValuesOfCorrectTypeRule,\n VariablesAreInputTypesRule,\n VariablesInAllowedPositionRule,\n MaxIntrospectionDepthRule,\n // SDL-specific validation rules\n LoneSchemaDefinitionRule,\n UniqueOperationTypesRule,\n UniqueTypeNamesRule,\n UniqueEnumValueNamesRule,\n UniqueFieldDefinitionNamesRule,\n UniqueArgumentDefinitionNamesRule,\n UniqueDirectiveNamesRule,\n PossibleTypeExtensionsRule,\n // Custom validation rules\n NoDeprecatedCustomRule,\n NoSchemaIntrospectionCustomRule,\n} from './validation/index.js';\n\nexport type { ValidationRule } from './validation/index.js';\n\n// Create, format, and print GraphQL errors.\nexport { GraphQLError, syntaxError, locatedError } from './error/index.js';\n\nexport type {\n GraphQLErrorOptions,\n GraphQLFormattedError,\n GraphQLErrorExtensions,\n GraphQLFormattedErrorExtensions,\n} from './error/index.js';\n\n// Utilities for operating on GraphQL type schema and parsed sources.\nexport {\n // Produce the GraphQL query recommended for a full schema introspection.\n // Accepts optional IntrospectionOptions.\n getIntrospectionQuery,\n // Gets the target Operation from a Document.\n getOperationAST,\n // Convert a GraphQLSchema to an IntrospectionQuery.\n introspectionFromSchema,\n // Build a GraphQLSchema from an introspection result.\n buildClientSchema,\n // Build a GraphQLSchema from a parsed GraphQL Schema language AST.\n buildASTSchema,\n // Build a GraphQLSchema from a GraphQL schema language document.\n buildSchema,\n // Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.\n extendSchema,\n // Sort a GraphQLSchema.\n lexicographicSortSchema,\n // Print a GraphQLSchema to GraphQL Schema language.\n printSchema,\n // Print a GraphQLType to GraphQL Schema language.\n printType,\n // Print a GraphQLDirective to GraphQL Schema language.\n printDirective,\n // Prints the built-in introspection schema in the Schema Language format.\n printIntrospectionSchema,\n // Create a GraphQLType from a GraphQL language AST.\n typeFromAST,\n // Create a JavaScript value from a GraphQL language AST with a Type.\n /** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */\n valueFromAST,\n // Create a JavaScript value from a GraphQL language AST without a Type.\n valueFromASTUntyped,\n // Create a GraphQL language AST from a JavaScript value.\n /** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */\n astFromValue,\n // A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.\n TypeInfo,\n visitWithTypeInfo,\n // Converts a value to a const value by replacing variables.\n replaceVariables,\n // Create a GraphQL literal (AST) from a JavaScript input value.\n valueToLiteral,\n // Coerces a JavaScript value to a GraphQL type, or returns undefined.\n coerceInputValue,\n // Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined.\n coerceInputLiteral,\n // Validate a JavaScript value with a GraphQL type, collecting all errors.\n validateInputValue,\n // Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors.\n validateInputLiteral,\n // Concatenates multiple AST together.\n concatAST,\n // Separates an AST into an AST per Operation.\n separateOperations,\n // Strips characters that are not significant to the validity or execution of a GraphQL document.\n stripIgnoredCharacters,\n // Comparators for types\n isEqualType,\n isTypeSubTypeOf,\n doTypesOverlap,\n // Compares two GraphQLSchemas and detects breaking changes.\n BreakingChangeType,\n DangerousChangeType,\n SafeChangeType,\n findBreakingChanges,\n findDangerousChanges,\n findSchemaChanges,\n} from './utilities/index.js';\n\nexport type {\n IntrospectionOptions,\n IntrospectionQuery,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionInputType,\n IntrospectionOutputType,\n IntrospectionScalarType,\n IntrospectionObjectType,\n IntrospectionInterfaceType,\n IntrospectionUnionType,\n IntrospectionEnumType,\n IntrospectionInputObjectType,\n IntrospectionTypeRef,\n IntrospectionInputTypeRef,\n IntrospectionOutputTypeRef,\n IntrospectionNamedTypeRef,\n IntrospectionListTypeRef,\n IntrospectionNonNullTypeRef,\n IntrospectionField,\n IntrospectionInputValue,\n IntrospectionEnumValue,\n IntrospectionDirective,\n BuildSchemaOptions,\n BreakingChange,\n SafeChange,\n DangerousChange,\n TypedQueryDocumentNode,\n} from './utilities/index.js';\n"]} \ No newline at end of file diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000000..9385cc8ab2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,150 @@ +/** + * GraphQL.js provides a reference implementation for the GraphQL specification + * but is also a useful utility for operating on GraphQL files and building + * sophisticated tools. + * + * This primary module exports a general purpose function for fulfilling all + * steps of the GraphQL specification in a single operation, but also includes + * utilities for every part of the GraphQL specification: + * + * - Parsing the GraphQL language. + * - Building a GraphQL type schema. + * - Validating a GraphQL request against a type schema. + * - Executing a GraphQL request against a type schema. + * + * This also includes utility functions for operating on GraphQL types and + * GraphQL documents to facilitate building tools. + * + * You may also import from each sub-directory directly. For example, the + * following two import statements are equivalent: + * + * ```ts + * import { parse } from 'graphql'; + * import { parse } from 'graphql/language'; + * ``` + * + * @packageDocumentation + */ +// The GraphQL.js version info. +export { version, versionInfo } from "./version.mjs"; +export { graphql, graphqlSync } from "./graphql.mjs"; +export { resolveObjMapThunk, resolveReadonlyArrayThunk, +// Definitions +GraphQLSchema, GraphQLDirective, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, GraphQLList, GraphQLNonNull, +// Standard GraphQL Scalars +specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID, +// Int boundaries constants +GRAPHQL_MAX_INT, GRAPHQL_MIN_INT, +// Built-in Directives defined by the Spec +specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeferDirective, GraphQLStreamDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective, GraphQLOneOfDirective, +// "Enum" of Type Kinds +TypeKind, +// Constant Deprecation Reason +DEFAULT_DEPRECATION_REASON, +// GraphQL Types for introspection. +introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, +// Meta-field definitions. +SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, +// Predicates +isSchema, isDirective, isType, isScalarType, isObjectType, isField, isArgument, isInterfaceType, isUnionType, isEnumType, isEnumValue, isInputObjectType, isInputField, isListType, isNonNullType, isInputType, isOutputType, isLeafType, isCompositeType, isAbstractType, isWrappingType, isNullableType, isNamedType, isRequiredArgument, isRequiredInputField, isSpecifiedScalarType, isIntrospectionType, isSpecifiedDirective, +// Assertions +assertSchema, assertDirective, assertType, assertScalarType, assertObjectType, assertField, assertArgument, assertInterfaceType, assertUnionType, assertEnumType, assertEnumValue, assertInputObjectType, assertInputField, assertListType, assertNonNullType, assertInputType, assertOutputType, assertLeafType, assertCompositeType, assertAbstractType, assertWrappingType, assertNullableType, assertNamedType, +// Un-modifiers +getNullableType, getNamedType, +// Validate GraphQL schema. +validateSchema, assertValidSchema, +// Upholds the spec rules about naming. +assertName, assertEnumValueName, } from "./type/index.mjs"; +// Parse and operate on GraphQL language source files. +// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313 +// eslint-disable-next-line @typescript-eslint/consistent-type-exports +export { Kind } from "./language/kinds.mjs"; +export { Token, Source, Location, OperationTypeNode, getLocation, +// Print source location. +printLocation, printSourceLocation, +// Lex +Lexer, TokenKind, +// Parse +parse, parseValue, parseConstValue, parseType, +// Print +print, +// Visit +visit, visitInParallel, getEnterLeaveForKind, BREAK, DirectiveLocation, +// Predicates +isDefinitionNode, isExecutableDefinitionNode, isSelectionNode, isValueNode, isConstValueNode, isTypeNode, isTypeSystemDefinitionNode, isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode, } from "./language/index.mjs"; +// Execute GraphQL queries. +export { execute, executeQueryOrMutationOrSubscriptionEvent, executeSubscriptionEvent, experimentalExecuteIncrementally, experimentalExecuteQueryOrMutationOrSubscriptionEvent, executeSync, defaultFieldResolver, defaultTypeResolver, responsePathAsArray, getArgumentValues, getVariableValues, getDirectiveValues, subscribe, createSourceEventStream, } from "./execution/index.mjs"; +// Validate GraphQL documents. +export { validate, ValidationContext, +// All validation rules in the GraphQL Specification. +specifiedRules, recommendedRules, +// Individual validation rules. +ExecutableDefinitionsRule, FieldsOnCorrectTypeRule, FragmentsOnCompositeTypesRule, KnownArgumentNamesRule, KnownDirectivesRule, KnownFragmentNamesRule, KnownOperationTypesRule, KnownTypeNamesRule, LoneAnonymousOperationRule, NoFragmentCyclesRule, NoUndefinedVariablesRule, NoUnusedFragmentsRule, NoUnusedVariablesRule, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, ProvidedRequiredArgumentsRule, ScalarLeafsRule, SingleFieldSubscriptionsRule, UniqueArgumentNamesRule, UniqueDirectivesPerLocationRule, UniqueFragmentNamesRule, UniqueInputFieldNamesRule, UniqueOperationNamesRule, UniqueVariableNamesRule, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule, MaxIntrospectionDepthRule, +// SDL-specific validation rules +LoneSchemaDefinitionRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueArgumentDefinitionNamesRule, UniqueDirectiveNamesRule, PossibleTypeExtensionsRule, +// Custom validation rules +NoDeprecatedCustomRule, NoSchemaIntrospectionCustomRule, } from "./validation/index.mjs"; +// Create, format, and print GraphQL errors. +export { GraphQLError, syntaxError, locatedError } from "./error/index.mjs"; +// Utilities for operating on GraphQL type schema and parsed sources. +export { +// Produce the GraphQL query recommended for a full schema introspection. +// Accepts optional IntrospectionOptions. +getIntrospectionQuery, +// Gets the target Operation from a Document. +getOperationAST, +// Convert a GraphQLSchema to an IntrospectionQuery. +introspectionFromSchema, +// Build a GraphQLSchema from an introspection result. +buildClientSchema, +// Build a GraphQLSchema from a parsed GraphQL Schema language AST. +buildASTSchema, +// Build a GraphQLSchema from a GraphQL schema language document. +buildSchema, +// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. +extendSchema, +// Sort a GraphQLSchema. +lexicographicSortSchema, +// Print a GraphQLSchema to GraphQL Schema language. +printSchema, +// Print a GraphQLType to GraphQL Schema language. +printType, +// Print a GraphQLDirective to GraphQL Schema language. +printDirective, +// Prints the built-in introspection schema in the Schema Language format. +printIntrospectionSchema, +// Create a GraphQLType from a GraphQL language AST. +typeFromAST, +// Create a JavaScript value from a GraphQL language AST with a Type. +/** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */ +valueFromAST, +// Create a JavaScript value from a GraphQL language AST without a Type. +valueFromASTUntyped, +// Create a GraphQL language AST from a JavaScript value. +/** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */ +astFromValue, +// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. +TypeInfo, visitWithTypeInfo, +// Converts a value to a const value by replacing variables. +replaceVariables, +// Create a GraphQL literal (AST) from a JavaScript input value. +valueToLiteral, +// Coerces a JavaScript value to a GraphQL type, or returns undefined. +coerceInputValue, +// Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined. +coerceInputLiteral, +// Validate a JavaScript value with a GraphQL type, collecting all errors. +validateInputValue, +// Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors. +validateInputLiteral, +// Concatenates multiple AST together. +concatAST, +// Separates an AST into an AST per Operation. +separateOperations, +// Strips characters that are not significant to the validity or execution of a GraphQL document. +stripIgnoredCharacters, +// Comparators for types +isEqualType, isTypeSubTypeOf, doTypesOverlap, +// Compares two GraphQLSchemas and detects breaking changes. +BreakingChangeType, DangerousChangeType, SafeChangeType, findBreakingChanges, findDangerousChanges, findSchemaChanges, } from "./utilities/index.mjs"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000000..e66124b910 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,+BAA+B;AAC/B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAqB;AAIpD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAqB;AASpD,OAAO,EACL,kBAAkB,EAClB,yBAAyB;AACzB,cAAc;AACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,cAAc;AACd,2BAA2B;AAC3B,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,SAAS;AACT,2BAA2B;AAC3B,eAAe,EACf,eAAe;A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provides a reference implementation for the GraphQL specification\n * but is also a useful utility for operating on GraphQL files and building\n * sophisticated tools.\n *\n * This primary module exports a general purpose function for fulfilling all\n * steps of the GraphQL specification in a single operation, but also includes\n * utilities for every part of the GraphQL specification:\n *\n * - Parsing the GraphQL language.\n * - Building a GraphQL type schema.\n * - Validating a GraphQL request against a type schema.\n * - Executing a GraphQL request against a type schema.\n *\n * This also includes utility functions for operating on GraphQL types and\n * GraphQL documents to facilitate building tools.\n *\n * You may also import from each sub-directory directly. For example, the\n * following two import statements are equivalent:\n *\n * ```ts\n * import { parse } from 'graphql';\n * import { parse } from 'graphql/language';\n * ```\n *\n * @packageDocumentation\n */\n\n// The GraphQL.js version info.\nexport { version, versionInfo } from './version.js';\n\n// The primary entry point into fulfilling a GraphQL request.\nexport type { GraphQLArgs } from './graphql.js';\nexport { graphql, graphqlSync } from './graphql.js';\n\n// Create and operate on GraphQL type definitions and schema.\nexport type {\n GraphQLField,\n GraphQLArgument,\n GraphQLEnumValue,\n GraphQLInputField,\n} from './type/index.js';\nexport {\n resolveObjMapThunk,\n resolveReadonlyArrayThunk,\n // Definitions\n GraphQLSchema,\n GraphQLDirective,\n GraphQLScalarType,\n GraphQLObjectType,\n GraphQLInterfaceType,\n GraphQLUnionType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLList,\n GraphQLNonNull,\n // Standard GraphQL Scalars\n specifiedScalarTypes,\n GraphQLInt,\n GraphQLFloat,\n GraphQLString,\n GraphQLBoolean,\n GraphQLID,\n // Int boundaries constants\n GRAPHQL_MAX_INT,\n GRAPHQL_MIN_INT,\n // Built-in Directives defined by the Spec\n specifiedDirectives,\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n // \"Enum\" of Type Kinds\n TypeKind,\n // Constant Deprecation Reason\n DEFAULT_DEPRECATION_REASON,\n // GraphQL Types for introspection.\n introspectionTypes,\n __Schema,\n __Directive,\n __DirectiveLocation,\n __Type,\n __Field,\n __InputValue,\n __EnumValue,\n __TypeKind,\n // Meta-field definitions.\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n // Predicates\n isSchema,\n isDirective,\n isType,\n isScalarType,\n isObjectType,\n isField,\n isArgument,\n isInterfaceType,\n isUnionType,\n isEnumType,\n isEnumValue,\n isInputObjectType,\n isInputField,\n isListType,\n isNonNullType,\n isInputType,\n isOutputType,\n isLeafType,\n isCompositeType,\n isAbstractType,\n isWrappingType,\n isNullableType,\n isNamedType,\n isRequiredArgument,\n isRequiredInputField,\n isSpecifiedScalarType,\n isIntrospectionType,\n isSpecifiedDirective,\n // Assertions\n assertSchema,\n assertDirective,\n assertType,\n assertScalarType,\n assertObjectType,\n assertField,\n assertArgument,\n assertInterfaceType,\n assertUnionType,\n assertEnumType,\n assertEnumValue,\n assertInputObjectType,\n assertInputField,\n assertListType,\n assertNonNullType,\n assertInputType,\n assertOutputType,\n assertLeafType,\n assertCompositeType,\n assertAbstractType,\n assertWrappingType,\n assertNullableType,\n assertNamedType,\n // Un-modifiers\n getNullableType,\n getNamedType,\n // Validate GraphQL schema.\n validateSchema,\n assertValidSchema,\n // Upholds the spec rules about naming.\n assertName,\n assertEnumValueName,\n} from './type/index.js';\n\nexport type {\n GraphQLType,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLLeafType,\n GraphQLCompositeType,\n GraphQLAbstractType,\n GraphQLWrappingType,\n GraphQLNullableType,\n GraphQLNullableInputType,\n GraphQLNullableOutputType,\n GraphQLNamedType,\n GraphQLNamedInputType,\n GraphQLNamedOutputType,\n ThunkReadonlyArray,\n ThunkObjMap,\n GraphQLSchemaConfig,\n GraphQLSchemaExtensions,\n GraphQLDirectiveConfig,\n GraphQLDirectiveExtensions,\n GraphQLArgumentConfig,\n GraphQLArgumentExtensions,\n GraphQLEnumTypeConfig,\n GraphQLEnumTypeExtensions,\n GraphQLEnumValueConfig,\n GraphQLEnumValueConfigMap,\n GraphQLEnumValueExtensions,\n GraphQLFieldConfig,\n GraphQLFieldConfigArgumentMap,\n GraphQLFieldConfigMap,\n GraphQLFieldExtensions,\n GraphQLFieldMap,\n GraphQLFieldResolver,\n GraphQLInputFieldConfig,\n GraphQLInputFieldConfigMap,\n GraphQLInputFieldExtensions,\n GraphQLInputFieldMap,\n GraphQLInputObjectTypeConfig,\n GraphQLInputObjectTypeExtensions,\n GraphQLInterfaceTypeConfig,\n GraphQLInterfaceTypeExtensions,\n GraphQLIsTypeOfFn,\n GraphQLObjectTypeConfig,\n GraphQLObjectTypeExtensions,\n GraphQLResolveInfo,\n ResponsePath,\n GraphQLScalarTypeConfig,\n GraphQLScalarTypeExtensions,\n GraphQLTypeResolver,\n GraphQLUnionTypeConfig,\n GraphQLUnionTypeExtensions,\n GraphQLScalarSerializer,\n GraphQLScalarValueParser,\n GraphQLScalarLiteralParser,\n GraphQLScalarOutputValueCoercer,\n GraphQLScalarInputValueCoercer,\n GraphQLScalarInputLiteralCoercer,\n GraphQLDefaultInput,\n} from './type/index.js';\n\n// Parse and operate on GraphQL language source files.\n// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313\n// eslint-disable-next-line @typescript-eslint/consistent-type-exports\nexport { Kind } from './language/kinds.js';\nexport {\n Token,\n Source,\n Location,\n OperationTypeNode,\n getLocation,\n // Print source location.\n printLocation,\n printSourceLocation,\n // Lex\n Lexer,\n TokenKind,\n // Parse\n parse,\n parseValue,\n parseConstValue,\n parseType,\n // Print\n print,\n // Visit\n visit,\n visitInParallel,\n getEnterLeaveForKind,\n BREAK,\n DirectiveLocation,\n // Predicates\n isDefinitionNode,\n isExecutableDefinitionNode,\n isSelectionNode,\n isValueNode,\n isConstValueNode,\n isTypeNode,\n isTypeSystemDefinitionNode,\n isTypeDefinitionNode,\n isTypeSystemExtensionNode,\n isTypeExtensionNode,\n} from './language/index.js';\n\nexport type {\n ParseOptions,\n SourceLocation,\n // Visitor utilities\n ASTVisitor,\n ASTVisitFn,\n ASTVisitorKeyMap,\n // AST nodes\n ASTNode,\n ASTKindToNode,\n // Each kind of AST node\n NameNode,\n DocumentNode,\n DefinitionNode,\n ExecutableDefinitionNode,\n OperationDefinitionNode,\n VariableDefinitionNode,\n VariableNode,\n SelectionSetNode,\n SelectionNode,\n FieldNode,\n ArgumentNode,\n FragmentArgumentNode,\n ConstArgumentNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n FragmentDefinitionNode,\n ValueNode,\n ConstValueNode,\n IntValueNode,\n FloatValueNode,\n StringValueNode,\n BooleanValueNode,\n NullValueNode,\n EnumValueNode,\n ListValueNode,\n ConstListValueNode,\n ObjectValueNode,\n ConstObjectValueNode,\n ObjectFieldNode,\n ConstObjectFieldNode,\n DirectiveNode,\n ConstDirectiveNode,\n TypeNode,\n NamedTypeNode,\n ListTypeNode,\n NonNullTypeNode,\n TypeSystemDefinitionNode,\n SchemaDefinitionNode,\n OperationTypeDefinitionNode,\n TypeDefinitionNode,\n ScalarTypeDefinitionNode,\n ObjectTypeDefinitionNode,\n FieldDefinitionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n UnionTypeDefinitionNode,\n EnumTypeDefinitionNode,\n EnumValueDefinitionNode,\n InputObjectTypeDefinitionNode,\n DirectiveDefinitionNode,\n TypeSystemExtensionNode,\n SchemaExtensionNode,\n TypeExtensionNode,\n ScalarTypeExtensionNode,\n ObjectTypeExtensionNode,\n InterfaceTypeExtensionNode,\n UnionTypeExtensionNode,\n EnumTypeExtensionNode,\n InputObjectTypeExtensionNode,\n} from './language/index.js';\n\n// Execute GraphQL queries.\nexport {\n execute,\n executeQueryOrMutationOrSubscriptionEvent,\n executeSubscriptionEvent,\n experimentalExecuteIncrementally,\n experimentalExecuteQueryOrMutationOrSubscriptionEvent,\n executeSync,\n defaultFieldResolver,\n defaultTypeResolver,\n responsePathAsArray,\n getArgumentValues,\n getVariableValues,\n getDirectiveValues,\n subscribe,\n createSourceEventStream,\n} from './execution/index.js';\n\nexport type {\n ExecutionArgs,\n ValidatedExecutionArgs,\n ExecutionResult,\n ExperimentalIncrementalExecutionResults,\n InitialIncrementalExecutionResult,\n SubsequentIncrementalExecutionResult,\n IncrementalDeferResult,\n IncrementalStreamResult,\n IncrementalResult,\n FormattedExecutionResult,\n FormattedInitialIncrementalExecutionResult,\n FormattedSubsequentIncrementalExecutionResult,\n FormattedIncrementalDeferResult,\n FormattedIncrementalStreamResult,\n FormattedIncrementalResult,\n} from './execution/index.js';\n\n// Validate GraphQL documents.\nexport {\n validate,\n ValidationContext,\n // All validation rules in the GraphQL Specification.\n specifiedRules,\n recommendedRules,\n // Individual validation rules.\n ExecutableDefinitionsRule,\n FieldsOnCorrectTypeRule,\n FragmentsOnCompositeTypesRule,\n KnownArgumentNamesRule,\n KnownDirectivesRule,\n KnownFragmentNamesRule,\n KnownOperationTypesRule,\n KnownTypeNamesRule,\n LoneAnonymousOperationRule,\n NoFragmentCyclesRule,\n NoUndefinedVariablesRule,\n NoUnusedFragmentsRule,\n NoUnusedVariablesRule,\n OverlappingFieldsCanBeMergedRule,\n PossibleFragmentSpreadsRule,\n ProvidedRequiredArgumentsRule,\n ScalarLeafsRule,\n SingleFieldSubscriptionsRule,\n UniqueArgumentNamesRule,\n UniqueDirectivesPerLocationRule,\n UniqueFragmentNamesRule,\n UniqueInputFieldNamesRule,\n UniqueOperationNamesRule,\n UniqueVariableNamesRule,\n ValuesOfCorrectTypeRule,\n VariablesAreInputTypesRule,\n VariablesInAllowedPositionRule,\n MaxIntrospectionDepthRule,\n // SDL-specific validation rules\n LoneSchemaDefinitionRule,\n UniqueOperationTypesRule,\n UniqueTypeNamesRule,\n UniqueEnumValueNamesRule,\n UniqueFieldDefinitionNamesRule,\n UniqueArgumentDefinitionNamesRule,\n UniqueDirectiveNamesRule,\n PossibleTypeExtensionsRule,\n // Custom validation rules\n NoDeprecatedCustomRule,\n NoSchemaIntrospectionCustomRule,\n} from './validation/index.js';\n\nexport type { ValidationRule } from './validation/index.js';\n\n// Create, format, and print GraphQL errors.\nexport { GraphQLError, syntaxError, locatedError } from './error/index.js';\n\nexport type {\n GraphQLErrorOptions,\n GraphQLFormattedError,\n GraphQLErrorExtensions,\n GraphQLFormattedErrorExtensions,\n} from './error/index.js';\n\n// Utilities for operating on GraphQL type schema and parsed sources.\nexport {\n // Produce the GraphQL query recommended for a full schema introspection.\n // Accepts optional IntrospectionOptions.\n getIntrospectionQuery,\n // Gets the target Operation from a Document.\n getOperationAST,\n // Convert a GraphQLSchema to an IntrospectionQuery.\n introspectionFromSchema,\n // Build a GraphQLSchema from an introspection result.\n buildClientSchema,\n // Build a GraphQLSchema from a parsed GraphQL Schema language AST.\n buildASTSchema,\n // Build a GraphQLSchema from a GraphQL schema language document.\n buildSchema,\n // Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.\n extendSchema,\n // Sort a GraphQLSchema.\n lexicographicSortSchema,\n // Print a GraphQLSchema to GraphQL Schema language.\n printSchema,\n // Print a GraphQLType to GraphQL Schema language.\n printType,\n // Print a GraphQLDirective to GraphQL Schema language.\n printDirective,\n // Prints the built-in introspection schema in the Schema Language format.\n printIntrospectionSchema,\n // Create a GraphQLType from a GraphQL language AST.\n typeFromAST,\n // Create a JavaScript value from a GraphQL language AST with a Type.\n /** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */\n valueFromAST,\n // Create a JavaScript value from a GraphQL language AST without a Type.\n valueFromASTUntyped,\n // Create a GraphQL language AST from a JavaScript value.\n /** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */\n astFromValue,\n // A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.\n TypeInfo,\n visitWithTypeInfo,\n // Converts a value to a const value by replacing variables.\n replaceVariables,\n // Create a GraphQL literal (AST) from a JavaScript input value.\n valueToLiteral,\n // Coerces a JavaScript value to a GraphQL type, or returns undefined.\n coerceInputValue,\n // Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined.\n coerceInputLiteral,\n // Validate a JavaScript value with a GraphQL type, collecting all errors.\n validateInputValue,\n // Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors.\n validateInputLiteral,\n // Concatenates multiple AST together.\n concatAST,\n // Separates an AST into an AST per Operation.\n separateOperations,\n // Strips characters that are not significant to the validity or execution of a GraphQL document.\n stripIgnoredCharacters,\n // Comparators for types\n isEqualType,\n isTypeSubTypeOf,\n doTypesOverlap,\n // Compares two GraphQLSchemas and detects breaking changes.\n BreakingChangeType,\n DangerousChangeType,\n SafeChangeType,\n findBreakingChanges,\n findDangerousChanges,\n findSchemaChanges,\n} from './utilities/index.js';\n\nexport type {\n IntrospectionOptions,\n IntrospectionQuery,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionInputType,\n IntrospectionOutputType,\n IntrospectionScalarType,\n IntrospectionObjectType,\n IntrospectionInterfaceType,\n IntrospectionUnionType,\n IntrospectionEnumType,\n IntrospectionInputObjectType,\n IntrospectionTypeRef,\n IntrospectionInputTypeRef,\n IntrospectionOutputTypeRef,\n IntrospectionNamedTypeRef,\n IntrospectionListTypeRef,\n IntrospectionNonNullTypeRef,\n IntrospectionField,\n IntrospectionInputValue,\n IntrospectionEnumValue,\n IntrospectionDirective,\n BuildSchemaOptions,\n BreakingChange,\n SafeChange,\n DangerousChange,\n TypedQueryDocumentNode,\n} from './utilities/index.js';\n"]} \ No newline at end of file diff --git a/integrationTests/README.md b/integrationTests/README.md deleted file mode 100644 index 706449103a..0000000000 --- a/integrationTests/README.md +++ /dev/null @@ -1 +0,0 @@ -# TBD diff --git a/integrationTests/integration-test.js b/integrationTests/integration-test.js deleted file mode 100644 index 41718d0605..0000000000 --- a/integrationTests/integration-test.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -const os = require('os'); -const fs = require('fs'); -const path = require('path'); -const childProcess = require('child_process'); - -const { describe, it } = require('mocha'); - -function exec(command, options = {}) { - const output = childProcess.execSync(command, { - encoding: 'utf-8', - ...options, - }); - return output && output.trimEnd(); -} - -describe('Integration Tests', () => { - const tmpDir = path.join(os.tmpdir(), 'graphql-js-integrationTmp'); - fs.rmSync(tmpDir, { recursive: true, force: true }); - fs.mkdirSync(tmpDir); - - const distDir = path.resolve('./npmDist'); - const archiveName = exec(`npm --quiet pack ${distDir}`, { cwd: tmpDir }); - fs.renameSync( - path.join(tmpDir, archiveName), - path.join(tmpDir, 'graphql.tgz'), - ); - - function testOnNodeProject(projectName) { - const projectPath = path.join(__dirname, projectName); - - const packageJSONPath = path.join(projectPath, 'package.json'); - const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8')); - - it(packageJSON.description, () => { - exec(`cp -R ${projectPath} ${tmpDir}`); - - const cwd = path.join(tmpDir, projectName); - // TODO: figure out a way to run it with --ignore-scripts - exec('npm --quiet install', { cwd, stdio: 'inherit' }); - exec('npm --quiet test', { cwd, stdio: 'inherit' }); - }).timeout(120000); - } - - testOnNodeProject('ts'); - testOnNodeProject('node'); - testOnNodeProject('webpack'); -}); diff --git a/integrationTests/node/index.js b/integrationTests/node/index.js deleted file mode 100644 index 4815fe52e4..0000000000 --- a/integrationTests/node/index.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const { readFileSync } = require('fs'); - -const { version, graphqlSync } = require('graphql'); -const { buildSchema } = require('graphql/utilities'); - -assert.deepStrictEqual( - version, - JSON.parse(readFileSync('./node_modules/graphql/package.json')).version, -); - -const schema = buildSchema('type Query { hello: String }'); - -const result = graphqlSync({ - schema, - source: '{ hello }', - rootValue: { hello: 'world' }, -}); - -assert.deepStrictEqual(result, { - data: { - __proto__: null, - hello: 'world', - }, -}); diff --git a/integrationTests/node/package.json b/integrationTests/node/package.json deleted file mode 100644 index e4e8d36d97..0000000000 --- a/integrationTests/node/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "description": "graphql-js should work on all supported node versions", - "scripts": { - "test": "node test.js" - }, - "dependencies": { - "graphql": "file:../graphql.tgz" - } -} diff --git a/integrationTests/node/test.js b/integrationTests/node/test.js deleted file mode 100644 index 3f9ea8d35e..0000000000 --- a/integrationTests/node/test.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const childProcess = require('child_process'); - -const graphqlPackageJSON = require('graphql/package.json'); - -const nodeVersions = graphqlPackageJSON.engines.node - .split(' || ') - .map((version) => version.replace(/^(\^|>=)/, '')) - .sort((a, b) => b.localeCompare(a)); - -for (const version of nodeVersions) { - console.log(`Testing on node@${version} ...`); - - childProcess.execSync( - `docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app node:${version}-slim node ./index.js`, - { stdio: 'inherit' }, - ); -} diff --git a/integrationTests/ts/TypedQueryDocumentNode-test.ts b/integrationTests/ts/TypedQueryDocumentNode-test.ts deleted file mode 100644 index 89044efbfe..0000000000 --- a/integrationTests/ts/TypedQueryDocumentNode-test.ts +++ /dev/null @@ -1,72 +0,0 @@ -import type { ExecutionResult } from 'graphql/execution'; -import type { TypedQueryDocumentNode } from 'graphql/utilities'; - -import { parse } from 'graphql/language'; -import { execute } from 'graphql/execution'; -import { buildSchema } from 'graphql/utilities'; - -const schema = buildSchema(` - type Query { - test: String - } -`); - -// Tests for TS specific TypedQueryDocumentNode type -const queryDocument = parse('{ test }'); - -type ResponseData = { test: string }; -const typedQueryDocument = queryDocument as TypedQueryDocumentNode< - ResponseData, - {} ->; - -// Supports conversion to DocumentNode -execute({ schema, document: typedQueryDocument }); - -function wrappedExecute(document: TypedQueryDocumentNode) { - return execute({ schema, document }) as ExecutionResult; -} - -const response = wrappedExecute(typedQueryDocument); -const responseData: ResponseData | undefined | null = response.data; - -declare function runQueryA( - q: TypedQueryDocumentNode<{ output: string }, { input: string | null }>, -): void; - -// valid -declare const optionalInputRequiredOutput: TypedQueryDocumentNode< - { output: string }, - { input: string | null } ->; -runQueryA(optionalInputRequiredOutput); - -declare function runQueryB( - q: TypedQueryDocumentNode<{ output: string | null }, { input: string }>, -): void; - -// still valid: We still accept {output: string} as a valid result. -// We're now passing in {input: string} which is still assignable to {input: string | null} -runQueryB(optionalInputRequiredOutput); - -// valid: we now accept {output: null} as a valid Result -declare const optionalInputOptionalOutput: TypedQueryDocumentNode< - { output: string | null }, - { input: string | null } ->; -runQueryB(optionalInputOptionalOutput); - -// valid: we now only pass {input: string} to the query -declare const requiredInputRequiredOutput: TypedQueryDocumentNode< - { output: string }, - { input: string } ->; -runQueryB(requiredInputRequiredOutput); - -// valid: we now accept {output: null} as a valid Result AND -// we now only pass {input: string} to the query -declare const requiredInputOptionalOutput: TypedQueryDocumentNode< - { output: null }, - { input: string } ->; -runQueryB(requiredInputOptionalOutput); diff --git a/integrationTests/ts/basic-test.ts b/integrationTests/ts/basic-test.ts deleted file mode 100644 index a28bd840e7..0000000000 --- a/integrationTests/ts/basic-test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { ExecutionResult } from 'graphql/execution'; - -import { graphqlSync } from 'graphql'; -import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type'; - -const queryType: GraphQLObjectType = new GraphQLObjectType({ - name: 'Query', - fields: () => ({ - sayHi: { - type: GraphQLString, - args: { - who: { - type: GraphQLString, - defaultValue: 'World', - }, - }, - resolve(_root, args: { who: string }) { - return 'Hello ' + args.who; - }, - }, - }), -}); - -const schema: GraphQLSchema = new GraphQLSchema({ query: queryType }); - -const result: ExecutionResult = graphqlSync({ - schema, - source: ` - query helloWho($who: String){ - test(who: $who) - } - `, - variableValues: { who: 'Dolly' }, -}); diff --git a/integrationTests/ts/extensions-test.ts b/integrationTests/ts/extensions-test.ts deleted file mode 100644 index 689d943598..0000000000 --- a/integrationTests/ts/extensions-test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { GraphQLError } from 'graphql/error'; -import { GraphQLString, GraphQLObjectType } from 'graphql/type'; - -interface SomeExtension { - meaningOfLife: 42; -} - -declare module 'graphql' { - interface GraphQLObjectTypeExtensions<_TSource, _TContext> { - someObjectExtension?: SomeExtension; - } - - interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs> { - someFieldExtension?: SomeExtension; - } - - interface GraphQLArgumentExtensions { - someArgumentExtension?: SomeExtension; - } -} - -const queryType: GraphQLObjectType = new GraphQLObjectType({ - name: 'Query', - fields: () => ({ - sayHi: { - type: GraphQLString, - args: { - who: { - type: GraphQLString, - extensions: { - someArgumentExtension: { meaningOfLife: 42 }, - }, - }, - }, - resolve: (_root, args) => 'Hello ' + (args.who || 'World'), - extensions: { - someFieldExtension: { meaningOfLife: 42 }, - }, - }, - }), - extensions: { - someObjectExtension: { meaningOfLife: 42 }, - }, -}); - -function checkExtensionTypes(_test: SomeExtension | null | undefined) {} - -checkExtensionTypes(queryType.extensions.someObjectExtension); - -const sayHiField = queryType.getFields().sayHi; -checkExtensionTypes(sayHiField.extensions.someFieldExtension); - -checkExtensionTypes(sayHiField.args[0].extensions.someArgumentExtension); - -declare module 'graphql' { - export interface GraphQLErrorExtensions { - someErrorExtension?: SomeExtension; - } -} - -const error = new GraphQLError('foo'); -checkExtensionTypes(error.extensions.someErrorExtension); diff --git a/integrationTests/ts/internalImports-test.ts b/integrationTests/ts/internalImports-test.ts deleted file mode 100644 index 62d9628df8..0000000000 --- a/integrationTests/ts/internalImports-test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { NameNode } from 'graphql/language'; - -// Parser class is internal API so so any changes to it are never considered breaking changes. -// We just want to test that we are able to import it. -import { Parser } from 'graphql/language/parser'; - -const parser = new Parser('foo'); -const ast: NameNode = parser.parseName(); diff --git a/integrationTests/ts/package.json b/integrationTests/ts/package.json deleted file mode 100644 index 413e1aec05..0000000000 --- a/integrationTests/ts/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "private": true, - "description": "graphql-js should compile with all supported TS versions", - "scripts": { - "test": "node test.js" - }, - "dependencies": { - "graphql": "file:../graphql.tgz", - "typescript-4.1": "npm:typescript@4.1.x", - "typescript-4.2": "npm:typescript@4.2.x", - "typescript-4.3": "npm:typescript@4.3.x", - "typescript-4.4": "npm:typescript@4.4.x", - "typescript-4.5": "npm:typescript@4.5.x", - "typescript-4.6": "npm:typescript@4.6.x" - } -} diff --git a/integrationTests/ts/test.js b/integrationTests/ts/test.js deleted file mode 100644 index b328fe160b..0000000000 --- a/integrationTests/ts/test.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const path = require('path'); -const childProcess = require('child_process'); - -const { dependencies } = require('./package.json'); - -const tsVersions = Object.keys(dependencies) - .filter((pkg) => pkg.startsWith('typescript-')) - .sort((a, b) => b.localeCompare(a)); - -for (const version of tsVersions) { - console.log(`Testing on ${version} ...`); - childProcess.execSync(tscPath(version), { stdio: 'inherit' }); -} - -function tscPath(version) { - return path.join(__dirname, 'node_modules', version, 'bin/tsc'); -} diff --git a/integrationTests/ts/tsconfig.json b/integrationTests/ts/tsconfig.json deleted file mode 100644 index 403b4c213f..0000000000 --- a/integrationTests/ts/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"], - "strict": true, - "noEmit": true, - "types": [] - } -} diff --git a/integrationTests/webpack/entry.js b/integrationTests/webpack/entry.js deleted file mode 100644 index 8f51030c5d..0000000000 --- a/integrationTests/webpack/entry.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -const { buildSchema, graphqlSync } = require('graphql'); - -const schema = buildSchema('type Query { hello: String }'); - -const result = graphqlSync({ - schema, - source: '{ hello }', - rootValue: { hello: 'world' }, -}); - -module.exports = { result }; diff --git a/integrationTests/webpack/package.json b/integrationTests/webpack/package.json deleted file mode 100644 index aec7a21afb..0000000000 --- a/integrationTests/webpack/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "description": "graphql-js should be compatible with Webpack", - "scripts": { - "test": "webpack && node test.js" - }, - "dependencies": { - "graphql": "file:../graphql.tgz", - "webpack": "5.x.x", - "webpack-cli": "4.x.x" - } -} diff --git a/integrationTests/webpack/test.js b/integrationTests/webpack/test.js deleted file mode 100644 index 40c22233d4..0000000000 --- a/integrationTests/webpack/test.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -const assert = require('assert'); - -// eslint-disable-next-line node/no-missing-require -const { result } = require('./dist/main.js'); - -assert.deepStrictEqual(result, { - data: { - __proto__: null, - hello: 'world', - }, -}); -console.log('Test script: Got correct result from Webpack bundle!'); diff --git a/integrationTests/webpack/webpack.config.json b/integrationTests/webpack/webpack.config.json deleted file mode 100644 index 830b2bd52d..0000000000 --- a/integrationTests/webpack/webpack.config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "mode": "production", - "entry": "./entry.js", - "output": { - "libraryTarget": "commonjs2" - } -} diff --git a/jsutils/AccumulatorMap.d.ts b/jsutils/AccumulatorMap.d.ts new file mode 100644 index 0000000000..1e2aac208f --- /dev/null +++ b/jsutils/AccumulatorMap.d.ts @@ -0,0 +1,7 @@ +/** + * ES6 Map with additional `add` method to accumulate items. + */ +export declare class AccumulatorMap extends Map> { + get [Symbol.toStringTag](): string; + add(key: K, item: T): void; +} diff --git a/jsutils/AccumulatorMap.js b/jsutils/AccumulatorMap.js new file mode 100644 index 0000000000..22225d7d2b --- /dev/null +++ b/jsutils/AccumulatorMap.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AccumulatorMap = void 0; +/** + * ES6 Map with additional `add` method to accumulate items. + */ +class AccumulatorMap extends Map { + get [Symbol.toStringTag]() { + return 'AccumulatorMap'; + } + add(key, item) { + const group = this.get(key); + if (group === undefined) { + this.set(key, [item]); + } + else { + group.push(item); + } + } +} +exports.AccumulatorMap = AccumulatorMap; +//# sourceMappingURL=AccumulatorMap.js.map \ No newline at end of file diff --git a/jsutils/AccumulatorMap.js.map b/jsutils/AccumulatorMap.js.map new file mode 100644 index 0000000000..2f2fd5309b --- /dev/null +++ b/jsutils/AccumulatorMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"AccumulatorMap.js","sourceRoot":"","sources":["../../src/jsutils/AccumulatorMap.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,cAAqB,SAAQ,GAAgB;IACxD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC/B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,IAAO;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAbD,wCAaC","sourcesContent":["/**\n * ES6 Map with additional `add` method to accumulate items.\n */\nexport class AccumulatorMap extends Map> {\n override get [Symbol.toStringTag]() {\n return 'AccumulatorMap';\n }\n\n add(key: K, item: T): void {\n const group = this.get(key);\n if (group === undefined) {\n this.set(key, [item]);\n } else {\n group.push(item);\n }\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/AccumulatorMap.mjs b/jsutils/AccumulatorMap.mjs new file mode 100644 index 0000000000..ff6221f991 --- /dev/null +++ b/jsutils/AccumulatorMap.mjs @@ -0,0 +1,18 @@ +/** + * ES6 Map with additional `add` method to accumulate items. + */ +export class AccumulatorMap extends Map { + get [Symbol.toStringTag]() { + return 'AccumulatorMap'; + } + add(key, item) { + const group = this.get(key); + if (group === undefined) { + this.set(key, [item]); + } + else { + group.push(item); + } + } +} +//# sourceMappingURL=AccumulatorMap.js.map \ No newline at end of file diff --git a/jsutils/AccumulatorMap.mjs.map b/jsutils/AccumulatorMap.mjs.map new file mode 100644 index 0000000000..47761a3d02 --- /dev/null +++ b/jsutils/AccumulatorMap.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"AccumulatorMap.js","sourceRoot":"","sources":["../../src/jsutils/AccumulatorMap.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,cAAqB,SAAQ,GAAgB;IACxD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC/B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,IAAO;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * ES6 Map with additional `add` method to accumulate items.\n */\nexport class AccumulatorMap extends Map> {\n override get [Symbol.toStringTag]() {\n return 'AccumulatorMap';\n }\n\n add(key: K, item: T): void {\n const group = this.get(key);\n if (group === undefined) {\n this.set(key, [item]);\n } else {\n group.push(item);\n }\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/BoxedPromiseOrValue.d.ts b/jsutils/BoxedPromiseOrValue.d.ts new file mode 100644 index 0000000000..603e53be0f --- /dev/null +++ b/jsutils/BoxedPromiseOrValue.d.ts @@ -0,0 +1,15 @@ +import type { PromiseOrValue } from './PromiseOrValue.js'; +/** + * A BoxedPromiseOrValue is a container for a value or promise where the value + * will be updated when the promise resolves. + * + * A BoxedPromiseOrValue may only be used with promises whose possible + * rejection has already been handled, otherwise this will lead to unhandled + * promise rejections. + * + * @internal + * */ +export declare class BoxedPromiseOrValue { + value: PromiseOrValue; + constructor(value: PromiseOrValue); +} diff --git a/jsutils/BoxedPromiseOrValue.js b/jsutils/BoxedPromiseOrValue.js new file mode 100644 index 0000000000..e3526a4510 --- /dev/null +++ b/jsutils/BoxedPromiseOrValue.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BoxedPromiseOrValue = void 0; +const isPromise_js_1 = require("./isPromise.js"); +/** + * A BoxedPromiseOrValue is a container for a value or promise where the value + * will be updated when the promise resolves. + * + * A BoxedPromiseOrValue may only be used with promises whose possible + * rejection has already been handled, otherwise this will lead to unhandled + * promise rejections. + * + * @internal + * */ +class BoxedPromiseOrValue { + constructor(value) { + this.value = value; + if ((0, isPromise_js_1.isPromise)(value)) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + value.then((resolved) => { + this.value = resolved; + }); + } + } +} +exports.BoxedPromiseOrValue = BoxedPromiseOrValue; +//# sourceMappingURL=BoxedPromiseOrValue.js.map \ No newline at end of file diff --git a/jsutils/BoxedPromiseOrValue.js.map b/jsutils/BoxedPromiseOrValue.js.map new file mode 100644 index 0000000000..c83a9ec3ec --- /dev/null +++ b/jsutils/BoxedPromiseOrValue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BoxedPromiseOrValue.js","sourceRoot":"","sources":["../../src/jsutils/BoxedPromiseOrValue.ts"],"names":[],"mappings":";;;AAAA,iDAA2C;AAG3C;;;;;;;;;KASK;AACL,MAAa,mBAAmB;IAG9B,YAAY,KAAwB;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,IAAA,wBAAS,EAAC,KAAK,CAAC,EAAE,CAAC;YACrB,mEAAmE;YACnE,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACtB,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAZD,kDAYC","sourcesContent":["import { isPromise } from './isPromise.js';\nimport type { PromiseOrValue } from './PromiseOrValue.js';\n\n/**\n * A BoxedPromiseOrValue is a container for a value or promise where the value\n * will be updated when the promise resolves.\n *\n * A BoxedPromiseOrValue may only be used with promises whose possible\n * rejection has already been handled, otherwise this will lead to unhandled\n * promise rejections.\n *\n * @internal\n * */\nexport class BoxedPromiseOrValue {\n value: PromiseOrValue;\n\n constructor(value: PromiseOrValue) {\n this.value = value;\n if (isPromise(value)) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n value.then((resolved) => {\n this.value = resolved;\n });\n }\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/BoxedPromiseOrValue.mjs b/jsutils/BoxedPromiseOrValue.mjs new file mode 100644 index 0000000000..9fc5f19717 --- /dev/null +++ b/jsutils/BoxedPromiseOrValue.mjs @@ -0,0 +1,23 @@ +import { isPromise } from "./isPromise.mjs"; +/** + * A BoxedPromiseOrValue is a container for a value or promise where the value + * will be updated when the promise resolves. + * + * A BoxedPromiseOrValue may only be used with promises whose possible + * rejection has already been handled, otherwise this will lead to unhandled + * promise rejections. + * + * @internal + * */ +export class BoxedPromiseOrValue { + constructor(value) { + this.value = value; + if (isPromise(value)) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + value.then((resolved) => { + this.value = resolved; + }); + } + } +} +//# sourceMappingURL=BoxedPromiseOrValue.js.map \ No newline at end of file diff --git a/jsutils/BoxedPromiseOrValue.mjs.map b/jsutils/BoxedPromiseOrValue.mjs.map new file mode 100644 index 0000000000..3c0dcf5b45 --- /dev/null +++ b/jsutils/BoxedPromiseOrValue.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"BoxedPromiseOrValue.js","sourceRoot":"","sources":["../../src/jsutils/BoxedPromiseOrValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAG3C;;;;;;;;;KASK;AACL,MAAM,OAAO,mBAAmB;IAG9B,YAAY,KAAwB;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,mEAAmE;YACnE,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACtB,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import { isPromise } from './isPromise.js';\nimport type { PromiseOrValue } from './PromiseOrValue.js';\n\n/**\n * A BoxedPromiseOrValue is a container for a value or promise where the value\n * will be updated when the promise resolves.\n *\n * A BoxedPromiseOrValue may only be used with promises whose possible\n * rejection has already been handled, otherwise this will lead to unhandled\n * promise rejections.\n *\n * @internal\n * */\nexport class BoxedPromiseOrValue {\n value: PromiseOrValue;\n\n constructor(value: PromiseOrValue) {\n this.value = value;\n if (isPromise(value)) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n value.then((resolved) => {\n this.value = resolved;\n });\n }\n }\n}\n"]} \ No newline at end of file diff --git a/src/jsutils/Maybe.ts b/jsutils/Maybe.d.ts similarity index 100% rename from src/jsutils/Maybe.ts rename to jsutils/Maybe.d.ts diff --git a/jsutils/Maybe.js b/jsutils/Maybe.js new file mode 100644 index 0000000000..52ca347692 --- /dev/null +++ b/jsutils/Maybe.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Maybe.js.map \ No newline at end of file diff --git a/jsutils/Maybe.js.map b/jsutils/Maybe.js.map new file mode 100644 index 0000000000..64ae404386 --- /dev/null +++ b/jsutils/Maybe.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Maybe.js","sourceRoot":"","sources":["../../src/jsutils/Maybe.ts"],"names":[],"mappings":"","sourcesContent":["/** Conveniently represents flow's \"Maybe\" type https://flow.org/en/docs/types/maybe/ */\nexport type Maybe = null | undefined | T;\n"]} \ No newline at end of file diff --git a/jsutils/Maybe.mjs b/jsutils/Maybe.mjs new file mode 100644 index 0000000000..9cdff50f4c --- /dev/null +++ b/jsutils/Maybe.mjs @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=Maybe.js.map \ No newline at end of file diff --git a/jsutils/Maybe.mjs.map b/jsutils/Maybe.mjs.map new file mode 100644 index 0000000000..64ae404386 --- /dev/null +++ b/jsutils/Maybe.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Maybe.js","sourceRoot":"","sources":["../../src/jsutils/Maybe.ts"],"names":[],"mappings":"","sourcesContent":["/** Conveniently represents flow's \"Maybe\" type https://flow.org/en/docs/types/maybe/ */\nexport type Maybe = null | undefined | T;\n"]} \ No newline at end of file diff --git a/jsutils/ObjMap.d.ts b/jsutils/ObjMap.d.ts new file mode 100644 index 0000000000..067b6ce631 --- /dev/null +++ b/jsutils/ObjMap.d.ts @@ -0,0 +1,18 @@ +export interface ObjMap { + [key: string]: T; +} +export type ObjMapLike = ObjMap | { + [key: string]: T; +}; +export interface ReadOnlyObjMap { + readonly [key: string]: T; +} +export interface ReadOnlyObjMapWithSymbol { + readonly [key: string | symbol]: T; +} +export type ReadOnlyObjMapLike = ReadOnlyObjMap | { + readonly [key: string]: T; +}; +export type ReadOnlyObjMapSymbolLike = ReadOnlyObjMapWithSymbol | { + readonly [key: string | symbol]: T; +}; diff --git a/jsutils/ObjMap.js b/jsutils/ObjMap.js new file mode 100644 index 0000000000..47124f50cd --- /dev/null +++ b/jsutils/ObjMap.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=ObjMap.js.map \ No newline at end of file diff --git a/jsutils/ObjMap.js.map b/jsutils/ObjMap.js.map new file mode 100644 index 0000000000..870ea0eb4e --- /dev/null +++ b/jsutils/ObjMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ObjMap.js","sourceRoot":"","sources":["../../src/jsutils/ObjMap.ts"],"names":[],"mappings":"","sourcesContent":["export interface ObjMap {\n [key: string]: T;\n}\n\nexport type ObjMapLike = ObjMap | { [key: string]: T };\n\nexport interface ReadOnlyObjMap {\n readonly [key: string]: T;\n}\n\nexport interface ReadOnlyObjMapWithSymbol {\n readonly [key: string | symbol]: T;\n}\n\nexport type ReadOnlyObjMapLike =\n | ReadOnlyObjMap\n | { readonly [key: string]: T };\n\nexport type ReadOnlyObjMapSymbolLike =\n | ReadOnlyObjMapWithSymbol\n | { readonly [key: string | symbol]: T };\n"]} \ No newline at end of file diff --git a/jsutils/ObjMap.mjs b/jsutils/ObjMap.mjs new file mode 100644 index 0000000000..8df79b1d5d --- /dev/null +++ b/jsutils/ObjMap.mjs @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ObjMap.js.map \ No newline at end of file diff --git a/jsutils/ObjMap.mjs.map b/jsutils/ObjMap.mjs.map new file mode 100644 index 0000000000..870ea0eb4e --- /dev/null +++ b/jsutils/ObjMap.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ObjMap.js","sourceRoot":"","sources":["../../src/jsutils/ObjMap.ts"],"names":[],"mappings":"","sourcesContent":["export interface ObjMap {\n [key: string]: T;\n}\n\nexport type ObjMapLike = ObjMap | { [key: string]: T };\n\nexport interface ReadOnlyObjMap {\n readonly [key: string]: T;\n}\n\nexport interface ReadOnlyObjMapWithSymbol {\n readonly [key: string | symbol]: T;\n}\n\nexport type ReadOnlyObjMapLike =\n | ReadOnlyObjMap\n | { readonly [key: string]: T };\n\nexport type ReadOnlyObjMapSymbolLike =\n | ReadOnlyObjMapWithSymbol\n | { readonly [key: string | symbol]: T };\n"]} \ No newline at end of file diff --git a/jsutils/Path.d.ts b/jsutils/Path.d.ts new file mode 100644 index 0000000000..b02c87fa66 --- /dev/null +++ b/jsutils/Path.d.ts @@ -0,0 +1,14 @@ +import type { Maybe } from './Maybe.js'; +export interface Path { + readonly prev: Path | undefined; + readonly key: string | number; + readonly typename: string | undefined; +} +/** + * Given a Path and a key, return a new Path containing the new key. + */ +export declare function addPath(prev: Readonly | undefined, key: string | number, typename: string | undefined): Path; +/** + * Given a Path, return an Array of the path keys. + */ +export declare function pathToArray(path: Maybe>): Array; diff --git a/jsutils/Path.js b/jsutils/Path.js new file mode 100644 index 0000000000..fa1c6dfdee --- /dev/null +++ b/jsutils/Path.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.addPath = addPath; +exports.pathToArray = pathToArray; +/** + * Given a Path and a key, return a new Path containing the new key. + */ +function addPath(prev, key, typename) { + return { prev, key, typename }; +} +/** + * Given a Path, return an Array of the path keys. + */ +function pathToArray(path) { + const flattened = []; + let curr = path; + while (curr) { + flattened.push(curr.key); + curr = curr.prev; + } + return flattened.reverse(); +} +//# sourceMappingURL=Path.js.map \ No newline at end of file diff --git a/jsutils/Path.js.map b/jsutils/Path.js.map new file mode 100644 index 0000000000..8b768ebc5b --- /dev/null +++ b/jsutils/Path.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Path.js","sourceRoot":"","sources":["../../src/jsutils/Path.ts"],"names":[],"mappings":";;AAWA,0BAMC;AAKD,kCAUC;AAxBD;;GAEG;AACH,SAAgB,OAAO,CACrB,IAAgC,EAChC,GAAoB,EACpB,QAA4B;IAE5B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CACzB,IAA2B;IAE3B,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,OAAO,IAAI,EAAE,CAAC;QACZ,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import type { Maybe } from './Maybe.js';\n\nexport interface Path {\n readonly prev: Path | undefined;\n readonly key: string | number;\n readonly typename: string | undefined;\n}\n\n/**\n * Given a Path and a key, return a new Path containing the new key.\n */\nexport function addPath(\n prev: Readonly | undefined,\n key: string | number,\n typename: string | undefined,\n): Path {\n return { prev, key, typename };\n}\n\n/**\n * Given a Path, return an Array of the path keys.\n */\nexport function pathToArray(\n path: Maybe>,\n): Array {\n const flattened = [];\n let curr = path;\n while (curr) {\n flattened.push(curr.key);\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n"]} \ No newline at end of file diff --git a/jsutils/Path.mjs b/jsutils/Path.mjs new file mode 100644 index 0000000000..bcf8c17fe8 --- /dev/null +++ b/jsutils/Path.mjs @@ -0,0 +1,19 @@ +/** + * Given a Path and a key, return a new Path containing the new key. + */ +export function addPath(prev, key, typename) { + return { prev, key, typename }; +} +/** + * Given a Path, return an Array of the path keys. + */ +export function pathToArray(path) { + const flattened = []; + let curr = path; + while (curr) { + flattened.push(curr.key); + curr = curr.prev; + } + return flattened.reverse(); +} +//# sourceMappingURL=Path.js.map \ No newline at end of file diff --git a/jsutils/Path.mjs.map b/jsutils/Path.mjs.map new file mode 100644 index 0000000000..83f4711b1a --- /dev/null +++ b/jsutils/Path.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Path.js","sourceRoot":"","sources":["../../src/jsutils/Path.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,UAAU,OAAO,CACrB,IAAgC,EAChC,GAAoB,EACpB,QAA4B;IAE5B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,IAA2B;IAE3B,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,OAAO,IAAI,EAAE,CAAC;QACZ,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import type { Maybe } from './Maybe.js';\n\nexport interface Path {\n readonly prev: Path | undefined;\n readonly key: string | number;\n readonly typename: string | undefined;\n}\n\n/**\n * Given a Path and a key, return a new Path containing the new key.\n */\nexport function addPath(\n prev: Readonly | undefined,\n key: string | number,\n typename: string | undefined,\n): Path {\n return { prev, key, typename };\n}\n\n/**\n * Given a Path, return an Array of the path keys.\n */\nexport function pathToArray(\n path: Maybe>,\n): Array {\n const flattened = [];\n let curr = path;\n while (curr) {\n flattened.push(curr.key);\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n"]} \ No newline at end of file diff --git a/src/jsutils/PromiseOrValue.ts b/jsutils/PromiseOrValue.d.ts similarity index 100% rename from src/jsutils/PromiseOrValue.ts rename to jsutils/PromiseOrValue.d.ts diff --git a/jsutils/PromiseOrValue.js b/jsutils/PromiseOrValue.js new file mode 100644 index 0000000000..2c8ccca3dd --- /dev/null +++ b/jsutils/PromiseOrValue.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=PromiseOrValue.js.map \ No newline at end of file diff --git a/jsutils/PromiseOrValue.js.map b/jsutils/PromiseOrValue.js.map new file mode 100644 index 0000000000..cfd028aa29 --- /dev/null +++ b/jsutils/PromiseOrValue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PromiseOrValue.js","sourceRoot":"","sources":["../../src/jsutils/PromiseOrValue.ts"],"names":[],"mappings":"","sourcesContent":["export type PromiseOrValue = Promise | T;\n"]} \ No newline at end of file diff --git a/jsutils/PromiseOrValue.mjs b/jsutils/PromiseOrValue.mjs new file mode 100644 index 0000000000..dd04344185 --- /dev/null +++ b/jsutils/PromiseOrValue.mjs @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=PromiseOrValue.js.map \ No newline at end of file diff --git a/jsutils/PromiseOrValue.mjs.map b/jsutils/PromiseOrValue.mjs.map new file mode 100644 index 0000000000..cfd028aa29 --- /dev/null +++ b/jsutils/PromiseOrValue.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"PromiseOrValue.js","sourceRoot":"","sources":["../../src/jsutils/PromiseOrValue.ts"],"names":[],"mappings":"","sourcesContent":["export type PromiseOrValue = Promise | T;\n"]} \ No newline at end of file diff --git a/jsutils/capitalize.d.ts b/jsutils/capitalize.d.ts new file mode 100644 index 0000000000..d4df77077a --- /dev/null +++ b/jsutils/capitalize.d.ts @@ -0,0 +1,4 @@ +/** + * Converts the first character of string to upper case and the remaining to lower case. + */ +export declare function capitalize(str: string): string; diff --git a/jsutils/capitalize.js b/jsutils/capitalize.js new file mode 100644 index 0000000000..a49608a3ec --- /dev/null +++ b/jsutils/capitalize.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.capitalize = capitalize; +/** + * Converts the first character of string to upper case and the remaining to lower case. + */ +function capitalize(str) { + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +} +//# sourceMappingURL=capitalize.js.map \ No newline at end of file diff --git a/jsutils/capitalize.js.map b/jsutils/capitalize.js.map new file mode 100644 index 0000000000..6e43ca0856 --- /dev/null +++ b/jsutils/capitalize.js.map @@ -0,0 +1 @@ +{"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../src/jsutils/capitalize.ts"],"names":[],"mappings":";;AAGA,gCAEC;AALD;;GAEG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC","sourcesContent":["/**\n * Converts the first character of string to upper case and the remaining to lower case.\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n}\n"]} \ No newline at end of file diff --git a/jsutils/capitalize.mjs b/jsutils/capitalize.mjs new file mode 100644 index 0000000000..e25afca0ca --- /dev/null +++ b/jsutils/capitalize.mjs @@ -0,0 +1,7 @@ +/** + * Converts the first character of string to upper case and the remaining to lower case. + */ +export function capitalize(str) { + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +} +//# sourceMappingURL=capitalize.js.map \ No newline at end of file diff --git a/jsutils/capitalize.mjs.map b/jsutils/capitalize.mjs.map new file mode 100644 index 0000000000..9e3f6ad63c --- /dev/null +++ b/jsutils/capitalize.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../src/jsutils/capitalize.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC","sourcesContent":["/**\n * Converts the first character of string to upper case and the remaining to lower case.\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n}\n"]} \ No newline at end of file diff --git a/jsutils/devAssert.d.ts b/jsutils/devAssert.d.ts new file mode 100644 index 0000000000..96ade0d601 --- /dev/null +++ b/jsutils/devAssert.d.ts @@ -0,0 +1 @@ +export declare function devAssert(condition: boolean, message: string): void; diff --git a/jsutils/devAssert.js b/jsutils/devAssert.js new file mode 100644 index 0000000000..a6bb906c44 --- /dev/null +++ b/jsutils/devAssert.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.devAssert = devAssert; +function devAssert(condition, message) { + if (!condition) { + throw new Error(message); + } +} +//# sourceMappingURL=devAssert.js.map \ No newline at end of file diff --git a/jsutils/devAssert.js.map b/jsutils/devAssert.js.map new file mode 100644 index 0000000000..4936b0ca98 --- /dev/null +++ b/jsutils/devAssert.js.map @@ -0,0 +1 @@ +{"version":3,"file":"devAssert.js","sourceRoot":"","sources":["../../src/jsutils/devAssert.ts"],"names":[],"mappings":";;AAAA,8BAIC;AAJD,SAAgB,SAAS,CAAC,SAAkB,EAAE,OAAe;IAC3D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["export function devAssert(condition: boolean, message: string): void {\n if (!condition) {\n throw new Error(message);\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/devAssert.mjs b/jsutils/devAssert.mjs new file mode 100644 index 0000000000..c7080bffd3 --- /dev/null +++ b/jsutils/devAssert.mjs @@ -0,0 +1,6 @@ +export function devAssert(condition, message) { + if (!condition) { + throw new Error(message); + } +} +//# sourceMappingURL=devAssert.js.map \ No newline at end of file diff --git a/jsutils/devAssert.mjs.map b/jsutils/devAssert.mjs.map new file mode 100644 index 0000000000..582b90c01d --- /dev/null +++ b/jsutils/devAssert.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"devAssert.js","sourceRoot":"","sources":["../../src/jsutils/devAssert.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,SAAkB,EAAE,OAAe;IAC3D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["export function devAssert(condition: boolean, message: string): void {\n if (!condition) {\n throw new Error(message);\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/didYouMean.d.ts b/jsutils/didYouMean.d.ts new file mode 100644 index 0000000000..6ea2e15c79 --- /dev/null +++ b/jsutils/didYouMean.d.ts @@ -0,0 +1,5 @@ +/** + * Given [ A, B, C ] return ' Did you mean A, B, or C?'. + */ +export declare function didYouMean(suggestions: ReadonlyArray): string; +export declare function didYouMean(subMessage: string, suggestions: ReadonlyArray): string; diff --git a/jsutils/didYouMean.js b/jsutils/didYouMean.js new file mode 100644 index 0000000000..b9d34e51b9 --- /dev/null +++ b/jsutils/didYouMean.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.didYouMean = didYouMean; +const formatList_js_1 = require("./formatList.js"); +const MAX_SUGGESTIONS = 5; +function didYouMean(firstArg, secondArg) { + const [subMessage, suggestions] = secondArg + ? [firstArg, secondArg] + : [undefined, firstArg]; + if (suggestions.length === 0) { + return ''; + } + let message = ' Did you mean '; + if (subMessage != null) { + message += subMessage + ' '; + } + const suggestionList = (0, formatList_js_1.orList)(suggestions.slice(0, MAX_SUGGESTIONS).map((x) => `"${x}"`)); + return message + suggestionList + '?'; +} +//# sourceMappingURL=didYouMean.js.map \ No newline at end of file diff --git a/jsutils/didYouMean.js.map b/jsutils/didYouMean.js.map new file mode 100644 index 0000000000..ccc39a035d --- /dev/null +++ b/jsutils/didYouMean.js.map @@ -0,0 +1 @@ +{"version":3,"file":"didYouMean.js","sourceRoot":"","sources":["../../src/jsutils/didYouMean.ts"],"names":[],"mappings":";;AAYA,gCAqBC;AAjCD,mDAAyC;AAEzC,MAAM,eAAe,GAAG,CAAC,CAAC;AAU1B,SAAgB,UAAU,CACxB,QAAwC,EACxC,SAAiC;IAEjC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,SAAS;QACzC,CAAC,CAAC,CAAC,QAAkB,EAAE,SAAS,CAAC;QACjC,CAAC,CAAC,CAAC,SAAS,EAAE,QAAiC,CAAC,CAAC;IAEnD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,GAAG,gBAAgB,CAAC;IAC/B,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,IAAI,UAAU,GAAG,GAAG,CAAC;IAC9B,CAAC;IAED,MAAM,cAAc,GAAG,IAAA,sBAAM,EAC3B,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAC3D,CAAC;IACF,OAAO,OAAO,GAAG,cAAc,GAAG,GAAG,CAAC;AACxC,CAAC","sourcesContent":["import { orList } from './formatList.js';\n\nconst MAX_SUGGESTIONS = 5;\n\n/**\n * Given [ A, B, C ] return ' Did you mean A, B, or C?'.\n */\nexport function didYouMean(suggestions: ReadonlyArray): string;\nexport function didYouMean(\n subMessage: string,\n suggestions: ReadonlyArray,\n): string;\nexport function didYouMean(\n firstArg: string | ReadonlyArray,\n secondArg?: ReadonlyArray,\n) {\n const [subMessage, suggestions] = secondArg\n ? [firstArg as string, secondArg]\n : [undefined, firstArg as ReadonlyArray];\n\n if (suggestions.length === 0) {\n return '';\n }\n\n let message = ' Did you mean ';\n if (subMessage != null) {\n message += subMessage + ' ';\n }\n\n const suggestionList = orList(\n suggestions.slice(0, MAX_SUGGESTIONS).map((x) => `\"${x}\"`),\n );\n return message + suggestionList + '?';\n}\n"]} \ No newline at end of file diff --git a/jsutils/didYouMean.mjs b/jsutils/didYouMean.mjs new file mode 100644 index 0000000000..4d7fe41796 --- /dev/null +++ b/jsutils/didYouMean.mjs @@ -0,0 +1,17 @@ +import { orList } from "./formatList.mjs"; +const MAX_SUGGESTIONS = 5; +export function didYouMean(firstArg, secondArg) { + const [subMessage, suggestions] = secondArg + ? [firstArg, secondArg] + : [undefined, firstArg]; + if (suggestions.length === 0) { + return ''; + } + let message = ' Did you mean '; + if (subMessage != null) { + message += subMessage + ' '; + } + const suggestionList = orList(suggestions.slice(0, MAX_SUGGESTIONS).map((x) => `"${x}"`)); + return message + suggestionList + '?'; +} +//# sourceMappingURL=didYouMean.js.map \ No newline at end of file diff --git a/jsutils/didYouMean.mjs.map b/jsutils/didYouMean.mjs.map new file mode 100644 index 0000000000..92deb765cf --- /dev/null +++ b/jsutils/didYouMean.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"didYouMean.js","sourceRoot":"","sources":["../../src/jsutils/didYouMean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,yBAAwB;AAEzC,MAAM,eAAe,GAAG,CAAC,CAAC;AAU1B,MAAM,UAAU,UAAU,CACxB,QAAwC,EACxC,SAAiC;IAEjC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,SAAS;QACzC,CAAC,CAAC,CAAC,QAAkB,EAAE,SAAS,CAAC;QACjC,CAAC,CAAC,CAAC,SAAS,EAAE,QAAiC,CAAC,CAAC;IAEnD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,GAAG,gBAAgB,CAAC;IAC/B,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,IAAI,UAAU,GAAG,GAAG,CAAC;IAC9B,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,CAC3B,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAC3D,CAAC;IACF,OAAO,OAAO,GAAG,cAAc,GAAG,GAAG,CAAC;AACxC,CAAC","sourcesContent":["import { orList } from './formatList.js';\n\nconst MAX_SUGGESTIONS = 5;\n\n/**\n * Given [ A, B, C ] return ' Did you mean A, B, or C?'.\n */\nexport function didYouMean(suggestions: ReadonlyArray): string;\nexport function didYouMean(\n subMessage: string,\n suggestions: ReadonlyArray,\n): string;\nexport function didYouMean(\n firstArg: string | ReadonlyArray,\n secondArg?: ReadonlyArray,\n) {\n const [subMessage, suggestions] = secondArg\n ? [firstArg as string, secondArg]\n : [undefined, firstArg as ReadonlyArray];\n\n if (suggestions.length === 0) {\n return '';\n }\n\n let message = ' Did you mean ';\n if (subMessage != null) {\n message += subMessage + ' ';\n }\n\n const suggestionList = orList(\n suggestions.slice(0, MAX_SUGGESTIONS).map((x) => `\"${x}\"`),\n );\n return message + suggestionList + '?';\n}\n"]} \ No newline at end of file diff --git a/jsutils/formatList.d.ts b/jsutils/formatList.d.ts new file mode 100644 index 0000000000..05f1ef2f08 --- /dev/null +++ b/jsutils/formatList.d.ts @@ -0,0 +1,8 @@ +/** + * Given [ A, B, C ] return 'A, B, or C'. + */ +export declare function orList(items: ReadonlyArray): string; +/** + * Given [ A, B, C ] return 'A, B, and C'. + */ +export declare function andList(items: ReadonlyArray): string; diff --git a/jsutils/formatList.js b/jsutils/formatList.js new file mode 100644 index 0000000000..8a95fe2fa4 --- /dev/null +++ b/jsutils/formatList.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.orList = orList; +exports.andList = andList; +const invariant_js_1 = require("./invariant.js"); +/** + * Given [ A, B, C ] return 'A, B, or C'. + */ +function orList(items) { + return formatList('or', items); +} +/** + * Given [ A, B, C ] return 'A, B, and C'. + */ +function andList(items) { + return formatList('and', items); +} +function formatList(conjunction, items) { + (items.length !== 0) || (0, invariant_js_1.invariant)(false); + switch (items.length) { + case 1: + return items[0]; + case 2: + return items[0] + ' ' + conjunction + ' ' + items[1]; + } + const allButLast = items.slice(0, -1); + const lastItem = items.at(-1); + return allButLast.join(', ') + ', ' + conjunction + ' ' + lastItem; +} +//# sourceMappingURL=formatList.js.map \ No newline at end of file diff --git a/jsutils/formatList.js.map b/jsutils/formatList.js.map new file mode 100644 index 0000000000..785ecdb899 --- /dev/null +++ b/jsutils/formatList.js.map @@ -0,0 +1 @@ +{"version":3,"file":"formatList.js","sourceRoot":"","sources":["../../src/jsutils/formatList.ts"],"names":[],"mappings":";;AAKA,wBAEC;AAKD,0BAEC;AAdD,iDAA2C;AAE3C;;GAEG;AACH,SAAgB,MAAM,CAAC,KAA4B;IACjD,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,KAA4B;IAClD,OAAO,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,UAAU,CAAC,WAAmB,EAAE,KAA4B;IACnE,CAAU,KAAK,CAAC,MAAM,KAAK,CAAC,SAA5B,wBAAS,SAAqB;IAE9B,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,CAAC;YACJ,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,KAAK,CAAC;YACJ,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,WAAW,GAAG,GAAG,GAAG,QAAQ,CAAC;AACrE,CAAC","sourcesContent":["import { invariant } from './invariant.js';\n\n/**\n * Given [ A, B, C ] return 'A, B, or C'.\n */\nexport function orList(items: ReadonlyArray): string {\n return formatList('or', items);\n}\n\n/**\n * Given [ A, B, C ] return 'A, B, and C'.\n */\nexport function andList(items: ReadonlyArray): string {\n return formatList('and', items);\n}\n\nfunction formatList(conjunction: string, items: ReadonlyArray): string {\n invariant(items.length !== 0);\n\n switch (items.length) {\n case 1:\n return items[0];\n case 2:\n return items[0] + ' ' + conjunction + ' ' + items[1];\n }\n\n const allButLast = items.slice(0, -1);\n const lastItem = items.at(-1);\n return allButLast.join(', ') + ', ' + conjunction + ' ' + lastItem;\n}\n"]} \ No newline at end of file diff --git a/jsutils/formatList.mjs b/jsutils/formatList.mjs new file mode 100644 index 0000000000..e9b5b50929 --- /dev/null +++ b/jsutils/formatList.mjs @@ -0,0 +1,26 @@ +import { invariant } from "./invariant.mjs"; +/** + * Given [ A, B, C ] return 'A, B, or C'. + */ +export function orList(items) { + return formatList('or', items); +} +/** + * Given [ A, B, C ] return 'A, B, and C'. + */ +export function andList(items) { + return formatList('and', items); +} +function formatList(conjunction, items) { + (items.length !== 0) || invariant(false); + switch (items.length) { + case 1: + return items[0]; + case 2: + return items[0] + ' ' + conjunction + ' ' + items[1]; + } + const allButLast = items.slice(0, -1); + const lastItem = items.at(-1); + return allButLast.join(', ') + ', ' + conjunction + ' ' + lastItem; +} +//# sourceMappingURL=formatList.js.map \ No newline at end of file diff --git a/jsutils/formatList.mjs.map b/jsutils/formatList.mjs.map new file mode 100644 index 0000000000..f1e3e98a64 --- /dev/null +++ b/jsutils/formatList.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"formatList.js","sourceRoot":"","sources":["../../src/jsutils/formatList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAE3C;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAA4B;IACjD,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,KAA4B;IAClD,OAAO,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,UAAU,CAAC,WAAmB,EAAE,KAA4B;IACnE,CAAU,KAAK,CAAC,MAAM,KAAK,CAAC,KAA5B,SAAS,QAAqB;IAE9B,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,CAAC;YACJ,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,KAAK,CAAC;YACJ,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,WAAW,GAAG,GAAG,GAAG,QAAQ,CAAC;AACrE,CAAC","sourcesContent":["import { invariant } from './invariant.js';\n\n/**\n * Given [ A, B, C ] return 'A, B, or C'.\n */\nexport function orList(items: ReadonlyArray): string {\n return formatList('or', items);\n}\n\n/**\n * Given [ A, B, C ] return 'A, B, and C'.\n */\nexport function andList(items: ReadonlyArray): string {\n return formatList('and', items);\n}\n\nfunction formatList(conjunction: string, items: ReadonlyArray): string {\n invariant(items.length !== 0);\n\n switch (items.length) {\n case 1:\n return items[0];\n case 2:\n return items[0] + ' ' + conjunction + ' ' + items[1];\n }\n\n const allButLast = items.slice(0, -1);\n const lastItem = items.at(-1);\n return allButLast.join(', ') + ', ' + conjunction + ' ' + lastItem;\n}\n"]} \ No newline at end of file diff --git a/jsutils/getBySet.d.ts b/jsutils/getBySet.d.ts new file mode 100644 index 0000000000..1410e7e744 --- /dev/null +++ b/jsutils/getBySet.d.ts @@ -0,0 +1 @@ +export declare function getBySet(map: ReadonlyMap, U>, setToMatch: ReadonlySet): U | undefined; diff --git a/jsutils/getBySet.js b/jsutils/getBySet.js new file mode 100644 index 0000000000..32edecf3dc --- /dev/null +++ b/jsutils/getBySet.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getBySet = getBySet; +const isSameSet_js_1 = require("./isSameSet.js"); +function getBySet(map, setToMatch) { + for (const set of map.keys()) { + if ((0, isSameSet_js_1.isSameSet)(set, setToMatch)) { + return map.get(set); + } + } + return undefined; +} +//# sourceMappingURL=getBySet.js.map \ No newline at end of file diff --git a/jsutils/getBySet.js.map b/jsutils/getBySet.js.map new file mode 100644 index 0000000000..f833f21c28 --- /dev/null +++ b/jsutils/getBySet.js.map @@ -0,0 +1 @@ +{"version":3,"file":"getBySet.js","sourceRoot":"","sources":["../../src/jsutils/getBySet.ts"],"names":[],"mappings":";;AAEA,4BAUC;AAZD,iDAA2C;AAE3C,SAAgB,QAAQ,CACtB,GAAmC,EACnC,UAA0B;IAE1B,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,IAAI,IAAA,wBAAS,EAAC,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { isSameSet } from './isSameSet.js';\n\nexport function getBySet(\n map: ReadonlyMap, U>,\n setToMatch: ReadonlySet,\n): U | undefined {\n for (const set of map.keys()) {\n if (isSameSet(set, setToMatch)) {\n return map.get(set);\n }\n }\n return undefined;\n}\n"]} \ No newline at end of file diff --git a/jsutils/getBySet.mjs b/jsutils/getBySet.mjs new file mode 100644 index 0000000000..d0601d1255 --- /dev/null +++ b/jsutils/getBySet.mjs @@ -0,0 +1,10 @@ +import { isSameSet } from "./isSameSet.mjs"; +export function getBySet(map, setToMatch) { + for (const set of map.keys()) { + if (isSameSet(set, setToMatch)) { + return map.get(set); + } + } + return undefined; +} +//# sourceMappingURL=getBySet.js.map \ No newline at end of file diff --git a/jsutils/getBySet.mjs.map b/jsutils/getBySet.mjs.map new file mode 100644 index 0000000000..0908187533 --- /dev/null +++ b/jsutils/getBySet.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"getBySet.js","sourceRoot":"","sources":["../../src/jsutils/getBySet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAE3C,MAAM,UAAU,QAAQ,CACtB,GAAmC,EACnC,UAA0B;IAE1B,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,IAAI,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { isSameSet } from './isSameSet.js';\n\nexport function getBySet(\n map: ReadonlyMap, U>,\n setToMatch: ReadonlySet,\n): U | undefined {\n for (const set of map.keys()) {\n if (isSameSet(set, setToMatch)) {\n return map.get(set);\n }\n }\n return undefined;\n}\n"]} \ No newline at end of file diff --git a/jsutils/groupBy.d.ts b/jsutils/groupBy.d.ts new file mode 100644 index 0000000000..4695df90f8 --- /dev/null +++ b/jsutils/groupBy.d.ts @@ -0,0 +1,4 @@ +/** + * Groups array items into a Map, given a function to produce grouping key. + */ +export declare function groupBy(list: ReadonlyArray, keyFn: (item: T) => K): Map>; diff --git a/jsutils/groupBy.js b/jsutils/groupBy.js new file mode 100644 index 0000000000..a7bc1ef257 --- /dev/null +++ b/jsutils/groupBy.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.groupBy = groupBy; +const AccumulatorMap_js_1 = require("./AccumulatorMap.js"); +/** + * Groups array items into a Map, given a function to produce grouping key. + */ +function groupBy(list, keyFn) { + const result = new AccumulatorMap_js_1.AccumulatorMap(); + for (const item of list) { + result.add(keyFn(item), item); + } + return result; +} +//# sourceMappingURL=groupBy.js.map \ No newline at end of file diff --git a/jsutils/groupBy.js.map b/jsutils/groupBy.js.map new file mode 100644 index 0000000000..3065e23d65 --- /dev/null +++ b/jsutils/groupBy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"groupBy.js","sourceRoot":"","sources":["../../src/jsutils/groupBy.ts"],"names":[],"mappings":";;AAKA,0BASC;AAdD,2DAAqD;AAErD;;GAEG;AACH,SAAgB,OAAO,CACrB,IAAsB,EACtB,KAAqB;IAErB,MAAM,MAAM,GAAG,IAAI,kCAAc,EAAQ,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { AccumulatorMap } from './AccumulatorMap.js';\n\n/**\n * Groups array items into a Map, given a function to produce grouping key.\n */\nexport function groupBy(\n list: ReadonlyArray,\n keyFn: (item: T) => K,\n): Map> {\n const result = new AccumulatorMap();\n for (const item of list) {\n result.add(keyFn(item), item);\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/groupBy.mjs b/jsutils/groupBy.mjs new file mode 100644 index 0000000000..8509e0125c --- /dev/null +++ b/jsutils/groupBy.mjs @@ -0,0 +1,12 @@ +import { AccumulatorMap } from "./AccumulatorMap.mjs"; +/** + * Groups array items into a Map, given a function to produce grouping key. + */ +export function groupBy(list, keyFn) { + const result = new AccumulatorMap(); + for (const item of list) { + result.add(keyFn(item), item); + } + return result; +} +//# sourceMappingURL=groupBy.js.map \ No newline at end of file diff --git a/jsutils/groupBy.mjs.map b/jsutils/groupBy.mjs.map new file mode 100644 index 0000000000..128a45680b --- /dev/null +++ b/jsutils/groupBy.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"groupBy.js","sourceRoot":"","sources":["../../src/jsutils/groupBy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAA4B;AAErD;;GAEG;AACH,MAAM,UAAU,OAAO,CACrB,IAAsB,EACtB,KAAqB;IAErB,MAAM,MAAM,GAAG,IAAI,cAAc,EAAQ,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { AccumulatorMap } from './AccumulatorMap.js';\n\n/**\n * Groups array items into a Map, given a function to produce grouping key.\n */\nexport function groupBy(\n list: ReadonlyArray,\n keyFn: (item: T) => K,\n): Map> {\n const result = new AccumulatorMap();\n for (const item of list) {\n result.add(keyFn(item), item);\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/identityFunc.d.ts b/jsutils/identityFunc.d.ts new file mode 100644 index 0000000000..bf1bbcb943 --- /dev/null +++ b/jsutils/identityFunc.d.ts @@ -0,0 +1,4 @@ +/** + * Returns the first argument it receives. + */ +export declare function identityFunc(x: T): T; diff --git a/jsutils/identityFunc.js b/jsutils/identityFunc.js new file mode 100644 index 0000000000..7b9a1b8aff --- /dev/null +++ b/jsutils/identityFunc.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.identityFunc = identityFunc; +/** + * Returns the first argument it receives. + */ +function identityFunc(x) { + return x; +} +//# sourceMappingURL=identityFunc.js.map \ No newline at end of file diff --git a/jsutils/identityFunc.js.map b/jsutils/identityFunc.js.map new file mode 100644 index 0000000000..2123dc1b8a --- /dev/null +++ b/jsutils/identityFunc.js.map @@ -0,0 +1 @@ +{"version":3,"file":"identityFunc.js","sourceRoot":"","sources":["../../src/jsutils/identityFunc.ts"],"names":[],"mappings":";;AAGA,oCAEC;AALD;;GAEG;AACH,SAAgB,YAAY,CAAI,CAAI;IAClC,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * Returns the first argument it receives.\n */\nexport function identityFunc(x: T): T {\n return x;\n}\n"]} \ No newline at end of file diff --git a/jsutils/identityFunc.mjs b/jsutils/identityFunc.mjs new file mode 100644 index 0000000000..b4bf4f59ec --- /dev/null +++ b/jsutils/identityFunc.mjs @@ -0,0 +1,7 @@ +/** + * Returns the first argument it receives. + */ +export function identityFunc(x) { + return x; +} +//# sourceMappingURL=identityFunc.js.map \ No newline at end of file diff --git a/jsutils/identityFunc.mjs.map b/jsutils/identityFunc.mjs.map new file mode 100644 index 0000000000..0edfe7b4cb --- /dev/null +++ b/jsutils/identityFunc.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"identityFunc.js","sourceRoot":"","sources":["../../src/jsutils/identityFunc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,YAAY,CAAI,CAAI;IAClC,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * Returns the first argument it receives.\n */\nexport function identityFunc(x: T): T {\n return x;\n}\n"]} \ No newline at end of file diff --git a/jsutils/inspect.d.ts b/jsutils/inspect.d.ts new file mode 100644 index 0000000000..b6e0815a56 --- /dev/null +++ b/jsutils/inspect.d.ts @@ -0,0 +1,4 @@ +/** + * Used to print values in error messages. + */ +export declare function inspect(value: unknown): string; diff --git a/jsutils/inspect.js b/jsutils/inspect.js new file mode 100644 index 0000000000..7e350551b8 --- /dev/null +++ b/jsutils/inspect.js @@ -0,0 +1,94 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.inspect = inspect; +const MAX_ARRAY_LENGTH = 10; +const MAX_RECURSIVE_DEPTH = 2; +/** + * Used to print values in error messages. + */ +function inspect(value) { + return formatValue(value, []); +} +function formatValue(value, seenValues) { + switch (typeof value) { + case 'string': + return JSON.stringify(value); + case 'function': + return value.name ? `[function ${value.name}]` : '[function]'; + case 'object': + return formatObjectValue(value, seenValues); + default: + return String(value); + } +} +function formatObjectValue(value, previouslySeenValues) { + if (value === null) { + return 'null'; + } + if (previouslySeenValues.includes(value)) { + return '[Circular]'; + } + const seenValues = [...previouslySeenValues, value]; + if (isJSONable(value)) { + const jsonValue = value.toJSON(); + // check for infinite recursion + if (jsonValue !== value) { + return typeof jsonValue === 'string' + ? jsonValue + : formatValue(jsonValue, seenValues); + } + } + else if (Array.isArray(value)) { + return formatArray(value, seenValues); + } + return formatObject(value, seenValues); +} +function isJSONable(value) { + return typeof value.toJSON === 'function'; +} +function formatObject(object, seenValues) { + const entries = Object.entries(object); + if (entries.length === 0) { + return '{}'; + } + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[' + getObjectTag(object) + ']'; + } + const properties = entries.map(([key, value]) => key + ': ' + formatValue(value, seenValues)); + return '{ ' + properties.join(', ') + ' }'; +} +function formatArray(array, seenValues) { + if (array.length === 0) { + return '[]'; + } + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[Array]'; + } + const len = Math.min(MAX_ARRAY_LENGTH, array.length); + const remaining = array.length - len; + const items = []; + for (let i = 0; i < len; ++i) { + items.push(formatValue(array[i], seenValues)); + } + if (remaining === 1) { + items.push('... 1 more item'); + } + else if (remaining > 1) { + items.push(`... ${remaining} more items`); + } + return '[' + items.join(', ') + ']'; +} +function getObjectTag(object) { + const tag = Object.prototype.toString + .call(object) + .replace(/^\[object /, '') + .replace(/]$/, ''); + if (tag === 'Object' && typeof object.constructor === 'function') { + const name = object.constructor.name; + if (typeof name === 'string' && name !== '') { + return name; + } + } + return tag; +} +//# sourceMappingURL=inspect.js.map \ No newline at end of file diff --git a/jsutils/inspect.js.map b/jsutils/inspect.js.map new file mode 100644 index 0000000000..f4e171cd62 --- /dev/null +++ b/jsutils/inspect.js.map @@ -0,0 +1 @@ +{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/jsutils/inspect.ts"],"names":[],"mappings":";;AAMA,0BAEC;AARD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;GAEG;AACH,SAAgB,OAAO,CAAC,KAAc;IACpC,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,WAAW,CAClB,KAAc,EACd,UAAkC;IAElC,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,UAAU;YACb,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;QAChE,KAAK,QAAQ;YACX,OAAO,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC9C;YACE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,KAAoB,EACpB,oBAA4C;IAE5C,IAAI,KAAK,KAAK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,CAAC,YAAY,EAAE,EAAE,CAAC;SACzB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAErB,IAAI,GAAG,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACjE,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["const MAX_ARRAY_LENGTH = 10;\nconst MAX_RECURSIVE_DEPTH = 2;\n\n/**\n * Used to print values in error messages.\n */\nexport function inspect(value: unknown): string {\n return formatValue(value, []);\n}\n\nfunction formatValue(\n value: unknown,\n seenValues: ReadonlyArray,\n): string {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'function':\n return value.name ? `[function ${value.name}]` : '[function]';\n case 'object':\n return formatObjectValue(value, seenValues);\n default:\n return String(value);\n }\n}\n\nfunction formatObjectValue(\n value: object | null,\n previouslySeenValues: ReadonlyArray,\n): string {\n if (value === null) {\n return 'null';\n }\n\n if (previouslySeenValues.includes(value)) {\n return '[Circular]';\n }\n\n const seenValues = [...previouslySeenValues, value];\n\n if (isJSONable(value)) {\n const jsonValue = value.toJSON();\n\n // check for infinite recursion\n if (jsonValue !== value) {\n return typeof jsonValue === 'string'\n ? jsonValue\n : formatValue(jsonValue, seenValues);\n }\n } else if (Array.isArray(value)) {\n return formatArray(value, seenValues);\n }\n\n return formatObject(value, seenValues);\n}\n\nfunction isJSONable(value: any): value is { toJSON: () => unknown } {\n return typeof value.toJSON === 'function';\n}\n\nfunction formatObject(\n object: object,\n seenValues: ReadonlyArray,\n): string {\n const entries = Object.entries(object);\n if (entries.length === 0) {\n return '{}';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[' + getObjectTag(object) + ']';\n }\n\n const properties = entries.map(\n ([key, value]) => key + ': ' + formatValue(value, seenValues),\n );\n return '{ ' + properties.join(', ') + ' }';\n}\n\nfunction formatArray(\n array: ReadonlyArray,\n seenValues: ReadonlyArray,\n): string {\n if (array.length === 0) {\n return '[]';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[Array]';\n }\n\n const len = Math.min(MAX_ARRAY_LENGTH, array.length);\n const remaining = array.length - len;\n const items = [];\n\n for (let i = 0; i < len; ++i) {\n items.push(formatValue(array[i], seenValues));\n }\n\n if (remaining === 1) {\n items.push('... 1 more item');\n } else if (remaining > 1) {\n items.push(`... ${remaining} more items`);\n }\n\n return '[' + items.join(', ') + ']';\n}\n\nfunction getObjectTag(object: object): string {\n const tag = Object.prototype.toString\n .call(object)\n .replace(/^\\[object /, '')\n .replace(/]$/, '');\n\n if (tag === 'Object' && typeof object.constructor === 'function') {\n const name = object.constructor.name;\n if (typeof name === 'string' && name !== '') {\n return name;\n }\n }\n\n return tag;\n}\n"]} \ No newline at end of file diff --git a/jsutils/inspect.mjs b/jsutils/inspect.mjs new file mode 100644 index 0000000000..e0582e5457 --- /dev/null +++ b/jsutils/inspect.mjs @@ -0,0 +1,91 @@ +const MAX_ARRAY_LENGTH = 10; +const MAX_RECURSIVE_DEPTH = 2; +/** + * Used to print values in error messages. + */ +export function inspect(value) { + return formatValue(value, []); +} +function formatValue(value, seenValues) { + switch (typeof value) { + case 'string': + return JSON.stringify(value); + case 'function': + return value.name ? `[function ${value.name}]` : '[function]'; + case 'object': + return formatObjectValue(value, seenValues); + default: + return String(value); + } +} +function formatObjectValue(value, previouslySeenValues) { + if (value === null) { + return 'null'; + } + if (previouslySeenValues.includes(value)) { + return '[Circular]'; + } + const seenValues = [...previouslySeenValues, value]; + if (isJSONable(value)) { + const jsonValue = value.toJSON(); + // check for infinite recursion + if (jsonValue !== value) { + return typeof jsonValue === 'string' + ? jsonValue + : formatValue(jsonValue, seenValues); + } + } + else if (Array.isArray(value)) { + return formatArray(value, seenValues); + } + return formatObject(value, seenValues); +} +function isJSONable(value) { + return typeof value.toJSON === 'function'; +} +function formatObject(object, seenValues) { + const entries = Object.entries(object); + if (entries.length === 0) { + return '{}'; + } + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[' + getObjectTag(object) + ']'; + } + const properties = entries.map(([key, value]) => key + ': ' + formatValue(value, seenValues)); + return '{ ' + properties.join(', ') + ' }'; +} +function formatArray(array, seenValues) { + if (array.length === 0) { + return '[]'; + } + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[Array]'; + } + const len = Math.min(MAX_ARRAY_LENGTH, array.length); + const remaining = array.length - len; + const items = []; + for (let i = 0; i < len; ++i) { + items.push(formatValue(array[i], seenValues)); + } + if (remaining === 1) { + items.push('... 1 more item'); + } + else if (remaining > 1) { + items.push(`... ${remaining} more items`); + } + return '[' + items.join(', ') + ']'; +} +function getObjectTag(object) { + const tag = Object.prototype.toString + .call(object) + .replace(/^\[object /, '') + .replace(/]$/, ''); + if (tag === 'Object' && typeof object.constructor === 'function') { + const name = object.constructor.name; + if (typeof name === 'string' && name !== '') { + return name; + } + } + return tag; +} +//# sourceMappingURL=inspect.js.map \ No newline at end of file diff --git a/jsutils/inspect.mjs.map b/jsutils/inspect.mjs.map new file mode 100644 index 0000000000..54846f32cb --- /dev/null +++ b/jsutils/inspect.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/jsutils/inspect.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,WAAW,CAClB,KAAc,EACd,UAAkC;IAElC,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK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EAAE,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAChC,CAAC;SAAM,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,OAAO,SAAS,aAAa,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;AACtC,CAAC;AAED,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ;SAClC,IAAI,CAAC,MAAM,CAAC;SACZ,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;SACzB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAErB,IAAI,GAAG,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACjE,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["const MAX_ARRAY_LENGTH = 10;\nconst MAX_RECURSIVE_DEPTH = 2;\n\n/**\n * Used to print values in error messages.\n */\nexport function inspect(value: unknown): string {\n return formatValue(value, []);\n}\n\nfunction formatValue(\n value: unknown,\n seenValues: ReadonlyArray,\n): string {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'function':\n return value.name ? `[function ${value.name}]` : '[function]';\n case 'object':\n return formatObjectValue(value, seenValues);\n default:\n return String(value);\n }\n}\n\nfunction formatObjectValue(\n value: object | null,\n previouslySeenValues: ReadonlyArray,\n): string {\n if (value === null) {\n return 'null';\n }\n\n if (previouslySeenValues.includes(value)) {\n return '[Circular]';\n }\n\n const seenValues = [...previouslySeenValues, value];\n\n if (isJSONable(value)) {\n const jsonValue = value.toJSON();\n\n // check for infinite recursion\n if (jsonValue !== value) {\n return typeof jsonValue === 'string'\n ? jsonValue\n : formatValue(jsonValue, seenValues);\n }\n } else if (Array.isArray(value)) {\n return formatArray(value, seenValues);\n }\n\n return formatObject(value, seenValues);\n}\n\nfunction isJSONable(value: any): value is { toJSON: () => unknown } {\n return typeof value.toJSON === 'function';\n}\n\nfunction formatObject(\n object: object,\n seenValues: ReadonlyArray,\n): string {\n const entries = Object.entries(object);\n if (entries.length === 0) {\n return '{}';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[' + getObjectTag(object) + ']';\n }\n\n const properties = entries.map(\n ([key, value]) => key + ': ' + formatValue(value, seenValues),\n );\n return '{ ' + properties.join(', ') + ' }';\n}\n\nfunction formatArray(\n array: ReadonlyArray,\n seenValues: ReadonlyArray,\n): string {\n if (array.length === 0) {\n return '[]';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[Array]';\n }\n\n const len = Math.min(MAX_ARRAY_LENGTH, array.length);\n const remaining = array.length - len;\n const items = [];\n\n for (let i = 0; i < len; ++i) {\n items.push(formatValue(array[i], seenValues));\n }\n\n if (remaining === 1) {\n items.push('... 1 more item');\n } else if (remaining > 1) {\n items.push(`... ${remaining} more items`);\n }\n\n return '[' + items.join(', ') + ']';\n}\n\nfunction getObjectTag(object: object): string {\n const tag = Object.prototype.toString\n .call(object)\n .replace(/^\\[object /, '')\n .replace(/]$/, '');\n\n if (tag === 'Object' && typeof object.constructor === 'function') {\n const name = object.constructor.name;\n if (typeof name === 'string' && name !== '') {\n return name;\n }\n }\n\n return tag;\n}\n"]} \ No newline at end of file diff --git a/jsutils/instanceOf.d.ts b/jsutils/instanceOf.d.ts new file mode 100644 index 0000000000..fae55ada6c --- /dev/null +++ b/jsutils/instanceOf.d.ts @@ -0,0 +1,14 @@ +/** + * A replacement for instanceof which includes an error warning when multi-realm + * constructors are detected. + * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production + * See: https://webpack.js.org/guides/production/ + */ +export declare const instanceOf: (value: unknown, constructor: Constructor) => boolean; +interface Constructor { + prototype: { + [Symbol.toStringTag]: string; + }; + new (...args: Array): any; +} +export {}; diff --git a/jsutils/instanceOf.js b/jsutils/instanceOf.js new file mode 100644 index 0000000000..ccb0653621 --- /dev/null +++ b/jsutils/instanceOf.js @@ -0,0 +1,52 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.instanceOf = void 0; +const inspect_js_1 = require("./inspect.js"); +/* c8 ignore next 3 */ +const isProduction = globalThis.process != null && + // eslint-disable-next-line no-undef + process.env.NODE_ENV === 'production'; +/** + * A replacement for instanceof which includes an error warning when multi-realm + * constructors are detected. + * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production + * See: https://webpack.js.org/guides/production/ + */ +exports.instanceOf = +/* c8 ignore next 6 */ +// FIXME: https://github.com/graphql/graphql-js/issues/2317 +isProduction + ? function instanceOf(value, constructor) { + return value instanceof constructor; + } + : function instanceOf(value, constructor) { + if (value instanceof constructor) { + return true; + } + if (typeof value === 'object' && value !== null) { + // Prefer Symbol.toStringTag since it is immune to minification. + const className = constructor.prototype[Symbol.toStringTag]; + const valueClassName = + // We still need to support constructor's name to detect conflicts with older versions of this library. + Symbol.toStringTag in value + ? value[Symbol.toStringTag] + : value.constructor?.name; + if (className === valueClassName) { + const stringifiedValue = (0, inspect_js_1.inspect)(value); + throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm. + +Ensure that there is only one instance of "graphql" in the node_modules +directory. If different versions of "graphql" are the dependencies of other +relied on modules, use "resolutions" to ensure only one version is installed. + +https://yarnpkg.com/en/docs/selective-version-resolutions + +Duplicate "graphql" modules cannot be used at the same time since different +versions may have different capabilities and behavior. The data from one +version used in the function from another could produce confusing and +spurious results.`); + } + } + return false; + }; +//# sourceMappingURL=instanceOf.js.map \ No newline at end of file diff --git a/jsutils/instanceOf.js.map b/jsutils/instanceOf.js.map new file mode 100644 index 0000000000..52d040a8ea --- /dev/null +++ b/jsutils/instanceOf.js.map @@ -0,0 +1 @@ +{"version":3,"file":"instanceOf.js","sourceRoot":"","sources":["../../src/jsutils/instanceOf.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC,sBAAsB;AACtB,MAAM,YAAY,GAChB,UAAU,CAAC,OAAO,IAAI,IAAI;IAC1B,oCAAoC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAExC;;;;;GAKG;AACU,QAAA,UAAU;AACrB,sBAAsB;AACtB,2DAA2D;AAC3D,YAAY;IACV,CAAC,CAAC,SAAS,UAAU,CAAC,KAAc,EAAE,WAAwB;QAC1D,OAAO,KAAK,YAAY,WAAW,CAAC;IACtC,CAAC;IACH,CAAC,CAAC,SAAS,UAAU,CAAC,KAAc,EAAE,WAAwB;QAC1D,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAChD,gEAAgE;YAChE,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC5D,MAAM,cAAc;YAClB,uGAAuG;YACvG,MAAM,CAAC,WAAW,IAAI,KAAK;gBACzB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;gBAC3B,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;YAC9B,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;gBACjC,MAAM,gBAAgB,GAAG,IAAA,oBAAO,EAAC,KAAK,CAAC,CAAC;gBACxC,MAAM,IAAI,KAAK,CACb,cAAc,SAAS,KAAK,gBAAgB;;;;;;;;;;;kBAWxC,CACL,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC","sourcesContent":["import { inspect } from './inspect.js';\n\n/* c8 ignore next 3 */\nconst isProduction =\n globalThis.process != null &&\n // eslint-disable-next-line no-undef\n process.env.NODE_ENV === 'production';\n\n/**\n * A replacement for instanceof which includes an error warning when multi-realm\n * constructors are detected.\n * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production\n * See: https://webpack.js.org/guides/production/\n */\nexport const instanceOf: (value: unknown, constructor: Constructor) => boolean =\n /* c8 ignore next 6 */\n // FIXME: https://github.com/graphql/graphql-js/issues/2317\n isProduction\n ? function instanceOf(value: unknown, constructor: Constructor): boolean {\n return value instanceof constructor;\n }\n : function instanceOf(value: unknown, constructor: Constructor): boolean {\n if (value instanceof constructor) {\n return true;\n }\n if (typeof value === 'object' && value !== null) {\n // Prefer Symbol.toStringTag since it is immune to minification.\n const className = constructor.prototype[Symbol.toStringTag];\n const valueClassName =\n // We still need to support constructor's name to detect conflicts with older versions of this library.\n Symbol.toStringTag in value\n ? value[Symbol.toStringTag]\n : value.constructor?.name;\n if (className === valueClassName) {\n const stringifiedValue = inspect(value);\n throw new Error(\n `Cannot use ${className} \"${stringifiedValue}\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`,\n );\n }\n }\n return false;\n };\n\ninterface Constructor {\n prototype: {\n [Symbol.toStringTag]: string;\n };\n new (...args: Array): any;\n}\n"]} \ No newline at end of file diff --git a/jsutils/instanceOf.mjs b/jsutils/instanceOf.mjs new file mode 100644 index 0000000000..318966164b --- /dev/null +++ b/jsutils/instanceOf.mjs @@ -0,0 +1,49 @@ +import { inspect } from "./inspect.mjs"; +/* c8 ignore next 3 */ +const isProduction = globalThis.process != null && + // eslint-disable-next-line no-undef + process.env.NODE_ENV === 'production'; +/** + * A replacement for instanceof which includes an error warning when multi-realm + * constructors are detected. + * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production + * See: https://webpack.js.org/guides/production/ + */ +export const instanceOf = +/* c8 ignore next 6 */ +// FIXME: https://github.com/graphql/graphql-js/issues/2317 +isProduction + ? function instanceOf(value, constructor) { + return value instanceof constructor; + } + : function instanceOf(value, constructor) { + if (value instanceof constructor) { + return true; + } + if (typeof value === 'object' && value !== null) { + // Prefer Symbol.toStringTag since it is immune to minification. + const className = constructor.prototype[Symbol.toStringTag]; + const valueClassName = + // We still need to support constructor's name to detect conflicts with older versions of this library. + Symbol.toStringTag in value + ? value[Symbol.toStringTag] + : value.constructor?.name; + if (className === valueClassName) { + const stringifiedValue = inspect(value); + throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm. + +Ensure that there is only one instance of "graphql" in the node_modules +directory. If different versions of "graphql" are the dependencies of other +relied on modules, use "resolutions" to ensure only one version is installed. + +https://yarnpkg.com/en/docs/selective-version-resolutions + +Duplicate "graphql" modules cannot be used at the same time since different +versions may have different capabilities and behavior. The data from one +version used in the function from another could produce confusing and +spurious results.`); + } + } + return false; + }; +//# sourceMappingURL=instanceOf.js.map \ No newline at end of file diff --git a/jsutils/instanceOf.mjs.map b/jsutils/instanceOf.mjs.map new file mode 100644 index 0000000000..42acbb9a65 --- /dev/null +++ b/jsutils/instanceOf.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"instanceOf.js","sourceRoot":"","sources":["../../src/jsutils/instanceOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,sBAAqB;AAEvC,sBAAsB;AACtB,MAAM,YAAY,GAChB,UAAU,CAAC,OAAO,IAAI,IAAI;IAC1B,oCAAoC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU;AACrB,sBAAsB;AACtB,2DAA2D;AAC3D,YAAY;IACV,CAAC,CAAC,SAAS,UAAU,CAAC,KAAc,EAAE,WAAwB;QAC1D,OAAO,KAAK,YAAY,WAAW,CAAC;IACtC,CAAC;IACH,CAAC,CAAC,SAAS,UAAU,CAAC,KAAc,EAAE,WAAwB;QAC1D,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAChD,gEAAgE;YAChE,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC5D,MAAM,cAAc;YAClB,uGAAuG;YACvG,MAAM,CAAC,WAAW,IAAI,KAAK;gBACzB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;gBAC3B,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;YAC9B,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;gBACjC,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;gBACxC,MAAM,IAAI,KAAK,CACb,cAAc,SAAS,KAAK,gBAAgB;;;;;;;;;;;kBAWxC,CACL,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC","sourcesContent":["import { inspect } from './inspect.js';\n\n/* c8 ignore next 3 */\nconst isProduction =\n globalThis.process != null &&\n // eslint-disable-next-line no-undef\n process.env.NODE_ENV === 'production';\n\n/**\n * A replacement for instanceof which includes an error warning when multi-realm\n * constructors are detected.\n * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production\n * See: https://webpack.js.org/guides/production/\n */\nexport const instanceOf: (value: unknown, constructor: Constructor) => boolean =\n /* c8 ignore next 6 */\n // FIXME: https://github.com/graphql/graphql-js/issues/2317\n isProduction\n ? function instanceOf(value: unknown, constructor: Constructor): boolean {\n return value instanceof constructor;\n }\n : function instanceOf(value: unknown, constructor: Constructor): boolean {\n if (value instanceof constructor) {\n return true;\n }\n if (typeof value === 'object' && value !== null) {\n // Prefer Symbol.toStringTag since it is immune to minification.\n const className = constructor.prototype[Symbol.toStringTag];\n const valueClassName =\n // We still need to support constructor's name to detect conflicts with older versions of this library.\n Symbol.toStringTag in value\n ? value[Symbol.toStringTag]\n : value.constructor?.name;\n if (className === valueClassName) {\n const stringifiedValue = inspect(value);\n throw new Error(\n `Cannot use ${className} \"${stringifiedValue}\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`,\n );\n }\n }\n return false;\n };\n\ninterface Constructor {\n prototype: {\n [Symbol.toStringTag]: string;\n };\n new (...args: Array): any;\n}\n"]} \ No newline at end of file diff --git a/jsutils/invariant.d.ts b/jsutils/invariant.d.ts new file mode 100644 index 0000000000..9d969a43e3 --- /dev/null +++ b/jsutils/invariant.d.ts @@ -0,0 +1 @@ +export declare function invariant(condition: boolean, message?: string): asserts condition; diff --git a/jsutils/invariant.js b/jsutils/invariant.js new file mode 100644 index 0000000000..3552d92b18 --- /dev/null +++ b/jsutils/invariant.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.invariant = invariant; +function invariant(condition, message) { + if (!condition) { + throw new Error(message ?? 'Unexpected invariant triggered.'); + } +} +//# sourceMappingURL=invariant.js.map \ No newline at end of file diff --git a/jsutils/invariant.js.map b/jsutils/invariant.js.map new file mode 100644 index 0000000000..10bf2ea845 --- /dev/null +++ b/jsutils/invariant.js.map @@ -0,0 +1 @@ +{"version":3,"file":"invariant.js","sourceRoot":"","sources":["../../src/jsutils/invariant.ts"],"names":[],"mappings":";;AAAA,8BAOC;AAPD,SAAgB,SAAS,CACvB,SAAkB,EAClB,OAAgB;IAEhB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,iCAAiC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["export function invariant(\n condition: boolean,\n message?: string,\n): asserts condition {\n if (!condition) {\n throw new Error(message ?? 'Unexpected invariant triggered.');\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/invariant.mjs b/jsutils/invariant.mjs new file mode 100644 index 0000000000..51f609a8a8 --- /dev/null +++ b/jsutils/invariant.mjs @@ -0,0 +1,6 @@ +export function invariant(condition, message) { + if (!condition) { + throw new Error(message ?? 'Unexpected invariant triggered.'); + } +} +//# sourceMappingURL=invariant.js.map \ No newline at end of file diff --git a/jsutils/invariant.mjs.map b/jsutils/invariant.mjs.map new file mode 100644 index 0000000000..fd6f504358 --- /dev/null +++ b/jsutils/invariant.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"invariant.js","sourceRoot":"","sources":["../../src/jsutils/invariant.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CACvB,SAAkB,EAClB,OAAgB;IAEhB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,iCAAiC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["export function invariant(\n condition: boolean,\n message?: string,\n): asserts condition {\n if (!condition) {\n throw new Error(message ?? 'Unexpected invariant triggered.');\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/isAsyncIterable.d.ts b/jsutils/isAsyncIterable.d.ts new file mode 100644 index 0000000000..25a3e0b15a --- /dev/null +++ b/jsutils/isAsyncIterable.d.ts @@ -0,0 +1,5 @@ +/** + * Returns true if the provided object implements the AsyncIterator protocol via + * implementing a `Symbol.asyncIterator` method. + */ +export declare function isAsyncIterable(maybeAsyncIterable: any): maybeAsyncIterable is AsyncIterable; diff --git a/jsutils/isAsyncIterable.js b/jsutils/isAsyncIterable.js new file mode 100644 index 0000000000..687d1f6f1a --- /dev/null +++ b/jsutils/isAsyncIterable.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isAsyncIterable = isAsyncIterable; +/** + * Returns true if the provided object implements the AsyncIterator protocol via + * implementing a `Symbol.asyncIterator` method. + */ +function isAsyncIterable(maybeAsyncIterable) { + return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function'; +} +//# sourceMappingURL=isAsyncIterable.js.map \ No newline at end of file diff --git a/jsutils/isAsyncIterable.js.map b/jsutils/isAsyncIterable.js.map new file mode 100644 index 0000000000..28e8b3f24e --- /dev/null +++ b/jsutils/isAsyncIterable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isAsyncIterable.js","sourceRoot":"","sources":["../../src/jsutils/isAsyncIterable.ts"],"names":[],"mappings":";;AAIA,0CAIC;AARD;;;GAGG;AACH,SAAgB,eAAe,CAC7B,kBAAuB;IAEvB,OAAO,OAAO,kBAAkB,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * Returns true if the provided object implements the AsyncIterator protocol via\n * implementing a `Symbol.asyncIterator` method.\n */\nexport function isAsyncIterable(\n maybeAsyncIterable: any,\n): maybeAsyncIterable is AsyncIterable {\n return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function';\n}\n"]} \ No newline at end of file diff --git a/jsutils/isAsyncIterable.mjs b/jsutils/isAsyncIterable.mjs new file mode 100644 index 0000000000..f3561f7847 --- /dev/null +++ b/jsutils/isAsyncIterable.mjs @@ -0,0 +1,8 @@ +/** + * Returns true if the provided object implements the AsyncIterator protocol via + * implementing a `Symbol.asyncIterator` method. + */ +export function isAsyncIterable(maybeAsyncIterable) { + return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function'; +} +//# sourceMappingURL=isAsyncIterable.js.map \ No newline at end of file diff --git a/jsutils/isAsyncIterable.mjs.map b/jsutils/isAsyncIterable.mjs.map new file mode 100644 index 0000000000..30afd463bc --- /dev/null +++ b/jsutils/isAsyncIterable.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"isAsyncIterable.js","sourceRoot":"","sources":["../../src/jsutils/isAsyncIterable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,kBAAuB;IAEvB,OAAO,OAAO,kBAAkB,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * Returns true if the provided object implements the AsyncIterator protocol via\n * implementing a `Symbol.asyncIterator` method.\n */\nexport function isAsyncIterable(\n maybeAsyncIterable: any,\n): maybeAsyncIterable is AsyncIterable {\n return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function';\n}\n"]} \ No newline at end of file diff --git a/jsutils/isIterableObject.d.ts b/jsutils/isIterableObject.d.ts new file mode 100644 index 0000000000..63cf531af9 --- /dev/null +++ b/jsutils/isIterableObject.d.ts @@ -0,0 +1,18 @@ +/** + * Returns true if the provided object is an Object (i.e. not a string literal) + * and implements the Iterator protocol. + * + * This may be used in place of [Array.isArray()][isArray] to determine if + * an object should be iterated-over e.g. Array, Map, Set, Int8Array, + * TypedArray, etc. but excludes string literals. + * + * @example + * ```ts + * isIterableObject([ 1, 2, 3 ]) // true + * isIterableObject(new Map()) // true + * isIterableObject('ABC') // false + * isIterableObject({ key: 'value' }) // false + * isIterableObject({ length: 1, 0: 'Alpha' }) // false + * ``` + */ +export declare function isIterableObject(maybeIterable: any): maybeIterable is Iterable; diff --git a/jsutils/isIterableObject.js b/jsutils/isIterableObject.js new file mode 100644 index 0000000000..61d05d5b3e --- /dev/null +++ b/jsutils/isIterableObject.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isIterableObject = isIterableObject; +/** + * Returns true if the provided object is an Object (i.e. not a string literal) + * and implements the Iterator protocol. + * + * This may be used in place of [Array.isArray()][isArray] to determine if + * an object should be iterated-over e.g. Array, Map, Set, Int8Array, + * TypedArray, etc. but excludes string literals. + * + * @example + * ```ts + * isIterableObject([ 1, 2, 3 ]) // true + * isIterableObject(new Map()) // true + * isIterableObject('ABC') // false + * isIterableObject({ key: 'value' }) // false + * isIterableObject({ length: 1, 0: 'Alpha' }) // false + * ``` + */ +function isIterableObject(maybeIterable) { + return (typeof maybeIterable === 'object' && + typeof maybeIterable?.[Symbol.iterator] === 'function'); +} +//# sourceMappingURL=isIterableObject.js.map \ No newline at end of file diff --git a/jsutils/isIterableObject.js.map b/jsutils/isIterableObject.js.map new file mode 100644 index 0000000000..38c7309436 --- /dev/null +++ b/jsutils/isIterableObject.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isIterableObject.js","sourceRoot":"","sources":["../../src/jsutils/isIterableObject.ts"],"names":[],"mappings":";;AAiBA,4CAOC;AAxBD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,gBAAgB,CAC9B,aAAkB;IAElB,OAAO,CACL,OAAO,aAAa,KAAK,QAAQ;QACjC,OAAO,aAAa,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CACvD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Returns true if the provided object is an Object (i.e. not a string literal)\n * and implements the Iterator protocol.\n *\n * This may be used in place of [Array.isArray()][isArray] to determine if\n * an object should be iterated-over e.g. Array, Map, Set, Int8Array,\n * TypedArray, etc. but excludes string literals.\n *\n * @example\n * ```ts\n * isIterableObject([ 1, 2, 3 ]) // true\n * isIterableObject(new Map()) // true\n * isIterableObject('ABC') // false\n * isIterableObject({ key: 'value' }) // false\n * isIterableObject({ length: 1, 0: 'Alpha' }) // false\n * ```\n */\nexport function isIterableObject(\n maybeIterable: any,\n): maybeIterable is Iterable {\n return (\n typeof maybeIterable === 'object' &&\n typeof maybeIterable?.[Symbol.iterator] === 'function'\n );\n}\n"]} \ No newline at end of file diff --git a/jsutils/isIterableObject.mjs b/jsutils/isIterableObject.mjs new file mode 100644 index 0000000000..9a7d3748aa --- /dev/null +++ b/jsutils/isIterableObject.mjs @@ -0,0 +1,22 @@ +/** + * Returns true if the provided object is an Object (i.e. not a string literal) + * and implements the Iterator protocol. + * + * This may be used in place of [Array.isArray()][isArray] to determine if + * an object should be iterated-over e.g. Array, Map, Set, Int8Array, + * TypedArray, etc. but excludes string literals. + * + * @example + * ```ts + * isIterableObject([ 1, 2, 3 ]) // true + * isIterableObject(new Map()) // true + * isIterableObject('ABC') // false + * isIterableObject({ key: 'value' }) // false + * isIterableObject({ length: 1, 0: 'Alpha' }) // false + * ``` + */ +export function isIterableObject(maybeIterable) { + return (typeof maybeIterable === 'object' && + typeof maybeIterable?.[Symbol.iterator] === 'function'); +} +//# sourceMappingURL=isIterableObject.js.map \ No newline at end of file diff --git a/jsutils/isIterableObject.mjs.map b/jsutils/isIterableObject.mjs.map new file mode 100644 index 0000000000..80a1a85d3b --- /dev/null +++ b/jsutils/isIterableObject.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"isIterableObject.js","sourceRoot":"","sources":["../../src/jsutils/isIterableObject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,aAAkB;IAElB,OAAO,CACL,OAAO,aAAa,KAAK,QAAQ;QACjC,OAAO,aAAa,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CACvD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Returns true if the provided object is an Object (i.e. not a string literal)\n * and implements the Iterator protocol.\n *\n * This may be used in place of [Array.isArray()][isArray] to determine if\n * an object should be iterated-over e.g. Array, Map, Set, Int8Array,\n * TypedArray, etc. but excludes string literals.\n *\n * @example\n * ```ts\n * isIterableObject([ 1, 2, 3 ]) // true\n * isIterableObject(new Map()) // true\n * isIterableObject('ABC') // false\n * isIterableObject({ key: 'value' }) // false\n * isIterableObject({ length: 1, 0: 'Alpha' }) // false\n * ```\n */\nexport function isIterableObject(\n maybeIterable: any,\n): maybeIterable is Iterable {\n return (\n typeof maybeIterable === 'object' &&\n typeof maybeIterable?.[Symbol.iterator] === 'function'\n );\n}\n"]} \ No newline at end of file diff --git a/jsutils/isObjectLike.d.ts b/jsutils/isObjectLike.d.ts new file mode 100644 index 0000000000..a7c0baab3d --- /dev/null +++ b/jsutils/isObjectLike.d.ts @@ -0,0 +1,7 @@ +/** + * Return true if `value` is object-like. A value is object-like if it's not + * `null` and has a `typeof` result of "object". + */ +export declare function isObjectLike(value: unknown): value is { + [key: string]: unknown; +}; diff --git a/jsutils/isObjectLike.js b/jsutils/isObjectLike.js new file mode 100644 index 0000000000..843243dabb --- /dev/null +++ b/jsutils/isObjectLike.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isObjectLike = isObjectLike; +/** + * Return true if `value` is object-like. A value is object-like if it's not + * `null` and has a `typeof` result of "object". + */ +function isObjectLike(value) { + return typeof value == 'object' && value !== null; +} +//# sourceMappingURL=isObjectLike.js.map \ No newline at end of file diff --git a/jsutils/isObjectLike.js.map b/jsutils/isObjectLike.js.map new file mode 100644 index 0000000000..a186ac4e6b --- /dev/null +++ b/jsutils/isObjectLike.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isObjectLike.js","sourceRoot":"","sources":["../../src/jsutils/isObjectLike.ts"],"names":[],"mappings":";;AAIA,oCAIC;AARD;;;GAGG;AACH,SAAgB,YAAY,CAC1B,KAAc;IAEd,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC","sourcesContent":["/**\n * Return true if `value` is object-like. A value is object-like if it's not\n * `null` and has a `typeof` result of \"object\".\n */\nexport function isObjectLike(\n value: unknown,\n): value is { [key: string]: unknown } {\n return typeof value == 'object' && value !== null;\n}\n"]} \ No newline at end of file diff --git a/jsutils/isObjectLike.mjs b/jsutils/isObjectLike.mjs new file mode 100644 index 0000000000..90c364c5e1 --- /dev/null +++ b/jsutils/isObjectLike.mjs @@ -0,0 +1,8 @@ +/** + * Return true if `value` is object-like. A value is object-like if it's not + * `null` and has a `typeof` result of "object". + */ +export function isObjectLike(value) { + return typeof value == 'object' && value !== null; +} +//# sourceMappingURL=isObjectLike.js.map \ No newline at end of file diff --git a/jsutils/isObjectLike.mjs.map b/jsutils/isObjectLike.mjs.map new file mode 100644 index 0000000000..ad2ab1796d --- /dev/null +++ b/jsutils/isObjectLike.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"isObjectLike.js","sourceRoot":"","sources":["../../src/jsutils/isObjectLike.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAc;IAEd,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC","sourcesContent":["/**\n * Return true if `value` is object-like. A value is object-like if it's not\n * `null` and has a `typeof` result of \"object\".\n */\nexport function isObjectLike(\n value: unknown,\n): value is { [key: string]: unknown } {\n return typeof value == 'object' && value !== null;\n}\n"]} \ No newline at end of file diff --git a/jsutils/isPromise.d.ts b/jsutils/isPromise.d.ts new file mode 100644 index 0000000000..786de26185 --- /dev/null +++ b/jsutils/isPromise.d.ts @@ -0,0 +1,5 @@ +/** + * Returns true if the value acts like a Promise, i.e. has a "then" function, + * otherwise returns false. + */ +export declare function isPromise(value: any): value is Promise; diff --git a/jsutils/isPromise.js b/jsutils/isPromise.js new file mode 100644 index 0000000000..9e44e3ed51 --- /dev/null +++ b/jsutils/isPromise.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isPromise = isPromise; +/** + * Returns true if the value acts like a Promise, i.e. has a "then" function, + * otherwise returns false. + */ +function isPromise(value) { + return typeof value?.then === 'function'; +} +//# sourceMappingURL=isPromise.js.map \ No newline at end of file diff --git a/jsutils/isPromise.js.map b/jsutils/isPromise.js.map new file mode 100644 index 0000000000..a8c74892cc --- /dev/null +++ b/jsutils/isPromise.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isPromise.js","sourceRoot":"","sources":["../../src/jsutils/isPromise.ts"],"names":[],"mappings":";;AAIA,8BAEC;AAND;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAU;IAClC,OAAO,OAAO,KAAK,EAAE,IAAI,KAAK,UAAU,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * Returns true if the value acts like a Promise, i.e. has a \"then\" function,\n * otherwise returns false.\n */\nexport function isPromise(value: any): value is Promise {\n return typeof value?.then === 'function';\n}\n"]} \ No newline at end of file diff --git a/jsutils/isPromise.mjs b/jsutils/isPromise.mjs new file mode 100644 index 0000000000..b44b87decf --- /dev/null +++ b/jsutils/isPromise.mjs @@ -0,0 +1,8 @@ +/** + * Returns true if the value acts like a Promise, i.e. has a "then" function, + * otherwise returns false. + */ +export function isPromise(value) { + return typeof value?.then === 'function'; +} +//# sourceMappingURL=isPromise.js.map \ No newline at end of file diff --git a/jsutils/isPromise.mjs.map b/jsutils/isPromise.mjs.map new file mode 100644 index 0000000000..8459d89481 --- /dev/null +++ b/jsutils/isPromise.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"isPromise.js","sourceRoot":"","sources":["../../src/jsutils/isPromise.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAU;IAClC,OAAO,OAAO,KAAK,EAAE,IAAI,KAAK,UAAU,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * Returns true if the value acts like a Promise, i.e. has a \"then\" function,\n * otherwise returns false.\n */\nexport function isPromise(value: any): value is Promise {\n return typeof value?.then === 'function';\n}\n"]} \ No newline at end of file diff --git a/jsutils/isSameSet.d.ts b/jsutils/isSameSet.d.ts new file mode 100644 index 0000000000..43e7c8e9d0 --- /dev/null +++ b/jsutils/isSameSet.d.ts @@ -0,0 +1 @@ +export declare function isSameSet(setA: ReadonlySet, setB: ReadonlySet): boolean; diff --git a/jsutils/isSameSet.js b/jsutils/isSameSet.js new file mode 100644 index 0000000000..811b485a19 --- /dev/null +++ b/jsutils/isSameSet.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isSameSet = isSameSet; +function isSameSet(setA, setB) { + if (setA.size !== setB.size) { + return false; + } + for (const item of setA) { + if (!setB.has(item)) { + return false; + } + } + return true; +} +//# sourceMappingURL=isSameSet.js.map \ No newline at end of file diff --git a/jsutils/isSameSet.js.map b/jsutils/isSameSet.js.map new file mode 100644 index 0000000000..0f0d4d7a93 --- /dev/null +++ b/jsutils/isSameSet.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isSameSet.js","sourceRoot":"","sources":["../../src/jsutils/isSameSet.ts"],"names":[],"mappings":";;AAAA,8BAaC;AAbD,SAAgB,SAAS,CACvB,IAAoB,EACpB,IAAoB;IAEpB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["export function isSameSet(\n setA: ReadonlySet,\n setB: ReadonlySet,\n): boolean {\n if (setA.size !== setB.size) {\n return false;\n }\n for (const item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n return true;\n}\n"]} \ No newline at end of file diff --git a/jsutils/isSameSet.mjs b/jsutils/isSameSet.mjs new file mode 100644 index 0000000000..a072b0f509 --- /dev/null +++ b/jsutils/isSameSet.mjs @@ -0,0 +1,12 @@ +export function isSameSet(setA, setB) { + if (setA.size !== setB.size) { + return false; + } + for (const item of setA) { + if (!setB.has(item)) { + return false; + } + } + return true; +} +//# sourceMappingURL=isSameSet.js.map \ No newline at end of file diff --git a/jsutils/isSameSet.mjs.map b/jsutils/isSameSet.mjs.map new file mode 100644 index 0000000000..f50e279945 --- /dev/null +++ b/jsutils/isSameSet.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"isSameSet.js","sourceRoot":"","sources":["../../src/jsutils/isSameSet.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CACvB,IAAoB,EACpB,IAAoB;IAEpB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["export function isSameSet(\n setA: ReadonlySet,\n setB: ReadonlySet,\n): boolean {\n if (setA.size !== setB.size) {\n return false;\n }\n for (const item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n return true;\n}\n"]} \ No newline at end of file diff --git a/jsutils/keyMap.d.ts b/jsutils/keyMap.d.ts new file mode 100644 index 0000000000..531c93fa4d --- /dev/null +++ b/jsutils/keyMap.d.ts @@ -0,0 +1,29 @@ +import type { ObjMap } from './ObjMap.js'; +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * for each value in the array. + * + * This provides a convenient lookup for the array items if the key function + * produces unique results. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * const entriesByName = keyMap( + * phoneBook, + * entry => entry.name + * ) + * + * // { + * // Jon: { name: 'Jon', num: '555-1234' }, + * // Jenny: { name: 'Jenny', num: '867-5309' } + * // } + * + * const jennyEntry = entriesByName['Jenny'] + * + * // { name: 'Jenny', num: '857-6309' } + * ``` + */ +export declare function keyMap(list: ReadonlyArray, keyFn: (item: T) => string): ObjMap; diff --git a/jsutils/keyMap.js b/jsutils/keyMap.js new file mode 100644 index 0000000000..9e00484ec2 --- /dev/null +++ b/jsutils/keyMap.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.keyMap = keyMap; +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * for each value in the array. + * + * This provides a convenient lookup for the array items if the key function + * produces unique results. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * const entriesByName = keyMap( + * phoneBook, + * entry => entry.name + * ) + * + * // { + * // Jon: { name: 'Jon', num: '555-1234' }, + * // Jenny: { name: 'Jenny', num: '867-5309' } + * // } + * + * const jennyEntry = entriesByName['Jenny'] + * + * // { name: 'Jenny', num: '857-6309' } + * ``` + */ +function keyMap(list, keyFn) { + const result = Object.create(null); + for (const item of list) { + result[keyFn(item)] = item; + } + return result; +} +//# sourceMappingURL=keyMap.js.map \ No newline at end of file diff --git a/jsutils/keyMap.js.map b/jsutils/keyMap.js.map new file mode 100644 index 0000000000..9a5d1df004 --- /dev/null +++ b/jsutils/keyMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"keyMap.js","sourceRoot":"","sources":["../../src/jsutils/keyMap.ts"],"names":[],"mappings":";;AA6BA,wBASC;AApCD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,MAAM,CACpB,IAAsB,EACtB,KAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ObjMap } from './ObjMap.js';\n\n/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * for each value in the array.\n *\n * This provides a convenient lookup for the array items if the key function\n * produces unique results.\n * ```ts\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * const entriesByName = keyMap(\n * phoneBook,\n * entry => entry.name\n * )\n *\n * // {\n * // Jon: { name: 'Jon', num: '555-1234' },\n * // Jenny: { name: 'Jenny', num: '867-5309' }\n * // }\n *\n * const jennyEntry = entriesByName['Jenny']\n *\n * // { name: 'Jenny', num: '857-6309' }\n * ```\n */\nexport function keyMap(\n list: ReadonlyArray,\n keyFn: (item: T) => string,\n): ObjMap {\n const result = Object.create(null);\n for (const item of list) {\n result[keyFn(item)] = item;\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/keyMap.mjs b/jsutils/keyMap.mjs new file mode 100644 index 0000000000..2e69ca567e --- /dev/null +++ b/jsutils/keyMap.mjs @@ -0,0 +1,35 @@ +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * for each value in the array. + * + * This provides a convenient lookup for the array items if the key function + * produces unique results. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * const entriesByName = keyMap( + * phoneBook, + * entry => entry.name + * ) + * + * // { + * // Jon: { name: 'Jon', num: '555-1234' }, + * // Jenny: { name: 'Jenny', num: '867-5309' } + * // } + * + * const jennyEntry = entriesByName['Jenny'] + * + * // { name: 'Jenny', num: '857-6309' } + * ``` + */ +export function keyMap(list, keyFn) { + const result = Object.create(null); + for (const item of list) { + result[keyFn(item)] = item; + } + return result; +} +//# sourceMappingURL=keyMap.js.map \ No newline at end of file diff --git a/jsutils/keyMap.mjs.map b/jsutils/keyMap.mjs.map new file mode 100644 index 0000000000..69e5085a77 --- /dev/null +++ b/jsutils/keyMap.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"keyMap.js","sourceRoot":"","sources":["../../src/jsutils/keyMap.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,MAAM,CACpB,IAAsB,EACtB,KAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ObjMap } from './ObjMap.js';\n\n/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * for each value in the array.\n *\n * This provides a convenient lookup for the array items if the key function\n * produces unique results.\n * ```ts\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * const entriesByName = keyMap(\n * phoneBook,\n * entry => entry.name\n * )\n *\n * // {\n * // Jon: { name: 'Jon', num: '555-1234' },\n * // Jenny: { name: 'Jenny', num: '867-5309' }\n * // }\n *\n * const jennyEntry = entriesByName['Jenny']\n *\n * // { name: 'Jenny', num: '857-6309' }\n * ```\n */\nexport function keyMap(\n list: ReadonlyArray,\n keyFn: (item: T) => string,\n): ObjMap {\n const result = Object.create(null);\n for (const item of list) {\n result[keyFn(item)] = item;\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/keyValMap.d.ts b/jsutils/keyValMap.d.ts new file mode 100644 index 0000000000..6195041ba8 --- /dev/null +++ b/jsutils/keyValMap.d.ts @@ -0,0 +1,19 @@ +import type { ObjMap } from './ObjMap.js'; +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * and a function to produce the values from each item in the array. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * // { Jon: '555-1234', Jenny: '867-5309' } + * const phonesByName = keyValMap( + * phoneBook, + * entry => entry.name, + * entry => entry.num + * ) + * ``` + */ +export declare function keyValMap(list: ReadonlyArray, keyFn: (item: T) => string, valFn: (item: T) => V): ObjMap; diff --git a/jsutils/keyValMap.js b/jsutils/keyValMap.js new file mode 100644 index 0000000000..748b39d7b0 --- /dev/null +++ b/jsutils/keyValMap.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.keyValMap = keyValMap; +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * and a function to produce the values from each item in the array. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * // { Jon: '555-1234', Jenny: '867-5309' } + * const phonesByName = keyValMap( + * phoneBook, + * entry => entry.name, + * entry => entry.num + * ) + * ``` + */ +function keyValMap(list, keyFn, valFn) { + const result = Object.create(null); + for (const item of list) { + result[keyFn(item)] = valFn(item); + } + return result; +} +//# sourceMappingURL=keyValMap.js.map \ No newline at end of file diff --git a/jsutils/keyValMap.js.map b/jsutils/keyValMap.js.map new file mode 100644 index 0000000000..a5614ecfee --- /dev/null +++ b/jsutils/keyValMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"keyValMap.js","sourceRoot":"","sources":["../../src/jsutils/keyValMap.ts"],"names":[],"mappings":";;AAmBA,8BAUC;AA3BD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,SAAS,CACvB,IAAsB,EACtB,KAA0B,EAC1B,KAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ObjMap } from './ObjMap.js';\n\n/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * and a function to produce the values from each item in the array.\n * ```ts\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: '555-1234', Jenny: '867-5309' }\n * const phonesByName = keyValMap(\n * phoneBook,\n * entry => entry.name,\n * entry => entry.num\n * )\n * ```\n */\nexport function keyValMap(\n list: ReadonlyArray,\n keyFn: (item: T) => string,\n valFn: (item: T) => V,\n): ObjMap {\n const result = Object.create(null);\n for (const item of list) {\n result[keyFn(item)] = valFn(item);\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/keyValMap.mjs b/jsutils/keyValMap.mjs new file mode 100644 index 0000000000..f58c70ba9c --- /dev/null +++ b/jsutils/keyValMap.mjs @@ -0,0 +1,25 @@ +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * and a function to produce the values from each item in the array. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * // { Jon: '555-1234', Jenny: '867-5309' } + * const phonesByName = keyValMap( + * phoneBook, + * entry => entry.name, + * entry => entry.num + * ) + * ``` + */ +export function keyValMap(list, keyFn, valFn) { + const result = Object.create(null); + for (const item of list) { + result[keyFn(item)] = valFn(item); + } + return result; +} +//# sourceMappingURL=keyValMap.js.map \ No newline at end of file diff --git a/jsutils/keyValMap.mjs.map b/jsutils/keyValMap.mjs.map new file mode 100644 index 0000000000..9947d35c3d --- /dev/null +++ b/jsutils/keyValMap.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"keyValMap.js","sourceRoot":"","sources":["../../src/jsutils/keyValMap.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS,CACvB,IAAsB,EACtB,KAA0B,EAC1B,KAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ObjMap } from './ObjMap.js';\n\n/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * and a function to produce the values from each item in the array.\n * ```ts\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: '555-1234', Jenny: '867-5309' }\n * const phonesByName = keyValMap(\n * phoneBook,\n * entry => entry.name,\n * entry => entry.num\n * )\n * ```\n */\nexport function keyValMap(\n list: ReadonlyArray,\n keyFn: (item: T) => string,\n valFn: (item: T) => V,\n): ObjMap {\n const result = Object.create(null);\n for (const item of list) {\n result[keyFn(item)] = valFn(item);\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/mapValue.d.ts b/jsutils/mapValue.d.ts new file mode 100644 index 0000000000..45dcba49f9 --- /dev/null +++ b/jsutils/mapValue.d.ts @@ -0,0 +1,6 @@ +import type { ObjMap, ReadOnlyObjMap } from './ObjMap.js'; +/** + * Creates an object map with the same keys as `map` and values generated by + * running each value of `map` thru `fn`. + */ +export declare function mapValue(map: ReadOnlyObjMap, fn: (value: T, key: string) => V): ObjMap; diff --git a/jsutils/mapValue.js b/jsutils/mapValue.js new file mode 100644 index 0000000000..17aedd52e3 --- /dev/null +++ b/jsutils/mapValue.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapValue = mapValue; +/** + * Creates an object map with the same keys as `map` and values generated by + * running each value of `map` thru `fn`. + */ +function mapValue(map, fn) { + const result = Object.create(null); + for (const key of Object.keys(map)) { + result[key] = fn(map[key], key); + } + return result; +} +//# sourceMappingURL=mapValue.js.map \ No newline at end of file diff --git a/jsutils/mapValue.js.map b/jsutils/mapValue.js.map new file mode 100644 index 0000000000..d300b4f0b6 --- /dev/null +++ b/jsutils/mapValue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mapValue.js","sourceRoot":"","sources":["../../src/jsutils/mapValue.ts"],"names":[],"mappings":";;AAMA,4BAUC;AAdD;;;GAGG;AACH,SAAgB,QAAQ,CACtB,GAAsB,EACtB,EAAgC;IAEhC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ObjMap, ReadOnlyObjMap } from './ObjMap.js';\n\n/**\n * Creates an object map with the same keys as `map` and values generated by\n * running each value of `map` thru `fn`.\n */\nexport function mapValue(\n map: ReadOnlyObjMap,\n fn: (value: T, key: string) => V,\n): ObjMap {\n const result = Object.create(null);\n\n for (const key of Object.keys(map)) {\n result[key] = fn(map[key], key);\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/mapValue.mjs b/jsutils/mapValue.mjs new file mode 100644 index 0000000000..fa7e6ac223 --- /dev/null +++ b/jsutils/mapValue.mjs @@ -0,0 +1,12 @@ +/** + * Creates an object map with the same keys as `map` and values generated by + * running each value of `map` thru `fn`. + */ +export function mapValue(map, fn) { + const result = Object.create(null); + for (const key of Object.keys(map)) { + result[key] = fn(map[key], key); + } + return result; +} +//# sourceMappingURL=mapValue.js.map \ No newline at end of file diff --git a/jsutils/mapValue.mjs.map b/jsutils/mapValue.mjs.map new file mode 100644 index 0000000000..6981c3bbc3 --- /dev/null +++ b/jsutils/mapValue.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"mapValue.js","sourceRoot":"","sources":["../../src/jsutils/mapValue.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,GAAsB,EACtB,EAAgC;IAEhC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ObjMap, ReadOnlyObjMap } from './ObjMap.js';\n\n/**\n * Creates an object map with the same keys as `map` and values generated by\n * running each value of `map` thru `fn`.\n */\nexport function mapValue(\n map: ReadOnlyObjMap,\n fn: (value: T, key: string) => V,\n): ObjMap {\n const result = Object.create(null);\n\n for (const key of Object.keys(map)) {\n result[key] = fn(map[key], key);\n }\n return result;\n}\n"]} \ No newline at end of file diff --git a/jsutils/memoize3.d.ts b/jsutils/memoize3.d.ts new file mode 100644 index 0000000000..b0f099651f --- /dev/null +++ b/jsutils/memoize3.d.ts @@ -0,0 +1,4 @@ +/** + * Memoizes the provided three-argument function. + */ +export declare function memoize3(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R; diff --git a/jsutils/memoize3.js b/jsutils/memoize3.js new file mode 100644 index 0000000000..1520f94694 --- /dev/null +++ b/jsutils/memoize3.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.memoize3 = memoize3; +/** + * Memoizes the provided three-argument function. + */ +function memoize3(fn) { + let cache0; + return function memoized(a1, a2, a3) { + if (cache0 === undefined) { + cache0 = new WeakMap(); + } + let cache1 = cache0.get(a1); + if (cache1 === undefined) { + cache1 = new WeakMap(); + cache0.set(a1, cache1); + } + let cache2 = cache1.get(a2); + if (cache2 === undefined) { + cache2 = new WeakMap(); + cache1.set(a2, cache2); + } + let fnResult = cache2.get(a3); + if (fnResult === undefined) { + fnResult = fn(a1, a2, a3); + cache2.set(a3, fnResult); + } + return fnResult; + }; +} +//# sourceMappingURL=memoize3.js.map \ No newline at end of file diff --git a/jsutils/memoize3.js.map b/jsutils/memoize3.js.map new file mode 100644 index 0000000000..d334a48977 --- /dev/null +++ b/jsutils/memoize3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"memoize3.js","sourceRoot":"","sources":["../../src/jsutils/memoize3.ts"],"names":[],"mappings":";;AAGA,4BAiCC;AApCD;;GAEG;AACH,SAAgB,QAAQ,CAKtB,EAAiC;IACjC,IAAI,MAAgD,CAAC;IAErD,OAAO,SAAS,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACjC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,CAAC;QAED,IAAI,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC3B,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Memoizes the provided three-argument function.\n */\nexport function memoize3<\n A1 extends object,\n A2 extends object,\n A3 extends object,\n R,\n>(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R {\n let cache0: WeakMap>>;\n\n return function memoized(a1, a2, a3) {\n if (cache0 === undefined) {\n cache0 = new WeakMap();\n }\n\n let cache1 = cache0.get(a1);\n if (cache1 === undefined) {\n cache1 = new WeakMap();\n cache0.set(a1, cache1);\n }\n\n let cache2 = cache1.get(a2);\n if (cache2 === undefined) {\n cache2 = new WeakMap();\n cache1.set(a2, cache2);\n }\n\n let fnResult = cache2.get(a3);\n if (fnResult === undefined) {\n fnResult = fn(a1, a2, a3);\n cache2.set(a3, fnResult);\n }\n\n return fnResult;\n };\n}\n"]} \ No newline at end of file diff --git a/jsutils/memoize3.mjs b/jsutils/memoize3.mjs new file mode 100644 index 0000000000..648ad9ab25 --- /dev/null +++ b/jsutils/memoize3.mjs @@ -0,0 +1,28 @@ +/** + * Memoizes the provided three-argument function. + */ +export function memoize3(fn) { + let cache0; + return function memoized(a1, a2, a3) { + if (cache0 === undefined) { + cache0 = new WeakMap(); + } + let cache1 = cache0.get(a1); + if (cache1 === undefined) { + cache1 = new WeakMap(); + cache0.set(a1, cache1); + } + let cache2 = cache1.get(a2); + if (cache2 === undefined) { + cache2 = new WeakMap(); + cache1.set(a2, cache2); + } + let fnResult = cache2.get(a3); + if (fnResult === undefined) { + fnResult = fn(a1, a2, a3); + cache2.set(a3, fnResult); + } + return fnResult; + }; +} +//# sourceMappingURL=memoize3.js.map \ No newline at end of file diff --git a/jsutils/memoize3.mjs.map b/jsutils/memoize3.mjs.map new file mode 100644 index 0000000000..ca1bc64abe --- /dev/null +++ b/jsutils/memoize3.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"memoize3.js","sourceRoot":"","sources":["../../src/jsutils/memoize3.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,QAAQ,CAKtB,EAAiC;IACjC,IAAI,MAAgD,CAAC;IAErD,OAAO,SAAS,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACjC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,CAAC;QAED,IAAI,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC3B,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Memoizes the provided three-argument function.\n */\nexport function memoize3<\n A1 extends object,\n A2 extends object,\n A3 extends object,\n R,\n>(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R {\n let cache0: WeakMap>>;\n\n return function memoized(a1, a2, a3) {\n if (cache0 === undefined) {\n cache0 = new WeakMap();\n }\n\n let cache1 = cache0.get(a1);\n if (cache1 === undefined) {\n cache1 = new WeakMap();\n cache0.set(a1, cache1);\n }\n\n let cache2 = cache1.get(a2);\n if (cache2 === undefined) {\n cache2 = new WeakMap();\n cache1.set(a2, cache2);\n }\n\n let fnResult = cache2.get(a3);\n if (fnResult === undefined) {\n fnResult = fn(a1, a2, a3);\n cache2.set(a3, fnResult);\n }\n\n return fnResult;\n };\n}\n"]} \ No newline at end of file diff --git a/jsutils/naturalCompare.d.ts b/jsutils/naturalCompare.d.ts new file mode 100644 index 0000000000..94077795d6 --- /dev/null +++ b/jsutils/naturalCompare.d.ts @@ -0,0 +1,8 @@ +/** + * Returns a number indicating whether a reference string comes before, or after, + * or is the same as the given string in natural sort order. + * + * See: https://en.wikipedia.org/wiki/Natural_sort_order + * + */ +export declare function naturalCompare(aStr: string, bStr: string): number; diff --git a/jsutils/naturalCompare.js b/jsutils/naturalCompare.js new file mode 100644 index 0000000000..efabc91a5e --- /dev/null +++ b/jsutils/naturalCompare.js @@ -0,0 +1,55 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.naturalCompare = naturalCompare; +/** + * Returns a number indicating whether a reference string comes before, or after, + * or is the same as the given string in natural sort order. + * + * See: https://en.wikipedia.org/wiki/Natural_sort_order + * + */ +function naturalCompare(aStr, bStr) { + let aIndex = 0; + let bIndex = 0; + while (aIndex < aStr.length && bIndex < bStr.length) { + let aChar = aStr.charCodeAt(aIndex); + let bChar = bStr.charCodeAt(bIndex); + if (isDigit(aChar) && isDigit(bChar)) { + let aNum = 0; + do { + ++aIndex; + aNum = aNum * 10 + aChar - DIGIT_0; + aChar = aStr.charCodeAt(aIndex); + } while (isDigit(aChar) && aNum > 0); + let bNum = 0; + do { + ++bIndex; + bNum = bNum * 10 + bChar - DIGIT_0; + bChar = bStr.charCodeAt(bIndex); + } while (isDigit(bChar) && bNum > 0); + if (aNum < bNum) { + return -1; + } + if (aNum > bNum) { + return 1; + } + } + else { + if (aChar < bChar) { + return -1; + } + if (aChar > bChar) { + return 1; + } + ++aIndex; + ++bIndex; + } + } + return aStr.length - bStr.length; +} +const DIGIT_0 = 48; +const DIGIT_9 = 57; +function isDigit(code) { + return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9; +} +//# sourceMappingURL=naturalCompare.js.map \ No newline at end of file diff --git a/jsutils/naturalCompare.js.map b/jsutils/naturalCompare.js.map new file mode 100644 index 0000000000..2453048027 --- /dev/null +++ b/jsutils/naturalCompare.js.map @@ -0,0 +1 @@ +{"version":3,"file":"naturalCompare.js","sourceRoot":"","sources":["../../src/jsutils/naturalCompare.ts"],"names":[],"mappings":";;AAOA,wCA2CC;AAlDD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACpD,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,GAAG,CAAC;gBACF,EAAE,MAAM,CAAC;gBACT,IAAI,GAAG,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,CAAC;gBACnC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC,QAAQ,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE;YAErC,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,GAAG,CAAC;gBACF,EAAE,MAAM,CAAC;gBACT,IAAI,GAAG,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,CAAC;gBACnC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC,QAAQ,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE;YAErC,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;gBAChB,OAAO,CAAC,CAAC,CAAC;YACZ,CAAC;YAED,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;gBAChB,OAAO,CAAC,CAAC;YACX,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,CAAC,CAAC;YACZ,CAAC;YACD,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,CAAC;YACX,CAAC;YACD,EAAE,MAAM,CAAC;YACT,EAAE,MAAM,CAAC;QACX,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * Returns a number indicating whether a reference string comes before, or after,\n * or is the same as the given string in natural sort order.\n *\n * See: https://en.wikipedia.org/wiki/Natural_sort_order\n *\n */\nexport function naturalCompare(aStr: string, bStr: string): number {\n let aIndex = 0;\n let bIndex = 0;\n\n while (aIndex < aStr.length && bIndex < bStr.length) {\n let aChar = aStr.charCodeAt(aIndex);\n let bChar = bStr.charCodeAt(bIndex);\n\n if (isDigit(aChar) && isDigit(bChar)) {\n let aNum = 0;\n do {\n ++aIndex;\n aNum = aNum * 10 + aChar - DIGIT_0;\n aChar = aStr.charCodeAt(aIndex);\n } while (isDigit(aChar) && aNum > 0);\n\n let bNum = 0;\n do {\n ++bIndex;\n bNum = bNum * 10 + bChar - DIGIT_0;\n bChar = bStr.charCodeAt(bIndex);\n } while (isDigit(bChar) && bNum > 0);\n\n if (aNum < bNum) {\n return -1;\n }\n\n if (aNum > bNum) {\n return 1;\n }\n } else {\n if (aChar < bChar) {\n return -1;\n }\n if (aChar > bChar) {\n return 1;\n }\n ++aIndex;\n ++bIndex;\n }\n }\n\n return aStr.length - bStr.length;\n}\n\nconst DIGIT_0 = 48;\nconst DIGIT_9 = 57;\n\nfunction isDigit(code: number): boolean {\n return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;\n}\n"]} \ No newline at end of file diff --git a/jsutils/naturalCompare.mjs b/jsutils/naturalCompare.mjs new file mode 100644 index 0000000000..27b85cefee --- /dev/null +++ b/jsutils/naturalCompare.mjs @@ -0,0 +1,52 @@ +/** + * Returns a number indicating whether a reference string comes before, or after, + * or is the same as the given string in natural sort order. + * + * See: https://en.wikipedia.org/wiki/Natural_sort_order + * + */ +export function naturalCompare(aStr, bStr) { + let aIndex = 0; + let bIndex = 0; + while (aIndex < aStr.length && bIndex < bStr.length) { + let aChar = aStr.charCodeAt(aIndex); + let bChar = bStr.charCodeAt(bIndex); + if (isDigit(aChar) && isDigit(bChar)) { + let aNum = 0; + do { + ++aIndex; + aNum = aNum * 10 + aChar - DIGIT_0; + aChar = aStr.charCodeAt(aIndex); + } while (isDigit(aChar) && aNum > 0); + let bNum = 0; + do { + ++bIndex; + bNum = bNum * 10 + bChar - DIGIT_0; + bChar = bStr.charCodeAt(bIndex); + } while (isDigit(bChar) && bNum > 0); + if (aNum < bNum) { + return -1; + } + if (aNum > bNum) { + return 1; + } + } + else { + if (aChar < bChar) { + return -1; + } + if (aChar > bChar) { + return 1; + } + ++aIndex; + ++bIndex; + } + } + return aStr.length - bStr.length; +} +const DIGIT_0 = 48; +const DIGIT_9 = 57; +function isDigit(code) { + return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9; +} +//# sourceMappingURL=naturalCompare.js.map \ No newline at end of file diff --git a/jsutils/naturalCompare.mjs.map b/jsutils/naturalCompare.mjs.map new file mode 100644 index 0000000000..136dfc6e1c --- /dev/null +++ b/jsutils/naturalCompare.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"naturalCompare.js","sourceRoot":"","sources":["../../src/jsutils/naturalCompare.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACpD,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,GAAG,CAAC;gBACF,EAAE,MAAM,CAAC;gBACT,IAAI,GAAG,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,CAAC;gBACnC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC,QAAQ,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE;YAErC,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,GAAG,CAAC;gBACF,EAAE,MAAM,CAAC;gBACT,IAAI,GAAG,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,CAAC;gBACnC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC,QAAQ,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE;YAErC,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;gBAChB,OAAO,CAAC,CAAC,CAAC;YACZ,CAAC;YAED,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;gBAChB,OAAO,CAAC,CAAC;YACX,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,CAAC,CAAC;YACZ,CAAC;YACD,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,CAAC;YACX,CAAC;YACD,EAAE,MAAM,CAAC;YACT,EAAE,MAAM,CAAC;QACX,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * Returns a number indicating whether a reference string comes before, or after,\n * or is the same as the given string in natural sort order.\n *\n * See: https://en.wikipedia.org/wiki/Natural_sort_order\n *\n */\nexport function naturalCompare(aStr: string, bStr: string): number {\n let aIndex = 0;\n let bIndex = 0;\n\n while (aIndex < aStr.length && bIndex < bStr.length) {\n let aChar = aStr.charCodeAt(aIndex);\n let bChar = bStr.charCodeAt(bIndex);\n\n if (isDigit(aChar) && isDigit(bChar)) {\n let aNum = 0;\n do {\n ++aIndex;\n aNum = aNum * 10 + aChar - DIGIT_0;\n aChar = aStr.charCodeAt(aIndex);\n } while (isDigit(aChar) && aNum > 0);\n\n let bNum = 0;\n do {\n ++bIndex;\n bNum = bNum * 10 + bChar - DIGIT_0;\n bChar = bStr.charCodeAt(bIndex);\n } while (isDigit(bChar) && bNum > 0);\n\n if (aNum < bNum) {\n return -1;\n }\n\n if (aNum > bNum) {\n return 1;\n }\n } else {\n if (aChar < bChar) {\n return -1;\n }\n if (aChar > bChar) {\n return 1;\n }\n ++aIndex;\n ++bIndex;\n }\n }\n\n return aStr.length - bStr.length;\n}\n\nconst DIGIT_0 = 48;\nconst DIGIT_9 = 57;\n\nfunction isDigit(code: number): boolean {\n return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;\n}\n"]} \ No newline at end of file diff --git a/jsutils/printPathArray.d.ts b/jsutils/printPathArray.d.ts new file mode 100644 index 0000000000..43bf86119e --- /dev/null +++ b/jsutils/printPathArray.d.ts @@ -0,0 +1,4 @@ +/** + * Build a string describing the path. + */ +export declare function printPathArray(path: ReadonlyArray): string; diff --git a/jsutils/printPathArray.js b/jsutils/printPathArray.js new file mode 100644 index 0000000000..7249d05d98 --- /dev/null +++ b/jsutils/printPathArray.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.printPathArray = printPathArray; +/** + * Build a string describing the path. + */ +function printPathArray(path) { + if (path.length === 0) { + return ''; + } + return ` at ${path + .map((key) => (typeof key === 'number' ? `[${key}]` : `.${key}`)) + .join('')}`; +} +//# sourceMappingURL=printPathArray.js.map \ No newline at end of file diff --git a/jsutils/printPathArray.js.map b/jsutils/printPathArray.js.map new file mode 100644 index 0000000000..5d21d83730 --- /dev/null +++ b/jsutils/printPathArray.js.map @@ -0,0 +1 @@ +{"version":3,"file":"printPathArray.js","sourceRoot":"","sources":["../../src/jsutils/printPathArray.ts"],"names":[],"mappings":";;AAGA,wCAOC;AAVD;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAoC;IACjE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO,IAAI;SACf,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;SAChE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Build a string describing the path.\n */\nexport function printPathArray(path: ReadonlyArray): string {\n if (path.length === 0) {\n return '';\n }\n return ` at ${path\n .map((key) => (typeof key === 'number' ? `[${key}]` : `.${key}`))\n .join('')}`;\n}\n"]} \ No newline at end of file diff --git a/jsutils/printPathArray.mjs b/jsutils/printPathArray.mjs new file mode 100644 index 0000000000..3d7fbfb019 --- /dev/null +++ b/jsutils/printPathArray.mjs @@ -0,0 +1,12 @@ +/** + * Build a string describing the path. + */ +export function printPathArray(path) { + if (path.length === 0) { + return ''; + } + return ` at ${path + .map((key) => (typeof key === 'number' ? `[${key}]` : `.${key}`)) + .join('')}`; +} +//# sourceMappingURL=printPathArray.js.map \ No newline at end of file diff --git a/jsutils/printPathArray.mjs.map b/jsutils/printPathArray.mjs.map new file mode 100644 index 0000000000..50f660f4bb --- /dev/null +++ b/jsutils/printPathArray.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"printPathArray.js","sourceRoot":"","sources":["../../src/jsutils/printPathArray.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAoC;IACjE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO,IAAI;SACf,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;SAChE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Build a string describing the path.\n */\nexport function printPathArray(path: ReadonlyArray): string {\n if (path.length === 0) {\n return '';\n }\n return ` at ${path\n .map((key) => (typeof key === 'number' ? `[${key}]` : `.${key}`))\n .join('')}`;\n}\n"]} \ No newline at end of file diff --git a/jsutils/promiseForObject.d.ts b/jsutils/promiseForObject.d.ts new file mode 100644 index 0000000000..7481892160 --- /dev/null +++ b/jsutils/promiseForObject.d.ts @@ -0,0 +1,9 @@ +import type { ObjMap } from './ObjMap.js'; +/** + * This function transforms a JS object `ObjMap>` into + * a `Promise>` + * + * This is akin to bluebird's `Promise.props`, but implemented only using + * `Promise.all` so it will work with any implementation of ES6 promises. + */ +export declare function promiseForObject(object: ObjMap>, callback: (object: ObjMap) => U): Promise; diff --git a/jsutils/promiseForObject.js b/jsutils/promiseForObject.js new file mode 100644 index 0000000000..740adc57c6 --- /dev/null +++ b/jsutils/promiseForObject.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.promiseForObject = promiseForObject; +/** + * This function transforms a JS object `ObjMap>` into + * a `Promise>` + * + * This is akin to bluebird's `Promise.props`, but implemented only using + * `Promise.all` so it will work with any implementation of ES6 promises. + */ +async function promiseForObject(object, callback) { + const keys = Object.keys(object); + const values = Object.values(object); + const resolvedValues = await Promise.all(values); + const resolvedObject = Object.create(null); + for (let i = 0; i < keys.length; ++i) { + resolvedObject[keys[i]] = resolvedValues[i]; + } + return callback(resolvedObject); +} +//# sourceMappingURL=promiseForObject.js.map \ No newline at end of file diff --git a/jsutils/promiseForObject.js.map b/jsutils/promiseForObject.js.map new file mode 100644 index 0000000000..3d51af0ccc --- /dev/null +++ b/jsutils/promiseForObject.js.map @@ -0,0 +1 @@ +{"version":3,"file":"promiseForObject.js","sourceRoot":"","sources":["../../src/jsutils/promiseForObject.ts"],"names":[],"mappings":";;AASA,4CAaC;AApBD;;;;;;GAMG;AACI,KAAK,UAAU,gBAAgB,CACpC,MAA0B,EAC1B,QAAkC;IAElC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAErC,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import type { ObjMap } from './ObjMap.js';\n\n/**\n * This function transforms a JS object `ObjMap>` into\n * a `Promise>`\n *\n * This is akin to bluebird's `Promise.props`, but implemented only using\n * `Promise.all` so it will work with any implementation of ES6 promises.\n */\nexport async function promiseForObject(\n object: ObjMap>,\n callback: (object: ObjMap) => U,\n): Promise {\n const keys = Object.keys(object);\n const values = Object.values(object);\n\n const resolvedValues = await Promise.all(values);\n const resolvedObject = Object.create(null);\n for (let i = 0; i < keys.length; ++i) {\n resolvedObject[keys[i]] = resolvedValues[i];\n }\n return callback(resolvedObject);\n}\n"]} \ No newline at end of file diff --git a/jsutils/promiseForObject.mjs b/jsutils/promiseForObject.mjs new file mode 100644 index 0000000000..81173a0680 --- /dev/null +++ b/jsutils/promiseForObject.mjs @@ -0,0 +1,18 @@ +/** + * This function transforms a JS object `ObjMap>` into + * a `Promise>` + * + * This is akin to bluebird's `Promise.props`, but implemented only using + * `Promise.all` so it will work with any implementation of ES6 promises. + */ +export async function promiseForObject(object, callback) { + const keys = Object.keys(object); + const values = Object.values(object); + const resolvedValues = await Promise.all(values); + const resolvedObject = Object.create(null); + for (let i = 0; i < keys.length; ++i) { + resolvedObject[keys[i]] = resolvedValues[i]; + } + return callback(resolvedObject); +} +//# sourceMappingURL=promiseForObject.js.map \ No newline at end of file diff --git a/jsutils/promiseForObject.mjs.map b/jsutils/promiseForObject.mjs.map new file mode 100644 index 0000000000..bf1f5f1e3d --- /dev/null +++ b/jsutils/promiseForObject.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"promiseForObject.js","sourceRoot":"","sources":["../../src/jsutils/promiseForObject.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA0B,EAC1B,QAAkC;IAElC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAErC,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import type { ObjMap } from './ObjMap.js';\n\n/**\n * This function transforms a JS object `ObjMap>` into\n * a `Promise>`\n *\n * This is akin to bluebird's `Promise.props`, but implemented only using\n * `Promise.all` so it will work with any implementation of ES6 promises.\n */\nexport async function promiseForObject(\n object: ObjMap>,\n callback: (object: ObjMap) => U,\n): Promise {\n const keys = Object.keys(object);\n const values = Object.values(object);\n\n const resolvedValues = await Promise.all(values);\n const resolvedObject = Object.create(null);\n for (let i = 0; i < keys.length; ++i) {\n resolvedObject[keys[i]] = resolvedValues[i];\n }\n return callback(resolvedObject);\n}\n"]} \ No newline at end of file diff --git a/jsutils/promiseReduce.d.ts b/jsutils/promiseReduce.d.ts new file mode 100644 index 0000000000..022da23dad --- /dev/null +++ b/jsutils/promiseReduce.d.ts @@ -0,0 +1,9 @@ +import type { PromiseOrValue } from './PromiseOrValue.js'; +/** + * Similar to Array.prototype.reduce(), however the reducing callback may return + * a Promise, in which case reduction will continue after each promise resolves. + * + * If the callback does not return a Promise, then this function will also not + * return a Promise. + */ +export declare function promiseReduce(values: Iterable, callbackFn: (accumulator: U, currentValue: T) => PromiseOrValue, initialValue: PromiseOrValue): PromiseOrValue; diff --git a/jsutils/promiseReduce.js b/jsutils/promiseReduce.js new file mode 100644 index 0000000000..48af5f5d68 --- /dev/null +++ b/jsutils/promiseReduce.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.promiseReduce = promiseReduce; +const isPromise_js_1 = require("./isPromise.js"); +/** + * Similar to Array.prototype.reduce(), however the reducing callback may return + * a Promise, in which case reduction will continue after each promise resolves. + * + * If the callback does not return a Promise, then this function will also not + * return a Promise. + */ +function promiseReduce(values, callbackFn, initialValue) { + let accumulator = initialValue; + for (const value of values) { + accumulator = (0, isPromise_js_1.isPromise)(accumulator) + ? accumulator.then((resolved) => callbackFn(resolved, value)) + : callbackFn(accumulator, value); + } + return accumulator; +} +//# sourceMappingURL=promiseReduce.js.map \ No newline at end of file diff --git a/jsutils/promiseReduce.js.map b/jsutils/promiseReduce.js.map new file mode 100644 index 0000000000..d63848d454 --- /dev/null +++ b/jsutils/promiseReduce.js.map @@ -0,0 +1 @@ +{"version":3,"file":"promiseReduce.js","sourceRoot":"","sources":["../../src/jsutils/promiseReduce.ts"],"names":[],"mappings":";;AAUA,sCAYC;AAtBD,iDAA2C;AAG3C;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,MAAmB,EACnB,UAAkE,EAClE,YAA+B;IAE/B,IAAI,WAAW,GAAG,YAAY,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,WAAW,GAAG,IAAA,wBAAS,EAAC,WAAW,CAAC;YAClC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { isPromise } from './isPromise.js';\nimport type { PromiseOrValue } from './PromiseOrValue.js';\n\n/**\n * Similar to Array.prototype.reduce(), however the reducing callback may return\n * a Promise, in which case reduction will continue after each promise resolves.\n *\n * If the callback does not return a Promise, then this function will also not\n * return a Promise.\n */\nexport function promiseReduce(\n values: Iterable,\n callbackFn: (accumulator: U, currentValue: T) => PromiseOrValue,\n initialValue: PromiseOrValue,\n): PromiseOrValue {\n let accumulator = initialValue;\n for (const value of values) {\n accumulator = isPromise(accumulator)\n ? accumulator.then((resolved) => callbackFn(resolved, value))\n : callbackFn(accumulator, value);\n }\n return accumulator;\n}\n"]} \ No newline at end of file diff --git a/jsutils/promiseReduce.mjs b/jsutils/promiseReduce.mjs new file mode 100644 index 0000000000..8e331f9756 --- /dev/null +++ b/jsutils/promiseReduce.mjs @@ -0,0 +1,18 @@ +import { isPromise } from "./isPromise.mjs"; +/** + * Similar to Array.prototype.reduce(), however the reducing callback may return + * a Promise, in which case reduction will continue after each promise resolves. + * + * If the callback does not return a Promise, then this function will also not + * return a Promise. + */ +export function promiseReduce(values, callbackFn, initialValue) { + let accumulator = initialValue; + for (const value of values) { + accumulator = isPromise(accumulator) + ? accumulator.then((resolved) => callbackFn(resolved, value)) + : callbackFn(accumulator, value); + } + return accumulator; +} +//# sourceMappingURL=promiseReduce.js.map \ No newline at end of file diff --git a/jsutils/promiseReduce.mjs.map b/jsutils/promiseReduce.mjs.map new file mode 100644 index 0000000000..9dfe3b60ea --- /dev/null +++ b/jsutils/promiseReduce.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"promiseReduce.js","sourceRoot":"","sources":["../../src/jsutils/promiseReduce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAG3C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAmB,EACnB,UAAkE,EAClE,YAA+B;IAE/B,IAAI,WAAW,GAAG,YAAY,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;YAClC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { isPromise } from './isPromise.js';\nimport type { PromiseOrValue } from './PromiseOrValue.js';\n\n/**\n * Similar to Array.prototype.reduce(), however the reducing callback may return\n * a Promise, in which case reduction will continue after each promise resolves.\n *\n * If the callback does not return a Promise, then this function will also not\n * return a Promise.\n */\nexport function promiseReduce(\n values: Iterable,\n callbackFn: (accumulator: U, currentValue: T) => PromiseOrValue,\n initialValue: PromiseOrValue,\n): PromiseOrValue {\n let accumulator = initialValue;\n for (const value of values) {\n accumulator = isPromise(accumulator)\n ? accumulator.then((resolved) => callbackFn(resolved, value))\n : callbackFn(accumulator, value);\n }\n return accumulator;\n}\n"]} \ No newline at end of file diff --git a/jsutils/promiseWithResolvers.d.ts b/jsutils/promiseWithResolvers.d.ts new file mode 100644 index 0000000000..b761f222dd --- /dev/null +++ b/jsutils/promiseWithResolvers.d.ts @@ -0,0 +1,10 @@ +import type { PromiseOrValue } from './PromiseOrValue.js'; +/** + * Based on Promise.withResolvers proposal + * https://github.com/tc39/proposal-promise-with-resolvers + */ +export declare function promiseWithResolvers(): { + promise: Promise; + resolve: (value: T | PromiseOrValue) => void; + reject: (reason?: any) => void; +}; diff --git a/jsutils/promiseWithResolvers.js b/jsutils/promiseWithResolvers.js new file mode 100644 index 0000000000..e514f62016 --- /dev/null +++ b/jsutils/promiseWithResolvers.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.promiseWithResolvers = promiseWithResolvers; +/** + * Based on Promise.withResolvers proposal + * https://github.com/tc39/proposal-promise-with-resolvers + */ +function promiseWithResolvers() { + // these are assigned synchronously within the Promise constructor + let resolve; + let reject; + const promise = new Promise((res, rej) => { + resolve = res; + reject = rej; + }); + return { promise, resolve, reject }; +} +//# sourceMappingURL=promiseWithResolvers.js.map \ No newline at end of file diff --git a/jsutils/promiseWithResolvers.js.map b/jsutils/promiseWithResolvers.js.map new file mode 100644 index 0000000000..81900599b6 --- /dev/null +++ b/jsutils/promiseWithResolvers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"promiseWithResolvers.js","sourceRoot":"","sources":["../../src/jsutils/promiseWithResolvers.ts"],"names":[],"mappings":";;AAMA,oDAaC;AAjBD;;;GAGG;AACH,SAAgB,oBAAoB;IAKlC,kEAAkE;IAClE,IAAI,OAAgD,CAAC;IACrD,IAAI,MAA+B,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import type { PromiseOrValue } from './PromiseOrValue.js';\n\n/**\n * Based on Promise.withResolvers proposal\n * https://github.com/tc39/proposal-promise-with-resolvers\n */\nexport function promiseWithResolvers(): {\n promise: Promise;\n resolve: (value: T | PromiseOrValue) => void;\n reject: (reason?: any) => void;\n} {\n // these are assigned synchronously within the Promise constructor\n let resolve!: (value: T | PromiseOrValue) => void;\n let reject!: (reason?: any) => void;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n"]} \ No newline at end of file diff --git a/jsutils/promiseWithResolvers.mjs b/jsutils/promiseWithResolvers.mjs new file mode 100644 index 0000000000..0e308a23a0 --- /dev/null +++ b/jsutils/promiseWithResolvers.mjs @@ -0,0 +1,15 @@ +/** + * Based on Promise.withResolvers proposal + * https://github.com/tc39/proposal-promise-with-resolvers + */ +export function promiseWithResolvers() { + // these are assigned synchronously within the Promise constructor + let resolve; + let reject; + const promise = new Promise((res, rej) => { + resolve = res; + reject = rej; + }); + return { promise, resolve, reject }; +} +//# sourceMappingURL=promiseWithResolvers.js.map \ No newline at end of file diff --git a/jsutils/promiseWithResolvers.mjs.map b/jsutils/promiseWithResolvers.mjs.map new file mode 100644 index 0000000000..1b125f3980 --- /dev/null +++ b/jsutils/promiseWithResolvers.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"promiseWithResolvers.js","sourceRoot":"","sources":["../../src/jsutils/promiseWithResolvers.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAKlC,kEAAkE;IAClE,IAAI,OAAgD,CAAC;IACrD,IAAI,MAA+B,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import type { PromiseOrValue } from './PromiseOrValue.js';\n\n/**\n * Based on Promise.withResolvers proposal\n * https://github.com/tc39/proposal-promise-with-resolvers\n */\nexport function promiseWithResolvers(): {\n promise: Promise;\n resolve: (value: T | PromiseOrValue) => void;\n reject: (reason?: any) => void;\n} {\n // these are assigned synchronously within the Promise constructor\n let resolve!: (value: T | PromiseOrValue) => void;\n let reject!: (reason?: any) => void;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n"]} \ No newline at end of file diff --git a/jsutils/suggestionList.d.ts b/jsutils/suggestionList.d.ts new file mode 100644 index 0000000000..b1327d4294 --- /dev/null +++ b/jsutils/suggestionList.d.ts @@ -0,0 +1,5 @@ +/** + * Given an invalid input string and a list of valid options, returns a filtered + * list of valid options sorted based on their similarity with the input. + */ +export declare function suggestionList(input: string, options: ReadonlyArray): Array; diff --git a/jsutils/suggestionList.js b/jsutils/suggestionList.js new file mode 100644 index 0000000000..31f81920df --- /dev/null +++ b/jsutils/suggestionList.js @@ -0,0 +1,110 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.suggestionList = suggestionList; +const naturalCompare_js_1 = require("./naturalCompare.js"); +/** + * Given an invalid input string and a list of valid options, returns a filtered + * list of valid options sorted based on their similarity with the input. + */ +function suggestionList(input, options) { + const optionsByDistance = Object.create(null); + const lexicalDistance = new LexicalDistance(input); + const threshold = Math.floor(input.length * 0.4) + 1; + for (const option of options) { + const distance = lexicalDistance.measure(option, threshold); + if (distance !== undefined) { + optionsByDistance[option] = distance; + } + } + return Object.keys(optionsByDistance).sort((a, b) => { + const distanceDiff = optionsByDistance[a] - optionsByDistance[b]; + return distanceDiff !== 0 ? distanceDiff : (0, naturalCompare_js_1.naturalCompare)(a, b); + }); +} +/** + * Computes the lexical distance between strings A and B. + * + * The "distance" between two strings is given by counting the minimum number + * of edits needed to transform string A into string B. An edit can be an + * insertion, deletion, or substitution of a single character, or a swap of two + * adjacent characters. + * + * Includes a custom alteration from Damerau-Levenshtein to treat case changes + * as a single edit which helps identify mis-cased values with an edit distance + * of 1. + * + * This distance can be useful for detecting typos in input or sorting + */ +class LexicalDistance { + constructor(input) { + this._input = input; + this._inputLowerCase = input.toLowerCase(); + this._inputArray = stringToArray(this._inputLowerCase); + this._rows = [ + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + ]; + } + measure(option, threshold) { + if (this._input === option) { + return 0; + } + const optionLowerCase = option.toLowerCase(); + // Any case change counts as a single edit + if (this._inputLowerCase === optionLowerCase) { + return 1; + } + let a = stringToArray(optionLowerCase); + let b = this._inputArray; + if (a.length < b.length) { + const tmp = a; + a = b; + b = tmp; + } + const aLength = a.length; + const bLength = b.length; + if (aLength - bLength > threshold) { + return undefined; + } + const rows = this._rows; + for (let j = 0; j <= bLength; j++) { + rows[0][j] = j; + } + for (let i = 1; i <= aLength; i++) { + const upRow = rows[(i - 1) % 3]; + const currentRow = rows[i % 3]; + let smallestCell = (currentRow[0] = i); + for (let j = 1; j <= bLength; j++) { + const cost = a[i - 1] === b[j - 1] ? 0 : 1; + let currentCell = Math.min(upRow[j] + 1, // delete + currentRow[j - 1] + 1, // insert + upRow[j - 1] + cost); + if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { + // transposition + const doubleDiagonalCell = rows[(i - 2) % 3][j - 2]; + currentCell = Math.min(currentCell, doubleDiagonalCell + 1); + } + if (currentCell < smallestCell) { + smallestCell = currentCell; + } + currentRow[j] = currentCell; + } + // Early exit, since distance can't go smaller than smallest element of the previous row. + if (smallestCell > threshold) { + return undefined; + } + } + const distance = rows[aLength % 3][bLength]; + return distance <= threshold ? distance : undefined; + } +} +function stringToArray(str) { + const strLength = str.length; + const array = new Array(strLength); + for (let i = 0; i < strLength; ++i) { + array[i] = str.charCodeAt(i); + } + return array; +} +//# sourceMappingURL=suggestionList.js.map \ No newline at end of file diff --git a/jsutils/suggestionList.js.map b/jsutils/suggestionList.js.map new file mode 100644 index 0000000000..9945e5bb9b --- /dev/null +++ b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AC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBACpD,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,GAAG,CAAC,CAAC,CAAC;gBAC9D,CAAC;gBAED,IAAI,WAAW,GAAG,YAAY,EAAE,CAAC;oBAC/B,YAAY,GAAG,WAAW,CAAC;gBAC7B,CAAC;gBAED,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;YAC9B,CAAC;YAED,yFAAyF;YACzF,IAAI,YAAY,GAAG,SAAS,EAAE,CAAC;gBAC7B,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,QAAQ,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;CACF;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC;QACnC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { naturalCompare } from './naturalCompare.js';\n\n/**\n * Given an invalid input string and a list of valid options, returns a filtered\n * list of valid options sorted based on their similarity with the input.\n */\nexport function suggestionList(\n input: string,\n options: ReadonlyArray,\n): Array {\n const optionsByDistance = Object.create(null);\n const lexicalDistance = new LexicalDistance(input);\n\n const threshold = Math.floor(input.length * 0.4) + 1;\n for (const option of options) {\n const distance = lexicalDistance.measure(option, threshold);\n if (distance !== undefined) {\n optionsByDistance[option] = distance;\n }\n }\n\n return Object.keys(optionsByDistance).sort((a, b) => {\n const distanceDiff = optionsByDistance[a] - optionsByDistance[b];\n return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b);\n });\n}\n\n/**\n * Computes the lexical distance between strings A and B.\n *\n * The \"distance\" between two strings is given by counting the minimum number\n * of edits needed to transform string A into string B. An edit can be an\n * insertion, deletion, or substitution of a single character, or a swap of two\n * adjacent characters.\n *\n * Includes a custom alteration from Damerau-Levenshtein to treat case changes\n * as a single edit which helps identify mis-cased values with an edit distance\n * of 1.\n *\n * This distance can be useful for detecting typos in input or sorting\n */\nclass LexicalDistance {\n _input: string;\n _inputLowerCase: string;\n _inputArray: Array;\n _rows: [Array, Array, Array];\n\n constructor(input: string) {\n this._input = input;\n this._inputLowerCase = input.toLowerCase();\n this._inputArray = stringToArray(this._inputLowerCase);\n\n this._rows = [\n new Array(input.length + 1).fill(0),\n new Array(input.length + 1).fill(0),\n new Array(input.length + 1).fill(0),\n ];\n }\n\n measure(option: string, threshold: number): number | undefined {\n if (this._input === option) {\n return 0;\n }\n\n const optionLowerCase = option.toLowerCase();\n\n // Any case change counts as a single edit\n if (this._inputLowerCase === optionLowerCase) {\n return 1;\n }\n\n let a = stringToArray(optionLowerCase);\n let b = this._inputArray;\n\n if (a.length < b.length) {\n const tmp = a;\n a = b;\n b = tmp;\n }\n const aLength = a.length;\n const bLength = b.length;\n\n if (aLength - bLength > threshold) {\n return undefined;\n }\n\n const rows = this._rows;\n for (let j = 0; j <= bLength; j++) {\n rows[0][j] = j;\n }\n\n for (let i = 1; i <= aLength; i++) {\n const upRow = rows[(i - 1) % 3];\n const currentRow = rows[i % 3];\n\n let smallestCell = (currentRow[0] = i);\n for (let j = 1; j <= bLength; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n\n let currentCell = Math.min(\n upRow[j] + 1, // delete\n currentRow[j - 1] + 1, // insert\n upRow[j - 1] + cost, // substitute\n );\n\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n // transposition\n const doubleDiagonalCell = rows[(i - 2) % 3][j - 2];\n currentCell = Math.min(currentCell, doubleDiagonalCell + 1);\n }\n\n if (currentCell < smallestCell) {\n smallestCell = currentCell;\n }\n\n currentRow[j] = currentCell;\n }\n\n // Early exit, since distance can't go smaller than smallest element of the previous row.\n if (smallestCell > threshold) {\n return undefined;\n }\n }\n\n const distance = rows[aLength % 3][bLength];\n return distance <= threshold ? distance : undefined;\n }\n}\n\nfunction stringToArray(str: string): Array {\n const strLength = str.length;\n const array = new Array(strLength);\n for (let i = 0; i < strLength; ++i) {\n array[i] = str.charCodeAt(i);\n }\n return array;\n}\n"]} \ No newline at end of file diff --git a/jsutils/suggestionList.mjs b/jsutils/suggestionList.mjs new file mode 100644 index 0000000000..46ea12bb7e --- /dev/null +++ b/jsutils/suggestionList.mjs @@ -0,0 +1,107 @@ +import { naturalCompare } from "./naturalCompare.mjs"; +/** + * Given an invalid input string and a list of valid options, returns a filtered + * list of valid options sorted based on their similarity with the input. + */ +export function suggestionList(input, options) { + const optionsByDistance = Object.create(null); + const lexicalDistance = new LexicalDistance(input); + const threshold = Math.floor(input.length * 0.4) + 1; + for (const option of options) { + const distance = lexicalDistance.measure(option, threshold); + if (distance !== undefined) { + optionsByDistance[option] = distance; + } + } + return Object.keys(optionsByDistance).sort((a, b) => { + const distanceDiff = optionsByDistance[a] - optionsByDistance[b]; + return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b); + }); +} +/** + * Computes the lexical distance between strings A and B. + * + * The "distance" between two strings is given by counting the minimum number + * of edits needed to transform string A into string B. An edit can be an + * insertion, deletion, or substitution of a single character, or a swap of two + * adjacent characters. + * + * Includes a custom alteration from Damerau-Levenshtein to treat case changes + * as a single edit which helps identify mis-cased values with an edit distance + * of 1. + * + * This distance can be useful for detecting typos in input or sorting + */ +class LexicalDistance { + constructor(input) { + this._input = input; + this._inputLowerCase = input.toLowerCase(); + this._inputArray = stringToArray(this._inputLowerCase); + this._rows = [ + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + ]; + } + measure(option, threshold) { + if (this._input === option) { + return 0; + } + const optionLowerCase = option.toLowerCase(); + // Any case change counts as a single edit + if (this._inputLowerCase === optionLowerCase) { + return 1; + } + let a = stringToArray(optionLowerCase); + let b = this._inputArray; + if (a.length < b.length) { + const tmp = a; + a = b; + b = tmp; + } + const aLength = a.length; + const bLength = b.length; + if (aLength - bLength > threshold) { + return undefined; + } + const rows = this._rows; + for (let j = 0; j <= bLength; j++) { + rows[0][j] = j; + } + for (let i = 1; i <= aLength; i++) { + const upRow = rows[(i - 1) % 3]; + const currentRow = rows[i % 3]; + let smallestCell = (currentRow[0] = i); + for (let j = 1; j <= bLength; j++) { + const cost = a[i - 1] === b[j - 1] ? 0 : 1; + let currentCell = Math.min(upRow[j] + 1, // delete + currentRow[j - 1] + 1, // insert + upRow[j - 1] + cost); + if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { + // transposition + const doubleDiagonalCell = rows[(i - 2) % 3][j - 2]; + currentCell = Math.min(currentCell, doubleDiagonalCell + 1); + } + if (currentCell < smallestCell) { + smallestCell = currentCell; + } + currentRow[j] = currentCell; + } + // Early exit, since distance can't go smaller than smallest element of the previous row. + if (smallestCell > threshold) { + return undefined; + } + } + const distance = rows[aLength % 3][bLength]; + return distance <= threshold ? distance : undefined; + } +} +function stringToArray(str) { + const strLength = str.length; + const array = new Array(strLength); + for (let i = 0; i < strLength; ++i) { + array[i] = str.charCodeAt(i); + } + return array; +} +//# sourceMappingURL=suggestionList.js.map \ No newline at end of file diff --git a/jsutils/suggestionList.mjs.map b/jsutils/suggestionList.mjs.map new file mode 100644 index 0000000000..d2f5014861 --- /dev/null +++ b/jsutils/suggestionList.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"suggestionList.js","sourceRoot":"","sources":["../../src/jsutils/suggestionList.ts"],"names":[],"mappings":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GAAG,CAAC,CAAC,CAAC;gBAC9D,CAAC;gBAED,IAAI,WAAW,GAAG,YAAY,EAAE,CAAC;oBAC/B,YAAY,GAAG,WAAW,CAAC;gBAC7B,CAAC;gBAED,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;YAC9B,CAAC;YAED,yFAAyF;YACzF,IAAI,YAAY,GAAG,SAAS,EAAE,CAAC;gBAC7B,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,QAAQ,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;CACF;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC;QACnC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { naturalCompare } from './naturalCompare.js';\n\n/**\n * Given an invalid input string and a list of valid options, returns a filtered\n * list of valid options sorted based on their similarity with the input.\n */\nexport function suggestionList(\n input: string,\n options: ReadonlyArray,\n): Array {\n const optionsByDistance = Object.create(null);\n const lexicalDistance = new LexicalDistance(input);\n\n const threshold = Math.floor(input.length * 0.4) + 1;\n for (const option of options) {\n const distance = lexicalDistance.measure(option, threshold);\n if (distance !== undefined) {\n optionsByDistance[option] = distance;\n }\n }\n\n return Object.keys(optionsByDistance).sort((a, b) => {\n const distanceDiff = optionsByDistance[a] - optionsByDistance[b];\n return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b);\n });\n}\n\n/**\n * Computes the lexical distance between strings A and B.\n *\n * The \"distance\" between two strings is given by counting the minimum number\n * of edits needed to transform string A into string B. An edit can be an\n * insertion, deletion, or substitution of a single character, or a swap of two\n * adjacent characters.\n *\n * Includes a custom alteration from Damerau-Levenshtein to treat case changes\n * as a single edit which helps identify mis-cased values with an edit distance\n * of 1.\n *\n * This distance can be useful for detecting typos in input or sorting\n */\nclass LexicalDistance {\n _input: string;\n _inputLowerCase: string;\n _inputArray: Array;\n _rows: [Array, Array, Array];\n\n constructor(input: string) {\n this._input = input;\n this._inputLowerCase = input.toLowerCase();\n this._inputArray = stringToArray(this._inputLowerCase);\n\n this._rows = [\n new Array(input.length + 1).fill(0),\n new Array(input.length + 1).fill(0),\n new Array(input.length + 1).fill(0),\n ];\n }\n\n measure(option: string, threshold: number): number | undefined {\n if (this._input === option) {\n return 0;\n }\n\n const optionLowerCase = option.toLowerCase();\n\n // Any case change counts as a single edit\n if (this._inputLowerCase === optionLowerCase) {\n return 1;\n }\n\n let a = stringToArray(optionLowerCase);\n let b = this._inputArray;\n\n if (a.length < b.length) {\n const tmp = a;\n a = b;\n b = tmp;\n }\n const aLength = a.length;\n const bLength = b.length;\n\n if (aLength - bLength > threshold) {\n return undefined;\n }\n\n const rows = this._rows;\n for (let j = 0; j <= bLength; j++) {\n rows[0][j] = j;\n }\n\n for (let i = 1; i <= aLength; i++) {\n const upRow = rows[(i - 1) % 3];\n const currentRow = rows[i % 3];\n\n let smallestCell = (currentRow[0] = i);\n for (let j = 1; j <= bLength; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n\n let currentCell = Math.min(\n upRow[j] + 1, // delete\n currentRow[j - 1] + 1, // insert\n upRow[j - 1] + cost, // substitute\n );\n\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n // transposition\n const doubleDiagonalCell = rows[(i - 2) % 3][j - 2];\n currentCell = Math.min(currentCell, doubleDiagonalCell + 1);\n }\n\n if (currentCell < smallestCell) {\n smallestCell = currentCell;\n }\n\n currentRow[j] = currentCell;\n }\n\n // Early exit, since distance can't go smaller than smallest element of the previous row.\n if (smallestCell > threshold) {\n return undefined;\n }\n }\n\n const distance = rows[aLength % 3][bLength];\n return distance <= threshold ? distance : undefined;\n }\n}\n\nfunction stringToArray(str: string): Array {\n const strLength = str.length;\n const array = new Array(strLength);\n for (let i = 0; i < strLength; ++i) {\n array[i] = str.charCodeAt(i);\n }\n return array;\n}\n"]} \ No newline at end of file diff --git a/jsutils/toError.d.ts b/jsutils/toError.d.ts new file mode 100644 index 0000000000..f9c372941f --- /dev/null +++ b/jsutils/toError.d.ts @@ -0,0 +1,4 @@ +/** + * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + */ +export declare function toError(thrownValue: unknown): Error; diff --git a/jsutils/toError.js b/jsutils/toError.js new file mode 100644 index 0000000000..b8d11086f2 --- /dev/null +++ b/jsutils/toError.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toError = toError; +const inspect_js_1 = require("./inspect.js"); +/** + * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + */ +function toError(thrownValue) { + return thrownValue instanceof Error + ? thrownValue + : new NonErrorThrown(thrownValue); +} +class NonErrorThrown extends Error { + constructor(thrownValue) { + super('Unexpected error value: ' + (0, inspect_js_1.inspect)(thrownValue)); + this.name = 'NonErrorThrown'; + this.thrownValue = thrownValue; + } +} +//# sourceMappingURL=toError.js.map \ No newline at end of file diff --git a/jsutils/toError.js.map b/jsutils/toError.js.map new file mode 100644 index 0000000000..3a6d208fd8 --- /dev/null +++ b/jsutils/toError.js.map @@ -0,0 +1 @@ +{"version":3,"file":"toError.js","sourceRoot":"","sources":["../../src/jsutils/toError.ts"],"names":[],"mappings":";;AAKA,0BAIC;AATD,6CAAuC;AAEvC;;GAEG;AACH,SAAgB,OAAO,CAAC,WAAoB;IAC1C,OAAO,WAAW,YAAY,KAAK;QACjC,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,cAAe,SAAQ,KAAK;IAGhC,YAAY,WAAoB;QAC9B,KAAK,CAAC,0BAA0B,GAAG,IAAA,oBAAO,EAAC,WAAW,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { inspect } from './inspect.js';\n\n/**\n * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.\n */\nexport function toError(thrownValue: unknown): Error {\n return thrownValue instanceof Error\n ? thrownValue\n : new NonErrorThrown(thrownValue);\n}\n\nclass NonErrorThrown extends Error {\n thrownValue: unknown;\n\n constructor(thrownValue: unknown) {\n super('Unexpected error value: ' + inspect(thrownValue));\n this.name = 'NonErrorThrown';\n this.thrownValue = thrownValue;\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/toError.mjs b/jsutils/toError.mjs new file mode 100644 index 0000000000..abfbc6c3f2 --- /dev/null +++ b/jsutils/toError.mjs @@ -0,0 +1,17 @@ +import { inspect } from "./inspect.mjs"; +/** + * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + */ +export function toError(thrownValue) { + return thrownValue instanceof Error + ? thrownValue + : new NonErrorThrown(thrownValue); +} +class NonErrorThrown extends Error { + constructor(thrownValue) { + super('Unexpected error value: ' + inspect(thrownValue)); + this.name = 'NonErrorThrown'; + this.thrownValue = thrownValue; + } +} +//# sourceMappingURL=toError.js.map \ No newline at end of file diff --git a/jsutils/toError.mjs.map b/jsutils/toError.mjs.map new file mode 100644 index 0000000000..4195f8d087 --- /dev/null +++ b/jsutils/toError.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"toError.js","sourceRoot":"","sources":["../../src/jsutils/toError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,sBAAqB;AAEvC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,WAAoB;IAC1C,OAAO,WAAW,YAAY,KAAK;QACjC,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,cAAe,SAAQ,KAAK;IAGhC,YAAY,WAAoB;QAC9B,KAAK,CAAC,0BAA0B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { inspect } from './inspect.js';\n\n/**\n * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.\n */\nexport function toError(thrownValue: unknown): Error {\n return thrownValue instanceof Error\n ? thrownValue\n : new NonErrorThrown(thrownValue);\n}\n\nclass NonErrorThrown extends Error {\n thrownValue: unknown;\n\n constructor(thrownValue: unknown) {\n super('Unexpected error value: ' + inspect(thrownValue));\n this.name = 'NonErrorThrown';\n this.thrownValue = thrownValue;\n }\n}\n"]} \ No newline at end of file diff --git a/jsutils/toObjMap.d.ts b/jsutils/toObjMap.d.ts new file mode 100644 index 0000000000..1943371066 --- /dev/null +++ b/jsutils/toObjMap.d.ts @@ -0,0 +1,4 @@ +import type { Maybe } from './Maybe.js'; +import type { ReadOnlyObjMap, ReadOnlyObjMapLike, ReadOnlyObjMapSymbolLike, ReadOnlyObjMapWithSymbol } from './ObjMap.js'; +export declare function toObjMap(obj: Maybe>): ReadOnlyObjMap; +export declare function toObjMapWithSymbols(obj: Maybe>): ReadOnlyObjMapWithSymbol; diff --git a/jsutils/toObjMap.js b/jsutils/toObjMap.js new file mode 100644 index 0000000000..8dd10f6cbe --- /dev/null +++ b/jsutils/toObjMap.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toObjMap = toObjMap; +exports.toObjMapWithSymbols = toObjMapWithSymbols; +function toObjMap(obj) { + if (obj == null) { + return Object.create(null); + } + if (Object.getPrototypeOf(obj) === null) { + return obj; + } + const map = Object.create(null); + for (const [key, value] of Object.entries(obj)) { + map[key] = value; + } + return map; +} +function toObjMapWithSymbols(obj) { + if (obj == null) { + return Object.create(null); + } + if (Object.getPrototypeOf(obj) === null) { + return obj; + } + const map = Object.create(null); + for (const [key, value] of Object.entries(obj)) { + map[key] = value; + } + for (const key of Object.getOwnPropertySymbols(obj)) { + map[key] = obj[key]; + } + return map; +} +//# sourceMappingURL=toObjMap.js.map \ No newline at end of file diff --git a/jsutils/toObjMap.js.map b/jsutils/toObjMap.js.map new file mode 100644 index 0000000000..ae189137b8 --- /dev/null +++ b/jsutils/toObjMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"toObjMap.js","sourceRoot":"","sources":["../../src/jsutils/toObjMap.ts"],"names":[],"mappings":";;AAQA,4BAiBC;AAED,kDAqBC;AAxCD,SAAgB,QAAQ,CACtB,GAAiC;IAEjC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,mBAAmB,CACjC,GAAuC;IAEvC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QACpD,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { Maybe } from './Maybe.js';\nimport type {\n ReadOnlyObjMap,\n ReadOnlyObjMapLike,\n ReadOnlyObjMapSymbolLike,\n ReadOnlyObjMapWithSymbol,\n} from './ObjMap.js';\n\nexport function toObjMap(\n obj: Maybe>,\n): ReadOnlyObjMap {\n if (obj == null) {\n return Object.create(null);\n }\n\n if (Object.getPrototypeOf(obj) === null) {\n return obj;\n }\n\n const map = Object.create(null);\n for (const [key, value] of Object.entries(obj)) {\n map[key] = value;\n }\n\n return map;\n}\n\nexport function toObjMapWithSymbols(\n obj: Maybe>,\n): ReadOnlyObjMapWithSymbol {\n if (obj == null) {\n return Object.create(null);\n }\n\n if (Object.getPrototypeOf(obj) === null) {\n return obj;\n }\n\n const map = Object.create(null);\n for (const [key, value] of Object.entries(obj)) {\n map[key] = value;\n }\n\n for (const key of Object.getOwnPropertySymbols(obj)) {\n map[key] = obj[key];\n }\n\n return map;\n}\n"]} \ No newline at end of file diff --git a/jsutils/toObjMap.mjs b/jsutils/toObjMap.mjs new file mode 100644 index 0000000000..d61ddb8442 --- /dev/null +++ b/jsutils/toObjMap.mjs @@ -0,0 +1,30 @@ +export function toObjMap(obj) { + if (obj == null) { + return Object.create(null); + } + if (Object.getPrototypeOf(obj) === null) { + return obj; + } + const map = Object.create(null); + for (const [key, value] of Object.entries(obj)) { + map[key] = value; + } + return map; +} +export function toObjMapWithSymbols(obj) { + if (obj == null) { + return Object.create(null); + } + if (Object.getPrototypeOf(obj) === null) { + return obj; + } + const map = Object.create(null); + for (const [key, value] of Object.entries(obj)) { + map[key] = value; + } + for (const key of Object.getOwnPropertySymbols(obj)) { + map[key] = obj[key]; + } + return map; +} +//# sourceMappingURL=toObjMap.js.map \ No newline at end of file diff --git a/jsutils/toObjMap.mjs.map b/jsutils/toObjMap.mjs.map new file mode 100644 index 0000000000..f8222a34c9 --- /dev/null +++ b/jsutils/toObjMap.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"toObjMap.js","sourceRoot":"","sources":["../../src/jsutils/toObjMap.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,QAAQ,CACtB,GAAiC;IAEjC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,GAAuC;IAEvC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QACpD,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { Maybe } from './Maybe.js';\nimport type {\n ReadOnlyObjMap,\n ReadOnlyObjMapLike,\n ReadOnlyObjMapSymbolLike,\n ReadOnlyObjMapWithSymbol,\n} from './ObjMap.js';\n\nexport function toObjMap(\n obj: Maybe>,\n): ReadOnlyObjMap {\n if (obj == null) {\n return Object.create(null);\n }\n\n if (Object.getPrototypeOf(obj) === null) {\n return obj;\n }\n\n const map = Object.create(null);\n for (const [key, value] of Object.entries(obj)) {\n map[key] = value;\n }\n\n return map;\n}\n\nexport function toObjMapWithSymbols(\n obj: Maybe>,\n): ReadOnlyObjMapWithSymbol {\n if (obj == null) {\n return Object.create(null);\n }\n\n if (Object.getPrototypeOf(obj) === null) {\n return obj;\n }\n\n const map = Object.create(null);\n for (const [key, value] of Object.entries(obj)) {\n map[key] = value;\n }\n\n for (const key of Object.getOwnPropertySymbols(obj)) {\n map[key] = obj[key];\n }\n\n return map;\n}\n"]} \ No newline at end of file diff --git a/language/ast.d.ts b/language/ast.d.ts new file mode 100644 index 0000000000..134ddff522 --- /dev/null +++ b/language/ast.d.ts @@ -0,0 +1,452 @@ +import type { Kind } from './kinds.js'; +import type { Source } from './source.js'; +import type { TokenKind } from './tokenKind.js'; +/** + * Contains a range of UTF-8 character offsets and token references that + * identify the region of the source from which the AST derived. + */ +export declare class Location { + /** + * The character offset at which this Node begins. + */ + readonly start: number; + /** + * The character offset at which this Node ends. + */ + readonly end: number; + /** + * The Token at which this Node begins. + */ + readonly startToken: Token; + /** + * The Token at which this Node ends. + */ + readonly endToken: Token; + /** + * The Source document the AST represents. + */ + readonly source: Source; + constructor(startToken: Token, endToken: Token, source: Source); + get [Symbol.toStringTag](): string; + toJSON(): { + start: number; + end: number; + }; +} +/** + * Represents a range of characters represented by a lexical token + * within a Source. + */ +export declare class Token { + /** + * The kind of Token. + */ + readonly kind: TokenKind; + /** + * The character offset at which this Node begins. + */ + readonly start: number; + /** + * The character offset at which this Node ends. + */ + readonly end: number; + /** + * The 1-indexed line number on which this Token appears. + */ + readonly line: number; + /** + * The 1-indexed column number at which this Token begins. + */ + readonly column: number; + /** + * For non-punctuation tokens, represents the interpreted value of the token. + * + * Note: is undefined for punctuation tokens, but typed as string for + * convenience in the parser. + */ + readonly value: string; + /** + * Tokens exist as nodes in a double-linked-list amongst all tokens + * including ignored tokens. is always the first node and + * the last. + */ + readonly prev: Token | null; + readonly next: Token | null; + constructor(kind: TokenKind, start: number, end: number, line: number, column: number, value?: string); + get [Symbol.toStringTag](): string; + toJSON(): { + kind: TokenKind; + value?: string; + line: number; + column: number; + }; +} +/** + * The list of all possible AST node types. + */ +export type ASTNode = NameNode | DocumentNode | OperationDefinitionNode | VariableDefinitionNode | VariableNode | SelectionSetNode | FieldNode | ArgumentNode | FragmentArgumentNode | FragmentSpreadNode | InlineFragmentNode | FragmentDefinitionNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode | ObjectFieldNode | DirectiveNode | NamedTypeNode | ListTypeNode | NonNullTypeNode | SchemaDefinitionNode | OperationTypeDefinitionNode | ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | FieldDefinitionNode | InputValueDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | EnumValueDefinitionNode | InputObjectTypeDefinitionNode | DirectiveDefinitionNode | SchemaExtensionNode | ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode; +/** + * Utility type listing all nodes indexed by their kind. + */ +export type ASTKindToNode = { + [NodeT in ASTNode as NodeT['kind']]: NodeT; +}; +/** + * @internal + */ +export declare const QueryDocumentKeys: { + [NodeT in ASTNode as NodeT['kind']]: ReadonlyArray; +}; +/** + * @internal + */ +export declare function isNode(maybeNode: any): maybeNode is ASTNode; +/** Name */ +export interface NameNode { + readonly kind: typeof Kind.NAME; + readonly loc?: Location | undefined; + readonly value: string; +} +/** Document */ +export interface DocumentNode { + readonly kind: typeof Kind.DOCUMENT; + readonly loc?: Location | undefined; + readonly definitions: ReadonlyArray; + readonly tokenCount?: number | undefined; +} +export type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode; +export type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode; +export interface OperationDefinitionNode { + readonly kind: typeof Kind.OPERATION_DEFINITION; + readonly loc?: Location | undefined; + readonly operation: OperationTypeNode; + readonly name?: NameNode | undefined; + readonly variableDefinitions?: ReadonlyArray | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly selectionSet: SelectionSetNode; +} +export declare const OperationTypeNode: { + readonly QUERY: "query"; + readonly MUTATION: "mutation"; + readonly SUBSCRIPTION: "subscription"; +}; +export type OperationTypeNode = (typeof OperationTypeNode)[keyof typeof OperationTypeNode]; +export interface VariableDefinitionNode { + readonly kind: typeof Kind.VARIABLE_DEFINITION; + readonly loc?: Location | undefined; + readonly variable: VariableNode; + readonly type: TypeNode; + readonly defaultValue?: ConstValueNode | undefined; + readonly directives?: ReadonlyArray | undefined; +} +export interface VariableNode { + readonly kind: typeof Kind.VARIABLE; + readonly loc?: Location | undefined; + readonly name: NameNode; +} +export interface SelectionSetNode { + kind: typeof Kind.SELECTION_SET; + loc?: Location | undefined; + selections: ReadonlyArray; +} +export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode; +export interface FieldNode { + readonly kind: typeof Kind.FIELD; + readonly loc?: Location | undefined; + readonly alias?: NameNode | undefined; + readonly name: NameNode; + readonly arguments?: ReadonlyArray | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly selectionSet?: SelectionSetNode | undefined; +} +export interface ArgumentNode { + readonly kind: typeof Kind.ARGUMENT; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly value: ValueNode; +} +export interface ConstArgumentNode { + readonly kind: typeof Kind.ARGUMENT; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly value: ConstValueNode; +} +export interface FragmentArgumentNode { + readonly kind: typeof Kind.FRAGMENT_ARGUMENT; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly value: ValueNode; +} +/** Fragments */ +export interface FragmentSpreadNode { + readonly kind: typeof Kind.FRAGMENT_SPREAD; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly arguments?: ReadonlyArray | undefined; + readonly directives?: ReadonlyArray | undefined; +} +export interface InlineFragmentNode { + readonly kind: typeof Kind.INLINE_FRAGMENT; + readonly loc?: Location | undefined; + readonly typeCondition?: NamedTypeNode | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly selectionSet: SelectionSetNode; +} +export interface FragmentDefinitionNode { + readonly kind: typeof Kind.FRAGMENT_DEFINITION; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly variableDefinitions?: ReadonlyArray | undefined; + readonly typeCondition: NamedTypeNode; + readonly directives?: ReadonlyArray | undefined; + readonly selectionSet: SelectionSetNode; +} +/** Values */ +export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode; +export type ConstValueNode = IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ConstListValueNode | ConstObjectValueNode; +export interface IntValueNode { + readonly kind: typeof Kind.INT; + readonly loc?: Location | undefined; + readonly value: string; +} +export interface FloatValueNode { + readonly kind: typeof Kind.FLOAT; + readonly loc?: Location | undefined; + readonly value: string; +} +export interface StringValueNode { + readonly kind: typeof Kind.STRING; + readonly loc?: Location | undefined; + readonly value: string; + readonly block?: boolean | undefined; +} +export interface BooleanValueNode { + readonly kind: typeof Kind.BOOLEAN; + readonly loc?: Location | undefined; + readonly value: boolean; +} +export interface NullValueNode { + readonly kind: typeof Kind.NULL; + readonly loc?: Location | undefined; +} +export interface EnumValueNode { + readonly kind: typeof Kind.ENUM; + readonly loc?: Location | undefined; + readonly value: string; +} +export interface ListValueNode { + readonly kind: typeof Kind.LIST; + readonly loc?: Location | undefined; + readonly values: ReadonlyArray; +} +export interface ConstListValueNode { + readonly kind: typeof Kind.LIST; + readonly loc?: Location | undefined; + readonly values: ReadonlyArray; +} +export interface ObjectValueNode { + readonly kind: typeof Kind.OBJECT; + readonly loc?: Location | undefined; + readonly fields: ReadonlyArray; +} +export interface ConstObjectValueNode { + readonly kind: typeof Kind.OBJECT; + readonly loc?: Location | undefined; + readonly fields: ReadonlyArray; +} +export interface ObjectFieldNode { + readonly kind: typeof Kind.OBJECT_FIELD; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly value: ValueNode; +} +export interface ConstObjectFieldNode { + readonly kind: typeof Kind.OBJECT_FIELD; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly value: ConstValueNode; +} +/** Directives */ +export interface DirectiveNode { + readonly kind: typeof Kind.DIRECTIVE; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly arguments?: ReadonlyArray | undefined; +} +export interface ConstDirectiveNode { + readonly kind: typeof Kind.DIRECTIVE; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly arguments?: ReadonlyArray | undefined; +} +/** Type Reference */ +export type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode; +export interface NamedTypeNode { + readonly kind: typeof Kind.NAMED_TYPE; + readonly loc?: Location | undefined; + readonly name: NameNode; +} +export interface ListTypeNode { + readonly kind: typeof Kind.LIST_TYPE; + readonly loc?: Location | undefined; + readonly type: TypeNode; +} +export interface NonNullTypeNode { + readonly kind: typeof Kind.NON_NULL_TYPE; + readonly loc?: Location | undefined; + readonly type: NamedTypeNode | ListTypeNode; +} +/** Type System Definition */ +export type TypeSystemDefinitionNode = SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode; +export interface SchemaDefinitionNode { + readonly kind: typeof Kind.SCHEMA_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly operationTypes: ReadonlyArray; +} +export interface OperationTypeDefinitionNode { + readonly kind: typeof Kind.OPERATION_TYPE_DEFINITION; + readonly loc?: Location | undefined; + readonly operation: OperationTypeNode; + readonly type: NamedTypeNode; +} +/** Type Definition */ +export type TypeDefinitionNode = ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | InputObjectTypeDefinitionNode; +export interface ScalarTypeDefinitionNode { + readonly kind: typeof Kind.SCALAR_TYPE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; +} +export interface ObjectTypeDefinitionNode { + readonly kind: typeof Kind.OBJECT_TYPE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly interfaces?: ReadonlyArray | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly fields?: ReadonlyArray | undefined; +} +export interface FieldDefinitionNode { + readonly kind: typeof Kind.FIELD_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly arguments?: ReadonlyArray | undefined; + readonly type: TypeNode; + readonly directives?: ReadonlyArray | undefined; +} +export interface InputValueDefinitionNode { + readonly kind: typeof Kind.INPUT_VALUE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly type: TypeNode; + readonly defaultValue?: ConstValueNode | undefined; + readonly directives?: ReadonlyArray | undefined; +} +export interface InterfaceTypeDefinitionNode { + readonly kind: typeof Kind.INTERFACE_TYPE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly interfaces?: ReadonlyArray | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly fields?: ReadonlyArray | undefined; +} +export interface UnionTypeDefinitionNode { + readonly kind: typeof Kind.UNION_TYPE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; + readonly types?: ReadonlyArray | undefined; +} +export interface EnumTypeDefinitionNode { + readonly kind: typeof Kind.ENUM_TYPE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; + readonly values?: ReadonlyArray | undefined; +} +export interface EnumValueDefinitionNode { + readonly kind: typeof Kind.ENUM_VALUE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; +} +export interface InputObjectTypeDefinitionNode { + readonly kind: typeof Kind.INPUT_OBJECT_TYPE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; + readonly fields?: ReadonlyArray | undefined; +} +/** Directive Definitions */ +export interface DirectiveDefinitionNode { + readonly kind: typeof Kind.DIRECTIVE_DEFINITION; + readonly loc?: Location | undefined; + readonly description?: StringValueNode | undefined; + readonly name: NameNode; + readonly arguments?: ReadonlyArray | undefined; + readonly repeatable: boolean; + readonly locations: ReadonlyArray; +} +/** Type System Extensions */ +export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode; +export interface SchemaExtensionNode { + readonly kind: typeof Kind.SCHEMA_EXTENSION; + readonly loc?: Location | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly operationTypes?: ReadonlyArray | undefined; +} +/** Type Extensions */ +export type TypeExtensionNode = ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode; +export interface ScalarTypeExtensionNode { + readonly kind: typeof Kind.SCALAR_TYPE_EXTENSION; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; +} +export interface ObjectTypeExtensionNode { + readonly kind: typeof Kind.OBJECT_TYPE_EXTENSION; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly interfaces?: ReadonlyArray | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly fields?: ReadonlyArray | undefined; +} +export interface InterfaceTypeExtensionNode { + readonly kind: typeof Kind.INTERFACE_TYPE_EXTENSION; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly interfaces?: ReadonlyArray | undefined; + readonly directives?: ReadonlyArray | undefined; + readonly fields?: ReadonlyArray | undefined; +} +export interface UnionTypeExtensionNode { + readonly kind: typeof Kind.UNION_TYPE_EXTENSION; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; + readonly types?: ReadonlyArray | undefined; +} +export interface EnumTypeExtensionNode { + readonly kind: typeof Kind.ENUM_TYPE_EXTENSION; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; + readonly values?: ReadonlyArray | undefined; +} +export interface InputObjectTypeExtensionNode { + readonly kind: typeof Kind.INPUT_OBJECT_TYPE_EXTENSION; + readonly loc?: Location | undefined; + readonly name: NameNode; + readonly directives?: ReadonlyArray | undefined; + readonly fields?: ReadonlyArray | undefined; +} diff --git a/language/ast.js b/language/ast.js new file mode 100644 index 0000000000..06a9aff8e4 --- /dev/null +++ b/language/ast.js @@ -0,0 +1,154 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OperationTypeNode = exports.QueryDocumentKeys = exports.Token = exports.Location = void 0; +exports.isNode = isNode; +/** + * Contains a range of UTF-8 character offsets and token references that + * identify the region of the source from which the AST derived. + */ +class Location { + constructor(startToken, endToken, source) { + this.start = startToken.start; + this.end = endToken.end; + this.startToken = startToken; + this.endToken = endToken; + this.source = source; + } + get [Symbol.toStringTag]() { + return 'Location'; + } + toJSON() { + return { start: this.start, end: this.end }; + } +} +exports.Location = Location; +/** + * Represents a range of characters represented by a lexical token + * within a Source. + */ +class Token { + // eslint-disable-next-line @typescript-eslint/max-params + constructor(kind, start, end, line, column, value) { + this.kind = kind; + this.start = start; + this.end = end; + this.line = line; + this.column = column; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + this.value = value; + this.prev = null; + this.next = null; + } + get [Symbol.toStringTag]() { + return 'Token'; + } + toJSON() { + return { + kind: this.kind, + value: this.value, + line: this.line, + column: this.column, + }; + } +} +exports.Token = Token; +/** + * @internal + */ +exports.QueryDocumentKeys = { + Name: [], + Document: ['definitions'], + OperationDefinition: [ + 'name', + 'variableDefinitions', + 'directives', + 'selectionSet', + ], + VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], + Variable: ['name'], + SelectionSet: ['selections'], + Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], + Argument: ['name', 'value'], + FragmentArgument: ['name', 'value'], + FragmentSpread: [ + 'name', + // Note: Fragment arguments are experimental and may be changed or removed + // in the future. + 'arguments', + 'directives', + ], + InlineFragment: ['typeCondition', 'directives', 'selectionSet'], + FragmentDefinition: [ + 'name', + // Note: Fragment variables are experimental and may be changed or removed + // in the future. + 'variableDefinitions', + 'typeCondition', + 'directives', + 'selectionSet', + ], + IntValue: [], + FloatValue: [], + StringValue: [], + BooleanValue: [], + NullValue: [], + EnumValue: [], + ListValue: ['values'], + ObjectValue: ['fields'], + ObjectField: ['name', 'value'], + Directive: ['name', 'arguments'], + NamedType: ['name'], + ListType: ['type'], + NonNullType: ['type'], + SchemaDefinition: ['description', 'directives', 'operationTypes'], + OperationTypeDefinition: ['type'], + ScalarTypeDefinition: ['description', 'name', 'directives'], + ObjectTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'], + InputValueDefinition: [ + 'description', + 'name', + 'type', + 'defaultValue', + 'directives', + ], + InterfaceTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + UnionTypeDefinition: ['description', 'name', 'directives', 'types'], + EnumTypeDefinition: ['description', 'name', 'directives', 'values'], + EnumValueDefinition: ['description', 'name', 'directives'], + InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'], + DirectiveDefinition: ['description', 'name', 'arguments', 'locations'], + SchemaExtension: ['directives', 'operationTypes'], + ScalarTypeExtension: ['name', 'directives'], + ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + UnionTypeExtension: ['name', 'directives', 'types'], + EnumTypeExtension: ['name', 'directives', 'values'], + InputObjectTypeExtension: ['name', 'directives', 'fields'], +}; +const kindValues = new Set(Object.keys(exports.QueryDocumentKeys)); +/** + * @internal + */ +function isNode(maybeNode) { + const maybeKind = maybeNode?.kind; + return typeof maybeKind === 'string' && kindValues.has(maybeKind); +} +exports.OperationTypeNode = { + QUERY: 'query', + MUTATION: 'mutation', + SUBSCRIPTION: 'subscription', +}; +//# sourceMappingURL=ast.js.map \ No newline at end of file diff --git a/language/ast.js.map b/language/ast.js.map new file mode 100644 index 0000000000..4b6d1ddef1 --- /dev/null +++ b/language/ast.js.map @@ -0,0 +1 @@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AE,QAAQ,CAAC;IACtE,kBAAkB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC;IACnD,iBAAiB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC;IACnD,wBAAwB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC;CAC3D,CAAC;AAEF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAC,CAAC;AACnE;;GAEG;AACH,SAAgB,MAAM,CAAC,SAAc;IACnC,MAAM,SAAS,GAAG,SAAS,EAAE,IAAI,CAAC;IAClC,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACpE,CAAC;AAwCY,QAAA,iBAAiB,GAAG;IAC/B,KAAK,EAAE,OAAgB;IACvB,QAAQ,EAAE,UAAmB;IAC7B,YAAY,EAAE,cAAuB;CAC7B,CAAC","sourcesContent":["import type { Kind } from './kinds.js';\nimport type { Source } from './source.js';\nimport type { TokenKind } from './tokenKind.js';\n\n/**\n * Contains a range of UTF-8 character offsets and token references that\n * identify the region of the source from which the AST derived.\n */\nexport class Location {\n /**\n * The character offset at which this Node begins.\n */\n readonly start: number;\n\n /**\n * The character offset at which this Node ends.\n */\n readonly end: number;\n\n /**\n * The Token at which this Node begins.\n */\n readonly startToken: Token;\n\n /**\n * The Token at which this Node ends.\n */\n readonly endToken: Token;\n\n /**\n * The Source document the AST represents.\n */\n readonly source: Source;\n\n constructor(startToken: Token, endToken: Token, source: Source) {\n this.start = startToken.start;\n this.end = endToken.end;\n this.startToken = startToken;\n this.endToken = endToken;\n this.source = source;\n }\n\n get [Symbol.toStringTag]() {\n return 'Location';\n }\n\n toJSON(): { start: number; end: number } {\n return { start: this.start, end: this.end };\n }\n}\n\n/**\n * Represents a range of characters represented by a lexical token\n * within a Source.\n */\nexport class Token {\n /**\n * The kind of Token.\n */\n readonly kind: TokenKind;\n\n /**\n * The character offset at which this Node begins.\n */\n readonly start: number;\n\n /**\n * The character offset at which this Node ends.\n */\n readonly end: number;\n\n /**\n * The 1-indexed line number on which this Token appears.\n */\n readonly line: number;\n\n /**\n * The 1-indexed column number at which this Token begins.\n */\n readonly column: number;\n\n /**\n * For non-punctuation tokens, represents the interpreted value of the token.\n *\n * Note: is undefined for punctuation tokens, but typed as string for\n * convenience in the parser.\n */\n readonly value: string;\n\n /**\n * Tokens exist as nodes in a double-linked-list amongst all tokens\n * including ignored tokens. is always the first node and \n * the last.\n */\n readonly prev: Token | null;\n readonly next: Token | null;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n kind: TokenKind,\n start: number,\n end: number,\n line: number,\n column: number,\n value?: string,\n ) {\n this.kind = kind;\n this.start = start;\n this.end = end;\n this.line = line;\n this.column = column;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.value = value!;\n this.prev = null;\n this.next = null;\n }\n\n get [Symbol.toStringTag]() {\n return 'Token';\n }\n\n toJSON(): {\n kind: TokenKind;\n value?: string;\n line: number;\n column: number;\n } {\n return {\n kind: this.kind,\n value: this.value,\n line: this.line,\n column: this.column,\n };\n }\n}\n\n/**\n * The list of all possible AST node types.\n */\nexport type ASTNode =\n | NameNode\n | DocumentNode\n | OperationDefinitionNode\n | VariableDefinitionNode\n | VariableNode\n | SelectionSetNode\n | FieldNode\n | ArgumentNode\n | FragmentArgumentNode\n | FragmentSpreadNode\n | InlineFragmentNode\n | FragmentDefinitionNode\n | IntValueNode\n | FloatValueNode\n | StringValueNode\n | BooleanValueNode\n | NullValueNode\n | EnumValueNode\n | ListValueNode\n | ObjectValueNode\n | ObjectFieldNode\n | DirectiveNode\n | NamedTypeNode\n | ListTypeNode\n | NonNullTypeNode\n | SchemaDefinitionNode\n | OperationTypeDefinitionNode\n | ScalarTypeDefinitionNode\n | ObjectTypeDefinitionNode\n | FieldDefinitionNode\n | InputValueDefinitionNode\n | InterfaceTypeDefinitionNode\n | UnionTypeDefinitionNode\n | EnumTypeDefinitionNode\n | EnumValueDefinitionNode\n | InputObjectTypeDefinitionNode\n | DirectiveDefinitionNode\n | SchemaExtensionNode\n | ScalarTypeExtensionNode\n | ObjectTypeExtensionNode\n | InterfaceTypeExtensionNode\n | UnionTypeExtensionNode\n | EnumTypeExtensionNode\n | InputObjectTypeExtensionNode;\n\n/**\n * Utility type listing all nodes indexed by their kind.\n */\nexport type ASTKindToNode = {\n [NodeT in ASTNode as NodeT['kind']]: NodeT;\n};\n\n/**\n * @internal\n */\nexport const QueryDocumentKeys: {\n [NodeT in ASTNode as NodeT['kind']]: ReadonlyArray;\n} = {\n Name: [],\n\n Document: ['definitions'],\n OperationDefinition: [\n 'name',\n 'variableDefinitions',\n 'directives',\n 'selectionSet',\n ],\n VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],\n Variable: ['name'],\n SelectionSet: ['selections'],\n Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],\n Argument: ['name', 'value'],\n FragmentArgument: ['name', 'value'],\n\n FragmentSpread: [\n 'name',\n // Note: Fragment arguments are experimental and may be changed or removed\n // in the future.\n 'arguments',\n 'directives',\n ],\n InlineFragment: ['typeCondition', 'directives', 'selectionSet'],\n FragmentDefinition: [\n 'name',\n // Note: Fragment variables are experimental and may be changed or removed\n // in the future.\n 'variableDefinitions',\n 'typeCondition',\n 'directives',\n 'selectionSet',\n ],\n\n IntValue: [],\n FloatValue: [],\n StringValue: [],\n BooleanValue: [],\n NullValue: [],\n EnumValue: [],\n ListValue: ['values'],\n ObjectValue: ['fields'],\n ObjectField: ['name', 'value'],\n\n Directive: ['name', 'arguments'],\n\n NamedType: ['name'],\n ListType: ['type'],\n NonNullType: ['type'],\n\n SchemaDefinition: ['description', 'directives', 'operationTypes'],\n OperationTypeDefinition: ['type'],\n\n ScalarTypeDefinition: ['description', 'name', 'directives'],\n ObjectTypeDefinition: [\n 'description',\n 'name',\n 'interfaces',\n 'directives',\n 'fields',\n ],\n FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],\n InputValueDefinition: [\n 'description',\n 'name',\n 'type',\n 'defaultValue',\n 'directives',\n ],\n InterfaceTypeDefinition: [\n 'description',\n 'name',\n 'interfaces',\n 'directives',\n 'fields',\n ],\n UnionTypeDefinition: ['description', 'name', 'directives', 'types'],\n EnumTypeDefinition: ['description', 'name', 'directives', 'values'],\n EnumValueDefinition: ['description', 'name', 'directives'],\n InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],\n\n DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],\n\n SchemaExtension: ['directives', 'operationTypes'],\n\n ScalarTypeExtension: ['name', 'directives'],\n ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n UnionTypeExtension: ['name', 'directives', 'types'],\n EnumTypeExtension: ['name', 'directives', 'values'],\n InputObjectTypeExtension: ['name', 'directives', 'fields'],\n};\n\nconst kindValues = new Set(Object.keys(QueryDocumentKeys));\n/**\n * @internal\n */\nexport function isNode(maybeNode: any): maybeNode is ASTNode {\n const maybeKind = maybeNode?.kind;\n return typeof maybeKind === 'string' && kindValues.has(maybeKind);\n}\n\n/** Name */\n\nexport interface NameNode {\n readonly kind: typeof Kind.NAME;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\n/** Document */\n\nexport interface DocumentNode {\n readonly kind: typeof Kind.DOCUMENT;\n readonly loc?: Location | undefined;\n readonly definitions: ReadonlyArray;\n readonly tokenCount?: number | undefined;\n}\n\nexport type DefinitionNode =\n | ExecutableDefinitionNode\n | TypeSystemDefinitionNode\n | TypeSystemExtensionNode;\n\nexport type ExecutableDefinitionNode =\n | OperationDefinitionNode\n | FragmentDefinitionNode;\n\nexport interface OperationDefinitionNode {\n readonly kind: typeof Kind.OPERATION_DEFINITION;\n readonly loc?: Location | undefined;\n readonly operation: OperationTypeNode;\n readonly name?: NameNode | undefined;\n readonly variableDefinitions?:\n | ReadonlyArray\n | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet: SelectionSetNode;\n}\n\nexport const OperationTypeNode = {\n QUERY: 'query' as const,\n MUTATION: 'mutation' as const,\n SUBSCRIPTION: 'subscription' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type OperationTypeNode =\n (typeof OperationTypeNode)[keyof typeof OperationTypeNode];\n\nexport interface VariableDefinitionNode {\n readonly kind: typeof Kind.VARIABLE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly variable: VariableNode;\n readonly type: TypeNode;\n readonly defaultValue?: ConstValueNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface VariableNode {\n readonly kind: typeof Kind.VARIABLE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n}\n\nexport interface SelectionSetNode {\n kind: typeof Kind.SELECTION_SET;\n loc?: Location | undefined;\n selections: ReadonlyArray;\n}\n\nexport type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode;\n\nexport interface FieldNode {\n readonly kind: typeof Kind.FIELD;\n readonly loc?: Location | undefined;\n readonly alias?: NameNode | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet?: SelectionSetNode | undefined;\n}\n\nexport interface ArgumentNode {\n readonly kind: typeof Kind.ARGUMENT;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ValueNode;\n}\n\nexport interface ConstArgumentNode {\n readonly kind: typeof Kind.ARGUMENT;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ConstValueNode;\n}\n\nexport interface FragmentArgumentNode {\n readonly kind: typeof Kind.FRAGMENT_ARGUMENT;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ValueNode;\n}\n\n/** Fragments */\n\nexport interface FragmentSpreadNode {\n readonly kind: typeof Kind.FRAGMENT_SPREAD;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InlineFragmentNode {\n readonly kind: typeof Kind.INLINE_FRAGMENT;\n readonly loc?: Location | undefined;\n readonly typeCondition?: NamedTypeNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet: SelectionSetNode;\n}\n\nexport interface FragmentDefinitionNode {\n readonly kind: typeof Kind.FRAGMENT_DEFINITION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly variableDefinitions?:\n | ReadonlyArray\n | undefined;\n readonly typeCondition: NamedTypeNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet: SelectionSetNode;\n}\n\n/** Values */\n\nexport type ValueNode =\n | VariableNode\n | IntValueNode\n | FloatValueNode\n | StringValueNode\n | BooleanValueNode\n | NullValueNode\n | EnumValueNode\n | ListValueNode\n | ObjectValueNode;\n\nexport type ConstValueNode =\n | IntValueNode\n | FloatValueNode\n | StringValueNode\n | BooleanValueNode\n | NullValueNode\n | EnumValueNode\n | ConstListValueNode\n | ConstObjectValueNode;\n\nexport interface IntValueNode {\n readonly kind: typeof Kind.INT;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\nexport interface FloatValueNode {\n readonly kind: typeof Kind.FLOAT;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\nexport interface StringValueNode {\n readonly kind: typeof Kind.STRING;\n readonly loc?: Location | undefined;\n readonly value: string;\n readonly block?: boolean | undefined;\n}\n\nexport interface BooleanValueNode {\n readonly kind: typeof Kind.BOOLEAN;\n readonly loc?: Location | undefined;\n readonly value: boolean;\n}\n\nexport interface NullValueNode {\n readonly kind: typeof Kind.NULL;\n readonly loc?: Location | undefined;\n}\n\nexport interface EnumValueNode {\n readonly kind: typeof Kind.ENUM;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\nexport interface ListValueNode {\n readonly kind: typeof Kind.LIST;\n readonly loc?: Location | undefined;\n readonly values: ReadonlyArray;\n}\n\nexport interface ConstListValueNode {\n readonly kind: typeof Kind.LIST;\n readonly loc?: Location | undefined;\n readonly values: ReadonlyArray;\n}\n\nexport interface ObjectValueNode {\n readonly kind: typeof Kind.OBJECT;\n readonly loc?: Location | undefined;\n readonly fields: ReadonlyArray;\n}\n\nexport interface ConstObjectValueNode {\n readonly kind: typeof Kind.OBJECT;\n readonly loc?: Location | undefined;\n readonly fields: ReadonlyArray;\n}\n\nexport interface ObjectFieldNode {\n readonly kind: typeof Kind.OBJECT_FIELD;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ValueNode;\n}\n\nexport interface ConstObjectFieldNode {\n readonly kind: typeof Kind.OBJECT_FIELD;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ConstValueNode;\n}\n\n/** Directives */\n\nexport interface DirectiveNode {\n readonly kind: typeof Kind.DIRECTIVE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n}\n\nexport interface ConstDirectiveNode {\n readonly kind: typeof Kind.DIRECTIVE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n}\n\n/** Type Reference */\n\nexport type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;\n\nexport interface NamedTypeNode {\n readonly kind: typeof Kind.NAMED_TYPE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n}\n\nexport interface ListTypeNode {\n readonly kind: typeof Kind.LIST_TYPE;\n readonly loc?: Location | undefined;\n readonly type: TypeNode;\n}\n\nexport interface NonNullTypeNode {\n readonly kind: typeof Kind.NON_NULL_TYPE;\n readonly loc?: Location | undefined;\n readonly type: NamedTypeNode | ListTypeNode;\n}\n\n/** Type System Definition */\n\nexport type TypeSystemDefinitionNode =\n | SchemaDefinitionNode\n | TypeDefinitionNode\n | DirectiveDefinitionNode;\n\nexport interface SchemaDefinitionNode {\n readonly kind: typeof Kind.SCHEMA_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly operationTypes: ReadonlyArray;\n}\n\nexport interface OperationTypeDefinitionNode {\n readonly kind: typeof Kind.OPERATION_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly operation: OperationTypeNode;\n readonly type: NamedTypeNode;\n}\n\n/** Type Definition */\n\nexport type TypeDefinitionNode =\n | ScalarTypeDefinitionNode\n | ObjectTypeDefinitionNode\n | InterfaceTypeDefinitionNode\n | UnionTypeDefinitionNode\n | EnumTypeDefinitionNode\n | InputObjectTypeDefinitionNode;\n\nexport interface ScalarTypeDefinitionNode {\n readonly kind: typeof Kind.SCALAR_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface ObjectTypeDefinitionNode {\n readonly kind: typeof Kind.OBJECT_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface FieldDefinitionNode {\n readonly kind: typeof Kind.FIELD_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly type: TypeNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InputValueDefinitionNode {\n readonly kind: typeof Kind.INPUT_VALUE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly type: TypeNode;\n readonly defaultValue?: ConstValueNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InterfaceTypeDefinitionNode {\n readonly kind: typeof Kind.INTERFACE_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface UnionTypeDefinitionNode {\n readonly kind: typeof Kind.UNION_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly types?: ReadonlyArray | undefined;\n}\n\nexport interface EnumTypeDefinitionNode {\n readonly kind: typeof Kind.ENUM_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly values?: ReadonlyArray | undefined;\n}\n\nexport interface EnumValueDefinitionNode {\n readonly kind: typeof Kind.ENUM_VALUE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InputObjectTypeDefinitionNode {\n readonly kind: typeof Kind.INPUT_OBJECT_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\n/** Directive Definitions */\n\nexport interface DirectiveDefinitionNode {\n readonly kind: typeof Kind.DIRECTIVE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly repeatable: boolean;\n readonly locations: ReadonlyArray;\n}\n\n/** Type System Extensions */\n\nexport type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;\n\nexport interface SchemaExtensionNode {\n readonly kind: typeof Kind.SCHEMA_EXTENSION;\n readonly loc?: Location | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly operationTypes?:\n | ReadonlyArray\n | undefined;\n}\n\n/** Type Extensions */\n\nexport type TypeExtensionNode =\n | ScalarTypeExtensionNode\n | ObjectTypeExtensionNode\n | InterfaceTypeExtensionNode\n | UnionTypeExtensionNode\n | EnumTypeExtensionNode\n | InputObjectTypeExtensionNode;\n\nexport interface ScalarTypeExtensionNode {\n readonly kind: typeof Kind.SCALAR_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface ObjectTypeExtensionNode {\n readonly kind: typeof Kind.OBJECT_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface InterfaceTypeExtensionNode {\n readonly kind: typeof Kind.INTERFACE_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface UnionTypeExtensionNode {\n readonly kind: typeof Kind.UNION_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly types?: ReadonlyArray | undefined;\n}\n\nexport interface EnumTypeExtensionNode {\n readonly kind: typeof Kind.ENUM_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly values?: ReadonlyArray | undefined;\n}\n\nexport interface InputObjectTypeExtensionNode {\n readonly kind: typeof Kind.INPUT_OBJECT_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n"]} \ No newline at end of file diff --git a/language/ast.mjs b/language/ast.mjs new file mode 100644 index 0000000000..ef3454c93d --- /dev/null +++ b/language/ast.mjs @@ -0,0 +1,148 @@ +/** + * Contains a range of UTF-8 character offsets and token references that + * identify the region of the source from which the AST derived. + */ +export class Location { + constructor(startToken, endToken, source) { + this.start = startToken.start; + this.end = endToken.end; + this.startToken = startToken; + this.endToken = endToken; + this.source = source; + } + get [Symbol.toStringTag]() { + return 'Location'; + } + toJSON() { + return { start: this.start, end: this.end }; + } +} +/** + * Represents a range of characters represented by a lexical token + * within a Source. + */ +export class Token { + // eslint-disable-next-line @typescript-eslint/max-params + constructor(kind, start, end, line, column, value) { + this.kind = kind; + this.start = start; + this.end = end; + this.line = line; + this.column = column; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + this.value = value; + this.prev = null; + this.next = null; + } + get [Symbol.toStringTag]() { + return 'Token'; + } + toJSON() { + return { + kind: this.kind, + value: this.value, + line: this.line, + column: this.column, + }; + } +} +/** + * @internal + */ +export const QueryDocumentKeys = { + Name: [], + Document: ['definitions'], + OperationDefinition: [ + 'name', + 'variableDefinitions', + 'directives', + 'selectionSet', + ], + VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], + Variable: ['name'], + SelectionSet: ['selections'], + Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], + Argument: ['name', 'value'], + FragmentArgument: ['name', 'value'], + FragmentSpread: [ + 'name', + // Note: Fragment arguments are experimental and may be changed or removed + // in the future. + 'arguments', + 'directives', + ], + InlineFragment: ['typeCondition', 'directives', 'selectionSet'], + FragmentDefinition: [ + 'name', + // Note: Fragment variables are experimental and may be changed or removed + // in the future. + 'variableDefinitions', + 'typeCondition', + 'directives', + 'selectionSet', + ], + IntValue: [], + FloatValue: [], + StringValue: [], + BooleanValue: [], + NullValue: [], + EnumValue: [], + ListValue: ['values'], + ObjectValue: ['fields'], + ObjectField: ['name', 'value'], + Directive: ['name', 'arguments'], + NamedType: ['name'], + ListType: ['type'], + NonNullType: ['type'], + SchemaDefinition: ['description', 'directives', 'operationTypes'], + OperationTypeDefinition: ['type'], + ScalarTypeDefinition: ['description', 'name', 'directives'], + ObjectTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'], + InputValueDefinition: [ + 'description', + 'name', + 'type', + 'defaultValue', + 'directives', + ], + InterfaceTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + UnionTypeDefinition: ['description', 'name', 'directives', 'types'], + EnumTypeDefinition: ['description', 'name', 'directives', 'values'], + EnumValueDefinition: ['description', 'name', 'directives'], + InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'], + DirectiveDefinition: ['description', 'name', 'arguments', 'locations'], + SchemaExtension: ['directives', 'operationTypes'], + ScalarTypeExtension: ['name', 'directives'], + ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + UnionTypeExtension: ['name', 'directives', 'types'], + EnumTypeExtension: ['name', 'directives', 'values'], + InputObjectTypeExtension: ['name', 'directives', 'fields'], +}; +const kindValues = new Set(Object.keys(QueryDocumentKeys)); +/** + * @internal + */ +export function isNode(maybeNode) { + const maybeKind = maybeNode?.kind; + return typeof maybeKind === 'string' && kindValues.has(maybeKind); +} +export const OperationTypeNode = { + QUERY: 'query', + MUTATION: 'mutation', + SUBSCRIPTION: 'subscription', +}; +//# sourceMappingURL=ast.js.map \ No newline at end of file diff --git a/language/ast.mjs.map b/language/ast.mjs.map new file mode 100644 index 0000000000..3ace099efd --- /dev/null +++ b/language/ast.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/language/ast.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,OAAO,QAAQ;IA0BnB,YAAY,UAAiB,EAAE,QAAe,EAAE,MAAc;QAC5D,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7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AAM,UAAU,MAAM,CAAC,SAAc;IACnC,MAAM,SAAS,GAAG,SAAS,EAAE,IAAI,CAAC;IAClC,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACpE,CAAC;AAwCD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE,OAAgB;IACvB,QAAQ,EAAE,UAAmB;IAC7B,YAAY,EAAE,cAAuB;CAC7B,CAAC","sourcesContent":["import type { Kind } from './kinds.js';\nimport type { Source } from './source.js';\nimport type { TokenKind } from './tokenKind.js';\n\n/**\n * Contains a range of UTF-8 character offsets and token references that\n * identify the region of the source from which the AST derived.\n */\nexport class Location {\n /**\n * The character offset at which this Node begins.\n */\n readonly start: number;\n\n /**\n * The character offset at which this Node ends.\n */\n readonly end: number;\n\n /**\n * The Token at which this Node begins.\n */\n readonly startToken: Token;\n\n /**\n * The Token at which this Node ends.\n */\n readonly endToken: Token;\n\n /**\n * The Source document the AST represents.\n */\n readonly source: Source;\n\n constructor(startToken: Token, endToken: Token, source: Source) {\n this.start = startToken.start;\n this.end = endToken.end;\n this.startToken = startToken;\n this.endToken = endToken;\n this.source = source;\n }\n\n get [Symbol.toStringTag]() {\n return 'Location';\n }\n\n toJSON(): { start: number; end: number } {\n return { start: this.start, end: this.end };\n }\n}\n\n/**\n * Represents a range of characters represented by a lexical token\n * within a Source.\n */\nexport class Token {\n /**\n * The kind of Token.\n */\n readonly kind: TokenKind;\n\n /**\n * The character offset at which this Node begins.\n */\n readonly start: number;\n\n /**\n * The character offset at which this Node ends.\n */\n readonly end: number;\n\n /**\n * The 1-indexed line number on which this Token appears.\n */\n readonly line: number;\n\n /**\n * The 1-indexed column number at which this Token begins.\n */\n readonly column: number;\n\n /**\n * For non-punctuation tokens, represents the interpreted value of the token.\n *\n * Note: is undefined for punctuation tokens, but typed as string for\n * convenience in the parser.\n */\n readonly value: string;\n\n /**\n * Tokens exist as nodes in a double-linked-list amongst all tokens\n * including ignored tokens. is always the first node and \n * the last.\n */\n readonly prev: Token | null;\n readonly next: Token | null;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n kind: TokenKind,\n start: number,\n end: number,\n line: number,\n column: number,\n value?: string,\n ) {\n this.kind = kind;\n this.start = start;\n this.end = end;\n this.line = line;\n this.column = column;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.value = value!;\n this.prev = null;\n this.next = null;\n }\n\n get [Symbol.toStringTag]() {\n return 'Token';\n }\n\n toJSON(): {\n kind: TokenKind;\n value?: string;\n line: number;\n column: number;\n } {\n return {\n kind: this.kind,\n value: this.value,\n line: this.line,\n column: this.column,\n };\n }\n}\n\n/**\n * The list of all possible AST node types.\n */\nexport type ASTNode =\n | NameNode\n | DocumentNode\n | OperationDefinitionNode\n | VariableDefinitionNode\n | VariableNode\n | SelectionSetNode\n | FieldNode\n | ArgumentNode\n | FragmentArgumentNode\n | FragmentSpreadNode\n | InlineFragmentNode\n | FragmentDefinitionNode\n | IntValueNode\n | FloatValueNode\n | StringValueNode\n | BooleanValueNode\n | NullValueNode\n | EnumValueNode\n | ListValueNode\n | ObjectValueNode\n | ObjectFieldNode\n | DirectiveNode\n | NamedTypeNode\n | ListTypeNode\n | NonNullTypeNode\n | SchemaDefinitionNode\n | OperationTypeDefinitionNode\n | ScalarTypeDefinitionNode\n | ObjectTypeDefinitionNode\n | FieldDefinitionNode\n | InputValueDefinitionNode\n | InterfaceTypeDefinitionNode\n | UnionTypeDefinitionNode\n | EnumTypeDefinitionNode\n | EnumValueDefinitionNode\n | InputObjectTypeDefinitionNode\n | DirectiveDefinitionNode\n | SchemaExtensionNode\n | ScalarTypeExtensionNode\n | ObjectTypeExtensionNode\n | InterfaceTypeExtensionNode\n | UnionTypeExtensionNode\n | EnumTypeExtensionNode\n | InputObjectTypeExtensionNode;\n\n/**\n * Utility type listing all nodes indexed by their kind.\n */\nexport type ASTKindToNode = {\n [NodeT in ASTNode as NodeT['kind']]: NodeT;\n};\n\n/**\n * @internal\n */\nexport const QueryDocumentKeys: {\n [NodeT in ASTNode as NodeT['kind']]: ReadonlyArray;\n} = {\n Name: [],\n\n Document: ['definitions'],\n OperationDefinition: [\n 'name',\n 'variableDefinitions',\n 'directives',\n 'selectionSet',\n ],\n VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],\n Variable: ['name'],\n SelectionSet: ['selections'],\n Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],\n Argument: ['name', 'value'],\n FragmentArgument: ['name', 'value'],\n\n FragmentSpread: [\n 'name',\n // Note: Fragment arguments are experimental and may be changed or removed\n // in the future.\n 'arguments',\n 'directives',\n ],\n InlineFragment: ['typeCondition', 'directives', 'selectionSet'],\n FragmentDefinition: [\n 'name',\n // Note: Fragment variables are experimental and may be changed or removed\n // in the future.\n 'variableDefinitions',\n 'typeCondition',\n 'directives',\n 'selectionSet',\n ],\n\n IntValue: [],\n FloatValue: [],\n StringValue: [],\n BooleanValue: [],\n NullValue: [],\n EnumValue: [],\n ListValue: ['values'],\n ObjectValue: ['fields'],\n ObjectField: ['name', 'value'],\n\n Directive: ['name', 'arguments'],\n\n NamedType: ['name'],\n ListType: ['type'],\n NonNullType: ['type'],\n\n SchemaDefinition: ['description', 'directives', 'operationTypes'],\n OperationTypeDefinition: ['type'],\n\n ScalarTypeDefinition: ['description', 'name', 'directives'],\n ObjectTypeDefinition: [\n 'description',\n 'name',\n 'interfaces',\n 'directives',\n 'fields',\n ],\n FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],\n InputValueDefinition: [\n 'description',\n 'name',\n 'type',\n 'defaultValue',\n 'directives',\n ],\n InterfaceTypeDefinition: [\n 'description',\n 'name',\n 'interfaces',\n 'directives',\n 'fields',\n ],\n UnionTypeDefinition: ['description', 'name', 'directives', 'types'],\n EnumTypeDefinition: ['description', 'name', 'directives', 'values'],\n EnumValueDefinition: ['description', 'name', 'directives'],\n InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],\n\n DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],\n\n SchemaExtension: ['directives', 'operationTypes'],\n\n ScalarTypeExtension: ['name', 'directives'],\n ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n UnionTypeExtension: ['name', 'directives', 'types'],\n EnumTypeExtension: ['name', 'directives', 'values'],\n InputObjectTypeExtension: ['name', 'directives', 'fields'],\n};\n\nconst kindValues = new Set(Object.keys(QueryDocumentKeys));\n/**\n * @internal\n */\nexport function isNode(maybeNode: any): maybeNode is ASTNode {\n const maybeKind = maybeNode?.kind;\n return typeof maybeKind === 'string' && kindValues.has(maybeKind);\n}\n\n/** Name */\n\nexport interface NameNode {\n readonly kind: typeof Kind.NAME;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\n/** Document */\n\nexport interface DocumentNode {\n readonly kind: typeof Kind.DOCUMENT;\n readonly loc?: Location | undefined;\n readonly definitions: ReadonlyArray;\n readonly tokenCount?: number | undefined;\n}\n\nexport type DefinitionNode =\n | ExecutableDefinitionNode\n | TypeSystemDefinitionNode\n | TypeSystemExtensionNode;\n\nexport type ExecutableDefinitionNode =\n | OperationDefinitionNode\n | FragmentDefinitionNode;\n\nexport interface OperationDefinitionNode {\n readonly kind: typeof Kind.OPERATION_DEFINITION;\n readonly loc?: Location | undefined;\n readonly operation: OperationTypeNode;\n readonly name?: NameNode | undefined;\n readonly variableDefinitions?:\n | ReadonlyArray\n | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet: SelectionSetNode;\n}\n\nexport const OperationTypeNode = {\n QUERY: 'query' as const,\n MUTATION: 'mutation' as const,\n SUBSCRIPTION: 'subscription' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type OperationTypeNode =\n (typeof OperationTypeNode)[keyof typeof OperationTypeNode];\n\nexport interface VariableDefinitionNode {\n readonly kind: typeof Kind.VARIABLE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly variable: VariableNode;\n readonly type: TypeNode;\n readonly defaultValue?: ConstValueNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface VariableNode {\n readonly kind: typeof Kind.VARIABLE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n}\n\nexport interface SelectionSetNode {\n kind: typeof Kind.SELECTION_SET;\n loc?: Location | undefined;\n selections: ReadonlyArray;\n}\n\nexport type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode;\n\nexport interface FieldNode {\n readonly kind: typeof Kind.FIELD;\n readonly loc?: Location | undefined;\n readonly alias?: NameNode | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet?: SelectionSetNode | undefined;\n}\n\nexport interface ArgumentNode {\n readonly kind: typeof Kind.ARGUMENT;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ValueNode;\n}\n\nexport interface ConstArgumentNode {\n readonly kind: typeof Kind.ARGUMENT;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ConstValueNode;\n}\n\nexport interface FragmentArgumentNode {\n readonly kind: typeof Kind.FRAGMENT_ARGUMENT;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ValueNode;\n}\n\n/** Fragments */\n\nexport interface FragmentSpreadNode {\n readonly kind: typeof Kind.FRAGMENT_SPREAD;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InlineFragmentNode {\n readonly kind: typeof Kind.INLINE_FRAGMENT;\n readonly loc?: Location | undefined;\n readonly typeCondition?: NamedTypeNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet: SelectionSetNode;\n}\n\nexport interface FragmentDefinitionNode {\n readonly kind: typeof Kind.FRAGMENT_DEFINITION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly variableDefinitions?:\n | ReadonlyArray\n | undefined;\n readonly typeCondition: NamedTypeNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly selectionSet: SelectionSetNode;\n}\n\n/** Values */\n\nexport type ValueNode =\n | VariableNode\n | IntValueNode\n | FloatValueNode\n | StringValueNode\n | BooleanValueNode\n | NullValueNode\n | EnumValueNode\n | ListValueNode\n | ObjectValueNode;\n\nexport type ConstValueNode =\n | IntValueNode\n | FloatValueNode\n | StringValueNode\n | BooleanValueNode\n | NullValueNode\n | EnumValueNode\n | ConstListValueNode\n | ConstObjectValueNode;\n\nexport interface IntValueNode {\n readonly kind: typeof Kind.INT;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\nexport interface FloatValueNode {\n readonly kind: typeof Kind.FLOAT;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\nexport interface StringValueNode {\n readonly kind: typeof Kind.STRING;\n readonly loc?: Location | undefined;\n readonly value: string;\n readonly block?: boolean | undefined;\n}\n\nexport interface BooleanValueNode {\n readonly kind: typeof Kind.BOOLEAN;\n readonly loc?: Location | undefined;\n readonly value: boolean;\n}\n\nexport interface NullValueNode {\n readonly kind: typeof Kind.NULL;\n readonly loc?: Location | undefined;\n}\n\nexport interface EnumValueNode {\n readonly kind: typeof Kind.ENUM;\n readonly loc?: Location | undefined;\n readonly value: string;\n}\n\nexport interface ListValueNode {\n readonly kind: typeof Kind.LIST;\n readonly loc?: Location | undefined;\n readonly values: ReadonlyArray;\n}\n\nexport interface ConstListValueNode {\n readonly kind: typeof Kind.LIST;\n readonly loc?: Location | undefined;\n readonly values: ReadonlyArray;\n}\n\nexport interface ObjectValueNode {\n readonly kind: typeof Kind.OBJECT;\n readonly loc?: Location | undefined;\n readonly fields: ReadonlyArray;\n}\n\nexport interface ConstObjectValueNode {\n readonly kind: typeof Kind.OBJECT;\n readonly loc?: Location | undefined;\n readonly fields: ReadonlyArray;\n}\n\nexport interface ObjectFieldNode {\n readonly kind: typeof Kind.OBJECT_FIELD;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ValueNode;\n}\n\nexport interface ConstObjectFieldNode {\n readonly kind: typeof Kind.OBJECT_FIELD;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly value: ConstValueNode;\n}\n\n/** Directives */\n\nexport interface DirectiveNode {\n readonly kind: typeof Kind.DIRECTIVE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n}\n\nexport interface ConstDirectiveNode {\n readonly kind: typeof Kind.DIRECTIVE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n}\n\n/** Type Reference */\n\nexport type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;\n\nexport interface NamedTypeNode {\n readonly kind: typeof Kind.NAMED_TYPE;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n}\n\nexport interface ListTypeNode {\n readonly kind: typeof Kind.LIST_TYPE;\n readonly loc?: Location | undefined;\n readonly type: TypeNode;\n}\n\nexport interface NonNullTypeNode {\n readonly kind: typeof Kind.NON_NULL_TYPE;\n readonly loc?: Location | undefined;\n readonly type: NamedTypeNode | ListTypeNode;\n}\n\n/** Type System Definition */\n\nexport type TypeSystemDefinitionNode =\n | SchemaDefinitionNode\n | TypeDefinitionNode\n | DirectiveDefinitionNode;\n\nexport interface SchemaDefinitionNode {\n readonly kind: typeof Kind.SCHEMA_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly operationTypes: ReadonlyArray;\n}\n\nexport interface OperationTypeDefinitionNode {\n readonly kind: typeof Kind.OPERATION_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly operation: OperationTypeNode;\n readonly type: NamedTypeNode;\n}\n\n/** Type Definition */\n\nexport type TypeDefinitionNode =\n | ScalarTypeDefinitionNode\n | ObjectTypeDefinitionNode\n | InterfaceTypeDefinitionNode\n | UnionTypeDefinitionNode\n | EnumTypeDefinitionNode\n | InputObjectTypeDefinitionNode;\n\nexport interface ScalarTypeDefinitionNode {\n readonly kind: typeof Kind.SCALAR_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface ObjectTypeDefinitionNode {\n readonly kind: typeof Kind.OBJECT_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface FieldDefinitionNode {\n readonly kind: typeof Kind.FIELD_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly type: TypeNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InputValueDefinitionNode {\n readonly kind: typeof Kind.INPUT_VALUE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly type: TypeNode;\n readonly defaultValue?: ConstValueNode | undefined;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InterfaceTypeDefinitionNode {\n readonly kind: typeof Kind.INTERFACE_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface UnionTypeDefinitionNode {\n readonly kind: typeof Kind.UNION_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly types?: ReadonlyArray | undefined;\n}\n\nexport interface EnumTypeDefinitionNode {\n readonly kind: typeof Kind.ENUM_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly values?: ReadonlyArray | undefined;\n}\n\nexport interface EnumValueDefinitionNode {\n readonly kind: typeof Kind.ENUM_VALUE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface InputObjectTypeDefinitionNode {\n readonly kind: typeof Kind.INPUT_OBJECT_TYPE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\n/** Directive Definitions */\n\nexport interface DirectiveDefinitionNode {\n readonly kind: typeof Kind.DIRECTIVE_DEFINITION;\n readonly loc?: Location | undefined;\n readonly description?: StringValueNode | undefined;\n readonly name: NameNode;\n readonly arguments?: ReadonlyArray | undefined;\n readonly repeatable: boolean;\n readonly locations: ReadonlyArray;\n}\n\n/** Type System Extensions */\n\nexport type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;\n\nexport interface SchemaExtensionNode {\n readonly kind: typeof Kind.SCHEMA_EXTENSION;\n readonly loc?: Location | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly operationTypes?:\n | ReadonlyArray\n | undefined;\n}\n\n/** Type Extensions */\n\nexport type TypeExtensionNode =\n | ScalarTypeExtensionNode\n | ObjectTypeExtensionNode\n | InterfaceTypeExtensionNode\n | UnionTypeExtensionNode\n | EnumTypeExtensionNode\n | InputObjectTypeExtensionNode;\n\nexport interface ScalarTypeExtensionNode {\n readonly kind: typeof Kind.SCALAR_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n}\n\nexport interface ObjectTypeExtensionNode {\n readonly kind: typeof Kind.OBJECT_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface InterfaceTypeExtensionNode {\n readonly kind: typeof Kind.INTERFACE_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly interfaces?: ReadonlyArray | undefined;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n\nexport interface UnionTypeExtensionNode {\n readonly kind: typeof Kind.UNION_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly types?: ReadonlyArray | undefined;\n}\n\nexport interface EnumTypeExtensionNode {\n readonly kind: typeof Kind.ENUM_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly values?: ReadonlyArray | undefined;\n}\n\nexport interface InputObjectTypeExtensionNode {\n readonly kind: typeof Kind.INPUT_OBJECT_TYPE_EXTENSION;\n readonly loc?: Location | undefined;\n readonly name: NameNode;\n readonly directives?: ReadonlyArray | undefined;\n readonly fields?: ReadonlyArray | undefined;\n}\n"]} \ No newline at end of file diff --git a/language/blockString.d.ts b/language/blockString.d.ts new file mode 100644 index 0000000000..231ff09944 --- /dev/null +++ b/language/blockString.d.ts @@ -0,0 +1,23 @@ +/** + * Produces the value of a block string from its parsed raw value, similar to + * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. + * + * This implements the GraphQL spec's BlockStringValue() static algorithm. + * + * @internal + */ +export declare function dedentBlockStringLines(lines: ReadonlyArray): Array; +/** + * @internal + */ +export declare function isPrintableAsBlockString(value: string): boolean; +/** + * Print a block string in the indented block form by adding a leading and + * trailing blank line. However, if a block string starts with whitespace and is + * a single-line, adding a leading blank line would strip that whitespace. + * + * @internal + */ +export declare function printBlockString(value: string, options?: { + minimize?: boolean; +}): string; diff --git a/language/blockString.js b/language/blockString.js new file mode 100644 index 0000000000..90410cd84a --- /dev/null +++ b/language/blockString.js @@ -0,0 +1,140 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.dedentBlockStringLines = dedentBlockStringLines; +exports.isPrintableAsBlockString = isPrintableAsBlockString; +exports.printBlockString = printBlockString; +const characterClasses_js_1 = require("./characterClasses.js"); +/** + * Produces the value of a block string from its parsed raw value, similar to + * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. + * + * This implements the GraphQL spec's BlockStringValue() static algorithm. + * + * @internal + */ +function dedentBlockStringLines(lines) { + let commonIndent = Number.MAX_SAFE_INTEGER; + let firstNonEmptyLine = null; + let lastNonEmptyLine = -1; + for (let i = 0; i < lines.length; ++i) { + const line = lines[i]; + const indent = leadingWhitespace(line); + if (indent === line.length) { + continue; // skip empty lines + } + firstNonEmptyLine ??= i; + lastNonEmptyLine = i; + if (i !== 0 && indent < commonIndent) { + commonIndent = indent; + } + } + return (lines + // Remove common indentation from all lines but first. + .map((line, i) => (i === 0 ? line : line.slice(commonIndent))) + // Remove leading and trailing blank lines. + .slice(firstNonEmptyLine ?? 0, lastNonEmptyLine + 1)); +} +function leadingWhitespace(str) { + let i = 0; + while (i < str.length && (0, characterClasses_js_1.isWhiteSpace)(str.charCodeAt(i))) { + ++i; + } + return i; +} +/** + * @internal + */ +function isPrintableAsBlockString(value) { + if (value === '') { + return true; // empty string is printable + } + let isEmptyLine = true; + let hasIndent = false; + let hasCommonIndent = true; + let seenNonEmptyLine = false; + for (let i = 0; i < value.length; ++i) { + switch (value.codePointAt(i)) { + case 0x0000: + case 0x0001: + case 0x0002: + case 0x0003: + case 0x0004: + case 0x0005: + case 0x0006: + case 0x0007: + case 0x0008: + case 0x000b: + case 0x000c: + case 0x000e: + case 0x000f: + return false; // Has non-printable characters + case 0x000d: // \r + return false; // Has \r or \r\n which will be replaced as \n + case 10: // \n + if (isEmptyLine && !seenNonEmptyLine) { + return false; // Has leading new line + } + seenNonEmptyLine = true; + isEmptyLine = true; + hasIndent = false; + break; + case 9: // \t + case 32: // + hasIndent ||= isEmptyLine; + break; + default: + hasCommonIndent &&= hasIndent; + isEmptyLine = false; + } + } + if (isEmptyLine) { + return false; // Has trailing empty lines + } + if (hasCommonIndent && seenNonEmptyLine) { + return false; // Has internal indent + } + return true; +} +/** + * Print a block string in the indented block form by adding a leading and + * trailing blank line. However, if a block string starts with whitespace and is + * a single-line, adding a leading blank line would strip that whitespace. + * + * @internal + */ +function printBlockString(value, options) { + const escapedValue = value.replaceAll('"""', '\\"""'); + // Expand a block string's raw value into independent lines. + const lines = escapedValue.split(/\r\n|[\n\r]/g); + const isSingleLine = lines.length === 1; + // If common indentation is found we can fix some of those cases by adding leading new line + const forceLeadingNewLine = lines.length > 1 && + lines + .slice(1) + .every((line) => line.length === 0 || (0, characterClasses_js_1.isWhiteSpace)(line.charCodeAt(0))); + // Trailing triple quotes just looks confusing but doesn't force trailing new line + const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""'); + // Trailing quote (single or double) or slash forces trailing new line + const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes; + const hasTrailingSlash = value.endsWith('\\'); + const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash; + const printAsMultipleLines = !options?.minimize && + // add leading and trailing new lines only if it improves readability + (!isSingleLine || + value.length > 70 || + forceTrailingNewline || + forceLeadingNewLine || + hasTrailingTripleQuotes); + let result = ''; + // Format a multi-line block quote to account for leading space. + const skipLeadingNewLine = isSingleLine && (0, characterClasses_js_1.isWhiteSpace)(value.charCodeAt(0)); + if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) { + result += '\n'; + } + result += escapedValue; + if (printAsMultipleLines || forceTrailingNewline) { + result += '\n'; + } + return '"""' + result + '"""'; +} +//# sourceMappingURL=blockString.js.map \ No newline at end of file diff --git a/language/blockString.js.map b/language/blockString.js.map new file mode 100644 index 0000000000..aef6c50353 --- /dev/null +++ b/language/blockString.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blockString.js","sourceRoot":"","sources":["../../src/language/blockString.ts"],"names":[],"mappings":";;AAUA,wDA8BC;AAaD,4DA0DC;AASD,4CAgDC;AAxKD,+DAAqD;AAErD;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,KAA4B;IAE5B,IAAI,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC3C,IAAI,iBAAiB,GAAG,IAAI,CAAC;IAC7B,IAAI,gBAAgB,GAAG,CAAC,CAAC,CAAC;IAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3B,SAAS,CAAC,mBAAmB;QAC/B,CAAC;QAED,iBAAiB,KAAK,CAAC,CAAC;QACxB,gBAAgB,GAAG,CAAC,CAAC;QAErB,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,GAAG,YAAY,EAAE,CAAC;YACrC,YAAY,GAAG,MAAM,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,CACL,KAAK;QACH,sDAAsD;SACrD,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;QAC9D,2CAA2C;SAC1C,KAAK,CAAC,iBAAiB,IAAI,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,CACvD,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG,CAAC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E,MAAM,gBAAgB,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,oBAAoB,GAAG,gBAAgB,IAAI,gBAAgB,CAAC;IAElE,MAAM,oBAAoB,GACxB,CAAC,OAAO,EAAE,QAAQ;QAClB,qEAAqE;QACrE,CAAC,CAAC,YAAY;YACZ,KAAK,CAAC,MAAM,GAAG,EAAE;YACjB,oBAAoB;YACpB,mBAAmB;YACnB,uBAAuB,CAAC,CAAC;IAE7B,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,YAAY,IAAI,IAAA,kCAAY,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,IAAI,CAAC,oBAAoB,IAAI,CAAC,kBAAkB,CAAC,IAAI,mBAAmB,EAAE,CAAC;QACzE,MAAM,IAAI,IAAI,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,YAAY,CAAC;IACvB,IAAI,oBAAoB,IAAI,oBAAoB,EAAE,CAAC;QACjD,MAAM,IAAI,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAChC,CAAC","sourcesContent":["import { isWhiteSpace } from './characterClasses.js';\n\n/**\n * Produces the value of a block string from its parsed raw value, similar to\n * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.\n *\n * This implements the GraphQL spec's BlockStringValue() static algorithm.\n *\n * @internal\n */\nexport function dedentBlockStringLines(\n lines: ReadonlyArray,\n): Array {\n let commonIndent = Number.MAX_SAFE_INTEGER;\n let firstNonEmptyLine = null;\n let lastNonEmptyLine = -1;\n\n for (let i = 0; i < lines.length; ++i) {\n const line = lines[i];\n const indent = leadingWhitespace(line);\n\n if (indent === line.length) {\n continue; // skip empty lines\n }\n\n firstNonEmptyLine ??= i;\n lastNonEmptyLine = i;\n\n if (i !== 0 && indent < commonIndent) {\n commonIndent = indent;\n }\n }\n\n return (\n lines\n // Remove common indentation from all lines but first.\n .map((line, i) => (i === 0 ? line : line.slice(commonIndent)))\n // Remove leading and trailing blank lines.\n .slice(firstNonEmptyLine ?? 0, lastNonEmptyLine + 1)\n );\n}\n\nfunction leadingWhitespace(str: string): number {\n let i = 0;\n while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {\n ++i;\n }\n return i;\n}\n\n/**\n * @internal\n */\nexport function isPrintableAsBlockString(value: string): boolean {\n if (value === '') {\n return true; // empty string is printable\n }\n\n let isEmptyLine = true;\n let hasIndent = false;\n let hasCommonIndent = true;\n let seenNonEmptyLine = false;\n\n for (let i = 0; i < value.length; ++i) {\n switch (value.codePointAt(i)) {\n case 0x0000:\n case 0x0001:\n case 0x0002:\n case 0x0003:\n case 0x0004:\n case 0x0005:\n case 0x0006:\n case 0x0007:\n case 0x0008:\n case 0x000b:\n case 0x000c:\n case 0x000e:\n case 0x000f:\n return false; // Has non-printable characters\n\n case 0x000d: // \\r\n return false; // Has \\r or \\r\\n which will be replaced as \\n\n\n case 10: // \\n\n if (isEmptyLine && !seenNonEmptyLine) {\n return false; // Has leading new line\n }\n seenNonEmptyLine = true;\n\n isEmptyLine = true;\n hasIndent = false;\n break;\n case 9: // \\t\n case 32: // \n hasIndent ||= isEmptyLine;\n break;\n default:\n hasCommonIndent &&= hasIndent;\n isEmptyLine = false;\n }\n }\n\n if (isEmptyLine) {\n return false; // Has trailing empty lines\n }\n\n if (hasCommonIndent && seenNonEmptyLine) {\n return false; // Has internal indent\n }\n\n return true;\n}\n\n/**\n * Print a block string in the indented block form by adding a leading and\n * trailing blank line. However, if a block string starts with whitespace and is\n * a single-line, adding a leading blank line would strip that whitespace.\n *\n * @internal\n */\nexport function printBlockString(\n value: string,\n options?: { minimize?: boolean },\n): string {\n const escapedValue = value.replaceAll('\"\"\"', '\\\\\"\"\"');\n\n // Expand a block string's raw value into independent lines.\n const lines = escapedValue.split(/\\r\\n|[\\n\\r]/g);\n const isSingleLine = lines.length === 1;\n\n // If common indentation is found we can fix some of those cases by adding leading new line\n const forceLeadingNewLine =\n lines.length > 1 &&\n lines\n .slice(1)\n .every((line) => line.length === 0 || isWhiteSpace(line.charCodeAt(0)));\n\n // Trailing triple quotes just looks confusing but doesn't force trailing new line\n const hasTrailingTripleQuotes = escapedValue.endsWith('\\\\\"\"\"');\n\n // Trailing quote (single or double) or slash forces trailing new line\n const hasTrailingQuote = value.endsWith('\"') && !hasTrailingTripleQuotes;\n const hasTrailingSlash = value.endsWith('\\\\');\n const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash;\n\n const printAsMultipleLines =\n !options?.minimize &&\n // add leading and trailing new lines only if it improves readability\n (!isSingleLine ||\n value.length > 70 ||\n forceTrailingNewline ||\n forceLeadingNewLine ||\n hasTrailingTripleQuotes);\n\n let result = '';\n\n // Format a multi-line block quote to account for leading space.\n const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0));\n if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) {\n result += '\\n';\n }\n\n result += escapedValue;\n if (printAsMultipleLines || forceTrailingNewline) {\n result += '\\n';\n }\n\n return '\"\"\"' + result + '\"\"\"';\n}\n"]} \ No newline at end of file diff --git a/language/blockString.mjs b/language/blockString.mjs new file mode 100644 index 0000000000..fe3b050c75 --- /dev/null +++ b/language/blockString.mjs @@ -0,0 +1,135 @@ +import { isWhiteSpace } from "./characterClasses.mjs"; +/** + * Produces the value of a block string from its parsed raw value, similar to + * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. + * + * This implements the GraphQL spec's BlockStringValue() static algorithm. + * + * @internal + */ +export function dedentBlockStringLines(lines) { + let commonIndent = Number.MAX_SAFE_INTEGER; + let firstNonEmptyLine = null; + let lastNonEmptyLine = -1; + for (let i = 0; i < lines.length; ++i) { + const line = lines[i]; + const indent = leadingWhitespace(line); + if (indent === line.length) { + continue; // skip empty lines + } + firstNonEmptyLine ??= i; + lastNonEmptyLine = i; + if (i !== 0 && indent < commonIndent) { + commonIndent = indent; + } + } + return (lines + // Remove common indentation from all lines but first. + .map((line, i) => (i === 0 ? line : line.slice(commonIndent))) + // Remove leading and trailing blank lines. + .slice(firstNonEmptyLine ?? 0, lastNonEmptyLine + 1)); +} +function leadingWhitespace(str) { + let i = 0; + while (i < str.length && isWhiteSpace(str.charCodeAt(i))) { + ++i; + } + return i; +} +/** + * @internal + */ +export function isPrintableAsBlockString(value) { + if (value === '') { + return true; // empty string is printable + } + let isEmptyLine = true; + let hasIndent = false; + let hasCommonIndent = true; + let seenNonEmptyLine = false; + for (let i = 0; i < value.length; ++i) { + switch (value.codePointAt(i)) { + case 0x0000: + case 0x0001: + case 0x0002: + case 0x0003: + case 0x0004: + case 0x0005: + case 0x0006: + case 0x0007: + case 0x0008: + case 0x000b: + case 0x000c: + case 0x000e: + case 0x000f: + return false; // Has non-printable characters + case 0x000d: // \r + return false; // Has \r or \r\n which will be replaced as \n + case 10: // \n + if (isEmptyLine && !seenNonEmptyLine) { + return false; // Has leading new line + } + seenNonEmptyLine = true; + isEmptyLine = true; + hasIndent = false; + break; + case 9: // \t + case 32: // + hasIndent ||= isEmptyLine; + break; + default: + hasCommonIndent &&= hasIndent; + isEmptyLine = false; + } + } + if (isEmptyLine) { + return false; // Has trailing empty lines + } + if (hasCommonIndent && seenNonEmptyLine) { + return false; // Has internal indent + } + return true; +} +/** + * Print a block string in the indented block form by adding a leading and + * trailing blank line. However, if a block string starts with whitespace and is + * a single-line, adding a leading blank line would strip that whitespace. + * + * @internal + */ +export function printBlockString(value, options) { + const escapedValue = value.replaceAll('"""', '\\"""'); + // Expand a block string's raw value into independent lines. + const lines = escapedValue.split(/\r\n|[\n\r]/g); + const isSingleLine = lines.length === 1; + // If common indentation is found we can fix some of those cases by adding leading new line + const forceLeadingNewLine = lines.length > 1 && + lines + .slice(1) + .every((line) => line.length === 0 || isWhiteSpace(line.charCodeAt(0))); + // Trailing triple quotes just looks confusing but doesn't force trailing new line + const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""'); + // Trailing quote (single or double) or slash forces trailing new line + const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes; + const hasTrailingSlash = value.endsWith('\\'); + const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash; + const printAsMultipleLines = !options?.minimize && + // add leading and trailing new lines only if it improves readability + (!isSingleLine || + value.length > 70 || + forceTrailingNewline || + forceLeadingNewLine || + hasTrailingTripleQuotes); + let result = ''; + // Format a multi-line block quote to account for leading space. + const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0)); + if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) { + result += '\n'; + } + result += escapedValue; + if (printAsMultipleLines || forceTrailingNewline) { + result += '\n'; + } + return '"""' + result + '"""'; +} +//# sourceMappingURL=blockString.js.map \ No newline at end of file diff --git a/language/blockString.mjs.map b/language/blockString.mjs.map new file mode 100644 index 0000000000..efefaa99dc --- /dev/null +++ b/language/blockString.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"blockString.js","sourceRoot":"","sources":["../../src/language/blockString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,+BAA8B;AAErD;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAA4B;IAE5B,IAAI,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC3C,IAAI,iBAAiB,GAAG,IAAI,CAAC;IAC7B,IAAI,gBAAgB,GAAG,CAAC,CAAC,CAAC;IAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3B,SAAS,CAAC,mBAAmB;QAC/B,CAA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I,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAChC,CAAC","sourcesContent":["import { isWhiteSpace } from './characterClasses.js';\n\n/**\n * Produces the value of a block string from its parsed raw value, similar to\n * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.\n *\n * This implements the GraphQL spec's BlockStringValue() static algorithm.\n *\n * @internal\n */\nexport function dedentBlockStringLines(\n lines: ReadonlyArray,\n): Array {\n let commonIndent = Number.MAX_SAFE_INTEGER;\n let firstNonEmptyLine = null;\n let lastNonEmptyLine = -1;\n\n for (let i = 0; i < lines.length; ++i) {\n const line = lines[i];\n const indent = leadingWhitespace(line);\n\n if (indent === line.length) {\n continue; // skip empty lines\n }\n\n firstNonEmptyLine ??= i;\n lastNonEmptyLine = i;\n\n if (i !== 0 && indent < commonIndent) {\n commonIndent = indent;\n }\n }\n\n return (\n lines\n // Remove common indentation from all lines but first.\n .map((line, i) => (i === 0 ? line : line.slice(commonIndent)))\n // Remove leading and trailing blank lines.\n .slice(firstNonEmptyLine ?? 0, lastNonEmptyLine + 1)\n );\n}\n\nfunction leadingWhitespace(str: string): number {\n let i = 0;\n while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {\n ++i;\n }\n return i;\n}\n\n/**\n * @internal\n */\nexport function isPrintableAsBlockString(value: string): boolean {\n if (value === '') {\n return true; // empty string is printable\n }\n\n let isEmptyLine = true;\n let hasIndent = false;\n let hasCommonIndent = true;\n let seenNonEmptyLine = false;\n\n for (let i = 0; i < value.length; ++i) {\n switch (value.codePointAt(i)) {\n case 0x0000:\n case 0x0001:\n case 0x0002:\n case 0x0003:\n case 0x0004:\n case 0x0005:\n case 0x0006:\n case 0x0007:\n case 0x0008:\n case 0x000b:\n case 0x000c:\n case 0x000e:\n case 0x000f:\n return false; // Has non-printable characters\n\n case 0x000d: // \\r\n return false; // Has \\r or \\r\\n which will be replaced as \\n\n\n case 10: // \\n\n if (isEmptyLine && !seenNonEmptyLine) {\n return false; // Has leading new line\n }\n seenNonEmptyLine = true;\n\n isEmptyLine = true;\n hasIndent = false;\n break;\n case 9: // \\t\n case 32: // \n hasIndent ||= isEmptyLine;\n break;\n default:\n hasCommonIndent &&= hasIndent;\n isEmptyLine = false;\n }\n }\n\n if (isEmptyLine) {\n return false; // Has trailing empty lines\n }\n\n if (hasCommonIndent && seenNonEmptyLine) {\n return false; // Has internal indent\n }\n\n return true;\n}\n\n/**\n * Print a block string in the indented block form by adding a leading and\n * trailing blank line. However, if a block string starts with whitespace and is\n * a single-line, adding a leading blank line would strip that whitespace.\n *\n * @internal\n */\nexport function printBlockString(\n value: string,\n options?: { minimize?: boolean },\n): string {\n const escapedValue = value.replaceAll('\"\"\"', '\\\\\"\"\"');\n\n // Expand a block string's raw value into independent lines.\n const lines = escapedValue.split(/\\r\\n|[\\n\\r]/g);\n const isSingleLine = lines.length === 1;\n\n // If common indentation is found we can fix some of those cases by adding leading new line\n const forceLeadingNewLine =\n lines.length > 1 &&\n lines\n .slice(1)\n .every((line) => line.length === 0 || isWhiteSpace(line.charCodeAt(0)));\n\n // Trailing triple quotes just looks confusing but doesn't force trailing new line\n const hasTrailingTripleQuotes = escapedValue.endsWith('\\\\\"\"\"');\n\n // Trailing quote (single or double) or slash forces trailing new line\n const hasTrailingQuote = value.endsWith('\"') && !hasTrailingTripleQuotes;\n const hasTrailingSlash = value.endsWith('\\\\');\n const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash;\n\n const printAsMultipleLines =\n !options?.minimize &&\n // add leading and trailing new lines only if it improves readability\n (!isSingleLine ||\n value.length > 70 ||\n forceTrailingNewline ||\n forceLeadingNewLine ||\n hasTrailingTripleQuotes);\n\n let result = '';\n\n // Format a multi-line block quote to account for leading space.\n const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0));\n if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) {\n result += '\\n';\n }\n\n result += escapedValue;\n if (printAsMultipleLines || forceTrailingNewline) {\n result += '\\n';\n }\n\n return '\"\"\"' + result + '\"\"\"';\n}\n"]} \ No newline at end of file diff --git a/language/characterClasses.d.ts b/language/characterClasses.d.ts new file mode 100644 index 0000000000..1e5da8ae52 --- /dev/null +++ b/language/characterClasses.d.ts @@ -0,0 +1,47 @@ +/** + * ``` + * WhiteSpace :: + * - "Horizontal Tab (U+0009)" + * - "Space (U+0020)" + * ``` + * @internal + */ +export declare function isWhiteSpace(code: number): boolean; +/** + * ``` + * Digit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * ``` + * @internal + */ +export declare function isDigit(code: number): boolean; +/** + * ``` + * Letter :: one of + * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M` + * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z` + * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m` + * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z` + * ``` + * @internal + */ +export declare function isLetter(code: number): boolean; +/** + * ``` + * NameStart :: + * - Letter + * - `_` + * ``` + * @internal + */ +export declare function isNameStart(code: number): boolean; +/** + * ``` + * NameContinue :: + * - Letter + * - Digit + * - `_` + * ``` + * @internal + */ +export declare function isNameContinue(code: number): boolean; diff --git a/language/characterClasses.js b/language/characterClasses.js new file mode 100644 index 0000000000..e009c2a38f --- /dev/null +++ b/language/characterClasses.js @@ -0,0 +1,67 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isWhiteSpace = isWhiteSpace; +exports.isDigit = isDigit; +exports.isLetter = isLetter; +exports.isNameStart = isNameStart; +exports.isNameContinue = isNameContinue; +/** + * ``` + * WhiteSpace :: + * - "Horizontal Tab (U+0009)" + * - "Space (U+0020)" + * ``` + * @internal + */ +function isWhiteSpace(code) { + return code === 0x0009 || code === 0x0020; +} +/** + * ``` + * Digit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * ``` + * @internal + */ +function isDigit(code) { + return code >= 0x0030 && code <= 0x0039; +} +/** + * ``` + * Letter :: one of + * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M` + * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z` + * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m` + * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z` + * ``` + * @internal + */ +function isLetter(code) { + return ((code >= 0x0061 && code <= 0x007a) || // A-Z + (code >= 0x0041 && code <= 0x005a) // a-z + ); +} +/** + * ``` + * NameStart :: + * - Letter + * - `_` + * ``` + * @internal + */ +function isNameStart(code) { + return isLetter(code) || code === 0x005f; +} +/** + * ``` + * NameContinue :: + * - Letter + * - Digit + * - `_` + * ``` + * @internal + */ +function isNameContinue(code) { + return isLetter(code) || isDigit(code) || code === 0x005f; +} +//# sourceMappingURL=characterClasses.js.map \ No newline at end of file diff --git a/language/characterClasses.js.map b/language/characterClasses.js.map new file mode 100644 index 0000000000..46283850e8 --- /dev/null +++ b/language/characterClasses.js.map @@ -0,0 +1 @@ +{"version":3,"file":"characterClasses.js","sourceRoot":"","sources":["../../src/language/characterClasses.ts"],"names":[],"mappings":";;AAQA,oCAEC;AASD,0BAEC;AAYD,4BAKC;AAUD,kCAEC;AAWD,wCAEC;AA/DD;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;AAC1C,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,CACL,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,MAAM;QAC5C,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC,MAAM;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,IAAY;IACtC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * ```\n * WhiteSpace ::\n * - \"Horizontal Tab (U+0009)\"\n * - \"Space (U+0020)\"\n * ```\n * @internal\n */\nexport function isWhiteSpace(code: number): boolean {\n return code === 0x0009 || code === 0x0020;\n}\n\n/**\n * ```\n * Digit :: one of\n * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`\n * ```\n * @internal\n */\nexport function isDigit(code: number): boolean {\n return code >= 0x0030 && code <= 0x0039;\n}\n\n/**\n * ```\n * Letter :: one of\n * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`\n * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`\n * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`\n * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`\n * ```\n * @internal\n */\nexport function isLetter(code: number): boolean {\n return (\n (code >= 0x0061 && code <= 0x007a) || // A-Z\n (code >= 0x0041 && code <= 0x005a) // a-z\n );\n}\n\n/**\n * ```\n * NameStart ::\n * - Letter\n * - `_`\n * ```\n * @internal\n */\nexport function isNameStart(code: number): boolean {\n return isLetter(code) || code === 0x005f;\n}\n\n/**\n * ```\n * NameContinue ::\n * - Letter\n * - Digit\n * - `_`\n * ```\n * @internal\n */\nexport function isNameContinue(code: number): boolean {\n return isLetter(code) || isDigit(code) || code === 0x005f;\n}\n"]} \ No newline at end of file diff --git a/language/characterClasses.mjs b/language/characterClasses.mjs new file mode 100644 index 0000000000..476389f98f --- /dev/null +++ b/language/characterClasses.mjs @@ -0,0 +1,60 @@ +/** + * ``` + * WhiteSpace :: + * - "Horizontal Tab (U+0009)" + * - "Space (U+0020)" + * ``` + * @internal + */ +export function isWhiteSpace(code) { + return code === 0x0009 || code === 0x0020; +} +/** + * ``` + * Digit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * ``` + * @internal + */ +export function isDigit(code) { + return code >= 0x0030 && code <= 0x0039; +} +/** + * ``` + * Letter :: one of + * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M` + * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z` + * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m` + * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z` + * ``` + * @internal + */ +export function isLetter(code) { + return ((code >= 0x0061 && code <= 0x007a) || // A-Z + (code >= 0x0041 && code <= 0x005a) // a-z + ); +} +/** + * ``` + * NameStart :: + * - Letter + * - `_` + * ``` + * @internal + */ +export function isNameStart(code) { + return isLetter(code) || code === 0x005f; +} +/** + * ``` + * NameContinue :: + * - Letter + * - Digit + * - `_` + * ``` + * @internal + */ +export function isNameContinue(code) { + return isLetter(code) || isDigit(code) || code === 0x005f; +} +//# sourceMappingURL=characterClasses.js.map \ No newline at end of file diff --git a/language/characterClasses.mjs.map b/language/characterClasses.mjs.map new file mode 100644 index 0000000000..64a60784e2 --- /dev/null +++ b/language/characterClasses.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"characterClasses.js","sourceRoot":"","sources":["../../src/language/characterClasses.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;AAC1C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,CACL,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,MAAM;QAC5C,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC,MAAM;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * ```\n * WhiteSpace ::\n * - \"Horizontal Tab (U+0009)\"\n * - \"Space (U+0020)\"\n * ```\n * @internal\n */\nexport function isWhiteSpace(code: number): boolean {\n return code === 0x0009 || code === 0x0020;\n}\n\n/**\n * ```\n * Digit :: one of\n * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`\n * ```\n * @internal\n */\nexport function isDigit(code: number): boolean {\n return code >= 0x0030 && code <= 0x0039;\n}\n\n/**\n * ```\n * Letter :: one of\n * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`\n * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`\n * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`\n * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`\n * ```\n * @internal\n */\nexport function isLetter(code: number): boolean {\n return (\n (code >= 0x0061 && code <= 0x007a) || // A-Z\n (code >= 0x0041 && code <= 0x005a) // a-z\n );\n}\n\n/**\n * ```\n * NameStart ::\n * - Letter\n * - `_`\n * ```\n * @internal\n */\nexport function isNameStart(code: number): boolean {\n return isLetter(code) || code === 0x005f;\n}\n\n/**\n * ```\n * NameContinue ::\n * - Letter\n * - Digit\n * - `_`\n * ```\n * @internal\n */\nexport function isNameContinue(code: number): boolean {\n return isLetter(code) || isDigit(code) || code === 0x005f;\n}\n"]} \ No newline at end of file diff --git a/language/directiveLocation.d.ts b/language/directiveLocation.d.ts new file mode 100644 index 0000000000..23db94407f --- /dev/null +++ b/language/directiveLocation.d.ts @@ -0,0 +1,28 @@ +/** + * The set of allowed directive location values. + */ +export declare const DirectiveLocation: { + /** Request Definitions */ + readonly QUERY: "QUERY"; + readonly MUTATION: "MUTATION"; + readonly SUBSCRIPTION: "SUBSCRIPTION"; + readonly FIELD: "FIELD"; + readonly FRAGMENT_DEFINITION: "FRAGMENT_DEFINITION"; + readonly FRAGMENT_SPREAD: "FRAGMENT_SPREAD"; + readonly INLINE_FRAGMENT: "INLINE_FRAGMENT"; + readonly VARIABLE_DEFINITION: "VARIABLE_DEFINITION"; + /** Type System Definitions */ + readonly SCHEMA: "SCHEMA"; + readonly SCALAR: "SCALAR"; + readonly OBJECT: "OBJECT"; + readonly FIELD_DEFINITION: "FIELD_DEFINITION"; + readonly ARGUMENT_DEFINITION: "ARGUMENT_DEFINITION"; + readonly INTERFACE: "INTERFACE"; + readonly UNION: "UNION"; + readonly ENUM: "ENUM"; + readonly ENUM_VALUE: "ENUM_VALUE"; + readonly INPUT_OBJECT: "INPUT_OBJECT"; + readonly INPUT_FIELD_DEFINITION: "INPUT_FIELD_DEFINITION"; + readonly FRAGMENT_VARIABLE_DEFINITION: "FRAGMENT_VARIABLE_DEFINITION"; +}; +export type DirectiveLocation = (typeof DirectiveLocation)[keyof typeof DirectiveLocation]; diff --git a/language/directiveLocation.js b/language/directiveLocation.js new file mode 100644 index 0000000000..d3ce6855e9 --- /dev/null +++ b/language/directiveLocation.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DirectiveLocation = void 0; +/** + * The set of allowed directive location values. + */ +exports.DirectiveLocation = { + /** Request Definitions */ + QUERY: 'QUERY', + MUTATION: 'MUTATION', + SUBSCRIPTION: 'SUBSCRIPTION', + FIELD: 'FIELD', + FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION', + FRAGMENT_SPREAD: 'FRAGMENT_SPREAD', + INLINE_FRAGMENT: 'INLINE_FRAGMENT', + VARIABLE_DEFINITION: 'VARIABLE_DEFINITION', + /** Type System Definitions */ + SCHEMA: 'SCHEMA', + SCALAR: 'SCALAR', + OBJECT: 'OBJECT', + FIELD_DEFINITION: 'FIELD_DEFINITION', + ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION', + INTERFACE: 'INTERFACE', + UNION: 'UNION', + ENUM: 'ENUM', + ENUM_VALUE: 'ENUM_VALUE', + INPUT_OBJECT: 'INPUT_OBJECT', + INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION', + FRAGMENT_VARIABLE_DEFINITION: 'FRAGMENT_VARIABLE_DEFINITION', +}; +//# sourceMappingURL=directiveLocation.js.map \ No newline at end of file diff --git a/language/directiveLocation.js.map b/language/directiveLocation.js.map new file mode 100644 index 0000000000..60852ecac8 --- /dev/null +++ b/language/directiveLocation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"directiveLocation.js","sourceRoot":"","sources":["../../src/language/directiveLocation.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,0BAA0B;IAC1B,KAAK,EAAE,OAAgB;IACvB,QAAQ,EAAE,UAAmB;IAC7B,YAAY,EAAE,cAAuB;IACrC,KAAK,EAAE,OAAgB;IACvB,mBAAmB,EAAE,qBAA8B;IACnD,eAAe,EAAE,iBAA0B;IAC3C,eAAe,EAAE,iBAA0B;IAC3C,mBAAmB,EAAE,qBAA8B;IACnD,8BAA8B;IAC9B,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,gBAAgB,EAAE,kBAA2B;IAC7C,mBAAmB,EAAE,qBAA8B;IACnD,SAAS,EAAE,WAAoB;IAC/B,KAAK,EAAE,OAAgB;IACvB,IAAI,EAAE,MAAe;IACrB,UAAU,EAAE,YAAqB;IACjC,YAAY,EAAE,cAAuB;IACrC,sBAAsB,EAAE,wBAAiC;IACzD,4BAA4B,EAAE,8BAAuC;CAC7D,CAAC","sourcesContent":["/**\n * The set of allowed directive location values.\n */\nexport const DirectiveLocation = {\n /** Request Definitions */\n QUERY: 'QUERY' as const,\n MUTATION: 'MUTATION' as const,\n SUBSCRIPTION: 'SUBSCRIPTION' as const,\n FIELD: 'FIELD' as const,\n FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION' as const,\n FRAGMENT_SPREAD: 'FRAGMENT_SPREAD' as const,\n INLINE_FRAGMENT: 'INLINE_FRAGMENT' as const,\n VARIABLE_DEFINITION: 'VARIABLE_DEFINITION' as const,\n /** Type System Definitions */\n SCHEMA: 'SCHEMA' as const,\n SCALAR: 'SCALAR' as const,\n OBJECT: 'OBJECT' as const,\n FIELD_DEFINITION: 'FIELD_DEFINITION' as const,\n ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION' as const,\n INTERFACE: 'INTERFACE' as const,\n UNION: 'UNION' as const,\n ENUM: 'ENUM' as const,\n ENUM_VALUE: 'ENUM_VALUE' as const,\n INPUT_OBJECT: 'INPUT_OBJECT' as const,\n INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION' as const,\n FRAGMENT_VARIABLE_DEFINITION: 'FRAGMENT_VARIABLE_DEFINITION' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type DirectiveLocation =\n (typeof DirectiveLocation)[keyof typeof DirectiveLocation];\n"]} \ No newline at end of file diff --git a/language/directiveLocation.mjs b/language/directiveLocation.mjs new file mode 100644 index 0000000000..9165318da9 --- /dev/null +++ b/language/directiveLocation.mjs @@ -0,0 +1,28 @@ +/** + * The set of allowed directive location values. + */ +export const DirectiveLocation = { + /** Request Definitions */ + QUERY: 'QUERY', + MUTATION: 'MUTATION', + SUBSCRIPTION: 'SUBSCRIPTION', + FIELD: 'FIELD', + FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION', + FRAGMENT_SPREAD: 'FRAGMENT_SPREAD', + INLINE_FRAGMENT: 'INLINE_FRAGMENT', + VARIABLE_DEFINITION: 'VARIABLE_DEFINITION', + /** Type System Definitions */ + SCHEMA: 'SCHEMA', + SCALAR: 'SCALAR', + OBJECT: 'OBJECT', + FIELD_DEFINITION: 'FIELD_DEFINITION', + ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION', + INTERFACE: 'INTERFACE', + UNION: 'UNION', + ENUM: 'ENUM', + ENUM_VALUE: 'ENUM_VALUE', + INPUT_OBJECT: 'INPUT_OBJECT', + INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION', + FRAGMENT_VARIABLE_DEFINITION: 'FRAGMENT_VARIABLE_DEFINITION', +}; +//# sourceMappingURL=directiveLocation.js.map \ No newline at end of file diff --git a/language/directiveLocation.mjs.map b/language/directiveLocation.mjs.map new file mode 100644 index 0000000000..d5cfe30618 --- /dev/null +++ b/language/directiveLocation.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"directiveLocation.js","sourceRoot":"","sources":["../../src/language/directiveLocation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,0BAA0B;IAC1B,KAAK,EAAE,OAAgB;IACvB,QAAQ,EAAE,UAAmB;IAC7B,YAAY,EAAE,cAAuB;IACrC,KAAK,EAAE,OAAgB;IACvB,mBAAmB,EAAE,qBAA8B;IACnD,eAAe,EAAE,iBAA0B;IAC3C,eAAe,EAAE,iBAA0B;IAC3C,mBAAmB,EAAE,qBAA8B;IACnD,8BAA8B;IAC9B,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,gBAAgB,EAAE,kBAA2B;IAC7C,mBAAmB,EAAE,qBAA8B;IACnD,SAAS,EAAE,WAAoB;IAC/B,KAAK,EAAE,OAAgB;IACvB,IAAI,EAAE,MAAe;IACrB,UAAU,EAAE,YAAqB;IACjC,YAAY,EAAE,cAAuB;IACrC,sBAAsB,EAAE,wBAAiC;IACzD,4BAA4B,EAAE,8BAAuC;CAC7D,CAAC","sourcesContent":["/**\n * The set of allowed directive location values.\n */\nexport const DirectiveLocation = {\n /** Request Definitions */\n QUERY: 'QUERY' as const,\n MUTATION: 'MUTATION' as const,\n SUBSCRIPTION: 'SUBSCRIPTION' as const,\n FIELD: 'FIELD' as const,\n FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION' as const,\n FRAGMENT_SPREAD: 'FRAGMENT_SPREAD' as const,\n INLINE_FRAGMENT: 'INLINE_FRAGMENT' as const,\n VARIABLE_DEFINITION: 'VARIABLE_DEFINITION' as const,\n /** Type System Definitions */\n SCHEMA: 'SCHEMA' as const,\n SCALAR: 'SCALAR' as const,\n OBJECT: 'OBJECT' as const,\n FIELD_DEFINITION: 'FIELD_DEFINITION' as const,\n ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION' as const,\n INTERFACE: 'INTERFACE' as const,\n UNION: 'UNION' as const,\n ENUM: 'ENUM' as const,\n ENUM_VALUE: 'ENUM_VALUE' as const,\n INPUT_OBJECT: 'INPUT_OBJECT' as const,\n INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION' as const,\n FRAGMENT_VARIABLE_DEFINITION: 'FRAGMENT_VARIABLE_DEFINITION' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type DirectiveLocation =\n (typeof DirectiveLocation)[keyof typeof DirectiveLocation];\n"]} \ No newline at end of file diff --git a/language/index.d.ts b/language/index.d.ts new file mode 100644 index 0000000000..4172639cdf --- /dev/null +++ b/language/index.d.ts @@ -0,0 +1,16 @@ +export { Source } from './source.js'; +export { getLocation } from './location.js'; +export type { SourceLocation } from './location.js'; +export { printLocation, printSourceLocation } from './printLocation.js'; +export { Kind } from './kinds.js'; +export { TokenKind } from './tokenKind.js'; +export { Lexer } from './lexer.js'; +export { parse, parseValue, parseConstValue, parseType } from './parser.js'; +export type { ParseOptions } from './parser.js'; +export { print } from './printer.js'; +export { visit, visitInParallel, getEnterLeaveForKind, BREAK, } from './visitor.js'; +export type { ASTVisitor, ASTVisitFn, ASTVisitorKeyMap } from './visitor.js'; +export { Location, Token, OperationTypeNode } from './ast.js'; +export type { ASTNode, ASTKindToNode, NameNode, DocumentNode, DefinitionNode, ExecutableDefinitionNode, OperationDefinitionNode, VariableDefinitionNode, VariableNode, SelectionSetNode, SelectionNode, FieldNode, ArgumentNode, FragmentArgumentNode, ConstArgumentNode, FragmentSpreadNode, InlineFragmentNode, FragmentDefinitionNode, ValueNode, ConstValueNode, IntValueNode, FloatValueNode, StringValueNode, BooleanValueNode, NullValueNode, EnumValueNode, ListValueNode, ConstListValueNode, ObjectValueNode, ConstObjectValueNode, ObjectFieldNode, ConstObjectFieldNode, DirectiveNode, ConstDirectiveNode, TypeNode, NamedTypeNode, ListTypeNode, NonNullTypeNode, TypeSystemDefinitionNode, SchemaDefinitionNode, OperationTypeDefinitionNode, TypeDefinitionNode, ScalarTypeDefinitionNode, ObjectTypeDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, UnionTypeDefinitionNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, InputObjectTypeDefinitionNode, DirectiveDefinitionNode, TypeSystemExtensionNode, SchemaExtensionNode, TypeExtensionNode, ScalarTypeExtensionNode, ObjectTypeExtensionNode, InterfaceTypeExtensionNode, UnionTypeExtensionNode, EnumTypeExtensionNode, InputObjectTypeExtensionNode, } from './ast.js'; +export { isDefinitionNode, isExecutableDefinitionNode, isSelectionNode, isValueNode, isConstValueNode, isTypeNode, isTypeSystemDefinitionNode, isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode, } from './predicates.js'; +export { DirectiveLocation } from './directiveLocation.js'; diff --git a/language/index.js b/language/index.js new file mode 100644 index 0000000000..f76761a853 --- /dev/null +++ b/language/index.js @@ -0,0 +1,48 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DirectiveLocation = exports.isTypeExtensionNode = exports.isTypeSystemExtensionNode = exports.isTypeDefinitionNode = exports.isTypeSystemDefinitionNode = exports.isTypeNode = exports.isConstValueNode = exports.isValueNode = exports.isSelectionNode = exports.isExecutableDefinitionNode = exports.isDefinitionNode = exports.OperationTypeNode = exports.Token = exports.Location = exports.BREAK = exports.getEnterLeaveForKind = exports.visitInParallel = exports.visit = exports.parseType = exports.parseConstValue = exports.parseValue = exports.parse = exports.Lexer = exports.TokenKind = exports.Kind = exports.printSourceLocation = exports.printLocation = exports.getLocation = exports.Source = void 0; +var source_js_1 = require("./source.js"); +Object.defineProperty(exports, "Source", { enumerable: true, get: function () { return source_js_1.Source; } }); +var location_js_1 = require("./location.js"); +Object.defineProperty(exports, "getLocation", { enumerable: true, get: function () { return location_js_1.getLocation; } }); +var printLocation_js_1 = require("./printLocation.js"); +Object.defineProperty(exports, "printLocation", { enumerable: true, get: function () { return printLocation_js_1.printLocation; } }); +Object.defineProperty(exports, "printSourceLocation", { enumerable: true, get: function () { return printLocation_js_1.printSourceLocation; } }); +// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313 +// eslint-disable-next-line @typescript-eslint/consistent-type-exports +var kinds_js_1 = require("./kinds.js"); +Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return kinds_js_1.Kind; } }); +var tokenKind_js_1 = require("./tokenKind.js"); +Object.defineProperty(exports, "TokenKind", { enumerable: true, get: function () { return tokenKind_js_1.TokenKind; } }); +var lexer_js_1 = require("./lexer.js"); +Object.defineProperty(exports, "Lexer", { enumerable: true, get: function () { return lexer_js_1.Lexer; } }); +var parser_js_1 = require("./parser.js"); +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_js_1.parse; } }); +Object.defineProperty(exports, "parseValue", { enumerable: true, get: function () { return parser_js_1.parseValue; } }); +Object.defineProperty(exports, "parseConstValue", { enumerable: true, get: function () { return parser_js_1.parseConstValue; } }); +Object.defineProperty(exports, "parseType", { enumerable: true, get: function () { return parser_js_1.parseType; } }); +var printer_js_1 = require("./printer.js"); +Object.defineProperty(exports, "print", { enumerable: true, get: function () { return printer_js_1.print; } }); +var visitor_js_1 = require("./visitor.js"); +Object.defineProperty(exports, "visit", { enumerable: true, get: function () { return visitor_js_1.visit; } }); +Object.defineProperty(exports, "visitInParallel", { enumerable: true, get: function () { return visitor_js_1.visitInParallel; } }); +Object.defineProperty(exports, "getEnterLeaveForKind", { enumerable: true, get: function () { return visitor_js_1.getEnterLeaveForKind; } }); +Object.defineProperty(exports, "BREAK", { enumerable: true, get: function () { return visitor_js_1.BREAK; } }); +var ast_js_1 = require("./ast.js"); +Object.defineProperty(exports, "Location", { enumerable: true, get: function () { return ast_js_1.Location; } }); +Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return ast_js_1.Token; } }); +Object.defineProperty(exports, "OperationTypeNode", { enumerable: true, get: function () { return ast_js_1.OperationTypeNode; } }); +var predicates_js_1 = require("./predicates.js"); +Object.defineProperty(exports, "isDefinitionNode", { enumerable: true, get: function () { return predicates_js_1.isDefinitionNode; } }); +Object.defineProperty(exports, "isExecutableDefinitionNode", { enumerable: true, get: function () { return predicates_js_1.isExecutableDefinitionNode; } }); +Object.defineProperty(exports, "isSelectionNode", { enumerable: true, get: function () { return predicates_js_1.isSelectionNode; } }); +Object.defineProperty(exports, "isValueNode", { enumerable: true, get: function () { return predicates_js_1.isValueNode; } }); +Object.defineProperty(exports, "isConstValueNode", { enumerable: true, get: function () { return predicates_js_1.isConstValueNode; } }); +Object.defineProperty(exports, "isTypeNode", { enumerable: true, get: function () { return predicates_js_1.isTypeNode; } }); +Object.defineProperty(exports, "isTypeSystemDefinitionNode", { enumerable: true, get: function () { return predicates_js_1.isTypeSystemDefinitionNode; } }); +Object.defineProperty(exports, "isTypeDefinitionNode", { enumerable: true, get: function () { return predicates_js_1.isTypeDefinitionNode; } }); +Object.defineProperty(exports, "isTypeSystemExtensionNode", { enumerable: true, get: function () { return predicates_js_1.isTypeSystemExtensionNode; } }); +Object.defineProperty(exports, "isTypeExtensionNode", { enumerable: true, get: function () { return predicates_js_1.isTypeExtensionNode; } }); +var directiveLocation_js_1 = require("./directiveLocation.js"); +Object.defineProperty(exports, "DirectiveLocation", { enumerable: true, get: function () { return directiveLocation_js_1.DirectiveLocation; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/language/index.js.map b/language/index.js.map new file mode 100644 index 0000000000..dfde57d2c1 --- /dev/null +++ b/language/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/language/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AAEf,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AAGpB,uDAAwE;AAA/D,iHAAA,aAAa,OAAA;AAAE,uHAAA,mBAAmB,OAAA;AAE3C,2EAA2E;AAC3E,sEAAsE;AACtE,uCAAkC;AAAzB,gGAAA,IAAI,OAAA;AAEb,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAElB,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AAEd,yCAA4E;AAAnE,kGAAA,KAAK,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,sGAAA,SAAS,OAAA;AAGtD,2CAAqC;AAA5B,mGAAA,KAAK,OAAA;AAEd,2CAKsB;AAJpB,mGAAA,KAAK,OAAA;AACL,6GAAA,eAAe,OAAA;AACf,kHAAA,oBAAoB,OAAA;AACpB,mGAAA,KAAK,OAAA;AAIP,mCAA8D;AAArD,kGAAA,QAAQ,OAAA;AAAE,+FAAA,KAAK,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAkE3C,iDAWyB;AAVvB,iHAAA,gBAAgB,OAAA;AAChB,2HAAA,0BAA0B,OAAA;AAC1B,gHAAA,eAAe,OAAA;AACf,4GAAA,WAAW,OAAA;AACX,iHAAA,gBAAgB,OAAA;AAChB,2GAAA,UAAU,OAAA;AACV,2HAAA,0BAA0B,OAAA;AAC1B,qHAAA,oBAAoB,OAAA;AACpB,0HAAA,yBAAyB,OAAA;AACzB,oHAAA,mBAAmB,OAAA;AAGrB,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA","sourcesContent":["export { Source } from './source.js';\n\nexport { getLocation } from './location.js';\nexport type { SourceLocation } from './location.js';\n\nexport { printLocation, printSourceLocation } from './printLocation.js';\n\n// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313\n// eslint-disable-next-line @typescript-eslint/consistent-type-exports\nexport { Kind } from './kinds.js';\n\nexport { TokenKind } from './tokenKind.js';\n\nexport { Lexer } from './lexer.js';\n\nexport { parse, parseValue, parseConstValue, parseType } from './parser.js';\nexport type { ParseOptions } from './parser.js';\n\nexport { print } from './printer.js';\n\nexport {\n visit,\n visitInParallel,\n getEnterLeaveForKind,\n BREAK,\n} from './visitor.js';\nexport type { ASTVisitor, ASTVisitFn, ASTVisitorKeyMap } from './visitor.js';\n\nexport { Location, Token, OperationTypeNode } from './ast.js';\nexport type {\n ASTNode,\n ASTKindToNode,\n // Each kind of AST node\n NameNode,\n DocumentNode,\n DefinitionNode,\n ExecutableDefinitionNode,\n OperationDefinitionNode,\n VariableDefinitionNode,\n VariableNode,\n SelectionSetNode,\n SelectionNode,\n FieldNode,\n ArgumentNode,\n FragmentArgumentNode /* for experimental fragment arguments */,\n ConstArgumentNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n FragmentDefinitionNode,\n ValueNode,\n ConstValueNode,\n IntValueNode,\n FloatValueNode,\n StringValueNode,\n BooleanValueNode,\n NullValueNode,\n EnumValueNode,\n ListValueNode,\n ConstListValueNode,\n ObjectValueNode,\n ConstObjectValueNode,\n ObjectFieldNode,\n ConstObjectFieldNode,\n DirectiveNode,\n ConstDirectiveNode,\n TypeNode,\n NamedTypeNode,\n ListTypeNode,\n NonNullTypeNode,\n TypeSystemDefinitionNode,\n SchemaDefinitionNode,\n OperationTypeDefinitionNode,\n TypeDefinitionNode,\n ScalarTypeDefinitionNode,\n ObjectTypeDefinitionNode,\n FieldDefinitionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n UnionTypeDefinitionNode,\n EnumTypeDefinitionNode,\n EnumValueDefinitionNode,\n InputObjectTypeDefinitionNode,\n DirectiveDefinitionNode,\n TypeSystemExtensionNode,\n SchemaExtensionNode,\n TypeExtensionNode,\n ScalarTypeExtensionNode,\n ObjectTypeExtensionNode,\n InterfaceTypeExtensionNode,\n UnionTypeExtensionNode,\n EnumTypeExtensionNode,\n InputObjectTypeExtensionNode,\n} from './ast.js';\n\nexport {\n isDefinitionNode,\n isExecutableDefinitionNode,\n isSelectionNode,\n isValueNode,\n isConstValueNode,\n isTypeNode,\n isTypeSystemDefinitionNode,\n isTypeDefinitionNode,\n isTypeSystemExtensionNode,\n isTypeExtensionNode,\n} from './predicates.js';\n\nexport { DirectiveLocation } from './directiveLocation.js';\n"]} \ No newline at end of file diff --git a/language/index.mjs b/language/index.mjs new file mode 100644 index 0000000000..8332dc3dab --- /dev/null +++ b/language/index.mjs @@ -0,0 +1,15 @@ +export { Source } from "./source.mjs"; +export { getLocation } from "./location.mjs"; +export { printLocation, printSourceLocation } from "./printLocation.mjs"; +// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313 +// eslint-disable-next-line @typescript-eslint/consistent-type-exports +export { Kind } from "./kinds.mjs"; +export { TokenKind } from "./tokenKind.mjs"; +export { Lexer } from "./lexer.mjs"; +export { parse, parseValue, parseConstValue, parseType } from "./parser.mjs"; +export { print } from "./printer.mjs"; +export { visit, visitInParallel, getEnterLeaveForKind, BREAK, } from "./visitor.mjs"; +export { Location, Token, OperationTypeNode } from "./ast.mjs"; +export { isDefinitionNode, isExecutableDefinitionNode, isSelectionNode, isValueNode, isConstValueNode, isTypeNode, isTypeSystemDefinitionNode, isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode, } from "./predicates.mjs"; +export { DirectiveLocation } from "./directiveLocation.mjs"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/language/index.mjs.map b/language/index.mjs.map new file mode 100644 index 0000000000..b50e22b99e --- /dev/null +++ b/language/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/language/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,qBAAoB;AAErC,OAAO,EAAE,WAAW,EAAE,uBAAsB;AAG5C,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,4BAA2B;AAExE,2EAA2E;AAC3E,sEAAsE;AACtE,OAAO,EAAE,IAAI,EAAE,oBAAmB;AAElC,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAE3C,OAAO,EAAE,KAAK,EAAE,oBAAmB;AAEnC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,qBAAoB;AAG5E,OAAO,EAAE,KAAK,EAAE,sBAAqB;AAErC,OAAO,EACL,KAAK,EACL,eAAe,EACf,oBAAoB,EACpB,KAAK,GACN,sBAAqB;AAGtB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,iBAAiB,EAAE,kBAAiB;AAkE9D,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,GACpB,yBAAwB;AAEzB,OAAO,EAAE,iBAAiB,EAAE,gCAA+B","sourcesContent":["export { Source } from './source.js';\n\nexport { getLocation } from './location.js';\nexport type { SourceLocation } from './location.js';\n\nexport { printLocation, printSourceLocation } from './printLocation.js';\n\n// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313\n// eslint-disable-next-line @typescript-eslint/consistent-type-exports\nexport { Kind } from './kinds.js';\n\nexport { TokenKind } from './tokenKind.js';\n\nexport { Lexer } from './lexer.js';\n\nexport { parse, parseValue, parseConstValue, parseType } from './parser.js';\nexport type { ParseOptions } from './parser.js';\n\nexport { print } from './printer.js';\n\nexport {\n visit,\n visitInParallel,\n getEnterLeaveForKind,\n BREAK,\n} from './visitor.js';\nexport type { ASTVisitor, ASTVisitFn, ASTVisitorKeyMap } from './visitor.js';\n\nexport { Location, Token, OperationTypeNode } from './ast.js';\nexport type {\n ASTNode,\n ASTKindToNode,\n // Each kind of AST node\n NameNode,\n DocumentNode,\n DefinitionNode,\n ExecutableDefinitionNode,\n OperationDefinitionNode,\n VariableDefinitionNode,\n VariableNode,\n SelectionSetNode,\n SelectionNode,\n FieldNode,\n ArgumentNode,\n FragmentArgumentNode /* for experimental fragment arguments */,\n ConstArgumentNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n FragmentDefinitionNode,\n ValueNode,\n ConstValueNode,\n IntValueNode,\n FloatValueNode,\n StringValueNode,\n BooleanValueNode,\n NullValueNode,\n EnumValueNode,\n ListValueNode,\n ConstListValueNode,\n ObjectValueNode,\n ConstObjectValueNode,\n ObjectFieldNode,\n ConstObjectFieldNode,\n DirectiveNode,\n ConstDirectiveNode,\n TypeNode,\n NamedTypeNode,\n ListTypeNode,\n NonNullTypeNode,\n TypeSystemDefinitionNode,\n SchemaDefinitionNode,\n OperationTypeDefinitionNode,\n TypeDefinitionNode,\n ScalarTypeDefinitionNode,\n ObjectTypeDefinitionNode,\n FieldDefinitionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n UnionTypeDefinitionNode,\n EnumTypeDefinitionNode,\n EnumValueDefinitionNode,\n InputObjectTypeDefinitionNode,\n DirectiveDefinitionNode,\n TypeSystemExtensionNode,\n SchemaExtensionNode,\n TypeExtensionNode,\n ScalarTypeExtensionNode,\n ObjectTypeExtensionNode,\n InterfaceTypeExtensionNode,\n UnionTypeExtensionNode,\n EnumTypeExtensionNode,\n InputObjectTypeExtensionNode,\n} from './ast.js';\n\nexport {\n isDefinitionNode,\n isExecutableDefinitionNode,\n isSelectionNode,\n isValueNode,\n isConstValueNode,\n isTypeNode,\n isTypeSystemDefinitionNode,\n isTypeDefinitionNode,\n isTypeSystemExtensionNode,\n isTypeExtensionNode,\n} from './predicates.js';\n\nexport { DirectiveLocation } from './directiveLocation.js';\n"]} \ No newline at end of file diff --git a/language/kinds.d.ts b/language/kinds.d.ts new file mode 100644 index 0000000000..87a6e0633e --- /dev/null +++ b/language/kinds.d.ts @@ -0,0 +1,3 @@ +import type * as Kind_ from './kinds_.js'; +export * as Kind from './kinds_.js'; +export type Kind = (typeof Kind_)[keyof typeof Kind_]; diff --git a/language/kinds.js b/language/kinds.js new file mode 100644 index 0000000000..42cc5047ef --- /dev/null +++ b/language/kinds.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Kind = void 0; +exports.Kind = require("./kinds_.js"); +//# sourceMappingURL=kinds.js.map \ No newline at end of file diff --git a/language/kinds.js.map b/language/kinds.js.map new file mode 100644 index 0000000000..972ec48d4a --- /dev/null +++ b/language/kinds.js.map @@ -0,0 +1 @@ +{"version":3,"file":"kinds.js","sourceRoot":"","sources":["../../src/language/kinds.ts"],"names":[],"mappings":";;;AAGA,sCAAoC","sourcesContent":["/* eslint-disable import/no-namespace */\nimport type * as Kind_ from './kinds_.js';\n\nexport * as Kind from './kinds_.js';\n\nexport type Kind = (typeof Kind_)[keyof typeof Kind_];\n"]} \ No newline at end of file diff --git a/language/kinds.mjs b/language/kinds.mjs new file mode 100644 index 0000000000..a62b2c54b1 --- /dev/null +++ b/language/kinds.mjs @@ -0,0 +1,2 @@ +export * as Kind from "./kinds_.mjs"; +//# sourceMappingURL=kinds.js.map \ No newline at end of file diff --git a/language/kinds.mjs.map b/language/kinds.mjs.map new file mode 100644 index 0000000000..c64c0b1fe7 --- /dev/null +++ b/language/kinds.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"kinds.js","sourceRoot":"","sources":["../../src/language/kinds.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,qBAAoB","sourcesContent":["/* eslint-disable import/no-namespace */\nimport type * as Kind_ from './kinds_.js';\n\nexport * as Kind from './kinds_.js';\n\nexport type Kind = (typeof Kind_)[keyof typeof Kind_];\n"]} \ No newline at end of file diff --git a/language/kinds_.d.ts b/language/kinds_.d.ts new file mode 100644 index 0000000000..7aa130c648 --- /dev/null +++ b/language/kinds_.d.ts @@ -0,0 +1,98 @@ +/** Name */ +export declare const NAME = "Name"; +export type NAME = typeof NAME; +/** Document */ +export declare const DOCUMENT = "Document"; +export type DOCUMENT = typeof DOCUMENT; +export declare const OPERATION_DEFINITION = "OperationDefinition"; +export type OPERATION_DEFINITION = typeof OPERATION_DEFINITION; +export declare const VARIABLE_DEFINITION = "VariableDefinition"; +export type VARIABLE_DEFINITION = typeof VARIABLE_DEFINITION; +export declare const SELECTION_SET = "SelectionSet"; +export type SELECTION_SET = typeof SELECTION_SET; +export declare const FIELD = "Field"; +export type FIELD = typeof FIELD; +export declare const ARGUMENT = "Argument"; +export type ARGUMENT = typeof ARGUMENT; +export declare const FRAGMENT_ARGUMENT = "FragmentArgument"; +export type FRAGMENT_ARGUMENT = typeof FRAGMENT_ARGUMENT; +/** Fragments */ +export declare const FRAGMENT_SPREAD = "FragmentSpread"; +export type FRAGMENT_SPREAD = typeof FRAGMENT_SPREAD; +export declare const INLINE_FRAGMENT = "InlineFragment"; +export type INLINE_FRAGMENT = typeof INLINE_FRAGMENT; +export declare const FRAGMENT_DEFINITION = "FragmentDefinition"; +export type FRAGMENT_DEFINITION = typeof FRAGMENT_DEFINITION; +/** Values */ +export declare const VARIABLE = "Variable"; +export type VARIABLE = typeof VARIABLE; +export declare const INT = "IntValue"; +export type INT = typeof INT; +export declare const FLOAT = "FloatValue"; +export type FLOAT = typeof FLOAT; +export declare const STRING = "StringValue"; +export type STRING = typeof STRING; +export declare const BOOLEAN = "BooleanValue"; +export type BOOLEAN = typeof BOOLEAN; +export declare const NULL = "NullValue"; +export type NULL = typeof NULL; +export declare const ENUM = "EnumValue"; +export type ENUM = typeof ENUM; +export declare const LIST = "ListValue"; +export type LIST = typeof LIST; +export declare const OBJECT = "ObjectValue"; +export type OBJECT = typeof OBJECT; +export declare const OBJECT_FIELD = "ObjectField"; +export type OBJECT_FIELD = typeof OBJECT_FIELD; +/** Directives */ +export declare const DIRECTIVE = "Directive"; +export type DIRECTIVE = typeof DIRECTIVE; +/** Types */ +export declare const NAMED_TYPE = "NamedType"; +export type NAMED_TYPE = typeof NAMED_TYPE; +export declare const LIST_TYPE = "ListType"; +export type LIST_TYPE = typeof LIST_TYPE; +export declare const NON_NULL_TYPE = "NonNullType"; +export type NON_NULL_TYPE = typeof NON_NULL_TYPE; +/** Type System Definitions */ +export declare const SCHEMA_DEFINITION = "SchemaDefinition"; +export type SCHEMA_DEFINITION = typeof SCHEMA_DEFINITION; +export declare const OPERATION_TYPE_DEFINITION = "OperationTypeDefinition"; +export type OPERATION_TYPE_DEFINITION = typeof OPERATION_TYPE_DEFINITION; +/** Type Definitions */ +export declare const SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition"; +export type SCALAR_TYPE_DEFINITION = typeof SCALAR_TYPE_DEFINITION; +export declare const OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition"; +export type OBJECT_TYPE_DEFINITION = typeof OBJECT_TYPE_DEFINITION; +export declare const FIELD_DEFINITION = "FieldDefinition"; +export type FIELD_DEFINITION = typeof FIELD_DEFINITION; +export declare const INPUT_VALUE_DEFINITION = "InputValueDefinition"; +export type INPUT_VALUE_DEFINITION = typeof INPUT_VALUE_DEFINITION; +export declare const INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition"; +export type INTERFACE_TYPE_DEFINITION = typeof INTERFACE_TYPE_DEFINITION; +export declare const UNION_TYPE_DEFINITION = "UnionTypeDefinition"; +export type UNION_TYPE_DEFINITION = typeof UNION_TYPE_DEFINITION; +export declare const ENUM_TYPE_DEFINITION = "EnumTypeDefinition"; +export declare const ENUM_VALUE_DEFINITION = "EnumValueDefinition"; +export type ENUM_VALUE_DEFINITION = typeof ENUM_VALUE_DEFINITION; +export declare const INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition"; +export type INPUT_OBJECT_TYPE_DEFINITION = typeof INPUT_OBJECT_TYPE_DEFINITION; +/** Directive Definitions */ +export declare const DIRECTIVE_DEFINITION = "DirectiveDefinition"; +export type DIRECTIVE_DEFINITION = typeof DIRECTIVE_DEFINITION; +/** Type System Extensions */ +export declare const SCHEMA_EXTENSION = "SchemaExtension"; +export type SCHEMA_EXTENSION = typeof SCHEMA_EXTENSION; +/** Type Extensions */ +export declare const SCALAR_TYPE_EXTENSION = "ScalarTypeExtension"; +export type SCALAR_TYPE_EXTENSION = typeof SCALAR_TYPE_EXTENSION; +export declare const OBJECT_TYPE_EXTENSION = "ObjectTypeExtension"; +export type OBJECT_TYPE_EXTENSION = typeof OBJECT_TYPE_EXTENSION; +export declare const INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension"; +export type INTERFACE_TYPE_EXTENSION = typeof INTERFACE_TYPE_EXTENSION; +export declare const UNION_TYPE_EXTENSION = "UnionTypeExtension"; +export type UNION_TYPE_EXTENSION = typeof UNION_TYPE_EXTENSION; +export declare const ENUM_TYPE_EXTENSION = "EnumTypeExtension"; +export type ENUM_TYPE_EXTENSION = typeof ENUM_TYPE_EXTENSION; +export declare const INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension"; +export type INPUT_OBJECT_TYPE_EXTENSION = typeof INPUT_OBJECT_TYPE_EXTENSION; diff --git a/language/kinds_.js b/language/kinds_.js new file mode 100644 index 0000000000..2fc6212a44 --- /dev/null +++ b/language/kinds_.js @@ -0,0 +1,60 @@ +"use strict"; +/* eslint-disable @typescript-eslint/no-redeclare */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.INPUT_OBJECT_TYPE_EXTENSION = exports.ENUM_TYPE_EXTENSION = exports.UNION_TYPE_EXTENSION = exports.INTERFACE_TYPE_EXTENSION = exports.OBJECT_TYPE_EXTENSION = exports.SCALAR_TYPE_EXTENSION = exports.SCHEMA_EXTENSION = exports.DIRECTIVE_DEFINITION = exports.INPUT_OBJECT_TYPE_DEFINITION = exports.ENUM_VALUE_DEFINITION = exports.ENUM_TYPE_DEFINITION = exports.UNION_TYPE_DEFINITION = exports.INTERFACE_TYPE_DEFINITION = exports.INPUT_VALUE_DEFINITION = exports.FIELD_DEFINITION = exports.OBJECT_TYPE_DEFINITION = exports.SCALAR_TYPE_DEFINITION = exports.OPERATION_TYPE_DEFINITION = exports.SCHEMA_DEFINITION = exports.NON_NULL_TYPE = exports.LIST_TYPE = exports.NAMED_TYPE = exports.DIRECTIVE = exports.OBJECT_FIELD = exports.OBJECT = exports.LIST = exports.ENUM = exports.NULL = exports.BOOLEAN = exports.STRING = exports.FLOAT = exports.INT = exports.VARIABLE = exports.FRAGMENT_DEFINITION = exports.INLINE_FRAGMENT = exports.FRAGMENT_SPREAD = exports.FRAGMENT_ARGUMENT = exports.ARGUMENT = exports.FIELD = exports.SELECTION_SET = exports.VARIABLE_DEFINITION = exports.OPERATION_DEFINITION = exports.DOCUMENT = exports.NAME = void 0; +/** Name */ +exports.NAME = 'Name'; +/** Document */ +exports.DOCUMENT = 'Document'; +exports.OPERATION_DEFINITION = 'OperationDefinition'; +exports.VARIABLE_DEFINITION = 'VariableDefinition'; +exports.SELECTION_SET = 'SelectionSet'; +exports.FIELD = 'Field'; +exports.ARGUMENT = 'Argument'; +exports.FRAGMENT_ARGUMENT = 'FragmentArgument'; +/** Fragments */ +exports.FRAGMENT_SPREAD = 'FragmentSpread'; +exports.INLINE_FRAGMENT = 'InlineFragment'; +exports.FRAGMENT_DEFINITION = 'FragmentDefinition'; +/** Values */ +exports.VARIABLE = 'Variable'; +exports.INT = 'IntValue'; +exports.FLOAT = 'FloatValue'; +exports.STRING = 'StringValue'; +exports.BOOLEAN = 'BooleanValue'; +exports.NULL = 'NullValue'; +exports.ENUM = 'EnumValue'; +exports.LIST = 'ListValue'; +exports.OBJECT = 'ObjectValue'; +exports.OBJECT_FIELD = 'ObjectField'; +/** Directives */ +exports.DIRECTIVE = 'Directive'; +/** Types */ +exports.NAMED_TYPE = 'NamedType'; +exports.LIST_TYPE = 'ListType'; +exports.NON_NULL_TYPE = 'NonNullType'; +/** Type System Definitions */ +exports.SCHEMA_DEFINITION = 'SchemaDefinition'; +exports.OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition'; +/** Type Definitions */ +exports.SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition'; +exports.OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition'; +exports.FIELD_DEFINITION = 'FieldDefinition'; +exports.INPUT_VALUE_DEFINITION = 'InputValueDefinition'; +exports.INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition'; +exports.UNION_TYPE_DEFINITION = 'UnionTypeDefinition'; +exports.ENUM_TYPE_DEFINITION = 'EnumTypeDefinition'; +exports.ENUM_VALUE_DEFINITION = 'EnumValueDefinition'; +exports.INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition'; +/** Directive Definitions */ +exports.DIRECTIVE_DEFINITION = 'DirectiveDefinition'; +/** Type System Extensions */ +exports.SCHEMA_EXTENSION = 'SchemaExtension'; +/** Type Extensions */ +exports.SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension'; +exports.OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension'; +exports.INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension'; +exports.UNION_TYPE_EXTENSION = 'UnionTypeExtension'; +exports.ENUM_TYPE_EXTENSION = 'EnumTypeExtension'; +exports.INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension'; +//# sourceMappingURL=kinds_.js.map \ No newline at end of file diff --git a/language/kinds_.js.map b/language/kinds_.js.map new file mode 100644 index 0000000000..f1cddd603a --- /dev/null +++ b/language/kinds_.js.map @@ -0,0 +1 @@ +{"version":3,"file":"kinds_.js","sourceRoot":"","sources":["../../src/language/kinds_.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAEpD,WAAW;AACE,QAAA,IAAI,GAAG,MAAM,CAAC;AAG3B,eAAe;AACF,QAAA,QAAQ,GAAG,UAAU,CAAC;AAEtB,QAAA,oBAAoB,GAAG,qBAAqB,CAAC;AAE7C,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAE3C,QAAA,aAAa,GAAG,cAAc,CAAC;AAE/B,QAAA,KAAK,GAAG,OAAO,CAAC;AAEhB,QAAA,QAAQ,GAAG,UAAU,CAAC;AAEtB,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AAGpD,gBAAgB;AACH,QAAA,eAAe,GAAG,gBAAgB,CAAC;AAEnC,QAAA,eAAe,GAAG,gBAAgB,CAAC;AAEnC,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAGxD,aAAa;AACA,QAAA,QAAQ,GAAG,UAAU,CAAC;AAEtB,QAAA,GAAG,GAAG,UAAU,CAAC;AAEjB,QAAA,KAAK,GAAG,YAAY,CAAC;AAErB,QAAA,MAAM,GAAG,aAAa,CAAC;AAEvB,QAAA,OAAO,GAAG,cAAc,CAAC;AAEzB,QAAA,IAAI,GAAG,WAAW,CAAC;AAEnB,QAAA,IAAI,GAAG,WAAW,CAAC;AAEnB,QAAA,IAAI,GAAG,WAAW,CAAC;AAEnB,QAAA,MAAM,GAAG,aAAa,CAAC;AAEvB,QAAA,YAAY,GAAG,aAAa,CAAC;AAG1C,iBAAiB;AACJ,QAAA,SAAS,GAAG,WAAW,CAAC;AAGrC,YAAY;AACC,QAAA,UAAU,GAAG,WAAW,CAAC;AAEzB,QAAA,SAAS,GAAG,UAAU,CAAC;AAEvB,QAAA,aAAa,GAAG,aAAa,CAAC;AAG3C,8BAA8B;AACjB,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AAEvC,QAAA,yBAAyB,GAAG,yBAAyB,CAAC;AAGnE,uBAAuB;AACV,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAEhD,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAEhD,QAAA,gBAAgB,GAAG,iBAAiB,CAAC;AAErC,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAEhD,QAAA,yBAAyB,GAAG,yBAAyB,CAAC;AAEtD,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAE9C,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAC5C,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAE9C,QAAA,4BAA4B,GAAG,2BAA2B,CAAC;AAGxE,4BAA4B;AACf,QAAA,oBAAoB,GAAG,qBAAqB,CAAC;AAG1D,6BAA6B;AAChB,QAAA,gBAAgB,GAAG,iBAAiB,CAAC;AAGlD,sBAAsB;AACT,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAE9C,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAE9C,QAAA,wBAAwB,GAAG,wBAAwB,CAAC;AAEpD,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAE5C,QAAA,mBAAmB,GAAG,mBAAmB,CAAC;AAE1C,QAAA,2BAA2B,GAAG,0BAA0B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-redeclare */\n\n/** Name */\nexport const NAME = 'Name';\nexport type NAME = typeof NAME;\n\n/** Document */\nexport const DOCUMENT = 'Document';\nexport type DOCUMENT = typeof DOCUMENT;\nexport const OPERATION_DEFINITION = 'OperationDefinition';\nexport type OPERATION_DEFINITION = typeof OPERATION_DEFINITION;\nexport const VARIABLE_DEFINITION = 'VariableDefinition';\nexport type VARIABLE_DEFINITION = typeof VARIABLE_DEFINITION;\nexport const SELECTION_SET = 'SelectionSet';\nexport type SELECTION_SET = typeof SELECTION_SET;\nexport const FIELD = 'Field';\nexport type FIELD = typeof FIELD;\nexport const ARGUMENT = 'Argument';\nexport type ARGUMENT = typeof ARGUMENT;\nexport const FRAGMENT_ARGUMENT = 'FragmentArgument';\nexport type FRAGMENT_ARGUMENT = typeof FRAGMENT_ARGUMENT;\n\n/** Fragments */\nexport const FRAGMENT_SPREAD = 'FragmentSpread';\nexport type FRAGMENT_SPREAD = typeof FRAGMENT_SPREAD;\nexport const INLINE_FRAGMENT = 'InlineFragment';\nexport type INLINE_FRAGMENT = typeof INLINE_FRAGMENT;\nexport const FRAGMENT_DEFINITION = 'FragmentDefinition';\nexport type FRAGMENT_DEFINITION = typeof FRAGMENT_DEFINITION;\n\n/** Values */\nexport const VARIABLE = 'Variable';\nexport type VARIABLE = typeof VARIABLE;\nexport const INT = 'IntValue';\nexport type INT = typeof INT;\nexport const FLOAT = 'FloatValue';\nexport type FLOAT = typeof FLOAT;\nexport const STRING = 'StringValue';\nexport type STRING = typeof STRING;\nexport const BOOLEAN = 'BooleanValue';\nexport type BOOLEAN = typeof BOOLEAN;\nexport const NULL = 'NullValue';\nexport type NULL = typeof NULL;\nexport const ENUM = 'EnumValue';\nexport type ENUM = typeof ENUM;\nexport const LIST = 'ListValue';\nexport type LIST = typeof LIST;\nexport const OBJECT = 'ObjectValue';\nexport type OBJECT = typeof OBJECT;\nexport const OBJECT_FIELD = 'ObjectField';\nexport type OBJECT_FIELD = typeof OBJECT_FIELD;\n\n/** Directives */\nexport const DIRECTIVE = 'Directive';\nexport type DIRECTIVE = typeof DIRECTIVE;\n\n/** Types */\nexport const NAMED_TYPE = 'NamedType';\nexport type NAMED_TYPE = typeof NAMED_TYPE;\nexport const LIST_TYPE = 'ListType';\nexport type LIST_TYPE = typeof LIST_TYPE;\nexport const NON_NULL_TYPE = 'NonNullType';\nexport type NON_NULL_TYPE = typeof NON_NULL_TYPE;\n\n/** Type System Definitions */\nexport const SCHEMA_DEFINITION = 'SchemaDefinition';\nexport type SCHEMA_DEFINITION = typeof SCHEMA_DEFINITION;\nexport const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';\nexport type OPERATION_TYPE_DEFINITION = typeof OPERATION_TYPE_DEFINITION;\n\n/** Type Definitions */\nexport const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';\nexport type SCALAR_TYPE_DEFINITION = typeof SCALAR_TYPE_DEFINITION;\nexport const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';\nexport type OBJECT_TYPE_DEFINITION = typeof OBJECT_TYPE_DEFINITION;\nexport const FIELD_DEFINITION = 'FieldDefinition';\nexport type FIELD_DEFINITION = typeof FIELD_DEFINITION;\nexport const INPUT_VALUE_DEFINITION = 'InputValueDefinition';\nexport type INPUT_VALUE_DEFINITION = typeof INPUT_VALUE_DEFINITION;\nexport const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';\nexport type INTERFACE_TYPE_DEFINITION = typeof INTERFACE_TYPE_DEFINITION;\nexport const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';\nexport type UNION_TYPE_DEFINITION = typeof UNION_TYPE_DEFINITION;\nexport const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';\nexport const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';\nexport type ENUM_VALUE_DEFINITION = typeof ENUM_VALUE_DEFINITION;\nexport const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';\nexport type INPUT_OBJECT_TYPE_DEFINITION = typeof INPUT_OBJECT_TYPE_DEFINITION;\n\n/** Directive Definitions */\nexport const DIRECTIVE_DEFINITION = 'DirectiveDefinition';\nexport type DIRECTIVE_DEFINITION = typeof DIRECTIVE_DEFINITION;\n\n/** Type System Extensions */\nexport const SCHEMA_EXTENSION = 'SchemaExtension';\nexport type SCHEMA_EXTENSION = typeof SCHEMA_EXTENSION;\n\n/** Type Extensions */\nexport const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension';\nexport type SCALAR_TYPE_EXTENSION = typeof SCALAR_TYPE_EXTENSION;\nexport const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension';\nexport type OBJECT_TYPE_EXTENSION = typeof OBJECT_TYPE_EXTENSION;\nexport const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension';\nexport type INTERFACE_TYPE_EXTENSION = typeof INTERFACE_TYPE_EXTENSION;\nexport const UNION_TYPE_EXTENSION = 'UnionTypeExtension';\nexport type UNION_TYPE_EXTENSION = typeof UNION_TYPE_EXTENSION;\nexport const ENUM_TYPE_EXTENSION = 'EnumTypeExtension';\nexport type ENUM_TYPE_EXTENSION = typeof ENUM_TYPE_EXTENSION;\nexport const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension';\nexport type INPUT_OBJECT_TYPE_EXTENSION = typeof INPUT_OBJECT_TYPE_EXTENSION;\n"]} \ No newline at end of file diff --git a/language/kinds_.mjs b/language/kinds_.mjs new file mode 100644 index 0000000000..50db517475 --- /dev/null +++ b/language/kinds_.mjs @@ -0,0 +1,57 @@ +/* eslint-disable @typescript-eslint/no-redeclare */ +/** Name */ +export const NAME = 'Name'; +/** Document */ +export const DOCUMENT = 'Document'; +export const OPERATION_DEFINITION = 'OperationDefinition'; +export const VARIABLE_DEFINITION = 'VariableDefinition'; +export const SELECTION_SET = 'SelectionSet'; +export const FIELD = 'Field'; +export const ARGUMENT = 'Argument'; +export const FRAGMENT_ARGUMENT = 'FragmentArgument'; +/** Fragments */ +export const FRAGMENT_SPREAD = 'FragmentSpread'; +export const INLINE_FRAGMENT = 'InlineFragment'; +export const FRAGMENT_DEFINITION = 'FragmentDefinition'; +/** Values */ +export const VARIABLE = 'Variable'; +export const INT = 'IntValue'; +export const FLOAT = 'FloatValue'; +export const STRING = 'StringValue'; +export const BOOLEAN = 'BooleanValue'; +export const NULL = 'NullValue'; +export const ENUM = 'EnumValue'; +export const LIST = 'ListValue'; +export const OBJECT = 'ObjectValue'; +export const OBJECT_FIELD = 'ObjectField'; +/** Directives */ +export const DIRECTIVE = 'Directive'; +/** Types */ +export const NAMED_TYPE = 'NamedType'; +export const LIST_TYPE = 'ListType'; +export const NON_NULL_TYPE = 'NonNullType'; +/** Type System Definitions */ +export const SCHEMA_DEFINITION = 'SchemaDefinition'; +export const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition'; +/** Type Definitions */ +export const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition'; +export const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition'; +export const FIELD_DEFINITION = 'FieldDefinition'; +export const INPUT_VALUE_DEFINITION = 'InputValueDefinition'; +export const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition'; +export const UNION_TYPE_DEFINITION = 'UnionTypeDefinition'; +export const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition'; +export const ENUM_VALUE_DEFINITION = 'EnumValueDefinition'; +export const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition'; +/** Directive Definitions */ +export const DIRECTIVE_DEFINITION = 'DirectiveDefinition'; +/** Type System Extensions */ +export const SCHEMA_EXTENSION = 'SchemaExtension'; +/** Type Extensions */ +export const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension'; +export const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension'; +export const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension'; +export const UNION_TYPE_EXTENSION = 'UnionTypeExtension'; +export const ENUM_TYPE_EXTENSION = 'EnumTypeExtension'; +export const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension'; +//# sourceMappingURL=kinds_.js.map \ No newline at end of file diff --git a/language/kinds_.mjs.map b/language/kinds_.mjs.map new file mode 100644 index 0000000000..24b760e058 --- /dev/null +++ b/language/kinds_.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"kinds_.js","sourceRoot":"","sources":["../../src/language/kinds_.ts"],"names":[],"m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* eslint-disable @typescript-eslint/no-redeclare */\n\n/** Name */\nexport const NAME = 'Name';\nexport type NAME = typeof NAME;\n\n/** Document */\nexport const DOCUMENT = 'Document';\nexport type DOCUMENT = typeof DOCUMENT;\nexport const OPERATION_DEFINITION = 'OperationDefinition';\nexport type OPERATION_DEFINITION = typeof OPERATION_DEFINITION;\nexport const VARIABLE_DEFINITION = 'VariableDefinition';\nexport type VARIABLE_DEFINITION = typeof VARIABLE_DEFINITION;\nexport const SELECTION_SET = 'SelectionSet';\nexport type SELECTION_SET = typeof SELECTION_SET;\nexport const FIELD = 'Field';\nexport type FIELD = typeof FIELD;\nexport const ARGUMENT = 'Argument';\nexport type ARGUMENT = typeof ARGUMENT;\nexport const FRAGMENT_ARGUMENT = 'FragmentArgument';\nexport type FRAGMENT_ARGUMENT = typeof FRAGMENT_ARGUMENT;\n\n/** Fragments */\nexport const FRAGMENT_SPREAD = 'FragmentSpread';\nexport type FRAGMENT_SPREAD = typeof FRAGMENT_SPREAD;\nexport const INLINE_FRAGMENT = 'InlineFragment';\nexport type INLINE_FRAGMENT = typeof INLINE_FRAGMENT;\nexport const FRAGMENT_DEFINITION = 'FragmentDefinition';\nexport type FRAGMENT_DEFINITION = typeof FRAGMENT_DEFINITION;\n\n/** Values */\nexport const VARIABLE = 'Variable';\nexport type VARIABLE = typeof VARIABLE;\nexport const INT = 'IntValue';\nexport type INT = typeof INT;\nexport const FLOAT = 'FloatValue';\nexport type FLOAT = typeof FLOAT;\nexport const STRING = 'StringValue';\nexport type STRING = typeof STRING;\nexport const BOOLEAN = 'BooleanValue';\nexport type BOOLEAN = typeof BOOLEAN;\nexport const NULL = 'NullValue';\nexport type NULL = typeof NULL;\nexport const ENUM = 'EnumValue';\nexport type ENUM = typeof ENUM;\nexport const LIST = 'ListValue';\nexport type LIST = typeof LIST;\nexport const OBJECT = 'ObjectValue';\nexport type OBJECT = typeof OBJECT;\nexport const OBJECT_FIELD = 'ObjectField';\nexport type OBJECT_FIELD = typeof OBJECT_FIELD;\n\n/** Directives */\nexport const DIRECTIVE = 'Directive';\nexport type DIRECTIVE = typeof DIRECTIVE;\n\n/** Types */\nexport const NAMED_TYPE = 'NamedType';\nexport type NAMED_TYPE = typeof NAMED_TYPE;\nexport const LIST_TYPE = 'ListType';\nexport type LIST_TYPE = typeof LIST_TYPE;\nexport const NON_NULL_TYPE = 'NonNullType';\nexport type NON_NULL_TYPE = typeof NON_NULL_TYPE;\n\n/** Type System Definitions */\nexport const SCHEMA_DEFINITION = 'SchemaDefinition';\nexport type SCHEMA_DEFINITION = typeof SCHEMA_DEFINITION;\nexport const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';\nexport type OPERATION_TYPE_DEFINITION = typeof OPERATION_TYPE_DEFINITION;\n\n/** Type Definitions */\nexport const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';\nexport type SCALAR_TYPE_DEFINITION = typeof SCALAR_TYPE_DEFINITION;\nexport const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';\nexport type OBJECT_TYPE_DEFINITION = typeof OBJECT_TYPE_DEFINITION;\nexport const FIELD_DEFINITION = 'FieldDefinition';\nexport type FIELD_DEFINITION = typeof FIELD_DEFINITION;\nexport const INPUT_VALUE_DEFINITION = 'InputValueDefinition';\nexport type INPUT_VALUE_DEFINITION = typeof INPUT_VALUE_DEFINITION;\nexport const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';\nexport type INTERFACE_TYPE_DEFINITION = typeof INTERFACE_TYPE_DEFINITION;\nexport const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';\nexport type UNION_TYPE_DEFINITION = typeof UNION_TYPE_DEFINITION;\nexport const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';\nexport const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';\nexport type ENUM_VALUE_DEFINITION = typeof ENUM_VALUE_DEFINITION;\nexport const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';\nexport type INPUT_OBJECT_TYPE_DEFINITION = typeof INPUT_OBJECT_TYPE_DEFINITION;\n\n/** Directive Definitions */\nexport const DIRECTIVE_DEFINITION = 'DirectiveDefinition';\nexport type DIRECTIVE_DEFINITION = typeof DIRECTIVE_DEFINITION;\n\n/** Type System Extensions */\nexport const SCHEMA_EXTENSION = 'SchemaExtension';\nexport type SCHEMA_EXTENSION = typeof SCHEMA_EXTENSION;\n\n/** Type Extensions */\nexport const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension';\nexport type SCALAR_TYPE_EXTENSION = typeof SCALAR_TYPE_EXTENSION;\nexport const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension';\nexport type OBJECT_TYPE_EXTENSION = typeof OBJECT_TYPE_EXTENSION;\nexport const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension';\nexport type INTERFACE_TYPE_EXTENSION = typeof INTERFACE_TYPE_EXTENSION;\nexport const UNION_TYPE_EXTENSION = 'UnionTypeExtension';\nexport type UNION_TYPE_EXTENSION = typeof UNION_TYPE_EXTENSION;\nexport const ENUM_TYPE_EXTENSION = 'EnumTypeExtension';\nexport type ENUM_TYPE_EXTENSION = typeof ENUM_TYPE_EXTENSION;\nexport const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension';\nexport type INPUT_OBJECT_TYPE_EXTENSION = typeof INPUT_OBJECT_TYPE_EXTENSION;\n"]} \ No newline at end of file diff --git a/language/lexer.d.ts b/language/lexer.d.ts new file mode 100644 index 0000000000..238f156985 --- /dev/null +++ b/language/lexer.d.ts @@ -0,0 +1,45 @@ +import { Token } from './ast.js'; +import type { Source } from './source.js'; +import { TokenKind } from './tokenKind.js'; +/** + * Given a Source object, creates a Lexer for that source. + * A Lexer is a stateful stream generator in that every time + * it is advanced, it returns the next token in the Source. Assuming the + * source lexes, the final Token emitted by the lexer will be of kind + * EOF, after which the lexer will repeatedly return the same EOF token + * whenever called. + */ +export declare class Lexer { + source: Source; + /** + * The previously focused non-ignored token. + */ + lastToken: Token; + /** + * The currently focused non-ignored token. + */ + token: Token; + /** + * The (1-indexed) line containing the current token. + */ + line: number; + /** + * The character offset at which the current line begins. + */ + lineStart: number; + constructor(source: Source); + get [Symbol.toStringTag](): string; + /** + * Advances the token stream to the next non-ignored token. + */ + advance(): Token; + /** + * Looks ahead and returns the next non-ignored token, but does not change + * the current Lexer token. + */ + lookahead(): Token; +} +/** + * @internal + */ +export declare function isPunctuatorTokenKind(kind: TokenKind): boolean; diff --git a/language/lexer.js b/language/lexer.js new file mode 100644 index 0000000000..fde2851733 --- /dev/null +++ b/language/lexer.js @@ -0,0 +1,670 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Lexer = void 0; +exports.isPunctuatorTokenKind = isPunctuatorTokenKind; +const syntaxError_js_1 = require("../error/syntaxError.js"); +const ast_js_1 = require("./ast.js"); +const blockString_js_1 = require("./blockString.js"); +const characterClasses_js_1 = require("./characterClasses.js"); +const tokenKind_js_1 = require("./tokenKind.js"); +/** + * Given a Source object, creates a Lexer for that source. + * A Lexer is a stateful stream generator in that every time + * it is advanced, it returns the next token in the Source. Assuming the + * source lexes, the final Token emitted by the lexer will be of kind + * EOF, after which the lexer will repeatedly return the same EOF token + * whenever called. + */ +class Lexer { + constructor(source) { + const startOfFileToken = new ast_js_1.Token(tokenKind_js_1.TokenKind.SOF, 0, 0, 0, 0); + this.source = source; + this.lastToken = startOfFileToken; + this.token = startOfFileToken; + this.line = 1; + this.lineStart = 0; + } + get [Symbol.toStringTag]() { + return 'Lexer'; + } + /** + * Advances the token stream to the next non-ignored token. + */ + advance() { + this.lastToken = this.token; + const token = (this.token = this.lookahead()); + return token; + } + /** + * Looks ahead and returns the next non-ignored token, but does not change + * the current Lexer token. + */ + lookahead() { + let token = this.token; + if (token.kind !== tokenKind_js_1.TokenKind.EOF) { + do { + if (token.next) { + token = token.next; + } + else { + // Read the next token and form a link in the token linked-list. + const nextToken = readNextToken(this, token.end); + // @ts-expect-error next is only mutable during parsing. + token.next = nextToken; + // @ts-expect-error prev is only mutable during parsing. + nextToken.prev = token; + token = nextToken; + } + } while (token.kind === tokenKind_js_1.TokenKind.COMMENT); + } + return token; + } +} +exports.Lexer = Lexer; +/** + * @internal + */ +function isPunctuatorTokenKind(kind) { + return (kind === tokenKind_js_1.TokenKind.BANG || + kind === tokenKind_js_1.TokenKind.DOLLAR || + kind === tokenKind_js_1.TokenKind.AMP || + kind === tokenKind_js_1.TokenKind.PAREN_L || + kind === tokenKind_js_1.TokenKind.PAREN_R || + kind === tokenKind_js_1.TokenKind.SPREAD || + kind === tokenKind_js_1.TokenKind.COLON || + kind === tokenKind_js_1.TokenKind.EQUALS || + kind === tokenKind_js_1.TokenKind.AT || + kind === tokenKind_js_1.TokenKind.BRACKET_L || + kind === tokenKind_js_1.TokenKind.BRACKET_R || + kind === tokenKind_js_1.TokenKind.BRACE_L || + kind === tokenKind_js_1.TokenKind.PIPE || + kind === tokenKind_js_1.TokenKind.BRACE_R); +} +/** + * A Unicode scalar value is any Unicode code point except surrogate code + * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and + * 0xE000 to 0x10FFFF. + * + * SourceCharacter :: + * - "Any Unicode scalar value" + */ +function isUnicodeScalarValue(code) { + return ((code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff)); +} +/** + * The GraphQL specification defines source text as a sequence of unicode scalar + * values (which Unicode defines to exclude surrogate code points). However + * JavaScript defines strings as a sequence of UTF-16 code units which may + * include surrogates. A surrogate pair is a valid source character as it + * encodes a supplementary code point (above U+FFFF), but unpaired surrogate + * code points are not valid source characters. + */ +function isSupplementaryCodePoint(body, location) { + return (isLeadingSurrogate(body.charCodeAt(location)) && + isTrailingSurrogate(body.charCodeAt(location + 1))); +} +function isLeadingSurrogate(code) { + return code >= 0xd800 && code <= 0xdbff; +} +function isTrailingSurrogate(code) { + return code >= 0xdc00 && code <= 0xdfff; +} +/** + * Prints the code point (or end of file reference) at a given location in a + * source for use in error messages. + * + * Printable ASCII is printed quoted, while other points are printed in Unicode + * code point form (ie. U+1234). + */ +function printCodePointAt(lexer, location) { + const code = lexer.source.body.codePointAt(location); + if (code === undefined) { + return tokenKind_js_1.TokenKind.EOF; + } + else if (code >= 0x0020 && code <= 0x007e) { + // Printable ASCII + const char = String.fromCodePoint(code); + return char === '"' ? "'\"'" : `"${char}"`; + } + // Unicode code point + return 'U+' + code.toString(16).toUpperCase().padStart(4, '0'); +} +/** + * Create a token with line and column location information. + */ +function createToken(lexer, kind, start, end, value) { + const line = lexer.line; + const col = 1 + start - lexer.lineStart; + return new ast_js_1.Token(kind, start, end, line, col, value); +} +/** + * Gets the next token from the source starting at the given position. + * + * This skips over whitespace until it finds the next lexable token, then lexes + * punctuators immediately or calls the appropriate helper function for more + * complicated tokens. + */ +function readNextToken(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // SourceCharacter + switch (code) { + // Ignored :: + // - UnicodeBOM + // - WhiteSpace + // - LineTerminator + // - Comment + // - Comma + // + // UnicodeBOM :: "Byte Order Mark (U+FEFF)" + // + // WhiteSpace :: + // - "Horizontal Tab (U+0009)" + // - "Space (U+0020)" + // + // Comma :: , + case 0xfeff: // + case 0x0009: // \t + case 0x0020: // + case 0x002c: // , + ++position; + continue; + // LineTerminator :: + // - "New Line (U+000A)" + // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"] + // - "Carriage Return (U+000D)" "New Line (U+000A)" + case 0x000a: // \n + ++position; + ++lexer.line; + lexer.lineStart = position; + continue; + case 0x000d: // \r + if (body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } + else { + ++position; + } + ++lexer.line; + lexer.lineStart = position; + continue; + // Comment + case 0x0023: // # + return readComment(lexer, position); + // Token :: + // - Punctuator + // - Name + // - IntValue + // - FloatValue + // - StringValue + // + // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } + case 0x0021: // ! + return createToken(lexer, tokenKind_js_1.TokenKind.BANG, position, position + 1); + case 0x0024: // $ + return createToken(lexer, tokenKind_js_1.TokenKind.DOLLAR, position, position + 1); + case 0x0026: // & + return createToken(lexer, tokenKind_js_1.TokenKind.AMP, position, position + 1); + case 0x0028: // ( + return createToken(lexer, tokenKind_js_1.TokenKind.PAREN_L, position, position + 1); + case 0x0029: // ) + return createToken(lexer, tokenKind_js_1.TokenKind.PAREN_R, position, position + 1); + case 0x002e: { + // . + const nextCode = body.charCodeAt(position + 1); + if (nextCode === 0x002e && body.charCodeAt(position + 2) === 0x002e) { + return createToken(lexer, tokenKind_js_1.TokenKind.SPREAD, position, position + 3); + } + if (nextCode === 0x002e) { + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, 'Unexpected "..", did you mean "..."?'); + } + else if ((0, characterClasses_js_1.isDigit)(nextCode)) { + const digits = lexer.source.body.slice(position + 1, readDigits(lexer, position + 1, nextCode)); + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid number, expected digit before ".", did you mean "0.${digits}"?`); + } + break; + } + case 0x003a: // : + return createToken(lexer, tokenKind_js_1.TokenKind.COLON, position, position + 1); + case 0x003d: // = + return createToken(lexer, tokenKind_js_1.TokenKind.EQUALS, position, position + 1); + case 0x0040: // @ + return createToken(lexer, tokenKind_js_1.TokenKind.AT, position, position + 1); + case 0x005b: // [ + return createToken(lexer, tokenKind_js_1.TokenKind.BRACKET_L, position, position + 1); + case 0x005d: // ] + return createToken(lexer, tokenKind_js_1.TokenKind.BRACKET_R, position, position + 1); + case 0x007b: // { + return createToken(lexer, tokenKind_js_1.TokenKind.BRACE_L, position, position + 1); + case 0x007c: // | + return createToken(lexer, tokenKind_js_1.TokenKind.PIPE, position, position + 1); + case 0x007d: // } + return createToken(lexer, tokenKind_js_1.TokenKind.BRACE_R, position, position + 1); + // StringValue + case 0x0022: // " + if (body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022) { + return readBlockString(lexer, position); + } + return readString(lexer, position); + } + // IntValue | FloatValue (Digit | -) + if ((0, characterClasses_js_1.isDigit)(code) || code === 0x002d) { + return readNumber(lexer, position, code); + } + // Name + if ((0, characterClasses_js_1.isNameStart)(code)) { + return readName(lexer, position); + } + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, code === 0x0027 + ? 'Unexpected single quote character (\'), did you mean to use a double quote (")?' + : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) + ? `Unexpected character: ${printCodePointAt(lexer, position)}.` + : `Invalid character: ${printCodePointAt(lexer, position)}.`); + } + return createToken(lexer, tokenKind_js_1.TokenKind.EOF, bodyLength, bodyLength); +} +/** + * Reads a comment token from the source file. + * + * ``` + * Comment :: # CommentChar* [lookahead != CommentChar] + * + * CommentChar :: SourceCharacter but not LineTerminator + * ``` + */ +function readComment(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // LineTerminator (\n | \r) + if (code === 0x000a || code === 0x000d) { + break; + } + // SourceCharacter + if (isUnicodeScalarValue(code)) { + ++position; + } + else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } + else { + break; + } + } + return createToken(lexer, tokenKind_js_1.TokenKind.COMMENT, start, position, body.slice(start + 1, position)); +} +/** + * Reads a number token from the source file, either a FloatValue or an IntValue + * depending on whether a FractionalPart or ExponentPart is encountered. + * + * ``` + * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}] + * + * IntegerPart :: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit Digit* + * + * NegativeSign :: - + * + * NonZeroDigit :: Digit but not `0` + * + * FloatValue :: + * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * + * FractionalPart :: . Digit+ + * + * ExponentPart :: ExponentIndicator Sign? Digit+ + * + * ExponentIndicator :: one of `e` `E` + * + * Sign :: one of + - + * ``` + */ +function readNumber(lexer, start, firstCode) { + const body = lexer.source.body; + let position = start; + let code = firstCode; + let isFloat = false; + // NegativeSign (-) + if (code === 0x002d) { + code = body.charCodeAt(++position); + } + // Zero (0) + if (code === 0x0030) { + code = body.charCodeAt(++position); + if ((0, characterClasses_js_1.isDigit)(code)) { + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid number, unexpected digit after 0: ${printCodePointAt(lexer, position)}.`); + } + } + else { + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } + // Full stop (.) + if (code === 0x002e) { + isFloat = true; + code = body.charCodeAt(++position); + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } + // E e + if (code === 0x0045 || code === 0x0065) { + isFloat = true; + code = body.charCodeAt(++position); + // + - + if (code === 0x002b || code === 0x002d) { + code = body.charCodeAt(++position); + } + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } + // Numbers cannot be followed by . or NameStart + if (code === 0x002e || (0, characterClasses_js_1.isNameStart)(code)) { + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid number, expected digit but got: ${printCodePointAt(lexer, position)}.`); + } + return createToken(lexer, isFloat ? tokenKind_js_1.TokenKind.FLOAT : tokenKind_js_1.TokenKind.INT, start, position, body.slice(start, position)); +} +/** + * Returns the new position in the source after reading one or more digits. + */ +function readDigits(lexer, start, firstCode) { + if (!(0, characterClasses_js_1.isDigit)(firstCode)) { + throw (0, syntaxError_js_1.syntaxError)(lexer.source, start, `Invalid number, expected digit but got: ${printCodePointAt(lexer, start)}.`); + } + const body = lexer.source.body; + let position = start + 1; // +1 to skip first firstCode + while ((0, characterClasses_js_1.isDigit)(body.charCodeAt(position))) { + ++position; + } + return position; +} +/** + * Reads a single-quote string token from the source file. + * + * ``` + * StringValue :: + * - `""` [lookahead != `"`] + * - `"` StringCharacter+ `"` + * + * StringCharacter :: + * - SourceCharacter but not `"` or `\` or LineTerminator + * - `\u` EscapedUnicode + * - `\` EscapedCharacter + * + * EscapedUnicode :: + * - `{` HexDigit+ `}` + * - HexDigit HexDigit HexDigit HexDigit + * + * EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t` + * ``` + */ +function readString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + let chunkStart = position; + let value = ''; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // Closing Quote (") + if (code === 0x0022) { + value += body.slice(chunkStart, position); + return createToken(lexer, tokenKind_js_1.TokenKind.STRING, start, position + 1, value); + } + // Escape Sequence (\) + if (code === 0x005c) { + value += body.slice(chunkStart, position); + const escape = body.charCodeAt(position + 1) === 0x0075 // u + ? body.charCodeAt(position + 2) === 0x007b // { + ? readEscapedUnicodeVariableWidth(lexer, position) + : readEscapedUnicodeFixedWidth(lexer, position) + : readEscapedCharacter(lexer, position); + value += escape.value; + position += escape.size; + chunkStart = position; + continue; + } + // LineTerminator (\n | \r) + if (code === 0x000a || code === 0x000d) { + break; + } + // SourceCharacter + if (isUnicodeScalarValue(code)) { + ++position; + } + else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } + else { + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`); + } + } + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, 'Unterminated string.'); +} +function readEscapedUnicodeVariableWidth(lexer, position) { + const body = lexer.source.body; + let point = 0; + let size = 3; + // Cannot be larger than 12 chars (\u{00000000}). + while (size < 12) { + const code = body.charCodeAt(position + size++); + // Closing Brace (}) + if (code === 0x007d) { + // Must be at least 5 chars (\u{0}) and encode a Unicode scalar value. + if (size < 5 || !isUnicodeScalarValue(point)) { + break; + } + return { value: String.fromCodePoint(point), size }; + } + // Append this hex digit to the code point. + point = (point << 4) | readHexDigit(code); + if (point < 0) { + break; + } + } + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + size)}".`); +} +function readEscapedUnicodeFixedWidth(lexer, position) { + const body = lexer.source.body; + const code = read16BitHexCode(body, position + 2); + if (isUnicodeScalarValue(code)) { + return { value: String.fromCodePoint(code), size: 6 }; + } + // GraphQL allows JSON-style surrogate pair escape sequences, but only when + // a valid pair is formed. + if (isLeadingSurrogate(code)) { + // \u + if (body.charCodeAt(position + 6) === 0x005c && + body.charCodeAt(position + 7) === 0x0075) { + const trailingCode = read16BitHexCode(body, position + 8); + if (isTrailingSurrogate(trailingCode)) { + // JavaScript defines strings as a sequence of UTF-16 code units and + // encodes Unicode code points above U+FFFF using a surrogate pair of + // code units. Since this is a surrogate pair escape sequence, just + // include both codes into the JavaScript string value. Had JavaScript + // not been internally based on UTF-16, then this surrogate pair would + // be decoded to retrieve the supplementary code point. + return { value: String.fromCodePoint(code, trailingCode), size: 12 }; + } + } + } + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`); +} +/** + * Reads four hexadecimal characters and returns the positive integer that 16bit + * hexadecimal string represents. For example, "000f" will return 15, and "dead" + * will return 57005. + * + * Returns a negative number if any char was not a valid hexadecimal digit. + */ +function read16BitHexCode(body, position) { + // readHexDigit() returns -1 on error. ORing a negative value with any other + // value always produces a negative value. + return ((readHexDigit(body.charCodeAt(position)) << 12) | + (readHexDigit(body.charCodeAt(position + 1)) << 8) | + (readHexDigit(body.charCodeAt(position + 2)) << 4) | + readHexDigit(body.charCodeAt(position + 3))); +} +/** + * Reads a hexadecimal character and returns its positive integer value (0-15). + * + * '0' becomes 0, '9' becomes 9 + * 'A' becomes 10, 'F' becomes 15 + * 'a' becomes 10, 'f' becomes 15 + * + * Returns -1 if the provided character code was not a valid hexadecimal digit. + * + * HexDigit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * - `A` `B` `C` `D` `E` `F` + * - `a` `b` `c` `d` `e` `f` + */ +function readHexDigit(code) { + return code >= 0x0030 && code <= 0x0039 // 0-9 + ? code - 0x0030 + : code >= 0x0041 && code <= 0x0046 // A-F + ? code - 0x0037 + : code >= 0x0061 && code <= 0x0066 // a-f + ? code - 0x0057 + : -1; +} +/** + * | Escaped Character | Code Point | Character Name | + * | ----------------- | ---------- | ---------------------------- | + * | `"` | U+0022 | double quote | + * | `\` | U+005C | reverse solidus (back slash) | + * | `/` | U+002F | solidus (forward slash) | + * | `b` | U+0008 | backspace | + * | `f` | U+000C | form feed | + * | `n` | U+000A | line feed (new line) | + * | `r` | U+000D | carriage return | + * | `t` | U+0009 | horizontal tab | + */ +function readEscapedCharacter(lexer, position) { + const body = lexer.source.body; + const code = body.charCodeAt(position + 1); + switch (code) { + case 0x0022: // " + return { value: '\u0022', size: 2 }; + case 0x005c: // \ + return { value: '\u005c', size: 2 }; + case 0x002f: // / + return { value: '\u002f', size: 2 }; + case 0x0062: // b + return { value: '\u0008', size: 2 }; + case 0x0066: // f + return { value: '\u000c', size: 2 }; + case 0x006e: // n + return { value: '\u000a', size: 2 }; + case 0x0072: // r + return { value: '\u000d', size: 2 }; + case 0x0074: // t + return { value: '\u0009', size: 2 }; + } + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid character escape sequence: "${body.slice(position, position + 2)}".`); +} +/** + * Reads a block string token from the source file. + * + * ``` + * StringValue :: + * - `"""` BlockStringCharacter* `"""` + * + * BlockStringCharacter :: + * - SourceCharacter but not `"""` or `\"""` + * - `\"""` + * ``` + */ +function readBlockString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let lineStart = lexer.lineStart; + let position = start + 3; + let chunkStart = position; + let currentLine = ''; + const blockLines = []; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // Closing Triple-Quote (""") + if (code === 0x0022 && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + const token = createToken(lexer, tokenKind_js_1.TokenKind.BLOCK_STRING, start, position + 3, + // Return a string of the lines joined with U+000A. + (0, blockString_js_1.dedentBlockStringLines)(blockLines).join('\n')); + lexer.line += blockLines.length - 1; + lexer.lineStart = lineStart; + return token; + } + // Escaped Triple-Quote (\""") + if (code === 0x005c && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 && + body.charCodeAt(position + 3) === 0x0022) { + currentLine += body.slice(chunkStart, position); + chunkStart = position + 1; // skip only slash + position += 4; + continue; + } + // LineTerminator + if (code === 0x000a || code === 0x000d) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } + else { + ++position; + } + currentLine = ''; + chunkStart = position; + lineStart = position; + continue; + } + // SourceCharacter + if (isUnicodeScalarValue(code)) { + ++position; + } + else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } + else { + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`); + } + } + throw (0, syntaxError_js_1.syntaxError)(lexer.source, position, 'Unterminated string.'); +} +/** + * Reads an alphanumeric + underscore name from the source. + * + * ``` + * Name :: + * - NameStart NameContinue* [lookahead != NameContinue] + * ``` + */ +function readName(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + while (position < bodyLength) { + const code = body.charCodeAt(position); + if ((0, characterClasses_js_1.isNameContinue)(code)) { + ++position; + } + else { + break; + } + } + return createToken(lexer, tokenKind_js_1.TokenKind.NAME, start, position, body.slice(start, position)); +} +//# sourceMappingURL=lexer.js.map \ No newline at end of file diff --git a/language/lexer.js.map b/language/lexer.js.map new file mode 100644 index 0000000000..598e123e52 --- /dev/null +++ b/language/lexer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../src/language/lexer.ts"],"names":[],"mappings":";;;AA0FA,sDAiBC;AA3GD,4DAAsD;AAEtD,qCAAiC;AACjC,qDAA0D;AAC1D,+DAA6E;AAE7E,iDAA2C;AAE3C;;;;;;;GAOG;AACH,MAAa,K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,EAAE,sBAAsB,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,KAAY,EAAE,KAAa;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;IAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAC;IAEzB,OAAO,QAAQ,GAAG,UAAU,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,IAAA,oCAAc,EAAC,IAAI,CAAC,EAAE,CAAC;YACzB,EAAE,QAAQ,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAChB,KAAK,EACL,wBAAS,CAAC,IAAI,EACd,KAAK,EACL,QAAQ,EACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { syntaxError } from '../error/syntaxError.js';\n\nimport { Token } from './ast.js';\nimport { dedentBlockStringLines } from './blockString.js';\nimport { isDigit, isNameContinue, isNameStart } from './characterClasses.js';\nimport type { Source } from './source.js';\nimport { TokenKind } from './tokenKind.js';\n\n/**\n * Given a Source object, creates a Lexer for that source.\n * A Lexer is a stateful stream generator in that every time\n * it is advanced, it returns the next token in the Source. Assuming the\n * source lexes, the final Token emitted by the lexer will be of kind\n * EOF, after which the lexer will repeatedly return the same EOF token\n * whenever called.\n */\nexport class Lexer {\n source: Source;\n\n /**\n * The previously focused non-ignored token.\n */\n lastToken: Token;\n\n /**\n * The currently focused non-ignored token.\n */\n token: Token;\n\n /**\n * The (1-indexed) line containing the current token.\n */\n line: number;\n\n /**\n * The character offset at which the current line begins.\n */\n lineStart: number;\n\n constructor(source: Source) {\n const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);\n\n this.source = source;\n this.lastToken = startOfFileToken;\n this.token = startOfFileToken;\n this.line = 1;\n this.lineStart = 0;\n }\n\n get [Symbol.toStringTag]() {\n return 'Lexer';\n }\n\n /**\n * Advances the token stream to the next non-ignored token.\n */\n advance(): Token {\n this.lastToken = this.token;\n const token = (this.token = this.lookahead());\n return token;\n }\n\n /**\n * Looks ahead and returns the next non-ignored token, but does not change\n * the current Lexer token.\n */\n lookahead(): Token {\n let token = this.token;\n if (token.kind !== TokenKind.EOF) {\n do {\n if (token.next) {\n token = token.next;\n } else {\n // Read the next token and form a link in the token linked-list.\n const nextToken = readNextToken(this, token.end);\n // @ts-expect-error next is only mutable during parsing.\n token.next = nextToken;\n // @ts-expect-error prev is only mutable during parsing.\n nextToken.prev = token;\n token = nextToken;\n }\n } while (token.kind === TokenKind.COMMENT);\n }\n return token;\n }\n}\n\n/**\n * @internal\n */\nexport function isPunctuatorTokenKind(kind: TokenKind): boolean {\n return (\n kind === TokenKind.BANG ||\n kind === TokenKind.DOLLAR ||\n kind === TokenKind.AMP ||\n kind === TokenKind.PAREN_L ||\n kind === TokenKind.PAREN_R ||\n kind === TokenKind.SPREAD ||\n kind === TokenKind.COLON ||\n kind === TokenKind.EQUALS ||\n kind === TokenKind.AT ||\n kind === TokenKind.BRACKET_L ||\n kind === TokenKind.BRACKET_R ||\n kind === TokenKind.BRACE_L ||\n kind === TokenKind.PIPE ||\n kind === TokenKind.BRACE_R\n );\n}\n\n/**\n * A Unicode scalar value is any Unicode code point except surrogate code\n * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and\n * 0xE000 to 0x10FFFF.\n *\n * SourceCharacter ::\n * - \"Any Unicode scalar value\"\n */\nfunction isUnicodeScalarValue(code: number): boolean {\n return (\n (code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff)\n );\n}\n\n/**\n * The GraphQL specification defines source text as a sequence of unicode scalar\n * values (which Unicode defines to exclude surrogate code points). However\n * JavaScript defines strings as a sequence of UTF-16 code units which may\n * include surrogates. A surrogate pair is a valid source character as it\n * encodes a supplementary code point (above U+FFFF), but unpaired surrogate\n * code points are not valid source characters.\n */\nfunction isSupplementaryCodePoint(body: string, location: number): boolean {\n return (\n isLeadingSurrogate(body.charCodeAt(location)) &&\n isTrailingSurrogate(body.charCodeAt(location + 1))\n );\n}\n\nfunction isLeadingSurrogate(code: number): boolean {\n return code >= 0xd800 && code <= 0xdbff;\n}\n\nfunction isTrailingSurrogate(code: number): boolean {\n return code >= 0xdc00 && code <= 0xdfff;\n}\n\n/**\n * Prints the code point (or end of file reference) at a given location in a\n * source for use in error messages.\n *\n * Printable ASCII is printed quoted, while other points are printed in Unicode\n * code point form (ie. U+1234).\n */\nfunction printCodePointAt(lexer: Lexer, location: number): string {\n const code = lexer.source.body.codePointAt(location);\n\n if (code === undefined) {\n return TokenKind.EOF;\n } else if (code >= 0x0020 && code <= 0x007e) {\n // Printable ASCII\n const char = String.fromCodePoint(code);\n return char === '\"' ? \"'\\\"'\" : `\"${char}\"`;\n }\n\n // Unicode code point\n return 'U+' + code.toString(16).toUpperCase().padStart(4, '0');\n}\n\n/**\n * Create a token with line and column location information.\n */\nfunction createToken(\n lexer: Lexer,\n kind: TokenKind,\n start: number,\n end: number,\n value?: string,\n): Token {\n const line = lexer.line;\n const col = 1 + start - lexer.lineStart;\n return new Token(kind, start, end, line, col, value);\n}\n\n/**\n * Gets the next token from the source starting at the given position.\n *\n * This skips over whitespace until it finds the next lexable token, then lexes\n * punctuators immediately or calls the appropriate helper function for more\n * complicated tokens.\n */\nfunction readNextToken(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start;\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // SourceCharacter\n switch (code) {\n // Ignored ::\n // - UnicodeBOM\n // - WhiteSpace\n // - LineTerminator\n // - Comment\n // - Comma\n //\n // UnicodeBOM :: \"Byte Order Mark (U+FEFF)\"\n //\n // WhiteSpace ::\n // - \"Horizontal Tab (U+0009)\"\n // - \"Space (U+0020)\"\n //\n // Comma :: ,\n case 0xfeff: // \n case 0x0009: // \\t\n case 0x0020: // \n case 0x002c: // ,\n ++position;\n continue;\n // LineTerminator ::\n // - \"New Line (U+000A)\"\n // - \"Carriage Return (U+000D)\" [lookahead != \"New Line (U+000A)\"]\n // - \"Carriage Return (U+000D)\" \"New Line (U+000A)\"\n case 0x000a: // \\n\n ++position;\n ++lexer.line;\n lexer.lineStart = position;\n continue;\n case 0x000d: // \\r\n if (body.charCodeAt(position + 1) === 0x000a) {\n position += 2;\n } else {\n ++position;\n }\n ++lexer.line;\n lexer.lineStart = position;\n continue;\n // Comment\n case 0x0023: // #\n return readComment(lexer, position);\n // Token ::\n // - Punctuator\n // - Name\n // - IntValue\n // - FloatValue\n // - StringValue\n //\n // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }\n case 0x0021: // !\n return createToken(lexer, TokenKind.BANG, position, position + 1);\n case 0x0024: // $\n return createToken(lexer, TokenKind.DOLLAR, position, position + 1);\n case 0x0026: // &\n return createToken(lexer, TokenKind.AMP, position, position + 1);\n case 0x0028: // (\n return createToken(lexer, TokenKind.PAREN_L, position, position + 1);\n case 0x0029: // )\n return createToken(lexer, TokenKind.PAREN_R, position, position + 1);\n case 0x002e: {\n // .\n const nextCode = body.charCodeAt(position + 1);\n if (nextCode === 0x002e && body.charCodeAt(position + 2) === 0x002e) {\n return createToken(lexer, TokenKind.SPREAD, position, position + 3);\n }\n if (nextCode === 0x002e) {\n throw syntaxError(\n lexer.source,\n position,\n 'Unexpected \"..\", did you mean \"...\"?',\n );\n } else if (isDigit(nextCode)) {\n const digits = lexer.source.body.slice(\n position + 1,\n readDigits(lexer, position + 1, nextCode),\n );\n throw syntaxError(\n lexer.source,\n position,\n `Invalid number, expected digit before \".\", did you mean \"0.${digits}\"?`,\n );\n }\n break;\n }\n case 0x003a: // :\n return createToken(lexer, TokenKind.COLON, position, position + 1);\n case 0x003d: // =\n return createToken(lexer, TokenKind.EQUALS, position, position + 1);\n case 0x0040: // @\n return createToken(lexer, TokenKind.AT, position, position + 1);\n case 0x005b: // [\n return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);\n case 0x005d: // ]\n return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);\n case 0x007b: // {\n return createToken(lexer, TokenKind.BRACE_L, position, position + 1);\n case 0x007c: // |\n return createToken(lexer, TokenKind.PIPE, position, position + 1);\n case 0x007d: // }\n return createToken(lexer, TokenKind.BRACE_R, position, position + 1);\n // StringValue\n case 0x0022: // \"\n if (\n body.charCodeAt(position + 1) === 0x0022 &&\n body.charCodeAt(position + 2) === 0x0022\n ) {\n return readBlockString(lexer, position);\n }\n return readString(lexer, position);\n }\n\n // IntValue | FloatValue (Digit | -)\n if (isDigit(code) || code === 0x002d) {\n return readNumber(lexer, position, code);\n }\n\n // Name\n if (isNameStart(code)) {\n return readName(lexer, position);\n }\n\n throw syntaxError(\n lexer.source,\n position,\n code === 0x0027\n ? 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?'\n : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position)\n ? `Unexpected character: ${printCodePointAt(lexer, position)}.`\n : `Invalid character: ${printCodePointAt(lexer, position)}.`,\n );\n }\n\n return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);\n}\n\n/**\n * Reads a comment token from the source file.\n *\n * ```\n * Comment :: # CommentChar* [lookahead != CommentChar]\n *\n * CommentChar :: SourceCharacter but not LineTerminator\n * ```\n */\nfunction readComment(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start + 1;\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // LineTerminator (\\n | \\r)\n if (code === 0x000a || code === 0x000d) {\n break;\n }\n\n // SourceCharacter\n if (isUnicodeScalarValue(code)) {\n ++position;\n } else if (isSupplementaryCodePoint(body, position)) {\n position += 2;\n } else {\n break;\n }\n }\n\n return createToken(\n lexer,\n TokenKind.COMMENT,\n start,\n position,\n body.slice(start + 1, position),\n );\n}\n\n/**\n * Reads a number token from the source file, either a FloatValue or an IntValue\n * depending on whether a FractionalPart or ExponentPart is encountered.\n *\n * ```\n * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]\n *\n * IntegerPart ::\n * - NegativeSign? 0\n * - NegativeSign? NonZeroDigit Digit*\n *\n * NegativeSign :: -\n *\n * NonZeroDigit :: Digit but not `0`\n *\n * FloatValue ::\n * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]\n * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]\n * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]\n *\n * FractionalPart :: . Digit+\n *\n * ExponentPart :: ExponentIndicator Sign? Digit+\n *\n * ExponentIndicator :: one of `e` `E`\n *\n * Sign :: one of + -\n * ```\n */\nfunction readNumber(lexer: Lexer, start: number, firstCode: number): Token {\n const body = lexer.source.body;\n let position = start;\n let code = firstCode;\n let isFloat = false;\n\n // NegativeSign (-)\n if (code === 0x002d) {\n code = body.charCodeAt(++position);\n }\n\n // Zero (0)\n if (code === 0x0030) {\n code = body.charCodeAt(++position);\n if (isDigit(code)) {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid number, unexpected digit after 0: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n } else {\n position = readDigits(lexer, position, code);\n code = body.charCodeAt(position);\n }\n\n // Full stop (.)\n if (code === 0x002e) {\n isFloat = true;\n\n code = body.charCodeAt(++position);\n position = readDigits(lexer, position, code);\n code = body.charCodeAt(position);\n }\n\n // E e\n if (code === 0x0045 || code === 0x0065) {\n isFloat = true;\n\n code = body.charCodeAt(++position);\n // + -\n if (code === 0x002b || code === 0x002d) {\n code = body.charCodeAt(++position);\n }\n position = readDigits(lexer, position, code);\n code = body.charCodeAt(position);\n }\n\n // Numbers cannot be followed by . or NameStart\n if (code === 0x002e || isNameStart(code)) {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid number, expected digit but got: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n\n return createToken(\n lexer,\n isFloat ? TokenKind.FLOAT : TokenKind.INT,\n start,\n position,\n body.slice(start, position),\n );\n}\n\n/**\n * Returns the new position in the source after reading one or more digits.\n */\nfunction readDigits(lexer: Lexer, start: number, firstCode: number): number {\n if (!isDigit(firstCode)) {\n throw syntaxError(\n lexer.source,\n start,\n `Invalid number, expected digit but got: ${printCodePointAt(\n lexer,\n start,\n )}.`,\n );\n }\n\n const body = lexer.source.body;\n let position = start + 1; // +1 to skip first firstCode\n\n while (isDigit(body.charCodeAt(position))) {\n ++position;\n }\n\n return position;\n}\n\n/**\n * Reads a single-quote string token from the source file.\n *\n * ```\n * StringValue ::\n * - `\"\"` [lookahead != `\"`]\n * - `\"` StringCharacter+ `\"`\n *\n * StringCharacter ::\n * - SourceCharacter but not `\"` or `\\` or LineTerminator\n * - `\\u` EscapedUnicode\n * - `\\` EscapedCharacter\n *\n * EscapedUnicode ::\n * - `{` HexDigit+ `}`\n * - HexDigit HexDigit HexDigit HexDigit\n *\n * EscapedCharacter :: one of `\"` `\\` `/` `b` `f` `n` `r` `t`\n * ```\n */\nfunction readString(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start + 1;\n let chunkStart = position;\n let value = '';\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // Closing Quote (\")\n if (code === 0x0022) {\n value += body.slice(chunkStart, position);\n return createToken(lexer, TokenKind.STRING, start, position + 1, value);\n }\n\n // Escape Sequence (\\)\n if (code === 0x005c) {\n value += body.slice(chunkStart, position);\n const escape =\n body.charCodeAt(position + 1) === 0x0075 // u\n ? body.charCodeAt(position + 2) === 0x007b // {\n ? readEscapedUnicodeVariableWidth(lexer, position)\n : readEscapedUnicodeFixedWidth(lexer, position)\n : readEscapedCharacter(lexer, position);\n value += escape.value;\n position += escape.size;\n chunkStart = position;\n continue;\n }\n\n // LineTerminator (\\n | \\r)\n if (code === 0x000a || code === 0x000d) {\n break;\n }\n\n // SourceCharacter\n if (isUnicodeScalarValue(code)) {\n ++position;\n } else if (isSupplementaryCodePoint(body, position)) {\n position += 2;\n } else {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid character within String: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n }\n\n throw syntaxError(lexer.source, position, 'Unterminated string.');\n}\n\n// The string value and lexed size of an escape sequence.\ninterface EscapeSequence {\n value: string;\n size: number;\n}\n\nfunction readEscapedUnicodeVariableWidth(\n lexer: Lexer,\n position: number,\n): EscapeSequence {\n const body = lexer.source.body;\n let point = 0;\n let size = 3;\n // Cannot be larger than 12 chars (\\u{00000000}).\n while (size < 12) {\n const code = body.charCodeAt(position + size++);\n // Closing Brace (})\n if (code === 0x007d) {\n // Must be at least 5 chars (\\u{0}) and encode a Unicode scalar value.\n if (size < 5 || !isUnicodeScalarValue(point)) {\n break;\n }\n return { value: String.fromCodePoint(point), size };\n }\n // Append this hex digit to the code point.\n point = (point << 4) | readHexDigit(code);\n if (point < 0) {\n break;\n }\n }\n\n throw syntaxError(\n lexer.source,\n position,\n `Invalid Unicode escape sequence: \"${body.slice(\n position,\n position + size,\n )}\".`,\n );\n}\n\nfunction readEscapedUnicodeFixedWidth(\n lexer: Lexer,\n position: number,\n): EscapeSequence {\n const body = lexer.source.body;\n const code = read16BitHexCode(body, position + 2);\n\n if (isUnicodeScalarValue(code)) {\n return { value: String.fromCodePoint(code), size: 6 };\n }\n\n // GraphQL allows JSON-style surrogate pair escape sequences, but only when\n // a valid pair is formed.\n if (isLeadingSurrogate(code)) {\n // \\u\n if (\n body.charCodeAt(position + 6) === 0x005c &&\n body.charCodeAt(position + 7) === 0x0075\n ) {\n const trailingCode = read16BitHexCode(body, position + 8);\n if (isTrailingSurrogate(trailingCode)) {\n // JavaScript defines strings as a sequence of UTF-16 code units and\n // encodes Unicode code points above U+FFFF using a surrogate pair of\n // code units. Since this is a surrogate pair escape sequence, just\n // include both codes into the JavaScript string value. Had JavaScript\n // not been internally based on UTF-16, then this surrogate pair would\n // be decoded to retrieve the supplementary code point.\n return { value: String.fromCodePoint(code, trailingCode), size: 12 };\n }\n }\n }\n\n throw syntaxError(\n lexer.source,\n position,\n `Invalid Unicode escape sequence: \"${body.slice(position, position + 6)}\".`,\n );\n}\n\n/**\n * Reads four hexadecimal characters and returns the positive integer that 16bit\n * hexadecimal string represents. For example, \"000f\" will return 15, and \"dead\"\n * will return 57005.\n *\n * Returns a negative number if any char was not a valid hexadecimal digit.\n */\nfunction read16BitHexCode(body: string, position: number): number {\n // readHexDigit() returns -1 on error. ORing a negative value with any other\n // value always produces a negative value.\n return (\n (readHexDigit(body.charCodeAt(position)) << 12) |\n (readHexDigit(body.charCodeAt(position + 1)) << 8) |\n (readHexDigit(body.charCodeAt(position + 2)) << 4) |\n readHexDigit(body.charCodeAt(position + 3))\n );\n}\n\n/**\n * Reads a hexadecimal character and returns its positive integer value (0-15).\n *\n * '0' becomes 0, '9' becomes 9\n * 'A' becomes 10, 'F' becomes 15\n * 'a' becomes 10, 'f' becomes 15\n *\n * Returns -1 if the provided character code was not a valid hexadecimal digit.\n *\n * HexDigit :: one of\n * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`\n * - `A` `B` `C` `D` `E` `F`\n * - `a` `b` `c` `d` `e` `f`\n */\nfunction readHexDigit(code: number): number {\n return code >= 0x0030 && code <= 0x0039 // 0-9\n ? code - 0x0030\n : code >= 0x0041 && code <= 0x0046 // A-F\n ? code - 0x0037\n : code >= 0x0061 && code <= 0x0066 // a-f\n ? code - 0x0057\n : -1;\n}\n\n/**\n * | Escaped Character | Code Point | Character Name |\n * | ----------------- | ---------- | ---------------------------- |\n * | `\"` | U+0022 | double quote |\n * | `\\` | U+005C | reverse solidus (back slash) |\n * | `/` | U+002F | solidus (forward slash) |\n * | `b` | U+0008 | backspace |\n * | `f` | U+000C | form feed |\n * | `n` | U+000A | line feed (new line) |\n * | `r` | U+000D | carriage return |\n * | `t` | U+0009 | horizontal tab |\n */\nfunction readEscapedCharacter(lexer: Lexer, position: number): EscapeSequence {\n const body = lexer.source.body;\n const code = body.charCodeAt(position + 1);\n switch (code) {\n case 0x0022: // \"\n return { value: '\\u0022', size: 2 };\n case 0x005c: // \\\n return { value: '\\u005c', size: 2 };\n case 0x002f: // /\n return { value: '\\u002f', size: 2 };\n case 0x0062: // b\n return { value: '\\u0008', size: 2 };\n case 0x0066: // f\n return { value: '\\u000c', size: 2 };\n case 0x006e: // n\n return { value: '\\u000a', size: 2 };\n case 0x0072: // r\n return { value: '\\u000d', size: 2 };\n case 0x0074: // t\n return { value: '\\u0009', size: 2 };\n }\n throw syntaxError(\n lexer.source,\n position,\n `Invalid character escape sequence: \"${body.slice(\n position,\n position + 2,\n )}\".`,\n );\n}\n\n/**\n * Reads a block string token from the source file.\n *\n * ```\n * StringValue ::\n * - `\"\"\"` BlockStringCharacter* `\"\"\"`\n *\n * BlockStringCharacter ::\n * - SourceCharacter but not `\"\"\"` or `\\\"\"\"`\n * - `\\\"\"\"`\n * ```\n */\nfunction readBlockString(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let lineStart = lexer.lineStart;\n\n let position = start + 3;\n let chunkStart = position;\n let currentLine = '';\n\n const blockLines = [];\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // Closing Triple-Quote (\"\"\")\n if (\n code === 0x0022 &&\n body.charCodeAt(position + 1) === 0x0022 &&\n body.charCodeAt(position + 2) === 0x0022\n ) {\n currentLine += body.slice(chunkStart, position);\n blockLines.push(currentLine);\n\n const token = createToken(\n lexer,\n TokenKind.BLOCK_STRING,\n start,\n position + 3,\n // Return a string of the lines joined with U+000A.\n dedentBlockStringLines(blockLines).join('\\n'),\n );\n\n lexer.line += blockLines.length - 1;\n lexer.lineStart = lineStart;\n return token;\n }\n\n // Escaped Triple-Quote (\\\"\"\")\n if (\n code === 0x005c &&\n body.charCodeAt(position + 1) === 0x0022 &&\n body.charCodeAt(position + 2) === 0x0022 &&\n body.charCodeAt(position + 3) === 0x0022\n ) {\n currentLine += body.slice(chunkStart, position);\n chunkStart = position + 1; // skip only slash\n position += 4;\n continue;\n }\n\n // LineTerminator\n if (code === 0x000a || code === 0x000d) {\n currentLine += body.slice(chunkStart, position);\n blockLines.push(currentLine);\n\n if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) {\n position += 2;\n } else {\n ++position;\n }\n\n currentLine = '';\n chunkStart = position;\n lineStart = position;\n continue;\n }\n\n // SourceCharacter\n if (isUnicodeScalarValue(code)) {\n ++position;\n } else if (isSupplementaryCodePoint(body, position)) {\n position += 2;\n } else {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid character within String: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n }\n\n throw syntaxError(lexer.source, position, 'Unterminated string.');\n}\n\n/**\n * Reads an alphanumeric + underscore name from the source.\n *\n * ```\n * Name ::\n * - NameStart NameContinue* [lookahead != NameContinue]\n * ```\n */\nfunction readName(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start + 1;\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n if (isNameContinue(code)) {\n ++position;\n } else {\n break;\n }\n }\n\n return createToken(\n lexer,\n TokenKind.NAME,\n start,\n position,\n body.slice(start, position),\n );\n}\n"]} \ No newline at end of file diff --git a/language/lexer.mjs b/language/lexer.mjs new file mode 100644 index 0000000000..c91e3b60f6 --- /dev/null +++ b/language/lexer.mjs @@ -0,0 +1,665 @@ +import { syntaxError } from "../error/syntaxError.mjs"; +import { Token } from "./ast.mjs"; +import { dedentBlockStringLines } from "./blockString.mjs"; +import { isDigit, isNameContinue, isNameStart } from "./characterClasses.mjs"; +import { TokenKind } from "./tokenKind.mjs"; +/** + * Given a Source object, creates a Lexer for that source. + * A Lexer is a stateful stream generator in that every time + * it is advanced, it returns the next token in the Source. Assuming the + * source lexes, the final Token emitted by the lexer will be of kind + * EOF, after which the lexer will repeatedly return the same EOF token + * whenever called. + */ +export class Lexer { + constructor(source) { + const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0); + this.source = source; + this.lastToken = startOfFileToken; + this.token = startOfFileToken; + this.line = 1; + this.lineStart = 0; + } + get [Symbol.toStringTag]() { + return 'Lexer'; + } + /** + * Advances the token stream to the next non-ignored token. + */ + advance() { + this.lastToken = this.token; + const token = (this.token = this.lookahead()); + return token; + } + /** + * Looks ahead and returns the next non-ignored token, but does not change + * the current Lexer token. + */ + lookahead() { + let token = this.token; + if (token.kind !== TokenKind.EOF) { + do { + if (token.next) { + token = token.next; + } + else { + // Read the next token and form a link in the token linked-list. + const nextToken = readNextToken(this, token.end); + // @ts-expect-error next is only mutable during parsing. + token.next = nextToken; + // @ts-expect-error prev is only mutable during parsing. + nextToken.prev = token; + token = nextToken; + } + } while (token.kind === TokenKind.COMMENT); + } + return token; + } +} +/** + * @internal + */ +export function isPunctuatorTokenKind(kind) { + return (kind === TokenKind.BANG || + kind === TokenKind.DOLLAR || + kind === TokenKind.AMP || + kind === TokenKind.PAREN_L || + kind === TokenKind.PAREN_R || + kind === TokenKind.SPREAD || + kind === TokenKind.COLON || + kind === TokenKind.EQUALS || + kind === TokenKind.AT || + kind === TokenKind.BRACKET_L || + kind === TokenKind.BRACKET_R || + kind === TokenKind.BRACE_L || + kind === TokenKind.PIPE || + kind === TokenKind.BRACE_R); +} +/** + * A Unicode scalar value is any Unicode code point except surrogate code + * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and + * 0xE000 to 0x10FFFF. + * + * SourceCharacter :: + * - "Any Unicode scalar value" + */ +function isUnicodeScalarValue(code) { + return ((code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff)); +} +/** + * The GraphQL specification defines source text as a sequence of unicode scalar + * values (which Unicode defines to exclude surrogate code points). However + * JavaScript defines strings as a sequence of UTF-16 code units which may + * include surrogates. A surrogate pair is a valid source character as it + * encodes a supplementary code point (above U+FFFF), but unpaired surrogate + * code points are not valid source characters. + */ +function isSupplementaryCodePoint(body, location) { + return (isLeadingSurrogate(body.charCodeAt(location)) && + isTrailingSurrogate(body.charCodeAt(location + 1))); +} +function isLeadingSurrogate(code) { + return code >= 0xd800 && code <= 0xdbff; +} +function isTrailingSurrogate(code) { + return code >= 0xdc00 && code <= 0xdfff; +} +/** + * Prints the code point (or end of file reference) at a given location in a + * source for use in error messages. + * + * Printable ASCII is printed quoted, while other points are printed in Unicode + * code point form (ie. U+1234). + */ +function printCodePointAt(lexer, location) { + const code = lexer.source.body.codePointAt(location); + if (code === undefined) { + return TokenKind.EOF; + } + else if (code >= 0x0020 && code <= 0x007e) { + // Printable ASCII + const char = String.fromCodePoint(code); + return char === '"' ? "'\"'" : `"${char}"`; + } + // Unicode code point + return 'U+' + code.toString(16).toUpperCase().padStart(4, '0'); +} +/** + * Create a token with line and column location information. + */ +function createToken(lexer, kind, start, end, value) { + const line = lexer.line; + const col = 1 + start - lexer.lineStart; + return new Token(kind, start, end, line, col, value); +} +/** + * Gets the next token from the source starting at the given position. + * + * This skips over whitespace until it finds the next lexable token, then lexes + * punctuators immediately or calls the appropriate helper function for more + * complicated tokens. + */ +function readNextToken(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // SourceCharacter + switch (code) { + // Ignored :: + // - UnicodeBOM + // - WhiteSpace + // - LineTerminator + // - Comment + // - Comma + // + // UnicodeBOM :: "Byte Order Mark (U+FEFF)" + // + // WhiteSpace :: + // - "Horizontal Tab (U+0009)" + // - "Space (U+0020)" + // + // Comma :: , + case 0xfeff: // + case 0x0009: // \t + case 0x0020: // + case 0x002c: // , + ++position; + continue; + // LineTerminator :: + // - "New Line (U+000A)" + // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"] + // - "Carriage Return (U+000D)" "New Line (U+000A)" + case 0x000a: // \n + ++position; + ++lexer.line; + lexer.lineStart = position; + continue; + case 0x000d: // \r + if (body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } + else { + ++position; + } + ++lexer.line; + lexer.lineStart = position; + continue; + // Comment + case 0x0023: // # + return readComment(lexer, position); + // Token :: + // - Punctuator + // - Name + // - IntValue + // - FloatValue + // - StringValue + // + // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } + case 0x0021: // ! + return createToken(lexer, TokenKind.BANG, position, position + 1); + case 0x0024: // $ + return createToken(lexer, TokenKind.DOLLAR, position, position + 1); + case 0x0026: // & + return createToken(lexer, TokenKind.AMP, position, position + 1); + case 0x0028: // ( + return createToken(lexer, TokenKind.PAREN_L, position, position + 1); + case 0x0029: // ) + return createToken(lexer, TokenKind.PAREN_R, position, position + 1); + case 0x002e: { + // . + const nextCode = body.charCodeAt(position + 1); + if (nextCode === 0x002e && body.charCodeAt(position + 2) === 0x002e) { + return createToken(lexer, TokenKind.SPREAD, position, position + 3); + } + if (nextCode === 0x002e) { + throw syntaxError(lexer.source, position, 'Unexpected "..", did you mean "..."?'); + } + else if (isDigit(nextCode)) { + const digits = lexer.source.body.slice(position + 1, readDigits(lexer, position + 1, nextCode)); + throw syntaxError(lexer.source, position, `Invalid number, expected digit before ".", did you mean "0.${digits}"?`); + } + break; + } + case 0x003a: // : + return createToken(lexer, TokenKind.COLON, position, position + 1); + case 0x003d: // = + return createToken(lexer, TokenKind.EQUALS, position, position + 1); + case 0x0040: // @ + return createToken(lexer, TokenKind.AT, position, position + 1); + case 0x005b: // [ + return createToken(lexer, TokenKind.BRACKET_L, position, position + 1); + case 0x005d: // ] + return createToken(lexer, TokenKind.BRACKET_R, position, position + 1); + case 0x007b: // { + return createToken(lexer, TokenKind.BRACE_L, position, position + 1); + case 0x007c: // | + return createToken(lexer, TokenKind.PIPE, position, position + 1); + case 0x007d: // } + return createToken(lexer, TokenKind.BRACE_R, position, position + 1); + // StringValue + case 0x0022: // " + if (body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022) { + return readBlockString(lexer, position); + } + return readString(lexer, position); + } + // IntValue | FloatValue (Digit | -) + if (isDigit(code) || code === 0x002d) { + return readNumber(lexer, position, code); + } + // Name + if (isNameStart(code)) { + return readName(lexer, position); + } + throw syntaxError(lexer.source, position, code === 0x0027 + ? 'Unexpected single quote character (\'), did you mean to use a double quote (")?' + : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) + ? `Unexpected character: ${printCodePointAt(lexer, position)}.` + : `Invalid character: ${printCodePointAt(lexer, position)}.`); + } + return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength); +} +/** + * Reads a comment token from the source file. + * + * ``` + * Comment :: # CommentChar* [lookahead != CommentChar] + * + * CommentChar :: SourceCharacter but not LineTerminator + * ``` + */ +function readComment(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // LineTerminator (\n | \r) + if (code === 0x000a || code === 0x000d) { + break; + } + // SourceCharacter + if (isUnicodeScalarValue(code)) { + ++position; + } + else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } + else { + break; + } + } + return createToken(lexer, TokenKind.COMMENT, start, position, body.slice(start + 1, position)); +} +/** + * Reads a number token from the source file, either a FloatValue or an IntValue + * depending on whether a FractionalPart or ExponentPart is encountered. + * + * ``` + * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}] + * + * IntegerPart :: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit Digit* + * + * NegativeSign :: - + * + * NonZeroDigit :: Digit but not `0` + * + * FloatValue :: + * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * + * FractionalPart :: . Digit+ + * + * ExponentPart :: ExponentIndicator Sign? Digit+ + * + * ExponentIndicator :: one of `e` `E` + * + * Sign :: one of + - + * ``` + */ +function readNumber(lexer, start, firstCode) { + const body = lexer.source.body; + let position = start; + let code = firstCode; + let isFloat = false; + // NegativeSign (-) + if (code === 0x002d) { + code = body.charCodeAt(++position); + } + // Zero (0) + if (code === 0x0030) { + code = body.charCodeAt(++position); + if (isDigit(code)) { + throw syntaxError(lexer.source, position, `Invalid number, unexpected digit after 0: ${printCodePointAt(lexer, position)}.`); + } + } + else { + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } + // Full stop (.) + if (code === 0x002e) { + isFloat = true; + code = body.charCodeAt(++position); + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } + // E e + if (code === 0x0045 || code === 0x0065) { + isFloat = true; + code = body.charCodeAt(++position); + // + - + if (code === 0x002b || code === 0x002d) { + code = body.charCodeAt(++position); + } + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } + // Numbers cannot be followed by . or NameStart + if (code === 0x002e || isNameStart(code)) { + throw syntaxError(lexer.source, position, `Invalid number, expected digit but got: ${printCodePointAt(lexer, position)}.`); + } + return createToken(lexer, isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, body.slice(start, position)); +} +/** + * Returns the new position in the source after reading one or more digits. + */ +function readDigits(lexer, start, firstCode) { + if (!isDigit(firstCode)) { + throw syntaxError(lexer.source, start, `Invalid number, expected digit but got: ${printCodePointAt(lexer, start)}.`); + } + const body = lexer.source.body; + let position = start + 1; // +1 to skip first firstCode + while (isDigit(body.charCodeAt(position))) { + ++position; + } + return position; +} +/** + * Reads a single-quote string token from the source file. + * + * ``` + * StringValue :: + * - `""` [lookahead != `"`] + * - `"` StringCharacter+ `"` + * + * StringCharacter :: + * - SourceCharacter but not `"` or `\` or LineTerminator + * - `\u` EscapedUnicode + * - `\` EscapedCharacter + * + * EscapedUnicode :: + * - `{` HexDigit+ `}` + * - HexDigit HexDigit HexDigit HexDigit + * + * EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t` + * ``` + */ +function readString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + let chunkStart = position; + let value = ''; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // Closing Quote (") + if (code === 0x0022) { + value += body.slice(chunkStart, position); + return createToken(lexer, TokenKind.STRING, start, position + 1, value); + } + // Escape Sequence (\) + if (code === 0x005c) { + value += body.slice(chunkStart, position); + const escape = body.charCodeAt(position + 1) === 0x0075 // u + ? body.charCodeAt(position + 2) === 0x007b // { + ? readEscapedUnicodeVariableWidth(lexer, position) + : readEscapedUnicodeFixedWidth(lexer, position) + : readEscapedCharacter(lexer, position); + value += escape.value; + position += escape.size; + chunkStart = position; + continue; + } + // LineTerminator (\n | \r) + if (code === 0x000a || code === 0x000d) { + break; + } + // SourceCharacter + if (isUnicodeScalarValue(code)) { + ++position; + } + else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } + else { + throw syntaxError(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`); + } + } + throw syntaxError(lexer.source, position, 'Unterminated string.'); +} +function readEscapedUnicodeVariableWidth(lexer, position) { + const body = lexer.source.body; + let point = 0; + let size = 3; + // Cannot be larger than 12 chars (\u{00000000}). + while (size < 12) { + const code = body.charCodeAt(position + size++); + // Closing Brace (}) + if (code === 0x007d) { + // Must be at least 5 chars (\u{0}) and encode a Unicode scalar value. + if (size < 5 || !isUnicodeScalarValue(point)) { + break; + } + return { value: String.fromCodePoint(point), size }; + } + // Append this hex digit to the code point. + point = (point << 4) | readHexDigit(code); + if (point < 0) { + break; + } + } + throw syntaxError(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + size)}".`); +} +function readEscapedUnicodeFixedWidth(lexer, position) { + const body = lexer.source.body; + const code = read16BitHexCode(body, position + 2); + if (isUnicodeScalarValue(code)) { + return { value: String.fromCodePoint(code), size: 6 }; + } + // GraphQL allows JSON-style surrogate pair escape sequences, but only when + // a valid pair is formed. + if (isLeadingSurrogate(code)) { + // \u + if (body.charCodeAt(position + 6) === 0x005c && + body.charCodeAt(position + 7) === 0x0075) { + const trailingCode = read16BitHexCode(body, position + 8); + if (isTrailingSurrogate(trailingCode)) { + // JavaScript defines strings as a sequence of UTF-16 code units and + // encodes Unicode code points above U+FFFF using a surrogate pair of + // code units. Since this is a surrogate pair escape sequence, just + // include both codes into the JavaScript string value. Had JavaScript + // not been internally based on UTF-16, then this surrogate pair would + // be decoded to retrieve the supplementary code point. + return { value: String.fromCodePoint(code, trailingCode), size: 12 }; + } + } + } + throw syntaxError(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`); +} +/** + * Reads four hexadecimal characters and returns the positive integer that 16bit + * hexadecimal string represents. For example, "000f" will return 15, and "dead" + * will return 57005. + * + * Returns a negative number if any char was not a valid hexadecimal digit. + */ +function read16BitHexCode(body, position) { + // readHexDigit() returns -1 on error. ORing a negative value with any other + // value always produces a negative value. + return ((readHexDigit(body.charCodeAt(position)) << 12) | + (readHexDigit(body.charCodeAt(position + 1)) << 8) | + (readHexDigit(body.charCodeAt(position + 2)) << 4) | + readHexDigit(body.charCodeAt(position + 3))); +} +/** + * Reads a hexadecimal character and returns its positive integer value (0-15). + * + * '0' becomes 0, '9' becomes 9 + * 'A' becomes 10, 'F' becomes 15 + * 'a' becomes 10, 'f' becomes 15 + * + * Returns -1 if the provided character code was not a valid hexadecimal digit. + * + * HexDigit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * - `A` `B` `C` `D` `E` `F` + * - `a` `b` `c` `d` `e` `f` + */ +function readHexDigit(code) { + return code >= 0x0030 && code <= 0x0039 // 0-9 + ? code - 0x0030 + : code >= 0x0041 && code <= 0x0046 // A-F + ? code - 0x0037 + : code >= 0x0061 && code <= 0x0066 // a-f + ? code - 0x0057 + : -1; +} +/** + * | Escaped Character | Code Point | Character Name | + * | ----------------- | ---------- | ---------------------------- | + * | `"` | U+0022 | double quote | + * | `\` | U+005C | reverse solidus (back slash) | + * | `/` | U+002F | solidus (forward slash) | + * | `b` | U+0008 | backspace | + * | `f` | U+000C | form feed | + * | `n` | U+000A | line feed (new line) | + * | `r` | U+000D | carriage return | + * | `t` | U+0009 | horizontal tab | + */ +function readEscapedCharacter(lexer, position) { + const body = lexer.source.body; + const code = body.charCodeAt(position + 1); + switch (code) { + case 0x0022: // " + return { value: '\u0022', size: 2 }; + case 0x005c: // \ + return { value: '\u005c', size: 2 }; + case 0x002f: // / + return { value: '\u002f', size: 2 }; + case 0x0062: // b + return { value: '\u0008', size: 2 }; + case 0x0066: // f + return { value: '\u000c', size: 2 }; + case 0x006e: // n + return { value: '\u000a', size: 2 }; + case 0x0072: // r + return { value: '\u000d', size: 2 }; + case 0x0074: // t + return { value: '\u0009', size: 2 }; + } + throw syntaxError(lexer.source, position, `Invalid character escape sequence: "${body.slice(position, position + 2)}".`); +} +/** + * Reads a block string token from the source file. + * + * ``` + * StringValue :: + * - `"""` BlockStringCharacter* `"""` + * + * BlockStringCharacter :: + * - SourceCharacter but not `"""` or `\"""` + * - `\"""` + * ``` + */ +function readBlockString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let lineStart = lexer.lineStart; + let position = start + 3; + let chunkStart = position; + let currentLine = ''; + const blockLines = []; + while (position < bodyLength) { + const code = body.charCodeAt(position); + // Closing Triple-Quote (""") + if (code === 0x0022 && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + const token = createToken(lexer, TokenKind.BLOCK_STRING, start, position + 3, + // Return a string of the lines joined with U+000A. + dedentBlockStringLines(blockLines).join('\n')); + lexer.line += blockLines.length - 1; + lexer.lineStart = lineStart; + return token; + } + // Escaped Triple-Quote (\""") + if (code === 0x005c && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 && + body.charCodeAt(position + 3) === 0x0022) { + currentLine += body.slice(chunkStart, position); + chunkStart = position + 1; // skip only slash + position += 4; + continue; + } + // LineTerminator + if (code === 0x000a || code === 0x000d) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } + else { + ++position; + } + currentLine = ''; + chunkStart = position; + lineStart = position; + continue; + } + // SourceCharacter + if (isUnicodeScalarValue(code)) { + ++position; + } + else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } + else { + throw syntaxError(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`); + } + } + throw syntaxError(lexer.source, position, 'Unterminated string.'); +} +/** + * Reads an alphanumeric + underscore name from the source. + * + * ``` + * Name :: + * - NameStart NameContinue* [lookahead != NameContinue] + * ``` + */ +function readName(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + while (position < bodyLength) { + const code = body.charCodeAt(position); + if (isNameContinue(code)) { + ++position; + } + else { + break; + } + } + return createToken(lexer, TokenKind.NAME, start, position, body.slice(start, position)); +} +//# sourceMappingURL=lexer.js.map \ No newline at end of file diff --git a/language/lexer.mjs.map b/language/lexer.mjs.map new file mode 100644 index 0000000000..c356a4d8b5 --- /dev/null +++ b/language/lexer.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../src/language/lexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iCAAgC;AAEtD,OAAO,EAAE,KAAK,EAAE,kBAAiB;AACjC,OAAO,EAAE,sBAAsB,EAAE,0BAAyB;AAC1D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,+BAA8B;AAE7E,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAE3C;;;;;;;GAOG;AACH,MAAM,OAAO,KAAK;IAuBhB,YAAY,MAAc;QACxB,MAAM,gBAAgB,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE9D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,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C,EAAE,CAAC;YACzB,EAAE,QAAQ,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAChB,KAAK,EACL,SAAS,CAAC,IAAI,EACd,KAAK,EACL,QAAQ,EACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { syntaxError } from '../error/syntaxError.js';\n\nimport { Token } from './ast.js';\nimport { dedentBlockStringLines } from './blockString.js';\nimport { isDigit, isNameContinue, isNameStart } from './characterClasses.js';\nimport type { Source } from './source.js';\nimport { TokenKind } from './tokenKind.js';\n\n/**\n * Given a Source object, creates a Lexer for that source.\n * A Lexer is a stateful stream generator in that every time\n * it is advanced, it returns the next token in the Source. Assuming the\n * source lexes, the final Token emitted by the lexer will be of kind\n * EOF, after which the lexer will repeatedly return the same EOF token\n * whenever called.\n */\nexport class Lexer {\n source: Source;\n\n /**\n * The previously focused non-ignored token.\n */\n lastToken: Token;\n\n /**\n * The currently focused non-ignored token.\n */\n token: Token;\n\n /**\n * The (1-indexed) line containing the current token.\n */\n line: number;\n\n /**\n * The character offset at which the current line begins.\n */\n lineStart: number;\n\n constructor(source: Source) {\n const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);\n\n this.source = source;\n this.lastToken = startOfFileToken;\n this.token = startOfFileToken;\n this.line = 1;\n this.lineStart = 0;\n }\n\n get [Symbol.toStringTag]() {\n return 'Lexer';\n }\n\n /**\n * Advances the token stream to the next non-ignored token.\n */\n advance(): Token {\n this.lastToken = this.token;\n const token = (this.token = this.lookahead());\n return token;\n }\n\n /**\n * Looks ahead and returns the next non-ignored token, but does not change\n * the current Lexer token.\n */\n lookahead(): Token {\n let token = this.token;\n if (token.kind !== TokenKind.EOF) {\n do {\n if (token.next) {\n token = token.next;\n } else {\n // Read the next token and form a link in the token linked-list.\n const nextToken = readNextToken(this, token.end);\n // @ts-expect-error next is only mutable during parsing.\n token.next = nextToken;\n // @ts-expect-error prev is only mutable during parsing.\n nextToken.prev = token;\n token = nextToken;\n }\n } while (token.kind === TokenKind.COMMENT);\n }\n return token;\n }\n}\n\n/**\n * @internal\n */\nexport function isPunctuatorTokenKind(kind: TokenKind): boolean {\n return (\n kind === TokenKind.BANG ||\n kind === TokenKind.DOLLAR ||\n kind === TokenKind.AMP ||\n kind === TokenKind.PAREN_L ||\n kind === TokenKind.PAREN_R ||\n kind === TokenKind.SPREAD ||\n kind === TokenKind.COLON ||\n kind === TokenKind.EQUALS ||\n kind === TokenKind.AT ||\n kind === TokenKind.BRACKET_L ||\n kind === TokenKind.BRACKET_R ||\n kind === TokenKind.BRACE_L ||\n kind === TokenKind.PIPE ||\n kind === TokenKind.BRACE_R\n );\n}\n\n/**\n * A Unicode scalar value is any Unicode code point except surrogate code\n * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and\n * 0xE000 to 0x10FFFF.\n *\n * SourceCharacter ::\n * - \"Any Unicode scalar value\"\n */\nfunction isUnicodeScalarValue(code: number): boolean {\n return (\n (code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff)\n );\n}\n\n/**\n * The GraphQL specification defines source text as a sequence of unicode scalar\n * values (which Unicode defines to exclude surrogate code points). However\n * JavaScript defines strings as a sequence of UTF-16 code units which may\n * include surrogates. A surrogate pair is a valid source character as it\n * encodes a supplementary code point (above U+FFFF), but unpaired surrogate\n * code points are not valid source characters.\n */\nfunction isSupplementaryCodePoint(body: string, location: number): boolean {\n return (\n isLeadingSurrogate(body.charCodeAt(location)) &&\n isTrailingSurrogate(body.charCodeAt(location + 1))\n );\n}\n\nfunction isLeadingSurrogate(code: number): boolean {\n return code >= 0xd800 && code <= 0xdbff;\n}\n\nfunction isTrailingSurrogate(code: number): boolean {\n return code >= 0xdc00 && code <= 0xdfff;\n}\n\n/**\n * Prints the code point (or end of file reference) at a given location in a\n * source for use in error messages.\n *\n * Printable ASCII is printed quoted, while other points are printed in Unicode\n * code point form (ie. U+1234).\n */\nfunction printCodePointAt(lexer: Lexer, location: number): string {\n const code = lexer.source.body.codePointAt(location);\n\n if (code === undefined) {\n return TokenKind.EOF;\n } else if (code >= 0x0020 && code <= 0x007e) {\n // Printable ASCII\n const char = String.fromCodePoint(code);\n return char === '\"' ? \"'\\\"'\" : `\"${char}\"`;\n }\n\n // Unicode code point\n return 'U+' + code.toString(16).toUpperCase().padStart(4, '0');\n}\n\n/**\n * Create a token with line and column location information.\n */\nfunction createToken(\n lexer: Lexer,\n kind: TokenKind,\n start: number,\n end: number,\n value?: string,\n): Token {\n const line = lexer.line;\n const col = 1 + start - lexer.lineStart;\n return new Token(kind, start, end, line, col, value);\n}\n\n/**\n * Gets the next token from the source starting at the given position.\n *\n * This skips over whitespace until it finds the next lexable token, then lexes\n * punctuators immediately or calls the appropriate helper function for more\n * complicated tokens.\n */\nfunction readNextToken(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start;\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // SourceCharacter\n switch (code) {\n // Ignored ::\n // - UnicodeBOM\n // - WhiteSpace\n // - LineTerminator\n // - Comment\n // - Comma\n //\n // UnicodeBOM :: \"Byte Order Mark (U+FEFF)\"\n //\n // WhiteSpace ::\n // - \"Horizontal Tab (U+0009)\"\n // - \"Space (U+0020)\"\n //\n // Comma :: ,\n case 0xfeff: // \n case 0x0009: // \\t\n case 0x0020: // \n case 0x002c: // ,\n ++position;\n continue;\n // LineTerminator ::\n // - \"New Line (U+000A)\"\n // - \"Carriage Return (U+000D)\" [lookahead != \"New Line (U+000A)\"]\n // - \"Carriage Return (U+000D)\" \"New Line (U+000A)\"\n case 0x000a: // \\n\n ++position;\n ++lexer.line;\n lexer.lineStart = position;\n continue;\n case 0x000d: // \\r\n if (body.charCodeAt(position + 1) === 0x000a) {\n position += 2;\n } else {\n ++position;\n }\n ++lexer.line;\n lexer.lineStart = position;\n continue;\n // Comment\n case 0x0023: // #\n return readComment(lexer, position);\n // Token ::\n // - Punctuator\n // - Name\n // - IntValue\n // - FloatValue\n // - StringValue\n //\n // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }\n case 0x0021: // !\n return createToken(lexer, TokenKind.BANG, position, position + 1);\n case 0x0024: // $\n return createToken(lexer, TokenKind.DOLLAR, position, position + 1);\n case 0x0026: // &\n return createToken(lexer, TokenKind.AMP, position, position + 1);\n case 0x0028: // (\n return createToken(lexer, TokenKind.PAREN_L, position, position + 1);\n case 0x0029: // )\n return createToken(lexer, TokenKind.PAREN_R, position, position + 1);\n case 0x002e: {\n // .\n const nextCode = body.charCodeAt(position + 1);\n if (nextCode === 0x002e && body.charCodeAt(position + 2) === 0x002e) {\n return createToken(lexer, TokenKind.SPREAD, position, position + 3);\n }\n if (nextCode === 0x002e) {\n throw syntaxError(\n lexer.source,\n position,\n 'Unexpected \"..\", did you mean \"...\"?',\n );\n } else if (isDigit(nextCode)) {\n const digits = lexer.source.body.slice(\n position + 1,\n readDigits(lexer, position + 1, nextCode),\n );\n throw syntaxError(\n lexer.source,\n position,\n `Invalid number, expected digit before \".\", did you mean \"0.${digits}\"?`,\n );\n }\n break;\n }\n case 0x003a: // :\n return createToken(lexer, TokenKind.COLON, position, position + 1);\n case 0x003d: // =\n return createToken(lexer, TokenKind.EQUALS, position, position + 1);\n case 0x0040: // @\n return createToken(lexer, TokenKind.AT, position, position + 1);\n case 0x005b: // [\n return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);\n case 0x005d: // ]\n return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);\n case 0x007b: // {\n return createToken(lexer, TokenKind.BRACE_L, position, position + 1);\n case 0x007c: // |\n return createToken(lexer, TokenKind.PIPE, position, position + 1);\n case 0x007d: // }\n return createToken(lexer, TokenKind.BRACE_R, position, position + 1);\n // StringValue\n case 0x0022: // \"\n if (\n body.charCodeAt(position + 1) === 0x0022 &&\n body.charCodeAt(position + 2) === 0x0022\n ) {\n return readBlockString(lexer, position);\n }\n return readString(lexer, position);\n }\n\n // IntValue | FloatValue (Digit | -)\n if (isDigit(code) || code === 0x002d) {\n return readNumber(lexer, position, code);\n }\n\n // Name\n if (isNameStart(code)) {\n return readName(lexer, position);\n }\n\n throw syntaxError(\n lexer.source,\n position,\n code === 0x0027\n ? 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?'\n : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position)\n ? `Unexpected character: ${printCodePointAt(lexer, position)}.`\n : `Invalid character: ${printCodePointAt(lexer, position)}.`,\n );\n }\n\n return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);\n}\n\n/**\n * Reads a comment token from the source file.\n *\n * ```\n * Comment :: # CommentChar* [lookahead != CommentChar]\n *\n * CommentChar :: SourceCharacter but not LineTerminator\n * ```\n */\nfunction readComment(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start + 1;\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // LineTerminator (\\n | \\r)\n if (code === 0x000a || code === 0x000d) {\n break;\n }\n\n // SourceCharacter\n if (isUnicodeScalarValue(code)) {\n ++position;\n } else if (isSupplementaryCodePoint(body, position)) {\n position += 2;\n } else {\n break;\n }\n }\n\n return createToken(\n lexer,\n TokenKind.COMMENT,\n start,\n position,\n body.slice(start + 1, position),\n );\n}\n\n/**\n * Reads a number token from the source file, either a FloatValue or an IntValue\n * depending on whether a FractionalPart or ExponentPart is encountered.\n *\n * ```\n * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]\n *\n * IntegerPart ::\n * - NegativeSign? 0\n * - NegativeSign? NonZeroDigit Digit*\n *\n * NegativeSign :: -\n *\n * NonZeroDigit :: Digit but not `0`\n *\n * FloatValue ::\n * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]\n * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]\n * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]\n *\n * FractionalPart :: . Digit+\n *\n * ExponentPart :: ExponentIndicator Sign? Digit+\n *\n * ExponentIndicator :: one of `e` `E`\n *\n * Sign :: one of + -\n * ```\n */\nfunction readNumber(lexer: Lexer, start: number, firstCode: number): Token {\n const body = lexer.source.body;\n let position = start;\n let code = firstCode;\n let isFloat = false;\n\n // NegativeSign (-)\n if (code === 0x002d) {\n code = body.charCodeAt(++position);\n }\n\n // Zero (0)\n if (code === 0x0030) {\n code = body.charCodeAt(++position);\n if (isDigit(code)) {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid number, unexpected digit after 0: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n } else {\n position = readDigits(lexer, position, code);\n code = body.charCodeAt(position);\n }\n\n // Full stop (.)\n if (code === 0x002e) {\n isFloat = true;\n\n code = body.charCodeAt(++position);\n position = readDigits(lexer, position, code);\n code = body.charCodeAt(position);\n }\n\n // E e\n if (code === 0x0045 || code === 0x0065) {\n isFloat = true;\n\n code = body.charCodeAt(++position);\n // + -\n if (code === 0x002b || code === 0x002d) {\n code = body.charCodeAt(++position);\n }\n position = readDigits(lexer, position, code);\n code = body.charCodeAt(position);\n }\n\n // Numbers cannot be followed by . or NameStart\n if (code === 0x002e || isNameStart(code)) {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid number, expected digit but got: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n\n return createToken(\n lexer,\n isFloat ? TokenKind.FLOAT : TokenKind.INT,\n start,\n position,\n body.slice(start, position),\n );\n}\n\n/**\n * Returns the new position in the source after reading one or more digits.\n */\nfunction readDigits(lexer: Lexer, start: number, firstCode: number): number {\n if (!isDigit(firstCode)) {\n throw syntaxError(\n lexer.source,\n start,\n `Invalid number, expected digit but got: ${printCodePointAt(\n lexer,\n start,\n )}.`,\n );\n }\n\n const body = lexer.source.body;\n let position = start + 1; // +1 to skip first firstCode\n\n while (isDigit(body.charCodeAt(position))) {\n ++position;\n }\n\n return position;\n}\n\n/**\n * Reads a single-quote string token from the source file.\n *\n * ```\n * StringValue ::\n * - `\"\"` [lookahead != `\"`]\n * - `\"` StringCharacter+ `\"`\n *\n * StringCharacter ::\n * - SourceCharacter but not `\"` or `\\` or LineTerminator\n * - `\\u` EscapedUnicode\n * - `\\` EscapedCharacter\n *\n * EscapedUnicode ::\n * - `{` HexDigit+ `}`\n * - HexDigit HexDigit HexDigit HexDigit\n *\n * EscapedCharacter :: one of `\"` `\\` `/` `b` `f` `n` `r` `t`\n * ```\n */\nfunction readString(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start + 1;\n let chunkStart = position;\n let value = '';\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // Closing Quote (\")\n if (code === 0x0022) {\n value += body.slice(chunkStart, position);\n return createToken(lexer, TokenKind.STRING, start, position + 1, value);\n }\n\n // Escape Sequence (\\)\n if (code === 0x005c) {\n value += body.slice(chunkStart, position);\n const escape =\n body.charCodeAt(position + 1) === 0x0075 // u\n ? body.charCodeAt(position + 2) === 0x007b // {\n ? readEscapedUnicodeVariableWidth(lexer, position)\n : readEscapedUnicodeFixedWidth(lexer, position)\n : readEscapedCharacter(lexer, position);\n value += escape.value;\n position += escape.size;\n chunkStart = position;\n continue;\n }\n\n // LineTerminator (\\n | \\r)\n if (code === 0x000a || code === 0x000d) {\n break;\n }\n\n // SourceCharacter\n if (isUnicodeScalarValue(code)) {\n ++position;\n } else if (isSupplementaryCodePoint(body, position)) {\n position += 2;\n } else {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid character within String: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n }\n\n throw syntaxError(lexer.source, position, 'Unterminated string.');\n}\n\n// The string value and lexed size of an escape sequence.\ninterface EscapeSequence {\n value: string;\n size: number;\n}\n\nfunction readEscapedUnicodeVariableWidth(\n lexer: Lexer,\n position: number,\n): EscapeSequence {\n const body = lexer.source.body;\n let point = 0;\n let size = 3;\n // Cannot be larger than 12 chars (\\u{00000000}).\n while (size < 12) {\n const code = body.charCodeAt(position + size++);\n // Closing Brace (})\n if (code === 0x007d) {\n // Must be at least 5 chars (\\u{0}) and encode a Unicode scalar value.\n if (size < 5 || !isUnicodeScalarValue(point)) {\n break;\n }\n return { value: String.fromCodePoint(point), size };\n }\n // Append this hex digit to the code point.\n point = (point << 4) | readHexDigit(code);\n if (point < 0) {\n break;\n }\n }\n\n throw syntaxError(\n lexer.source,\n position,\n `Invalid Unicode escape sequence: \"${body.slice(\n position,\n position + size,\n )}\".`,\n );\n}\n\nfunction readEscapedUnicodeFixedWidth(\n lexer: Lexer,\n position: number,\n): EscapeSequence {\n const body = lexer.source.body;\n const code = read16BitHexCode(body, position + 2);\n\n if (isUnicodeScalarValue(code)) {\n return { value: String.fromCodePoint(code), size: 6 };\n }\n\n // GraphQL allows JSON-style surrogate pair escape sequences, but only when\n // a valid pair is formed.\n if (isLeadingSurrogate(code)) {\n // \\u\n if (\n body.charCodeAt(position + 6) === 0x005c &&\n body.charCodeAt(position + 7) === 0x0075\n ) {\n const trailingCode = read16BitHexCode(body, position + 8);\n if (isTrailingSurrogate(trailingCode)) {\n // JavaScript defines strings as a sequence of UTF-16 code units and\n // encodes Unicode code points above U+FFFF using a surrogate pair of\n // code units. Since this is a surrogate pair escape sequence, just\n // include both codes into the JavaScript string value. Had JavaScript\n // not been internally based on UTF-16, then this surrogate pair would\n // be decoded to retrieve the supplementary code point.\n return { value: String.fromCodePoint(code, trailingCode), size: 12 };\n }\n }\n }\n\n throw syntaxError(\n lexer.source,\n position,\n `Invalid Unicode escape sequence: \"${body.slice(position, position + 6)}\".`,\n );\n}\n\n/**\n * Reads four hexadecimal characters and returns the positive integer that 16bit\n * hexadecimal string represents. For example, \"000f\" will return 15, and \"dead\"\n * will return 57005.\n *\n * Returns a negative number if any char was not a valid hexadecimal digit.\n */\nfunction read16BitHexCode(body: string, position: number): number {\n // readHexDigit() returns -1 on error. ORing a negative value with any other\n // value always produces a negative value.\n return (\n (readHexDigit(body.charCodeAt(position)) << 12) |\n (readHexDigit(body.charCodeAt(position + 1)) << 8) |\n (readHexDigit(body.charCodeAt(position + 2)) << 4) |\n readHexDigit(body.charCodeAt(position + 3))\n );\n}\n\n/**\n * Reads a hexadecimal character and returns its positive integer value (0-15).\n *\n * '0' becomes 0, '9' becomes 9\n * 'A' becomes 10, 'F' becomes 15\n * 'a' becomes 10, 'f' becomes 15\n *\n * Returns -1 if the provided character code was not a valid hexadecimal digit.\n *\n * HexDigit :: one of\n * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`\n * - `A` `B` `C` `D` `E` `F`\n * - `a` `b` `c` `d` `e` `f`\n */\nfunction readHexDigit(code: number): number {\n return code >= 0x0030 && code <= 0x0039 // 0-9\n ? code - 0x0030\n : code >= 0x0041 && code <= 0x0046 // A-F\n ? code - 0x0037\n : code >= 0x0061 && code <= 0x0066 // a-f\n ? code - 0x0057\n : -1;\n}\n\n/**\n * | Escaped Character | Code Point | Character Name |\n * | ----------------- | ---------- | ---------------------------- |\n * | `\"` | U+0022 | double quote |\n * | `\\` | U+005C | reverse solidus (back slash) |\n * | `/` | U+002F | solidus (forward slash) |\n * | `b` | U+0008 | backspace |\n * | `f` | U+000C | form feed |\n * | `n` | U+000A | line feed (new line) |\n * | `r` | U+000D | carriage return |\n * | `t` | U+0009 | horizontal tab |\n */\nfunction readEscapedCharacter(lexer: Lexer, position: number): EscapeSequence {\n const body = lexer.source.body;\n const code = body.charCodeAt(position + 1);\n switch (code) {\n case 0x0022: // \"\n return { value: '\\u0022', size: 2 };\n case 0x005c: // \\\n return { value: '\\u005c', size: 2 };\n case 0x002f: // /\n return { value: '\\u002f', size: 2 };\n case 0x0062: // b\n return { value: '\\u0008', size: 2 };\n case 0x0066: // f\n return { value: '\\u000c', size: 2 };\n case 0x006e: // n\n return { value: '\\u000a', size: 2 };\n case 0x0072: // r\n return { value: '\\u000d', size: 2 };\n case 0x0074: // t\n return { value: '\\u0009', size: 2 };\n }\n throw syntaxError(\n lexer.source,\n position,\n `Invalid character escape sequence: \"${body.slice(\n position,\n position + 2,\n )}\".`,\n );\n}\n\n/**\n * Reads a block string token from the source file.\n *\n * ```\n * StringValue ::\n * - `\"\"\"` BlockStringCharacter* `\"\"\"`\n *\n * BlockStringCharacter ::\n * - SourceCharacter but not `\"\"\"` or `\\\"\"\"`\n * - `\\\"\"\"`\n * ```\n */\nfunction readBlockString(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let lineStart = lexer.lineStart;\n\n let position = start + 3;\n let chunkStart = position;\n let currentLine = '';\n\n const blockLines = [];\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n\n // Closing Triple-Quote (\"\"\")\n if (\n code === 0x0022 &&\n body.charCodeAt(position + 1) === 0x0022 &&\n body.charCodeAt(position + 2) === 0x0022\n ) {\n currentLine += body.slice(chunkStart, position);\n blockLines.push(currentLine);\n\n const token = createToken(\n lexer,\n TokenKind.BLOCK_STRING,\n start,\n position + 3,\n // Return a string of the lines joined with U+000A.\n dedentBlockStringLines(blockLines).join('\\n'),\n );\n\n lexer.line += blockLines.length - 1;\n lexer.lineStart = lineStart;\n return token;\n }\n\n // Escaped Triple-Quote (\\\"\"\")\n if (\n code === 0x005c &&\n body.charCodeAt(position + 1) === 0x0022 &&\n body.charCodeAt(position + 2) === 0x0022 &&\n body.charCodeAt(position + 3) === 0x0022\n ) {\n currentLine += body.slice(chunkStart, position);\n chunkStart = position + 1; // skip only slash\n position += 4;\n continue;\n }\n\n // LineTerminator\n if (code === 0x000a || code === 0x000d) {\n currentLine += body.slice(chunkStart, position);\n blockLines.push(currentLine);\n\n if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) {\n position += 2;\n } else {\n ++position;\n }\n\n currentLine = '';\n chunkStart = position;\n lineStart = position;\n continue;\n }\n\n // SourceCharacter\n if (isUnicodeScalarValue(code)) {\n ++position;\n } else if (isSupplementaryCodePoint(body, position)) {\n position += 2;\n } else {\n throw syntaxError(\n lexer.source,\n position,\n `Invalid character within String: ${printCodePointAt(\n lexer,\n position,\n )}.`,\n );\n }\n }\n\n throw syntaxError(lexer.source, position, 'Unterminated string.');\n}\n\n/**\n * Reads an alphanumeric + underscore name from the source.\n *\n * ```\n * Name ::\n * - NameStart NameContinue* [lookahead != NameContinue]\n * ```\n */\nfunction readName(lexer: Lexer, start: number): Token {\n const body = lexer.source.body;\n const bodyLength = body.length;\n let position = start + 1;\n\n while (position < bodyLength) {\n const code = body.charCodeAt(position);\n if (isNameContinue(code)) {\n ++position;\n } else {\n break;\n }\n }\n\n return createToken(\n lexer,\n TokenKind.NAME,\n start,\n position,\n body.slice(start, position),\n );\n}\n"]} \ No newline at end of file diff --git a/language/location.d.ts b/language/location.d.ts new file mode 100644 index 0000000000..38ef368cde --- /dev/null +++ b/language/location.d.ts @@ -0,0 +1,13 @@ +import type { Source } from './source.js'; +/** + * Represents a location in a Source. + */ +export interface SourceLocation { + readonly line: number; + readonly column: number; +} +/** + * Takes a Source and a UTF-8 character offset, and returns the corresponding + * line and column as a SourceLocation. + */ +export declare function getLocation(source: Source, position: number): SourceLocation; diff --git a/language/location.js b/language/location.js new file mode 100644 index 0000000000..47a3653a2d --- /dev/null +++ b/language/location.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getLocation = getLocation; +const invariant_js_1 = require("../jsutils/invariant.js"); +const LineRegExp = /\r\n|[\n\r]/g; +/** + * Takes a Source and a UTF-8 character offset, and returns the corresponding + * line and column as a SourceLocation. + */ +function getLocation(source, position) { + let lastLineStart = 0; + let line = 1; + for (const match of source.body.matchAll(LineRegExp)) { + (typeof match.index === 'number') || (0, invariant_js_1.invariant)(false); + if (match.index >= position) { + break; + } + lastLineStart = match.index + match[0].length; + line += 1; + } + return { line, column: position + 1 - lastLineStart }; +} +//# sourceMappingURL=location.js.map \ No newline at end of file diff --git a/language/location.js.map b/language/location.js.map new file mode 100644 index 0000000000..95284bc64e --- /dev/null +++ b/language/location.js.map @@ -0,0 +1 @@ +{"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/language/location.ts"],"names":[],"mappings":";;AAkBA,kCAcC;AAhCD,0DAAoD;AAIpD,MAAM,UAAU,GAAG,cAAc,CAAC;AAUlC;;;GAGG;AACH,SAAgB,WAAW,CAAC,MAAc,EAAE,QAAgB;IAC1D,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,CAAU,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,SAAzC,wBAAS,SAAkC;QAC3C,IAAI,KAAK,CAAC,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC5B,MAAM;QACR,CAAC;QACD,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC9C,IAAI,IAAI,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAG,CAAC,GAAG,aAAa,EAAE,CAAC;AACxD,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\n\nimport type { Source } from './source.js';\n\nconst LineRegExp = /\\r\\n|[\\n\\r]/g;\n\n/**\n * Represents a location in a Source.\n */\nexport interface SourceLocation {\n readonly line: number;\n readonly column: number;\n}\n\n/**\n * Takes a Source and a UTF-8 character offset, and returns the corresponding\n * line and column as a SourceLocation.\n */\nexport function getLocation(source: Source, position: number): SourceLocation {\n let lastLineStart = 0;\n let line = 1;\n\n for (const match of source.body.matchAll(LineRegExp)) {\n invariant(typeof match.index === 'number');\n if (match.index >= position) {\n break;\n }\n lastLineStart = match.index + match[0].length;\n line += 1;\n }\n\n return { line, column: position + 1 - lastLineStart };\n}\n"]} \ No newline at end of file diff --git a/language/location.mjs b/language/location.mjs new file mode 100644 index 0000000000..e845959a08 --- /dev/null +++ b/language/location.mjs @@ -0,0 +1,20 @@ +import { invariant } from "../jsutils/invariant.mjs"; +const LineRegExp = /\r\n|[\n\r]/g; +/** + * Takes a Source and a UTF-8 character offset, and returns the corresponding + * line and column as a SourceLocation. + */ +export function getLocation(source, position) { + let lastLineStart = 0; + let line = 1; + for (const match of source.body.matchAll(LineRegExp)) { + (typeof match.index === 'number') || invariant(false); + if (match.index >= position) { + break; + } + lastLineStart = match.index + match[0].length; + line += 1; + } + return { line, column: position + 1 - lastLineStart }; +} +//# sourceMappingURL=location.js.map \ No newline at end of file diff --git a/language/location.mjs.map b/language/location.mjs.map new file mode 100644 index 0000000000..4b6b2f37ce --- /dev/null +++ b/language/location.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/language/location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAIpD,MAAM,UAAU,GAAG,cAAc,CAAC;AAUlC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,QAAgB;IAC1D,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,CAAU,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,KAAzC,SAAS,QAAkC;QAC3C,IAAI,KAAK,CAAC,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC5B,MAAM;QACR,CAAC;QACD,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC9C,IAAI,IAAI,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAG,CAAC,GAAG,aAAa,EAAE,CAAC;AACxD,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\n\nimport type { Source } from './source.js';\n\nconst LineRegExp = /\\r\\n|[\\n\\r]/g;\n\n/**\n * Represents a location in a Source.\n */\nexport interface SourceLocation {\n readonly line: number;\n readonly column: number;\n}\n\n/**\n * Takes a Source and a UTF-8 character offset, and returns the corresponding\n * line and column as a SourceLocation.\n */\nexport function getLocation(source: Source, position: number): SourceLocation {\n let lastLineStart = 0;\n let line = 1;\n\n for (const match of source.body.matchAll(LineRegExp)) {\n invariant(typeof match.index === 'number');\n if (match.index >= position) {\n break;\n }\n lastLineStart = match.index + match[0].length;\n line += 1;\n }\n\n return { line, column: position + 1 - lastLineStart };\n}\n"]} \ No newline at end of file diff --git a/language/parser.d.ts b/language/parser.d.ts new file mode 100644 index 0000000000..a628735c26 --- /dev/null +++ b/language/parser.d.ts @@ -0,0 +1,498 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { GraphQLError } from '../error/GraphQLError.js'; +import type { ArgumentNode, ConstArgumentNode, ConstDirectiveNode, ConstListValueNode, ConstObjectFieldNode, ConstObjectValueNode, ConstValueNode, DefinitionNode, DirectiveDefinitionNode, DirectiveNode, DocumentNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, EnumValueDefinitionNode, FieldDefinitionNode, FieldNode, FragmentArgumentNode, FragmentDefinitionNode, FragmentSpreadNode, InlineFragmentNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, ListValueNode, NamedTypeNode, NameNode, ObjectFieldNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, ObjectValueNode, OperationDefinitionNode, OperationTypeDefinitionNode, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, SchemaDefinitionNode, SchemaExtensionNode, SelectionNode, SelectionSetNode, StringValueNode, Token, TypeNode, TypeSystemExtensionNode, UnionTypeDefinitionNode, UnionTypeExtensionNode, ValueNode, VariableDefinitionNode, VariableNode } from './ast.js'; +import { Location, OperationTypeNode } from './ast.js'; +import { Lexer } from './lexer.js'; +import { Source } from './source.js'; +import { TokenKind } from './tokenKind.js'; +/** + * Configuration options to control parser behavior + */ +export interface ParseOptions { + /** + * By default, the parser creates AST nodes that know the location + * in the source that they correspond to. This configuration flag + * disables that behavior for performance or testing. + */ + noLocation?: boolean | undefined; + /** + * Parser CPU and memory usage is linear to the number of tokens in a document + * however in extreme cases it becomes quadratic due to memory exhaustion. + * Parsing happens before validation so even invalid queries can burn lots of + * CPU time and memory. + * To prevent this you can set a maximum number of tokens allowed within a document. + */ + maxTokens?: number | undefined; + /** + * EXPERIMENTAL: + * + * If enabled, the parser will understand and parse fragment variable definitions + * and arguments on fragment spreads. Fragment variable definitions will be represented + * in the `variableDefinitions` field of the FragmentDefinitionNode. + * Fragment spread arguments will be represented in the `arguments` field of FragmentSpreadNode. + * + * For example: + * + * ```graphql + * { + * t { ...A(var: true) } + * } + * fragment A($var: Boolean = false) on T { + * ...B(x: $var) + * } + * ``` + */ + experimentalFragmentArguments?: boolean | undefined; +} +/** + * Given a GraphQL source, parses it into a Document. + * Throws GraphQLError if a syntax error is encountered. + */ +export declare function parse(source: string | Source, options?: ParseOptions): DocumentNode; +/** + * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for + * that value. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Values directly and + * in isolation of complete GraphQL documents. + */ +export declare function parseValue(source: string | Source, options?: ParseOptions): ValueNode; +/** + * Similar to parseValue(), but raises a parse error if it encounters a + * variable. The return type will be a constant value. + */ +export declare function parseConstValue(source: string | Source, options?: ParseOptions): ConstValueNode; +/** + * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for + * that type. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Types directly and + * in isolation of complete GraphQL documents. + * + * Consider providing the results to the utility function: typeFromAST(). + */ +export declare function parseType(source: string | Source, options?: ParseOptions): TypeNode; +/** + * This class is exported only to assist people in implementing their own parsers + * without duplicating too much code and should be used only as last resort for cases + * such as experimental syntax or if certain features could not be contributed upstream. + * + * It is still part of the internal API and is versioned, so any changes to it are never + * considered breaking changes. If you still need to support multiple versions of the + * library, please use the `versionInfo` variable for version detection. + * + * @internal + */ +export declare class Parser { + protected _options: ParseOptions; + protected _lexer: Lexer; + protected _tokenCounter: number; + constructor(source: string | Source, options?: ParseOptions); + get tokenCount(): number; + /** + * Converts a name lex token into a name parse node. + */ + parseName(): NameNode; + /** + * Document : Definition+ + */ + parseDocument(): DocumentNode; + /** + * Definition : + * - ExecutableDefinition + * - TypeSystemDefinition + * - TypeSystemExtension + * + * ExecutableDefinition : + * - OperationDefinition + * - FragmentDefinition + * + * TypeSystemDefinition : + * - SchemaDefinition + * - TypeDefinition + * - DirectiveDefinition + * + * TypeDefinition : + * - ScalarTypeDefinition + * - ObjectTypeDefinition + * - InterfaceTypeDefinition + * - UnionTypeDefinition + * - EnumTypeDefinition + * - InputObjectTypeDefinition + */ + parseDefinition(): DefinitionNode; + /** + * OperationDefinition : + * - SelectionSet + * - OperationType Name? VariableDefinitions? Directives? SelectionSet + */ + parseOperationDefinition(): OperationDefinitionNode; + /** + * OperationType : one of query mutation subscription + */ + parseOperationType(): OperationTypeNode; + /** + * VariableDefinitions : ( VariableDefinition+ ) + */ + parseVariableDefinitions(): Array | undefined; + /** + * VariableDefinition : Variable : Type DefaultValue? Directives[Const]? + */ + parseVariableDefinition(): VariableDefinitionNode; + /** + * Variable : $ Name + */ + parseVariable(): VariableNode; + /** + * ``` + * SelectionSet : { Selection+ } + * ``` + */ + parseSelectionSet(): SelectionSetNode; + /** + * Selection : + * - Field + * - FragmentSpread + * - InlineFragment + */ + parseSelection(): SelectionNode; + /** + * Field : Alias? Name Arguments? Directives? SelectionSet? + * + * Alias : Name : + */ + parseField(): FieldNode; + /** + * Arguments[Const] : ( Argument[?Const]+ ) + */ + parseArguments(isConst: true): Array | undefined; + parseArguments(isConst: boolean): Array | undefined; + parseFragmentArguments(): Array | undefined; + /** + * Argument[Const] : Name : Value[?Const] + */ + parseArgument(isConst: true): ConstArgumentNode; + parseArgument(isConst?: boolean): ArgumentNode; + parseConstArgument(): ConstArgumentNode; + parseFragmentArgument(): FragmentArgumentNode; + /** + * Corresponds to both FragmentSpread and InlineFragment in the spec. + * + * FragmentSpread : ... FragmentName Arguments? Directives? + * + * InlineFragment : ... TypeCondition? Directives? SelectionSet + */ + parseFragment(): FragmentSpreadNode | InlineFragmentNode; + /** + * FragmentDefinition : + * - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet + * + * TypeCondition : NamedType + */ + parseFragmentDefinition(): FragmentDefinitionNode; + /** + * FragmentName : Name but not `on` + */ + parseFragmentName(): NameNode; + /** + * Value[Const] : + * - [~Const] Variable + * - IntValue + * - FloatValue + * - StringValue + * - BooleanValue + * - NullValue + * - EnumValue + * - ListValue[?Const] + * - ObjectValue[?Const] + * + * BooleanValue : one of `true` `false` + * + * NullValue : `null` + * + * EnumValue : Name but not `true`, `false` or `null` + */ + parseValueLiteral(isConst: true): ConstValueNode; + parseValueLiteral(isConst: boolean): ValueNode; + parseConstValueLiteral(): ConstValueNode; + parseStringLiteral(): StringValueNode; + /** + * ListValue[Const] : + * - [ ] + * - [ Value[?Const]+ ] + */ + parseList(isConst: true): ConstListValueNode; + parseList(isConst: boolean): ListValueNode; + /** + * ``` + * ObjectValue[Const] : + * - { } + * - { ObjectField[?Const]+ } + * ``` + */ + parseObject(isConst: true): ConstObjectValueNode; + parseObject(isConst: boolean): ObjectValueNode; + /** + * ObjectField[Const] : Name : Value[?Const] + */ + parseObjectField(isConst: true): ConstObjectFieldNode; + parseObjectField(isConst: boolean): ObjectFieldNode; + /** + * Directives[Const] : Directive[?Const]+ + */ + parseDirectives(isConst: true): Array | undefined; + parseDirectives(isConst: boolean): Array | undefined; + parseConstDirectives(): Array | undefined; + /** + * ``` + * Directive[Const] : @ Name Arguments[?Const]? + * ``` + */ + parseDirective(isConst: true): ConstDirectiveNode; + parseDirective(isConst: boolean): DirectiveNode; + /** + * Type : + * - NamedType + * - ListType + * - NonNullType + */ + parseTypeReference(): TypeNode; + /** + * NamedType : Name + */ + parseNamedType(): NamedTypeNode; + peekDescription(): boolean; + /** + * Description : StringValue + */ + parseDescription(): undefined | StringValueNode; + /** + * ``` + * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } + * ``` + */ + parseSchemaDefinition(): SchemaDefinitionNode; + /** + * OperationTypeDefinition : OperationType : NamedType + */ + parseOperationTypeDefinition(): OperationTypeDefinitionNode; + /** + * ScalarTypeDefinition : Description? scalar Name Directives[Const]? + */ + parseScalarTypeDefinition(): ScalarTypeDefinitionNode; + /** + * ObjectTypeDefinition : + * Description? + * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? + */ + parseObjectTypeDefinition(): ObjectTypeDefinitionNode; + /** + * ImplementsInterfaces : + * - implements `&`? NamedType + * - ImplementsInterfaces & NamedType + */ + parseImplementsInterfaces(): Array | undefined; + /** + * ``` + * FieldsDefinition : { FieldDefinition+ } + * ``` + */ + parseFieldsDefinition(): Array | undefined; + /** + * FieldDefinition : + * - Description? Name ArgumentsDefinition? : Type Directives[Const]? + */ + parseFieldDefinition(): FieldDefinitionNode; + /** + * ArgumentsDefinition : ( InputValueDefinition+ ) + */ + parseArgumentDefs(): Array | undefined; + /** + * InputValueDefinition : + * - Description? Name : Type DefaultValue? Directives[Const]? + */ + parseInputValueDef(): InputValueDefinitionNode; + /** + * InterfaceTypeDefinition : + * - Description? interface Name Directives[Const]? FieldsDefinition? + */ + parseInterfaceTypeDefinition(): InterfaceTypeDefinitionNode; + /** + * UnionTypeDefinition : + * - Description? union Name Directives[Const]? UnionMemberTypes? + */ + parseUnionTypeDefinition(): UnionTypeDefinitionNode; + /** + * UnionMemberTypes : + * - = `|`? NamedType + * - UnionMemberTypes | NamedType + */ + parseUnionMemberTypes(): Array | undefined; + /** + * EnumTypeDefinition : + * - Description? enum Name Directives[Const]? EnumValuesDefinition? + */ + parseEnumTypeDefinition(): EnumTypeDefinitionNode; + /** + * ``` + * EnumValuesDefinition : { EnumValueDefinition+ } + * ``` + */ + parseEnumValuesDefinition(): Array | undefined; + /** + * EnumValueDefinition : Description? EnumValue Directives[Const]? + */ + parseEnumValueDefinition(): EnumValueDefinitionNode; + /** + * EnumValue : Name but not `true`, `false` or `null` + */ + parseEnumValueName(): NameNode; + /** + * InputObjectTypeDefinition : + * - Description? input Name Directives[Const]? InputFieldsDefinition? + */ + parseInputObjectTypeDefinition(): InputObjectTypeDefinitionNode; + /** + * ``` + * InputFieldsDefinition : { InputValueDefinition+ } + * ``` + */ + parseInputFieldsDefinition(): Array | undefined; + /** + * TypeSystemExtension : + * - SchemaExtension + * - TypeExtension + * + * TypeExtension : + * - ScalarTypeExtension + * - ObjectTypeExtension + * - InterfaceTypeExtension + * - UnionTypeExtension + * - EnumTypeExtension + * - InputObjectTypeDefinition + */ + parseTypeSystemExtension(): TypeSystemExtensionNode; + /** + * ``` + * SchemaExtension : + * - extend schema Directives[Const]? { OperationTypeDefinition+ } + * - extend schema Directives[Const] + * ``` + */ + parseSchemaExtension(): SchemaExtensionNode; + /** + * ScalarTypeExtension : + * - extend scalar Name Directives[Const] + */ + parseScalarTypeExtension(): ScalarTypeExtensionNode; + /** + * ObjectTypeExtension : + * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend type Name ImplementsInterfaces? Directives[Const] + * - extend type Name ImplementsInterfaces + */ + parseObjectTypeExtension(): ObjectTypeExtensionNode; + /** + * InterfaceTypeExtension : + * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend interface Name ImplementsInterfaces? Directives[Const] + * - extend interface Name ImplementsInterfaces + */ + parseInterfaceTypeExtension(): InterfaceTypeExtensionNode; + /** + * UnionTypeExtension : + * - extend union Name Directives[Const]? UnionMemberTypes + * - extend union Name Directives[Const] + */ + parseUnionTypeExtension(): UnionTypeExtensionNode; + /** + * EnumTypeExtension : + * - extend enum Name Directives[Const]? EnumValuesDefinition + * - extend enum Name Directives[Const] + */ + parseEnumTypeExtension(): EnumTypeExtensionNode; + /** + * InputObjectTypeExtension : + * - extend input Name Directives[Const]? InputFieldsDefinition + * - extend input Name Directives[Const] + */ + parseInputObjectTypeExtension(): InputObjectTypeExtensionNode; + /** + * ``` + * DirectiveDefinition : + * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations + * ``` + */ + parseDirectiveDefinition(): DirectiveDefinitionNode; + /** + * DirectiveLocations : + * - `|`? DirectiveLocation + * - DirectiveLocations | DirectiveLocation + */ + parseDirectiveLocations(): Array; + parseDirectiveLocation(): NameNode; + /** + * Returns a node that, if configured to do so, sets a "loc" field as a + * location object, used to identify the place in the source that created a + * given parsed object. + */ + node(startToken: Token, node: T): T; + /** + * Determines if the next token is of a given kind + */ + peek(kind: TokenKind): boolean; + /** + * If the next token is of the given kind, return that token after advancing the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + expectToken(kind: TokenKind): Token; + /** + * If the next token is of the given kind, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + expectOptionalToken(kind: TokenKind): boolean; + /** + * If the next token is a given keyword, advance the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + expectKeyword(value: string): void; + /** + * If the next token is a given keyword, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + expectOptionalKeyword(value: string): boolean; + /** + * Helper function for creating an error when an unexpected lexed token is encountered. + */ + unexpected(atToken?: Maybe): GraphQLError; + /** + * Returns a possibly empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + any(openKind: TokenKind, parseFn: () => T, closeKind: TokenKind): Array; + /** + * Returns a list of parse nodes, determined by the parseFn. + * It can be empty only if open token is missing otherwise it will always return non-empty list + * that begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + optionalMany(openKind: TokenKind, parseFn: () => T, closeKind: TokenKind): Array | undefined; + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + many(openKind: TokenKind, parseFn: () => T, closeKind: TokenKind): Array; + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind. + * Advances the parser to the next lex token after last item in the list. + */ + delimitedMany(delimiterKind: TokenKind, parseFn: () => T): Array; + advanceLexer(): void; +} diff --git a/language/parser.js b/language/parser.js new file mode 100644 index 0000000000..111bfb276c --- /dev/null +++ b/language/parser.js @@ -0,0 +1,1266 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Parser = void 0; +exports.parse = parse; +exports.parseValue = parseValue; +exports.parseConstValue = parseConstValue; +exports.parseType = parseType; +const syntaxError_js_1 = require("../error/syntaxError.js"); +const ast_js_1 = require("./ast.js"); +const directiveLocation_js_1 = require("./directiveLocation.js"); +const kinds_js_1 = require("./kinds.js"); +const lexer_js_1 = require("./lexer.js"); +const source_js_1 = require("./source.js"); +const tokenKind_js_1 = require("./tokenKind.js"); +/** + * Given a GraphQL source, parses it into a Document. + * Throws GraphQLError if a syntax error is encountered. + */ +function parse(source, options) { + const parser = new Parser(source, options); + const document = parser.parseDocument(); + Object.defineProperty(document, 'tokenCount', { + enumerable: false, + value: parser.tokenCount, + }); + return document; +} +/** + * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for + * that value. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Values directly and + * in isolation of complete GraphQL documents. + */ +function parseValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(tokenKind_js_1.TokenKind.SOF); + const value = parser.parseValueLiteral(false); + parser.expectToken(tokenKind_js_1.TokenKind.EOF); + return value; +} +/** + * Similar to parseValue(), but raises a parse error if it encounters a + * variable. The return type will be a constant value. + */ +function parseConstValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(tokenKind_js_1.TokenKind.SOF); + const value = parser.parseConstValueLiteral(); + parser.expectToken(tokenKind_js_1.TokenKind.EOF); + return value; +} +/** + * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for + * that type. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Types directly and + * in isolation of complete GraphQL documents. + * + * Consider providing the results to the utility function: typeFromAST(). + */ +function parseType(source, options) { + const parser = new Parser(source, options); + parser.expectToken(tokenKind_js_1.TokenKind.SOF); + const type = parser.parseTypeReference(); + parser.expectToken(tokenKind_js_1.TokenKind.EOF); + return type; +} +/** + * This class is exported only to assist people in implementing their own parsers + * without duplicating too much code and should be used only as last resort for cases + * such as experimental syntax or if certain features could not be contributed upstream. + * + * It is still part of the internal API and is versioned, so any changes to it are never + * considered breaking changes. If you still need to support multiple versions of the + * library, please use the `versionInfo` variable for version detection. + * + * @internal + */ +class Parser { + constructor(source, options = {}) { + const sourceObj = (0, source_js_1.isSource)(source) ? source : new source_js_1.Source(source); + this._lexer = new lexer_js_1.Lexer(sourceObj); + this._options = options; + this._tokenCounter = 0; + } + get tokenCount() { + return this._tokenCounter; + } + /** + * Converts a name lex token into a name parse node. + */ + parseName() { + const token = this.expectToken(tokenKind_js_1.TokenKind.NAME); + return this.node(token, { + kind: kinds_js_1.Kind.NAME, + value: token.value, + }); + } + // Implements the parsing rules in the Document section. + /** + * Document : Definition+ + */ + parseDocument() { + return this.node(this._lexer.token, { + kind: kinds_js_1.Kind.DOCUMENT, + definitions: this.many(tokenKind_js_1.TokenKind.SOF, this.parseDefinition, tokenKind_js_1.TokenKind.EOF), + }); + } + /** + * Definition : + * - ExecutableDefinition + * - TypeSystemDefinition + * - TypeSystemExtension + * + * ExecutableDefinition : + * - OperationDefinition + * - FragmentDefinition + * + * TypeSystemDefinition : + * - SchemaDefinition + * - TypeDefinition + * - DirectiveDefinition + * + * TypeDefinition : + * - ScalarTypeDefinition + * - ObjectTypeDefinition + * - InterfaceTypeDefinition + * - UnionTypeDefinition + * - EnumTypeDefinition + * - InputObjectTypeDefinition + */ + parseDefinition() { + if (this.peek(tokenKind_js_1.TokenKind.BRACE_L)) { + return this.parseOperationDefinition(); + } + // Many definitions begin with a description and require a lookahead. + const hasDescription = this.peekDescription(); + const keywordToken = hasDescription + ? this._lexer.lookahead() + : this._lexer.token; + if (keywordToken.kind === tokenKind_js_1.TokenKind.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaDefinition(); + case 'scalar': + return this.parseScalarTypeDefinition(); + case 'type': + return this.parseObjectTypeDefinition(); + case 'interface': + return this.parseInterfaceTypeDefinition(); + case 'union': + return this.parseUnionTypeDefinition(); + case 'enum': + return this.parseEnumTypeDefinition(); + case 'input': + return this.parseInputObjectTypeDefinition(); + case 'directive': + return this.parseDirectiveDefinition(); + } + if (hasDescription) { + throw (0, syntaxError_js_1.syntaxError)(this._lexer.source, this._lexer.token.start, 'Unexpected description, descriptions are supported only on type definitions.'); + } + switch (keywordToken.value) { + case 'query': + case 'mutation': + case 'subscription': + return this.parseOperationDefinition(); + case 'fragment': + return this.parseFragmentDefinition(); + case 'extend': + return this.parseTypeSystemExtension(); + } + } + throw this.unexpected(keywordToken); + } + // Implements the parsing rules in the Operations section. + /** + * OperationDefinition : + * - SelectionSet + * - OperationType Name? VariableDefinitions? Directives? SelectionSet + */ + parseOperationDefinition() { + const start = this._lexer.token; + if (this.peek(tokenKind_js_1.TokenKind.BRACE_L)) { + return this.node(start, { + kind: kinds_js_1.Kind.OPERATION_DEFINITION, + operation: ast_js_1.OperationTypeNode.QUERY, + name: undefined, + variableDefinitions: undefined, + directives: undefined, + selectionSet: this.parseSelectionSet(), + }); + } + const operation = this.parseOperationType(); + let name; + if (this.peek(tokenKind_js_1.TokenKind.NAME)) { + name = this.parseName(); + } + return this.node(start, { + kind: kinds_js_1.Kind.OPERATION_DEFINITION, + operation, + name, + variableDefinitions: this.parseVariableDefinitions(), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * OperationType : one of query mutation subscription + */ + parseOperationType() { + const operationToken = this.expectToken(tokenKind_js_1.TokenKind.NAME); + switch (operationToken.value) { + case 'query': + return ast_js_1.OperationTypeNode.QUERY; + case 'mutation': + return ast_js_1.OperationTypeNode.MUTATION; + case 'subscription': + return ast_js_1.OperationTypeNode.SUBSCRIPTION; + } + throw this.unexpected(operationToken); + } + /** + * VariableDefinitions : ( VariableDefinition+ ) + */ + parseVariableDefinitions() { + return this.optionalMany(tokenKind_js_1.TokenKind.PAREN_L, this.parseVariableDefinition, tokenKind_js_1.TokenKind.PAREN_R); + } + /** + * VariableDefinition : Variable : Type DefaultValue? Directives[Const]? + */ + parseVariableDefinition() { + return this.node(this._lexer.token, { + kind: kinds_js_1.Kind.VARIABLE_DEFINITION, + variable: this.parseVariable(), + type: (this.expectToken(tokenKind_js_1.TokenKind.COLON), this.parseTypeReference()), + defaultValue: this.expectOptionalToken(tokenKind_js_1.TokenKind.EQUALS) + ? this.parseConstValueLiteral() + : undefined, + directives: this.parseConstDirectives(), + }); + } + /** + * Variable : $ Name + */ + parseVariable() { + const start = this._lexer.token; + this.expectToken(tokenKind_js_1.TokenKind.DOLLAR); + return this.node(start, { + kind: kinds_js_1.Kind.VARIABLE, + name: this.parseName(), + }); + } + /** + * ``` + * SelectionSet : { Selection+ } + * ``` + */ + parseSelectionSet() { + return this.node(this._lexer.token, { + kind: kinds_js_1.Kind.SELECTION_SET, + selections: this.many(tokenKind_js_1.TokenKind.BRACE_L, this.parseSelection, tokenKind_js_1.TokenKind.BRACE_R), + }); + } + /** + * Selection : + * - Field + * - FragmentSpread + * - InlineFragment + */ + parseSelection() { + return this.peek(tokenKind_js_1.TokenKind.SPREAD) + ? this.parseFragment() + : this.parseField(); + } + /** + * Field : Alias? Name Arguments? Directives? SelectionSet? + * + * Alias : Name : + */ + parseField() { + const start = this._lexer.token; + const nameOrAlias = this.parseName(); + let alias; + let name; + if (this.expectOptionalToken(tokenKind_js_1.TokenKind.COLON)) { + alias = nameOrAlias; + name = this.parseName(); + } + else { + name = nameOrAlias; + } + return this.node(start, { + kind: kinds_js_1.Kind.FIELD, + alias, + name, + arguments: this.parseArguments(false), + directives: this.parseDirectives(false), + selectionSet: this.peek(tokenKind_js_1.TokenKind.BRACE_L) + ? this.parseSelectionSet() + : undefined, + }); + } + parseArguments(isConst) { + const item = isConst ? this.parseConstArgument : this.parseArgument; + return this.optionalMany(tokenKind_js_1.TokenKind.PAREN_L, item, tokenKind_js_1.TokenKind.PAREN_R); + } + /* experimental */ + parseFragmentArguments() { + const item = this.parseFragmentArgument; + return this.optionalMany(tokenKind_js_1.TokenKind.PAREN_L, item, tokenKind_js_1.TokenKind.PAREN_R); + } + parseArgument(isConst = false) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(tokenKind_js_1.TokenKind.COLON); + return this.node(start, { + kind: kinds_js_1.Kind.ARGUMENT, + name, + value: this.parseValueLiteral(isConst), + }); + } + parseConstArgument() { + return this.parseArgument(true); + } + /* experimental */ + parseFragmentArgument() { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(tokenKind_js_1.TokenKind.COLON); + return this.node(start, { + kind: kinds_js_1.Kind.FRAGMENT_ARGUMENT, + name, + value: this.parseValueLiteral(false), + }); + } + // Implements the parsing rules in the Fragments section. + /** + * Corresponds to both FragmentSpread and InlineFragment in the spec. + * + * FragmentSpread : ... FragmentName Arguments? Directives? + * + * InlineFragment : ... TypeCondition? Directives? SelectionSet + */ + parseFragment() { + const start = this._lexer.token; + this.expectToken(tokenKind_js_1.TokenKind.SPREAD); + const hasTypeCondition = this.expectOptionalKeyword('on'); + if (!hasTypeCondition && this.peek(tokenKind_js_1.TokenKind.NAME)) { + const name = this.parseFragmentName(); + if (this.peek(tokenKind_js_1.TokenKind.PAREN_L) && + this._options.experimentalFragmentArguments) { + return this.node(start, { + kind: kinds_js_1.Kind.FRAGMENT_SPREAD, + name, + arguments: this.parseFragmentArguments(), + directives: this.parseDirectives(false), + }); + } + return this.node(start, { + kind: kinds_js_1.Kind.FRAGMENT_SPREAD, + name, + directives: this.parseDirectives(false), + }); + } + return this.node(start, { + kind: kinds_js_1.Kind.INLINE_FRAGMENT, + typeCondition: hasTypeCondition ? this.parseNamedType() : undefined, + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentDefinition : + * - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet + * + * TypeCondition : NamedType + */ + parseFragmentDefinition() { + const start = this._lexer.token; + this.expectKeyword('fragment'); + if (this._options.experimentalFragmentArguments === true) { + return this.node(start, { + kind: kinds_js_1.Kind.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + variableDefinitions: this.parseVariableDefinitions(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + return this.node(start, { + kind: kinds_js_1.Kind.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentName : Name but not `on` + */ + parseFragmentName() { + if (this._lexer.token.value === 'on') { + throw this.unexpected(); + } + return this.parseName(); + } + parseValueLiteral(isConst) { + const token = this._lexer.token; + switch (token.kind) { + case tokenKind_js_1.TokenKind.BRACKET_L: + return this.parseList(isConst); + case tokenKind_js_1.TokenKind.BRACE_L: + return this.parseObject(isConst); + case tokenKind_js_1.TokenKind.INT: + this.advanceLexer(); + return this.node(token, { + kind: kinds_js_1.Kind.INT, + value: token.value, + }); + case tokenKind_js_1.TokenKind.FLOAT: + this.advanceLexer(); + return this.node(token, { + kind: kinds_js_1.Kind.FLOAT, + value: token.value, + }); + case tokenKind_js_1.TokenKind.STRING: + case tokenKind_js_1.TokenKind.BLOCK_STRING: + return this.parseStringLiteral(); + case tokenKind_js_1.TokenKind.NAME: + this.advanceLexer(); + switch (token.value) { + case 'true': + return this.node(token, { + kind: kinds_js_1.Kind.BOOLEAN, + value: true, + }); + case 'false': + return this.node(token, { + kind: kinds_js_1.Kind.BOOLEAN, + value: false, + }); + case 'null': + return this.node(token, { kind: kinds_js_1.Kind.NULL }); + default: + return this.node(token, { + kind: kinds_js_1.Kind.ENUM, + value: token.value, + }); + } + case tokenKind_js_1.TokenKind.DOLLAR: + if (isConst) { + this.expectToken(tokenKind_js_1.TokenKind.DOLLAR); + if (this._lexer.token.kind === tokenKind_js_1.TokenKind.NAME) { + const varName = this._lexer.token.value; + throw (0, syntaxError_js_1.syntaxError)(this._lexer.source, token.start, `Unexpected variable "$${varName}" in constant value.`); + } + else { + throw this.unexpected(token); + } + } + return this.parseVariable(); + default: + throw this.unexpected(); + } + } + parseConstValueLiteral() { + return this.parseValueLiteral(true); + } + parseStringLiteral() { + const token = this._lexer.token; + this.advanceLexer(); + return this.node(token, { + kind: kinds_js_1.Kind.STRING, + value: token.value, + block: token.kind === tokenKind_js_1.TokenKind.BLOCK_STRING, + }); + } + parseList(isConst) { + const item = () => this.parseValueLiteral(isConst); + return this.node(this._lexer.token, { + kind: kinds_js_1.Kind.LIST, + values: this.any(tokenKind_js_1.TokenKind.BRACKET_L, item, tokenKind_js_1.TokenKind.BRACKET_R), + }); + } + parseObject(isConst) { + const item = () => this.parseObjectField(isConst); + return this.node(this._lexer.token, { + kind: kinds_js_1.Kind.OBJECT, + fields: this.any(tokenKind_js_1.TokenKind.BRACE_L, item, tokenKind_js_1.TokenKind.BRACE_R), + }); + } + parseObjectField(isConst) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(tokenKind_js_1.TokenKind.COLON); + return this.node(start, { + kind: kinds_js_1.Kind.OBJECT_FIELD, + name, + value: this.parseValueLiteral(isConst), + }); + } + parseDirectives(isConst) { + const directives = []; + while (this.peek(tokenKind_js_1.TokenKind.AT)) { + directives.push(this.parseDirective(isConst)); + } + if (directives.length) { + return directives; + } + return undefined; + } + parseConstDirectives() { + return this.parseDirectives(true); + } + parseDirective(isConst) { + const start = this._lexer.token; + this.expectToken(tokenKind_js_1.TokenKind.AT); + return this.node(start, { + kind: kinds_js_1.Kind.DIRECTIVE, + name: this.parseName(), + arguments: this.parseArguments(isConst), + }); + } + // Implements the parsing rules in the Types section. + /** + * Type : + * - NamedType + * - ListType + * - NonNullType + */ + parseTypeReference() { + const start = this._lexer.token; + let type; + if (this.expectOptionalToken(tokenKind_js_1.TokenKind.BRACKET_L)) { + const innerType = this.parseTypeReference(); + this.expectToken(tokenKind_js_1.TokenKind.BRACKET_R); + type = this.node(start, { + kind: kinds_js_1.Kind.LIST_TYPE, + type: innerType, + }); + } + else { + type = this.parseNamedType(); + } + if (this.expectOptionalToken(tokenKind_js_1.TokenKind.BANG)) { + return this.node(start, { + kind: kinds_js_1.Kind.NON_NULL_TYPE, + type, + }); + } + return type; + } + /** + * NamedType : Name + */ + parseNamedType() { + return this.node(this._lexer.token, { + kind: kinds_js_1.Kind.NAMED_TYPE, + name: this.parseName(), + }); + } + // Implements the parsing rules in the Type Definition section. + peekDescription() { + return this.peek(tokenKind_js_1.TokenKind.STRING) || this.peek(tokenKind_js_1.TokenKind.BLOCK_STRING); + } + /** + * Description : StringValue + */ + parseDescription() { + if (this.peekDescription()) { + return this.parseStringLiteral(); + } + } + /** + * ``` + * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } + * ``` + */ + parseSchemaDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.many(tokenKind_js_1.TokenKind.BRACE_L, this.parseOperationTypeDefinition, tokenKind_js_1.TokenKind.BRACE_R); + return this.node(start, { + kind: kinds_js_1.Kind.SCHEMA_DEFINITION, + description, + directives, + operationTypes, + }); + } + /** + * OperationTypeDefinition : OperationType : NamedType + */ + parseOperationTypeDefinition() { + const start = this._lexer.token; + const operation = this.parseOperationType(); + this.expectToken(tokenKind_js_1.TokenKind.COLON); + const type = this.parseNamedType(); + return this.node(start, { + kind: kinds_js_1.Kind.OPERATION_TYPE_DEFINITION, + operation, + type, + }); + } + /** + * ScalarTypeDefinition : Description? scalar Name Directives[Const]? + */ + parseScalarTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: kinds_js_1.Kind.SCALAR_TYPE_DEFINITION, + description, + name, + directives, + }); + } + /** + * ObjectTypeDefinition : + * Description? + * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? + */ + parseObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: kinds_js_1.Kind.OBJECT_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * ImplementsInterfaces : + * - implements `&`? NamedType + * - ImplementsInterfaces & NamedType + */ + parseImplementsInterfaces() { + return this.expectOptionalKeyword('implements') + ? this.delimitedMany(tokenKind_js_1.TokenKind.AMP, this.parseNamedType) + : undefined; + } + /** + * ``` + * FieldsDefinition : { FieldDefinition+ } + * ``` + */ + parseFieldsDefinition() { + return this.optionalMany(tokenKind_js_1.TokenKind.BRACE_L, this.parseFieldDefinition, tokenKind_js_1.TokenKind.BRACE_R); + } + /** + * FieldDefinition : + * - Description? Name ArgumentsDefinition? : Type Directives[Const]? + */ + parseFieldDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + this.expectToken(tokenKind_js_1.TokenKind.COLON); + const type = this.parseTypeReference(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: kinds_js_1.Kind.FIELD_DEFINITION, + description, + name, + arguments: args, + type, + directives, + }); + } + /** + * ArgumentsDefinition : ( InputValueDefinition+ ) + */ + parseArgumentDefs() { + return this.optionalMany(tokenKind_js_1.TokenKind.PAREN_L, this.parseInputValueDef, tokenKind_js_1.TokenKind.PAREN_R); + } + /** + * InputValueDefinition : + * - Description? Name : Type DefaultValue? Directives[Const]? + */ + parseInputValueDef() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + this.expectToken(tokenKind_js_1.TokenKind.COLON); + const type = this.parseTypeReference(); + let defaultValue; + if (this.expectOptionalToken(tokenKind_js_1.TokenKind.EQUALS)) { + defaultValue = this.parseConstValueLiteral(); + } + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: kinds_js_1.Kind.INPUT_VALUE_DEFINITION, + description, + name, + type, + defaultValue, + directives, + }); + } + /** + * InterfaceTypeDefinition : + * - Description? interface Name Directives[Const]? FieldsDefinition? + */ + parseInterfaceTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: kinds_js_1.Kind.INTERFACE_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeDefinition : + * - Description? union Name Directives[Const]? UnionMemberTypes? + */ + parseUnionTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + return this.node(start, { + kind: kinds_js_1.Kind.UNION_TYPE_DEFINITION, + description, + name, + directives, + types, + }); + } + /** + * UnionMemberTypes : + * - = `|`? NamedType + * - UnionMemberTypes | NamedType + */ + parseUnionMemberTypes() { + return this.expectOptionalToken(tokenKind_js_1.TokenKind.EQUALS) + ? this.delimitedMany(tokenKind_js_1.TokenKind.PIPE, this.parseNamedType) + : undefined; + } + /** + * EnumTypeDefinition : + * - Description? enum Name Directives[Const]? EnumValuesDefinition? + */ + parseEnumTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + return this.node(start, { + kind: kinds_js_1.Kind.ENUM_TYPE_DEFINITION, + description, + name, + directives, + values, + }); + } + /** + * ``` + * EnumValuesDefinition : { EnumValueDefinition+ } + * ``` + */ + parseEnumValuesDefinition() { + return this.optionalMany(tokenKind_js_1.TokenKind.BRACE_L, this.parseEnumValueDefinition, tokenKind_js_1.TokenKind.BRACE_R); + } + /** + * EnumValueDefinition : Description? EnumValue Directives[Const]? + */ + parseEnumValueDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseEnumValueName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: kinds_js_1.Kind.ENUM_VALUE_DEFINITION, + description, + name, + directives, + }); + } + /** + * EnumValue : Name but not `true`, `false` or `null` + */ + parseEnumValueName() { + if (this._lexer.token.value === 'true' || + this._lexer.token.value === 'false' || + this._lexer.token.value === 'null') { + throw (0, syntaxError_js_1.syntaxError)(this._lexer.source, this._lexer.token.start, `${getTokenDesc(this._lexer.token)} is reserved and cannot be used for an enum value.`); + } + return this.parseName(); + } + /** + * InputObjectTypeDefinition : + * - Description? input Name Directives[Const]? InputFieldsDefinition? + */ + parseInputObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + return this.node(start, { + kind: kinds_js_1.Kind.INPUT_OBJECT_TYPE_DEFINITION, + description, + name, + directives, + fields, + }); + } + /** + * ``` + * InputFieldsDefinition : { InputValueDefinition+ } + * ``` + */ + parseInputFieldsDefinition() { + return this.optionalMany(tokenKind_js_1.TokenKind.BRACE_L, this.parseInputValueDef, tokenKind_js_1.TokenKind.BRACE_R); + } + /** + * TypeSystemExtension : + * - SchemaExtension + * - TypeExtension + * + * TypeExtension : + * - ScalarTypeExtension + * - ObjectTypeExtension + * - InterfaceTypeExtension + * - UnionTypeExtension + * - EnumTypeExtension + * - InputObjectTypeDefinition + */ + parseTypeSystemExtension() { + const keywordToken = this._lexer.lookahead(); + if (keywordToken.kind === tokenKind_js_1.TokenKind.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaExtension(); + case 'scalar': + return this.parseScalarTypeExtension(); + case 'type': + return this.parseObjectTypeExtension(); + case 'interface': + return this.parseInterfaceTypeExtension(); + case 'union': + return this.parseUnionTypeExtension(); + case 'enum': + return this.parseEnumTypeExtension(); + case 'input': + return this.parseInputObjectTypeExtension(); + } + } + throw this.unexpected(keywordToken); + } + /** + * ``` + * SchemaExtension : + * - extend schema Directives[Const]? { OperationTypeDefinition+ } + * - extend schema Directives[Const] + * ``` + */ + parseSchemaExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.optionalMany(tokenKind_js_1.TokenKind.BRACE_L, this.parseOperationTypeDefinition, tokenKind_js_1.TokenKind.BRACE_R); + if (directives === undefined && operationTypes === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: kinds_js_1.Kind.SCHEMA_EXTENSION, + directives, + operationTypes, + }); + } + /** + * ScalarTypeExtension : + * - extend scalar Name Directives[Const] + */ + parseScalarTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + if (directives === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: kinds_js_1.Kind.SCALAR_TYPE_EXTENSION, + name, + directives, + }); + } + /** + * ObjectTypeExtension : + * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend type Name ImplementsInterfaces? Directives[Const] + * - extend type Name ImplementsInterfaces + */ + parseObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + if (interfaces === undefined && + directives === undefined && + fields === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: kinds_js_1.Kind.OBJECT_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * InterfaceTypeExtension : + * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend interface Name ImplementsInterfaces? Directives[Const] + * - extend interface Name ImplementsInterfaces + */ + parseInterfaceTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + if (interfaces === undefined && + directives === undefined && + fields === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: kinds_js_1.Kind.INTERFACE_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeExtension : + * - extend union Name Directives[Const]? UnionMemberTypes + * - extend union Name Directives[Const] + */ + parseUnionTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + if (directives === undefined && types === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: kinds_js_1.Kind.UNION_TYPE_EXTENSION, + name, + directives, + types, + }); + } + /** + * EnumTypeExtension : + * - extend enum Name Directives[Const]? EnumValuesDefinition + * - extend enum Name Directives[Const] + */ + parseEnumTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + if (directives === undefined && values === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: kinds_js_1.Kind.ENUM_TYPE_EXTENSION, + name, + directives, + values, + }); + } + /** + * InputObjectTypeExtension : + * - extend input Name Directives[Const]? InputFieldsDefinition + * - extend input Name Directives[Const] + */ + parseInputObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + if (directives === undefined && fields === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: kinds_js_1.Kind.INPUT_OBJECT_TYPE_EXTENSION, + name, + directives, + fields, + }); + } + /** + * ``` + * DirectiveDefinition : + * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations + * ``` + */ + parseDirectiveDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('directive'); + this.expectToken(tokenKind_js_1.TokenKind.AT); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + const repeatable = this.expectOptionalKeyword('repeatable'); + this.expectKeyword('on'); + const locations = this.parseDirectiveLocations(); + return this.node(start, { + kind: kinds_js_1.Kind.DIRECTIVE_DEFINITION, + description, + name, + arguments: args, + repeatable, + locations, + }); + } + /** + * DirectiveLocations : + * - `|`? DirectiveLocation + * - DirectiveLocations | DirectiveLocation + */ + parseDirectiveLocations() { + return this.delimitedMany(tokenKind_js_1.TokenKind.PIPE, this.parseDirectiveLocation); + } + /* + * DirectiveLocation : + * - ExecutableDirectiveLocation + * - TypeSystemDirectiveLocation + * + * ExecutableDirectiveLocation : one of + * `QUERY` + * `MUTATION` + * `SUBSCRIPTION` + * `FIELD` + * `FRAGMENT_DEFINITION` + * `FRAGMENT_SPREAD` + * `INLINE_FRAGMENT` + * + * TypeSystemDirectiveLocation : one of + * `SCHEMA` + * `SCALAR` + * `OBJECT` + * `FIELD_DEFINITION` + * `ARGUMENT_DEFINITION` + * `INTERFACE` + * `UNION` + * `ENUM` + * `ENUM_VALUE` + * `INPUT_OBJECT` + * `INPUT_FIELD_DEFINITION` + */ + parseDirectiveLocation() { + const start = this._lexer.token; + const name = this.parseName(); + if (Object.hasOwn(directiveLocation_js_1.DirectiveLocation, name.value)) { + return name; + } + throw this.unexpected(start); + } + // Core parsing utility functions + /** + * Returns a node that, if configured to do so, sets a "loc" field as a + * location object, used to identify the place in the source that created a + * given parsed object. + */ + node(startToken, node) { + if (this._options.noLocation !== true) { + node.loc = new ast_js_1.Location(startToken, this._lexer.lastToken, this._lexer.source); + } + return node; + } + /** + * Determines if the next token is of a given kind + */ + peek(kind) { + return this._lexer.token.kind === kind; + } + /** + * If the next token is of the given kind, return that token after advancing the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + expectToken(kind) { + const token = this._lexer.token; + if (token.kind === kind) { + this.advanceLexer(); + return token; + } + throw (0, syntaxError_js_1.syntaxError)(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`); + } + /** + * If the next token is of the given kind, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + expectOptionalToken(kind) { + const token = this._lexer.token; + if (token.kind === kind) { + this.advanceLexer(); + return true; + } + return false; + } + /** + * If the next token is a given keyword, advance the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + expectKeyword(value) { + const token = this._lexer.token; + if (token.kind === tokenKind_js_1.TokenKind.NAME && token.value === value) { + this.advanceLexer(); + } + else { + throw (0, syntaxError_js_1.syntaxError)(this._lexer.source, token.start, `Expected "${value}", found ${getTokenDesc(token)}.`); + } + } + /** + * If the next token is a given keyword, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + expectOptionalKeyword(value) { + const token = this._lexer.token; + if (token.kind === tokenKind_js_1.TokenKind.NAME && token.value === value) { + this.advanceLexer(); + return true; + } + return false; + } + /** + * Helper function for creating an error when an unexpected lexed token is encountered. + */ + unexpected(atToken) { + const token = atToken ?? this._lexer.token; + return (0, syntaxError_js_1.syntaxError)(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`); + } + /** + * Returns a possibly empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + any(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + while (!this.expectOptionalToken(closeKind)) { + nodes.push(parseFn.call(this)); + } + return nodes; + } + /** + * Returns a list of parse nodes, determined by the parseFn. + * It can be empty only if open token is missing otherwise it will always return non-empty list + * that begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + optionalMany(openKind, parseFn, closeKind) { + if (this.expectOptionalToken(openKind)) { + const nodes = []; + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + return nodes; + } + return undefined; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + many(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + return nodes; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind. + * Advances the parser to the next lex token after last item in the list. + */ + delimitedMany(delimiterKind, parseFn) { + this.expectOptionalToken(delimiterKind); + const nodes = []; + do { + nodes.push(parseFn.call(this)); + } while (this.expectOptionalToken(delimiterKind)); + return nodes; + } + advanceLexer() { + const { maxTokens } = this._options; + const token = this._lexer.advance(); + if (token.kind !== tokenKind_js_1.TokenKind.EOF) { + ++this._tokenCounter; + if (maxTokens !== undefined && this._tokenCounter > maxTokens) { + throw (0, syntaxError_js_1.syntaxError)(this._lexer.source, token.start, `Document contains more than ${maxTokens} tokens. Parsing aborted.`); + } + } + } +} +exports.Parser = Parser; +/** + * A helper function to describe a token as a string for debugging. + */ +function getTokenDesc(token) { + const value = token.value; + return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : ''); +} +/** + * A helper function to describe a token kind as a string for debugging. + */ +function getTokenKindDesc(kind) { + return (0, lexer_js_1.isPunctuatorTokenKind)(kind) ? `"${kind}"` : kind; +} +//# sourceMappingURL=parser.js.map \ No newline at end of file diff --git a/language/parser.js.map b/language/parser.js.map new file mode 100644 index 0000000000..e58f6a695c --- /dev/null +++ b/language/parser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/language/parser.ts"],"names":[],"mappings":";;;AAoHA,sBAWC;AAUD,gCASC;AAMD,0CASC;AAYD,8BASC;AAnLD,4DAAsD;AA4DtD,qCAAuD;AACvD,iEAA2D;AAC3D,yCAAkC;AAClC,yCAA0D;AAC1D,2CAA+C;AAC/C,iDAA2C;AA4C3C;;;GAGG;AACH,SAAgB,KAAK,CACnB,MAAuB,EACvB,OAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IACxC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,YAAY,EAAE;QAC5C,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,MAAM,CAAC,UAAU;KACzB,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CACxB,MAAuB,EACvB,OAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,WAAW,CAAC,wBAAS,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,WAAW,CAAC,wBAAS,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAC7B,MAAuB,EACvB,OAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,CA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AC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\nimport { syntaxError } from '../error/syntaxError.js';\n\nimport type {\n ArgumentNode,\n BooleanValueNode,\n ConstArgumentNode,\n ConstDirectiveNode,\n ConstListValueNode,\n ConstObjectFieldNode,\n ConstObjectValueNode,\n ConstValueNode,\n DefinitionNode,\n DirectiveDefinitionNode,\n DirectiveNode,\n DocumentNode,\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n EnumValueDefinitionNode,\n EnumValueNode,\n FieldDefinitionNode,\n FieldNode,\n FloatValueNode,\n FragmentArgumentNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n InputObjectTypeDefinitionNode,\n InputObjectTypeExtensionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n IntValueNode,\n ListTypeNode,\n ListValueNode,\n NamedTypeNode,\n NameNode,\n NonNullTypeNode,\n NullValueNode,\n ObjectFieldNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n ObjectValueNode,\n OperationDefinitionNode,\n OperationTypeDefinitionNode,\n ScalarTypeDefinitionNode,\n ScalarTypeExtensionNode,\n SchemaDefinitionNode,\n SchemaExtensionNode,\n SelectionNode,\n SelectionSetNode,\n StringValueNode,\n Token,\n TypeNode,\n TypeSystemExtensionNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n ValueNode,\n VariableDefinitionNode,\n VariableNode,\n} from './ast.js';\nimport { Location, OperationTypeNode } from './ast.js';\nimport { DirectiveLocation } from './directiveLocation.js';\nimport { Kind } from './kinds.js';\nimport { isPunctuatorTokenKind, Lexer } from './lexer.js';\nimport { isSource, Source } from './source.js';\nimport { TokenKind } from './tokenKind.js';\n\n/**\n * Configuration options to control parser behavior\n */\nexport interface ParseOptions {\n /**\n * By default, the parser creates AST nodes that know the location\n * in the source that they correspond to. This configuration flag\n * disables that behavior for performance or testing.\n */\n noLocation?: boolean | undefined;\n\n /**\n * Parser CPU and memory usage is linear to the number of tokens in a document\n * however in extreme cases it becomes quadratic due to memory exhaustion.\n * Parsing happens before validation so even invalid queries can burn lots of\n * CPU time and memory.\n * To prevent this you can set a maximum number of tokens allowed within a document.\n */\n maxTokens?: number | undefined;\n\n /**\n * EXPERIMENTAL:\n *\n * If enabled, the parser will understand and parse fragment variable definitions\n * and arguments on fragment spreads. Fragment variable definitions will be represented\n * in the `variableDefinitions` field of the FragmentDefinitionNode.\n * Fragment spread arguments will be represented in the `arguments` field of FragmentSpreadNode.\n *\n * For example:\n *\n * ```graphql\n * {\n * t { ...A(var: true) }\n * }\n * fragment A($var: Boolean = false) on T {\n * ...B(x: $var)\n * }\n * ```\n */\n experimentalFragmentArguments?: boolean | undefined;\n}\n\n/**\n * Given a GraphQL source, parses it into a Document.\n * Throws GraphQLError if a syntax error is encountered.\n */\nexport function parse(\n source: string | Source,\n options?: ParseOptions,\n): DocumentNode {\n const parser = new Parser(source, options);\n const document = parser.parseDocument();\n Object.defineProperty(document, 'tokenCount', {\n enumerable: false,\n value: parser.tokenCount,\n });\n return document;\n}\n\n/**\n * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for\n * that value.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Values directly and\n * in isolation of complete GraphQL documents.\n */\nexport function parseValue(\n source: string | Source,\n options?: ParseOptions,\n): ValueNode {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const value = parser.parseValueLiteral(false);\n parser.expectToken(TokenKind.EOF);\n return value;\n}\n\n/**\n * Similar to parseValue(), but raises a parse error if it encounters a\n * variable. The return type will be a constant value.\n */\nexport function parseConstValue(\n source: string | Source,\n options?: ParseOptions,\n): ConstValueNode {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const value = parser.parseConstValueLiteral();\n parser.expectToken(TokenKind.EOF);\n return value;\n}\n\n/**\n * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for\n * that type.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Types directly and\n * in isolation of complete GraphQL documents.\n *\n * Consider providing the results to the utility function: typeFromAST().\n */\nexport function parseType(\n source: string | Source,\n options?: ParseOptions,\n): TypeNode {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const type = parser.parseTypeReference();\n parser.expectToken(TokenKind.EOF);\n return type;\n}\n\n/**\n * This class is exported only to assist people in implementing their own parsers\n * without duplicating too much code and should be used only as last resort for cases\n * such as experimental syntax or if certain features could not be contributed upstream.\n *\n * It is still part of the internal API and is versioned, so any changes to it are never\n * considered breaking changes. If you still need to support multiple versions of the\n * library, please use the `versionInfo` variable for version detection.\n *\n * @internal\n */\nexport class Parser {\n protected _options: ParseOptions;\n protected _lexer: Lexer;\n protected _tokenCounter: number;\n\n constructor(source: string | Source, options: ParseOptions = {}) {\n const sourceObj = isSource(source) ? source : new Source(source);\n\n this._lexer = new Lexer(sourceObj);\n this._options = options;\n this._tokenCounter = 0;\n }\n\n get tokenCount(): number {\n return this._tokenCounter;\n }\n\n /**\n * Converts a name lex token into a name parse node.\n */\n parseName(): NameNode {\n const token = this.expectToken(TokenKind.NAME);\n return this.node(token, {\n kind: Kind.NAME,\n value: token.value,\n });\n }\n\n // Implements the parsing rules in the Document section.\n\n /**\n * Document : Definition+\n */\n parseDocument(): DocumentNode {\n return this.node(this._lexer.token, {\n kind: Kind.DOCUMENT,\n definitions: this.many(\n TokenKind.SOF,\n this.parseDefinition,\n TokenKind.EOF,\n ),\n });\n }\n\n /**\n * Definition :\n * - ExecutableDefinition\n * - TypeSystemDefinition\n * - TypeSystemExtension\n *\n * ExecutableDefinition :\n * - OperationDefinition\n * - FragmentDefinition\n *\n * TypeSystemDefinition :\n * - SchemaDefinition\n * - TypeDefinition\n * - DirectiveDefinition\n *\n * TypeDefinition :\n * - ScalarTypeDefinition\n * - ObjectTypeDefinition\n * - InterfaceTypeDefinition\n * - UnionTypeDefinition\n * - EnumTypeDefinition\n * - InputObjectTypeDefinition\n */\n parseDefinition(): DefinitionNode {\n if (this.peek(TokenKind.BRACE_L)) {\n return this.parseOperationDefinition();\n }\n\n // Many definitions begin with a description and require a lookahead.\n const hasDescription = this.peekDescription();\n const keywordToken = hasDescription\n ? this._lexer.lookahead()\n : this._lexer.token;\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaDefinition();\n case 'scalar':\n return this.parseScalarTypeDefinition();\n case 'type':\n return this.parseObjectTypeDefinition();\n case 'interface':\n return this.parseInterfaceTypeDefinition();\n case 'union':\n return this.parseUnionTypeDefinition();\n case 'enum':\n return this.parseEnumTypeDefinition();\n case 'input':\n return this.parseInputObjectTypeDefinition();\n case 'directive':\n return this.parseDirectiveDefinition();\n }\n\n if (hasDescription) {\n throw syntaxError(\n this._lexer.source,\n this._lexer.token.start,\n 'Unexpected description, descriptions are supported only on type definitions.',\n );\n }\n\n switch (keywordToken.value) {\n case 'query':\n case 'mutation':\n case 'subscription':\n return this.parseOperationDefinition();\n case 'fragment':\n return this.parseFragmentDefinition();\n case 'extend':\n return this.parseTypeSystemExtension();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n\n // Implements the parsing rules in the Operations section.\n\n /**\n * OperationDefinition :\n * - SelectionSet\n * - OperationType Name? VariableDefinitions? Directives? SelectionSet\n */\n parseOperationDefinition(): OperationDefinitionNode {\n const start = this._lexer.token;\n if (this.peek(TokenKind.BRACE_L)) {\n return this.node(start, {\n kind: Kind.OPERATION_DEFINITION,\n operation: OperationTypeNode.QUERY,\n name: undefined,\n variableDefinitions: undefined,\n directives: undefined,\n selectionSet: this.parseSelectionSet(),\n });\n }\n const operation = this.parseOperationType();\n let name;\n if (this.peek(TokenKind.NAME)) {\n name = this.parseName();\n }\n return this.node(start, {\n kind: Kind.OPERATION_DEFINITION,\n operation,\n name,\n variableDefinitions: this.parseVariableDefinitions(),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n\n /**\n * OperationType : one of query mutation subscription\n */\n parseOperationType(): OperationTypeNode {\n const operationToken = this.expectToken(TokenKind.NAME);\n switch (operationToken.value) {\n case 'query':\n return OperationTypeNode.QUERY;\n case 'mutation':\n return OperationTypeNode.MUTATION;\n case 'subscription':\n return OperationTypeNode.SUBSCRIPTION;\n }\n\n throw this.unexpected(operationToken);\n }\n\n /**\n * VariableDefinitions : ( VariableDefinition+ )\n */\n parseVariableDefinitions(): Array | undefined {\n return this.optionalMany(\n TokenKind.PAREN_L,\n this.parseVariableDefinition,\n TokenKind.PAREN_R,\n );\n }\n\n /**\n * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?\n */\n parseVariableDefinition(): VariableDefinitionNode {\n return this.node(this._lexer.token, {\n kind: Kind.VARIABLE_DEFINITION,\n variable: this.parseVariable(),\n type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),\n defaultValue: this.expectOptionalToken(TokenKind.EQUALS)\n ? this.parseConstValueLiteral()\n : undefined,\n directives: this.parseConstDirectives(),\n });\n }\n\n /**\n * Variable : $ Name\n */\n parseVariable(): VariableNode {\n const start = this._lexer.token;\n this.expectToken(TokenKind.DOLLAR);\n return this.node(start, {\n kind: Kind.VARIABLE,\n name: this.parseName(),\n });\n }\n\n /**\n * ```\n * SelectionSet : { Selection+ }\n * ```\n */\n parseSelectionSet(): SelectionSetNode {\n return this.node(this._lexer.token, {\n kind: Kind.SELECTION_SET,\n selections: this.many(\n TokenKind.BRACE_L,\n this.parseSelection,\n TokenKind.BRACE_R,\n ),\n });\n }\n\n /**\n * Selection :\n * - Field\n * - FragmentSpread\n * - InlineFragment\n */\n parseSelection(): SelectionNode {\n return this.peek(TokenKind.SPREAD)\n ? this.parseFragment()\n : this.parseField();\n }\n\n /**\n * Field : Alias? Name Arguments? Directives? SelectionSet?\n *\n * Alias : Name :\n */\n parseField(): FieldNode {\n const start = this._lexer.token;\n\n const nameOrAlias = this.parseName();\n let alias;\n let name;\n if (this.expectOptionalToken(TokenKind.COLON)) {\n alias = nameOrAlias;\n name = this.parseName();\n } else {\n name = nameOrAlias;\n }\n\n return this.node(start, {\n kind: Kind.FIELD,\n alias,\n name,\n arguments: this.parseArguments(false),\n directives: this.parseDirectives(false),\n selectionSet: this.peek(TokenKind.BRACE_L)\n ? this.parseSelectionSet()\n : undefined,\n });\n }\n\n /**\n * Arguments[Const] : ( Argument[?Const]+ )\n */\n parseArguments(isConst: true): Array | undefined;\n parseArguments(isConst: boolean): Array | undefined;\n parseArguments(isConst: boolean): Array | undefined {\n const item = isConst ? this.parseConstArgument : this.parseArgument;\n return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);\n }\n\n /* experimental */\n parseFragmentArguments(): Array | undefined {\n const item = this.parseFragmentArgument;\n return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);\n }\n\n /**\n * Argument[Const] : Name : Value[?Const]\n */\n parseArgument(isConst: true): ConstArgumentNode;\n parseArgument(isConst?: boolean): ArgumentNode;\n parseArgument(isConst: boolean = false): ArgumentNode {\n const start = this._lexer.token;\n const name = this.parseName();\n\n this.expectToken(TokenKind.COLON);\n return this.node(start, {\n kind: Kind.ARGUMENT,\n name,\n value: this.parseValueLiteral(isConst),\n });\n }\n\n parseConstArgument(): ConstArgumentNode {\n return this.parseArgument(true);\n }\n\n /* experimental */\n parseFragmentArgument(): FragmentArgumentNode {\n const start = this._lexer.token;\n const name = this.parseName();\n\n this.expectToken(TokenKind.COLON);\n return this.node(start, {\n kind: Kind.FRAGMENT_ARGUMENT,\n name,\n value: this.parseValueLiteral(false),\n });\n }\n\n // Implements the parsing rules in the Fragments section.\n\n /**\n * Corresponds to both FragmentSpread and InlineFragment in the spec.\n *\n * FragmentSpread : ... FragmentName Arguments? Directives?\n *\n * InlineFragment : ... TypeCondition? Directives? SelectionSet\n */\n parseFragment(): FragmentSpreadNode | InlineFragmentNode {\n const start = this._lexer.token;\n this.expectToken(TokenKind.SPREAD);\n\n const hasTypeCondition = this.expectOptionalKeyword('on');\n if (!hasTypeCondition && this.peek(TokenKind.NAME)) {\n const name = this.parseFragmentName();\n if (\n this.peek(TokenKind.PAREN_L) &&\n this._options.experimentalFragmentArguments\n ) {\n return this.node(start, {\n kind: Kind.FRAGMENT_SPREAD,\n name,\n arguments: this.parseFragmentArguments(),\n directives: this.parseDirectives(false),\n });\n }\n return this.node(start, {\n kind: Kind.FRAGMENT_SPREAD,\n name,\n directives: this.parseDirectives(false),\n });\n }\n return this.node(start, {\n kind: Kind.INLINE_FRAGMENT,\n typeCondition: hasTypeCondition ? this.parseNamedType() : undefined,\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n\n /**\n * FragmentDefinition :\n * - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet\n *\n * TypeCondition : NamedType\n */\n parseFragmentDefinition(): FragmentDefinitionNode {\n const start = this._lexer.token;\n this.expectKeyword('fragment');\n if (this._options.experimentalFragmentArguments === true) {\n return this.node(start, {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n variableDefinitions: this.parseVariableDefinitions(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n return this.node(start, {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n\n /**\n * FragmentName : Name but not `on`\n */\n parseFragmentName(): NameNode {\n if (this._lexer.token.value === 'on') {\n throw this.unexpected();\n }\n return this.parseName();\n }\n\n // Implements the parsing rules in the Values section.\n\n /**\n * Value[Const] :\n * - [~Const] Variable\n * - IntValue\n * - FloatValue\n * - StringValue\n * - BooleanValue\n * - NullValue\n * - EnumValue\n * - ListValue[?Const]\n * - ObjectValue[?Const]\n *\n * BooleanValue : one of `true` `false`\n *\n * NullValue : `null`\n *\n * EnumValue : Name but not `true`, `false` or `null`\n */\n parseValueLiteral(isConst: true): ConstValueNode;\n parseValueLiteral(isConst: boolean): ValueNode;\n parseValueLiteral(isConst: boolean): ValueNode {\n const token = this._lexer.token;\n switch (token.kind) {\n case TokenKind.BRACKET_L:\n return this.parseList(isConst);\n case TokenKind.BRACE_L:\n return this.parseObject(isConst);\n case TokenKind.INT:\n this.advanceLexer();\n return this.node(token, {\n kind: Kind.INT,\n value: token.value,\n });\n case TokenKind.FLOAT:\n this.advanceLexer();\n return this.node(token, {\n kind: Kind.FLOAT,\n value: token.value,\n });\n case TokenKind.STRING:\n case TokenKind.BLOCK_STRING:\n return this.parseStringLiteral();\n case TokenKind.NAME:\n this.advanceLexer();\n switch (token.value) {\n case 'true':\n return this.node(token, {\n kind: Kind.BOOLEAN,\n value: true,\n });\n case 'false':\n return this.node(token, {\n kind: Kind.BOOLEAN,\n value: false,\n });\n case 'null':\n return this.node(token, { kind: Kind.NULL });\n default:\n return this.node(token, {\n kind: Kind.ENUM,\n value: token.value,\n });\n }\n case TokenKind.DOLLAR:\n if (isConst) {\n this.expectToken(TokenKind.DOLLAR);\n if (this._lexer.token.kind === TokenKind.NAME) {\n const varName = this._lexer.token.value;\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Unexpected variable \"$${varName}\" in constant value.`,\n );\n } else {\n throw this.unexpected(token);\n }\n }\n return this.parseVariable();\n default:\n throw this.unexpected();\n }\n }\n\n parseConstValueLiteral(): ConstValueNode {\n return this.parseValueLiteral(true);\n }\n\n parseStringLiteral(): StringValueNode {\n const token = this._lexer.token;\n this.advanceLexer();\n return this.node(token, {\n kind: Kind.STRING,\n value: token.value,\n block: token.kind === TokenKind.BLOCK_STRING,\n });\n }\n\n /**\n * ListValue[Const] :\n * - [ ]\n * - [ Value[?Const]+ ]\n */\n parseList(isConst: true): ConstListValueNode;\n parseList(isConst: boolean): ListValueNode;\n parseList(isConst: boolean): ListValueNode {\n const item = () => this.parseValueLiteral(isConst);\n return this.node(this._lexer.token, {\n kind: Kind.LIST,\n values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),\n });\n }\n\n /**\n * ```\n * ObjectValue[Const] :\n * - { }\n * - { ObjectField[?Const]+ }\n * ```\n */\n parseObject(isConst: true): ConstObjectValueNode;\n parseObject(isConst: boolean): ObjectValueNode;\n parseObject(isConst: boolean): ObjectValueNode {\n const item = () => this.parseObjectField(isConst);\n return this.node(this._lexer.token, {\n kind: Kind.OBJECT,\n fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R),\n });\n }\n\n /**\n * ObjectField[Const] : Name : Value[?Const]\n */\n parseObjectField(isConst: true): ConstObjectFieldNode;\n parseObjectField(isConst: boolean): ObjectFieldNode;\n parseObjectField(isConst: boolean): ObjectFieldNode {\n const start = this._lexer.token;\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n return this.node(start, {\n kind: Kind.OBJECT_FIELD,\n name,\n value: this.parseValueLiteral(isConst),\n });\n }\n\n // Implements the parsing rules in the Directives section.\n\n /**\n * Directives[Const] : Directive[?Const]+\n */\n parseDirectives(isConst: true): Array | undefined;\n parseDirectives(isConst: boolean): Array | undefined;\n parseDirectives(isConst: boolean): Array | undefined {\n const directives = [];\n while (this.peek(TokenKind.AT)) {\n directives.push(this.parseDirective(isConst));\n }\n if (directives.length) {\n return directives;\n }\n return undefined;\n }\n\n parseConstDirectives(): Array | undefined {\n return this.parseDirectives(true);\n }\n\n /**\n * ```\n * Directive[Const] : @ Name Arguments[?Const]?\n * ```\n */\n parseDirective(isConst: true): ConstDirectiveNode;\n parseDirective(isConst: boolean): DirectiveNode;\n parseDirective(isConst: boolean): DirectiveNode {\n const start = this._lexer.token;\n this.expectToken(TokenKind.AT);\n return this.node(start, {\n kind: Kind.DIRECTIVE,\n name: this.parseName(),\n arguments: this.parseArguments(isConst),\n });\n }\n\n // Implements the parsing rules in the Types section.\n\n /**\n * Type :\n * - NamedType\n * - ListType\n * - NonNullType\n */\n parseTypeReference(): TypeNode {\n const start = this._lexer.token;\n let type;\n if (this.expectOptionalToken(TokenKind.BRACKET_L)) {\n const innerType = this.parseTypeReference();\n this.expectToken(TokenKind.BRACKET_R);\n type = this.node(start, {\n kind: Kind.LIST_TYPE,\n type: innerType,\n });\n } else {\n type = this.parseNamedType();\n }\n\n if (this.expectOptionalToken(TokenKind.BANG)) {\n return this.node(start, {\n kind: Kind.NON_NULL_TYPE,\n type,\n });\n }\n\n return type;\n }\n\n /**\n * NamedType : Name\n */\n parseNamedType(): NamedTypeNode {\n return this.node(this._lexer.token, {\n kind: Kind.NAMED_TYPE,\n name: this.parseName(),\n });\n }\n\n // Implements the parsing rules in the Type Definition section.\n\n peekDescription(): boolean {\n return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);\n }\n\n /**\n * Description : StringValue\n */\n parseDescription(): undefined | StringValueNode {\n if (this.peekDescription()) {\n return this.parseStringLiteral();\n }\n }\n\n /**\n * ```\n * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }\n * ```\n */\n parseSchemaDefinition(): SchemaDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('schema');\n const directives = this.parseConstDirectives();\n const operationTypes = this.many(\n TokenKind.BRACE_L,\n this.parseOperationTypeDefinition,\n TokenKind.BRACE_R,\n );\n return this.node(start, {\n kind: Kind.SCHEMA_DEFINITION,\n description,\n directives,\n operationTypes,\n });\n }\n\n /**\n * OperationTypeDefinition : OperationType : NamedType\n */\n parseOperationTypeDefinition(): OperationTypeDefinitionNode {\n const start = this._lexer.token;\n const operation = this.parseOperationType();\n this.expectToken(TokenKind.COLON);\n const type = this.parseNamedType();\n return this.node(start, {\n kind: Kind.OPERATION_TYPE_DEFINITION,\n operation,\n type,\n });\n }\n\n /**\n * ScalarTypeDefinition : Description? scalar Name Directives[Const]?\n */\n parseScalarTypeDefinition(): ScalarTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.SCALAR_TYPE_DEFINITION,\n description,\n name,\n directives,\n });\n }\n\n /**\n * ObjectTypeDefinition :\n * Description?\n * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?\n */\n parseObjectTypeDefinition(): ObjectTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n return this.node(start, {\n kind: Kind.OBJECT_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * ImplementsInterfaces :\n * - implements `&`? NamedType\n * - ImplementsInterfaces & NamedType\n */\n parseImplementsInterfaces(): Array | undefined {\n return this.expectOptionalKeyword('implements')\n ? this.delimitedMany(TokenKind.AMP, this.parseNamedType)\n : undefined;\n }\n\n /**\n * ```\n * FieldsDefinition : { FieldDefinition+ }\n * ```\n */\n parseFieldsDefinition(): Array | undefined {\n return this.optionalMany(\n TokenKind.BRACE_L,\n this.parseFieldDefinition,\n TokenKind.BRACE_R,\n );\n }\n\n /**\n * FieldDefinition :\n * - Description? Name ArgumentsDefinition? : Type Directives[Const]?\n */\n parseFieldDefinition(): FieldDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.FIELD_DEFINITION,\n description,\n name,\n arguments: args,\n type,\n directives,\n });\n }\n\n /**\n * ArgumentsDefinition : ( InputValueDefinition+ )\n */\n parseArgumentDefs(): Array | undefined {\n return this.optionalMany(\n TokenKind.PAREN_L,\n this.parseInputValueDef,\n TokenKind.PAREN_R,\n );\n }\n\n /**\n * InputValueDefinition :\n * - Description? Name : Type DefaultValue? Directives[Const]?\n */\n parseInputValueDef(): InputValueDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n let defaultValue;\n if (this.expectOptionalToken(TokenKind.EQUALS)) {\n defaultValue = this.parseConstValueLiteral();\n }\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.INPUT_VALUE_DEFINITION,\n description,\n name,\n type,\n defaultValue,\n directives,\n });\n }\n\n /**\n * InterfaceTypeDefinition :\n * - Description? interface Name Directives[Const]? FieldsDefinition?\n */\n parseInterfaceTypeDefinition(): InterfaceTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n return this.node(start, {\n kind: Kind.INTERFACE_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * UnionTypeDefinition :\n * - Description? union Name Directives[Const]? UnionMemberTypes?\n */\n parseUnionTypeDefinition(): UnionTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const types = this.parseUnionMemberTypes();\n return this.node(start, {\n kind: Kind.UNION_TYPE_DEFINITION,\n description,\n name,\n directives,\n types,\n });\n }\n\n /**\n * UnionMemberTypes :\n * - = `|`? NamedType\n * - UnionMemberTypes | NamedType\n */\n parseUnionMemberTypes(): Array | undefined {\n return this.expectOptionalToken(TokenKind.EQUALS)\n ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType)\n : undefined;\n }\n\n /**\n * EnumTypeDefinition :\n * - Description? enum Name Directives[Const]? EnumValuesDefinition?\n */\n parseEnumTypeDefinition(): EnumTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const values = this.parseEnumValuesDefinition();\n return this.node(start, {\n kind: Kind.ENUM_TYPE_DEFINITION,\n description,\n name,\n directives,\n values,\n });\n }\n\n /**\n * ```\n * EnumValuesDefinition : { EnumValueDefinition+ }\n * ```\n */\n parseEnumValuesDefinition(): Array | undefined {\n return this.optionalMany(\n TokenKind.BRACE_L,\n this.parseEnumValueDefinition,\n TokenKind.BRACE_R,\n );\n }\n\n /**\n * EnumValueDefinition : Description? EnumValue Directives[Const]?\n */\n parseEnumValueDefinition(): EnumValueDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseEnumValueName();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.ENUM_VALUE_DEFINITION,\n description,\n name,\n directives,\n });\n }\n\n /**\n * EnumValue : Name but not `true`, `false` or `null`\n */\n parseEnumValueName(): NameNode {\n if (\n this._lexer.token.value === 'true' ||\n this._lexer.token.value === 'false' ||\n this._lexer.token.value === 'null'\n ) {\n throw syntaxError(\n this._lexer.source,\n this._lexer.token.start,\n `${getTokenDesc(\n this._lexer.token,\n )} is reserved and cannot be used for an enum value.`,\n );\n }\n return this.parseName();\n }\n\n /**\n * InputObjectTypeDefinition :\n * - Description? input Name Directives[Const]? InputFieldsDefinition?\n */\n parseInputObjectTypeDefinition(): InputObjectTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const fields = this.parseInputFieldsDefinition();\n return this.node(start, {\n kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,\n description,\n name,\n directives,\n fields,\n });\n }\n\n /**\n * ```\n * InputFieldsDefinition : { InputValueDefinition+ }\n * ```\n */\n parseInputFieldsDefinition(): Array | undefined {\n return this.optionalMany(\n TokenKind.BRACE_L,\n this.parseInputValueDef,\n TokenKind.BRACE_R,\n );\n }\n\n /**\n * TypeSystemExtension :\n * - SchemaExtension\n * - TypeExtension\n *\n * TypeExtension :\n * - ScalarTypeExtension\n * - ObjectTypeExtension\n * - InterfaceTypeExtension\n * - UnionTypeExtension\n * - EnumTypeExtension\n * - InputObjectTypeDefinition\n */\n parseTypeSystemExtension(): TypeSystemExtensionNode {\n const keywordToken = this._lexer.lookahead();\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaExtension();\n case 'scalar':\n return this.parseScalarTypeExtension();\n case 'type':\n return this.parseObjectTypeExtension();\n case 'interface':\n return this.parseInterfaceTypeExtension();\n case 'union':\n return this.parseUnionTypeExtension();\n case 'enum':\n return this.parseEnumTypeExtension();\n case 'input':\n return this.parseInputObjectTypeExtension();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n\n /**\n * ```\n * SchemaExtension :\n * - extend schema Directives[Const]? { OperationTypeDefinition+ }\n * - extend schema Directives[Const]\n * ```\n */\n parseSchemaExtension(): SchemaExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('schema');\n const directives = this.parseConstDirectives();\n const operationTypes = this.optionalMany(\n TokenKind.BRACE_L,\n this.parseOperationTypeDefinition,\n TokenKind.BRACE_R,\n );\n if (directives === undefined && operationTypes === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.SCHEMA_EXTENSION,\n directives,\n operationTypes,\n });\n }\n\n /**\n * ScalarTypeExtension :\n * - extend scalar Name Directives[Const]\n */\n parseScalarTypeExtension(): ScalarTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n if (directives === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.SCALAR_TYPE_EXTENSION,\n name,\n directives,\n });\n }\n\n /**\n * ObjectTypeExtension :\n * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend type Name ImplementsInterfaces? Directives[Const]\n * - extend type Name ImplementsInterfaces\n */\n parseObjectTypeExtension(): ObjectTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n if (\n interfaces === undefined &&\n directives === undefined &&\n fields === undefined\n ) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.OBJECT_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * InterfaceTypeExtension :\n * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend interface Name ImplementsInterfaces? Directives[Const]\n * - extend interface Name ImplementsInterfaces\n */\n parseInterfaceTypeExtension(): InterfaceTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n if (\n interfaces === undefined &&\n directives === undefined &&\n fields === undefined\n ) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.INTERFACE_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * UnionTypeExtension :\n * - extend union Name Directives[Const]? UnionMemberTypes\n * - extend union Name Directives[Const]\n */\n parseUnionTypeExtension(): UnionTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const types = this.parseUnionMemberTypes();\n if (directives === undefined && types === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.UNION_TYPE_EXTENSION,\n name,\n directives,\n types,\n });\n }\n\n /**\n * EnumTypeExtension :\n * - extend enum Name Directives[Const]? EnumValuesDefinition\n * - extend enum Name Directives[Const]\n */\n parseEnumTypeExtension(): EnumTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const values = this.parseEnumValuesDefinition();\n if (directives === undefined && values === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.ENUM_TYPE_EXTENSION,\n name,\n directives,\n values,\n });\n }\n\n /**\n * InputObjectTypeExtension :\n * - extend input Name Directives[Const]? InputFieldsDefinition\n * - extend input Name Directives[Const]\n */\n parseInputObjectTypeExtension(): InputObjectTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const fields = this.parseInputFieldsDefinition();\n if (directives === undefined && fields === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,\n name,\n directives,\n fields,\n });\n }\n\n /**\n * ```\n * DirectiveDefinition :\n * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations\n * ```\n */\n parseDirectiveDefinition(): DirectiveDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('directive');\n this.expectToken(TokenKind.AT);\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n const repeatable = this.expectOptionalKeyword('repeatable');\n this.expectKeyword('on');\n const locations = this.parseDirectiveLocations();\n return this.node(start, {\n kind: Kind.DIRECTIVE_DEFINITION,\n description,\n name,\n arguments: args,\n repeatable,\n locations,\n });\n }\n\n /**\n * DirectiveLocations :\n * - `|`? DirectiveLocation\n * - DirectiveLocations | DirectiveLocation\n */\n parseDirectiveLocations(): Array {\n return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);\n }\n\n /*\n * DirectiveLocation :\n * - ExecutableDirectiveLocation\n * - TypeSystemDirectiveLocation\n *\n * ExecutableDirectiveLocation : one of\n * `QUERY`\n * `MUTATION`\n * `SUBSCRIPTION`\n * `FIELD`\n * `FRAGMENT_DEFINITION`\n * `FRAGMENT_SPREAD`\n * `INLINE_FRAGMENT`\n *\n * TypeSystemDirectiveLocation : one of\n * `SCHEMA`\n * `SCALAR`\n * `OBJECT`\n * `FIELD_DEFINITION`\n * `ARGUMENT_DEFINITION`\n * `INTERFACE`\n * `UNION`\n * `ENUM`\n * `ENUM_VALUE`\n * `INPUT_OBJECT`\n * `INPUT_FIELD_DEFINITION`\n */\n parseDirectiveLocation(): NameNode {\n const start = this._lexer.token;\n const name = this.parseName();\n if (Object.hasOwn(DirectiveLocation, name.value)) {\n return name;\n }\n throw this.unexpected(start);\n }\n\n // Core parsing utility functions\n\n /**\n * Returns a node that, if configured to do so, sets a \"loc\" field as a\n * location object, used to identify the place in the source that created a\n * given parsed object.\n */\n node(\n startToken: Token,\n node: T,\n ): T {\n if (this._options.noLocation !== true) {\n node.loc = new Location(\n startToken,\n this._lexer.lastToken,\n this._lexer.source,\n );\n }\n return node;\n }\n\n /**\n * Determines if the next token is of a given kind\n */\n peek(kind: TokenKind): boolean {\n return this._lexer.token.kind === kind;\n }\n\n /**\n * If the next token is of the given kind, return that token after advancing the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n expectToken(kind: TokenKind): Token {\n const token = this._lexer.token;\n if (token.kind === kind) {\n this.advanceLexer();\n return token;\n }\n\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`,\n );\n }\n\n /**\n * If the next token is of the given kind, return \"true\" after advancing the lexer.\n * Otherwise, do not change the parser state and return \"false\".\n */\n expectOptionalToken(kind: TokenKind): boolean {\n const token = this._lexer.token;\n if (token.kind === kind) {\n this.advanceLexer();\n return true;\n }\n return false;\n }\n\n /**\n * If the next token is a given keyword, advance the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n expectKeyword(value: string): void {\n const token = this._lexer.token;\n if (token.kind === TokenKind.NAME && token.value === value) {\n this.advanceLexer();\n } else {\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Expected \"${value}\", found ${getTokenDesc(token)}.`,\n );\n }\n }\n\n /**\n * If the next token is a given keyword, return \"true\" after advancing the lexer.\n * Otherwise, do not change the parser state and return \"false\".\n */\n expectOptionalKeyword(value: string): boolean {\n const token = this._lexer.token;\n if (token.kind === TokenKind.NAME && token.value === value) {\n this.advanceLexer();\n return true;\n }\n return false;\n }\n\n /**\n * Helper function for creating an error when an unexpected lexed token is encountered.\n */\n unexpected(atToken?: Maybe): GraphQLError {\n const token = atToken ?? this._lexer.token;\n return syntaxError(\n this._lexer.source,\n token.start,\n `Unexpected ${getTokenDesc(token)}.`,\n );\n }\n\n /**\n * Returns a possibly empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n any(\n openKind: TokenKind,\n parseFn: () => T,\n closeKind: TokenKind,\n ): Array {\n this.expectToken(openKind);\n const nodes = [];\n while (!this.expectOptionalToken(closeKind)) {\n nodes.push(parseFn.call(this));\n }\n return nodes;\n }\n\n /**\n * Returns a list of parse nodes, determined by the parseFn.\n * It can be empty only if open token is missing otherwise it will always return non-empty list\n * that begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n optionalMany(\n openKind: TokenKind,\n parseFn: () => T,\n closeKind: TokenKind,\n ): Array | undefined {\n if (this.expectOptionalToken(openKind)) {\n const nodes = [];\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n return nodes;\n }\n return undefined;\n }\n\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n many(\n openKind: TokenKind,\n parseFn: () => T,\n closeKind: TokenKind,\n ): Array {\n this.expectToken(openKind);\n const nodes = [];\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n return nodes;\n }\n\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.\n * Advances the parser to the next lex token after last item in the list.\n */\n delimitedMany(delimiterKind: TokenKind, parseFn: () => T): Array {\n this.expectOptionalToken(delimiterKind);\n\n const nodes = [];\n do {\n nodes.push(parseFn.call(this));\n } while (this.expectOptionalToken(delimiterKind));\n return nodes;\n }\n\n advanceLexer(): void {\n const { maxTokens } = this._options;\n const token = this._lexer.advance();\n\n if (token.kind !== TokenKind.EOF) {\n ++this._tokenCounter;\n if (maxTokens !== undefined && this._tokenCounter > maxTokens) {\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Document contains more than ${maxTokens} tokens. Parsing aborted.`,\n );\n }\n }\n }\n}\n\n/**\n * A helper function to describe a token as a string for debugging.\n */\nfunction getTokenDesc(token: Token): string {\n const value = token.value;\n return getTokenKindDesc(token.kind) + (value != null ? ` \"${value}\"` : '');\n}\n\n/**\n * A helper function to describe a token kind as a string for debugging.\n */\nfunction getTokenKindDesc(kind: TokenKind): string {\n return isPunctuatorTokenKind(kind) ? `\"${kind}\"` : kind;\n}\n"]} \ No newline at end of file diff --git a/language/parser.mjs b/language/parser.mjs new file mode 100644 index 0000000000..f5508507aa --- /dev/null +++ b/language/parser.mjs @@ -0,0 +1,1258 @@ +import { syntaxError } from "../error/syntaxError.mjs"; +import { Location, OperationTypeNode } from "./ast.mjs"; +import { DirectiveLocation } from "./directiveLocation.mjs"; +import { Kind } from "./kinds.mjs"; +import { isPunctuatorTokenKind, Lexer } from "./lexer.mjs"; +import { isSource, Source } from "./source.mjs"; +import { TokenKind } from "./tokenKind.mjs"; +/** + * Given a GraphQL source, parses it into a Document. + * Throws GraphQLError if a syntax error is encountered. + */ +export function parse(source, options) { + const parser = new Parser(source, options); + const document = parser.parseDocument(); + Object.defineProperty(document, 'tokenCount', { + enumerable: false, + value: parser.tokenCount, + }); + return document; +} +/** + * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for + * that value. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Values directly and + * in isolation of complete GraphQL documents. + */ +export function parseValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(TokenKind.SOF); + const value = parser.parseValueLiteral(false); + parser.expectToken(TokenKind.EOF); + return value; +} +/** + * Similar to parseValue(), but raises a parse error if it encounters a + * variable. The return type will be a constant value. + */ +export function parseConstValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(TokenKind.SOF); + const value = parser.parseConstValueLiteral(); + parser.expectToken(TokenKind.EOF); + return value; +} +/** + * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for + * that type. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Types directly and + * in isolation of complete GraphQL documents. + * + * Consider providing the results to the utility function: typeFromAST(). + */ +export function parseType(source, options) { + const parser = new Parser(source, options); + parser.expectToken(TokenKind.SOF); + const type = parser.parseTypeReference(); + parser.expectToken(TokenKind.EOF); + return type; +} +/** + * This class is exported only to assist people in implementing their own parsers + * without duplicating too much code and should be used only as last resort for cases + * such as experimental syntax or if certain features could not be contributed upstream. + * + * It is still part of the internal API and is versioned, so any changes to it are never + * considered breaking changes. If you still need to support multiple versions of the + * library, please use the `versionInfo` variable for version detection. + * + * @internal + */ +export class Parser { + constructor(source, options = {}) { + const sourceObj = isSource(source) ? source : new Source(source); + this._lexer = new Lexer(sourceObj); + this._options = options; + this._tokenCounter = 0; + } + get tokenCount() { + return this._tokenCounter; + } + /** + * Converts a name lex token into a name parse node. + */ + parseName() { + const token = this.expectToken(TokenKind.NAME); + return this.node(token, { + kind: Kind.NAME, + value: token.value, + }); + } + // Implements the parsing rules in the Document section. + /** + * Document : Definition+ + */ + parseDocument() { + return this.node(this._lexer.token, { + kind: Kind.DOCUMENT, + definitions: this.many(TokenKind.SOF, this.parseDefinition, TokenKind.EOF), + }); + } + /** + * Definition : + * - ExecutableDefinition + * - TypeSystemDefinition + * - TypeSystemExtension + * + * ExecutableDefinition : + * - OperationDefinition + * - FragmentDefinition + * + * TypeSystemDefinition : + * - SchemaDefinition + * - TypeDefinition + * - DirectiveDefinition + * + * TypeDefinition : + * - ScalarTypeDefinition + * - ObjectTypeDefinition + * - InterfaceTypeDefinition + * - UnionTypeDefinition + * - EnumTypeDefinition + * - InputObjectTypeDefinition + */ + parseDefinition() { + if (this.peek(TokenKind.BRACE_L)) { + return this.parseOperationDefinition(); + } + // Many definitions begin with a description and require a lookahead. + const hasDescription = this.peekDescription(); + const keywordToken = hasDescription + ? this._lexer.lookahead() + : this._lexer.token; + if (keywordToken.kind === TokenKind.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaDefinition(); + case 'scalar': + return this.parseScalarTypeDefinition(); + case 'type': + return this.parseObjectTypeDefinition(); + case 'interface': + return this.parseInterfaceTypeDefinition(); + case 'union': + return this.parseUnionTypeDefinition(); + case 'enum': + return this.parseEnumTypeDefinition(); + case 'input': + return this.parseInputObjectTypeDefinition(); + case 'directive': + return this.parseDirectiveDefinition(); + } + if (hasDescription) { + throw syntaxError(this._lexer.source, this._lexer.token.start, 'Unexpected description, descriptions are supported only on type definitions.'); + } + switch (keywordToken.value) { + case 'query': + case 'mutation': + case 'subscription': + return this.parseOperationDefinition(); + case 'fragment': + return this.parseFragmentDefinition(); + case 'extend': + return this.parseTypeSystemExtension(); + } + } + throw this.unexpected(keywordToken); + } + // Implements the parsing rules in the Operations section. + /** + * OperationDefinition : + * - SelectionSet + * - OperationType Name? VariableDefinitions? Directives? SelectionSet + */ + parseOperationDefinition() { + const start = this._lexer.token; + if (this.peek(TokenKind.BRACE_L)) { + return this.node(start, { + kind: Kind.OPERATION_DEFINITION, + operation: OperationTypeNode.QUERY, + name: undefined, + variableDefinitions: undefined, + directives: undefined, + selectionSet: this.parseSelectionSet(), + }); + } + const operation = this.parseOperationType(); + let name; + if (this.peek(TokenKind.NAME)) { + name = this.parseName(); + } + return this.node(start, { + kind: Kind.OPERATION_DEFINITION, + operation, + name, + variableDefinitions: this.parseVariableDefinitions(), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * OperationType : one of query mutation subscription + */ + parseOperationType() { + const operationToken = this.expectToken(TokenKind.NAME); + switch (operationToken.value) { + case 'query': + return OperationTypeNode.QUERY; + case 'mutation': + return OperationTypeNode.MUTATION; + case 'subscription': + return OperationTypeNode.SUBSCRIPTION; + } + throw this.unexpected(operationToken); + } + /** + * VariableDefinitions : ( VariableDefinition+ ) + */ + parseVariableDefinitions() { + return this.optionalMany(TokenKind.PAREN_L, this.parseVariableDefinition, TokenKind.PAREN_R); + } + /** + * VariableDefinition : Variable : Type DefaultValue? Directives[Const]? + */ + parseVariableDefinition() { + return this.node(this._lexer.token, { + kind: Kind.VARIABLE_DEFINITION, + variable: this.parseVariable(), + type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()), + defaultValue: this.expectOptionalToken(TokenKind.EQUALS) + ? this.parseConstValueLiteral() + : undefined, + directives: this.parseConstDirectives(), + }); + } + /** + * Variable : $ Name + */ + parseVariable() { + const start = this._lexer.token; + this.expectToken(TokenKind.DOLLAR); + return this.node(start, { + kind: Kind.VARIABLE, + name: this.parseName(), + }); + } + /** + * ``` + * SelectionSet : { Selection+ } + * ``` + */ + parseSelectionSet() { + return this.node(this._lexer.token, { + kind: Kind.SELECTION_SET, + selections: this.many(TokenKind.BRACE_L, this.parseSelection, TokenKind.BRACE_R), + }); + } + /** + * Selection : + * - Field + * - FragmentSpread + * - InlineFragment + */ + parseSelection() { + return this.peek(TokenKind.SPREAD) + ? this.parseFragment() + : this.parseField(); + } + /** + * Field : Alias? Name Arguments? Directives? SelectionSet? + * + * Alias : Name : + */ + parseField() { + const start = this._lexer.token; + const nameOrAlias = this.parseName(); + let alias; + let name; + if (this.expectOptionalToken(TokenKind.COLON)) { + alias = nameOrAlias; + name = this.parseName(); + } + else { + name = nameOrAlias; + } + return this.node(start, { + kind: Kind.FIELD, + alias, + name, + arguments: this.parseArguments(false), + directives: this.parseDirectives(false), + selectionSet: this.peek(TokenKind.BRACE_L) + ? this.parseSelectionSet() + : undefined, + }); + } + parseArguments(isConst) { + const item = isConst ? this.parseConstArgument : this.parseArgument; + return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R); + } + /* experimental */ + parseFragmentArguments() { + const item = this.parseFragmentArgument; + return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R); + } + parseArgument(isConst = false) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(TokenKind.COLON); + return this.node(start, { + kind: Kind.ARGUMENT, + name, + value: this.parseValueLiteral(isConst), + }); + } + parseConstArgument() { + return this.parseArgument(true); + } + /* experimental */ + parseFragmentArgument() { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(TokenKind.COLON); + return this.node(start, { + kind: Kind.FRAGMENT_ARGUMENT, + name, + value: this.parseValueLiteral(false), + }); + } + // Implements the parsing rules in the Fragments section. + /** + * Corresponds to both FragmentSpread and InlineFragment in the spec. + * + * FragmentSpread : ... FragmentName Arguments? Directives? + * + * InlineFragment : ... TypeCondition? Directives? SelectionSet + */ + parseFragment() { + const start = this._lexer.token; + this.expectToken(TokenKind.SPREAD); + const hasTypeCondition = this.expectOptionalKeyword('on'); + if (!hasTypeCondition && this.peek(TokenKind.NAME)) { + const name = this.parseFragmentName(); + if (this.peek(TokenKind.PAREN_L) && + this._options.experimentalFragmentArguments) { + return this.node(start, { + kind: Kind.FRAGMENT_SPREAD, + name, + arguments: this.parseFragmentArguments(), + directives: this.parseDirectives(false), + }); + } + return this.node(start, { + kind: Kind.FRAGMENT_SPREAD, + name, + directives: this.parseDirectives(false), + }); + } + return this.node(start, { + kind: Kind.INLINE_FRAGMENT, + typeCondition: hasTypeCondition ? this.parseNamedType() : undefined, + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentDefinition : + * - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet + * + * TypeCondition : NamedType + */ + parseFragmentDefinition() { + const start = this._lexer.token; + this.expectKeyword('fragment'); + if (this._options.experimentalFragmentArguments === true) { + return this.node(start, { + kind: Kind.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + variableDefinitions: this.parseVariableDefinitions(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + return this.node(start, { + kind: Kind.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentName : Name but not `on` + */ + parseFragmentName() { + if (this._lexer.token.value === 'on') { + throw this.unexpected(); + } + return this.parseName(); + } + parseValueLiteral(isConst) { + const token = this._lexer.token; + switch (token.kind) { + case TokenKind.BRACKET_L: + return this.parseList(isConst); + case TokenKind.BRACE_L: + return this.parseObject(isConst); + case TokenKind.INT: + this.advanceLexer(); + return this.node(token, { + kind: Kind.INT, + value: token.value, + }); + case TokenKind.FLOAT: + this.advanceLexer(); + return this.node(token, { + kind: Kind.FLOAT, + value: token.value, + }); + case TokenKind.STRING: + case TokenKind.BLOCK_STRING: + return this.parseStringLiteral(); + case TokenKind.NAME: + this.advanceLexer(); + switch (token.value) { + case 'true': + return this.node(token, { + kind: Kind.BOOLEAN, + value: true, + }); + case 'false': + return this.node(token, { + kind: Kind.BOOLEAN, + value: false, + }); + case 'null': + return this.node(token, { kind: Kind.NULL }); + default: + return this.node(token, { + kind: Kind.ENUM, + value: token.value, + }); + } + case TokenKind.DOLLAR: + if (isConst) { + this.expectToken(TokenKind.DOLLAR); + if (this._lexer.token.kind === TokenKind.NAME) { + const varName = this._lexer.token.value; + throw syntaxError(this._lexer.source, token.start, `Unexpected variable "$${varName}" in constant value.`); + } + else { + throw this.unexpected(token); + } + } + return this.parseVariable(); + default: + throw this.unexpected(); + } + } + parseConstValueLiteral() { + return this.parseValueLiteral(true); + } + parseStringLiteral() { + const token = this._lexer.token; + this.advanceLexer(); + return this.node(token, { + kind: Kind.STRING, + value: token.value, + block: token.kind === TokenKind.BLOCK_STRING, + }); + } + parseList(isConst) { + const item = () => this.parseValueLiteral(isConst); + return this.node(this._lexer.token, { + kind: Kind.LIST, + values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R), + }); + } + parseObject(isConst) { + const item = () => this.parseObjectField(isConst); + return this.node(this._lexer.token, { + kind: Kind.OBJECT, + fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R), + }); + } + parseObjectField(isConst) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(TokenKind.COLON); + return this.node(start, { + kind: Kind.OBJECT_FIELD, + name, + value: this.parseValueLiteral(isConst), + }); + } + parseDirectives(isConst) { + const directives = []; + while (this.peek(TokenKind.AT)) { + directives.push(this.parseDirective(isConst)); + } + if (directives.length) { + return directives; + } + return undefined; + } + parseConstDirectives() { + return this.parseDirectives(true); + } + parseDirective(isConst) { + const start = this._lexer.token; + this.expectToken(TokenKind.AT); + return this.node(start, { + kind: Kind.DIRECTIVE, + name: this.parseName(), + arguments: this.parseArguments(isConst), + }); + } + // Implements the parsing rules in the Types section. + /** + * Type : + * - NamedType + * - ListType + * - NonNullType + */ + parseTypeReference() { + const start = this._lexer.token; + let type; + if (this.expectOptionalToken(TokenKind.BRACKET_L)) { + const innerType = this.parseTypeReference(); + this.expectToken(TokenKind.BRACKET_R); + type = this.node(start, { + kind: Kind.LIST_TYPE, + type: innerType, + }); + } + else { + type = this.parseNamedType(); + } + if (this.expectOptionalToken(TokenKind.BANG)) { + return this.node(start, { + kind: Kind.NON_NULL_TYPE, + type, + }); + } + return type; + } + /** + * NamedType : Name + */ + parseNamedType() { + return this.node(this._lexer.token, { + kind: Kind.NAMED_TYPE, + name: this.parseName(), + }); + } + // Implements the parsing rules in the Type Definition section. + peekDescription() { + return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING); + } + /** + * Description : StringValue + */ + parseDescription() { + if (this.peekDescription()) { + return this.parseStringLiteral(); + } + } + /** + * ``` + * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } + * ``` + */ + parseSchemaDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.many(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R); + return this.node(start, { + kind: Kind.SCHEMA_DEFINITION, + description, + directives, + operationTypes, + }); + } + /** + * OperationTypeDefinition : OperationType : NamedType + */ + parseOperationTypeDefinition() { + const start = this._lexer.token; + const operation = this.parseOperationType(); + this.expectToken(TokenKind.COLON); + const type = this.parseNamedType(); + return this.node(start, { + kind: Kind.OPERATION_TYPE_DEFINITION, + operation, + type, + }); + } + /** + * ScalarTypeDefinition : Description? scalar Name Directives[Const]? + */ + parseScalarTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: Kind.SCALAR_TYPE_DEFINITION, + description, + name, + directives, + }); + } + /** + * ObjectTypeDefinition : + * Description? + * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? + */ + parseObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: Kind.OBJECT_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * ImplementsInterfaces : + * - implements `&`? NamedType + * - ImplementsInterfaces & NamedType + */ + parseImplementsInterfaces() { + return this.expectOptionalKeyword('implements') + ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) + : undefined; + } + /** + * ``` + * FieldsDefinition : { FieldDefinition+ } + * ``` + */ + parseFieldsDefinition() { + return this.optionalMany(TokenKind.BRACE_L, this.parseFieldDefinition, TokenKind.BRACE_R); + } + /** + * FieldDefinition : + * - Description? Name ArgumentsDefinition? : Type Directives[Const]? + */ + parseFieldDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + this.expectToken(TokenKind.COLON); + const type = this.parseTypeReference(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: Kind.FIELD_DEFINITION, + description, + name, + arguments: args, + type, + directives, + }); + } + /** + * ArgumentsDefinition : ( InputValueDefinition+ ) + */ + parseArgumentDefs() { + return this.optionalMany(TokenKind.PAREN_L, this.parseInputValueDef, TokenKind.PAREN_R); + } + /** + * InputValueDefinition : + * - Description? Name : Type DefaultValue? Directives[Const]? + */ + parseInputValueDef() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + this.expectToken(TokenKind.COLON); + const type = this.parseTypeReference(); + let defaultValue; + if (this.expectOptionalToken(TokenKind.EQUALS)) { + defaultValue = this.parseConstValueLiteral(); + } + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: Kind.INPUT_VALUE_DEFINITION, + description, + name, + type, + defaultValue, + directives, + }); + } + /** + * InterfaceTypeDefinition : + * - Description? interface Name Directives[Const]? FieldsDefinition? + */ + parseInterfaceTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: Kind.INTERFACE_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeDefinition : + * - Description? union Name Directives[Const]? UnionMemberTypes? + */ + parseUnionTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + return this.node(start, { + kind: Kind.UNION_TYPE_DEFINITION, + description, + name, + directives, + types, + }); + } + /** + * UnionMemberTypes : + * - = `|`? NamedType + * - UnionMemberTypes | NamedType + */ + parseUnionMemberTypes() { + return this.expectOptionalToken(TokenKind.EQUALS) + ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) + : undefined; + } + /** + * EnumTypeDefinition : + * - Description? enum Name Directives[Const]? EnumValuesDefinition? + */ + parseEnumTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + return this.node(start, { + kind: Kind.ENUM_TYPE_DEFINITION, + description, + name, + directives, + values, + }); + } + /** + * ``` + * EnumValuesDefinition : { EnumValueDefinition+ } + * ``` + */ + parseEnumValuesDefinition() { + return this.optionalMany(TokenKind.BRACE_L, this.parseEnumValueDefinition, TokenKind.BRACE_R); + } + /** + * EnumValueDefinition : Description? EnumValue Directives[Const]? + */ + parseEnumValueDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseEnumValueName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: Kind.ENUM_VALUE_DEFINITION, + description, + name, + directives, + }); + } + /** + * EnumValue : Name but not `true`, `false` or `null` + */ + parseEnumValueName() { + if (this._lexer.token.value === 'true' || + this._lexer.token.value === 'false' || + this._lexer.token.value === 'null') { + throw syntaxError(this._lexer.source, this._lexer.token.start, `${getTokenDesc(this._lexer.token)} is reserved and cannot be used for an enum value.`); + } + return this.parseName(); + } + /** + * InputObjectTypeDefinition : + * - Description? input Name Directives[Const]? InputFieldsDefinition? + */ + parseInputObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + return this.node(start, { + kind: Kind.INPUT_OBJECT_TYPE_DEFINITION, + description, + name, + directives, + fields, + }); + } + /** + * ``` + * InputFieldsDefinition : { InputValueDefinition+ } + * ``` + */ + parseInputFieldsDefinition() { + return this.optionalMany(TokenKind.BRACE_L, this.parseInputValueDef, TokenKind.BRACE_R); + } + /** + * TypeSystemExtension : + * - SchemaExtension + * - TypeExtension + * + * TypeExtension : + * - ScalarTypeExtension + * - ObjectTypeExtension + * - InterfaceTypeExtension + * - UnionTypeExtension + * - EnumTypeExtension + * - InputObjectTypeDefinition + */ + parseTypeSystemExtension() { + const keywordToken = this._lexer.lookahead(); + if (keywordToken.kind === TokenKind.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaExtension(); + case 'scalar': + return this.parseScalarTypeExtension(); + case 'type': + return this.parseObjectTypeExtension(); + case 'interface': + return this.parseInterfaceTypeExtension(); + case 'union': + return this.parseUnionTypeExtension(); + case 'enum': + return this.parseEnumTypeExtension(); + case 'input': + return this.parseInputObjectTypeExtension(); + } + } + throw this.unexpected(keywordToken); + } + /** + * ``` + * SchemaExtension : + * - extend schema Directives[Const]? { OperationTypeDefinition+ } + * - extend schema Directives[Const] + * ``` + */ + parseSchemaExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.optionalMany(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R); + if (directives === undefined && operationTypes === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: Kind.SCHEMA_EXTENSION, + directives, + operationTypes, + }); + } + /** + * ScalarTypeExtension : + * - extend scalar Name Directives[Const] + */ + parseScalarTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + if (directives === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: Kind.SCALAR_TYPE_EXTENSION, + name, + directives, + }); + } + /** + * ObjectTypeExtension : + * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend type Name ImplementsInterfaces? Directives[Const] + * - extend type Name ImplementsInterfaces + */ + parseObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + if (interfaces === undefined && + directives === undefined && + fields === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: Kind.OBJECT_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * InterfaceTypeExtension : + * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend interface Name ImplementsInterfaces? Directives[Const] + * - extend interface Name ImplementsInterfaces + */ + parseInterfaceTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + if (interfaces === undefined && + directives === undefined && + fields === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: Kind.INTERFACE_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeExtension : + * - extend union Name Directives[Const]? UnionMemberTypes + * - extend union Name Directives[Const] + */ + parseUnionTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + if (directives === undefined && types === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: Kind.UNION_TYPE_EXTENSION, + name, + directives, + types, + }); + } + /** + * EnumTypeExtension : + * - extend enum Name Directives[Const]? EnumValuesDefinition + * - extend enum Name Directives[Const] + */ + parseEnumTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + if (directives === undefined && values === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: Kind.ENUM_TYPE_EXTENSION, + name, + directives, + values, + }); + } + /** + * InputObjectTypeExtension : + * - extend input Name Directives[Const]? InputFieldsDefinition + * - extend input Name Directives[Const] + */ + parseInputObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + if (directives === undefined && fields === undefined) { + throw this.unexpected(); + } + return this.node(start, { + kind: Kind.INPUT_OBJECT_TYPE_EXTENSION, + name, + directives, + fields, + }); + } + /** + * ``` + * DirectiveDefinition : + * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations + * ``` + */ + parseDirectiveDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('directive'); + this.expectToken(TokenKind.AT); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + const repeatable = this.expectOptionalKeyword('repeatable'); + this.expectKeyword('on'); + const locations = this.parseDirectiveLocations(); + return this.node(start, { + kind: Kind.DIRECTIVE_DEFINITION, + description, + name, + arguments: args, + repeatable, + locations, + }); + } + /** + * DirectiveLocations : + * - `|`? DirectiveLocation + * - DirectiveLocations | DirectiveLocation + */ + parseDirectiveLocations() { + return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation); + } + /* + * DirectiveLocation : + * - ExecutableDirectiveLocation + * - TypeSystemDirectiveLocation + * + * ExecutableDirectiveLocation : one of + * `QUERY` + * `MUTATION` + * `SUBSCRIPTION` + * `FIELD` + * `FRAGMENT_DEFINITION` + * `FRAGMENT_SPREAD` + * `INLINE_FRAGMENT` + * + * TypeSystemDirectiveLocation : one of + * `SCHEMA` + * `SCALAR` + * `OBJECT` + * `FIELD_DEFINITION` + * `ARGUMENT_DEFINITION` + * `INTERFACE` + * `UNION` + * `ENUM` + * `ENUM_VALUE` + * `INPUT_OBJECT` + * `INPUT_FIELD_DEFINITION` + */ + parseDirectiveLocation() { + const start = this._lexer.token; + const name = this.parseName(); + if (Object.hasOwn(DirectiveLocation, name.value)) { + return name; + } + throw this.unexpected(start); + } + // Core parsing utility functions + /** + * Returns a node that, if configured to do so, sets a "loc" field as a + * location object, used to identify the place in the source that created a + * given parsed object. + */ + node(startToken, node) { + if (this._options.noLocation !== true) { + node.loc = new Location(startToken, this._lexer.lastToken, this._lexer.source); + } + return node; + } + /** + * Determines if the next token is of a given kind + */ + peek(kind) { + return this._lexer.token.kind === kind; + } + /** + * If the next token is of the given kind, return that token after advancing the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + expectToken(kind) { + const token = this._lexer.token; + if (token.kind === kind) { + this.advanceLexer(); + return token; + } + throw syntaxError(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`); + } + /** + * If the next token is of the given kind, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + expectOptionalToken(kind) { + const token = this._lexer.token; + if (token.kind === kind) { + this.advanceLexer(); + return true; + } + return false; + } + /** + * If the next token is a given keyword, advance the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + expectKeyword(value) { + const token = this._lexer.token; + if (token.kind === TokenKind.NAME && token.value === value) { + this.advanceLexer(); + } + else { + throw syntaxError(this._lexer.source, token.start, `Expected "${value}", found ${getTokenDesc(token)}.`); + } + } + /** + * If the next token is a given keyword, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + expectOptionalKeyword(value) { + const token = this._lexer.token; + if (token.kind === TokenKind.NAME && token.value === value) { + this.advanceLexer(); + return true; + } + return false; + } + /** + * Helper function for creating an error when an unexpected lexed token is encountered. + */ + unexpected(atToken) { + const token = atToken ?? this._lexer.token; + return syntaxError(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`); + } + /** + * Returns a possibly empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + any(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + while (!this.expectOptionalToken(closeKind)) { + nodes.push(parseFn.call(this)); + } + return nodes; + } + /** + * Returns a list of parse nodes, determined by the parseFn. + * It can be empty only if open token is missing otherwise it will always return non-empty list + * that begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + optionalMany(openKind, parseFn, closeKind) { + if (this.expectOptionalToken(openKind)) { + const nodes = []; + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + return nodes; + } + return undefined; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + many(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + return nodes; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind. + * Advances the parser to the next lex token after last item in the list. + */ + delimitedMany(delimiterKind, parseFn) { + this.expectOptionalToken(delimiterKind); + const nodes = []; + do { + nodes.push(parseFn.call(this)); + } while (this.expectOptionalToken(delimiterKind)); + return nodes; + } + advanceLexer() { + const { maxTokens } = this._options; + const token = this._lexer.advance(); + if (token.kind !== TokenKind.EOF) { + ++this._tokenCounter; + if (maxTokens !== undefined && this._tokenCounter > maxTokens) { + throw syntaxError(this._lexer.source, token.start, `Document contains more than ${maxTokens} tokens. Parsing aborted.`); + } + } + } +} +/** + * A helper function to describe a token as a string for debugging. + */ +function getTokenDesc(token) { + const value = token.value; + return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : ''); +} +/** + * A helper function to describe a token kind as a string for debugging. + */ +function getTokenKindDesc(kind) { + return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind; +} +//# sourceMappingURL=parser.js.map \ No newline at end of file diff --git a/language/parser.mjs.map b/language/parser.mjs.map new file mode 100644 index 0000000000..fb4afc2d72 --- /dev/null +++ b/language/parser.mjs.map @@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type { GraphQLError } from '../error/GraphQLError.js';\nimport { syntaxError } from '../error/syntaxError.js';\n\nimport type {\n ArgumentNode,\n BooleanValueNode,\n ConstArgumentNode,\n ConstDirectiveNode,\n ConstListValueNode,\n ConstObjectFieldNode,\n ConstObjectValueNode,\n ConstValueNode,\n DefinitionNode,\n DirectiveDefinitionNode,\n DirectiveNode,\n DocumentNode,\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n EnumValueDefinitionNode,\n EnumValueNode,\n FieldDefinitionNode,\n FieldNode,\n FloatValueNode,\n FragmentArgumentNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n InputObjectTypeDefinitionNode,\n InputObjectTypeExtensionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n IntValueNode,\n ListTypeNode,\n ListValueNode,\n NamedTypeNode,\n NameNode,\n NonNullTypeNode,\n NullValueNode,\n ObjectFieldNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n ObjectValueNode,\n OperationDefinitionNode,\n OperationTypeDefinitionNode,\n ScalarTypeDefinitionNode,\n ScalarTypeExtensionNode,\n SchemaDefinitionNode,\n SchemaExtensionNode,\n SelectionNode,\n SelectionSetNode,\n StringValueNode,\n Token,\n TypeNode,\n TypeSystemExtensionNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n ValueNode,\n VariableDefinitionNode,\n VariableNode,\n} from './ast.js';\nimport { Location, OperationTypeNode } from './ast.js';\nimport { DirectiveLocation } from './directiveLocation.js';\nimport { Kind } from './kinds.js';\nimport { isPunctuatorTokenKind, Lexer } from './lexer.js';\nimport { isSource, Source } from './source.js';\nimport { TokenKind } from './tokenKind.js';\n\n/**\n * Configuration options to control parser behavior\n */\nexport interface ParseOptions {\n /**\n * By default, the parser creates AST nodes that know the location\n * in the source that they correspond to. This configuration flag\n * disables that behavior for performance or testing.\n */\n noLocation?: boolean | undefined;\n\n /**\n * Parser CPU and memory usage is linear to the number of tokens in a document\n * however in extreme cases it becomes quadratic due to memory exhaustion.\n * Parsing happens before validation so even invalid queries can burn lots of\n * CPU time and memory.\n * To prevent this you can set a maximum number of tokens allowed within a document.\n */\n maxTokens?: number | undefined;\n\n /**\n * EXPERIMENTAL:\n *\n * If enabled, the parser will understand and parse fragment variable definitions\n * and arguments on fragment spreads. Fragment variable definitions will be represented\n * in the `variableDefinitions` field of the FragmentDefinitionNode.\n * Fragment spread arguments will be represented in the `arguments` field of FragmentSpreadNode.\n *\n * For example:\n *\n * ```graphql\n * {\n * t { ...A(var: true) }\n * }\n * fragment A($var: Boolean = false) on T {\n * ...B(x: $var)\n * }\n * ```\n */\n experimentalFragmentArguments?: boolean | undefined;\n}\n\n/**\n * Given a GraphQL source, parses it into a Document.\n * Throws GraphQLError if a syntax error is encountered.\n */\nexport function parse(\n source: string | Source,\n options?: ParseOptions,\n): DocumentNode {\n const parser = new Parser(source, options);\n const document = parser.parseDocument();\n Object.defineProperty(document, 'tokenCount', {\n enumerable: false,\n value: parser.tokenCount,\n });\n return document;\n}\n\n/**\n * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for\n * that value.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Values directly and\n * in isolation of complete GraphQL documents.\n */\nexport function parseValue(\n source: string | Source,\n options?: ParseOptions,\n): ValueNode {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const value = parser.parseValueLiteral(false);\n parser.expectToken(TokenKind.EOF);\n return value;\n}\n\n/**\n * Similar to parseValue(), but raises a parse error if it encounters a\n * variable. The return type will be a constant value.\n */\nexport function parseConstValue(\n source: string | Source,\n options?: ParseOptions,\n): ConstValueNode {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const value = parser.parseConstValueLiteral();\n parser.expectToken(TokenKind.EOF);\n return value;\n}\n\n/**\n * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for\n * that type.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Types directly and\n * in isolation of complete GraphQL documents.\n *\n * Consider providing the results to the utility function: typeFromAST().\n */\nexport function parseType(\n source: string | Source,\n options?: ParseOptions,\n): TypeNode {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const type = parser.parseTypeReference();\n parser.expectToken(TokenKind.EOF);\n return type;\n}\n\n/**\n * This class is exported only to assist people in implementing their own parsers\n * without duplicating too much code and should be used only as last resort for cases\n * such as experimental syntax or if certain features could not be contributed upstream.\n *\n * It is still part of the internal API and is versioned, so any changes to it are never\n * considered breaking changes. If you still need to support multiple versions of the\n * library, please use the `versionInfo` variable for version detection.\n *\n * @internal\n */\nexport class Parser {\n protected _options: ParseOptions;\n protected _lexer: Lexer;\n protected _tokenCounter: number;\n\n constructor(source: string | Source, options: ParseOptions = {}) {\n const sourceObj = isSource(source) ? source : new Source(source);\n\n this._lexer = new Lexer(sourceObj);\n this._options = options;\n this._tokenCounter = 0;\n }\n\n get tokenCount(): number {\n return this._tokenCounter;\n }\n\n /**\n * Converts a name lex token into a name parse node.\n */\n parseName(): NameNode {\n const token = this.expectToken(TokenKind.NAME);\n return this.node(token, {\n kind: Kind.NAME,\n value: token.value,\n });\n }\n\n // Implements the parsing rules in the Document section.\n\n /**\n * Document : Definition+\n */\n parseDocument(): DocumentNode {\n return this.node(this._lexer.token, {\n kind: Kind.DOCUMENT,\n definitions: this.many(\n TokenKind.SOF,\n this.parseDefinition,\n TokenKind.EOF,\n ),\n });\n }\n\n /**\n * Definition :\n * - ExecutableDefinition\n * - TypeSystemDefinition\n * - TypeSystemExtension\n *\n * ExecutableDefinition :\n * - OperationDefinition\n * - FragmentDefinition\n *\n * TypeSystemDefinition :\n * - SchemaDefinition\n * - TypeDefinition\n * - DirectiveDefinition\n *\n * TypeDefinition :\n * - ScalarTypeDefinition\n * - ObjectTypeDefinition\n * - InterfaceTypeDefinition\n * - UnionTypeDefinition\n * - EnumTypeDefinition\n * - InputObjectTypeDefinition\n */\n parseDefinition(): DefinitionNode {\n if (this.peek(TokenKind.BRACE_L)) {\n return this.parseOperationDefinition();\n }\n\n // Many definitions begin with a description and require a lookahead.\n const hasDescription = this.peekDescription();\n const keywordToken = hasDescription\n ? this._lexer.lookahead()\n : this._lexer.token;\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaDefinition();\n case 'scalar':\n return this.parseScalarTypeDefinition();\n case 'type':\n return this.parseObjectTypeDefinition();\n case 'interface':\n return this.parseInterfaceTypeDefinition();\n case 'union':\n return this.parseUnionTypeDefinition();\n case 'enum':\n return this.parseEnumTypeDefinition();\n case 'input':\n return this.parseInputObjectTypeDefinition();\n case 'directive':\n return this.parseDirectiveDefinition();\n }\n\n if (hasDescription) {\n throw syntaxError(\n this._lexer.source,\n this._lexer.token.start,\n 'Unexpected description, descriptions are supported only on type definitions.',\n );\n }\n\n switch (keywordToken.value) {\n case 'query':\n case 'mutation':\n case 'subscription':\n return this.parseOperationDefinition();\n case 'fragment':\n return this.parseFragmentDefinition();\n case 'extend':\n return this.parseTypeSystemExtension();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n\n // Implements the parsing rules in the Operations section.\n\n /**\n * OperationDefinition :\n * - SelectionSet\n * - OperationType Name? VariableDefinitions? Directives? SelectionSet\n */\n parseOperationDefinition(): OperationDefinitionNode {\n const start = this._lexer.token;\n if (this.peek(TokenKind.BRACE_L)) {\n return this.node(start, {\n kind: Kind.OPERATION_DEFINITION,\n operation: OperationTypeNode.QUERY,\n name: undefined,\n variableDefinitions: undefined,\n directives: undefined,\n selectionSet: this.parseSelectionSet(),\n });\n }\n const operation = this.parseOperationType();\n let name;\n if (this.peek(TokenKind.NAME)) {\n name = this.parseName();\n }\n return this.node(start, {\n kind: Kind.OPERATION_DEFINITION,\n operation,\n name,\n variableDefinitions: this.parseVariableDefinitions(),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n\n /**\n * OperationType : one of query mutation subscription\n */\n parseOperationType(): OperationTypeNode {\n const operationToken = this.expectToken(TokenKind.NAME);\n switch (operationToken.value) {\n case 'query':\n return OperationTypeNode.QUERY;\n case 'mutation':\n return OperationTypeNode.MUTATION;\n case 'subscription':\n return OperationTypeNode.SUBSCRIPTION;\n }\n\n throw this.unexpected(operationToken);\n }\n\n /**\n * VariableDefinitions : ( VariableDefinition+ )\n */\n parseVariableDefinitions(): Array | undefined {\n return this.optionalMany(\n TokenKind.PAREN_L,\n this.parseVariableDefinition,\n TokenKind.PAREN_R,\n );\n }\n\n /**\n * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?\n */\n parseVariableDefinition(): VariableDefinitionNode {\n return this.node(this._lexer.token, {\n kind: Kind.VARIABLE_DEFINITION,\n variable: this.parseVariable(),\n type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),\n defaultValue: this.expectOptionalToken(TokenKind.EQUALS)\n ? this.parseConstValueLiteral()\n : undefined,\n directives: this.parseConstDirectives(),\n });\n }\n\n /**\n * Variable : $ Name\n */\n parseVariable(): VariableNode {\n const start = this._lexer.token;\n this.expectToken(TokenKind.DOLLAR);\n return this.node(start, {\n kind: Kind.VARIABLE,\n name: this.parseName(),\n });\n }\n\n /**\n * ```\n * SelectionSet : { Selection+ }\n * ```\n */\n parseSelectionSet(): SelectionSetNode {\n return this.node(this._lexer.token, {\n kind: Kind.SELECTION_SET,\n selections: this.many(\n TokenKind.BRACE_L,\n this.parseSelection,\n TokenKind.BRACE_R,\n ),\n });\n }\n\n /**\n * Selection :\n * - Field\n * - FragmentSpread\n * - InlineFragment\n */\n parseSelection(): SelectionNode {\n return this.peek(TokenKind.SPREAD)\n ? this.parseFragment()\n : this.parseField();\n }\n\n /**\n * Field : Alias? Name Arguments? Directives? SelectionSet?\n *\n * Alias : Name :\n */\n parseField(): FieldNode {\n const start = this._lexer.token;\n\n const nameOrAlias = this.parseName();\n let alias;\n let name;\n if (this.expectOptionalToken(TokenKind.COLON)) {\n alias = nameOrAlias;\n name = this.parseName();\n } else {\n name = nameOrAlias;\n }\n\n return this.node(start, {\n kind: Kind.FIELD,\n alias,\n name,\n arguments: this.parseArguments(false),\n directives: this.parseDirectives(false),\n selectionSet: this.peek(TokenKind.BRACE_L)\n ? this.parseSelectionSet()\n : undefined,\n });\n }\n\n /**\n * Arguments[Const] : ( Argument[?Const]+ )\n */\n parseArguments(isConst: true): Array | undefined;\n parseArguments(isConst: boolean): Array | undefined;\n parseArguments(isConst: boolean): Array | undefined {\n const item = isConst ? this.parseConstArgument : this.parseArgument;\n return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);\n }\n\n /* experimental */\n parseFragmentArguments(): Array | undefined {\n const item = this.parseFragmentArgument;\n return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);\n }\n\n /**\n * Argument[Const] : Name : Value[?Const]\n */\n parseArgument(isConst: true): ConstArgumentNode;\n parseArgument(isConst?: boolean): ArgumentNode;\n parseArgument(isConst: boolean = false): ArgumentNode {\n const start = this._lexer.token;\n const name = this.parseName();\n\n this.expectToken(TokenKind.COLON);\n return this.node(start, {\n kind: Kind.ARGUMENT,\n name,\n value: this.parseValueLiteral(isConst),\n });\n }\n\n parseConstArgument(): ConstArgumentNode {\n return this.parseArgument(true);\n }\n\n /* experimental */\n parseFragmentArgument(): FragmentArgumentNode {\n const start = this._lexer.token;\n const name = this.parseName();\n\n this.expectToken(TokenKind.COLON);\n return this.node(start, {\n kind: Kind.FRAGMENT_ARGUMENT,\n name,\n value: this.parseValueLiteral(false),\n });\n }\n\n // Implements the parsing rules in the Fragments section.\n\n /**\n * Corresponds to both FragmentSpread and InlineFragment in the spec.\n *\n * FragmentSpread : ... FragmentName Arguments? Directives?\n *\n * InlineFragment : ... TypeCondition? Directives? SelectionSet\n */\n parseFragment(): FragmentSpreadNode | InlineFragmentNode {\n const start = this._lexer.token;\n this.expectToken(TokenKind.SPREAD);\n\n const hasTypeCondition = this.expectOptionalKeyword('on');\n if (!hasTypeCondition && this.peek(TokenKind.NAME)) {\n const name = this.parseFragmentName();\n if (\n this.peek(TokenKind.PAREN_L) &&\n this._options.experimentalFragmentArguments\n ) {\n return this.node(start, {\n kind: Kind.FRAGMENT_SPREAD,\n name,\n arguments: this.parseFragmentArguments(),\n directives: this.parseDirectives(false),\n });\n }\n return this.node(start, {\n kind: Kind.FRAGMENT_SPREAD,\n name,\n directives: this.parseDirectives(false),\n });\n }\n return this.node(start, {\n kind: Kind.INLINE_FRAGMENT,\n typeCondition: hasTypeCondition ? this.parseNamedType() : undefined,\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n\n /**\n * FragmentDefinition :\n * - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet\n *\n * TypeCondition : NamedType\n */\n parseFragmentDefinition(): FragmentDefinitionNode {\n const start = this._lexer.token;\n this.expectKeyword('fragment');\n if (this._options.experimentalFragmentArguments === true) {\n return this.node(start, {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n variableDefinitions: this.parseVariableDefinitions(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n return this.node(start, {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n });\n }\n\n /**\n * FragmentName : Name but not `on`\n */\n parseFragmentName(): NameNode {\n if (this._lexer.token.value === 'on') {\n throw this.unexpected();\n }\n return this.parseName();\n }\n\n // Implements the parsing rules in the Values section.\n\n /**\n * Value[Const] :\n * - [~Const] Variable\n * - IntValue\n * - FloatValue\n * - StringValue\n * - BooleanValue\n * - NullValue\n * - EnumValue\n * - ListValue[?Const]\n * - ObjectValue[?Const]\n *\n * BooleanValue : one of `true` `false`\n *\n * NullValue : `null`\n *\n * EnumValue : Name but not `true`, `false` or `null`\n */\n parseValueLiteral(isConst: true): ConstValueNode;\n parseValueLiteral(isConst: boolean): ValueNode;\n parseValueLiteral(isConst: boolean): ValueNode {\n const token = this._lexer.token;\n switch (token.kind) {\n case TokenKind.BRACKET_L:\n return this.parseList(isConst);\n case TokenKind.BRACE_L:\n return this.parseObject(isConst);\n case TokenKind.INT:\n this.advanceLexer();\n return this.node(token, {\n kind: Kind.INT,\n value: token.value,\n });\n case TokenKind.FLOAT:\n this.advanceLexer();\n return this.node(token, {\n kind: Kind.FLOAT,\n value: token.value,\n });\n case TokenKind.STRING:\n case TokenKind.BLOCK_STRING:\n return this.parseStringLiteral();\n case TokenKind.NAME:\n this.advanceLexer();\n switch (token.value) {\n case 'true':\n return this.node(token, {\n kind: Kind.BOOLEAN,\n value: true,\n });\n case 'false':\n return this.node(token, {\n kind: Kind.BOOLEAN,\n value: false,\n });\n case 'null':\n return this.node(token, { kind: Kind.NULL });\n default:\n return this.node(token, {\n kind: Kind.ENUM,\n value: token.value,\n });\n }\n case TokenKind.DOLLAR:\n if (isConst) {\n this.expectToken(TokenKind.DOLLAR);\n if (this._lexer.token.kind === TokenKind.NAME) {\n const varName = this._lexer.token.value;\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Unexpected variable \"$${varName}\" in constant value.`,\n );\n } else {\n throw this.unexpected(token);\n }\n }\n return this.parseVariable();\n default:\n throw this.unexpected();\n }\n }\n\n parseConstValueLiteral(): ConstValueNode {\n return this.parseValueLiteral(true);\n }\n\n parseStringLiteral(): StringValueNode {\n const token = this._lexer.token;\n this.advanceLexer();\n return this.node(token, {\n kind: Kind.STRING,\n value: token.value,\n block: token.kind === TokenKind.BLOCK_STRING,\n });\n }\n\n /**\n * ListValue[Const] :\n * - [ ]\n * - [ Value[?Const]+ ]\n */\n parseList(isConst: true): ConstListValueNode;\n parseList(isConst: boolean): ListValueNode;\n parseList(isConst: boolean): ListValueNode {\n const item = () => this.parseValueLiteral(isConst);\n return this.node(this._lexer.token, {\n kind: Kind.LIST,\n values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),\n });\n }\n\n /**\n * ```\n * ObjectValue[Const] :\n * - { }\n * - { ObjectField[?Const]+ }\n * ```\n */\n parseObject(isConst: true): ConstObjectValueNode;\n parseObject(isConst: boolean): ObjectValueNode;\n parseObject(isConst: boolean): ObjectValueNode {\n const item = () => this.parseObjectField(isConst);\n return this.node(this._lexer.token, {\n kind: Kind.OBJECT,\n fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R),\n });\n }\n\n /**\n * ObjectField[Const] : Name : Value[?Const]\n */\n parseObjectField(isConst: true): ConstObjectFieldNode;\n parseObjectField(isConst: boolean): ObjectFieldNode;\n parseObjectField(isConst: boolean): ObjectFieldNode {\n const start = this._lexer.token;\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n return this.node(start, {\n kind: Kind.OBJECT_FIELD,\n name,\n value: this.parseValueLiteral(isConst),\n });\n }\n\n // Implements the parsing rules in the Directives section.\n\n /**\n * Directives[Const] : Directive[?Const]+\n */\n parseDirectives(isConst: true): Array | undefined;\n parseDirectives(isConst: boolean): Array | undefined;\n parseDirectives(isConst: boolean): Array | undefined {\n const directives = [];\n while (this.peek(TokenKind.AT)) {\n directives.push(this.parseDirective(isConst));\n }\n if (directives.length) {\n return directives;\n }\n return undefined;\n }\n\n parseConstDirectives(): Array | undefined {\n return this.parseDirectives(true);\n }\n\n /**\n * ```\n * Directive[Const] : @ Name Arguments[?Const]?\n * ```\n */\n parseDirective(isConst: true): ConstDirectiveNode;\n parseDirective(isConst: boolean): DirectiveNode;\n parseDirective(isConst: boolean): DirectiveNode {\n const start = this._lexer.token;\n this.expectToken(TokenKind.AT);\n return this.node(start, {\n kind: Kind.DIRECTIVE,\n name: this.parseName(),\n arguments: this.parseArguments(isConst),\n });\n }\n\n // Implements the parsing rules in the Types section.\n\n /**\n * Type :\n * - NamedType\n * - ListType\n * - NonNullType\n */\n parseTypeReference(): TypeNode {\n const start = this._lexer.token;\n let type;\n if (this.expectOptionalToken(TokenKind.BRACKET_L)) {\n const innerType = this.parseTypeReference();\n this.expectToken(TokenKind.BRACKET_R);\n type = this.node(start, {\n kind: Kind.LIST_TYPE,\n type: innerType,\n });\n } else {\n type = this.parseNamedType();\n }\n\n if (this.expectOptionalToken(TokenKind.BANG)) {\n return this.node(start, {\n kind: Kind.NON_NULL_TYPE,\n type,\n });\n }\n\n return type;\n }\n\n /**\n * NamedType : Name\n */\n parseNamedType(): NamedTypeNode {\n return this.node(this._lexer.token, {\n kind: Kind.NAMED_TYPE,\n name: this.parseName(),\n });\n }\n\n // Implements the parsing rules in the Type Definition section.\n\n peekDescription(): boolean {\n return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);\n }\n\n /**\n * Description : StringValue\n */\n parseDescription(): undefined | StringValueNode {\n if (this.peekDescription()) {\n return this.parseStringLiteral();\n }\n }\n\n /**\n * ```\n * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }\n * ```\n */\n parseSchemaDefinition(): SchemaDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('schema');\n const directives = this.parseConstDirectives();\n const operationTypes = this.many(\n TokenKind.BRACE_L,\n this.parseOperationTypeDefinition,\n TokenKind.BRACE_R,\n );\n return this.node(start, {\n kind: Kind.SCHEMA_DEFINITION,\n description,\n directives,\n operationTypes,\n });\n }\n\n /**\n * OperationTypeDefinition : OperationType : NamedType\n */\n parseOperationTypeDefinition(): OperationTypeDefinitionNode {\n const start = this._lexer.token;\n const operation = this.parseOperationType();\n this.expectToken(TokenKind.COLON);\n const type = this.parseNamedType();\n return this.node(start, {\n kind: Kind.OPERATION_TYPE_DEFINITION,\n operation,\n type,\n });\n }\n\n /**\n * ScalarTypeDefinition : Description? scalar Name Directives[Const]?\n */\n parseScalarTypeDefinition(): ScalarTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.SCALAR_TYPE_DEFINITION,\n description,\n name,\n directives,\n });\n }\n\n /**\n * ObjectTypeDefinition :\n * Description?\n * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?\n */\n parseObjectTypeDefinition(): ObjectTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n return this.node(start, {\n kind: Kind.OBJECT_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * ImplementsInterfaces :\n * - implements `&`? NamedType\n * - ImplementsInterfaces & NamedType\n */\n parseImplementsInterfaces(): Array | undefined {\n return this.expectOptionalKeyword('implements')\n ? this.delimitedMany(TokenKind.AMP, this.parseNamedType)\n : undefined;\n }\n\n /**\n * ```\n * FieldsDefinition : { FieldDefinition+ }\n * ```\n */\n parseFieldsDefinition(): Array | undefined {\n return this.optionalMany(\n TokenKind.BRACE_L,\n this.parseFieldDefinition,\n TokenKind.BRACE_R,\n );\n }\n\n /**\n * FieldDefinition :\n * - Description? Name ArgumentsDefinition? : Type Directives[Const]?\n */\n parseFieldDefinition(): FieldDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.FIELD_DEFINITION,\n description,\n name,\n arguments: args,\n type,\n directives,\n });\n }\n\n /**\n * ArgumentsDefinition : ( InputValueDefinition+ )\n */\n parseArgumentDefs(): Array | undefined {\n return this.optionalMany(\n TokenKind.PAREN_L,\n this.parseInputValueDef,\n TokenKind.PAREN_R,\n );\n }\n\n /**\n * InputValueDefinition :\n * - Description? Name : Type DefaultValue? Directives[Const]?\n */\n parseInputValueDef(): InputValueDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n let defaultValue;\n if (this.expectOptionalToken(TokenKind.EQUALS)) {\n defaultValue = this.parseConstValueLiteral();\n }\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.INPUT_VALUE_DEFINITION,\n description,\n name,\n type,\n defaultValue,\n directives,\n });\n }\n\n /**\n * InterfaceTypeDefinition :\n * - Description? interface Name Directives[Const]? FieldsDefinition?\n */\n parseInterfaceTypeDefinition(): InterfaceTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n return this.node(start, {\n kind: Kind.INTERFACE_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * UnionTypeDefinition :\n * - Description? union Name Directives[Const]? UnionMemberTypes?\n */\n parseUnionTypeDefinition(): UnionTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const types = this.parseUnionMemberTypes();\n return this.node(start, {\n kind: Kind.UNION_TYPE_DEFINITION,\n description,\n name,\n directives,\n types,\n });\n }\n\n /**\n * UnionMemberTypes :\n * - = `|`? NamedType\n * - UnionMemberTypes | NamedType\n */\n parseUnionMemberTypes(): Array | undefined {\n return this.expectOptionalToken(TokenKind.EQUALS)\n ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType)\n : undefined;\n }\n\n /**\n * EnumTypeDefinition :\n * - Description? enum Name Directives[Const]? EnumValuesDefinition?\n */\n parseEnumTypeDefinition(): EnumTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const values = this.parseEnumValuesDefinition();\n return this.node(start, {\n kind: Kind.ENUM_TYPE_DEFINITION,\n description,\n name,\n directives,\n values,\n });\n }\n\n /**\n * ```\n * EnumValuesDefinition : { EnumValueDefinition+ }\n * ```\n */\n parseEnumValuesDefinition(): Array | undefined {\n return this.optionalMany(\n TokenKind.BRACE_L,\n this.parseEnumValueDefinition,\n TokenKind.BRACE_R,\n );\n }\n\n /**\n * EnumValueDefinition : Description? EnumValue Directives[Const]?\n */\n parseEnumValueDefinition(): EnumValueDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseEnumValueName();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.ENUM_VALUE_DEFINITION,\n description,\n name,\n directives,\n });\n }\n\n /**\n * EnumValue : Name but not `true`, `false` or `null`\n */\n parseEnumValueName(): NameNode {\n if (\n this._lexer.token.value === 'true' ||\n this._lexer.token.value === 'false' ||\n this._lexer.token.value === 'null'\n ) {\n throw syntaxError(\n this._lexer.source,\n this._lexer.token.start,\n `${getTokenDesc(\n this._lexer.token,\n )} is reserved and cannot be used for an enum value.`,\n );\n }\n return this.parseName();\n }\n\n /**\n * InputObjectTypeDefinition :\n * - Description? input Name Directives[Const]? InputFieldsDefinition?\n */\n parseInputObjectTypeDefinition(): InputObjectTypeDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const fields = this.parseInputFieldsDefinition();\n return this.node(start, {\n kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,\n description,\n name,\n directives,\n fields,\n });\n }\n\n /**\n * ```\n * InputFieldsDefinition : { InputValueDefinition+ }\n * ```\n */\n parseInputFieldsDefinition(): Array | undefined {\n return this.optionalMany(\n TokenKind.BRACE_L,\n this.parseInputValueDef,\n TokenKind.BRACE_R,\n );\n }\n\n /**\n * TypeSystemExtension :\n * - SchemaExtension\n * - TypeExtension\n *\n * TypeExtension :\n * - ScalarTypeExtension\n * - ObjectTypeExtension\n * - InterfaceTypeExtension\n * - UnionTypeExtension\n * - EnumTypeExtension\n * - InputObjectTypeDefinition\n */\n parseTypeSystemExtension(): TypeSystemExtensionNode {\n const keywordToken = this._lexer.lookahead();\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaExtension();\n case 'scalar':\n return this.parseScalarTypeExtension();\n case 'type':\n return this.parseObjectTypeExtension();\n case 'interface':\n return this.parseInterfaceTypeExtension();\n case 'union':\n return this.parseUnionTypeExtension();\n case 'enum':\n return this.parseEnumTypeExtension();\n case 'input':\n return this.parseInputObjectTypeExtension();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n\n /**\n * ```\n * SchemaExtension :\n * - extend schema Directives[Const]? { OperationTypeDefinition+ }\n * - extend schema Directives[Const]\n * ```\n */\n parseSchemaExtension(): SchemaExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('schema');\n const directives = this.parseConstDirectives();\n const operationTypes = this.optionalMany(\n TokenKind.BRACE_L,\n this.parseOperationTypeDefinition,\n TokenKind.BRACE_R,\n );\n if (directives === undefined && operationTypes === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.SCHEMA_EXTENSION,\n directives,\n operationTypes,\n });\n }\n\n /**\n * ScalarTypeExtension :\n * - extend scalar Name Directives[Const]\n */\n parseScalarTypeExtension(): ScalarTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n if (directives === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.SCALAR_TYPE_EXTENSION,\n name,\n directives,\n });\n }\n\n /**\n * ObjectTypeExtension :\n * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend type Name ImplementsInterfaces? Directives[Const]\n * - extend type Name ImplementsInterfaces\n */\n parseObjectTypeExtension(): ObjectTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n if (\n interfaces === undefined &&\n directives === undefined &&\n fields === undefined\n ) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.OBJECT_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * InterfaceTypeExtension :\n * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend interface Name ImplementsInterfaces? Directives[Const]\n * - extend interface Name ImplementsInterfaces\n */\n parseInterfaceTypeExtension(): InterfaceTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFieldsDefinition();\n if (\n interfaces === undefined &&\n directives === undefined &&\n fields === undefined\n ) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.INTERFACE_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n });\n }\n\n /**\n * UnionTypeExtension :\n * - extend union Name Directives[Const]? UnionMemberTypes\n * - extend union Name Directives[Const]\n */\n parseUnionTypeExtension(): UnionTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const types = this.parseUnionMemberTypes();\n if (directives === undefined && types === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.UNION_TYPE_EXTENSION,\n name,\n directives,\n types,\n });\n }\n\n /**\n * EnumTypeExtension :\n * - extend enum Name Directives[Const]? EnumValuesDefinition\n * - extend enum Name Directives[Const]\n */\n parseEnumTypeExtension(): EnumTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const values = this.parseEnumValuesDefinition();\n if (directives === undefined && values === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.ENUM_TYPE_EXTENSION,\n name,\n directives,\n values,\n });\n }\n\n /**\n * InputObjectTypeExtension :\n * - extend input Name Directives[Const]? InputFieldsDefinition\n * - extend input Name Directives[Const]\n */\n parseInputObjectTypeExtension(): InputObjectTypeExtensionNode {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const fields = this.parseInputFieldsDefinition();\n if (directives === undefined && fields === undefined) {\n throw this.unexpected();\n }\n return this.node(start, {\n kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,\n name,\n directives,\n fields,\n });\n }\n\n /**\n * ```\n * DirectiveDefinition :\n * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations\n * ```\n */\n parseDirectiveDefinition(): DirectiveDefinitionNode {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('directive');\n this.expectToken(TokenKind.AT);\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n const repeatable = this.expectOptionalKeyword('repeatable');\n this.expectKeyword('on');\n const locations = this.parseDirectiveLocations();\n return this.node(start, {\n kind: Kind.DIRECTIVE_DEFINITION,\n description,\n name,\n arguments: args,\n repeatable,\n locations,\n });\n }\n\n /**\n * DirectiveLocations :\n * - `|`? DirectiveLocation\n * - DirectiveLocations | DirectiveLocation\n */\n parseDirectiveLocations(): Array {\n return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);\n }\n\n /*\n * DirectiveLocation :\n * - ExecutableDirectiveLocation\n * - TypeSystemDirectiveLocation\n *\n * ExecutableDirectiveLocation : one of\n * `QUERY`\n * `MUTATION`\n * `SUBSCRIPTION`\n * `FIELD`\n * `FRAGMENT_DEFINITION`\n * `FRAGMENT_SPREAD`\n * `INLINE_FRAGMENT`\n *\n * TypeSystemDirectiveLocation : one of\n * `SCHEMA`\n * `SCALAR`\n * `OBJECT`\n * `FIELD_DEFINITION`\n * `ARGUMENT_DEFINITION`\n * `INTERFACE`\n * `UNION`\n * `ENUM`\n * `ENUM_VALUE`\n * `INPUT_OBJECT`\n * `INPUT_FIELD_DEFINITION`\n */\n parseDirectiveLocation(): NameNode {\n const start = this._lexer.token;\n const name = this.parseName();\n if (Object.hasOwn(DirectiveLocation, name.value)) {\n return name;\n }\n throw this.unexpected(start);\n }\n\n // Core parsing utility functions\n\n /**\n * Returns a node that, if configured to do so, sets a \"loc\" field as a\n * location object, used to identify the place in the source that created a\n * given parsed object.\n */\n node(\n startToken: Token,\n node: T,\n ): T {\n if (this._options.noLocation !== true) {\n node.loc = new Location(\n startToken,\n this._lexer.lastToken,\n this._lexer.source,\n );\n }\n return node;\n }\n\n /**\n * Determines if the next token is of a given kind\n */\n peek(kind: TokenKind): boolean {\n return this._lexer.token.kind === kind;\n }\n\n /**\n * If the next token is of the given kind, return that token after advancing the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n expectToken(kind: TokenKind): Token {\n const token = this._lexer.token;\n if (token.kind === kind) {\n this.advanceLexer();\n return token;\n }\n\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`,\n );\n }\n\n /**\n * If the next token is of the given kind, return \"true\" after advancing the lexer.\n * Otherwise, do not change the parser state and return \"false\".\n */\n expectOptionalToken(kind: TokenKind): boolean {\n const token = this._lexer.token;\n if (token.kind === kind) {\n this.advanceLexer();\n return true;\n }\n return false;\n }\n\n /**\n * If the next token is a given keyword, advance the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n expectKeyword(value: string): void {\n const token = this._lexer.token;\n if (token.kind === TokenKind.NAME && token.value === value) {\n this.advanceLexer();\n } else {\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Expected \"${value}\", found ${getTokenDesc(token)}.`,\n );\n }\n }\n\n /**\n * If the next token is a given keyword, return \"true\" after advancing the lexer.\n * Otherwise, do not change the parser state and return \"false\".\n */\n expectOptionalKeyword(value: string): boolean {\n const token = this._lexer.token;\n if (token.kind === TokenKind.NAME && token.value === value) {\n this.advanceLexer();\n return true;\n }\n return false;\n }\n\n /**\n * Helper function for creating an error when an unexpected lexed token is encountered.\n */\n unexpected(atToken?: Maybe): GraphQLError {\n const token = atToken ?? this._lexer.token;\n return syntaxError(\n this._lexer.source,\n token.start,\n `Unexpected ${getTokenDesc(token)}.`,\n );\n }\n\n /**\n * Returns a possibly empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n any(\n openKind: TokenKind,\n parseFn: () => T,\n closeKind: TokenKind,\n ): Array {\n this.expectToken(openKind);\n const nodes = [];\n while (!this.expectOptionalToken(closeKind)) {\n nodes.push(parseFn.call(this));\n }\n return nodes;\n }\n\n /**\n * Returns a list of parse nodes, determined by the parseFn.\n * It can be empty only if open token is missing otherwise it will always return non-empty list\n * that begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n optionalMany(\n openKind: TokenKind,\n parseFn: () => T,\n closeKind: TokenKind,\n ): Array | undefined {\n if (this.expectOptionalToken(openKind)) {\n const nodes = [];\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n return nodes;\n }\n return undefined;\n }\n\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n many(\n openKind: TokenKind,\n parseFn: () => T,\n closeKind: TokenKind,\n ): Array {\n this.expectToken(openKind);\n const nodes = [];\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n return nodes;\n }\n\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.\n * Advances the parser to the next lex token after last item in the list.\n */\n delimitedMany(delimiterKind: TokenKind, parseFn: () => T): Array {\n this.expectOptionalToken(delimiterKind);\n\n const nodes = [];\n do {\n nodes.push(parseFn.call(this));\n } while (this.expectOptionalToken(delimiterKind));\n return nodes;\n }\n\n advanceLexer(): void {\n const { maxTokens } = this._options;\n const token = this._lexer.advance();\n\n if (token.kind !== TokenKind.EOF) {\n ++this._tokenCounter;\n if (maxTokens !== undefined && this._tokenCounter > maxTokens) {\n throw syntaxError(\n this._lexer.source,\n token.start,\n `Document contains more than ${maxTokens} tokens. Parsing aborted.`,\n );\n }\n }\n }\n}\n\n/**\n * A helper function to describe a token as a string for debugging.\n */\nfunction getTokenDesc(token: Token): string {\n const value = token.value;\n return getTokenKindDesc(token.kind) + (value != null ? ` \"${value}\"` : '');\n}\n\n/**\n * A helper function to describe a token kind as a string for debugging.\n */\nfunction getTokenKindDesc(kind: TokenKind): string {\n return isPunctuatorTokenKind(kind) ? `\"${kind}\"` : kind;\n}\n"]} \ No newline at end of file diff --git a/language/predicates.d.ts b/language/predicates.d.ts new file mode 100644 index 0000000000..da441cbddc --- /dev/null +++ b/language/predicates.d.ts @@ -0,0 +1,11 @@ +import type { ASTNode, ConstValueNode, DefinitionNode, ExecutableDefinitionNode, SelectionNode, TypeDefinitionNode, TypeExtensionNode, TypeNode, TypeSystemDefinitionNode, TypeSystemExtensionNode, ValueNode } from './ast.js'; +export declare function isDefinitionNode(node: ASTNode): node is DefinitionNode; +export declare function isExecutableDefinitionNode(node: ASTNode): node is ExecutableDefinitionNode; +export declare function isSelectionNode(node: ASTNode): node is SelectionNode; +export declare function isValueNode(node: ASTNode): node is ValueNode; +export declare function isConstValueNode(node: ASTNode): node is ConstValueNode; +export declare function isTypeNode(node: ASTNode): node is TypeNode; +export declare function isTypeSystemDefinitionNode(node: ASTNode): node is TypeSystemDefinitionNode; +export declare function isTypeDefinitionNode(node: ASTNode): node is TypeDefinitionNode; +export declare function isTypeSystemExtensionNode(node: ASTNode): node is TypeSystemExtensionNode; +export declare function isTypeExtensionNode(node: ASTNode): node is TypeExtensionNode; diff --git a/language/predicates.js b/language/predicates.js new file mode 100644 index 0000000000..9196b8d5f4 --- /dev/null +++ b/language/predicates.js @@ -0,0 +1,76 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isDefinitionNode = isDefinitionNode; +exports.isExecutableDefinitionNode = isExecutableDefinitionNode; +exports.isSelectionNode = isSelectionNode; +exports.isValueNode = isValueNode; +exports.isConstValueNode = isConstValueNode; +exports.isTypeNode = isTypeNode; +exports.isTypeSystemDefinitionNode = isTypeSystemDefinitionNode; +exports.isTypeDefinitionNode = isTypeDefinitionNode; +exports.isTypeSystemExtensionNode = isTypeSystemExtensionNode; +exports.isTypeExtensionNode = isTypeExtensionNode; +const kinds_js_1 = require("./kinds.js"); +function isDefinitionNode(node) { + return (isExecutableDefinitionNode(node) || + isTypeSystemDefinitionNode(node) || + isTypeSystemExtensionNode(node)); +} +function isExecutableDefinitionNode(node) { + return (node.kind === kinds_js_1.Kind.OPERATION_DEFINITION || + node.kind === kinds_js_1.Kind.FRAGMENT_DEFINITION); +} +function isSelectionNode(node) { + return (node.kind === kinds_js_1.Kind.FIELD || + node.kind === kinds_js_1.Kind.FRAGMENT_SPREAD || + node.kind === kinds_js_1.Kind.INLINE_FRAGMENT); +} +function isValueNode(node) { + return (node.kind === kinds_js_1.Kind.VARIABLE || + node.kind === kinds_js_1.Kind.INT || + node.kind === kinds_js_1.Kind.FLOAT || + node.kind === kinds_js_1.Kind.STRING || + node.kind === kinds_js_1.Kind.BOOLEAN || + node.kind === kinds_js_1.Kind.NULL || + node.kind === kinds_js_1.Kind.ENUM || + node.kind === kinds_js_1.Kind.LIST || + node.kind === kinds_js_1.Kind.OBJECT); +} +function isConstValueNode(node) { + return (isValueNode(node) && + (node.kind === kinds_js_1.Kind.LIST + ? node.values.some(isConstValueNode) + : node.kind === kinds_js_1.Kind.OBJECT + ? node.fields.some((field) => isConstValueNode(field.value)) + : node.kind !== kinds_js_1.Kind.VARIABLE)); +} +function isTypeNode(node) { + return (node.kind === kinds_js_1.Kind.NAMED_TYPE || + node.kind === kinds_js_1.Kind.LIST_TYPE || + node.kind === kinds_js_1.Kind.NON_NULL_TYPE); +} +function isTypeSystemDefinitionNode(node) { + return (node.kind === kinds_js_1.Kind.SCHEMA_DEFINITION || + isTypeDefinitionNode(node) || + node.kind === kinds_js_1.Kind.DIRECTIVE_DEFINITION); +} +function isTypeDefinitionNode(node) { + return (node.kind === kinds_js_1.Kind.SCALAR_TYPE_DEFINITION || + node.kind === kinds_js_1.Kind.OBJECT_TYPE_DEFINITION || + node.kind === kinds_js_1.Kind.INTERFACE_TYPE_DEFINITION || + node.kind === kinds_js_1.Kind.UNION_TYPE_DEFINITION || + node.kind === kinds_js_1.Kind.ENUM_TYPE_DEFINITION || + node.kind === kinds_js_1.Kind.INPUT_OBJECT_TYPE_DEFINITION); +} +function isTypeSystemExtensionNode(node) { + return node.kind === kinds_js_1.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node); +} +function isTypeExtensionNode(node) { + return (node.kind === kinds_js_1.Kind.SCALAR_TYPE_EXTENSION || + node.kind === kinds_js_1.Kind.OBJECT_TYPE_EXTENSION || + node.kind === kinds_js_1.Kind.INTERFACE_TYPE_EXTENSION || + node.kind === kinds_js_1.Kind.UNION_TYPE_EXTENSION || + node.kind === kinds_js_1.Kind.ENUM_TYPE_EXTENSION || + node.kind === kinds_js_1.Kind.INPUT_OBJECT_TYPE_EXTENSION); +} +//# sourceMappingURL=predicates.js.map \ No newline at end of file diff --git a/language/predicates.js.map b/language/predicates.js.map new file mode 100644 index 0000000000..f07bee2cd1 --- /dev/null +++ b/language/predicates.js.map @@ -0,0 +1 @@ +{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../src/language/predicates.ts"],"names":[],"mappings":";;AAeA,4CAMC;AAED,gEAOC;AAED,0CAMC;AAED,kCAYC;AAED,4CASC;AAED,gCA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BAAgB,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAAa;IAC/C,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,eAAI,CAAC,qBAAqB;QACxC,IAAI,CAAC,IAAI,KAAK,eAAI,CAAC,qBAAqB;QACxC,IAAI,CAAC,IAAI,KAAK,eAAI,CAAC,wBAAwB;QAC3C,IAAI,CAAC,IAAI,KAAK,eAAI,CAAC,oBAAoB;QACvC,IAAI,CAAC,IAAI,KAAK,eAAI,CAAC,mBAAmB;QACtC,IAAI,CAAC,IAAI,KAAK,eAAI,CAAC,2BAA2B,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ASTNode,\n ConstValueNode,\n DefinitionNode,\n ExecutableDefinitionNode,\n SelectionNode,\n TypeDefinitionNode,\n TypeExtensionNode,\n TypeNode,\n TypeSystemDefinitionNode,\n TypeSystemExtensionNode,\n ValueNode,\n} from './ast.js';\nimport { Kind } from './kinds.js';\n\nexport function isDefinitionNode(node: ASTNode): node is DefinitionNode {\n return (\n isExecutableDefinitionNode(node) ||\n isTypeSystemDefinitionNode(node) ||\n isTypeSystemExtensionNode(node)\n );\n}\n\nexport function isExecutableDefinitionNode(\n node: ASTNode,\n): node is ExecutableDefinitionNode {\n return (\n node.kind === Kind.OPERATION_DEFINITION ||\n node.kind === Kind.FRAGMENT_DEFINITION\n );\n}\n\nexport function isSelectionNode(node: ASTNode): node is SelectionNode {\n return (\n node.kind === Kind.FIELD ||\n node.kind === Kind.FRAGMENT_SPREAD ||\n node.kind === Kind.INLINE_FRAGMENT\n );\n}\n\nexport function isValueNode(node: ASTNode): node is ValueNode {\n return (\n node.kind === Kind.VARIABLE ||\n node.kind === Kind.INT ||\n node.kind === Kind.FLOAT ||\n node.kind === Kind.STRING ||\n node.kind === Kind.BOOLEAN ||\n node.kind === Kind.NULL ||\n node.kind === Kind.ENUM ||\n node.kind === Kind.LIST ||\n node.kind === Kind.OBJECT\n );\n}\n\nexport function isConstValueNode(node: ASTNode): node is ConstValueNode {\n return (\n isValueNode(node) &&\n (node.kind === Kind.LIST\n ? node.values.some(isConstValueNode)\n : node.kind === Kind.OBJECT\n ? node.fields.some((field) => isConstValueNode(field.value))\n : node.kind !== Kind.VARIABLE)\n );\n}\n\nexport function isTypeNode(node: ASTNode): node is TypeNode {\n return (\n node.kind === Kind.NAMED_TYPE ||\n node.kind === Kind.LIST_TYPE ||\n node.kind === Kind.NON_NULL_TYPE\n );\n}\n\nexport function isTypeSystemDefinitionNode(\n node: ASTNode,\n): node is TypeSystemDefinitionNode {\n return (\n node.kind === Kind.SCHEMA_DEFINITION ||\n isTypeDefinitionNode(node) ||\n node.kind === Kind.DIRECTIVE_DEFINITION\n );\n}\n\nexport function isTypeDefinitionNode(\n node: ASTNode,\n): node is TypeDefinitionNode {\n return (\n node.kind === Kind.SCALAR_TYPE_DEFINITION ||\n node.kind === Kind.OBJECT_TYPE_DEFINITION ||\n node.kind === Kind.INTERFACE_TYPE_DEFINITION ||\n node.kind === Kind.UNION_TYPE_DEFINITION ||\n node.kind === Kind.ENUM_TYPE_DEFINITION ||\n node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION\n );\n}\n\nexport function isTypeSystemExtensionNode(\n node: ASTNode,\n): node is TypeSystemExtensionNode {\n return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);\n}\n\nexport function isTypeExtensionNode(node: ASTNode): node is TypeExtensionNode {\n return (\n node.kind === Kind.SCALAR_TYPE_EXTENSION ||\n node.kind === Kind.OBJECT_TYPE_EXTENSION ||\n node.kind === Kind.INTERFACE_TYPE_EXTENSION ||\n node.kind === Kind.UNION_TYPE_EXTENSION ||\n node.kind === Kind.ENUM_TYPE_EXTENSION ||\n node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION\n );\n}\n"]} \ No newline at end of file diff --git a/language/predicates.mjs b/language/predicates.mjs new file mode 100644 index 0000000000..38f2f84a98 --- /dev/null +++ b/language/predicates.mjs @@ -0,0 +1,64 @@ +import { Kind } from "./kinds.mjs"; +export function isDefinitionNode(node) { + return (isExecutableDefinitionNode(node) || + isTypeSystemDefinitionNode(node) || + isTypeSystemExtensionNode(node)); +} +export function isExecutableDefinitionNode(node) { + return (node.kind === Kind.OPERATION_DEFINITION || + node.kind === Kind.FRAGMENT_DEFINITION); +} +export function isSelectionNode(node) { + return (node.kind === Kind.FIELD || + node.kind === Kind.FRAGMENT_SPREAD || + node.kind === Kind.INLINE_FRAGMENT); +} +export function isValueNode(node) { + return (node.kind === Kind.VARIABLE || + node.kind === Kind.INT || + node.kind === Kind.FLOAT || + node.kind === Kind.STRING || + node.kind === Kind.BOOLEAN || + node.kind === Kind.NULL || + node.kind === Kind.ENUM || + node.kind === Kind.LIST || + node.kind === Kind.OBJECT); +} +export function isConstValueNode(node) { + return (isValueNode(node) && + (node.kind === Kind.LIST + ? node.values.some(isConstValueNode) + : node.kind === Kind.OBJECT + ? node.fields.some((field) => isConstValueNode(field.value)) + : node.kind !== Kind.VARIABLE)); +} +export function isTypeNode(node) { + return (node.kind === Kind.NAMED_TYPE || + node.kind === Kind.LIST_TYPE || + node.kind === Kind.NON_NULL_TYPE); +} +export function isTypeSystemDefinitionNode(node) { + return (node.kind === Kind.SCHEMA_DEFINITION || + isTypeDefinitionNode(node) || + node.kind === Kind.DIRECTIVE_DEFINITION); +} +export function isTypeDefinitionNode(node) { + return (node.kind === Kind.SCALAR_TYPE_DEFINITION || + node.kind === Kind.OBJECT_TYPE_DEFINITION || + node.kind === Kind.INTERFACE_TYPE_DEFINITION || + node.kind === Kind.UNION_TYPE_DEFINITION || + node.kind === Kind.ENUM_TYPE_DEFINITION || + node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION); +} +export function isTypeSystemExtensionNode(node) { + return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node); +} +export function isTypeExtensionNode(node) { + return (node.kind === Kind.SCALAR_TYPE_EXTENSION || + node.kind === Kind.OBJECT_TYPE_EXTENSION || + node.kind === Kind.INTERFACE_TYPE_EXTENSION || + node.kind === Kind.UNION_TYPE_EXTENSION || + node.kind === Kind.ENUM_TYPE_EXTENSION || + node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION); +} +//# sourceMappingURL=predicates.js.map \ No newline at end of file diff --git a/language/predicates.mjs.map b/language/predicates.mjs.map new file mode 100644 index 0000000000..4dd57df65c --- /dev/null +++ b/language/predicates.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../src/language/predicates.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,oBAAmB;AAElC,MAAM,UAAU,gBAAgB,CAAC,IAAa;IAC5C,OAAO,CACL,0BAA0B,CAAC,IAAI,CAAC;QAChC,0BAA0B,CAAC,IAAI,CAAC;QAChC,yBAAyB,CAAC,IAAI,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,IAAa;IAEb,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,oBAAoB;QACvC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,mBAAmB,CACvC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK;QACxB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,eAAe;QAClC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,eAAe,CACnC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ;QAC3B,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG;QACtB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK;QACxB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM;QACzB,IAAI,CAAC,IAAI,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AAI,CAAC,sBAAsB;QACzC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,sBAAsB;QACzC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,yBAAyB;QAC5C,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,qBAAqB;QACxC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,oBAAoB;QACvC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,4BAA4B,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,IAAa;IAEb,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,gBAAgB,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAa;IAC/C,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,qBAAqB;QACxC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,qBAAqB;QACxC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,wBAAwB;QAC3C,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,oBAAoB;QACvC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,mBAAmB;QACtC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,2BAA2B,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ASTNode,\n ConstValueNode,\n DefinitionNode,\n ExecutableDefinitionNode,\n SelectionNode,\n TypeDefinitionNode,\n TypeExtensionNode,\n TypeNode,\n TypeSystemDefinitionNode,\n TypeSystemExtensionNode,\n ValueNode,\n} from './ast.js';\nimport { Kind } from './kinds.js';\n\nexport function isDefinitionNode(node: ASTNode): node is DefinitionNode {\n return (\n isExecutableDefinitionNode(node) ||\n isTypeSystemDefinitionNode(node) ||\n isTypeSystemExtensionNode(node)\n );\n}\n\nexport function isExecutableDefinitionNode(\n node: ASTNode,\n): node is ExecutableDefinitionNode {\n return (\n node.kind === Kind.OPERATION_DEFINITION ||\n node.kind === Kind.FRAGMENT_DEFINITION\n );\n}\n\nexport function isSelectionNode(node: ASTNode): node is SelectionNode {\n return (\n node.kind === Kind.FIELD ||\n node.kind === Kind.FRAGMENT_SPREAD ||\n node.kind === Kind.INLINE_FRAGMENT\n );\n}\n\nexport function isValueNode(node: ASTNode): node is ValueNode {\n return (\n node.kind === Kind.VARIABLE ||\n node.kind === Kind.INT ||\n node.kind === Kind.FLOAT ||\n node.kind === Kind.STRING ||\n node.kind === Kind.BOOLEAN ||\n node.kind === Kind.NULL ||\n node.kind === Kind.ENUM ||\n node.kind === Kind.LIST ||\n node.kind === Kind.OBJECT\n );\n}\n\nexport function isConstValueNode(node: ASTNode): node is ConstValueNode {\n return (\n isValueNode(node) &&\n (node.kind === Kind.LIST\n ? node.values.some(isConstValueNode)\n : node.kind === Kind.OBJECT\n ? node.fields.some((field) => isConstValueNode(field.value))\n : node.kind !== Kind.VARIABLE)\n );\n}\n\nexport function isTypeNode(node: ASTNode): node is TypeNode {\n return (\n node.kind === Kind.NAMED_TYPE ||\n node.kind === Kind.LIST_TYPE ||\n node.kind === Kind.NON_NULL_TYPE\n );\n}\n\nexport function isTypeSystemDefinitionNode(\n node: ASTNode,\n): node is TypeSystemDefinitionNode {\n return (\n node.kind === Kind.SCHEMA_DEFINITION ||\n isTypeDefinitionNode(node) ||\n node.kind === Kind.DIRECTIVE_DEFINITION\n );\n}\n\nexport function isTypeDefinitionNode(\n node: ASTNode,\n): node is TypeDefinitionNode {\n return (\n node.kind === Kind.SCALAR_TYPE_DEFINITION ||\n node.kind === Kind.OBJECT_TYPE_DEFINITION ||\n node.kind === Kind.INTERFACE_TYPE_DEFINITION ||\n node.kind === Kind.UNION_TYPE_DEFINITION ||\n node.kind === Kind.ENUM_TYPE_DEFINITION ||\n node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION\n );\n}\n\nexport function isTypeSystemExtensionNode(\n node: ASTNode,\n): node is TypeSystemExtensionNode {\n return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);\n}\n\nexport function isTypeExtensionNode(node: ASTNode): node is TypeExtensionNode {\n return (\n node.kind === Kind.SCALAR_TYPE_EXTENSION ||\n node.kind === Kind.OBJECT_TYPE_EXTENSION ||\n node.kind === Kind.INTERFACE_TYPE_EXTENSION ||\n node.kind === Kind.UNION_TYPE_EXTENSION ||\n node.kind === Kind.ENUM_TYPE_EXTENSION ||\n node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION\n );\n}\n"]} \ No newline at end of file diff --git a/language/printLocation.d.ts b/language/printLocation.d.ts new file mode 100644 index 0000000000..195ac931a5 --- /dev/null +++ b/language/printLocation.d.ts @@ -0,0 +1,11 @@ +import type { Location } from './ast.js'; +import type { SourceLocation } from './location.js'; +import type { Source } from './source.js'; +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +export declare function printLocation(location: Location): string; +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +export declare function printSourceLocation(source: Source, sourceLocation: SourceLocation): string; diff --git a/language/printLocation.js b/language/printLocation.js new file mode 100644 index 0000000000..59462d53e8 --- /dev/null +++ b/language/printLocation.js @@ -0,0 +1,60 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.printLocation = printLocation; +exports.printSourceLocation = printSourceLocation; +const location_js_1 = require("./location.js"); +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +function printLocation(location) { + return printSourceLocation(location.source, (0, location_js_1.getLocation)(location.source, location.start)); +} +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +function printSourceLocation(source, sourceLocation) { + const firstLineColumnOffset = source.locationOffset.column - 1; + const body = ''.padStart(firstLineColumnOffset) + source.body; + const lineIndex = sourceLocation.line - 1; + const lineOffset = source.locationOffset.line - 1; + const lineNum = sourceLocation.line + lineOffset; + const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0; + const columnNum = sourceLocation.column + columnOffset; + const locationStr = `${source.name}:${lineNum}:${columnNum}\n`; + const lines = body.split(/\r\n|[\n\r]/g); + const locationLine = lines[lineIndex]; + // Special case for minified documents + if (locationLine.length > 120) { + const subLineIndex = Math.floor(columnNum / 80); + const subLineColumnNum = columnNum % 80; + const subLines = []; + for (let i = 0; i < locationLine.length; i += 80) { + subLines.push(locationLine.slice(i, i + 80)); + } + return (locationStr + + printPrefixedLines([ + [`${lineNum} |`, subLines[0]], + ...subLines + .slice(1, subLineIndex + 1) + .map((subLine) => ['|', subLine]), + ['|', '^'.padStart(subLineColumnNum)], + ['|', subLines[subLineIndex + 1]], + ])); + } + return (locationStr + + printPrefixedLines([ + // Lines specified like this: ["prefix", "string"], + [`${lineNum - 1} |`, lines[lineIndex - 1]], + [`${lineNum} |`, locationLine], + ['|', '^'.padStart(columnNum)], + [`${lineNum + 1} |`, lines[lineIndex + 1]], + ])); +} +function printPrefixedLines(lines) { + const existingLines = lines.filter(([_, line]) => line !== undefined); + const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length)); + return existingLines + .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : '')) + .join('\n'); +} +//# sourceMappingURL=printLocation.js.map \ No newline at end of file diff --git a/language/printLocation.js.map b/language/printLocation.js.map new file mode 100644 index 0000000000..b1c1890668 --- /dev/null +++ b/language/printLocation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"printLocation.js","sourceRoot":"","sources":["../../src/language/printLocation.ts"],"names":[],"mappings":";;AAQA,sCAKC;AAKD,kDAkDC;AAlED,+CAA4C;AAG5C;;GAEG;AACH,SAAgB,aAAa,CAAC,QAAkB;IAC9C,OAAO,mBAAmB,CACxB,QAAQ,CAAC,MAAM,EACf,IAAA,yBAAW,EAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,MAAc,EACd,cAA8B;IAE9B,MAAM,qBAAqB,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;I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GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC3E,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC","sourcesContent":["import type { Location } from './ast.js';\nimport type { SourceLocation } from './location.js';\nimport { getLocation } from './location.js';\nimport type { Source } from './source.js';\n\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\nexport function printLocation(location: Location): string {\n return printSourceLocation(\n location.source,\n getLocation(location.source, location.start),\n );\n}\n\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\nexport function printSourceLocation(\n source: Source,\n sourceLocation: SourceLocation,\n): string {\n const firstLineColumnOffset = source.locationOffset.column - 1;\n const body = ''.padStart(firstLineColumnOffset) + source.body;\n\n const lineIndex = sourceLocation.line - 1;\n const lineOffset = source.locationOffset.line - 1;\n const lineNum = sourceLocation.line + lineOffset;\n\n const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;\n const columnNum = sourceLocation.column + columnOffset;\n const locationStr = `${source.name}:${lineNum}:${columnNum}\\n`;\n\n const lines = body.split(/\\r\\n|[\\n\\r]/g);\n const locationLine = lines[lineIndex];\n\n // Special case for minified documents\n if (locationLine.length > 120) {\n const subLineIndex = Math.floor(columnNum / 80);\n const subLineColumnNum = columnNum % 80;\n const subLines: Array = [];\n for (let i = 0; i < locationLine.length; i += 80) {\n subLines.push(locationLine.slice(i, i + 80));\n }\n\n return (\n locationStr +\n printPrefixedLines([\n [`${lineNum} |`, subLines[0]],\n ...subLines\n .slice(1, subLineIndex + 1)\n .map((subLine) => ['|', subLine] as const),\n ['|', '^'.padStart(subLineColumnNum)],\n ['|', subLines[subLineIndex + 1]],\n ])\n );\n }\n\n return (\n locationStr +\n printPrefixedLines([\n // Lines specified like this: [\"prefix\", \"string\"],\n [`${lineNum - 1} |`, lines[lineIndex - 1]],\n [`${lineNum} |`, locationLine],\n ['|', '^'.padStart(columnNum)],\n [`${lineNum + 1} |`, lines[lineIndex + 1]],\n ])\n );\n}\n\nfunction printPrefixedLines(\n lines: ReadonlyArray,\n): string {\n const existingLines = lines.filter(([_, line]) => line !== undefined);\n\n const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));\n return existingLines\n .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : ''))\n .join('\\n');\n}\n"]} \ No newline at end of file diff --git a/language/printLocation.mjs b/language/printLocation.mjs new file mode 100644 index 0000000000..2cec39648b --- /dev/null +++ b/language/printLocation.mjs @@ -0,0 +1,56 @@ +import { getLocation } from "./location.mjs"; +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +export function printLocation(location) { + return printSourceLocation(location.source, getLocation(location.source, location.start)); +} +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +export function printSourceLocation(source, sourceLocation) { + const firstLineColumnOffset = source.locationOffset.column - 1; + const body = ''.padStart(firstLineColumnOffset) + source.body; + const lineIndex = sourceLocation.line - 1; + const lineOffset = source.locationOffset.line - 1; + const lineNum = sourceLocation.line + lineOffset; + const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0; + const columnNum = sourceLocation.column + columnOffset; + const locationStr = `${source.name}:${lineNum}:${columnNum}\n`; + const lines = body.split(/\r\n|[\n\r]/g); + const locationLine = lines[lineIndex]; + // Special case for minified documents + if (locationLine.length > 120) { + const subLineIndex = Math.floor(columnNum / 80); + const subLineColumnNum = columnNum % 80; + const subLines = []; + for (let i = 0; i < locationLine.length; i += 80) { + subLines.push(locationLine.slice(i, i + 80)); + } + return (locationStr + + printPrefixedLines([ + [`${lineNum} |`, subLines[0]], + ...subLines + .slice(1, subLineIndex + 1) + .map((subLine) => ['|', subLine]), + ['|', '^'.padStart(subLineColumnNum)], + ['|', subLines[subLineIndex + 1]], + ])); + } + return (locationStr + + printPrefixedLines([ + // Lines specified like this: ["prefix", "string"], + [`${lineNum - 1} |`, lines[lineIndex - 1]], + [`${lineNum} |`, locationLine], + ['|', '^'.padStart(columnNum)], + [`${lineNum + 1} |`, lines[lineIndex + 1]], + ])); +} +function printPrefixedLines(lines) { + const existingLines = lines.filter(([_, line]) => line !== undefined); + const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length)); + return existingLines + .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : '')) + .join('\n'); +} +//# sourceMappingURL=printLocation.js.map \ No newline at end of file diff --git a/language/printLocation.mjs.map b/language/printLocation.mjs.map new file mode 100644 index 0000000000..0450fe7144 --- /dev/null +++ b/language/printLocation.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"printLocation.js","sourceRoot":"","sources":["../../src/language/printLocation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,uBAAsB;AAG5C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,OAAO,mBAAmB,CACxB,QAAQ,CAAC,MAAM,EACf,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc,EACd,cAA8B;IAE9B,MAAM,qBAAqB,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/D,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;IAE9D,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,GAAG,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,GAAG,UAAU,CAAC;IAEjD,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,GAAG,YAAY,CAAC;IACvD,MAAM,WAAW,GAAG,GAAG,MAA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1C,CAAC,GAAG,OAAO,IAAI,EAAE,YAAY,CAAC;YAC9B,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC9B,CAAC,GAAG,OAAO,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;SAC3C,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,KAA+C;IAE/C,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAEtE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3E,OAAO,aAAa;SACjB,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC3E,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC","sourcesContent":["import type { Location } from './ast.js';\nimport type { SourceLocation } from './location.js';\nimport { getLocation } from './location.js';\nimport type { Source } from './source.js';\n\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\nexport function printLocation(location: Location): string {\n return printSourceLocation(\n location.source,\n getLocation(location.source, location.start),\n );\n}\n\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\nexport function printSourceLocation(\n source: Source,\n sourceLocation: SourceLocation,\n): string {\n const firstLineColumnOffset = source.locationOffset.column - 1;\n const body = ''.padStart(firstLineColumnOffset) + source.body;\n\n const lineIndex = sourceLocation.line - 1;\n const lineOffset = source.locationOffset.line - 1;\n const lineNum = sourceLocation.line + lineOffset;\n\n const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;\n const columnNum = sourceLocation.column + columnOffset;\n const locationStr = `${source.name}:${lineNum}:${columnNum}\\n`;\n\n const lines = body.split(/\\r\\n|[\\n\\r]/g);\n const locationLine = lines[lineIndex];\n\n // Special case for minified documents\n if (locationLine.length > 120) {\n const subLineIndex = Math.floor(columnNum / 80);\n const subLineColumnNum = columnNum % 80;\n const subLines: Array = [];\n for (let i = 0; i < locationLine.length; i += 80) {\n subLines.push(locationLine.slice(i, i + 80));\n }\n\n return (\n locationStr +\n printPrefixedLines([\n [`${lineNum} |`, subLines[0]],\n ...subLines\n .slice(1, subLineIndex + 1)\n .map((subLine) => ['|', subLine] as const),\n ['|', '^'.padStart(subLineColumnNum)],\n ['|', subLines[subLineIndex + 1]],\n ])\n );\n }\n\n return (\n locationStr +\n printPrefixedLines([\n // Lines specified like this: [\"prefix\", \"string\"],\n [`${lineNum - 1} |`, lines[lineIndex - 1]],\n [`${lineNum} |`, locationLine],\n ['|', '^'.padStart(columnNum)],\n [`${lineNum + 1} |`, lines[lineIndex + 1]],\n ])\n );\n}\n\nfunction printPrefixedLines(\n lines: ReadonlyArray,\n): string {\n const existingLines = lines.filter(([_, line]) => line !== undefined);\n\n const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));\n return existingLines\n .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : ''))\n .join('\\n');\n}\n"]} \ No newline at end of file diff --git a/language/printString.d.ts b/language/printString.d.ts new file mode 100644 index 0000000000..34caad672b --- /dev/null +++ b/language/printString.d.ts @@ -0,0 +1,5 @@ +/** + * Prints a string as a GraphQL StringValue literal. Replaces control characters + * and excluded characters (" U+0022 and \\ U+005C) with escape sequences. + */ +export declare function printString(str: string): string; diff --git a/language/printString.js b/language/printString.js new file mode 100644 index 0000000000..c56b893e73 --- /dev/null +++ b/language/printString.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.printString = printString; +/** + * Prints a string as a GraphQL StringValue literal. Replaces control characters + * and excluded characters (" U+0022 and \\ U+005C) with escape sequences. + */ +function printString(str) { + return `"${str.replace(escapedRegExp, escapedReplacer)}"`; +} +// eslint-disable-next-line no-control-regex +const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g; +function escapedReplacer(str) { + return escapeSequences[str.charCodeAt(0)]; +} +// prettier-ignore +const escapeSequences = [ + '\\u0000', '\\u0001', '\\u0002', '\\u0003', '\\u0004', '\\u0005', '\\u0006', '\\u0007', + '\\b', '\\t', '\\n', '\\u000B', '\\f', '\\r', '\\u000E', '\\u000F', + '\\u0010', '\\u0011', '\\u0012', '\\u0013', '\\u0014', '\\u0015', '\\u0016', '\\u0017', + '\\u0018', '\\u0019', '\\u001A', '\\u001B', '\\u001C', '\\u001D', '\\u001E', '\\u001F', + '', '', '\\"', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 2F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 3F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 4F + '', '', '', '', '', '', '', '', + '', '', '', '', '\\\\', '', '', '', // 5F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 6F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '\\u007F', + '\\u0080', '\\u0081', '\\u0082', '\\u0083', '\\u0084', '\\u0085', '\\u0086', '\\u0087', + '\\u0088', '\\u0089', '\\u008A', '\\u008B', '\\u008C', '\\u008D', '\\u008E', '\\u008F', + '\\u0090', '\\u0091', '\\u0092', '\\u0093', '\\u0094', '\\u0095', '\\u0096', '\\u0097', + '\\u0098', '\\u0099', '\\u009A', '\\u009B', '\\u009C', '\\u009D', '\\u009E', '\\u009F', +]; +//# sourceMappingURL=printString.js.map \ No newline at end of file diff --git a/language/printString.js.map b/language/printString.js.map new file mode 100644 index 0000000000..b818d1e4b7 --- /dev/null +++ b/language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* Prints a string as a GraphQL StringValue literal. Replaces control characters\n * and excluded characters (\" U+0022 and \\\\ U+005C) with escape sequences.\n */\nexport function printString(str: string): string {\n return `\"${str.replace(escapedRegExp, escapedReplacer)}\"`;\n}\n\n// eslint-disable-next-line no-control-regex\nconst escapedRegExp = /[\\x00-\\x1f\\x22\\x5c\\x7f-\\x9f]/g;\n\nfunction escapedReplacer(str: string): string {\n return escapeSequences[str.charCodeAt(0)];\n}\n\n// prettier-ignore\nconst escapeSequences = [\n '\\\\u0000', '\\\\u0001', '\\\\u0002', '\\\\u0003', '\\\\u0004', '\\\\u0005', '\\\\u0006', '\\\\u0007',\n '\\\\b', '\\\\t', '\\\\n', '\\\\u000B', '\\\\f', '\\\\r', '\\\\u000E', '\\\\u000F',\n '\\\\u0010', '\\\\u0011', '\\\\u0012', '\\\\u0013', '\\\\u0014', '\\\\u0015', '\\\\u0016', '\\\\u0017',\n '\\\\u0018', '\\\\u0019', '\\\\u001A', '\\\\u001B', '\\\\u001C', '\\\\u001D', '\\\\u001E', '\\\\u001F',\n '', '', '\\\\\"', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 2F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 3F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 4F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '\\\\\\\\', '', '', '', // 5F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 6F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '\\\\u007F',\n '\\\\u0080', '\\\\u0081', '\\\\u0082', '\\\\u0083', '\\\\u0084', '\\\\u0085', '\\\\u0086', '\\\\u0087',\n '\\\\u0088', '\\\\u0089', '\\\\u008A', '\\\\u008B', '\\\\u008C', '\\\\u008D', '\\\\u008E', '\\\\u008F',\n '\\\\u0090', '\\\\u0091', '\\\\u0092', '\\\\u0093', '\\\\u0094', '\\\\u0095', '\\\\u0096', '\\\\u0097',\n '\\\\u0098', '\\\\u0099', '\\\\u009A', '\\\\u009B', '\\\\u009C', '\\\\u009D', '\\\\u009E', '\\\\u009F',\n];\n"]} \ No newline at end of file diff --git a/language/printString.mjs b/language/printString.mjs new file mode 100644 index 0000000000..881893acd8 --- /dev/null +++ b/language/printString.mjs @@ -0,0 +1,36 @@ +/** + * Prints a string as a GraphQL StringValue literal. Replaces control characters + * and excluded characters (" U+0022 and \\ U+005C) with escape sequences. + */ +export function printString(str) { + return `"${str.replace(escapedRegExp, escapedReplacer)}"`; +} +// eslint-disable-next-line no-control-regex +const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g; +function escapedReplacer(str) { + return escapeSequences[str.charCodeAt(0)]; +} +// prettier-ignore +const escapeSequences = [ + '\\u0000', '\\u0001', '\\u0002', '\\u0003', '\\u0004', '\\u0005', '\\u0006', '\\u0007', + '\\b', '\\t', '\\n', '\\u000B', '\\f', '\\r', '\\u000E', '\\u000F', + '\\u0010', '\\u0011', '\\u0012', '\\u0013', '\\u0014', '\\u0015', '\\u0016', '\\u0017', + '\\u0018', '\\u0019', '\\u001A', '\\u001B', '\\u001C', '\\u001D', '\\u001E', '\\u001F', + '', '', '\\"', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 2F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 3F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 4F + '', '', '', '', '', '', '', '', + '', '', '', '', '\\\\', '', '', '', // 5F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '', // 6F + '', '', '', '', '', '', '', '', + '', '', '', '', '', '', '', '\\u007F', + '\\u0080', '\\u0081', '\\u0082', '\\u0083', '\\u0084', '\\u0085', '\\u0086', '\\u0087', + '\\u0088', '\\u0089', '\\u008A', '\\u008B', '\\u008C', '\\u008D', '\\u008E', '\\u008F', + '\\u0090', '\\u0091', '\\u0092', '\\u0093', '\\u0094', '\\u0095', '\\u0096', '\\u0097', + '\\u0098', '\\u0099', '\\u009A', '\\u009B', '\\u009C', '\\u009D', '\\u009E', '\\u009F', +]; +//# sourceMappingURL=printString.js.map \ No newline at end of file diff --git a/language/printString.mjs.map b/language/printString.mjs.map new file mode 100644 index 0000000000..a876eb37c5 --- /dev/null +++ b/language/printString.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"printString.js","sourceRoot":"","sources":["../../src/language/printString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,GAAG,CAAC;AAC5D,CAAC;AAED,4CAA4C;AAC5C,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAEtD,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,kBAAkB;AAClB,MAAM,eAAe,GAAG;IACtB,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IACtF,KAAK,EAAM,KAAK,EAAM,KAAK,EAAM,SAAS,EAAE,KAAK,EAAM,KAAK,EAAM,SAAS,EAAE,SAAS;IACtF,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IACtF,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IACtF,EAAE,EAAS,EAAE,EAAS,KAAK,EAAM,EAAE,EAAS,EAAE,EAAS,EAAE,EAAS,EAAE,EAAS,EAAE;IAC/E,EAAE,EAAS,EAAE,EAAS,EAAE,EAAS,EAAE,EAAS,EAAE,EAAS,EAAE,EAAS,EAAE,EAAS,EAAE,EAAE,KAAK;IACtF,EAAE,EAAS,EAAE,EAAS,EAA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AS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IACtF,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;CACvF,CAAC","sourcesContent":["/**\n * Prints a string as a GraphQL StringValue literal. Replaces control characters\n * and excluded characters (\" U+0022 and \\\\ U+005C) with escape sequences.\n */\nexport function printString(str: string): string {\n return `\"${str.replace(escapedRegExp, escapedReplacer)}\"`;\n}\n\n// eslint-disable-next-line no-control-regex\nconst escapedRegExp = /[\\x00-\\x1f\\x22\\x5c\\x7f-\\x9f]/g;\n\nfunction escapedReplacer(str: string): string {\n return escapeSequences[str.charCodeAt(0)];\n}\n\n// prettier-ignore\nconst escapeSequences = [\n '\\\\u0000', '\\\\u0001', '\\\\u0002', '\\\\u0003', '\\\\u0004', '\\\\u0005', '\\\\u0006', '\\\\u0007',\n '\\\\b', '\\\\t', '\\\\n', '\\\\u000B', '\\\\f', '\\\\r', '\\\\u000E', '\\\\u000F',\n '\\\\u0010', '\\\\u0011', '\\\\u0012', '\\\\u0013', '\\\\u0014', '\\\\u0015', '\\\\u0016', '\\\\u0017',\n '\\\\u0018', '\\\\u0019', '\\\\u001A', '\\\\u001B', '\\\\u001C', '\\\\u001D', '\\\\u001E', '\\\\u001F',\n '', '', '\\\\\"', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 2F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 3F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 4F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '\\\\\\\\', '', '', '', // 5F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '', // 6F\n '', '', '', '', '', '', '', '',\n '', '', '', '', '', '', '', '\\\\u007F',\n '\\\\u0080', '\\\\u0081', '\\\\u0082', '\\\\u0083', '\\\\u0084', '\\\\u0085', '\\\\u0086', '\\\\u0087',\n '\\\\u0088', '\\\\u0089', '\\\\u008A', '\\\\u008B', '\\\\u008C', '\\\\u008D', '\\\\u008E', '\\\\u008F',\n '\\\\u0090', '\\\\u0091', '\\\\u0092', '\\\\u0093', '\\\\u0094', '\\\\u0095', '\\\\u0096', '\\\\u0097',\n '\\\\u0098', '\\\\u0099', '\\\\u009A', '\\\\u009B', '\\\\u009C', '\\\\u009D', '\\\\u009E', '\\\\u009F',\n];\n"]} \ No newline at end of file diff --git a/language/printer.d.ts b/language/printer.d.ts new file mode 100644 index 0000000000..e02b136b33 --- /dev/null +++ b/language/printer.d.ts @@ -0,0 +1,6 @@ +import type { ASTNode } from './ast.js'; +/** + * Converts an AST into a string, using one set of reasonable + * formatting rules. + */ +export declare function print(ast: ASTNode): string; diff --git a/language/printer.js b/language/printer.js new file mode 100644 index 0000000000..085c117d1d --- /dev/null +++ b/language/printer.js @@ -0,0 +1,256 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.print = print; +const blockString_js_1 = require("./blockString.js"); +const printString_js_1 = require("./printString.js"); +const visitor_js_1 = require("./visitor.js"); +/** + * Converts an AST into a string, using one set of reasonable + * formatting rules. + */ +function print(ast) { + return (0, visitor_js_1.visit)(ast, printDocASTReducer); +} +const MAX_LINE_LENGTH = 80; +const printDocASTReducer = { + Name: { leave: (node) => node.value }, + Variable: { leave: (node) => '$' + node.name }, + // Document + Document: { + leave: (node) => join(node.definitions, '\n\n'), + }, + OperationDefinition: { + leave(node) { + const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')'); + const prefix = join([ + node.operation, + join([node.name, varDefs]), + join(node.directives, ' '), + ], ' '); + // Anonymous queries with no directives or variable definitions can use + // the query short form. + return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet; + }, + }, + VariableDefinition: { + leave: ({ variable, type, defaultValue, directives }) => variable + + ': ' + + type + + wrap(' = ', defaultValue) + + wrap(' ', join(directives, ' ')), + }, + SelectionSet: { leave: ({ selections }) => block(selections) }, + Field: { + leave({ alias, name, arguments: args, directives, selectionSet }) { + const prefix = join([wrap('', alias, ': '), name], ''); + return join([ + wrappedLineAndArgs(prefix, args), + wrap(' ', join(directives, ' ')), + wrap(' ', selectionSet), + ]); + }, + }, + Argument: { leave: ({ name, value }) => name + ': ' + value }, + FragmentArgument: { leave: ({ name, value }) => name + ': ' + value }, + // Fragments + FragmentSpread: { + leave: ({ name, arguments: args, directives }) => { + const prefix = '...' + name; + return (wrappedLineAndArgs(prefix, args) + wrap(' ', join(directives, ' '))); + }, + }, + InlineFragment: { + leave: ({ typeCondition, directives, selectionSet }) => join([ + '...', + wrap('on ', typeCondition), + join(directives, ' '), + selectionSet, + ], ' '), + }, + FragmentDefinition: { + leave: ({ name, typeCondition, variableDefinitions, directives, selectionSet, }) => + // Note: fragment variable definitions are experimental and may be changed + // or removed in the future. + `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + + `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + + selectionSet, + }, + // Value + IntValue: { leave: ({ value }) => value }, + FloatValue: { leave: ({ value }) => value }, + StringValue: { + leave: ({ value, block: isBlockString }) => isBlockString === true ? (0, blockString_js_1.printBlockString)(value) : (0, printString_js_1.printString)(value), + }, + BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') }, + NullValue: { leave: () => 'null' }, + EnumValue: { leave: ({ value }) => value }, + ListValue: { + leave: ({ values }) => { + const valuesLine = '[' + join(values, ', ') + ']'; + if (valuesLine.length > MAX_LINE_LENGTH) { + return '[\n' + indent(join(values, '\n')) + '\n]'; + } + return valuesLine; + }, + }, + ObjectValue: { + leave: ({ fields }) => { + const fieldsLine = '{ ' + join(fields, ', ') + ' }'; + return fieldsLine.length > MAX_LINE_LENGTH ? block(fields) : fieldsLine; + }, + }, + ObjectField: { leave: ({ name, value }) => name + ': ' + value }, + // Directive + Directive: { + leave: ({ name, arguments: args }) => '@' + name + wrap('(', join(args, ', '), ')'), + }, + // Type + NamedType: { leave: ({ name }) => name }, + ListType: { leave: ({ type }) => '[' + type + ']' }, + NonNullType: { leave: ({ type }) => type + '!' }, + // Type System Definitions + SchemaDefinition: { + leave: ({ description, directives, operationTypes }) => wrap('', description, '\n') + + join(['schema', join(directives, ' '), block(operationTypes)], ' '), + }, + OperationTypeDefinition: { + leave: ({ operation, type }) => operation + ': ' + type, + }, + ScalarTypeDefinition: { + leave: ({ description, name, directives }) => wrap('', description, '\n') + + join(['scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') + + join([ + 'type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + FieldDefinition: { + leave: ({ description, name, arguments: args, type, directives }) => wrap('', description, '\n') + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + ': ' + + type + + wrap(' ', join(directives, ' ')), + }, + InputValueDefinition: { + leave: ({ description, name, type, defaultValue, directives }) => wrap('', description, '\n') + + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '), + }, + InterfaceTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') + + join([ + 'interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + UnionTypeDefinition: { + leave: ({ description, name, directives, types }) => wrap('', description, '\n') + + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '), + }, + EnumTypeDefinition: { + leave: ({ description, name, directives, values }) => wrap('', description, '\n') + + join(['enum', name, join(directives, ' '), block(values)], ' '), + }, + EnumValueDefinition: { + leave: ({ description, name, directives }) => wrap('', description, '\n') + join([name, join(directives, ' ')], ' '), + }, + InputObjectTypeDefinition: { + leave: ({ description, name, directives, fields }) => wrap('', description, '\n') + + join(['input', name, join(directives, ' '), block(fields)], ' '), + }, + DirectiveDefinition: { + leave: ({ description, name, arguments: args, repeatable, locations }) => wrap('', description, '\n') + + 'directive @' + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + (repeatable ? ' repeatable' : '') + + ' on ' + + join(locations, ' | '), + }, + SchemaExtension: { + leave: ({ directives, operationTypes }) => join(['extend schema', join(directives, ' '), block(operationTypes)], ' '), + }, + ScalarTypeExtension: { + leave: ({ name, directives }) => join(['extend scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => join([ + 'extend type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + InterfaceTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => join([ + 'extend interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + UnionTypeExtension: { + leave: ({ name, directives, types }) => join([ + 'extend union', + name, + join(directives, ' '), + wrap('= ', join(types, ' | ')), + ], ' '), + }, + EnumTypeExtension: { + leave: ({ name, directives, values }) => join(['extend enum', name, join(directives, ' '), block(values)], ' '), + }, + InputObjectTypeExtension: { + leave: ({ name, directives, fields }) => join(['extend input', name, join(directives, ' '), block(fields)], ' '), + }, +}; +/** + * Given maybeArray, print an empty string if it is null or empty, otherwise + * print all items together separated by separator if provided + */ +function join(maybeArray, separator = '') { + return maybeArray?.filter((x) => x).join(separator) ?? ''; +} +/** + * Given array, print each item on its own line, wrapped in an indented `{ }` block. + */ +function block(array) { + return wrap('{\n', indent(join(array, '\n')), '\n}'); +} +/** + * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string. + */ +function wrap(start, maybeString, end = '') { + return maybeString != null && maybeString !== '' + ? start + maybeString + end + : ''; +} +function indent(str) { + return wrap(' ', str.replaceAll('\n', '\n ')); +} +function hasMultilineItems(maybeArray) { + return maybeArray?.some((str) => str.includes('\n')) ?? false; +} +function wrappedLineAndArgs(prefix, args) { + let argsLine = prefix + wrap('(', join(args, ', '), ')'); + if (argsLine.length > MAX_LINE_LENGTH) { + argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)'); + } + return argsLine; +} +//# sourceMappingURL=printer.js.map \ No newline at end of file diff --git a/language/printer.js.map b/language/printer.js.map new file mode 100644 index 0000000000..d9b4a59722 --- /dev/null +++ b/language/printer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"printer.js","sourceRoot":"","sources":["../../src/language/printer.ts"],"names":[],"mappings":";;AAYA,sBAEC;AAXD,qDAAoD;AACpD,qDAA+C;AAE/C,6CAAqC;AAErC;;;GAGG;AACH,SAAgB,KAAK,CAAC,GAAY;IAChC,OAAO,IAAA,kBAAK,EAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,kBAAkB,GAAuB;IAC7C,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;IACrC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE;IAE9C,WAAW;IAEX,QAAQ,EAAE;QACR,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;KAChD;IAED,mBAAmB,EAAE;QACnB,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;YACrE,MAAM,MAAM,GAAG,IAAI,CACjB;gBACE,IAAI,CAAC,SAAS;gBACd,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC;aAC3B,EACD,GAAG,CACJ,CAAC;YAEF,uEA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AAC,UAAwC;IACjE,OAAO,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC;AAChE,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAc,EACd,IAAuC;IAEvC,IAAI,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAEzD,IAAI,QAAQ,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;QACtC,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ASTNode } from './ast.js';\nimport { printBlockString } from './blockString.js';\nimport { printString } from './printString.js';\nimport type { ASTReducer } from './visitor.js';\nimport { visit } from './visitor.js';\n\n/**\n * Converts an AST into a string, using one set of reasonable\n * formatting rules.\n */\nexport function print(ast: ASTNode): string {\n return visit(ast, printDocASTReducer);\n}\n\nconst MAX_LINE_LENGTH = 80;\n\nconst printDocASTReducer: ASTReducer = {\n Name: { leave: (node) => node.value },\n Variable: { leave: (node) => '$' + node.name },\n\n // Document\n\n Document: {\n leave: (node) => join(node.definitions, '\\n\\n'),\n },\n\n OperationDefinition: {\n leave(node) {\n const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');\n const prefix = join(\n [\n node.operation,\n join([node.name, varDefs]),\n join(node.directives, ' '),\n ],\n ' ',\n );\n\n // Anonymous queries with no directives or variable definitions can use\n // the query short form.\n return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet;\n },\n },\n\n VariableDefinition: {\n leave: ({ variable, type, defaultValue, directives }) =>\n variable +\n ': ' +\n type +\n wrap(' = ', defaultValue) +\n wrap(' ', join(directives, ' ')),\n },\n SelectionSet: { leave: ({ selections }) => block(selections) },\n\n Field: {\n leave({ alias, name, arguments: args, directives, selectionSet }) {\n const prefix = join([wrap('', alias, ': '), name], '');\n\n return join([\n wrappedLineAndArgs(prefix, args),\n wrap(' ', join(directives, ' ')),\n wrap(' ', selectionSet),\n ]);\n },\n },\n Argument: { leave: ({ name, value }) => name + ': ' + value },\n FragmentArgument: { leave: ({ name, value }) => name + ': ' + value },\n\n // Fragments\n\n FragmentSpread: {\n leave: ({ name, arguments: args, directives }) => {\n const prefix = '...' + name;\n return (\n wrappedLineAndArgs(prefix, args) + wrap(' ', join(directives, ' '))\n );\n },\n },\n\n InlineFragment: {\n leave: ({ typeCondition, directives, selectionSet }) =>\n join(\n [\n '...',\n wrap('on ', typeCondition),\n join(directives, ' '),\n selectionSet,\n ],\n ' ',\n ),\n },\n\n FragmentDefinition: {\n leave: ({\n name,\n typeCondition,\n variableDefinitions,\n directives,\n selectionSet,\n }) =>\n // Note: fragment variable definitions are experimental and may be changed\n // or removed in the future.\n `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` +\n `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` +\n selectionSet,\n },\n\n // Value\n\n IntValue: { leave: ({ value }) => value },\n FloatValue: { leave: ({ value }) => value },\n StringValue: {\n leave: ({ value, block: isBlockString }) =>\n isBlockString === true ? printBlockString(value) : printString(value),\n },\n BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },\n NullValue: { leave: () => 'null' },\n EnumValue: { leave: ({ value }) => value },\n ListValue: {\n leave: ({ values }) => {\n const valuesLine = '[' + join(values, ', ') + ']';\n\n if (valuesLine.length > MAX_LINE_LENGTH) {\n return '[\\n' + indent(join(values, '\\n')) + '\\n]';\n }\n return valuesLine;\n },\n },\n ObjectValue: {\n leave: ({ fields }) => {\n const fieldsLine = '{ ' + join(fields, ', ') + ' }';\n return fieldsLine.length > MAX_LINE_LENGTH ? block(fields) : fieldsLine;\n },\n },\n ObjectField: { leave: ({ name, value }) => name + ': ' + value },\n\n // Directive\n\n Directive: {\n leave: ({ name, arguments: args }) =>\n '@' + name + wrap('(', join(args, ', '), ')'),\n },\n\n // Type\n\n NamedType: { leave: ({ name }) => name },\n ListType: { leave: ({ type }) => '[' + type + ']' },\n NonNullType: { leave: ({ type }) => type + '!' },\n\n // Type System Definitions\n\n SchemaDefinition: {\n leave: ({ description, directives, operationTypes }) =>\n wrap('', description, '\\n') +\n join(['schema', join(directives, ' '), block(operationTypes)], ' '),\n },\n\n OperationTypeDefinition: {\n leave: ({ operation, type }) => operation + ': ' + type,\n },\n\n ScalarTypeDefinition: {\n leave: ({ description, name, directives }) =>\n wrap('', description, '\\n') +\n join(['scalar', name, join(directives, ' ')], ' '),\n },\n\n ObjectTypeDefinition: {\n leave: ({ description, name, interfaces, directives, fields }) =>\n wrap('', description, '\\n') +\n join(\n [\n 'type',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n FieldDefinition: {\n leave: ({ description, name, arguments: args, type, directives }) =>\n wrap('', description, '\\n') +\n name +\n (hasMultilineItems(args)\n ? wrap('(\\n', indent(join(args, '\\n')), '\\n)')\n : wrap('(', join(args, ', '), ')')) +\n ': ' +\n type +\n wrap(' ', join(directives, ' ')),\n },\n\n InputValueDefinition: {\n leave: ({ description, name, type, defaultValue, directives }) =>\n wrap('', description, '\\n') +\n join(\n [name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')],\n ' ',\n ),\n },\n\n InterfaceTypeDefinition: {\n leave: ({ description, name, interfaces, directives, fields }) =>\n wrap('', description, '\\n') +\n join(\n [\n 'interface',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n UnionTypeDefinition: {\n leave: ({ description, name, directives, types }) =>\n wrap('', description, '\\n') +\n join(\n ['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))],\n ' ',\n ),\n },\n\n EnumTypeDefinition: {\n leave: ({ description, name, directives, values }) =>\n wrap('', description, '\\n') +\n join(['enum', name, join(directives, ' '), block(values)], ' '),\n },\n\n EnumValueDefinition: {\n leave: ({ description, name, directives }) =>\n wrap('', description, '\\n') + join([name, join(directives, ' ')], ' '),\n },\n\n InputObjectTypeDefinition: {\n leave: ({ description, name, directives, fields }) =>\n wrap('', description, '\\n') +\n join(['input', name, join(directives, ' '), block(fields)], ' '),\n },\n\n DirectiveDefinition: {\n leave: ({ description, name, arguments: args, repeatable, locations }) =>\n wrap('', description, '\\n') +\n 'directive @' +\n name +\n (hasMultilineItems(args)\n ? wrap('(\\n', indent(join(args, '\\n')), '\\n)')\n : wrap('(', join(args, ', '), ')')) +\n (repeatable ? ' repeatable' : '') +\n ' on ' +\n join(locations, ' | '),\n },\n\n SchemaExtension: {\n leave: ({ directives, operationTypes }) =>\n join(\n ['extend schema', join(directives, ' '), block(operationTypes)],\n ' ',\n ),\n },\n\n ScalarTypeExtension: {\n leave: ({ name, directives }) =>\n join(['extend scalar', name, join(directives, ' ')], ' '),\n },\n\n ObjectTypeExtension: {\n leave: ({ name, interfaces, directives, fields }) =>\n join(\n [\n 'extend type',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n InterfaceTypeExtension: {\n leave: ({ name, interfaces, directives, fields }) =>\n join(\n [\n 'extend interface',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n UnionTypeExtension: {\n leave: ({ name, directives, types }) =>\n join(\n [\n 'extend union',\n name,\n join(directives, ' '),\n wrap('= ', join(types, ' | ')),\n ],\n ' ',\n ),\n },\n\n EnumTypeExtension: {\n leave: ({ name, directives, values }) =>\n join(['extend enum', name, join(directives, ' '), block(values)], ' '),\n },\n\n InputObjectTypeExtension: {\n leave: ({ name, directives, fields }) =>\n join(['extend input', name, join(directives, ' '), block(fields)], ' '),\n },\n};\n\n/**\n * Given maybeArray, print an empty string if it is null or empty, otherwise\n * print all items together separated by separator if provided\n */\nfunction join(\n maybeArray: Maybe>,\n separator = '',\n): string {\n return maybeArray?.filter((x) => x).join(separator) ?? '';\n}\n\n/**\n * Given array, print each item on its own line, wrapped in an indented `{ }` block.\n */\nfunction block(array: Maybe>): string {\n return wrap('{\\n', indent(join(array, '\\n')), '\\n}');\n}\n\n/**\n * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.\n */\nfunction wrap(\n start: string,\n maybeString: Maybe,\n end: string = '',\n): string {\n return maybeString != null && maybeString !== ''\n ? start + maybeString + end\n : '';\n}\n\nfunction indent(str: string): string {\n return wrap(' ', str.replaceAll('\\n', '\\n '));\n}\n\nfunction hasMultilineItems(maybeArray: Maybe>): boolean {\n return maybeArray?.some((str) => str.includes('\\n')) ?? false;\n}\n\nfunction wrappedLineAndArgs(\n prefix: string,\n args: ReadonlyArray | undefined,\n): string {\n let argsLine = prefix + wrap('(', join(args, ', '), ')');\n\n if (argsLine.length > MAX_LINE_LENGTH) {\n argsLine = prefix + wrap('(\\n', indent(join(args, '\\n')), '\\n)');\n }\n return argsLine;\n}\n"]} \ No newline at end of file diff --git a/language/printer.mjs b/language/printer.mjs new file mode 100644 index 0000000000..6e5533f1ef --- /dev/null +++ b/language/printer.mjs @@ -0,0 +1,253 @@ +import { printBlockString } from "./blockString.mjs"; +import { printString } from "./printString.mjs"; +import { visit } from "./visitor.mjs"; +/** + * Converts an AST into a string, using one set of reasonable + * formatting rules. + */ +export function print(ast) { + return visit(ast, printDocASTReducer); +} +const MAX_LINE_LENGTH = 80; +const printDocASTReducer = { + Name: { leave: (node) => node.value }, + Variable: { leave: (node) => '$' + node.name }, + // Document + Document: { + leave: (node) => join(node.definitions, '\n\n'), + }, + OperationDefinition: { + leave(node) { + const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')'); + const prefix = join([ + node.operation, + join([node.name, varDefs]), + join(node.directives, ' '), + ], ' '); + // Anonymous queries with no directives or variable definitions can use + // the query short form. + return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet; + }, + }, + VariableDefinition: { + leave: ({ variable, type, defaultValue, directives }) => variable + + ': ' + + type + + wrap(' = ', defaultValue) + + wrap(' ', join(directives, ' ')), + }, + SelectionSet: { leave: ({ selections }) => block(selections) }, + Field: { + leave({ alias, name, arguments: args, directives, selectionSet }) { + const prefix = join([wrap('', alias, ': '), name], ''); + return join([ + wrappedLineAndArgs(prefix, args), + wrap(' ', join(directives, ' ')), + wrap(' ', selectionSet), + ]); + }, + }, + Argument: { leave: ({ name, value }) => name + ': ' + value }, + FragmentArgument: { leave: ({ name, value }) => name + ': ' + value }, + // Fragments + FragmentSpread: { + leave: ({ name, arguments: args, directives }) => { + const prefix = '...' + name; + return (wrappedLineAndArgs(prefix, args) + wrap(' ', join(directives, ' '))); + }, + }, + InlineFragment: { + leave: ({ typeCondition, directives, selectionSet }) => join([ + '...', + wrap('on ', typeCondition), + join(directives, ' '), + selectionSet, + ], ' '), + }, + FragmentDefinition: { + leave: ({ name, typeCondition, variableDefinitions, directives, selectionSet, }) => + // Note: fragment variable definitions are experimental and may be changed + // or removed in the future. + `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + + `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + + selectionSet, + }, + // Value + IntValue: { leave: ({ value }) => value }, + FloatValue: { leave: ({ value }) => value }, + StringValue: { + leave: ({ value, block: isBlockString }) => isBlockString === true ? printBlockString(value) : printString(value), + }, + BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') }, + NullValue: { leave: () => 'null' }, + EnumValue: { leave: ({ value }) => value }, + ListValue: { + leave: ({ values }) => { + const valuesLine = '[' + join(values, ', ') + ']'; + if (valuesLine.length > MAX_LINE_LENGTH) { + return '[\n' + indent(join(values, '\n')) + '\n]'; + } + return valuesLine; + }, + }, + ObjectValue: { + leave: ({ fields }) => { + const fieldsLine = '{ ' + join(fields, ', ') + ' }'; + return fieldsLine.length > MAX_LINE_LENGTH ? block(fields) : fieldsLine; + }, + }, + ObjectField: { leave: ({ name, value }) => name + ': ' + value }, + // Directive + Directive: { + leave: ({ name, arguments: args }) => '@' + name + wrap('(', join(args, ', '), ')'), + }, + // Type + NamedType: { leave: ({ name }) => name }, + ListType: { leave: ({ type }) => '[' + type + ']' }, + NonNullType: { leave: ({ type }) => type + '!' }, + // Type System Definitions + SchemaDefinition: { + leave: ({ description, directives, operationTypes }) => wrap('', description, '\n') + + join(['schema', join(directives, ' '), block(operationTypes)], ' '), + }, + OperationTypeDefinition: { + leave: ({ operation, type }) => operation + ': ' + type, + }, + ScalarTypeDefinition: { + leave: ({ description, name, directives }) => wrap('', description, '\n') + + join(['scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') + + join([ + 'type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + FieldDefinition: { + leave: ({ description, name, arguments: args, type, directives }) => wrap('', description, '\n') + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + ': ' + + type + + wrap(' ', join(directives, ' ')), + }, + InputValueDefinition: { + leave: ({ description, name, type, defaultValue, directives }) => wrap('', description, '\n') + + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '), + }, + InterfaceTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') + + join([ + 'interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + UnionTypeDefinition: { + leave: ({ description, name, directives, types }) => wrap('', description, '\n') + + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '), + }, + EnumTypeDefinition: { + leave: ({ description, name, directives, values }) => wrap('', description, '\n') + + join(['enum', name, join(directives, ' '), block(values)], ' '), + }, + EnumValueDefinition: { + leave: ({ description, name, directives }) => wrap('', description, '\n') + join([name, join(directives, ' ')], ' '), + }, + InputObjectTypeDefinition: { + leave: ({ description, name, directives, fields }) => wrap('', description, '\n') + + join(['input', name, join(directives, ' '), block(fields)], ' '), + }, + DirectiveDefinition: { + leave: ({ description, name, arguments: args, repeatable, locations }) => wrap('', description, '\n') + + 'directive @' + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + (repeatable ? ' repeatable' : '') + + ' on ' + + join(locations, ' | '), + }, + SchemaExtension: { + leave: ({ directives, operationTypes }) => join(['extend schema', join(directives, ' '), block(operationTypes)], ' '), + }, + ScalarTypeExtension: { + leave: ({ name, directives }) => join(['extend scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => join([ + 'extend type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + InterfaceTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => join([ + 'extend interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], ' '), + }, + UnionTypeExtension: { + leave: ({ name, directives, types }) => join([ + 'extend union', + name, + join(directives, ' '), + wrap('= ', join(types, ' | ')), + ], ' '), + }, + EnumTypeExtension: { + leave: ({ name, directives, values }) => join(['extend enum', name, join(directives, ' '), block(values)], ' '), + }, + InputObjectTypeExtension: { + leave: ({ name, directives, fields }) => join(['extend input', name, join(directives, ' '), block(fields)], ' '), + }, +}; +/** + * Given maybeArray, print an empty string if it is null or empty, otherwise + * print all items together separated by separator if provided + */ +function join(maybeArray, separator = '') { + return maybeArray?.filter((x) => x).join(separator) ?? ''; +} +/** + * Given array, print each item on its own line, wrapped in an indented `{ }` block. + */ +function block(array) { + return wrap('{\n', indent(join(array, '\n')), '\n}'); +} +/** + * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string. + */ +function wrap(start, maybeString, end = '') { + return maybeString != null && maybeString !== '' + ? start + maybeString + end + : ''; +} +function indent(str) { + return wrap(' ', str.replaceAll('\n', '\n ')); +} +function hasMultilineItems(maybeArray) { + return maybeArray?.some((str) => str.includes('\n')) ?? false; +} +function wrappedLineAndArgs(prefix, args) { + let argsLine = prefix + wrap('(', join(args, ', '), ')'); + if (argsLine.length > MAX_LINE_LENGTH) { + argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)'); + } + return argsLine; +} +//# sourceMappingURL=printer.js.map \ No newline at end of file diff --git a/language/printer.mjs.map b/language/printer.mjs.map new file mode 100644 index 0000000000..81242f4661 --- /dev/null +++ b/language/printer.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"printer.js","sourceRoot":"","sources":["../../src/language/printer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,0BAAyB;AACpD,OAAO,EAAE,WAAW,EAAE,0BAAyB;AAE/C,OAAO,EAAE,KAAK,EAAE,sBAAqB;AAErC;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,OAAO,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,kBAAkB,GAAuB;IAC7C,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;IACrC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE;IAE9C,WAAW;IAEX,QAAQ,EAAE;QACR,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;KAChD;IAED,mBAAmB,EAAE;QACnB,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,GAAG,IAAI,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EhB,OAAO,WAAW,IAAI,IAAI,IAAI,WAAW,KAAK,EAAE;QAC9C,CAAC,CAAC,KAAK,GAAG,WAAW,GAAG,GAAG;QAC3B,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAwC;IACjE,OAAO,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC;AAChE,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAc,EACd,IAAuC;IAEvC,IAAI,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAEzD,IAAI,QAAQ,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;QACtC,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ASTNode } from './ast.js';\nimport { printBlockString } from './blockString.js';\nimport { printString } from './printString.js';\nimport type { ASTReducer } from './visitor.js';\nimport { visit } from './visitor.js';\n\n/**\n * Converts an AST into a string, using one set of reasonable\n * formatting rules.\n */\nexport function print(ast: ASTNode): string {\n return visit(ast, printDocASTReducer);\n}\n\nconst MAX_LINE_LENGTH = 80;\n\nconst printDocASTReducer: ASTReducer = {\n Name: { leave: (node) => node.value },\n Variable: { leave: (node) => '$' + node.name },\n\n // Document\n\n Document: {\n leave: (node) => join(node.definitions, '\\n\\n'),\n },\n\n OperationDefinition: {\n leave(node) {\n const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');\n const prefix = join(\n [\n node.operation,\n join([node.name, varDefs]),\n join(node.directives, ' '),\n ],\n ' ',\n );\n\n // Anonymous queries with no directives or variable definitions can use\n // the query short form.\n return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet;\n },\n },\n\n VariableDefinition: {\n leave: ({ variable, type, defaultValue, directives }) =>\n variable +\n ': ' +\n type +\n wrap(' = ', defaultValue) +\n wrap(' ', join(directives, ' ')),\n },\n SelectionSet: { leave: ({ selections }) => block(selections) },\n\n Field: {\n leave({ alias, name, arguments: args, directives, selectionSet }) {\n const prefix = join([wrap('', alias, ': '), name], '');\n\n return join([\n wrappedLineAndArgs(prefix, args),\n wrap(' ', join(directives, ' ')),\n wrap(' ', selectionSet),\n ]);\n },\n },\n Argument: { leave: ({ name, value }) => name + ': ' + value },\n FragmentArgument: { leave: ({ name, value }) => name + ': ' + value },\n\n // Fragments\n\n FragmentSpread: {\n leave: ({ name, arguments: args, directives }) => {\n const prefix = '...' + name;\n return (\n wrappedLineAndArgs(prefix, args) + wrap(' ', join(directives, ' '))\n );\n },\n },\n\n InlineFragment: {\n leave: ({ typeCondition, directives, selectionSet }) =>\n join(\n [\n '...',\n wrap('on ', typeCondition),\n join(directives, ' '),\n selectionSet,\n ],\n ' ',\n ),\n },\n\n FragmentDefinition: {\n leave: ({\n name,\n typeCondition,\n variableDefinitions,\n directives,\n selectionSet,\n }) =>\n // Note: fragment variable definitions are experimental and may be changed\n // or removed in the future.\n `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` +\n `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` +\n selectionSet,\n },\n\n // Value\n\n IntValue: { leave: ({ value }) => value },\n FloatValue: { leave: ({ value }) => value },\n StringValue: {\n leave: ({ value, block: isBlockString }) =>\n isBlockString === true ? printBlockString(value) : printString(value),\n },\n BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },\n NullValue: { leave: () => 'null' },\n EnumValue: { leave: ({ value }) => value },\n ListValue: {\n leave: ({ values }) => {\n const valuesLine = '[' + join(values, ', ') + ']';\n\n if (valuesLine.length > MAX_LINE_LENGTH) {\n return '[\\n' + indent(join(values, '\\n')) + '\\n]';\n }\n return valuesLine;\n },\n },\n ObjectValue: {\n leave: ({ fields }) => {\n const fieldsLine = '{ ' + join(fields, ', ') + ' }';\n return fieldsLine.length > MAX_LINE_LENGTH ? block(fields) : fieldsLine;\n },\n },\n ObjectField: { leave: ({ name, value }) => name + ': ' + value },\n\n // Directive\n\n Directive: {\n leave: ({ name, arguments: args }) =>\n '@' + name + wrap('(', join(args, ', '), ')'),\n },\n\n // Type\n\n NamedType: { leave: ({ name }) => name },\n ListType: { leave: ({ type }) => '[' + type + ']' },\n NonNullType: { leave: ({ type }) => type + '!' },\n\n // Type System Definitions\n\n SchemaDefinition: {\n leave: ({ description, directives, operationTypes }) =>\n wrap('', description, '\\n') +\n join(['schema', join(directives, ' '), block(operationTypes)], ' '),\n },\n\n OperationTypeDefinition: {\n leave: ({ operation, type }) => operation + ': ' + type,\n },\n\n ScalarTypeDefinition: {\n leave: ({ description, name, directives }) =>\n wrap('', description, '\\n') +\n join(['scalar', name, join(directives, ' ')], ' '),\n },\n\n ObjectTypeDefinition: {\n leave: ({ description, name, interfaces, directives, fields }) =>\n wrap('', description, '\\n') +\n join(\n [\n 'type',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n FieldDefinition: {\n leave: ({ description, name, arguments: args, type, directives }) =>\n wrap('', description, '\\n') +\n name +\n (hasMultilineItems(args)\n ? wrap('(\\n', indent(join(args, '\\n')), '\\n)')\n : wrap('(', join(args, ', '), ')')) +\n ': ' +\n type +\n wrap(' ', join(directives, ' ')),\n },\n\n InputValueDefinition: {\n leave: ({ description, name, type, defaultValue, directives }) =>\n wrap('', description, '\\n') +\n join(\n [name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')],\n ' ',\n ),\n },\n\n InterfaceTypeDefinition: {\n leave: ({ description, name, interfaces, directives, fields }) =>\n wrap('', description, '\\n') +\n join(\n [\n 'interface',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n UnionTypeDefinition: {\n leave: ({ description, name, directives, types }) =>\n wrap('', description, '\\n') +\n join(\n ['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))],\n ' ',\n ),\n },\n\n EnumTypeDefinition: {\n leave: ({ description, name, directives, values }) =>\n wrap('', description, '\\n') +\n join(['enum', name, join(directives, ' '), block(values)], ' '),\n },\n\n EnumValueDefinition: {\n leave: ({ description, name, directives }) =>\n wrap('', description, '\\n') + join([name, join(directives, ' ')], ' '),\n },\n\n InputObjectTypeDefinition: {\n leave: ({ description, name, directives, fields }) =>\n wrap('', description, '\\n') +\n join(['input', name, join(directives, ' '), block(fields)], ' '),\n },\n\n DirectiveDefinition: {\n leave: ({ description, name, arguments: args, repeatable, locations }) =>\n wrap('', description, '\\n') +\n 'directive @' +\n name +\n (hasMultilineItems(args)\n ? wrap('(\\n', indent(join(args, '\\n')), '\\n)')\n : wrap('(', join(args, ', '), ')')) +\n (repeatable ? ' repeatable' : '') +\n ' on ' +\n join(locations, ' | '),\n },\n\n SchemaExtension: {\n leave: ({ directives, operationTypes }) =>\n join(\n ['extend schema', join(directives, ' '), block(operationTypes)],\n ' ',\n ),\n },\n\n ScalarTypeExtension: {\n leave: ({ name, directives }) =>\n join(['extend scalar', name, join(directives, ' ')], ' '),\n },\n\n ObjectTypeExtension: {\n leave: ({ name, interfaces, directives, fields }) =>\n join(\n [\n 'extend type',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n InterfaceTypeExtension: {\n leave: ({ name, interfaces, directives, fields }) =>\n join(\n [\n 'extend interface',\n name,\n wrap('implements ', join(interfaces, ' & ')),\n join(directives, ' '),\n block(fields),\n ],\n ' ',\n ),\n },\n\n UnionTypeExtension: {\n leave: ({ name, directives, types }) =>\n join(\n [\n 'extend union',\n name,\n join(directives, ' '),\n wrap('= ', join(types, ' | ')),\n ],\n ' ',\n ),\n },\n\n EnumTypeExtension: {\n leave: ({ name, directives, values }) =>\n join(['extend enum', name, join(directives, ' '), block(values)], ' '),\n },\n\n InputObjectTypeExtension: {\n leave: ({ name, directives, fields }) =>\n join(['extend input', name, join(directives, ' '), block(fields)], ' '),\n },\n};\n\n/**\n * Given maybeArray, print an empty string if it is null or empty, otherwise\n * print all items together separated by separator if provided\n */\nfunction join(\n maybeArray: Maybe>,\n separator = '',\n): string {\n return maybeArray?.filter((x) => x).join(separator) ?? '';\n}\n\n/**\n * Given array, print each item on its own line, wrapped in an indented `{ }` block.\n */\nfunction block(array: Maybe>): string {\n return wrap('{\\n', indent(join(array, '\\n')), '\\n}');\n}\n\n/**\n * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.\n */\nfunction wrap(\n start: string,\n maybeString: Maybe,\n end: string = '',\n): string {\n return maybeString != null && maybeString !== ''\n ? start + maybeString + end\n : '';\n}\n\nfunction indent(str: string): string {\n return wrap(' ', str.replaceAll('\\n', '\\n '));\n}\n\nfunction hasMultilineItems(maybeArray: Maybe>): boolean {\n return maybeArray?.some((str) => str.includes('\\n')) ?? false;\n}\n\nfunction wrappedLineAndArgs(\n prefix: string,\n args: ReadonlyArray | undefined,\n): string {\n let argsLine = prefix + wrap('(', join(args, ', '), ')');\n\n if (argsLine.length > MAX_LINE_LENGTH) {\n argsLine = prefix + wrap('(\\n', indent(join(args, '\\n')), '\\n)');\n }\n return argsLine;\n}\n"]} \ No newline at end of file diff --git a/language/source.d.ts b/language/source.d.ts new file mode 100644 index 0000000000..763c4dc563 --- /dev/null +++ b/language/source.d.ts @@ -0,0 +1,25 @@ +interface Location { + line: number; + column: number; +} +/** + * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are + * optional, but they are useful for clients who store GraphQL documents in source files. + * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might + * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`. + * The `line` and `column` properties in `locationOffset` are 1-indexed. + */ +export declare class Source { + body: string; + name: string; + locationOffset: Location; + constructor(body: string, name?: string, locationOffset?: Location); + get [Symbol.toStringTag](): string; +} +/** + * Test if the given value is a Source object. + * + * @internal + */ +export declare function isSource(source: unknown): source is Source; +export {}; diff --git a/language/source.js b/language/source.js new file mode 100644 index 0000000000..93a24dd93b --- /dev/null +++ b/language/source.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Source = void 0; +exports.isSource = isSource; +const devAssert_js_1 = require("../jsutils/devAssert.js"); +const instanceOf_js_1 = require("../jsutils/instanceOf.js"); +/** + * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are + * optional, but they are useful for clients who store GraphQL documents in source files. + * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might + * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`. + * The `line` and `column` properties in `locationOffset` are 1-indexed. + */ +class Source { + constructor(body, name = 'GraphQL request', locationOffset = { line: 1, column: 1 }) { + this.body = body; + this.name = name; + this.locationOffset = locationOffset; + (this.locationOffset.line > 0) || (0, devAssert_js_1.devAssert)(false, 'line in locationOffset is 1-indexed and must be positive.'); + (this.locationOffset.column > 0) || (0, devAssert_js_1.devAssert)(false, 'column in locationOffset is 1-indexed and must be positive.'); + } + get [Symbol.toStringTag]() { + return 'Source'; + } +} +exports.Source = Source; +/** + * Test if the given value is a Source object. + * + * @internal + */ +function isSource(source) { + return (0, instanceOf_js_1.instanceOf)(source, Source); +} +//# sourceMappingURL=source.js.map \ No newline at end of file diff --git a/language/source.js.map b/language/source.js.map new file mode 100644 index 0000000000..b404c65446 --- /dev/null +++ b/language/source.js.map @@ -0,0 +1 @@ +{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/language/source.ts"],"names":[],"mappings":";;;AAgDA,4BAEC;AAlDD,0DAAoD;AACpD,4DAAsD;AAOtD;;;;;;GAMG;AACH,MAAa,MAAM;IAKjB,YACE,IAAY,EACZ,OAAe,iBAAiB,EAChC,iBAA2B,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QAEjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,CACE,IAAI,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,SAD9B,wBAAS,SAEP,2DAA2D,EAC3D;QACF,CACE,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,SADhC,wBAAS,SAEP,6DAA6D,EAC7D;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA1BD,wBA0BC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,MAAe;IACtC,OAAO,IAAA,0BAAU,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\n\ninterface Location {\n line: number;\n column: number;\n}\n\n/**\n * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are\n * optional, but they are useful for clients who store GraphQL documents in source files.\n * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might\n * be useful for `name` to be `\"Foo.graphql\"` and location to be `{ line: 40, column: 1 }`.\n * The `line` and `column` properties in `locationOffset` are 1-indexed.\n */\nexport class Source {\n body: string;\n name: string;\n locationOffset: Location;\n\n constructor(\n body: string,\n name: string = 'GraphQL request',\n locationOffset: Location = { line: 1, column: 1 },\n ) {\n this.body = body;\n this.name = name;\n this.locationOffset = locationOffset;\n devAssert(\n this.locationOffset.line > 0,\n 'line in locationOffset is 1-indexed and must be positive.',\n );\n devAssert(\n this.locationOffset.column > 0,\n 'column in locationOffset is 1-indexed and must be positive.',\n );\n }\n\n get [Symbol.toStringTag]() {\n return 'Source';\n }\n}\n\n/**\n * Test if the given value is a Source object.\n *\n * @internal\n */\nexport function isSource(source: unknown): source is Source {\n return instanceOf(source, Source);\n}\n"]} \ No newline at end of file diff --git a/language/source.mjs b/language/source.mjs new file mode 100644 index 0000000000..0fda1b3eee --- /dev/null +++ b/language/source.mjs @@ -0,0 +1,30 @@ +import { devAssert } from "../jsutils/devAssert.mjs"; +import { instanceOf } from "../jsutils/instanceOf.mjs"; +/** + * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are + * optional, but they are useful for clients who store GraphQL documents in source files. + * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might + * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`. + * The `line` and `column` properties in `locationOffset` are 1-indexed. + */ +export class Source { + constructor(body, name = 'GraphQL request', locationOffset = { line: 1, column: 1 }) { + this.body = body; + this.name = name; + this.locationOffset = locationOffset; + (this.locationOffset.line > 0) || devAssert(false, 'line in locationOffset is 1-indexed and must be positive.'); + (this.locationOffset.column > 0) || devAssert(false, 'column in locationOffset is 1-indexed and must be positive.'); + } + get [Symbol.toStringTag]() { + return 'Source'; + } +} +/** + * Test if the given value is a Source object. + * + * @internal + */ +export function isSource(source) { + return instanceOf(source, Source); +} +//# sourceMappingURL=source.js.map \ No newline at end of file diff --git a/language/source.mjs.map b/language/source.mjs.map new file mode 100644 index 0000000000..460e0b0448 --- /dev/null +++ b/language/source.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/language/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,UAAU,EAAE,kCAAiC;AAOtD;;;;;;GAMG;AACH,MAAM,OAAO,MAAM;IAKjB,YACE,IAAY,EACZ,OAAe,iBAAiB,EAChC,iBAA2B,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QAEjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,CACE,IAAI,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,KAD9B,SAAS,QAEP,2DAA2D,EAC3D;QACF,CACE,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,KADhC,SAAS,QAEP,6DAA6D,EAC7D;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAe;IACtC,OAAO,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\n\ninterface Location {\n line: number;\n column: number;\n}\n\n/**\n * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are\n * optional, but they are useful for clients who store GraphQL documents in source files.\n * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might\n * be useful for `name` to be `\"Foo.graphql\"` and location to be `{ line: 40, column: 1 }`.\n * The `line` and `column` properties in `locationOffset` are 1-indexed.\n */\nexport class Source {\n body: string;\n name: string;\n locationOffset: Location;\n\n constructor(\n body: string,\n name: string = 'GraphQL request',\n locationOffset: Location = { line: 1, column: 1 },\n ) {\n this.body = body;\n this.name = name;\n this.locationOffset = locationOffset;\n devAssert(\n this.locationOffset.line > 0,\n 'line in locationOffset is 1-indexed and must be positive.',\n );\n devAssert(\n this.locationOffset.column > 0,\n 'column in locationOffset is 1-indexed and must be positive.',\n );\n }\n\n get [Symbol.toStringTag]() {\n return 'Source';\n }\n}\n\n/**\n * Test if the given value is a Source object.\n *\n * @internal\n */\nexport function isSource(source: unknown): source is Source {\n return instanceOf(source, Source);\n}\n"]} \ No newline at end of file diff --git a/language/tokenKind.d.ts b/language/tokenKind.d.ts new file mode 100644 index 0000000000..418b6401b4 --- /dev/null +++ b/language/tokenKind.d.ts @@ -0,0 +1,29 @@ +/** + * An exported enum describing the different kinds of tokens that the + * lexer emits. + */ +export declare const TokenKind: { + readonly SOF: ""; + readonly EOF: ""; + readonly BANG: "!"; + readonly DOLLAR: "$"; + readonly AMP: "&"; + readonly PAREN_L: "("; + readonly PAREN_R: ")"; + readonly SPREAD: "..."; + readonly COLON: ":"; + readonly EQUALS: "="; + readonly AT: "@"; + readonly BRACKET_L: "["; + readonly BRACKET_R: "]"; + readonly BRACE_L: "{"; + readonly PIPE: "|"; + readonly BRACE_R: "}"; + readonly NAME: "Name"; + readonly INT: "Int"; + readonly FLOAT: "Float"; + readonly STRING: "String"; + readonly BLOCK_STRING: "BlockString"; + readonly COMMENT: "Comment"; +}; +export type TokenKind = (typeof TokenKind)[keyof typeof TokenKind]; diff --git a/language/tokenKind.js b/language/tokenKind.js new file mode 100644 index 0000000000..130b0f209d --- /dev/null +++ b/language/tokenKind.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TokenKind = void 0; +/** + * An exported enum describing the different kinds of tokens that the + * lexer emits. + */ +exports.TokenKind = { + SOF: '', + EOF: '', + BANG: '!', + DOLLAR: '$', + AMP: '&', + PAREN_L: '(', + PAREN_R: ')', + SPREAD: '...', + COLON: ':', + EQUALS: '=', + AT: '@', + BRACKET_L: '[', + BRACKET_R: ']', + BRACE_L: '{', + PIPE: '|', + BRACE_R: '}', + NAME: 'Name', + INT: 'Int', + FLOAT: 'Float', + STRING: 'String', + BLOCK_STRING: 'BlockString', + COMMENT: 'Comment', +}; +//# sourceMappingURL=tokenKind.js.map \ No newline at end of file diff --git a/language/tokenKind.js.map b/language/tokenKind.js.map new file mode 100644 index 0000000000..f935aff8d1 --- /dev/null +++ b/language/tokenKind.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tokenKind.js","sourceRoot":"","sources":["../../src/language/tokenKind.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,SAAS,GAAG;IACvB,GAAG,EAAE,OAAgB;IACrB,GAAG,EAAE,OAAgB;IACrB,IAAI,EAAE,GAAY;IAClB,MAAM,EAAE,GAAY;IACpB,GAAG,EAAE,GAAY;IACjB,OAAO,EAAE,GAAY;IACrB,OAAO,EAAE,GAAY;IACrB,MAAM,EAAE,KAAc;IACtB,KAAK,EAAE,GAAY;IACnB,MAAM,EAAE,GAAY;IACpB,EAAE,EAAE,GAAY;IAChB,SAAS,EAAE,GAAY;IACvB,SAAS,EAAE,GAAY;IACvB,OAAO,EAAE,GAAY;IACrB,IAAI,EAAE,GAAY;IAClB,OAAO,EAAE,GAAY;IACrB,IAAI,EAAE,MAAe;IACrB,GAAG,EAAE,KAAc;IACnB,KAAK,EAAE,OAAgB;IACvB,MAAM,EAAE,QAAiB;IACzB,YAAY,EAAE,aAAsB;IACpC,OAAO,EAAE,SAAkB;CACnB,CAAC","sourcesContent":["/**\n * An exported enum describing the different kinds of tokens that the\n * lexer emits.\n */\nexport const TokenKind = {\n SOF: '' as const,\n EOF: '' as const,\n BANG: '!' as const,\n DOLLAR: '$' as const,\n AMP: '&' as const,\n PAREN_L: '(' as const,\n PAREN_R: ')' as const,\n SPREAD: '...' as const,\n COLON: ':' as const,\n EQUALS: '=' as const,\n AT: '@' as const,\n BRACKET_L: '[' as const,\n BRACKET_R: ']' as const,\n BRACE_L: '{' as const,\n PIPE: '|' as const,\n BRACE_R: '}' as const,\n NAME: 'Name' as const,\n INT: 'Int' as const,\n FLOAT: 'Float' as const,\n STRING: 'String' as const,\n BLOCK_STRING: 'BlockString' as const,\n COMMENT: 'Comment' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type TokenKind = (typeof TokenKind)[keyof typeof TokenKind];\n"]} \ No newline at end of file diff --git a/language/tokenKind.mjs b/language/tokenKind.mjs new file mode 100644 index 0000000000..2fc9e59180 --- /dev/null +++ b/language/tokenKind.mjs @@ -0,0 +1,29 @@ +/** + * An exported enum describing the different kinds of tokens that the + * lexer emits. + */ +export const TokenKind = { + SOF: '', + EOF: '', + BANG: '!', + DOLLAR: '$', + AMP: '&', + PAREN_L: '(', + PAREN_R: ')', + SPREAD: '...', + COLON: ':', + EQUALS: '=', + AT: '@', + BRACKET_L: '[', + BRACKET_R: ']', + BRACE_L: '{', + PIPE: '|', + BRACE_R: '}', + NAME: 'Name', + INT: 'Int', + FLOAT: 'Float', + STRING: 'String', + BLOCK_STRING: 'BlockString', + COMMENT: 'Comment', +}; +//# sourceMappingURL=tokenKind.js.map \ No newline at end of file diff --git a/language/tokenKind.mjs.map b/language/tokenKind.mjs.map new file mode 100644 index 0000000000..9b27eb8a95 --- /dev/null +++ b/language/tokenKind.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"tokenKind.js","sourceRoot":"","sources":["../../src/language/tokenKind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,OAAgB;IACrB,GAAG,EAAE,OAAgB;IACrB,IAAI,EAAE,GAAY;IAClB,MAAM,EAAE,GAAY;IACpB,GAAG,EAAE,GAAY;IACjB,OAAO,EAAE,GAAY;IACrB,OAAO,EAAE,GAAY;IACrB,MAAM,EAAE,KAAc;IACtB,KAAK,EAAE,GAAY;IACnB,MAAM,EAAE,GAAY;IACpB,EAAE,EAAE,GAAY;IAChB,SAAS,EAAE,GAAY;IACvB,SAAS,EAAE,GAAY;IACvB,OAAO,EAAE,GAAY;IACrB,IAAI,EAAE,GAAY;IAClB,OAAO,EAAE,GAAY;IACrB,IAAI,EAAE,MAAe;IACrB,GAAG,EAAE,KAAc;IACnB,KAAK,EAAE,OAAgB;IACvB,MAAM,EAAE,QAAiB;IACzB,YAAY,EAAE,aAAsB;IACpC,OAAO,EAAE,SAAkB;CACnB,CAAC","sourcesContent":["/**\n * An exported enum describing the different kinds of tokens that the\n * lexer emits.\n */\nexport const TokenKind = {\n SOF: '' as const,\n EOF: '' as const,\n BANG: '!' as const,\n DOLLAR: '$' as const,\n AMP: '&' as const,\n PAREN_L: '(' as const,\n PAREN_R: ')' as const,\n SPREAD: '...' as const,\n COLON: ':' as const,\n EQUALS: '=' as const,\n AT: '@' as const,\n BRACKET_L: '[' as const,\n BRACKET_R: ']' as const,\n BRACE_L: '{' as const,\n PIPE: '|' as const,\n BRACE_R: '}' as const,\n NAME: 'Name' as const,\n INT: 'Int' as const,\n FLOAT: 'Float' as const,\n STRING: 'String' as const,\n BLOCK_STRING: 'BlockString' as const,\n COMMENT: 'Comment' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type TokenKind = (typeof TokenKind)[keyof typeof TokenKind];\n"]} \ No newline at end of file diff --git a/language/visitor.d.ts b/language/visitor.d.ts new file mode 100644 index 0000000000..e3e576279e --- /dev/null +++ b/language/visitor.d.ts @@ -0,0 +1,160 @@ +import type { ASTNode } from './ast.js'; +import { Kind } from './kinds.js'; +/** + * A visitor is provided to visit, it contains the collection of + * relevant functions to be called during the visitor's traversal. + */ +export type ASTVisitor = EnterLeaveVisitor | KindVisitor; +type KindVisitor = { + readonly [NodeT in ASTNode as NodeT['kind']]?: ASTVisitFn | EnterLeaveVisitor; +}; +interface EnterLeaveVisitor { + readonly enter?: ASTVisitFn | undefined; + readonly leave?: ASTVisitFn | undefined; +} +/** + * A visitor is comprised of visit functions, which are called on each node + * during the visitor's traversal. + */ +export type ASTVisitFn = ( +/** The current node being visiting. */ +node: TVisitedNode, +/** The index or key to this node from the parent node or Array. */ +key: string | number | undefined, +/** The parent immediately above this node, which may be an Array. */ +parent: ASTNode | ReadonlyArray | undefined, +/** The key path to get to this node from the root node. */ +path: ReadonlyArray, +/** + * All nodes and Arrays visited before reaching parent of this node. + * These correspond to array indices in `path`. + * Note: ancestors includes arrays which contain the parent of visited node. + */ +ancestors: ReadonlyArray>) => any; +/** + * A reducer is comprised of reducer functions which convert AST nodes into + * another form. + */ +export type ASTReducer = { + readonly [NodeT in ASTNode as NodeT['kind']]?: { + readonly enter?: ASTVisitFn; + readonly leave: ASTReducerFn; + }; +}; +type ASTReducerFn = ( +/** The current node being visiting. */ +node: { + [K in keyof TReducedNode]: ReducedField; +}, +/** The index or key to this node from the parent node or Array. */ +key: string | number | undefined, +/** The parent immediately above this node, which may be an Array. */ +parent: ASTNode | ReadonlyArray | undefined, +/** The key path to get to this node from the root node. */ +path: ReadonlyArray, +/** + * All nodes and Arrays visited before reaching parent of this node. + * These correspond to array indices in `path`. + * Note: ancestors includes arrays which contain the parent of visited node. + */ +ancestors: ReadonlyArray>) => R; +type ReducedField = T extends ASTNode ? R : T extends ReadonlyArray ? ReadonlyArray : T; +/** + * A KeyMap describes each the traversable properties of each kind of node. + */ +export type ASTVisitorKeyMap = { + [NodeT in ASTNode as NodeT['kind']]?: ReadonlyArray; +}; +export declare const BREAK: unknown; +/** + * visit() will walk through an AST using a depth-first traversal, calling + * the visitor's enter function at each node in the traversal, and calling the + * leave function after visiting that node and all of its child nodes. + * + * By returning different values from the enter and leave functions, the + * behavior of the visitor can be altered, including skipping over a sub-tree of + * the AST (by returning false), editing the AST by returning a value or null + * to remove the value, or to stop the whole traversal by returning BREAK. + * + * When using visit() to edit an AST, the original AST will not be modified, and + * a new version of the AST with the changes applied will be returned from the + * visit function. + * + * ```ts + * const editedAST = visit(ast, { + * enter(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: skip visiting this node + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * }, + * leave(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: no action + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * } + * }); + * ``` + * + * Alternatively to providing enter() and leave() functions, a visitor can + * instead provide functions named the same as the kinds of AST nodes, or + * enter/leave visitors at a named key, leading to three permutations of the + * visitor API: + * + * 1) Named visitors triggered when entering a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind(node) { + * // enter the "Kind" node + * } + * }) + * ``` + * + * 2) Named visitors that trigger upon entering and leaving a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind: { + * enter(node) { + * // enter the "Kind" node + * } + * leave(node) { + * // leave the "Kind" node + * } + * } + * }) + * ``` + * + * 3) Generic visitors that trigger upon entering and leaving any node. + * + * ```ts + * visit(ast, { + * enter(node) { + * // enter any node + * }, + * leave(node) { + * // leave any node + * } + * }) + * ``` + */ +export declare function visit(root: N, visitor: ASTVisitor, visitorKeys?: ASTVisitorKeyMap): N; +export declare function visit(root: ASTNode, visitor: ASTReducer, visitorKeys?: ASTVisitorKeyMap): R; +/** + * Creates a new visitor instance which delegates to many visitors to run in + * parallel. Each visitor will be visited for each node before moving on. + * + * If a prior visitor edits a node, no following visitors will see that node. + */ +export declare function visitInParallel(visitors: ReadonlyArray): ASTVisitor; +/** + * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind. + */ +export declare function getEnterLeaveForKind(visitor: ASTVisitor, kind: Kind): EnterLeaveVisitor; +export {}; diff --git a/language/visitor.js b/language/visitor.js new file mode 100644 index 0000000000..398c3abc6e --- /dev/null +++ b/language/visitor.js @@ -0,0 +1,204 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BREAK = void 0; +exports.visit = visit; +exports.visitInParallel = visitInParallel; +exports.getEnterLeaveForKind = getEnterLeaveForKind; +const devAssert_js_1 = require("../jsutils/devAssert.js"); +const inspect_js_1 = require("../jsutils/inspect.js"); +const ast_js_1 = require("./ast.js"); +const kinds_js_1 = require("./kinds.js"); +exports.BREAK = Object.freeze({}); +function visit(root, visitor, visitorKeys = ast_js_1.QueryDocumentKeys) { + const enterLeaveMap = new Map(); + for (const kind of Object.values(kinds_js_1.Kind)) { + enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); + } + /* eslint-disable no-undef-init */ + let stack = undefined; + let inArray = Array.isArray(root); + let keys = [root]; + let index = -1; + let edits = []; + let node = root; + let key = undefined; + let parent = undefined; + const path = []; + const ancestors = []; + /* eslint-enable no-undef-init */ + do { + index++; + const isLeaving = index === keys.length; + const isEdited = isLeaving && edits.length !== 0; + if (isLeaving) { + key = ancestors.length === 0 ? undefined : path[path.length - 1]; + node = parent; + parent = ancestors.pop(); + if (isEdited) { + if (inArray) { + node = node.slice(); + let editOffset = 0; + for (const [editKey, editValue] of edits) { + const arrayKey = editKey - editOffset; + if (editValue === null) { + node.splice(arrayKey, 1); + editOffset++; + } + else { + node[arrayKey] = editValue; + } + } + } + else { + node = Object.defineProperties({}, Object.getOwnPropertyDescriptors(node)); + for (const [editKey, editValue] of edits) { + node[editKey] = editValue; + } + } + } + index = stack.index; + keys = stack.keys; + edits = stack.edits; + inArray = stack.inArray; + stack = stack.prev; + } + else if (parent != null) { + key = inArray ? index : keys[index]; + node = parent[key]; + if (node === null || node === undefined) { + continue; + } + path.push(key); + } + let result; + if (!Array.isArray(node)) { + ((0, ast_js_1.isNode)(node)) || (0, devAssert_js_1.devAssert)(false, `Invalid AST Node: ${(0, inspect_js_1.inspect)(node)}.`); + const visitFn = isLeaving + ? enterLeaveMap.get(node.kind)?.leave + : enterLeaveMap.get(node.kind)?.enter; + result = visitFn?.call(visitor, node, key, parent, path, ancestors); + if (result === exports.BREAK) { + break; + } + if (result === false) { + if (!isLeaving) { + path.pop(); + continue; + } + } + else if (result !== undefined) { + edits.push([key, result]); + if (!isLeaving) { + if ((0, ast_js_1.isNode)(result)) { + node = result; + } + else { + path.pop(); + continue; + } + } + } + } + if (result === undefined && isEdited) { + edits.push([key, node]); + } + if (isLeaving) { + path.pop(); + } + else { + stack = { inArray, index, keys, edits, prev: stack }; + inArray = Array.isArray(node); + keys = inArray ? node : (visitorKeys[node.kind] ?? []); + index = -1; + edits = []; + if (parent != null) { + ancestors.push(parent); + } + parent = node; + } + } while (stack !== undefined); + if (edits.length !== 0) { + // New root + return edits.at(-1)[1]; + } + return root; +} +/** + * Creates a new visitor instance which delegates to many visitors to run in + * parallel. Each visitor will be visited for each node before moving on. + * + * If a prior visitor edits a node, no following visitors will see that node. + */ +function visitInParallel(visitors) { + const skipping = new Array(visitors.length).fill(null); + const mergedVisitor = Object.create(null); + for (const kind of Object.values(kinds_js_1.Kind)) { + let hasVisitor = false; + const enterList = new Array(visitors.length).fill(undefined); + const leaveList = new Array(visitors.length).fill(undefined); + for (let i = 0; i < visitors.length; ++i) { + const { enter, leave } = getEnterLeaveForKind(visitors[i], kind); + hasVisitor ||= enter != null || leave != null; + enterList[i] = enter; + leaveList[i] = leave; + } + if (!hasVisitor) { + continue; + } + const mergedEnterLeave = { + enter(...args) { + const node = args[0]; + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + const result = enterList[i]?.apply(visitors[i], args); + if (result === false) { + skipping[i] = node; + } + else if (result === exports.BREAK) { + skipping[i] = exports.BREAK; + } + else if (result !== undefined) { + return result; + } + } + } + }, + leave(...args) { + const node = args[0]; + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + const result = leaveList[i]?.apply(visitors[i], args); + if (result === exports.BREAK) { + skipping[i] = exports.BREAK; + } + else if (result !== undefined && result !== false) { + return result; + } + } + else if (skipping[i] === node) { + skipping[i] = null; + } + } + }, + }; + mergedVisitor[kind] = mergedEnterLeave; + } + return mergedVisitor; +} +/** + * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind. + */ +function getEnterLeaveForKind(visitor, kind) { + const kindVisitor = visitor[kind]; + if (typeof kindVisitor === 'object') { + // { Kind: { enter() {}, leave() {} } } + return kindVisitor; + } + else if (typeof kindVisitor === 'function') { + // { Kind() {} } + return { enter: kindVisitor, leave: undefined }; + } + // { enter() {}, leave() {} } + return { enter: visitor.enter, leave: visitor.leave }; +} +//# sourceMappingURL=visitor.js.map \ No newline at end of file diff --git a/language/visitor.js.map b/language/visitor.js.map new file mode 100644 index 0000000000..88d8d02957 --- /dev/null +++ b/language/visitor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"visitor.js","sourceRoot":"","sources":["../../src/language/visitor.ts"],"names":[],"mappings":";;;AAgLA,sBA8HC;AAQD,0CA2DC;AAKD,oDAmBC;AAzYD,0DAAoD;AACpD,sDAAgD;AAGhD,qCAAqD;AACrD,yCAAkC;AAiFrB,QAAA,KAAK,GAAY,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AA0FhD,SAAgB,KAAK,CACnB,IAAa,EACb,OAAqC,EACrC,cAAgC,0BAAiB;IAEjD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoC,CAAC;IAClE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,eAAI,CAAC,EAAE,CAAC;QACvC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,kCAAkC;IAClC,IAAI,KAAK,GAAQ,SAAS,CAAC;IAC3B,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,GAAQ,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,IAAI,GAAQ,IAAI,CAAC;IACrB,IAAI,GAAG,GAAQ,SAAS,CAAC;IACzB,IAAI,MAAM,GAAQ,SAAS,CAAC;IAC5B,MAAM,IAAI,GAAQ,EAAE,CAAC;IACrB,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,iCAAiC;IAEjC,GAAG,CAAC;QACF,KAAK,EAAE,CAAC;QACR,MAAM,SAAS,GAAG,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC;Q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;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;QAEF,aAAa,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACzC,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAClC,OAAmB,EACnB,IAAU;IAEV,MAAM,WAAW,GAGA,OAAe,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,uCAAuC;QACvC,OAAO,WAAW,CAAC;IACrB,CAAC;SAAM,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QAC7C,gBAAgB;QAChB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAClD,CAAC;IAED,6BAA6B;IAC7B,OAAO,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { inspect } from '../jsutils/inspect.js';\n\nimport type { ASTNode } from './ast.js';\nimport { isNode, QueryDocumentKeys } from './ast.js';\nimport { Kind } from './kinds.js';\n\n/**\n * A visitor is provided to visit, it contains the collection of\n * relevant functions to be called during the visitor's traversal.\n */\nexport type ASTVisitor = EnterLeaveVisitor | KindVisitor;\n\ntype KindVisitor = {\n readonly [NodeT in ASTNode as NodeT['kind']]?:\n | ASTVisitFn\n | EnterLeaveVisitor;\n};\n\ninterface EnterLeaveVisitor {\n readonly enter?: ASTVisitFn | undefined;\n readonly leave?: ASTVisitFn | undefined;\n}\n\n/**\n * A visitor is comprised of visit functions, which are called on each node\n * during the visitor's traversal.\n */\nexport type ASTVisitFn = (\n /** The current node being visiting. */\n node: TVisitedNode,\n /** The index or key to this node from the parent node or Array. */\n key: string | number | undefined,\n /** The parent immediately above this node, which may be an Array. */\n parent: ASTNode | ReadonlyArray | undefined,\n /** The key path to get to this node from the root node. */\n path: ReadonlyArray,\n /**\n * All nodes and Arrays visited before reaching parent of this node.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays which contain the parent of visited node.\n */\n ancestors: ReadonlyArray>,\n) => any;\n\n/**\n * A reducer is comprised of reducer functions which convert AST nodes into\n * another form.\n */\nexport type ASTReducer = {\n readonly [NodeT in ASTNode as NodeT['kind']]?: {\n readonly enter?: ASTVisitFn;\n readonly leave: ASTReducerFn;\n };\n};\n\ntype ASTReducerFn = (\n /** The current node being visiting. */\n node: { [K in keyof TReducedNode]: ReducedField },\n /** The index or key to this node from the parent node or Array. */\n key: string | number | undefined,\n /** The parent immediately above this node, which may be an Array. */\n parent: ASTNode | ReadonlyArray | undefined,\n /** The key path to get to this node from the root node. */\n path: ReadonlyArray,\n /**\n * All nodes and Arrays visited before reaching parent of this node.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays which contain the parent of visited node.\n */\n ancestors: ReadonlyArray>,\n) => R;\n\ntype ReducedField = T extends ASTNode\n ? R\n : T extends ReadonlyArray\n ? ReadonlyArray\n : T;\n\n/**\n * A KeyMap describes each the traversable properties of each kind of node.\n */\nexport type ASTVisitorKeyMap = {\n [NodeT in ASTNode as NodeT['kind']]?: ReadonlyArray;\n};\n\nexport const BREAK: unknown = Object.freeze({});\n\n/**\n * visit() will walk through an AST using a depth-first traversal, calling\n * the visitor's enter function at each node in the traversal, and calling the\n * leave function after visiting that node and all of its child nodes.\n *\n * By returning different values from the enter and leave functions, the\n * behavior of the visitor can be altered, including skipping over a sub-tree of\n * the AST (by returning false), editing the AST by returning a value or null\n * to remove the value, or to stop the whole traversal by returning BREAK.\n *\n * When using visit() to edit an AST, the original AST will not be modified, and\n * a new version of the AST with the changes applied will be returned from the\n * visit function.\n *\n * ```ts\n * const editedAST = visit(ast, {\n * enter(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: skip visiting this node\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * },\n * leave(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: no action\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * }\n * });\n * ```\n *\n * Alternatively to providing enter() and leave() functions, a visitor can\n * instead provide functions named the same as the kinds of AST nodes, or\n * enter/leave visitors at a named key, leading to three permutations of the\n * visitor API:\n *\n * 1) Named visitors triggered when entering a node of a specific kind.\n *\n * ```ts\n * visit(ast, {\n * Kind(node) {\n * // enter the \"Kind\" node\n * }\n * })\n * ```\n *\n * 2) Named visitors that trigger upon entering and leaving a node of a specific kind.\n *\n * ```ts\n * visit(ast, {\n * Kind: {\n * enter(node) {\n * // enter the \"Kind\" node\n * }\n * leave(node) {\n * // leave the \"Kind\" node\n * }\n * }\n * })\n * ```\n *\n * 3) Generic visitors that trigger upon entering and leaving any node.\n *\n * ```ts\n * visit(ast, {\n * enter(node) {\n * // enter any node\n * },\n * leave(node) {\n * // leave any node\n * }\n * })\n * ```\n */\nexport function visit(\n root: N,\n visitor: ASTVisitor,\n visitorKeys?: ASTVisitorKeyMap,\n): N;\nexport function visit(\n root: ASTNode,\n visitor: ASTReducer,\n visitorKeys?: ASTVisitorKeyMap,\n): R;\nexport function visit(\n root: ASTNode,\n visitor: ASTVisitor | ASTReducer,\n visitorKeys: ASTVisitorKeyMap = QueryDocumentKeys,\n): any {\n const enterLeaveMap = new Map>();\n for (const kind of Object.values(Kind)) {\n enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));\n }\n\n /* eslint-disable no-undef-init */\n let stack: any = undefined;\n let inArray = Array.isArray(root);\n let keys: any = [root];\n let index = -1;\n let edits = [];\n let node: any = root;\n let key: any = undefined;\n let parent: any = undefined;\n const path: any = [];\n const ancestors = [];\n /* eslint-enable no-undef-init */\n\n do {\n index++;\n const isLeaving = index === keys.length;\n const isEdited = isLeaving && edits.length !== 0;\n if (isLeaving) {\n key = ancestors.length === 0 ? undefined : path[path.length - 1];\n node = parent;\n parent = ancestors.pop();\n if (isEdited) {\n if (inArray) {\n node = node.slice();\n\n let editOffset = 0;\n for (const [editKey, editValue] of edits) {\n const arrayKey = editKey - editOffset;\n if (editValue === null) {\n node.splice(arrayKey, 1);\n editOffset++;\n } else {\n node[arrayKey] = editValue;\n }\n }\n } else {\n node = Object.defineProperties(\n {},\n Object.getOwnPropertyDescriptors(node),\n );\n for (const [editKey, editValue] of edits) {\n node[editKey] = editValue;\n }\n }\n }\n index = stack.index;\n keys = stack.keys;\n edits = stack.edits;\n inArray = stack.inArray;\n stack = stack.prev;\n } else if (parent != null) {\n key = inArray ? index : keys[index];\n node = parent[key];\n if (node === null || node === undefined) {\n continue;\n }\n path.push(key);\n }\n\n let result;\n if (!Array.isArray(node)) {\n devAssert(isNode(node), `Invalid AST Node: ${inspect(node)}.`);\n\n const visitFn = isLeaving\n ? enterLeaveMap.get(node.kind)?.leave\n : enterLeaveMap.get(node.kind)?.enter;\n\n result = visitFn?.call(visitor, node, key, parent, path, ancestors);\n\n if (result === BREAK) {\n break;\n }\n\n if (result === false) {\n if (!isLeaving) {\n path.pop();\n continue;\n }\n } else if (result !== undefined) {\n edits.push([key, result]);\n if (!isLeaving) {\n if (isNode(result)) {\n node = result;\n } else {\n path.pop();\n continue;\n }\n }\n }\n }\n\n if (result === undefined && isEdited) {\n edits.push([key, node]);\n }\n\n if (isLeaving) {\n path.pop();\n } else {\n stack = { inArray, index, keys, edits, prev: stack };\n inArray = Array.isArray(node);\n keys = inArray ? node : ((visitorKeys as any)[node.kind] ?? []);\n index = -1;\n edits = [];\n if (parent != null) {\n ancestors.push(parent);\n }\n parent = node;\n }\n } while (stack !== undefined);\n\n if (edits.length !== 0) {\n // New root\n return edits.at(-1)[1];\n }\n\n return root;\n}\n\n/**\n * Creates a new visitor instance which delegates to many visitors to run in\n * parallel. Each visitor will be visited for each node before moving on.\n *\n * If a prior visitor edits a node, no following visitors will see that node.\n */\nexport function visitInParallel(\n visitors: ReadonlyArray,\n): ASTVisitor {\n const skipping = new Array(visitors.length).fill(null);\n const mergedVisitor = Object.create(null);\n\n for (const kind of Object.values(Kind)) {\n let hasVisitor = false;\n const enterList = new Array(visitors.length).fill(undefined);\n const leaveList = new Array(visitors.length).fill(undefined);\n\n for (let i = 0; i < visitors.length; ++i) {\n const { enter, leave } = getEnterLeaveForKind(visitors[i], kind);\n hasVisitor ||= enter != null || leave != null;\n enterList[i] = enter;\n leaveList[i] = leave;\n }\n\n if (!hasVisitor) {\n continue;\n }\n\n const mergedEnterLeave: EnterLeaveVisitor = {\n enter(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = enterList[i]?.apply(visitors[i], args);\n if (result === false) {\n skipping[i] = node;\n } else if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined) {\n return result;\n }\n }\n }\n },\n leave(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = leaveList[i]?.apply(visitors[i], args);\n if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined && result !== false) {\n return result;\n }\n } else if (skipping[i] === node) {\n skipping[i] = null;\n }\n }\n },\n };\n\n mergedVisitor[kind] = mergedEnterLeave;\n }\n\n return mergedVisitor;\n}\n\n/**\n * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.\n */\nexport function getEnterLeaveForKind(\n visitor: ASTVisitor,\n kind: Kind,\n): EnterLeaveVisitor {\n const kindVisitor:\n | ASTVisitFn\n | EnterLeaveVisitor\n | undefined = (visitor as any)[kind];\n\n if (typeof kindVisitor === 'object') {\n // { Kind: { enter() {}, leave() {} } }\n return kindVisitor;\n } else if (typeof kindVisitor === 'function') {\n // { Kind() {} }\n return { enter: kindVisitor, leave: undefined };\n }\n\n // { enter() {}, leave() {} }\n return { enter: (visitor as any).enter, leave: (visitor as any).leave };\n}\n"]} \ No newline at end of file diff --git a/language/visitor.mjs b/language/visitor.mjs new file mode 100644 index 0000000000..f509cb44f8 --- /dev/null +++ b/language/visitor.mjs @@ -0,0 +1,198 @@ +import { devAssert } from "../jsutils/devAssert.mjs"; +import { inspect } from "../jsutils/inspect.mjs"; +import { isNode, QueryDocumentKeys } from "./ast.mjs"; +import { Kind } from "./kinds.mjs"; +export const BREAK = Object.freeze({}); +export function visit(root, visitor, visitorKeys = QueryDocumentKeys) { + const enterLeaveMap = new Map(); + for (const kind of Object.values(Kind)) { + enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); + } + /* eslint-disable no-undef-init */ + let stack = undefined; + let inArray = Array.isArray(root); + let keys = [root]; + let index = -1; + let edits = []; + let node = root; + let key = undefined; + let parent = undefined; + const path = []; + const ancestors = []; + /* eslint-enable no-undef-init */ + do { + index++; + const isLeaving = index === keys.length; + const isEdited = isLeaving && edits.length !== 0; + if (isLeaving) { + key = ancestors.length === 0 ? undefined : path[path.length - 1]; + node = parent; + parent = ancestors.pop(); + if (isEdited) { + if (inArray) { + node = node.slice(); + let editOffset = 0; + for (const [editKey, editValue] of edits) { + const arrayKey = editKey - editOffset; + if (editValue === null) { + node.splice(arrayKey, 1); + editOffset++; + } + else { + node[arrayKey] = editValue; + } + } + } + else { + node = Object.defineProperties({}, Object.getOwnPropertyDescriptors(node)); + for (const [editKey, editValue] of edits) { + node[editKey] = editValue; + } + } + } + index = stack.index; + keys = stack.keys; + edits = stack.edits; + inArray = stack.inArray; + stack = stack.prev; + } + else if (parent != null) { + key = inArray ? index : keys[index]; + node = parent[key]; + if (node === null || node === undefined) { + continue; + } + path.push(key); + } + let result; + if (!Array.isArray(node)) { + (isNode(node)) || devAssert(false, `Invalid AST Node: ${inspect(node)}.`); + const visitFn = isLeaving + ? enterLeaveMap.get(node.kind)?.leave + : enterLeaveMap.get(node.kind)?.enter; + result = visitFn?.call(visitor, node, key, parent, path, ancestors); + if (result === BREAK) { + break; + } + if (result === false) { + if (!isLeaving) { + path.pop(); + continue; + } + } + else if (result !== undefined) { + edits.push([key, result]); + if (!isLeaving) { + if (isNode(result)) { + node = result; + } + else { + path.pop(); + continue; + } + } + } + } + if (result === undefined && isEdited) { + edits.push([key, node]); + } + if (isLeaving) { + path.pop(); + } + else { + stack = { inArray, index, keys, edits, prev: stack }; + inArray = Array.isArray(node); + keys = inArray ? node : (visitorKeys[node.kind] ?? []); + index = -1; + edits = []; + if (parent != null) { + ancestors.push(parent); + } + parent = node; + } + } while (stack !== undefined); + if (edits.length !== 0) { + // New root + return edits.at(-1)[1]; + } + return root; +} +/** + * Creates a new visitor instance which delegates to many visitors to run in + * parallel. Each visitor will be visited for each node before moving on. + * + * If a prior visitor edits a node, no following visitors will see that node. + */ +export function visitInParallel(visitors) { + const skipping = new Array(visitors.length).fill(null); + const mergedVisitor = Object.create(null); + for (const kind of Object.values(Kind)) { + let hasVisitor = false; + const enterList = new Array(visitors.length).fill(undefined); + const leaveList = new Array(visitors.length).fill(undefined); + for (let i = 0; i < visitors.length; ++i) { + const { enter, leave } = getEnterLeaveForKind(visitors[i], kind); + hasVisitor ||= enter != null || leave != null; + enterList[i] = enter; + leaveList[i] = leave; + } + if (!hasVisitor) { + continue; + } + const mergedEnterLeave = { + enter(...args) { + const node = args[0]; + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + const result = enterList[i]?.apply(visitors[i], args); + if (result === false) { + skipping[i] = node; + } + else if (result === BREAK) { + skipping[i] = BREAK; + } + else if (result !== undefined) { + return result; + } + } + } + }, + leave(...args) { + const node = args[0]; + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + const result = leaveList[i]?.apply(visitors[i], args); + if (result === BREAK) { + skipping[i] = BREAK; + } + else if (result !== undefined && result !== false) { + return result; + } + } + else if (skipping[i] === node) { + skipping[i] = null; + } + } + }, + }; + mergedVisitor[kind] = mergedEnterLeave; + } + return mergedVisitor; +} +/** + * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind. + */ +export function getEnterLeaveForKind(visitor, kind) { + const kindVisitor = visitor[kind]; + if (typeof kindVisitor === 'object') { + // { Kind: { enter() {}, leave() {} } } + return kindVisitor; + } + else if (typeof kindVisitor === 'function') { + // { Kind() {} } + return { enter: kindVisitor, leave: undefined }; + } + // { enter() {}, leave() {} } + return { enter: visitor.enter, leave: visitor.leave }; +} +//# sourceMappingURL=visitor.js.map \ No newline at end of file diff --git a/language/visitor.mjs.map b/language/visitor.mjs.map new file mode 100644 index 0000000000..ac315a895c --- /dev/null +++ b/language/visitor.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"visitor.js","sourceRoot":"","sources":["../../src/language/visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAGhD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAiB;AACrD,OAAO,EAAE,IAAI,EAAE,oBAAmB;AAiFlC,MAAM,CAAC,MAAM,KAAK,GAAY,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AA0FhD,MAAM,UAAU,KAAK,CACnB,IAAa,EACb,OAAqC,EACrC,cAAgC,iBAAiB;IAEjD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoC,CAAC;IAClE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,kCAAkC;IAClC,IAAI,KAAK,GAAQ,SAAS,CAAC;IAC3B,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,GAAQ,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,IAAI,GAAQ,IAAI,CAAC;IACrB,IAAI,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B,CAAC;6BAAM,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;4BACpD,OAAO,MAAM,CAAC;wBAChB,CAAC;oBACH,CAAC;yBAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;wBAChC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;QAEF,aAAa,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACzC,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAmB,EACnB,IAAU;IAEV,MAAM,WAAW,GAGA,OAAe,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,uCAAuC;QACvC,OAAO,WAAW,CAAC;IACrB,CAAC;SAAM,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QAC7C,gBAAgB;QAChB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAClD,CAAC;IAED,6BAA6B;IAC7B,OAAO,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { inspect } from '../jsutils/inspect.js';\n\nimport type { ASTNode } from './ast.js';\nimport { isNode, QueryDocumentKeys } from './ast.js';\nimport { Kind } from './kinds.js';\n\n/**\n * A visitor is provided to visit, it contains the collection of\n * relevant functions to be called during the visitor's traversal.\n */\nexport type ASTVisitor = EnterLeaveVisitor | KindVisitor;\n\ntype KindVisitor = {\n readonly [NodeT in ASTNode as NodeT['kind']]?:\n | ASTVisitFn\n | EnterLeaveVisitor;\n};\n\ninterface EnterLeaveVisitor {\n readonly enter?: ASTVisitFn | undefined;\n readonly leave?: ASTVisitFn | undefined;\n}\n\n/**\n * A visitor is comprised of visit functions, which are called on each node\n * during the visitor's traversal.\n */\nexport type ASTVisitFn = (\n /** The current node being visiting. */\n node: TVisitedNode,\n /** The index or key to this node from the parent node or Array. */\n key: string | number | undefined,\n /** The parent immediately above this node, which may be an Array. */\n parent: ASTNode | ReadonlyArray | undefined,\n /** The key path to get to this node from the root node. */\n path: ReadonlyArray,\n /**\n * All nodes and Arrays visited before reaching parent of this node.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays which contain the parent of visited node.\n */\n ancestors: ReadonlyArray>,\n) => any;\n\n/**\n * A reducer is comprised of reducer functions which convert AST nodes into\n * another form.\n */\nexport type ASTReducer = {\n readonly [NodeT in ASTNode as NodeT['kind']]?: {\n readonly enter?: ASTVisitFn;\n readonly leave: ASTReducerFn;\n };\n};\n\ntype ASTReducerFn = (\n /** The current node being visiting. */\n node: { [K in keyof TReducedNode]: ReducedField },\n /** The index or key to this node from the parent node or Array. */\n key: string | number | undefined,\n /** The parent immediately above this node, which may be an Array. */\n parent: ASTNode | ReadonlyArray | undefined,\n /** The key path to get to this node from the root node. */\n path: ReadonlyArray,\n /**\n * All nodes and Arrays visited before reaching parent of this node.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays which contain the parent of visited node.\n */\n ancestors: ReadonlyArray>,\n) => R;\n\ntype ReducedField = T extends ASTNode\n ? R\n : T extends ReadonlyArray\n ? ReadonlyArray\n : T;\n\n/**\n * A KeyMap describes each the traversable properties of each kind of node.\n */\nexport type ASTVisitorKeyMap = {\n [NodeT in ASTNode as NodeT['kind']]?: ReadonlyArray;\n};\n\nexport const BREAK: unknown = Object.freeze({});\n\n/**\n * visit() will walk through an AST using a depth-first traversal, calling\n * the visitor's enter function at each node in the traversal, and calling the\n * leave function after visiting that node and all of its child nodes.\n *\n * By returning different values from the enter and leave functions, the\n * behavior of the visitor can be altered, including skipping over a sub-tree of\n * the AST (by returning false), editing the AST by returning a value or null\n * to remove the value, or to stop the whole traversal by returning BREAK.\n *\n * When using visit() to edit an AST, the original AST will not be modified, and\n * a new version of the AST with the changes applied will be returned from the\n * visit function.\n *\n * ```ts\n * const editedAST = visit(ast, {\n * enter(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: skip visiting this node\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * },\n * leave(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: no action\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * }\n * });\n * ```\n *\n * Alternatively to providing enter() and leave() functions, a visitor can\n * instead provide functions named the same as the kinds of AST nodes, or\n * enter/leave visitors at a named key, leading to three permutations of the\n * visitor API:\n *\n * 1) Named visitors triggered when entering a node of a specific kind.\n *\n * ```ts\n * visit(ast, {\n * Kind(node) {\n * // enter the \"Kind\" node\n * }\n * })\n * ```\n *\n * 2) Named visitors that trigger upon entering and leaving a node of a specific kind.\n *\n * ```ts\n * visit(ast, {\n * Kind: {\n * enter(node) {\n * // enter the \"Kind\" node\n * }\n * leave(node) {\n * // leave the \"Kind\" node\n * }\n * }\n * })\n * ```\n *\n * 3) Generic visitors that trigger upon entering and leaving any node.\n *\n * ```ts\n * visit(ast, {\n * enter(node) {\n * // enter any node\n * },\n * leave(node) {\n * // leave any node\n * }\n * })\n * ```\n */\nexport function visit(\n root: N,\n visitor: ASTVisitor,\n visitorKeys?: ASTVisitorKeyMap,\n): N;\nexport function visit(\n root: ASTNode,\n visitor: ASTReducer,\n visitorKeys?: ASTVisitorKeyMap,\n): R;\nexport function visit(\n root: ASTNode,\n visitor: ASTVisitor | ASTReducer,\n visitorKeys: ASTVisitorKeyMap = QueryDocumentKeys,\n): any {\n const enterLeaveMap = new Map>();\n for (const kind of Object.values(Kind)) {\n enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));\n }\n\n /* eslint-disable no-undef-init */\n let stack: any = undefined;\n let inArray = Array.isArray(root);\n let keys: any = [root];\n let index = -1;\n let edits = [];\n let node: any = root;\n let key: any = undefined;\n let parent: any = undefined;\n const path: any = [];\n const ancestors = [];\n /* eslint-enable no-undef-init */\n\n do {\n index++;\n const isLeaving = index === keys.length;\n const isEdited = isLeaving && edits.length !== 0;\n if (isLeaving) {\n key = ancestors.length === 0 ? undefined : path[path.length - 1];\n node = parent;\n parent = ancestors.pop();\n if (isEdited) {\n if (inArray) {\n node = node.slice();\n\n let editOffset = 0;\n for (const [editKey, editValue] of edits) {\n const arrayKey = editKey - editOffset;\n if (editValue === null) {\n node.splice(arrayKey, 1);\n editOffset++;\n } else {\n node[arrayKey] = editValue;\n }\n }\n } else {\n node = Object.defineProperties(\n {},\n Object.getOwnPropertyDescriptors(node),\n );\n for (const [editKey, editValue] of edits) {\n node[editKey] = editValue;\n }\n }\n }\n index = stack.index;\n keys = stack.keys;\n edits = stack.edits;\n inArray = stack.inArray;\n stack = stack.prev;\n } else if (parent != null) {\n key = inArray ? index : keys[index];\n node = parent[key];\n if (node === null || node === undefined) {\n continue;\n }\n path.push(key);\n }\n\n let result;\n if (!Array.isArray(node)) {\n devAssert(isNode(node), `Invalid AST Node: ${inspect(node)}.`);\n\n const visitFn = isLeaving\n ? enterLeaveMap.get(node.kind)?.leave\n : enterLeaveMap.get(node.kind)?.enter;\n\n result = visitFn?.call(visitor, node, key, parent, path, ancestors);\n\n if (result === BREAK) {\n break;\n }\n\n if (result === false) {\n if (!isLeaving) {\n path.pop();\n continue;\n }\n } else if (result !== undefined) {\n edits.push([key, result]);\n if (!isLeaving) {\n if (isNode(result)) {\n node = result;\n } else {\n path.pop();\n continue;\n }\n }\n }\n }\n\n if (result === undefined && isEdited) {\n edits.push([key, node]);\n }\n\n if (isLeaving) {\n path.pop();\n } else {\n stack = { inArray, index, keys, edits, prev: stack };\n inArray = Array.isArray(node);\n keys = inArray ? node : ((visitorKeys as any)[node.kind] ?? []);\n index = -1;\n edits = [];\n if (parent != null) {\n ancestors.push(parent);\n }\n parent = node;\n }\n } while (stack !== undefined);\n\n if (edits.length !== 0) {\n // New root\n return edits.at(-1)[1];\n }\n\n return root;\n}\n\n/**\n * Creates a new visitor instance which delegates to many visitors to run in\n * parallel. Each visitor will be visited for each node before moving on.\n *\n * If a prior visitor edits a node, no following visitors will see that node.\n */\nexport function visitInParallel(\n visitors: ReadonlyArray,\n): ASTVisitor {\n const skipping = new Array(visitors.length).fill(null);\n const mergedVisitor = Object.create(null);\n\n for (const kind of Object.values(Kind)) {\n let hasVisitor = false;\n const enterList = new Array(visitors.length).fill(undefined);\n const leaveList = new Array(visitors.length).fill(undefined);\n\n for (let i = 0; i < visitors.length; ++i) {\n const { enter, leave } = getEnterLeaveForKind(visitors[i], kind);\n hasVisitor ||= enter != null || leave != null;\n enterList[i] = enter;\n leaveList[i] = leave;\n }\n\n if (!hasVisitor) {\n continue;\n }\n\n const mergedEnterLeave: EnterLeaveVisitor = {\n enter(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = enterList[i]?.apply(visitors[i], args);\n if (result === false) {\n skipping[i] = node;\n } else if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined) {\n return result;\n }\n }\n }\n },\n leave(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = leaveList[i]?.apply(visitors[i], args);\n if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined && result !== false) {\n return result;\n }\n } else if (skipping[i] === node) {\n skipping[i] = null;\n }\n }\n },\n };\n\n mergedVisitor[kind] = mergedEnterLeave;\n }\n\n return mergedVisitor;\n}\n\n/**\n * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.\n */\nexport function getEnterLeaveForKind(\n visitor: ASTVisitor,\n kind: Kind,\n): EnterLeaveVisitor {\n const kindVisitor:\n | ASTVisitFn\n | EnterLeaveVisitor\n | undefined = (visitor as any)[kind];\n\n if (typeof kindVisitor === 'object') {\n // { Kind: { enter() {}, leave() {} } }\n return kindVisitor;\n } else if (typeof kindVisitor === 'function') {\n // { Kind() {} }\n return { enter: kindVisitor, leave: undefined };\n }\n\n // { enter() {}, leave() {} }\n return { enter: (visitor as any).enter, leave: (visitor as any).leave };\n}\n"]} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 7b95d6249d..0000000000 --- a/package-lock.json +++ /dev/null @@ -1,11838 +0,0 @@ -{ - "name": "graphql", - "version": "16.11.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "graphql", - "version": "16.11.0", - "license": "MIT", - "devDependencies": { - "@babel/core": "7.17.9", - "@babel/plugin-syntax-typescript": "7.16.7", - "@babel/plugin-transform-typescript": "7.16.8", - "@babel/preset-env": "7.16.11", - "@babel/register": "7.17.7", - "@types/chai": "4.3.1", - "@types/mocha": "9.1.0", - "@types/node": "17.0.24", - "@typescript-eslint/eslint-plugin": "5.19.0", - "@typescript-eslint/parser": "5.19.0", - "c8": "7.11.0", - "chai": "4.3.6", - "cspell": "5.19.7", - "eslint": "8.13.0", - "eslint-plugin-import": "2.26.0", - "eslint-plugin-internal-rules": "file:./resources/eslint-internal-rules", - "eslint-plugin-node": "11.1.0", - "eslint-plugin-react": "7.29.4", - "eslint-plugin-react-hooks": "4.4.0", - "eslint-plugin-simple-import-sort": "7.0.0", - "eslint-plugin-tsdoc": "0.2.16", - "mocha": "9.2.2", - "prettier": "2.6.2", - "typescript": "4.6.3" - }, - "engines": { - "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" - } - }, - "node_modules/@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", - "dev": true, - "dependencies": { - "@jridgewell/trace-mapping": "^0.3.0" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, - "dependencies": { - "@babel/highlight": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.7.tgz", - "integrity": "sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.9.tgz", - "integrity": "sha512-5ug+SfZCpDAkVp9SFIZAzlW18rlzsOcJGaetCjkySnrXXDUw9AR8cDUm1iByTmdWM6yxX6/zycaV76w3YTF2gw==", - "dev": true, - "dependencies": { - "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", - "@babel/helper-compilation-targets": "^7.17.7", - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helpers": "^7.17.9", - "@babel/parser": "^7.17.9", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.9", - "@babel/types": "^7.17.0", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.1", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/generator": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.9.tgz", - "integrity": "sha512-rAdDousTwxbIxbz5I7GEQ3lUip+xVCXooZNbsydCWs3xA7ZsYOv+CFRdzGxRX78BmQHu9B1Eso59AOZQOJDEdQ==", - "dev": true, - "dependencies": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-annotate-as-pure": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz", - "integrity": "sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-builder-binary-assignment-operator-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz", - "integrity": "sha512-C6FdbRaxYjwVu/geKW4ZeQ0Q31AftgRcdSnZ5/jsH6BzCJbtvXvhpfkbkThYSuutZA7nCXpPR6AD9zd1dprMkA==", - "dev": true, - "dependencies": { - "@babel/helper-explode-assignable-expression": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.7.tgz", - "integrity": "sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.17.7", - "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.17.9.tgz", - "integrity": "sha512-kUjip3gruz6AJKOq5i3nC6CoCEEF/oHH3cp6tOZhB+IyyyPyW0g1Gfsxn3mkk6S08pIA2y8GQh609v9G/5sHVQ==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.17.9", - "@babel/helper-member-expression-to-functions": "^7.17.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-create-regexp-features-plugin": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.17.0.tgz", - "integrity": "sha512-awO2So99wG6KnlE+TPs6rn83gCz5WlEePJDTnLEqbchMVrBeAujURVphRdigsk094VhvZehFoNOihSlcBjwsXA==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "regexpu-core": "^5.0.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-define-polyfill-provider": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.1.tgz", - "integrity": "sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA==", - "dev": true, - "dependencies": { - "@babel/helper-compilation-targets": "^7.13.0", - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-plugin-utils": "^7.13.0", - "@babel/traverse": "^7.13.0", - "debug": "^4.1.1", - "lodash.debounce": "^4.0.8", - "resolve": "^1.14.2", - "semver": "^6.1.2" - }, - "peerDependencies": { - "@babel/core": "^7.4.0-0" - } - }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-explode-assignable-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.7.tgz", - "integrity": "sha512-KyUenhWMC8VrxzkGP0Jizjo4/Zx+1nNZhgocs+gLzyZyB8SHidhoq9KK/8Ato4anhwsivfkBLftky7gvzbZMtQ==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz", - "integrity": "sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg==", - "dev": true, - "dependencies": { - "@babel/template": "^7.16.7", - "@babel/types": "^7.17.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.17.7.tgz", - "integrity": "sha512-thxXgnQ8qQ11W2wVUObIqDL4p148VMxkt5T/qpN5k2fboRyzFGFmKsTGViquyM5QHKUy48OZoca8kw4ajaDPyw==", - "dev": true, - "dependencies": { - "@babel/types": "^7.17.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz", - "integrity": "sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz", - "integrity": "sha512-VmZD99F3gNTYB7fJRDTi+u6l/zxY0BE6OIxPSU7a50s6ZUQkHwSDmV92FfM+oCG0pZRVojGYhkR8I0OGeCVREw==", - "dev": true, - "dependencies": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-simple-access": "^7.17.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-optimise-call-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz", - "integrity": "sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-plugin-utils": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz", - "integrity": "sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-remap-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.8.tgz", - "integrity": "sha512-fm0gH7Flb8H51LqJHy3HJ3wnE1+qtYR2A99K06ahwrawLdOFsCEWjZOrYricXJHoPSudNKxrMBUPEIPxiIIvBw==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-wrap-function": "^7.16.8", - "@babel/types": "^7.16.8" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-replace-supers": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz", - "integrity": "sha512-y9vsWilTNaVnVh6xiJfABzsNpgDPKev9HnAgz6Gb1p6UUwf9NepdlsV7VXGCftJM+jqD5f7JIEubcpLjZj5dBw==", - "dev": true, - "dependencies": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-member-expression-to-functions": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/traverse": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz", - "integrity": "sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.17.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz", - "integrity": "sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz", - "integrity": "sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-wrap-function": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.16.8.tgz", - "integrity": "sha512-8RpyRVIAW1RcDDGTA+GpPAwV22wXCfKOoM9bet6TLkGIFTkRQSkH1nMQ5Yet4MpoXe1ZwHPVtNasc2w0uZMqnw==", - "dev": true, - "dependencies": { - "@babel/helper-function-name": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.16.8", - "@babel/types": "^7.16.8" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.9.tgz", - "integrity": "sha512-cPCt915ShDWUEzEp3+UNRktO2n6v49l5RSnG9M5pS24hA+2FAc5si+Pn1i4VVbQQ+jh+bIZhPFQOJOzbrOYY1Q==", - "dev": true, - "dependencies": { - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.9", - "@babel/types": "^7.17.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.9.tgz", - "integrity": "sha512-J9PfEKCbFIv2X5bjTMiZu6Vf341N05QIY+d6FvVKynkG1S7G0j3I0QoRtWIrXhZ+/Nlb5Q0MzqL7TokEJ5BNHg==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.9.tgz", - "integrity": "sha512-vqUSBLP8dQHFPdPi9bc5GK9vRkYHJ49fsZdtoJ8EQ8ibpwk5rPKfvNIwChB0KVXcIjcepEBBd2VHC5r9Gy8ueg==", - "dev": true, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz", - "integrity": "sha512-anv/DObl7waiGEnC24O9zqL0pSuI9hljihqiDuFHC8d7/bjr/4RLGPWuc8rYOff/QPzbEPSkzG8wGG9aDuhHRg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.7.tgz", - "integrity": "sha512-di8vUHRdf+4aJ7ltXhaDbPoszdkh59AQtJM5soLsuHpQJdFQZOA4uGj0V2u/CZ8bJ/u8ULDL5yq6FO/bCXnKHw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", - "@babel/plugin-proposal-optional-chaining": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.13.0" - } - }, - "node_modules/@babel/plugin-proposal-async-generator-functions": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz", - "integrity": "sha512-71YHIvMuiuqWJQkebWJtdhQTfd4Q4mF76q2IX37uZPkG9+olBxsX+rH1vkhFto4UeJZ9dPY2s+mDvhDm1u2BGQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8", - "@babel/plugin-syntax-async-generators": "^7.8.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-class-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz", - "integrity": "sha512-IobU0Xme31ewjYOShSIqd/ZGM/r/cuOz2z0MDbNrhF5FW+ZVgi0f2lyeoj9KFPDOAqsYxmLWZte1WOwlvY9aww==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-class-static-block": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.17.6.tgz", - "integrity": "sha512-X/tididvL2zbs7jZCeeRJ8167U/+Ac135AM6jCAx6gYXDUviZV5Ku9UDvWS2NCuWlFjIRXklYhwo6HhAC7ETnA==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.17.6", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-class-static-block": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.12.0" - } - }, - "node_modules/@babel/plugin-proposal-dynamic-import": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.16.7.tgz", - "integrity": "sha512-I8SW9Ho3/8DRSdmDdH3gORdyUuYnk1m4cMxUAdu5oy4n3OfN8flDEH+d60iG7dUfi0KkYwSvoalHzzdRzpWHTg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-dynamic-import": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-export-namespace-from": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.16.7.tgz", - "integrity": "sha512-ZxdtqDXLRGBL64ocZcs7ovt71L3jhC1RGSyR996svrCi3PYqHNkb3SwPJCs8RIzD86s+WPpt2S73+EHCGO+NUA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-json-strings": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.7.tgz", - "integrity": "sha512-lNZ3EEggsGY78JavgbHsK9u5P3pQaW7k4axlgFLYkMd7UBsiNahCITShLjNQschPyjtO6dADrL24757IdhBrsQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-json-strings": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-logical-assignment-operators": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.16.7.tgz", - "integrity": "sha512-K3XzyZJGQCr00+EtYtrDjmwX7o7PLK6U9bi1nCwkQioRFVUv6dJoxbQjtWVtP+bCPy82bONBKG8NPyQ4+i6yjg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.16.7.tgz", - "integrity": "sha512-aUOrYU3EVtjf62jQrCj63pYZ7k6vns2h/DQvHPWGmsJRYzWXZ6/AsfgpiRy6XiuIDADhJzP2Q9MwSMKauBQ+UQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-numeric-separator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.16.7.tgz", - "integrity": "sha512-vQgPMknOIgiuVqbokToyXbkY/OmmjAzr/0lhSIbG/KmnzXPGwW/AdhdKpi+O4X/VkWiWjnkKOBiqJrTaC98VKw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-numeric-separator": "^7.10.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-object-rest-spread": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.17.3.tgz", - "integrity": "sha512-yuL5iQA/TbZn+RGAfxQXfi7CNLmKi1f8zInn4IgobuCWcAb7i+zj4TYzQ9l8cEzVyJ89PDGuqxK1xZpUDISesw==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.17.0", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-optional-catch-binding": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.7.tgz", - "integrity": "sha512-eMOH/L4OvWSZAE1VkHbr1vckLG1WUcHGJSLqqQwl2GaUqG6QjddvrOaTUMNYiv77H5IKPMZ9U9P7EaHwvAShfA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.7.tgz", - "integrity": "sha512-eC3xy+ZrUcBtP7x+sq62Q/HYd674pPTb/77XZMb5wbDPGWIdUbSr4Agr052+zaUPSb+gGRnjxXfKFvx5iMJ+DA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", - "@babel/plugin-syntax-optional-chaining": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-private-methods": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz", - "integrity": "sha512-F/2uAkPlXDr8+BHpZvo19w3hLFKge+k75XUprE6jaqKxjGkSYcK+4c+bup5PdW/7W/Rpjwql7FTVEDW+fRAQsw==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.16.10", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.7.tgz", - "integrity": "sha512-rMQkjcOFbm+ufe3bTZLyOfsOUOxyvLXZJCTARhJr+8UMSoZmqTe1K1BgkFcrW37rAchWg57yI69ORxiWvUINuQ==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-unicode-property-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.16.7.tgz", - "integrity": "sha512-QRK0YI/40VLhNVGIjRNAAQkEHws0cswSdFFjpFyt943YmJIU1da9uW63Iu6NFV6CxTZW5eTDCrwZUstBWgp/Rg==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-async-generators": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", - "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-class-properties": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", - "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.12.13" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-class-static-block": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", - "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-dynamic-import": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", - "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-export-namespace-from": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", - "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.3" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-json-strings": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", - "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-logical-assignment-operators": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", - "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", - "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-numeric-separator": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", - "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-object-rest-spread": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", - "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-catch-binding": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", - "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-chaining": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", - "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-private-property-in-object": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", - "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-top-level-await": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", - "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.16.7.tgz", - "integrity": "sha512-YhUIJHHGkqPgEcMYkPCKTyGUdoGKWtopIycQyjJH8OjvRgOYsXsaKehLVPScKJWAULPxMa4N1vCe6szREFlZ7A==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-arrow-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.7.tgz", - "integrity": "sha512-9ffkFFMbvzTvv+7dTp/66xvZAWASuPD5Tl9LK3Z9vhOmANo6j94rik+5YMBt4CwHVMWLWpMsriIc2zsa3WW3xQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.8.tgz", - "integrity": "sha512-MtmUmTJQHCnyJVrScNzNlofQJ3dLFuobYn3mwOTKHnSCMtbNsqvF71GQmJfFjdrXSsAA7iysFmYWw4bXZ20hOg==", - "dev": true, - "dependencies": { - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoped-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.7.tgz", - "integrity": "sha512-JUuzlzmF40Z9cXyytcbZEZKckgrQzChbQJw/5PuEHYeqzCsvebDx0K0jWnIIVcmmDOAVctCgnYs0pMcrYj2zJg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.16.7.tgz", - "integrity": "sha512-ObZev2nxVAYA4bhyusELdo9hb3H+A56bxH3FZMbEImZFiEDYVHXQSJ1hQKFlDnlt8G9bBrCZ5ZpURZUrV4G5qQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-classes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.16.7.tgz", - "integrity": "sha512-WY7og38SFAGYRe64BrjKf8OrE6ulEHtr5jEYaZMwox9KebgqPi67Zqz8K53EKk1fFEJgm96r32rkKZ3qA2nCWQ==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-computed-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.7.tgz", - "integrity": "sha512-gN72G9bcmenVILj//sv1zLNaPyYcOzUho2lIJBMh/iakJ9ygCo/hEF9cpGb61SCMEDxbbyBoVQxrt+bWKu5KGw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-destructuring": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.17.7.tgz", - "integrity": "sha512-XVh0r5yq9sLR4vZ6eVZe8FKfIcSgaTBxVBRSYokRj2qksf6QerYnTxz9/GTuKTH/n/HwLP7t6gtlybHetJ/6hQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-dotall-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.16.7.tgz", - "integrity": "sha512-Lyttaao2SjZF6Pf4vk1dVKv8YypMpomAbygW+mU5cYP3S5cWTfCJjG8xV6CFdzGFlfWK81IjL9viiTvpb6G7gQ==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-duplicate-keys": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.7.tgz", - "integrity": "sha512-03DvpbRfvWIXyK0/6QiR1KMTWeT6OcQ7tbhjrXyFS02kjuX/mu5Bvnh5SDSWHxyawit2g5aWhKwI86EE7GUnTw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-exponentiation-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.7.tgz", - "integrity": "sha512-8UYLSlyLgRixQvlYH3J2ekXFHDFLQutdy7FfFAMm3CPZ6q9wHCwnUyiXpQCe3gVVnQlHc5nsuiEVziteRNTXEA==", - "dev": true, - "dependencies": { - "@babel/helper-builder-binary-assignment-operator-visitor": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-for-of": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.16.7.tgz", - "integrity": "sha512-/QZm9W92Ptpw7sjI9Nx1mbcsWz33+l8kuMIQnDwgQBG5s3fAfQvkRjQ7NqXhtNcKOnPkdICmUHyCaWW06HCsqg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.16.7.tgz", - "integrity": "sha512-SU/C68YVwTRxqWj5kgsbKINakGag0KTgq9f2iZEXdStoAbOzLHEBRYzImmA6yFo8YZhJVflvXmIHUO7GWHmxxA==", - "dev": true, - "dependencies": { - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.7.tgz", - "integrity": "sha512-6tH8RTpTWI0s2sV6uq3e/C9wPo4PTqqZps4uF0kzQ9/xPLFQtipynvmT1g/dOfEJ+0EQsHhkQ/zyRId8J2b8zQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-member-expression-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.16.7.tgz", - "integrity": "sha512-mBruRMbktKQwbxaJof32LT9KLy2f3gH+27a5XSuXo6h7R3vqltl0PgZ80C8ZMKw98Bf8bqt6BEVi3svOh2PzMw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-amd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.7.tgz", - "integrity": "sha512-KaaEtgBL7FKYwjJ/teH63oAmE3lP34N3kshz8mm4VMAw7U3PxjVwwUmxEFksbgsNUaO3wId9R2AVQYSEGRa2+g==", - "dev": true, - "dependencies": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.17.9.tgz", - "integrity": "sha512-2TBFd/r2I6VlYn0YRTz2JdazS+FoUuQ2rIFHoAxtyP/0G3D82SBLaRq9rnUkpqlLg03Byfl/+M32mpxjO6KaPw==", - "dev": true, - "dependencies": { - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-simple-access": "^7.17.7", - "babel-plugin-dynamic-import-node": "^2.3.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.17.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.17.8.tgz", - "integrity": "sha512-39reIkMTUVagzgA5x88zDYXPCMT6lcaRKs1+S9K6NKBPErbgO/w/kP8GlNQTC87b412ZTlmNgr3k2JrWgHH+Bw==", - "dev": true, - "dependencies": { - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-umd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz", - "integrity": "sha512-EMh7uolsC8O4xhudF2F6wedbSHm1HHZ0C6aJ7K67zcDNidMzVcxWdGr+htW9n21klm+bOn+Rx4CBsAntZd3rEQ==", - "dev": true, - "dependencies": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.8.tgz", - "integrity": "sha512-j3Jw+n5PvpmhRR+mrgIh04puSANCk/T/UA3m3P1MjJkhlK906+ApHhDIqBQDdOgL/r1UYpz4GNclTXxyZrYGSw==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-new-target": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.7.tgz", - "integrity": "sha512-xiLDzWNMfKoGOpc6t3U+etCE2yRnn3SM09BXqWPIZOBpL2gvVrBWUKnsJx0K/ADi5F5YC5f8APFfWrz25TdlGg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-object-super": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.7.tgz", - "integrity": "sha512-14J1feiQVWaGvRxj2WjyMuXS2jsBkgB3MdSN5HuC2G5nRspa5RK9COcs82Pwy5BuGcjb+fYaUj94mYcOj7rCvw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-parameters": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.7.tgz", - "integrity": "sha512-AT3MufQ7zZEhU2hwOA11axBnExW0Lszu4RL/tAlUJBuNoRak+wehQW8h6KcXOcgjY42fHtDxswuMhMjFEuv/aw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-property-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.7.tgz", - "integrity": "sha512-z4FGr9NMGdoIl1RqavCqGG+ZuYjfZ/hkCIeuH6Do7tXmSm0ls11nYVSJqFEUOSJbDab5wC6lRE/w6YjVcr6Hqw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-regenerator": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.17.9.tgz", - "integrity": "sha512-Lc2TfbxR1HOyn/c6b4Y/b6NHoTb67n/IoWLxTu4kC7h4KQnWlhCq2S8Tx0t2SVvv5Uu87Hs+6JEJ5kt2tYGylQ==", - "dev": true, - "dependencies": { - "regenerator-transform": "^0.15.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-reserved-words": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.7.tgz", - "integrity": "sha512-KQzzDnZ9hWQBjwi5lpY5v9shmm6IVG0U9pB18zvMu2i4H90xpT4gmqwPYsn8rObiadYe2M0gmgsiOIF5A/2rtg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-shorthand-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz", - "integrity": "sha512-hah2+FEnoRoATdIb05IOXf+4GzXYTq75TVhIn1PewihbpyrNWUt2JbudKQOETWw6QpLe+AIUpJ5MVLYTQbeeUg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-spread": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.7.tgz", - "integrity": "sha512-+pjJpgAngb53L0iaA5gU/1MLXJIfXcYepLgXB3esVRf4fqmj8f2cxM3/FKaHsZms08hFQJkFccEWuIpm429TXg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-sticky-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.7.tgz", - "integrity": "sha512-NJa0Bd/87QV5NZZzTuZG5BPJjLYadeSZ9fO6oOUoL4iQx+9EEuw/eEM92SrsT19Yc2jgB1u1hsjqDtH02c3Drw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-template-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.16.7.tgz", - "integrity": "sha512-VwbkDDUeenlIjmfNeDX/V0aWrQH2QiVyJtwymVQSzItFDTpxfyJh3EVaQiS0rIN/CqbLGr0VcGmuwyTdZtdIsA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-typeof-symbol": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.7.tgz", - "integrity": "sha512-p2rOixCKRJzpg9JB4gjnG4gjWkWa89ZoYUnl9snJ1cWIcTH/hvxZqfO+WjG6T8DRBpctEol5jw1O5rA8gkCokQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-typescript": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.16.8.tgz", - "integrity": "sha512-bHdQ9k7YpBDO2d0NVfkj51DpQcvwIzIusJ7mEUaMlbZq3Kt/U47j24inXZHQ5MDiYpCs+oZiwnXyKedE8+q7AQ==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-typescript": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-escapes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.7.tgz", - "integrity": "sha512-TAV5IGahIz3yZ9/Hfv35TV2xEm+kaBDaZQCn2S/hG9/CZ0DktxJv9eKfPc7yYCvOYR4JGx1h8C+jcSOvgaaI/Q==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.7.tgz", - "integrity": "sha512-oC5tYYKw56HO75KZVLQ+R/Nl3Hro9kf8iG0hXoaHP7tjAyCpvqBiSNe6vGrZni1Z6MggmUOC6A7VP7AVmw225Q==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-env": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.16.11.tgz", - "integrity": "sha512-qcmWG8R7ZW6WBRPZK//y+E3Cli151B20W1Rv7ln27vuPaXU/8TKms6jFdiJtF7UDTxcrb7mZd88tAeK9LjdT8g==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.16.8", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-option": "^7.16.7", - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.7", - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-async-generator-functions": "^7.16.8", - "@babel/plugin-proposal-class-properties": "^7.16.7", - "@babel/plugin-proposal-class-static-block": "^7.16.7", - "@babel/plugin-proposal-dynamic-import": "^7.16.7", - "@babel/plugin-proposal-export-namespace-from": "^7.16.7", - "@babel/plugin-proposal-json-strings": "^7.16.7", - "@babel/plugin-proposal-logical-assignment-operators": "^7.16.7", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", - "@babel/plugin-proposal-numeric-separator": "^7.16.7", - "@babel/plugin-proposal-object-rest-spread": "^7.16.7", - "@babel/plugin-proposal-optional-catch-binding": "^7.16.7", - "@babel/plugin-proposal-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-private-methods": "^7.16.11", - "@babel/plugin-proposal-private-property-in-object": "^7.16.7", - "@babel/plugin-proposal-unicode-property-regex": "^7.16.7", - "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/plugin-syntax-class-properties": "^7.12.13", - "@babel/plugin-syntax-class-static-block": "^7.14.5", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3", - "@babel/plugin-syntax-json-strings": "^7.8.3", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-syntax-numeric-separator": "^7.10.4", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", - "@babel/plugin-syntax-optional-chaining": "^7.8.3", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5", - "@babel/plugin-syntax-top-level-await": "^7.14.5", - "@babel/plugin-transform-arrow-functions": "^7.16.7", - "@babel/plugin-transform-async-to-generator": "^7.16.8", - "@babel/plugin-transform-block-scoped-functions": "^7.16.7", - "@babel/plugin-transform-block-scoping": "^7.16.7", - "@babel/plugin-transform-classes": "^7.16.7", - "@babel/plugin-transform-computed-properties": "^7.16.7", - "@babel/plugin-transform-destructuring": "^7.16.7", - "@babel/plugin-transform-dotall-regex": "^7.16.7", - "@babel/plugin-transform-duplicate-keys": "^7.16.7", - "@babel/plugin-transform-exponentiation-operator": "^7.16.7", - "@babel/plugin-transform-for-of": "^7.16.7", - "@babel/plugin-transform-function-name": "^7.16.7", - "@babel/plugin-transform-literals": "^7.16.7", - "@babel/plugin-transform-member-expression-literals": "^7.16.7", - "@babel/plugin-transform-modules-amd": "^7.16.7", - "@babel/plugin-transform-modules-commonjs": "^7.16.8", - "@babel/plugin-transform-modules-systemjs": "^7.16.7", - "@babel/plugin-transform-modules-umd": "^7.16.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.8", - "@babel/plugin-transform-new-target": "^7.16.7", - "@babel/plugin-transform-object-super": "^7.16.7", - "@babel/plugin-transform-parameters": "^7.16.7", - "@babel/plugin-transform-property-literals": "^7.16.7", - "@babel/plugin-transform-regenerator": "^7.16.7", - "@babel/plugin-transform-reserved-words": "^7.16.7", - "@babel/plugin-transform-shorthand-properties": "^7.16.7", - "@babel/plugin-transform-spread": "^7.16.7", - "@babel/plugin-transform-sticky-regex": "^7.16.7", - "@babel/plugin-transform-template-literals": "^7.16.7", - "@babel/plugin-transform-typeof-symbol": "^7.16.7", - "@babel/plugin-transform-unicode-escapes": "^7.16.7", - "@babel/plugin-transform-unicode-regex": "^7.16.7", - "@babel/preset-modules": "^0.1.5", - "@babel/types": "^7.16.8", - "babel-plugin-polyfill-corejs2": "^0.3.0", - "babel-plugin-polyfill-corejs3": "^0.5.0", - "babel-plugin-polyfill-regenerator": "^0.3.0", - "core-js-compat": "^3.20.2", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-modules": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.5.tgz", - "integrity": "sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", - "@babel/plugin-transform-dotall-regex": "^7.4.4", - "@babel/types": "^7.4.4", - "esutils": "^2.0.2" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/register": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.17.7.tgz", - "integrity": "sha512-fg56SwvXRifootQEDQAu1mKdjh5uthPzdO0N6t358FktfL4XjAVXuH58ULoiW8mesxiOgNIrxiImqEwv0+hRRA==", - "dev": true, - "dependencies": { - "clone-deep": "^4.0.1", - "find-cache-dir": "^2.0.0", - "make-dir": "^2.1.0", - "pirates": "^4.0.5", - "source-map-support": "^0.5.16" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/runtime": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", - "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", - "dev": true, - "dependencies": { - "regenerator-runtime": "^0.13.4" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.9.tgz", - "integrity": "sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.17.9", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.9", - "@babel/types": "^7.17.0", - "debug": "^4.1.0", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@bcoe/v8-coverage": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", - "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", - "dev": true - }, - "node_modules/@cspell/cspell-bundled-dicts": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.19.7.tgz", - "integrity": "sha512-9h2KdI3yKODc8rAxkgB5UZb6RLwwEO25Fo91vnOtM1xfwLhX/scMACU1DoqtnTVaE73HoQ46DYAZAAq/OloRFQ==", - "dev": true, - "dependencies": { - "@cspell/dict-ada": "^2.0.0", - "@cspell/dict-aws": "^2.0.0", - "@cspell/dict-bash": "^2.0.2", - "@cspell/dict-companies": "^2.0.3", - "@cspell/dict-cpp": "^2.0.2", - "@cspell/dict-cryptocurrencies": "^2.0.0", - "@cspell/dict-csharp": "^2.0.1", - "@cspell/dict-css": "^2.0.0", - "@cspell/dict-dart": "^1.1.0", - "@cspell/dict-django": "^2.0.0", - "@cspell/dict-dotnet": "^2.0.1", - "@cspell/dict-elixir": "^2.0.1", - "@cspell/dict-en_us": "^2.2.0", - "@cspell/dict-en-gb": "^1.1.33", - "@cspell/dict-filetypes": "^2.0.1", - "@cspell/dict-fonts": "^2.0.0", - "@cspell/dict-fullstack": "^2.0.4", - "@cspell/dict-git": "^1.0.1", - "@cspell/dict-golang": "^2.0.0", - "@cspell/dict-haskell": "^2.0.0", - "@cspell/dict-html": "^3.0.1", - "@cspell/dict-html-symbol-entities": "^2.0.0", - "@cspell/dict-java": "^2.0.0", - "@cspell/dict-latex": "^2.0.0", - "@cspell/dict-lorem-ipsum": "^2.0.0", - "@cspell/dict-lua": "^2.0.0", - "@cspell/dict-node": "^2.0.0", - "@cspell/dict-npm": "^2.0.2", - "@cspell/dict-php": "^2.0.0", - "@cspell/dict-powershell": "^2.0.0", - "@cspell/dict-public-licenses": "^1.0.4", - "@cspell/dict-python": "^2.0.6", - "@cspell/dict-r": "^1.0.2", - "@cspell/dict-ruby": "^2.0.1", - "@cspell/dict-rust": "^2.0.0", - "@cspell/dict-scala": "^2.0.0", - "@cspell/dict-software-terms": "^2.1.4", - "@cspell/dict-swift": "^1.0.2", - "@cspell/dict-typescript": "^2.0.0", - "@cspell/dict-vue": "^2.0.2" - }, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/@cspell/cspell-pipe": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-5.19.7.tgz", - "integrity": "sha512-C2+qovrXyZtoM+IcyMuwwYieoGBwwnWORat+j7bkIkVHf6Pa9spxY3D1IdLt04PqWBKWKHb1g9KzJzw5grBqZw==", - "dev": true, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/@cspell/cspell-types": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-5.19.7.tgz", - "integrity": "sha512-xL9a0oE8kPQ/GCkE/bxE5DTCMTctCpk7tdrhYG26wVbMK1VRGo8fv9w+vRVzXgTfF5jTxolEA1LTtfVBuik1MA==", - "dev": true, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/@cspell/dict-ada": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-ada/-/dict-ada-2.0.0.tgz", - "integrity": "sha512-4gfJEYXVwz6IN2LBaT6QoUV4pqaR35i0z0u9O684vLuVczvNJIHa4vNaSEFBr9d6xxncUyqstgP9P73ajJjh9A==", - "dev": true - }, - "node_modules/@cspell/dict-aws": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-aws/-/dict-aws-2.0.0.tgz", - "integrity": "sha512-NKz7pDZ7pwj/b33i3f4WLpC1rOOUMmENwYgftxU+giU2YBeKM2wZbMTSEIzsrel56r0UlQYmdIVlP/B4nnVaoQ==", - "dev": true - }, - "node_modules/@cspell/dict-bash": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-bash/-/dict-bash-2.0.2.tgz", - "integrity": "sha512-ASIgI/LmV2TYrD4mtk+gm4XmUSTRomOyRt7NDWyBpEww/AeawC2O2NH6FosyUT6dUU3GaXt2wgJRN7R78n1SGg==", - "dev": true - }, - "node_modules/@cspell/dict-companies": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-2.0.3.tgz", - "integrity": "sha512-O622rMAaHm85AmqNyMki5je8HB/1XlTKbGOXh2UUhooI5qdgdfrjTQ6VBuHwHrfEfuODBHYTNYXVB2m23XqHCg==", - "dev": true - }, - "node_modules/@cspell/dict-cpp": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-cpp/-/dict-cpp-2.0.3.tgz", - "integrity": "sha512-aWRvI3CQW2M3XeJpDVffItw/9n4hxsN5EPwyBa6Po6EnCxZZZLOqpieZk4JNz4pH0/xbnOX+sMMuSeKWr71r/w==", - "dev": true - }, - "node_modules/@cspell/dict-cryptocurrencies": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-cryptocurrencies/-/dict-cryptocurrencies-2.0.0.tgz", - "integrity": "sha512-nREysmmfOp7L2YCRAUufQahwD5/Punzb5AZ6eyg4zUamdRWHgBFphb5/9h2flt1vgdUfhc6hZcML21Ci7iXjaA==", - "dev": true - }, - "node_modules/@cspell/dict-csharp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-csharp/-/dict-csharp-2.0.1.tgz", - "integrity": "sha512-ZzAr+WRP2FUtXHZtfhe8f3j9vPjH+5i44Hcr5JqbWxmqciGoTbWBPQXwu9y+J4mbdC69HSWRrVGkNJ8rQk8pSw==", - "dev": true - }, - "node_modules/@cspell/dict-css": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-css/-/dict-css-2.0.0.tgz", - "integrity": "sha512-MrFyswFHnPh4H0u6IlV4eHy+ZCUrrHzeL161LyTOqCvaKpbZavMgNYXzZqTF9xafO0iLgwKrl+Gkclu1KVBg0Q==", - "dev": true - }, - "node_modules/@cspell/dict-dart": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-dart/-/dict-dart-1.1.0.tgz", - "integrity": "sha512-bBqZINm+RVjMgUrAhRzv/xx3jc3dkIqO0higPbsK+63IAtMNY3EiQnEO4eapbU+qAhyvICY9hZQZXy5Ux4p+Pw==", - "dev": true - }, - "node_modules/@cspell/dict-django": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-django/-/dict-django-2.0.0.tgz", - "integrity": "sha512-GkJdJv6cmzrKcmq2/oxTXjKF5uv71r4eTqnFmgPbNBW1t+G4VYpzOf0QrVQrhx2RC4DdW5XfcTf+iS0FxHOTmw==", - "dev": true - }, - "node_modules/@cspell/dict-dotnet": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-dotnet/-/dict-dotnet-2.0.1.tgz", - "integrity": "sha512-b1n4crJRW0WZVf9Gp/52j/tDtjYiZ3N81fIyfqPlBrjsh/5AivfA697DYwQ2mr8ngNX7RsqRtYNQjealA1rEnQ==", - "dev": true - }, - "node_modules/@cspell/dict-elixir": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-elixir/-/dict-elixir-2.0.1.tgz", - "integrity": "sha512-eTTTxZt1FqGkM780yFDxsGHvTbWqvlK8YISSccK8FyrB6ULW+uflQlNS5AnWg3uWKC48b7pQott+odYCsPJ+Ow==", - "dev": true - }, - "node_modules/@cspell/dict-en_us": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-en_us/-/dict-en_us-2.2.0.tgz", - "integrity": "sha512-IJWu8MI2NdLyPzekrMi9K+v71b0qjDE+z/BccoMA/APnphqgSNM8BDUAzhio6mPKi1AvPRCNUjk79oiUfp+1Gw==", - "dev": true - }, - "node_modules/@cspell/dict-en-gb": { - "version": "1.1.33", - "resolved": "https://registry.npmjs.org/@cspell/dict-en-gb/-/dict-en-gb-1.1.33.tgz", - "integrity": "sha512-tKSSUf9BJEV+GJQAYGw5e+ouhEe2ZXE620S7BLKe3ZmpnjlNG9JqlnaBhkIMxKnNFkLY2BP/EARzw31AZnOv4g==", - "dev": true - }, - "node_modules/@cspell/dict-filetypes": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-filetypes/-/dict-filetypes-2.0.1.tgz", - "integrity": "sha512-bQ7K3U/3hKO2lpQjObf0veNP/n50qk5CVezSwApMBckf/sAVvDTR1RGAvYdr+vdQnkdQrk6wYmhbshXi0sLDVg==", - "dev": true - }, - "node_modules/@cspell/dict-fonts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-fonts/-/dict-fonts-2.0.0.tgz", - "integrity": "sha512-AgkTalphfDPtKFPYmEExDcj8rRCh86xlOSXco8tehOEkYVYbksOk9XH0YVH34RFpy93YBd2nnVGLgyGVwagcPw==", - "dev": true - }, - "node_modules/@cspell/dict-fullstack": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-fullstack/-/dict-fullstack-2.0.4.tgz", - "integrity": "sha512-+JtYO58QAXnetRN+MGVzI8YbkbFTLpYfl/Cw/tmNqy7U1IDVC4sTXQ2pZvbbeKQWFHBqYvBs0YASV+mTouXYBw==", - "dev": true - }, - "node_modules/@cspell/dict-git": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-git/-/dict-git-1.0.1.tgz", - "integrity": "sha512-Rk+eTof/9inF11lvxmkCRK+gODatA3qai8kSASv6OG/JfPvpj7fTHErx/rdgPw/LOTDUafnoTjTYmj7B2MOQXg==", - "dev": true - }, - "node_modules/@cspell/dict-golang": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-golang/-/dict-golang-2.0.0.tgz", - "integrity": "sha512-rUeZJR/S/ZjAsOURtxsAO6xDQhL0IzF458ScahaeOqe0zVL3tx7tCLikCgT92NWPs3BNqmsZGqYSDbn/1KsSIA==", - "dev": true - }, - "node_modules/@cspell/dict-haskell": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-haskell/-/dict-haskell-2.0.0.tgz", - "integrity": "sha512-cjX1Br+gSWqtcmJD/IMHz1UoP3pUaKIIKy/JfhEs7ANtRt6hhfEKe9dl2kQzDkkKt4pXol+YgdYxL/sVc/nLgQ==", - "dev": true - }, - "node_modules/@cspell/dict-html": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-html/-/dict-html-3.0.1.tgz", - "integrity": "sha512-sbuFd+nSjgbrGf5eYwSddFhm1eLLePKWyH6Zn8Zb0OODrBK5e4vGn1/scI/MOH5a2IvNs8W9wp84uMBFJcQZtw==", - "dev": true - }, - "node_modules/@cspell/dict-html-symbol-entities": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-html-symbol-entities/-/dict-html-symbol-entities-2.0.0.tgz", - "integrity": "sha512-71S5wGCe7dq6C+zGDwsEAe5msub/irrLi6SExeG11a/EkpA3RKAEheDGPk0hOY4+vOcIFHaApxOjLTtgQfYWfA==", - "dev": true - }, - "node_modules/@cspell/dict-java": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-java/-/dict-java-2.0.0.tgz", - "integrity": "sha512-9f5LDATlAiXRGqxLxgqbOLlQxuMW2zcN7tBgxwtN+4u90vM03ZUOR/gKIuDV/y0ZuAiWBIjA73cjk8DJ13Q1eA==", - "dev": true - }, - "node_modules/@cspell/dict-latex": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-latex/-/dict-latex-2.0.0.tgz", - "integrity": "sha512-H6RRwbHhQ9ARoO1R57SDqB+q/J5jUDdVnkdfukJkA+HNlJBhCcDuzGOIJqr+GBkJYDkF3obZ3LEOk2lUfT+Eyg==", - "dev": true - }, - "node_modules/@cspell/dict-lorem-ipsum": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-lorem-ipsum/-/dict-lorem-ipsum-2.0.0.tgz", - "integrity": "sha512-jKogAKtqvgPMleL6usyj3rZ0m8sVUR6drrD+wMnWSfdx1BmUyTsYiuh/mPEfLAebaYHELWSLQG3rDZRvV9Riqg==", - "dev": true - }, - "node_modules/@cspell/dict-lua": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-lua/-/dict-lua-2.0.0.tgz", - "integrity": "sha512-7WUEBEspSKtsq104WdIys1+DLqAxpJPzw74Py1TuE3fI5GvlzeSZkRFP2ya54GB2lCO4C3mq4M8EnitpibVDfw==", - "dev": true - }, - "node_modules/@cspell/dict-node": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-node/-/dict-node-2.0.0.tgz", - "integrity": "sha512-tPPl3liJORa/l6AoYqh/7rjoM7bdtaIXnIN6ox7CE0flZcBS5rWOB6mzEY3rpu/XJX0pjbBiIoqrolDkVl1RTQ==", - "dev": true - }, - "node_modules/@cspell/dict-npm": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-npm/-/dict-npm-2.0.2.tgz", - "integrity": "sha512-Q5ua0aeKTxW4WxvtU+UMdct46hCStOTeEiiG8iinTh/mH5brmdtMEj4olO8+mmkAKPpIC4TI3TmaaN6RN+Vpgw==", - "dev": true - }, - "node_modules/@cspell/dict-php": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-php/-/dict-php-2.0.0.tgz", - "integrity": "sha512-29WgU77eTO985LvMHwPi1pcpfopfCWfTdffDyqya0JIfOSaFUrlYKzGPkE4mRxcz2G3hXsaM0SRvBNdIRwEdUg==", - "dev": true - }, - "node_modules/@cspell/dict-powershell": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-powershell/-/dict-powershell-2.0.0.tgz", - "integrity": "sha512-6uvEhLiGmG3u9TFkM1TYcky6aL9Yk7Sk3KJwoTYBaQJY2KqrprgyQtW6yxIw9oU52VRHlq3KKvSAA9Q26+SIkQ==", - "dev": true - }, - "node_modules/@cspell/dict-public-licenses": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-public-licenses/-/dict-public-licenses-1.0.4.tgz", - "integrity": "sha512-h4xULfVEDUeWyvp1OO19pcGDqWcBEQ7WGMp3QBHyYpjsamlzsyYYjCRSY2ZvpM7wruDmywSRFmRHJ/+uNFT7nA==", - "dev": true - }, - "node_modules/@cspell/dict-python": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-2.0.6.tgz", - "integrity": "sha512-54ICgMRiGwavorg8UJC38Fwx8tW8WKj8pimJmFUd0F/ImQ8wmeg4VrmyMach5MZVUaw1qUe2aP5uSyqA15Q0mg==", - "dev": true - }, - "node_modules/@cspell/dict-r": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-r/-/dict-r-1.0.2.tgz", - "integrity": "sha512-Rp3d4sgD6izW9TW5yVI3D//3HTl9oOGBuzTvXRdoHksVPRvzIu2liVhj8MnQ3XIRe5Kc6IhLBAm6izuV2BpGwQ==", - "dev": true - }, - "node_modules/@cspell/dict-ruby": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-ruby/-/dict-ruby-2.0.1.tgz", - "integrity": "sha512-qGqhYfFeoBOashv/l0Kj5o4ilyvfq0s+t+r32juPOkOnbHz+hzxnJo2tMMg/L/UdjVV7Y8ovg4LDBC/seVrMYQ==", - "dev": true - }, - "node_modules/@cspell/dict-rust": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-rust/-/dict-rust-2.0.0.tgz", - "integrity": "sha512-EWlQivTKXMU3TTcq/Pi6KPKTQADknasQ700UrxRPzxhwQ4sKVZ88GDu6VZJlsbFUz8Vko289KS6wjiox/7WpmQ==", - "dev": true - }, - "node_modules/@cspell/dict-scala": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-scala/-/dict-scala-2.0.0.tgz", - "integrity": "sha512-MUwA2YKpqaQOSR4V1/CVGRNk8Ii5kf6I8Ch+4/BhRZRQXuwWbi21rDRYWPqdQWps7VNzAbbMA+PQDWsD5YY38g==", - "dev": true - }, - "node_modules/@cspell/dict-software-terms": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-2.1.4.tgz", - "integrity": "sha512-MB2eT9qhbnIEJajGv+ndzzi6S8NCJ9cMyeGJYMoRAiJobTKP6xPrT37VjPzhckRtrHJGG//UgtQ4NsiK5aBITw==", - "dev": true - }, - "node_modules/@cspell/dict-swift": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-swift/-/dict-swift-1.0.2.tgz", - "integrity": "sha512-IrMcRO7AYB2qU5cj4ttZyEbd04DRNOG6Iha106qGGmn4P096m+Y7lOnSLJx/rZbD/cAT3Z/7i465Lr1J93j7yg==", - "dev": true - }, - "node_modules/@cspell/dict-typescript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-typescript/-/dict-typescript-2.0.0.tgz", - "integrity": "sha512-WFBahxsnD2y4Os14tE5Zxh31Ggn4DzGOAu3UoxYl1lLLxaszx4RH7LmAeFuznySboiaBeRBbpfJOjQA796O6VQ==", - "dev": true - }, - "node_modules/@cspell/dict-vue": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-vue/-/dict-vue-2.0.2.tgz", - "integrity": "sha512-/MB0RS0Gn01s4pgmjy0FvsLfr3RRMrRphEuvTRserNcM8XVtoIVAtrjig/Gg0DPwDrN8Clm0L1j7iQay6S8D0g==", - "dev": true - }, - "node_modules/@eslint/eslintrc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", - "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", - "dev": true, - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/eslintrc/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@humanwhocodes/config-array": { - "version": "0.9.5", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz", - "integrity": "sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==", - "dev": true, - "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.4" - }, - "engines": { - "node": ">=10.10.0" - } - }, - "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", - "dev": true - }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", - "dev": true - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", - "dev": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "node_modules/@microsoft/tsdoc": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.14.1.tgz", - "integrity": "sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==", - "dev": true - }, - "node_modules/@microsoft/tsdoc-config": { - "version": "0.16.1", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.16.1.tgz", - "integrity": "sha512-2RqkwiD4uN6MLnHFljqBlZIXlt/SaUT6cuogU1w2ARw4nKuuppSmR0+s+NC+7kXBQykd9zzu0P4HtBpZT5zBpQ==", - "dev": true, - "dependencies": { - "@microsoft/tsdoc": "0.14.1", - "ajv": "~6.12.6", - "jju": "~1.4.0", - "resolve": "~1.19.0" - } - }, - "node_modules/@microsoft/tsdoc-config/node_modules/resolve": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", - "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", - "dev": true, - "dependencies": { - "is-core-module": "^2.1.0", - "path-parse": "^1.0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@types/chai": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.1.tgz", - "integrity": "sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==", - "dev": true - }, - "node_modules/@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", - "dev": true - }, - "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", - "dev": true - }, - "node_modules/@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", - "dev": true - }, - "node_modules/@types/mocha": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", - "integrity": "sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg==", - "dev": true - }, - "node_modules/@types/node": { - "version": "17.0.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.24.tgz", - "integrity": "sha512-aveCYRQbgTH9Pssp1voEP7HiuWlD2jW2BO56w+bVrJn04i61yh6mRfoKO6hEYQD9vF+W8Chkwc6j1M36uPkx4g==", - "dev": true - }, - "node_modules/@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true - }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz", - "integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==", - "dev": true, - "dependencies": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/type-utils": "5.19.0", - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "functional-red-black-tree": "^1.0.1", - "ignore": "^5.1.8", - "regexpp": "^3.2.0", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/parser": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz", - "integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "debug": "^4.3.2" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", - "dev": true, - "dependencies": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", - "debug": "^4.3.2", - "globby": "^11.0.4", - "is-glob": "^4.0.3", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", - "integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==", - "dev": true, - "dependencies": { - "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, - "node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "node_modules/array-includes": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", - "integrity": "sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", - "get-intrinsic": "^1.1.1", - "is-string": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array-timsort": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-timsort/-/array-timsort-1.0.3.tgz", - "integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==", - "dev": true - }, - "node_modules/array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/array.prototype.flat": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", - "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.2", - "es-shim-unscopables": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.flatmap": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.0.tgz", - "integrity": "sha512-PZC9/8TKAIxcWKdyeb77EzULHPrIX/tIZebLJUQOMR1OwYosT8yggdfWScfTBCDj5utONvOuPQQumYsU2ULbkg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.2", - "es-shim-unscopables": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/babel-plugin-dynamic-import-node": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", - "integrity": "sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==", - "dev": true, - "dependencies": { - "object.assign": "^4.1.0" - } - }, - "node_modules/babel-plugin-polyfill-corejs2": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz", - "integrity": "sha512-v7/T6EQcNfVLfcN2X8Lulb7DjprieyLWJK/zOWH5DUYcAgex9sP3h25Q+DLsX9TloXe3y1O8l2q2Jv9q8UVB9w==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.13.11", - "@babel/helper-define-polyfill-provider": "^0.3.1", - "semver": "^6.1.1" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", - "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", - "dev": true, - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.3.1", - "core-js-compat": "^3.21.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/babel-plugin-polyfill-regenerator": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.1.tgz", - "integrity": "sha512-Y2B06tvgHYt1x0yz17jGkGeeMr5FeKUu+ASJ+N6nB5lQ8Dapfg42i0OVrf8PNGJ3zKL4A23snMi1IRwrqqND7A==", - "dev": true, - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.3.1" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "node_modules/browserslist": { - "version": "4.20.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.2.tgz", - "integrity": "sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - } - ], - "dependencies": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", - "escalade": "^3.1.1", - "node-releases": "^2.0.2", - "picocolors": "^1.0.0" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true - }, - "node_modules/c8": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/c8/-/c8-7.11.0.tgz", - "integrity": "sha512-XqPyj1uvlHMr+Y1IeRndC2X5P7iJzJlEJwBpCdBbq2JocXOgJfr+JVfJkyNMGROke5LfKrhSFXGFXnwnRJAUJw==", - "dev": true, - "dependencies": { - "@bcoe/v8-coverage": "^0.2.3", - "@istanbuljs/schema": "^0.1.2", - "find-up": "^5.0.0", - "foreground-child": "^2.0.0", - "istanbul-lib-coverage": "^3.0.1", - "istanbul-lib-report": "^3.0.0", - "istanbul-reports": "^3.0.2", - "rimraf": "^3.0.0", - "test-exclude": "^6.0.0", - "v8-to-istanbul": "^8.0.0", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.7" - }, - "bin": { - "c8": "bin/c8.js" - }, - "engines": { - "node": ">=10.12.0" - } - }, - "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001332", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz", - "integrity": "sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - } - ] - }, - "node_modules/chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", - "dev": true, - "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/clear-module": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/clear-module/-/clear-module-4.1.2.tgz", - "integrity": "sha512-LWAxzHqdHsAZlPlEyJ2Poz6AIs384mPeqLVCru2p0BrP9G/kVGuhNyZYClLO6cXlnuJjzC8xtsJIuMjKqLXoAw==", - "dev": true, - "dependencies": { - "parent-module": "^2.0.0", - "resolve-from": "^5.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/cliui/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/cliui/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/cliui/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/cliui/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/clone-deep": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", - "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", - "dev": true, - "dependencies": { - "is-plain-object": "^2.0.4", - "kind-of": "^6.0.2", - "shallow-clone": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "node_modules/comment-json": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.2.tgz", - "integrity": "sha512-H8T+kl3nZesZu41zO2oNXIJWojNeK3mHxCLrsBNu6feksBXsgb+PtYz5daP5P86A0F3sz3840KVYehr04enISQ==", - "dev": true, - "dependencies": { - "array-timsort": "^1.0.3", - "core-util-is": "^1.0.3", - "esprima": "^4.0.1", - "has-own-prop": "^2.0.0", - "repeat-string": "^1.6.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", - "dev": true - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "node_modules/configstore": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.1.tgz", - "integrity": "sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==", - "dev": true, - "dependencies": { - "dot-prop": "^5.2.0", - "graceful-fs": "^4.1.2", - "make-dir": "^3.0.0", - "unique-string": "^2.0.0", - "write-file-atomic": "^3.0.0", - "xdg-basedir": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/configstore/node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dev": true, - "dependencies": { - "semver": "^6.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/convert-source-map": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", - "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.1" - } - }, - "node_modules/core-js-compat": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.1.tgz", - "integrity": "sha512-gbgX5AUvMb8gwxC7FLVWYT7Kkgu/y7+h/h1X43yJkNqhlK2fuYyQimqvKGNZFAY6CKii/GFKJ2cp/1/42TN36g==", - "dev": true, - "dependencies": { - "browserslist": "^4.19.1", - "semver": "7.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/core-js-compat/node_modules/semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true - }, - "node_modules/cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", - "dev": true, - "dependencies": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/crypto-random-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", - "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cspell": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell/-/cspell-5.19.7.tgz", - "integrity": "sha512-7/y+k708tv68+5lpN23Ew1/djx/EnG838zZ8W2ZDWCc6uRHutqRhpxsjMZr/MT3RHN44iKUj2MgT5+sfnhr4eg==", - "dev": true, - "dependencies": { - "@cspell/cspell-pipe": "^5.19.7", - "chalk": "^4.1.2", - "commander": "^9.1.0", - "cspell-gitignore": "^5.19.7", - "cspell-glob": "^5.19.7", - "cspell-lib": "^5.19.7", - "fast-json-stable-stringify": "^2.1.0", - "file-entry-cache": "^6.0.1", - "fs-extra": "^10.0.1", - "get-stdin": "^8.0.0", - "glob": "^7.2.0", - "imurmurhash": "^0.1.4", - "semver": "^7.3.6", - "strip-ansi": "^6.0.1", - "vscode-uri": "^3.0.3" - }, - "bin": { - "cspell": "bin.js" - }, - "engines": { - "node": ">=12.13.0" - }, - "funding": { - "url": "https://github.com/streetsidesoftware/cspell?sponsor=1" - } - }, - "node_modules/cspell-gitignore": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-5.19.7.tgz", - "integrity": "sha512-rEqlN6wigNj4P/4Z3QCI1P56KhKkPtXNBpGMXC5CbxIK/NTtn3cLaqHKIZp92pypEnU077lxSCSqRRYCPbg/6A==", - "dev": true, - "dependencies": { - "cspell-glob": "^5.19.7", - "find-up": "^5.0.0" - }, - "bin": { - "cspell-gitignore": "bin.js" - }, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/cspell-glob": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-5.19.7.tgz", - "integrity": "sha512-fqlF7oqYTT2A3SRfQr7gzN21fwPoRO9IGKec1L3QeGkni5UPDxGrM2a5z+oLaYs2GN5pEf29BXVlN7dq0jVxIg==", - "dev": true, - "dependencies": { - "micromatch": "^4.0.5" - }, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/cspell-io": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-5.19.7.tgz", - "integrity": "sha512-SEy8XkuOhvwleGjh336EBYj5HlH1J5FrCI5GxxGiU2g8zvWlBPQmaCfQPPO4tnDrrXtK76rZvolBu1jfCmWwQA==", - "dev": true, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/cspell-lib": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-5.19.7.tgz", - "integrity": "sha512-d4ewH1RBgcBE9NqAh0FexmVQ6YvkDQv9XOysskeDH+G9wm975owENUU/mBd8AyBt2b4YXL/FoLtaKd/7MRoNDA==", - "dev": true, - "dependencies": { - "@cspell/cspell-bundled-dicts": "^5.19.7", - "@cspell/cspell-pipe": "^5.19.7", - "@cspell/cspell-types": "^5.19.7", - "clear-module": "^4.1.2", - "comment-json": "^4.2.2", - "configstore": "^5.0.1", - "cosmiconfig": "^7.0.1", - "cspell-glob": "^5.19.7", - "cspell-io": "^5.19.7", - "cspell-trie-lib": "^5.19.7", - "fast-equals": "^3.0.1", - "find-up": "^5.0.0", - "fs-extra": "^10.0.1", - "gensequence": "^3.1.1", - "import-fresh": "^3.3.0", - "resolve-from": "^5.0.0", - "resolve-global": "^1.0.0", - "vscode-languageserver-textdocument": "^1.0.4", - "vscode-uri": "^3.0.3" - }, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/cspell-trie-lib": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-5.19.7.tgz", - "integrity": "sha512-qr0HS2hGuyIQhDGG5li0nqIjVi039iPRHR8wpeDoSO0YIBCll22i/VlvW3CSmqXLaP5RRoAc9txiZkIGob6DkQ==", - "dev": true, - "dependencies": { - "@cspell/cspell-pipe": "^5.19.7", - "fs-extra": "^10.0.1", - "gensequence": "^3.1.1" - }, - "engines": { - "node": ">=12.13.0" - } - }, - "node_modules/cspell/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/cspell/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/cspell/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/cspell/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/cspell/node_modules/commander": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.1.0.tgz", - "integrity": "sha512-i0/MaqBtdbnJ4XQs4Pmyb+oFQl+q0lsAmokVUH92SlSw4fkeAcG3bVon+Qt7hmtF+u3Het6o4VgrcY3qAoEB6w==", - "dev": true, - "engines": { - "node": "^12.20.0 || >=14" - } - }, - "node_modules/cspell/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cspell/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/cspell/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, - "engines": { - "node": ">=0.12" - } - }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true - }, - "node_modules/define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "dependencies": { - "object-keys": "^1.0.12" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/dot-prop": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", - "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", - "dev": true, - "dependencies": { - "is-obj": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/electron-to-chromium": { - "version": "1.4.107", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.107.tgz", - "integrity": "sha512-Huen6taaVrUrSy8o7mGStByba8PfOWWluHNxSHGBrCgEdFVLtvdQDBr9LBCF9Uci8SYxh28QNNMO0oC17wbGAg==", - "dev": true - }, - "node_modules/error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "dependencies": { - "is-arrayish": "^0.2.1" - } - }, - "node_modules/es-abstract": { - "version": "1.19.5", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.5.tgz", - "integrity": "sha512-Aa2G2+Rd3b6kxEUKTF4TaW67czBLyAv3z7VOhYRU50YBx+bbsYZ9xQP4lMNazePuFlybXI0V4MruPos7qUo5fA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "get-intrinsic": "^1.1.1", - "get-symbol-description": "^1.0.0", - "has": "^1.0.3", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "is-callable": "^1.2.4", - "is-negative-zero": "^2.0.2", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "is-string": "^1.0.7", - "is-weakref": "^1.0.2", - "object-inspect": "^1.12.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/es-shim-unscopables": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", - "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", - "dev": true, - "dependencies": { - "has": "^1.0.3" - } - }, - "node_modules/es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "dependencies": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/eslint": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.13.0.tgz", - "integrity": "sha512-D+Xei61eInqauAyTJ6C0q6x9mx7kTUC1KZ0m0LSEexR0V+e94K12LmWX076ZIsldwfQ2RONdaJe0re0TRGQbRQ==", - "dev": true, - "dependencies": { - "@eslint/eslintrc": "^1.2.1", - "@humanwhocodes/config-array": "^0.9.2", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", - "globals": "^13.6.0", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-import-resolver-node": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", - "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", - "dev": true, - "dependencies": { - "debug": "^3.2.7", - "resolve": "^1.20.0" - } - }, - "node_modules/eslint-import-resolver-node/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-module-utils": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz", - "integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==", - "dev": true, - "dependencies": { - "debug": "^3.2.7", - "find-up": "^2.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-module-utils/node_modules/find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "dependencies": { - "locate-path": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "dependencies": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "dependencies": { - "p-try": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "dependencies": { - "p-limit": "^1.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-plugin-es": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", - "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", - "dev": true, - "dependencies": { - "eslint-utils": "^2.0.0", - "regexpp": "^3.0.0" - }, - "engines": { - "node": ">=8.10.0" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=4.19.1" - } - }, - "node_modules/eslint-plugin-es/node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, - "node_modules/eslint-plugin-es/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-plugin-import": { - "version": "2.26.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", - "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", - "dev": true, - "dependencies": { - "array-includes": "^3.1.4", - "array.prototype.flat": "^1.2.5", - "debug": "^2.6.9", - "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.3", - "has": "^1.0.3", - "is-core-module": "^2.8.1", - "is-glob": "^4.0.3", - "minimatch": "^3.1.2", - "object.values": "^1.1.5", - "resolve": "^1.22.0", - "tsconfig-paths": "^3.14.1" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" - } - }, - "node_modules/eslint-plugin-import/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/eslint-plugin-import/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/eslint-plugin-import/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "node_modules/eslint-plugin-internal-rules": { - "resolved": "resources/eslint-internal-rules", - "link": true - }, - "node_modules/eslint-plugin-node": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", - "integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==", - "dev": true, - "dependencies": { - "eslint-plugin-es": "^3.0.0", - "eslint-utils": "^2.0.0", - "ignore": "^5.1.1", - "minimatch": "^3.0.4", - "resolve": "^1.10.1", - "semver": "^6.1.0" - }, - "engines": { - "node": ">=8.10.0" - }, - "peerDependencies": { - "eslint": ">=5.16.0" - } - }, - "node_modules/eslint-plugin-node/node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, - "node_modules/eslint-plugin-node/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-plugin-react": { - "version": "7.29.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.29.4.tgz", - "integrity": "sha512-CVCXajliVh509PcZYRFyu/BoUEz452+jtQJq2b3Bae4v3xBUWPLCmtmBM+ZinG4MzwmxJgJ2M5rMqhqLVn7MtQ==", - "dev": true, - "dependencies": { - "array-includes": "^3.1.4", - "array.prototype.flatmap": "^1.2.5", - "doctrine": "^2.1.0", - "estraverse": "^5.3.0", - "jsx-ast-utils": "^2.4.1 || ^3.0.0", - "minimatch": "^3.1.2", - "object.entries": "^1.1.5", - "object.fromentries": "^2.0.5", - "object.hasown": "^1.1.0", - "object.values": "^1.1.5", - "prop-types": "^15.8.1", - "resolve": "^2.0.0-next.3", - "semver": "^6.3.0", - "string.prototype.matchall": "^4.0.6" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" - } - }, - "node_modules/eslint-plugin-react-hooks": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.4.0.tgz", - "integrity": "sha512-U3RVIfdzJaeKDQKEJbz5p3NW8/L80PCATJAfuojwbaEL+gBjfGdhUcGde+WGUW46Q5sr/NgxevsIiDtNXrvZaQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" - } - }, - "node_modules/eslint-plugin-react/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/eslint-plugin-react/node_modules/resolve": { - "version": "2.0.0-next.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.3.tgz", - "integrity": "sha512-W8LucSynKUIDu9ylraa7ueVZ7hc0uAgJBxVsQSKOXOyle8a93qXhcz+XAXZ8bIq2d6i4Ehddn6Evt+0/UwKk6Q==", - "dev": true, - "dependencies": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/eslint-plugin-simple-import-sort": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-7.0.0.tgz", - "integrity": "sha512-U3vEDB5zhYPNfxT5TYR7u01dboFZp+HNpnGhkDB2g/2E4wZ/g1Q9Ton8UwCLfRV9yAKyYqDh62oHOamvkFxsvw==", - "dev": true, - "peerDependencies": { - "eslint": ">=5.0.0" - } - }, - "node_modules/eslint-plugin-tsdoc": { - "version": "0.2.16", - "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.16.tgz", - "integrity": "sha512-F/RWMnyDQuGlg82vQEFHQtGyWi7++XJKdYNn0ulIbyMOFqYIjoJOUdE6olORxgwgLkpJxsCJpJbTHgxJ/ggfXw==", - "dev": true, - "dependencies": { - "@microsoft/tsdoc": "0.14.1", - "@microsoft/tsdoc-config": "0.16.1" - } - }, - "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-scope/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/eslint/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/eslint/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/eslint/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/eslint/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint/node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/eslint/node_modules/globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/eslint/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/eslint/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", - "dev": true, - "dependencies": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", - "dev": true, - "dependencies": { - "estraverse": "^5.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "dependencies": { - "estraverse": "^5.2.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "node_modules/fast-equals": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-3.0.1.tgz", - "integrity": "sha512-J9FxqqC9E/ja0C+SYhoG3Jl6pQuhP92HNcVC75xDEhB+GUzPnjEp3vMfPIxPprYZFfXS5hpVvvPCWUMiDSMS8Q==", - "dev": true - }, - "node_modules/fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "node_modules/fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dev": true, - "dependencies": { - "reusify": "^1.0.4" - } - }, - "node_modules/file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "dev": true, - "dependencies": { - "flat-cache": "^3.0.4" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/find-cache-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", - "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", - "dev": true, - "dependencies": { - "commondir": "^1.0.1", - "make-dir": "^2.0.0", - "pkg-dir": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true, - "bin": { - "flat": "cli.js" - } - }, - "node_modules/flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", - "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", - "dev": true, - "dependencies": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", - "dev": true - }, - "node_modules/foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, - "node_modules/gensequence": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/gensequence/-/gensequence-3.1.1.tgz", - "integrity": "sha512-ys3h0hiteRwmY6BsvSttPmkhC0vEQHPJduANBRtH/dlDPZ0UBIb/dXy80IcckXyuQ6LKg+PloRqvGER9IS7F7g==", - "dev": true, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/get-symbol-description": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", - "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/global-dirs": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", - "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", - "dev": true, - "dependencies": { - "ini": "^1.3.4" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "dependencies": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "dev": true - }, - "node_modules/growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true, - "engines": { - "node": ">=4.x" - } - }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/has-own-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-own-prop/-/has-own-prop-2.0.0.tgz", - "integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dev": true, - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true, - "bin": { - "he": "bin/he" - } - }, - "node_modules/html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true - }, - "node_modules/ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, - "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/import-fresh/node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/import-fresh/node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true, - "engines": { - "node": ">=0.8.19" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true - }, - "node_modules/internal-slot": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", - "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", - "dev": true, - "dependencies": { - "get-intrinsic": "^1.1.0", - "has": "^1.0.3", - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, - "node_modules/is-bigint": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", - "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", - "dev": true, - "dependencies": { - "has-bigints": "^1.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-boolean-object": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", - "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-callable": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", - "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "dev": true, - "dependencies": { - "has": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", - "dev": true, - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-negative-zero": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", - "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-number-object": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", - "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", - "dev": true, - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-regex": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-shared-array-buffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", - "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-string": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", - "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", - "dev": true, - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-symbol": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", - "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", - "dev": true, - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true - }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-weakref": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", - "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "node_modules/isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/istanbul-lib-coverage": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", - "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", - "dev": true, - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-report/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-report/node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dev": true, - "dependencies": { - "semver": "^6.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/istanbul-lib-report/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-reports": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.4.tgz", - "integrity": "sha512-r1/DshN4KSE7xWEknZLLLLDn5CJybV3nw01VTkp6D5jzLuELlcbudfj/eSQFvrKsJuTVCGnePO7ho82Nw9zzfw==", - "dev": true, - "dependencies": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jju": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", - "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=", - "dev": true - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true - }, - "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true - }, - "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", - "dev": true, - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/jsx-ast-utils": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.2.2.tgz", - "integrity": "sha512-HDAyJ4MNQBboGpUnHAVUNJs6X0lh058s6FuixsFGP7MgJYpD6Vasd6nzSG5iIfXu1zAYlHJ/zsOKNlrenTUBnw==", - "dev": true, - "dependencies": { - "array-includes": "^3.1.4", - "object.assign": "^4.1.2" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true - }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true - }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true - }, - "node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/log-symbols/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/log-symbols/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/log-symbols/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/log-symbols/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/log-symbols/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/log-symbols/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } - }, - "node_modules/loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", - "dev": true, - "dependencies": { - "get-func-name": "^2.0.0" - } - }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/make-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", - "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", - "dev": true, - "dependencies": { - "pify": "^4.0.1", - "semver": "^5.6.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/make-dir/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dev": true, - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true - }, - "node_modules/mocha": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", - "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", - "dev": true, - "dependencies": { - "@ungap/promise-all-settled": "1.1.2", - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.3", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.2.0", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", - "minimatch": "4.2.1", - "ms": "2.1.3", - "nanoid": "3.3.1", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" - } - }, - "node_modules/mocha/node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mocha/node_modules/debug/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "node_modules/mocha/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/mocha/node_modules/minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/mocha/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "node_modules/mocha/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/mocha/node_modules/yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "node_modules/nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", - "dev": true, - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "node_modules/node-releases": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.3.tgz", - "integrity": "sha512-maHFz6OLqYxz+VQyCAtA3PTX4UP/53pa05fyDNc9CwjvJ0yEh6+xBwKsgCxMNhS8taUKBFYxfuiaD9U/55iFaw==", - "dev": true - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.entries": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.5.tgz", - "integrity": "sha512-TyxmjUoZggd4OrrU1W66FMDG6CuqJxsFvymeyXI51+vQLN67zYfZseptRge703kKQdo4uccgAKebXFcRCzk4+g==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.fromentries": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.5.tgz", - "integrity": "sha512-CAyG5mWQRRiBU57Re4FKoTBjXfDoNwdFVH2Y1tS9PqCsfUTymAohOkEMSG3aRNKmv4lV3O7p1et7c187q6bynw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.hasown": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.0.tgz", - "integrity": "sha512-MhjYRfj3GBlhSkDHo6QmvgjRLXQ2zndabdf3nX0yTyZK9rPfxb6uRpAac8HXNLy1GpqWtZ81Qh4v3uOls2sRAg==", - "dev": true, - "dependencies": { - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.values": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz", - "integrity": "sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/parent-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-2.0.0.tgz", - "integrity": "sha512-uo0Z9JJeWzv8BG+tRcapBKNJ0dro9cLyczGzulS6EfeyAdeC9sbojtW6XwvYxJkEne9En+J2XEl4zyglVeIwFg==", - "dev": true, - "dependencies": { - "callsites": "^3.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/pirates": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", - "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/pkg-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", - "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", - "dev": true, - "dependencies": { - "find-up": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-dir/node_modules/find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "dependencies": { - "locate-path": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "dependencies": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "dependencies": { - "p-limit": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-dir/node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/prettier": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz", - "integrity": "sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==", - "dev": true, - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, - "node_modules/prop-types": { - "version": "15.8.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", - "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, - "dependencies": { - "loose-envify": "^1.4.0", - "object-assign": "^4.1.1", - "react-is": "^16.13.1" - } - }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, - "node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/regenerate": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", - "dev": true - }, - "node_modules/regenerate-unicode-properties": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz", - "integrity": "sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw==", - "dev": true, - "dependencies": { - "regenerate": "^1.4.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regenerator-runtime": { - "version": "0.13.9", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "dev": true - }, - "node_modules/regenerator-transform": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.0.tgz", - "integrity": "sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==", - "dev": true, - "dependencies": { - "@babel/runtime": "^7.8.4" - } - }, - "node_modules/regexp.prototype.flags": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.2.tgz", - "integrity": "sha512-Ynz8fTQW5/1elh+jWU2EDDzeoNbD0OQ0R+D1VJU5ATOkUaro4A9YEkdN2ODQl/8UQFPPpZNw91fOcLFamM7Pww==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, - "node_modules/regexpu-core": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.0.1.tgz", - "integrity": "sha512-CriEZlrKK9VJw/xQGJpQM5rY88BtuL8DM+AEwvcThHilbxiTAy8vq4iJnd2tqq8wLmjbGZzP7ZcKFjbGkmEFrw==", - "dev": true, - "dependencies": { - "regenerate": "^1.4.2", - "regenerate-unicode-properties": "^10.0.1", - "regjsgen": "^0.6.0", - "regjsparser": "^0.8.2", - "unicode-match-property-ecmascript": "^2.0.0", - "unicode-match-property-value-ecmascript": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regjsgen": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.6.0.tgz", - "integrity": "sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA==", - "dev": true - }, - "node_modules/regjsparser": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.8.4.tgz", - "integrity": "sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA==", - "dev": true, - "dependencies": { - "jsesc": "~0.5.0" - }, - "bin": { - "regjsparser": "bin/parser" - } - }, - "node_modules/regjsparser/node_modules/jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true, - "bin": { - "jsesc": "bin/jsesc" - } - }, - "node_modules/repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "dev": true, - "dependencies": { - "is-core-module": "^2.8.1", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/resolve-global": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/resolve-global/-/resolve-global-1.0.0.tgz", - "integrity": "sha512-zFa12V4OLtT5XUX/Q4VLvTfBf+Ok0SPc1FNGM/z9ctUdiU618qwKpWnd0CHs3+RqROfyEg/DhuHbMWYqcgljEw==", - "dev": true, - "dependencies": { - "global-dirs": "^0.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true, - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", - "dev": true, - "dependencies": { - "randombytes": "^2.1.0" - } - }, - "node_modules/shallow-clone": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", - "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", - "dev": true, - "dependencies": { - "kind-of": "^6.0.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, - "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/source-map-support/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/string.prototype.matchall": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz", - "integrity": "sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", - "get-intrinsic": "^1.1.1", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "regexp.prototype.flags": "^1.4.1", - "side-channel": "^1.0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/string.prototype.trimend": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", - "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/string.prototype.trimstart": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", - "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/test-exclude": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", - "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", - "dev": true, - "dependencies": { - "@istanbuljs/schema": "^0.1.2", - "glob": "^7.1.4", - "minimatch": "^3.0.4" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/tsconfig-paths": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", - "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", - "dev": true, - "dependencies": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - } - }, - "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, - "node_modules/tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dev": true, - "dependencies": { - "tslib": "^1.8.1" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - } - }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "dependencies": { - "prelude-ls": "^1.2.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, - "dependencies": { - "is-typedarray": "^1.0.0" - } - }, - "node_modules/typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", - "which-boxed-primitive": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/unicode-canonical-property-names-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", - "integrity": "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", - "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", - "dev": true, - "dependencies": { - "unicode-canonical-property-names-ecmascript": "^2.0.0", - "unicode-property-aliases-ecmascript": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-value-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.0.0.tgz", - "integrity": "sha512-7Yhkc0Ye+t4PNYzOGKedDhXbYIBe1XEQYQxOPyhcXNMJ0WCABqqj6ckydd6pWRZTHV4GuCPKdBAUiMc60tsKVw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-property-aliases-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz", - "integrity": "sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/unique-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", - "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", - "dev": true, - "dependencies": { - "crypto-random-string": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/uri-js/node_modules/punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, - "node_modules/v8-to-istanbul": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz", - "integrity": "sha512-FGtKtv3xIpR6BYhvgH8MI/y78oT7d8Au3ww4QIxymrCtZEh5b8gCw2siywE+puhEmuWKDtmfrvF5UlB298ut3w==", - "dev": true, - "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.1", - "convert-source-map": "^1.6.0", - "source-map": "^0.7.3" - }, - "engines": { - "node": ">=10.12.0" - } - }, - "node_modules/v8-to-istanbul/node_modules/source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/vscode-languageserver-textdocument": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.4.tgz", - "integrity": "sha512-/xhqXP/2A2RSs+J8JNXpiiNVvvNM0oTosNVmQnunlKvq9o4mupHOBAnnzH0lwIPKazXKvAKsVp1kr+H/K4lgoQ==", - "dev": true - }, - "node_modules/vscode-uri": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.3.tgz", - "integrity": "sha512-EcswR2S8bpR7fD0YPeS7r2xXExrScVMxg4MedACaWHEtx9ftCF/qHG1xGkolzTPcEmjTavCQgbVzHUIdTMzFGA==", - "dev": true - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/which-boxed-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", - "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", - "dev": true, - "dependencies": { - "is-bigint": "^1.0.1", - "is-boolean-object": "^1.1.0", - "is-number-object": "^1.0.4", - "is-string": "^1.0.5", - "is-symbol": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", - "dev": true - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", - "dev": true, - "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" - } - }, - "node_modules/xdg-basedir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", - "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, - "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "dependencies": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "resources/eslint-internal-rules": { - "name": "eslint-plugin-graphql-internal", - "version": "0.0.0", - "dev": true, - "engines": { - "node": ">= 14.0.0" - } - } - }, - "dependencies": { - "@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", - "dev": true, - "requires": { - "@jridgewell/trace-mapping": "^0.3.0" - } - }, - "@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, - "requires": { - "@babel/highlight": "^7.16.7" - } - }, - "@babel/compat-data": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.7.tgz", - "integrity": "sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ==", - "dev": true - }, - "@babel/core": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.9.tgz", - "integrity": "sha512-5ug+SfZCpDAkVp9SFIZAzlW18rlzsOcJGaetCjkySnrXXDUw9AR8cDUm1iByTmdWM6yxX6/zycaV76w3YTF2gw==", - "dev": true, - "requires": { - "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", - "@babel/helper-compilation-targets": "^7.17.7", - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helpers": "^7.17.9", - "@babel/parser": "^7.17.9", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.9", - "@babel/types": "^7.17.0", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.1", - "semver": "^6.3.0" - } - }, - "@babel/generator": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.9.tgz", - "integrity": "sha512-rAdDousTwxbIxbz5I7GEQ3lUip+xVCXooZNbsydCWs3xA7ZsYOv+CFRdzGxRX78BmQHu9B1Eso59AOZQOJDEdQ==", - "dev": true, - "requires": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" - } - }, - "@babel/helper-annotate-as-pure": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz", - "integrity": "sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-builder-binary-assignment-operator-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz", - "integrity": "sha512-C6FdbRaxYjwVu/geKW4ZeQ0Q31AftgRcdSnZ5/jsH6BzCJbtvXvhpfkbkThYSuutZA7nCXpPR6AD9zd1dprMkA==", - "dev": true, - "requires": { - "@babel/helper-explode-assignable-expression": "^7.16.7", - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-compilation-targets": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.7.tgz", - "integrity": "sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==", - "dev": true, - "requires": { - "@babel/compat-data": "^7.17.7", - "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", - "semver": "^6.3.0" - } - }, - "@babel/helper-create-class-features-plugin": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.17.9.tgz", - "integrity": "sha512-kUjip3gruz6AJKOq5i3nC6CoCEEF/oHH3cp6tOZhB+IyyyPyW0g1Gfsxn3mkk6S08pIA2y8GQh609v9G/5sHVQ==", - "dev": true, - "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.17.9", - "@babel/helper-member-expression-to-functions": "^7.17.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7" - } - }, - "@babel/helper-create-regexp-features-plugin": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.17.0.tgz", - "integrity": "sha512-awO2So99wG6KnlE+TPs6rn83gCz5WlEePJDTnLEqbchMVrBeAujURVphRdigsk094VhvZehFoNOihSlcBjwsXA==", - "dev": true, - "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "regexpu-core": "^5.0.1" - } - }, - "@babel/helper-define-polyfill-provider": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.1.tgz", - "integrity": "sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA==", - "dev": true, - "requires": { - "@babel/helper-compilation-targets": "^7.13.0", - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-plugin-utils": "^7.13.0", - "@babel/traverse": "^7.13.0", - "debug": "^4.1.1", - "lodash.debounce": "^4.0.8", - "resolve": "^1.14.2", - "semver": "^6.1.2" - } - }, - "@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-explode-assignable-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.7.tgz", - "integrity": "sha512-KyUenhWMC8VrxzkGP0Jizjo4/Zx+1nNZhgocs+gLzyZyB8SHidhoq9KK/8Ato4anhwsivfkBLftky7gvzbZMtQ==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-function-name": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz", - "integrity": "sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg==", - "dev": true, - "requires": { - "@babel/template": "^7.16.7", - "@babel/types": "^7.17.0" - } - }, - "@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-member-expression-to-functions": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.17.7.tgz", - "integrity": "sha512-thxXgnQ8qQ11W2wVUObIqDL4p148VMxkt5T/qpN5k2fboRyzFGFmKsTGViquyM5QHKUy48OZoca8kw4ajaDPyw==", - "dev": true, - "requires": { - "@babel/types": "^7.17.0" - } - }, - "@babel/helper-module-imports": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz", - "integrity": "sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-module-transforms": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz", - "integrity": "sha512-VmZD99F3gNTYB7fJRDTi+u6l/zxY0BE6OIxPSU7a50s6ZUQkHwSDmV92FfM+oCG0pZRVojGYhkR8I0OGeCVREw==", - "dev": true, - "requires": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-simple-access": "^7.17.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" - } - }, - "@babel/helper-optimise-call-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz", - "integrity": "sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-plugin-utils": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz", - "integrity": "sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA==", - "dev": true - }, - "@babel/helper-remap-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.8.tgz", - "integrity": "sha512-fm0gH7Flb8H51LqJHy3HJ3wnE1+qtYR2A99K06ahwrawLdOFsCEWjZOrYricXJHoPSudNKxrMBUPEIPxiIIvBw==", - "dev": true, - "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-wrap-function": "^7.16.8", - "@babel/types": "^7.16.8" - } - }, - "@babel/helper-replace-supers": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz", - "integrity": "sha512-y9vsWilTNaVnVh6xiJfABzsNpgDPKev9HnAgz6Gb1p6UUwf9NepdlsV7VXGCftJM+jqD5f7JIEubcpLjZj5dBw==", - "dev": true, - "requires": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-member-expression-to-functions": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/traverse": "^7.16.7", - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-simple-access": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz", - "integrity": "sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA==", - "dev": true, - "requires": { - "@babel/types": "^7.17.0" - } - }, - "@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz", - "integrity": "sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw==", - "dev": true, - "requires": { - "@babel/types": "^7.16.0" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/helper-validator-option": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz", - "integrity": "sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==", - "dev": true - }, - "@babel/helper-wrap-function": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.16.8.tgz", - "integrity": "sha512-8RpyRVIAW1RcDDGTA+GpPAwV22wXCfKOoM9bet6TLkGIFTkRQSkH1nMQ5Yet4MpoXe1ZwHPVtNasc2w0uZMqnw==", - "dev": true, - "requires": { - "@babel/helper-function-name": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.16.8", - "@babel/types": "^7.16.8" - } - }, - "@babel/helpers": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.9.tgz", - "integrity": "sha512-cPCt915ShDWUEzEp3+UNRktO2n6v49l5RSnG9M5pS24hA+2FAc5si+Pn1i4VVbQQ+jh+bIZhPFQOJOzbrOYY1Q==", - "dev": true, - "requires": { - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.9", - "@babel/types": "^7.17.0" - } - }, - "@babel/highlight": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.9.tgz", - "integrity": "sha512-J9PfEKCbFIv2X5bjTMiZu6Vf341N05QIY+d6FvVKynkG1S7G0j3I0QoRtWIrXhZ+/Nlb5Q0MzqL7TokEJ5BNHg==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } - }, - "@babel/parser": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.9.tgz", - "integrity": "sha512-vqUSBLP8dQHFPdPi9bc5GK9vRkYHJ49fsZdtoJ8EQ8ibpwk5rPKfvNIwChB0KVXcIjcepEBBd2VHC5r9Gy8ueg==", - "dev": true - }, - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz", - "integrity": "sha512-anv/DObl7waiGEnC24O9zqL0pSuI9hljihqiDuFHC8d7/bjr/4RLGPWuc8rYOff/QPzbEPSkzG8wGG9aDuhHRg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.7.tgz", - "integrity": "sha512-di8vUHRdf+4aJ7ltXhaDbPoszdkh59AQtJM5soLsuHpQJdFQZOA4uGj0V2u/CZ8bJ/u8ULDL5yq6FO/bCXnKHw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", - "@babel/plugin-proposal-optional-chaining": "^7.16.7" - } - }, - "@babel/plugin-proposal-async-generator-functions": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz", - "integrity": "sha512-71YHIvMuiuqWJQkebWJtdhQTfd4Q4mF76q2IX37uZPkG9+olBxsX+rH1vkhFto4UeJZ9dPY2s+mDvhDm1u2BGQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8", - "@babel/plugin-syntax-async-generators": "^7.8.4" - } - }, - "@babel/plugin-proposal-class-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz", - "integrity": "sha512-IobU0Xme31ewjYOShSIqd/ZGM/r/cuOz2z0MDbNrhF5FW+ZVgi0f2lyeoj9KFPDOAqsYxmLWZte1WOwlvY9aww==", - "dev": true, - "requires": { - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-proposal-class-static-block": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.17.6.tgz", - "integrity": "sha512-X/tididvL2zbs7jZCeeRJ8167U/+Ac135AM6jCAx6gYXDUviZV5Ku9UDvWS2NCuWlFjIRXklYhwo6HhAC7ETnA==", - "dev": true, - "requires": { - "@babel/helper-create-class-features-plugin": "^7.17.6", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-class-static-block": "^7.14.5" - } - }, - "@babel/plugin-proposal-dynamic-import": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.16.7.tgz", - "integrity": "sha512-I8SW9Ho3/8DRSdmDdH3gORdyUuYnk1m4cMxUAdu5oy4n3OfN8flDEH+d60iG7dUfi0KkYwSvoalHzzdRzpWHTg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-dynamic-import": "^7.8.3" - } - }, - "@babel/plugin-proposal-export-namespace-from": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.16.7.tgz", - "integrity": "sha512-ZxdtqDXLRGBL64ocZcs7ovt71L3jhC1RGSyR996svrCi3PYqHNkb3SwPJCs8RIzD86s+WPpt2S73+EHCGO+NUA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3" - } - }, - "@babel/plugin-proposal-json-strings": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.7.tgz", - "integrity": "sha512-lNZ3EEggsGY78JavgbHsK9u5P3pQaW7k4axlgFLYkMd7UBsiNahCITShLjNQschPyjtO6dADrL24757IdhBrsQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-json-strings": "^7.8.3" - } - }, - "@babel/plugin-proposal-logical-assignment-operators": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.16.7.tgz", - "integrity": "sha512-K3XzyZJGQCr00+EtYtrDjmwX7o7PLK6U9bi1nCwkQioRFVUv6dJoxbQjtWVtP+bCPy82bONBKG8NPyQ4+i6yjg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" - } - }, - "@babel/plugin-proposal-nullish-coalescing-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.16.7.tgz", - "integrity": "sha512-aUOrYU3EVtjf62jQrCj63pYZ7k6vns2h/DQvHPWGmsJRYzWXZ6/AsfgpiRy6XiuIDADhJzP2Q9MwSMKauBQ+UQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" - } - }, - "@babel/plugin-proposal-numeric-separator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.16.7.tgz", - "integrity": "sha512-vQgPMknOIgiuVqbokToyXbkY/OmmjAzr/0lhSIbG/KmnzXPGwW/AdhdKpi+O4X/VkWiWjnkKOBiqJrTaC98VKw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-numeric-separator": "^7.10.4" - } - }, - "@babel/plugin-proposal-object-rest-spread": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.17.3.tgz", - "integrity": "sha512-yuL5iQA/TbZn+RGAfxQXfi7CNLmKi1f8zInn4IgobuCWcAb7i+zj4TYzQ9l8cEzVyJ89PDGuqxK1xZpUDISesw==", - "dev": true, - "requires": { - "@babel/compat-data": "^7.17.0", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.16.7" - } - }, - "@babel/plugin-proposal-optional-catch-binding": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.7.tgz", - "integrity": "sha512-eMOH/L4OvWSZAE1VkHbr1vckLG1WUcHGJSLqqQwl2GaUqG6QjddvrOaTUMNYiv77H5IKPMZ9U9P7EaHwvAShfA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" - } - }, - "@babel/plugin-proposal-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.7.tgz", - "integrity": "sha512-eC3xy+ZrUcBtP7x+sq62Q/HYd674pPTb/77XZMb5wbDPGWIdUbSr4Agr052+zaUPSb+gGRnjxXfKFvx5iMJ+DA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", - "@babel/plugin-syntax-optional-chaining": "^7.8.3" - } - }, - "@babel/plugin-proposal-private-methods": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz", - "integrity": "sha512-F/2uAkPlXDr8+BHpZvo19w3hLFKge+k75XUprE6jaqKxjGkSYcK+4c+bup5PdW/7W/Rpjwql7FTVEDW+fRAQsw==", - "dev": true, - "requires": { - "@babel/helper-create-class-features-plugin": "^7.16.10", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-proposal-private-property-in-object": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.7.tgz", - "integrity": "sha512-rMQkjcOFbm+ufe3bTZLyOfsOUOxyvLXZJCTARhJr+8UMSoZmqTe1K1BgkFcrW37rAchWg57yI69ORxiWvUINuQ==", - "dev": true, - "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5" - } - }, - "@babel/plugin-proposal-unicode-property-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.16.7.tgz", - "integrity": "sha512-QRK0YI/40VLhNVGIjRNAAQkEHws0cswSdFFjpFyt943YmJIU1da9uW63Iu6NFV6CxTZW5eTDCrwZUstBWgp/Rg==", - "dev": true, - "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-syntax-async-generators": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", - "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.0" - } - }, - "@babel/plugin-syntax-class-properties": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", - "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.12.13" - } - }, - "@babel/plugin-syntax-class-static-block": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", - "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.14.5" - } - }, - "@babel/plugin-syntax-dynamic-import": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", - "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.0" - } - }, - "@babel/plugin-syntax-export-namespace-from": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", - "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.3" - } - }, - "@babel/plugin-syntax-json-strings": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", - "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.0" - } - }, - "@babel/plugin-syntax-logical-assignment-operators": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", - "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.10.4" - } - }, - "@babel/plugin-syntax-nullish-coalescing-operator": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", - "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.0" - } - }, - "@babel/plugin-syntax-numeric-separator": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", - "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.10.4" - } - }, - "@babel/plugin-syntax-object-rest-spread": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", - "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.0" - } - }, - "@babel/plugin-syntax-optional-catch-binding": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", - "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.0" - } - }, - "@babel/plugin-syntax-optional-chaining": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", - "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.8.0" - } - }, - "@babel/plugin-syntax-private-property-in-object": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", - "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.14.5" - } - }, - "@babel/plugin-syntax-top-level-await": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", - "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.14.5" - } - }, - "@babel/plugin-syntax-typescript": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.16.7.tgz", - "integrity": "sha512-YhUIJHHGkqPgEcMYkPCKTyGUdoGKWtopIycQyjJH8OjvRgOYsXsaKehLVPScKJWAULPxMa4N1vCe6szREFlZ7A==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-arrow-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.7.tgz", - "integrity": "sha512-9ffkFFMbvzTvv+7dTp/66xvZAWASuPD5Tl9LK3Z9vhOmANo6j94rik+5YMBt4CwHVMWLWpMsriIc2zsa3WW3xQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.8.tgz", - "integrity": "sha512-MtmUmTJQHCnyJVrScNzNlofQJ3dLFuobYn3mwOTKHnSCMtbNsqvF71GQmJfFjdrXSsAA7iysFmYWw4bXZ20hOg==", - "dev": true, - "requires": { - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8" - } - }, - "@babel/plugin-transform-block-scoped-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.7.tgz", - "integrity": "sha512-JUuzlzmF40Z9cXyytcbZEZKckgrQzChbQJw/5PuEHYeqzCsvebDx0K0jWnIIVcmmDOAVctCgnYs0pMcrYj2zJg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-block-scoping": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.16.7.tgz", - "integrity": "sha512-ObZev2nxVAYA4bhyusELdo9hb3H+A56bxH3FZMbEImZFiEDYVHXQSJ1hQKFlDnlt8G9bBrCZ5ZpURZUrV4G5qQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-classes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.16.7.tgz", - "integrity": "sha512-WY7og38SFAGYRe64BrjKf8OrE6ulEHtr5jEYaZMwox9KebgqPi67Zqz8K53EKk1fFEJgm96r32rkKZ3qA2nCWQ==", - "dev": true, - "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "globals": "^11.1.0" - } - }, - "@babel/plugin-transform-computed-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.7.tgz", - "integrity": "sha512-gN72G9bcmenVILj//sv1zLNaPyYcOzUho2lIJBMh/iakJ9ygCo/hEF9cpGb61SCMEDxbbyBoVQxrt+bWKu5KGw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-destructuring": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.17.7.tgz", - "integrity": "sha512-XVh0r5yq9sLR4vZ6eVZe8FKfIcSgaTBxVBRSYokRj2qksf6QerYnTxz9/GTuKTH/n/HwLP7t6gtlybHetJ/6hQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-dotall-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.16.7.tgz", - "integrity": "sha512-Lyttaao2SjZF6Pf4vk1dVKv8YypMpomAbygW+mU5cYP3S5cWTfCJjG8xV6CFdzGFlfWK81IjL9viiTvpb6G7gQ==", - "dev": true, - "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-duplicate-keys": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.7.tgz", - "integrity": "sha512-03DvpbRfvWIXyK0/6QiR1KMTWeT6OcQ7tbhjrXyFS02kjuX/mu5Bvnh5SDSWHxyawit2g5aWhKwI86EE7GUnTw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-exponentiation-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.7.tgz", - "integrity": "sha512-8UYLSlyLgRixQvlYH3J2ekXFHDFLQutdy7FfFAMm3CPZ6q9wHCwnUyiXpQCe3gVVnQlHc5nsuiEVziteRNTXEA==", - "dev": true, - "requires": { - "@babel/helper-builder-binary-assignment-operator-visitor": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-for-of": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.16.7.tgz", - "integrity": "sha512-/QZm9W92Ptpw7sjI9Nx1mbcsWz33+l8kuMIQnDwgQBG5s3fAfQvkRjQ7NqXhtNcKOnPkdICmUHyCaWW06HCsqg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.16.7.tgz", - "integrity": "sha512-SU/C68YVwTRxqWj5kgsbKINakGag0KTgq9f2iZEXdStoAbOzLHEBRYzImmA6yFo8YZhJVflvXmIHUO7GWHmxxA==", - "dev": true, - "requires": { - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.7.tgz", - "integrity": "sha512-6tH8RTpTWI0s2sV6uq3e/C9wPo4PTqqZps4uF0kzQ9/xPLFQtipynvmT1g/dOfEJ+0EQsHhkQ/zyRId8J2b8zQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-member-expression-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.16.7.tgz", - "integrity": "sha512-mBruRMbktKQwbxaJof32LT9KLy2f3gH+27a5XSuXo6h7R3vqltl0PgZ80C8ZMKw98Bf8bqt6BEVi3svOh2PzMw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-modules-amd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.7.tgz", - "integrity": "sha512-KaaEtgBL7FKYwjJ/teH63oAmE3lP34N3kshz8mm4VMAw7U3PxjVwwUmxEFksbgsNUaO3wId9R2AVQYSEGRa2+g==", - "dev": true, - "requires": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" - } - }, - "@babel/plugin-transform-modules-commonjs": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.17.9.tgz", - "integrity": "sha512-2TBFd/r2I6VlYn0YRTz2JdazS+FoUuQ2rIFHoAxtyP/0G3D82SBLaRq9rnUkpqlLg03Byfl/+M32mpxjO6KaPw==", - "dev": true, - "requires": { - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-simple-access": "^7.17.7", - "babel-plugin-dynamic-import-node": "^2.3.3" - } - }, - "@babel/plugin-transform-modules-systemjs": { - "version": "7.17.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.17.8.tgz", - "integrity": "sha512-39reIkMTUVagzgA5x88zDYXPCMT6lcaRKs1+S9K6NKBPErbgO/w/kP8GlNQTC87b412ZTlmNgr3k2JrWgHH+Bw==", - "dev": true, - "requires": { - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" - } - }, - "@babel/plugin-transform-modules-umd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz", - "integrity": "sha512-EMh7uolsC8O4xhudF2F6wedbSHm1HHZ0C6aJ7K67zcDNidMzVcxWdGr+htW9n21klm+bOn+Rx4CBsAntZd3rEQ==", - "dev": true, - "requires": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.8.tgz", - "integrity": "sha512-j3Jw+n5PvpmhRR+mrgIh04puSANCk/T/UA3m3P1MjJkhlK906+ApHhDIqBQDdOgL/r1UYpz4GNclTXxyZrYGSw==", - "dev": true, - "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7" - } - }, - "@babel/plugin-transform-new-target": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.7.tgz", - "integrity": "sha512-xiLDzWNMfKoGOpc6t3U+etCE2yRnn3SM09BXqWPIZOBpL2gvVrBWUKnsJx0K/ADi5F5YC5f8APFfWrz25TdlGg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-object-super": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.7.tgz", - "integrity": "sha512-14J1feiQVWaGvRxj2WjyMuXS2jsBkgB3MdSN5HuC2G5nRspa5RK9COcs82Pwy5BuGcjb+fYaUj94mYcOj7rCvw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7" - } - }, - "@babel/plugin-transform-parameters": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.7.tgz", - "integrity": "sha512-AT3MufQ7zZEhU2hwOA11axBnExW0Lszu4RL/tAlUJBuNoRak+wehQW8h6KcXOcgjY42fHtDxswuMhMjFEuv/aw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-property-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.7.tgz", - "integrity": "sha512-z4FGr9NMGdoIl1RqavCqGG+ZuYjfZ/hkCIeuH6Do7tXmSm0ls11nYVSJqFEUOSJbDab5wC6lRE/w6YjVcr6Hqw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-regenerator": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.17.9.tgz", - "integrity": "sha512-Lc2TfbxR1HOyn/c6b4Y/b6NHoTb67n/IoWLxTu4kC7h4KQnWlhCq2S8Tx0t2SVvv5Uu87Hs+6JEJ5kt2tYGylQ==", - "dev": true, - "requires": { - "regenerator-transform": "^0.15.0" - } - }, - "@babel/plugin-transform-reserved-words": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.7.tgz", - "integrity": "sha512-KQzzDnZ9hWQBjwi5lpY5v9shmm6IVG0U9pB18zvMu2i4H90xpT4gmqwPYsn8rObiadYe2M0gmgsiOIF5A/2rtg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-shorthand-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz", - "integrity": "sha512-hah2+FEnoRoATdIb05IOXf+4GzXYTq75TVhIn1PewihbpyrNWUt2JbudKQOETWw6QpLe+AIUpJ5MVLYTQbeeUg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-spread": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.7.tgz", - "integrity": "sha512-+pjJpgAngb53L0iaA5gU/1MLXJIfXcYepLgXB3esVRf4fqmj8f2cxM3/FKaHsZms08hFQJkFccEWuIpm429TXg==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0" - } - }, - "@babel/plugin-transform-sticky-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.7.tgz", - "integrity": "sha512-NJa0Bd/87QV5NZZzTuZG5BPJjLYadeSZ9fO6oOUoL4iQx+9EEuw/eEM92SrsT19Yc2jgB1u1hsjqDtH02c3Drw==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-template-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.16.7.tgz", - "integrity": "sha512-VwbkDDUeenlIjmfNeDX/V0aWrQH2QiVyJtwymVQSzItFDTpxfyJh3EVaQiS0rIN/CqbLGr0VcGmuwyTdZtdIsA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-typeof-symbol": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.7.tgz", - "integrity": "sha512-p2rOixCKRJzpg9JB4gjnG4gjWkWa89ZoYUnl9snJ1cWIcTH/hvxZqfO+WjG6T8DRBpctEol5jw1O5rA8gkCokQ==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-typescript": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.16.8.tgz", - "integrity": "sha512-bHdQ9k7YpBDO2d0NVfkj51DpQcvwIzIusJ7mEUaMlbZq3Kt/U47j24inXZHQ5MDiYpCs+oZiwnXyKedE8+q7AQ==", - "dev": true, - "requires": { - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/plugin-syntax-typescript": "^7.16.7" - } - }, - "@babel/plugin-transform-unicode-escapes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.7.tgz", - "integrity": "sha512-TAV5IGahIz3yZ9/Hfv35TV2xEm+kaBDaZQCn2S/hG9/CZ0DktxJv9eKfPc7yYCvOYR4JGx1h8C+jcSOvgaaI/Q==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/plugin-transform-unicode-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.7.tgz", - "integrity": "sha512-oC5tYYKw56HO75KZVLQ+R/Nl3Hro9kf8iG0hXoaHP7tjAyCpvqBiSNe6vGrZni1Z6MggmUOC6A7VP7AVmw225Q==", - "dev": true, - "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" - } - }, - "@babel/preset-env": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.16.11.tgz", - "integrity": "sha512-qcmWG8R7ZW6WBRPZK//y+E3Cli151B20W1Rv7ln27vuPaXU/8TKms6jFdiJtF7UDTxcrb7mZd88tAeK9LjdT8g==", - "dev": true, - "requires": { - "@babel/compat-data": "^7.16.8", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-option": "^7.16.7", - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.7", - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-async-generator-functions": "^7.16.8", - "@babel/plugin-proposal-class-properties": "^7.16.7", - "@babel/plugin-proposal-class-static-block": "^7.16.7", - "@babel/plugin-proposal-dynamic-import": "^7.16.7", - "@babel/plugin-proposal-export-namespace-from": "^7.16.7", - "@babel/plugin-proposal-json-strings": "^7.16.7", - "@babel/plugin-proposal-logical-assignment-operators": "^7.16.7", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", - "@babel/plugin-proposal-numeric-separator": "^7.16.7", - "@babel/plugin-proposal-object-rest-spread": "^7.16.7", - "@babel/plugin-proposal-optional-catch-binding": "^7.16.7", - "@babel/plugin-proposal-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-private-methods": "^7.16.11", - "@babel/plugin-proposal-private-property-in-object": "^7.16.7", - "@babel/plugin-proposal-unicode-property-regex": "^7.16.7", - "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/plugin-syntax-class-properties": "^7.12.13", - "@babel/plugin-syntax-class-static-block": "^7.14.5", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3", - "@babel/plugin-syntax-json-strings": "^7.8.3", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-syntax-numeric-separator": "^7.10.4", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", - "@babel/plugin-syntax-optional-chaining": "^7.8.3", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5", - "@babel/plugin-syntax-top-level-await": "^7.14.5", - "@babel/plugin-transform-arrow-functions": "^7.16.7", - "@babel/plugin-transform-async-to-generator": "^7.16.8", - "@babel/plugin-transform-block-scoped-functions": "^7.16.7", - "@babel/plugin-transform-block-scoping": "^7.16.7", - "@babel/plugin-transform-classes": "^7.16.7", - "@babel/plugin-transform-computed-properties": "^7.16.7", - "@babel/plugin-transform-destructuring": "^7.16.7", - "@babel/plugin-transform-dotall-regex": "^7.16.7", - "@babel/plugin-transform-duplicate-keys": "^7.16.7", - "@babel/plugin-transform-exponentiation-operator": "^7.16.7", - "@babel/plugin-transform-for-of": "^7.16.7", - "@babel/plugin-transform-function-name": "^7.16.7", - "@babel/plugin-transform-literals": "^7.16.7", - "@babel/plugin-transform-member-expression-literals": "^7.16.7", - "@babel/plugin-transform-modules-amd": "^7.16.7", - "@babel/plugin-transform-modules-commonjs": "^7.16.8", - "@babel/plugin-transform-modules-systemjs": "^7.16.7", - "@babel/plugin-transform-modules-umd": "^7.16.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.8", - "@babel/plugin-transform-new-target": "^7.16.7", - "@babel/plugin-transform-object-super": "^7.16.7", - "@babel/plugin-transform-parameters": "^7.16.7", - "@babel/plugin-transform-property-literals": "^7.16.7", - "@babel/plugin-transform-regenerator": "^7.16.7", - "@babel/plugin-transform-reserved-words": "^7.16.7", - "@babel/plugin-transform-shorthand-properties": "^7.16.7", - "@babel/plugin-transform-spread": "^7.16.7", - "@babel/plugin-transform-sticky-regex": "^7.16.7", - "@babel/plugin-transform-template-literals": "^7.16.7", - "@babel/plugin-transform-typeof-symbol": "^7.16.7", - "@babel/plugin-transform-unicode-escapes": "^7.16.7", - "@babel/plugin-transform-unicode-regex": "^7.16.7", - "@babel/preset-modules": "^0.1.5", - "@babel/types": "^7.16.8", - "babel-plugin-polyfill-corejs2": "^0.3.0", - "babel-plugin-polyfill-corejs3": "^0.5.0", - "babel-plugin-polyfill-regenerator": "^0.3.0", - "core-js-compat": "^3.20.2", - "semver": "^6.3.0" - } - }, - "@babel/preset-modules": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.5.tgz", - "integrity": "sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", - "@babel/plugin-transform-dotall-regex": "^7.4.4", - "@babel/types": "^7.4.4", - "esutils": "^2.0.2" - } - }, - "@babel/register": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.17.7.tgz", - "integrity": "sha512-fg56SwvXRifootQEDQAu1mKdjh5uthPzdO0N6t358FktfL4XjAVXuH58ULoiW8mesxiOgNIrxiImqEwv0+hRRA==", - "dev": true, - "requires": { - "clone-deep": "^4.0.1", - "find-cache-dir": "^2.0.0", - "make-dir": "^2.1.0", - "pirates": "^4.0.5", - "source-map-support": "^0.5.16" - } - }, - "@babel/runtime": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", - "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", - "dev": true, - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" - } - }, - "@babel/traverse": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.9.tgz", - "integrity": "sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.17.9", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.9", - "@babel/types": "^7.17.0", - "debug": "^4.1.0", - "globals": "^11.1.0" - } - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - }, - "@bcoe/v8-coverage": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", - "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", - "dev": true - }, - "@cspell/cspell-bundled-dicts": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.19.7.tgz", - "integrity": "sha512-9h2KdI3yKODc8rAxkgB5UZb6RLwwEO25Fo91vnOtM1xfwLhX/scMACU1DoqtnTVaE73HoQ46DYAZAAq/OloRFQ==", - "dev": true, - "requires": { - "@cspell/dict-ada": "^2.0.0", - "@cspell/dict-aws": "^2.0.0", - "@cspell/dict-bash": "^2.0.2", - "@cspell/dict-companies": "^2.0.3", - "@cspell/dict-cpp": "^2.0.2", - "@cspell/dict-cryptocurrencies": "^2.0.0", - "@cspell/dict-csharp": "^2.0.1", - "@cspell/dict-css": "^2.0.0", - "@cspell/dict-dart": "^1.1.0", - "@cspell/dict-django": "^2.0.0", - "@cspell/dict-dotnet": "^2.0.1", - "@cspell/dict-elixir": "^2.0.1", - "@cspell/dict-en_us": "^2.2.0", - "@cspell/dict-en-gb": "^1.1.33", - "@cspell/dict-filetypes": "^2.0.1", - "@cspell/dict-fonts": "^2.0.0", - "@cspell/dict-fullstack": "^2.0.4", - "@cspell/dict-git": "^1.0.1", - "@cspell/dict-golang": "^2.0.0", - "@cspell/dict-haskell": "^2.0.0", - "@cspell/dict-html": "^3.0.1", - "@cspell/dict-html-symbol-entities": "^2.0.0", - "@cspell/dict-java": "^2.0.0", - "@cspell/dict-latex": "^2.0.0", - "@cspell/dict-lorem-ipsum": "^2.0.0", - "@cspell/dict-lua": "^2.0.0", - "@cspell/dict-node": "^2.0.0", - "@cspell/dict-npm": "^2.0.2", - "@cspell/dict-php": "^2.0.0", - "@cspell/dict-powershell": "^2.0.0", - "@cspell/dict-public-licenses": "^1.0.4", - "@cspell/dict-python": "^2.0.6", - "@cspell/dict-r": "^1.0.2", - "@cspell/dict-ruby": "^2.0.1", - "@cspell/dict-rust": "^2.0.0", - "@cspell/dict-scala": "^2.0.0", - "@cspell/dict-software-terms": "^2.1.4", - "@cspell/dict-swift": "^1.0.2", - "@cspell/dict-typescript": "^2.0.0", - "@cspell/dict-vue": "^2.0.2" - } - }, - "@cspell/cspell-pipe": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-5.19.7.tgz", - "integrity": "sha512-C2+qovrXyZtoM+IcyMuwwYieoGBwwnWORat+j7bkIkVHf6Pa9spxY3D1IdLt04PqWBKWKHb1g9KzJzw5grBqZw==", - "dev": true - }, - "@cspell/cspell-types": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-5.19.7.tgz", - "integrity": "sha512-xL9a0oE8kPQ/GCkE/bxE5DTCMTctCpk7tdrhYG26wVbMK1VRGo8fv9w+vRVzXgTfF5jTxolEA1LTtfVBuik1MA==", - "dev": true - }, - "@cspell/dict-ada": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-ada/-/dict-ada-2.0.0.tgz", - "integrity": "sha512-4gfJEYXVwz6IN2LBaT6QoUV4pqaR35i0z0u9O684vLuVczvNJIHa4vNaSEFBr9d6xxncUyqstgP9P73ajJjh9A==", - "dev": true - }, - "@cspell/dict-aws": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-aws/-/dict-aws-2.0.0.tgz", - "integrity": "sha512-NKz7pDZ7pwj/b33i3f4WLpC1rOOUMmENwYgftxU+giU2YBeKM2wZbMTSEIzsrel56r0UlQYmdIVlP/B4nnVaoQ==", - "dev": true - }, - "@cspell/dict-bash": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-bash/-/dict-bash-2.0.2.tgz", - "integrity": "sha512-ASIgI/LmV2TYrD4mtk+gm4XmUSTRomOyRt7NDWyBpEww/AeawC2O2NH6FosyUT6dUU3GaXt2wgJRN7R78n1SGg==", - "dev": true - }, - "@cspell/dict-companies": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-2.0.3.tgz", - "integrity": "sha512-O622rMAaHm85AmqNyMki5je8HB/1XlTKbGOXh2UUhooI5qdgdfrjTQ6VBuHwHrfEfuODBHYTNYXVB2m23XqHCg==", - "dev": true - }, - "@cspell/dict-cpp": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-cpp/-/dict-cpp-2.0.3.tgz", - "integrity": "sha512-aWRvI3CQW2M3XeJpDVffItw/9n4hxsN5EPwyBa6Po6EnCxZZZLOqpieZk4JNz4pH0/xbnOX+sMMuSeKWr71r/w==", - "dev": true - }, - "@cspell/dict-cryptocurrencies": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-cryptocurrencies/-/dict-cryptocurrencies-2.0.0.tgz", - "integrity": "sha512-nREysmmfOp7L2YCRAUufQahwD5/Punzb5AZ6eyg4zUamdRWHgBFphb5/9h2flt1vgdUfhc6hZcML21Ci7iXjaA==", - "dev": true - }, - "@cspell/dict-csharp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-csharp/-/dict-csharp-2.0.1.tgz", - "integrity": "sha512-ZzAr+WRP2FUtXHZtfhe8f3j9vPjH+5i44Hcr5JqbWxmqciGoTbWBPQXwu9y+J4mbdC69HSWRrVGkNJ8rQk8pSw==", - "dev": true - }, - "@cspell/dict-css": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-css/-/dict-css-2.0.0.tgz", - "integrity": "sha512-MrFyswFHnPh4H0u6IlV4eHy+ZCUrrHzeL161LyTOqCvaKpbZavMgNYXzZqTF9xafO0iLgwKrl+Gkclu1KVBg0Q==", - "dev": true - }, - "@cspell/dict-dart": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-dart/-/dict-dart-1.1.0.tgz", - "integrity": "sha512-bBqZINm+RVjMgUrAhRzv/xx3jc3dkIqO0higPbsK+63IAtMNY3EiQnEO4eapbU+qAhyvICY9hZQZXy5Ux4p+Pw==", - "dev": true - }, - "@cspell/dict-django": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-django/-/dict-django-2.0.0.tgz", - "integrity": "sha512-GkJdJv6cmzrKcmq2/oxTXjKF5uv71r4eTqnFmgPbNBW1t+G4VYpzOf0QrVQrhx2RC4DdW5XfcTf+iS0FxHOTmw==", - "dev": true - }, - "@cspell/dict-dotnet": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-dotnet/-/dict-dotnet-2.0.1.tgz", - "integrity": "sha512-b1n4crJRW0WZVf9Gp/52j/tDtjYiZ3N81fIyfqPlBrjsh/5AivfA697DYwQ2mr8ngNX7RsqRtYNQjealA1rEnQ==", - "dev": true - }, - "@cspell/dict-elixir": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-elixir/-/dict-elixir-2.0.1.tgz", - "integrity": "sha512-eTTTxZt1FqGkM780yFDxsGHvTbWqvlK8YISSccK8FyrB6ULW+uflQlNS5AnWg3uWKC48b7pQott+odYCsPJ+Ow==", - "dev": true - }, - "@cspell/dict-en_us": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-en_us/-/dict-en_us-2.2.0.tgz", - "integrity": "sha512-IJWu8MI2NdLyPzekrMi9K+v71b0qjDE+z/BccoMA/APnphqgSNM8BDUAzhio6mPKi1AvPRCNUjk79oiUfp+1Gw==", - "dev": true - }, - "@cspell/dict-en-gb": { - "version": "1.1.33", - "resolved": "https://registry.npmjs.org/@cspell/dict-en-gb/-/dict-en-gb-1.1.33.tgz", - "integrity": "sha512-tKSSUf9BJEV+GJQAYGw5e+ouhEe2ZXE620S7BLKe3ZmpnjlNG9JqlnaBhkIMxKnNFkLY2BP/EARzw31AZnOv4g==", - "dev": true - }, - "@cspell/dict-filetypes": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-filetypes/-/dict-filetypes-2.0.1.tgz", - "integrity": "sha512-bQ7K3U/3hKO2lpQjObf0veNP/n50qk5CVezSwApMBckf/sAVvDTR1RGAvYdr+vdQnkdQrk6wYmhbshXi0sLDVg==", - "dev": true - }, - "@cspell/dict-fonts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-fonts/-/dict-fonts-2.0.0.tgz", - "integrity": "sha512-AgkTalphfDPtKFPYmEExDcj8rRCh86xlOSXco8tehOEkYVYbksOk9XH0YVH34RFpy93YBd2nnVGLgyGVwagcPw==", - "dev": true - }, - "@cspell/dict-fullstack": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-fullstack/-/dict-fullstack-2.0.4.tgz", - "integrity": "sha512-+JtYO58QAXnetRN+MGVzI8YbkbFTLpYfl/Cw/tmNqy7U1IDVC4sTXQ2pZvbbeKQWFHBqYvBs0YASV+mTouXYBw==", - "dev": true - }, - "@cspell/dict-git": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-git/-/dict-git-1.0.1.tgz", - "integrity": "sha512-Rk+eTof/9inF11lvxmkCRK+gODatA3qai8kSASv6OG/JfPvpj7fTHErx/rdgPw/LOTDUafnoTjTYmj7B2MOQXg==", - "dev": true - }, - "@cspell/dict-golang": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-golang/-/dict-golang-2.0.0.tgz", - "integrity": "sha512-rUeZJR/S/ZjAsOURtxsAO6xDQhL0IzF458ScahaeOqe0zVL3tx7tCLikCgT92NWPs3BNqmsZGqYSDbn/1KsSIA==", - "dev": true - }, - "@cspell/dict-haskell": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-haskell/-/dict-haskell-2.0.0.tgz", - "integrity": "sha512-cjX1Br+gSWqtcmJD/IMHz1UoP3pUaKIIKy/JfhEs7ANtRt6hhfEKe9dl2kQzDkkKt4pXol+YgdYxL/sVc/nLgQ==", - "dev": true - }, - "@cspell/dict-html": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-html/-/dict-html-3.0.1.tgz", - "integrity": "sha512-sbuFd+nSjgbrGf5eYwSddFhm1eLLePKWyH6Zn8Zb0OODrBK5e4vGn1/scI/MOH5a2IvNs8W9wp84uMBFJcQZtw==", - "dev": true - }, - "@cspell/dict-html-symbol-entities": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-html-symbol-entities/-/dict-html-symbol-entities-2.0.0.tgz", - "integrity": "sha512-71S5wGCe7dq6C+zGDwsEAe5msub/irrLi6SExeG11a/EkpA3RKAEheDGPk0hOY4+vOcIFHaApxOjLTtgQfYWfA==", - "dev": true - }, - "@cspell/dict-java": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-java/-/dict-java-2.0.0.tgz", - "integrity": "sha512-9f5LDATlAiXRGqxLxgqbOLlQxuMW2zcN7tBgxwtN+4u90vM03ZUOR/gKIuDV/y0ZuAiWBIjA73cjk8DJ13Q1eA==", - "dev": true - }, - "@cspell/dict-latex": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-latex/-/dict-latex-2.0.0.tgz", - "integrity": "sha512-H6RRwbHhQ9ARoO1R57SDqB+q/J5jUDdVnkdfukJkA+HNlJBhCcDuzGOIJqr+GBkJYDkF3obZ3LEOk2lUfT+Eyg==", - "dev": true - }, - "@cspell/dict-lorem-ipsum": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-lorem-ipsum/-/dict-lorem-ipsum-2.0.0.tgz", - "integrity": "sha512-jKogAKtqvgPMleL6usyj3rZ0m8sVUR6drrD+wMnWSfdx1BmUyTsYiuh/mPEfLAebaYHELWSLQG3rDZRvV9Riqg==", - "dev": true - }, - "@cspell/dict-lua": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-lua/-/dict-lua-2.0.0.tgz", - "integrity": "sha512-7WUEBEspSKtsq104WdIys1+DLqAxpJPzw74Py1TuE3fI5GvlzeSZkRFP2ya54GB2lCO4C3mq4M8EnitpibVDfw==", - "dev": true - }, - "@cspell/dict-node": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-node/-/dict-node-2.0.0.tgz", - "integrity": "sha512-tPPl3liJORa/l6AoYqh/7rjoM7bdtaIXnIN6ox7CE0flZcBS5rWOB6mzEY3rpu/XJX0pjbBiIoqrolDkVl1RTQ==", - "dev": true - }, - "@cspell/dict-npm": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-npm/-/dict-npm-2.0.2.tgz", - "integrity": "sha512-Q5ua0aeKTxW4WxvtU+UMdct46hCStOTeEiiG8iinTh/mH5brmdtMEj4olO8+mmkAKPpIC4TI3TmaaN6RN+Vpgw==", - "dev": true - }, - "@cspell/dict-php": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-php/-/dict-php-2.0.0.tgz", - "integrity": "sha512-29WgU77eTO985LvMHwPi1pcpfopfCWfTdffDyqya0JIfOSaFUrlYKzGPkE4mRxcz2G3hXsaM0SRvBNdIRwEdUg==", - "dev": true - }, - "@cspell/dict-powershell": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-powershell/-/dict-powershell-2.0.0.tgz", - "integrity": "sha512-6uvEhLiGmG3u9TFkM1TYcky6aL9Yk7Sk3KJwoTYBaQJY2KqrprgyQtW6yxIw9oU52VRHlq3KKvSAA9Q26+SIkQ==", - "dev": true - }, - "@cspell/dict-public-licenses": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-public-licenses/-/dict-public-licenses-1.0.4.tgz", - "integrity": "sha512-h4xULfVEDUeWyvp1OO19pcGDqWcBEQ7WGMp3QBHyYpjsamlzsyYYjCRSY2ZvpM7wruDmywSRFmRHJ/+uNFT7nA==", - "dev": true - }, - "@cspell/dict-python": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-2.0.6.tgz", - "integrity": "sha512-54ICgMRiGwavorg8UJC38Fwx8tW8WKj8pimJmFUd0F/ImQ8wmeg4VrmyMach5MZVUaw1qUe2aP5uSyqA15Q0mg==", - "dev": true - }, - "@cspell/dict-r": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-r/-/dict-r-1.0.2.tgz", - "integrity": "sha512-Rp3d4sgD6izW9TW5yVI3D//3HTl9oOGBuzTvXRdoHksVPRvzIu2liVhj8MnQ3XIRe5Kc6IhLBAm6izuV2BpGwQ==", - "dev": true - }, - "@cspell/dict-ruby": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@cspell/dict-ruby/-/dict-ruby-2.0.1.tgz", - "integrity": "sha512-qGqhYfFeoBOashv/l0Kj5o4ilyvfq0s+t+r32juPOkOnbHz+hzxnJo2tMMg/L/UdjVV7Y8ovg4LDBC/seVrMYQ==", - "dev": true - }, - "@cspell/dict-rust": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-rust/-/dict-rust-2.0.0.tgz", - "integrity": "sha512-EWlQivTKXMU3TTcq/Pi6KPKTQADknasQ700UrxRPzxhwQ4sKVZ88GDu6VZJlsbFUz8Vko289KS6wjiox/7WpmQ==", - "dev": true - }, - "@cspell/dict-scala": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-scala/-/dict-scala-2.0.0.tgz", - "integrity": "sha512-MUwA2YKpqaQOSR4V1/CVGRNk8Ii5kf6I8Ch+4/BhRZRQXuwWbi21rDRYWPqdQWps7VNzAbbMA+PQDWsD5YY38g==", - "dev": true - }, - "@cspell/dict-software-terms": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-2.1.4.tgz", - "integrity": "sha512-MB2eT9qhbnIEJajGv+ndzzi6S8NCJ9cMyeGJYMoRAiJobTKP6xPrT37VjPzhckRtrHJGG//UgtQ4NsiK5aBITw==", - "dev": true - }, - "@cspell/dict-swift": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-swift/-/dict-swift-1.0.2.tgz", - "integrity": "sha512-IrMcRO7AYB2qU5cj4ttZyEbd04DRNOG6Iha106qGGmn4P096m+Y7lOnSLJx/rZbD/cAT3Z/7i465Lr1J93j7yg==", - "dev": true - }, - "@cspell/dict-typescript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cspell/dict-typescript/-/dict-typescript-2.0.0.tgz", - "integrity": "sha512-WFBahxsnD2y4Os14tE5Zxh31Ggn4DzGOAu3UoxYl1lLLxaszx4RH7LmAeFuznySboiaBeRBbpfJOjQA796O6VQ==", - "dev": true - }, - "@cspell/dict-vue": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-vue/-/dict-vue-2.0.2.tgz", - "integrity": "sha512-/MB0RS0Gn01s4pgmjy0FvsLfr3RRMrRphEuvTRserNcM8XVtoIVAtrjig/Gg0DPwDrN8Clm0L1j7iQay6S8D0g==", - "dev": true - }, - "@eslint/eslintrc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", - "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" - }, - "dependencies": { - "globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - } - } - }, - "@humanwhocodes/config-array": { - "version": "0.9.5", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz", - "integrity": "sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==", - "dev": true, - "requires": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.4" - } - }, - "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", - "dev": true - }, - "@istanbuljs/schema": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", - "dev": true - }, - "@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", - "dev": true - }, - "@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", - "dev": true - }, - "@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "@microsoft/tsdoc": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.14.1.tgz", - "integrity": "sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==", - "dev": true - }, - "@microsoft/tsdoc-config": { - "version": "0.16.1", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.16.1.tgz", - "integrity": "sha512-2RqkwiD4uN6MLnHFljqBlZIXlt/SaUT6cuogU1w2ARw4nKuuppSmR0+s+NC+7kXBQykd9zzu0P4HtBpZT5zBpQ==", - "dev": true, - "requires": { - "@microsoft/tsdoc": "0.14.1", - "ajv": "~6.12.6", - "jju": "~1.4.0", - "resolve": "~1.19.0" - }, - "dependencies": { - "resolve": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", - "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", - "dev": true, - "requires": { - "is-core-module": "^2.1.0", - "path-parse": "^1.0.6" - } - } - } - }, - "@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - } - }, - "@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true - }, - "@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "requires": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - } - }, - "@types/chai": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.1.tgz", - "integrity": "sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==", - "dev": true - }, - "@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", - "dev": true - }, - "@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", - "dev": true - }, - "@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", - "dev": true - }, - "@types/mocha": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", - "integrity": "sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg==", - "dev": true - }, - "@types/node": { - "version": "17.0.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.24.tgz", - "integrity": "sha512-aveCYRQbgTH9Pssp1voEP7HiuWlD2jW2BO56w+bVrJn04i61yh6mRfoKO6hEYQD9vF+W8Chkwc6j1M36uPkx4g==", - "dev": true - }, - "@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true - }, - "@typescript-eslint/eslint-plugin": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz", - "integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==", - "dev": true, - "requires": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/type-utils": "5.19.0", - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "functional-red-black-tree": "^1.0.1", - "ignore": "^5.1.8", - "regexpp": "^3.2.0", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - }, - "dependencies": { - "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, - "@typescript-eslint/parser": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz", - "integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==", - "dev": true, - "requires": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "debug": "^4.3.2" - } - }, - "@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - } - }, - "@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", - "dev": true, - "requires": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", - "debug": "^4.3.2", - "globby": "^11.0.4", - "is-glob": "^4.0.3", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - }, - "dependencies": { - "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, - "@typescript-eslint/utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", - "integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==", - "dev": true, - "requires": { - "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - } - }, - "@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, - "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", - "dev": true - }, - "acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} - }, - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "array-includes": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", - "integrity": "sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", - "get-intrinsic": "^1.1.1", - "is-string": "^1.0.7" - } - }, - "array-timsort": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-timsort/-/array-timsort-1.0.3.tgz", - "integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==", - "dev": true - }, - "array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true - }, - "array.prototype.flat": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", - "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.2", - "es-shim-unscopables": "^1.0.0" - } - }, - "array.prototype.flatmap": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.0.tgz", - "integrity": "sha512-PZC9/8TKAIxcWKdyeb77EzULHPrIX/tIZebLJUQOMR1OwYosT8yggdfWScfTBCDj5utONvOuPQQumYsU2ULbkg==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.2", - "es-shim-unscopables": "^1.0.0" - } - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, - "babel-plugin-dynamic-import-node": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", - "integrity": "sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==", - "dev": true, - "requires": { - "object.assign": "^4.1.0" - } - }, - "babel-plugin-polyfill-corejs2": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz", - "integrity": "sha512-v7/T6EQcNfVLfcN2X8Lulb7DjprieyLWJK/zOWH5DUYcAgex9sP3h25Q+DLsX9TloXe3y1O8l2q2Jv9q8UVB9w==", - "dev": true, - "requires": { - "@babel/compat-data": "^7.13.11", - "@babel/helper-define-polyfill-provider": "^0.3.1", - "semver": "^6.1.1" - } - }, - "babel-plugin-polyfill-corejs3": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", - "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", - "dev": true, - "requires": { - "@babel/helper-define-polyfill-provider": "^0.3.1", - "core-js-compat": "^3.21.0" - } - }, - "babel-plugin-polyfill-regenerator": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.1.tgz", - "integrity": "sha512-Y2B06tvgHYt1x0yz17jGkGeeMr5FeKUu+ASJ+N6nB5lQ8Dapfg42i0OVrf8PNGJ3zKL4A23snMi1IRwrqqND7A==", - "dev": true, - "requires": { - "@babel/helper-define-polyfill-provider": "^0.3.1" - } - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "requires": { - "fill-range": "^7.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "browserslist": { - "version": "4.20.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.2.tgz", - "integrity": "sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA==", - "dev": true, - "requires": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", - "escalade": "^3.1.1", - "node-releases": "^2.0.2", - "picocolors": "^1.0.0" - } - }, - "buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true - }, - "c8": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/c8/-/c8-7.11.0.tgz", - "integrity": "sha512-XqPyj1uvlHMr+Y1IeRndC2X5P7iJzJlEJwBpCdBbq2JocXOgJfr+JVfJkyNMGROke5LfKrhSFXGFXnwnRJAUJw==", - "dev": true, - "requires": { - "@bcoe/v8-coverage": "^0.2.3", - "@istanbuljs/schema": "^0.1.2", - "find-up": "^5.0.0", - "foreground-child": "^2.0.0", - "istanbul-lib-coverage": "^3.0.1", - "istanbul-lib-report": "^3.0.0", - "istanbul-reports": "^3.0.2", - "rimraf": "^3.0.0", - "test-exclude": "^6.0.0", - "v8-to-istanbul": "^8.0.0", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.7" - } - }, - "call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - } - }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true - }, - "camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true - }, - "caniuse-lite": { - "version": "1.0.30001332", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz", - "integrity": "sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw==", - "dev": true - }, - "chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, - "chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "clear-module": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/clear-module/-/clear-module-4.1.2.tgz", - "integrity": "sha512-LWAxzHqdHsAZlPlEyJ2Poz6AIs384mPeqLVCru2p0BrP9G/kVGuhNyZYClLO6cXlnuJjzC8xtsJIuMjKqLXoAw==", - "dev": true, - "requires": { - "parent-module": "^2.0.0", - "resolve-from": "^5.0.0" - } - }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - } - } - }, - "clone-deep": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", - "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4", - "kind-of": "^6.0.2", - "shallow-clone": "^3.0.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "comment-json": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.2.tgz", - "integrity": "sha512-H8T+kl3nZesZu41zO2oNXIJWojNeK3mHxCLrsBNu6feksBXsgb+PtYz5daP5P86A0F3sz3840KVYehr04enISQ==", - "dev": true, - "requires": { - "array-timsort": "^1.0.3", - "core-util-is": "^1.0.3", - "esprima": "^4.0.1", - "has-own-prop": "^2.0.0", - "repeat-string": "^1.6.1" - } - }, - "commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "configstore": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.1.tgz", - "integrity": "sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==", - "dev": true, - "requires": { - "dot-prop": "^5.2.0", - "graceful-fs": "^4.1.2", - "make-dir": "^3.0.0", - "unique-string": "^2.0.0", - "write-file-atomic": "^3.0.0", - "xdg-basedir": "^4.0.0" - }, - "dependencies": { - "make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dev": true, - "requires": { - "semver": "^6.0.0" - } - } - } - }, - "convert-source-map": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", - "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.1" - } - }, - "core-js-compat": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.1.tgz", - "integrity": "sha512-gbgX5AUvMb8gwxC7FLVWYT7Kkgu/y7+h/h1X43yJkNqhlK2fuYyQimqvKGNZFAY6CKii/GFKJ2cp/1/42TN36g==", - "dev": true, - "requires": { - "browserslist": "^4.19.1", - "semver": "7.0.0" - }, - "dependencies": { - "semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true - } - } - }, - "core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true - }, - "cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", - "dev": true, - "requires": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - } - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "crypto-random-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", - "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", - "dev": true - }, - "cspell": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell/-/cspell-5.19.7.tgz", - "integrity": "sha512-7/y+k708tv68+5lpN23Ew1/djx/EnG838zZ8W2ZDWCc6uRHutqRhpxsjMZr/MT3RHN44iKUj2MgT5+sfnhr4eg==", - "dev": true, - "requires": { - "@cspell/cspell-pipe": "^5.19.7", - "chalk": "^4.1.2", - "commander": "^9.1.0", - "cspell-gitignore": "^5.19.7", - "cspell-glob": "^5.19.7", - "cspell-lib": "^5.19.7", - "fast-json-stable-stringify": "^2.1.0", - "file-entry-cache": "^6.0.1", - "fs-extra": "^10.0.1", - "get-stdin": "^8.0.0", - "glob": "^7.2.0", - "imurmurhash": "^0.1.4", - "semver": "^7.3.6", - "strip-ansi": "^6.0.1", - "vscode-uri": "^3.0.3" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "commander": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.1.0.tgz", - "integrity": "sha512-i0/MaqBtdbnJ4XQs4Pmyb+oFQl+q0lsAmokVUH92SlSw4fkeAcG3bVon+Qt7hmtF+u3Het6o4VgrcY3qAoEB6w==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "cspell-gitignore": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-5.19.7.tgz", - "integrity": "sha512-rEqlN6wigNj4P/4Z3QCI1P56KhKkPtXNBpGMXC5CbxIK/NTtn3cLaqHKIZp92pypEnU077lxSCSqRRYCPbg/6A==", - "dev": true, - "requires": { - "cspell-glob": "^5.19.7", - "find-up": "^5.0.0" - } - }, - "cspell-glob": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-5.19.7.tgz", - "integrity": "sha512-fqlF7oqYTT2A3SRfQr7gzN21fwPoRO9IGKec1L3QeGkni5UPDxGrM2a5z+oLaYs2GN5pEf29BXVlN7dq0jVxIg==", - "dev": true, - "requires": { - "micromatch": "^4.0.5" - } - }, - "cspell-io": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-5.19.7.tgz", - "integrity": "sha512-SEy8XkuOhvwleGjh336EBYj5HlH1J5FrCI5GxxGiU2g8zvWlBPQmaCfQPPO4tnDrrXtK76rZvolBu1jfCmWwQA==", - "dev": true - }, - "cspell-lib": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-5.19.7.tgz", - "integrity": "sha512-d4ewH1RBgcBE9NqAh0FexmVQ6YvkDQv9XOysskeDH+G9wm975owENUU/mBd8AyBt2b4YXL/FoLtaKd/7MRoNDA==", - "dev": true, - "requires": { - "@cspell/cspell-bundled-dicts": "^5.19.7", - "@cspell/cspell-pipe": "^5.19.7", - "@cspell/cspell-types": "^5.19.7", - "clear-module": "^4.1.2", - "comment-json": "^4.2.2", - "configstore": "^5.0.1", - "cosmiconfig": "^7.0.1", - "cspell-glob": "^5.19.7", - "cspell-io": "^5.19.7", - "cspell-trie-lib": "^5.19.7", - "fast-equals": "^3.0.1", - "find-up": "^5.0.0", - "fs-extra": "^10.0.1", - "gensequence": "^3.1.1", - "import-fresh": "^3.3.0", - "resolve-from": "^5.0.0", - "resolve-global": "^1.0.0", - "vscode-languageserver-textdocument": "^1.0.4", - "vscode-uri": "^3.0.3" - } - }, - "cspell-trie-lib": { - "version": "5.19.7", - "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-5.19.7.tgz", - "integrity": "sha512-qr0HS2hGuyIQhDGG5li0nqIjVi039iPRHR8wpeDoSO0YIBCll22i/VlvW3CSmqXLaP5RRoAc9txiZkIGob6DkQ==", - "dev": true, - "requires": { - "@cspell/cspell-pipe": "^5.19.7", - "fs-extra": "^10.0.1", - "gensequence": "^3.1.1" - } - }, - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, - "deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true - }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, - "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", - "dev": true - }, - "dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "requires": { - "path-type": "^4.0.0" - } - }, - "doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "dot-prop": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", - "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", - "dev": true, - "requires": { - "is-obj": "^2.0.0" - } - }, - "electron-to-chromium": { - "version": "1.4.107", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.107.tgz", - "integrity": "sha512-Huen6taaVrUrSy8o7mGStByba8PfOWWluHNxSHGBrCgEdFVLtvdQDBr9LBCF9Uci8SYxh28QNNMO0oC17wbGAg==", - "dev": true - }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "es-abstract": { - "version": "1.19.5", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.5.tgz", - "integrity": "sha512-Aa2G2+Rd3b6kxEUKTF4TaW67czBLyAv3z7VOhYRU50YBx+bbsYZ9xQP4lMNazePuFlybXI0V4MruPos7qUo5fA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "get-intrinsic": "^1.1.1", - "get-symbol-description": "^1.0.0", - "has": "^1.0.3", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "is-callable": "^1.2.4", - "is-negative-zero": "^2.0.2", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "is-string": "^1.0.7", - "is-weakref": "^1.0.2", - "object-inspect": "^1.12.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" - } - }, - "es-shim-unscopables": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", - "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "eslint": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.13.0.tgz", - "integrity": "sha512-D+Xei61eInqauAyTJ6C0q6x9mx7kTUC1KZ0m0LSEexR0V+e94K12LmWX076ZIsldwfQ2RONdaJe0re0TRGQbRQ==", - "dev": true, - "requires": { - "@eslint/eslintrc": "^1.2.1", - "@humanwhocodes/config-array": "^0.9.2", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", - "globals": "^13.6.0", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - } - }, - "glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "requires": { - "is-glob": "^4.0.3" - } - }, - "globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - } - } - }, - "eslint-import-resolver-node": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", - "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", - "dev": true, - "requires": { - "debug": "^3.2.7", - "resolve": "^1.20.0" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "eslint-module-utils": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz", - "integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==", - "dev": true, - "requires": { - "debug": "^3.2.7", - "find-up": "^2.1.0" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - } - } - }, - "eslint-plugin-es": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", - "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", - "dev": true, - "requires": { - "eslint-utils": "^2.0.0", - "regexpp": "^3.0.0" - }, - "dependencies": { - "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } - } - }, - "eslint-plugin-import": { - "version": "2.26.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", - "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", - "dev": true, - "requires": { - "array-includes": "^3.1.4", - "array.prototype.flat": "^1.2.5", - "debug": "^2.6.9", - "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.3", - "has": "^1.0.3", - "is-core-module": "^2.8.1", - "is-glob": "^4.0.3", - "minimatch": "^3.1.2", - "object.values": "^1.1.5", - "resolve": "^1.22.0", - "tsconfig-paths": "^3.14.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "eslint-plugin-internal-rules": { - "version": "file:resources/eslint-internal-rules" - }, - "eslint-plugin-node": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", - "integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==", - "dev": true, - "requires": { - "eslint-plugin-es": "^3.0.0", - "eslint-utils": "^2.0.0", - "ignore": "^5.1.1", - "minimatch": "^3.0.4", - "resolve": "^1.10.1", - "semver": "^6.1.0" - }, - "dependencies": { - "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } - } - }, - "eslint-plugin-react": { - "version": "7.29.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.29.4.tgz", - "integrity": "sha512-CVCXajliVh509PcZYRFyu/BoUEz452+jtQJq2b3Bae4v3xBUWPLCmtmBM+ZinG4MzwmxJgJ2M5rMqhqLVn7MtQ==", - "dev": true, - "requires": { - "array-includes": "^3.1.4", - "array.prototype.flatmap": "^1.2.5", - "doctrine": "^2.1.0", - "estraverse": "^5.3.0", - "jsx-ast-utils": "^2.4.1 || ^3.0.0", - "minimatch": "^3.1.2", - "object.entries": "^1.1.5", - "object.fromentries": "^2.0.5", - "object.hasown": "^1.1.0", - "object.values": "^1.1.5", - "prop-types": "^15.8.1", - "resolve": "^2.0.0-next.3", - "semver": "^6.3.0", - "string.prototype.matchall": "^4.0.6" - }, - "dependencies": { - "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "resolve": { - "version": "2.0.0-next.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.3.tgz", - "integrity": "sha512-W8LucSynKUIDu9ylraa7ueVZ7hc0uAgJBxVsQSKOXOyle8a93qXhcz+XAXZ8bIq2d6i4Ehddn6Evt+0/UwKk6Q==", - "dev": true, - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } - } - } - }, - "eslint-plugin-react-hooks": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.4.0.tgz", - "integrity": "sha512-U3RVIfdzJaeKDQKEJbz5p3NW8/L80PCATJAfuojwbaEL+gBjfGdhUcGde+WGUW46Q5sr/NgxevsIiDtNXrvZaQ==", - "dev": true, - "requires": {} - }, - "eslint-plugin-simple-import-sort": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-7.0.0.tgz", - "integrity": "sha512-U3vEDB5zhYPNfxT5TYR7u01dboFZp+HNpnGhkDB2g/2E4wZ/g1Q9Ton8UwCLfRV9yAKyYqDh62oHOamvkFxsvw==", - "dev": true, - "requires": {} - }, - "eslint-plugin-tsdoc": { - "version": "0.2.16", - "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.16.tgz", - "integrity": "sha512-F/RWMnyDQuGlg82vQEFHQtGyWi7++XJKdYNn0ulIbyMOFqYIjoJOUdE6olORxgwgLkpJxsCJpJbTHgxJ/ggfXw==", - "dev": true, - "requires": { - "@microsoft/tsdoc": "0.14.1", - "@microsoft/tsdoc-config": "0.16.1" - } - }, - "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "dependencies": { - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - } - } - }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true - } - } - }, - "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true - }, - "espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", - "dev": true, - "requires": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.3.0" - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", - "dev": true, - "requires": { - "estraverse": "^5.1.0" - } - }, - "esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "requires": { - "estraverse": "^5.2.0" - } - }, - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "fast-equals": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-3.0.1.tgz", - "integrity": "sha512-J9FxqqC9E/ja0C+SYhoG3Jl6pQuhP92HNcVC75xDEhB+GUzPnjEp3vMfPIxPprYZFfXS5hpVvvPCWUMiDSMS8Q==", - "dev": true - }, - "fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - } - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dev": true, - "requires": { - "reusify": "^1.0.4" - } - }, - "file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "dev": true, - "requires": { - "flat-cache": "^3.0.4" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "find-cache-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", - "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", - "dev": true, - "requires": { - "commondir": "^1.0.1", - "make-dir": "^2.0.0", - "pkg-dir": "^3.0.0" - } - }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true - }, - "flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", - "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", - "dev": true, - "requires": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" - } - }, - "flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", - "dev": true - }, - "foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", - "dev": true, - "requires": { - "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" - } - }, - "fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, - "gensequence": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/gensequence/-/gensequence-3.1.1.tgz", - "integrity": "sha512-ys3h0hiteRwmY6BsvSttPmkhC0vEQHPJduANBRtH/dlDPZ0UBIb/dXy80IcckXyuQ6LKg+PloRqvGER9IS7F7g==", - "dev": true - }, - "gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1" - } - }, - "get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "dev": true - }, - "get-symbol-description": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", - "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.1" - } - }, - "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "global-dirs": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", - "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", - "dev": true, - "requires": { - "ini": "^1.3.4" - } - }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true - }, - "globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "requires": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - } - }, - "graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "dev": true - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-own-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-own-prop/-/has-own-prop-2.0.0.tgz", - "integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==", - "dev": true - }, - "has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true - }, - "has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dev": true, - "requires": { - "has-symbols": "^1.0.2" - } - }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, - "html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true - }, - "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", - "dev": true - }, - "import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "dependencies": { - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "requires": { - "callsites": "^3.0.0" - } - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - } - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true - }, - "internal-slot": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", - "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", - "dev": true, - "requires": { - "get-intrinsic": "^1.1.0", - "has": "^1.0.3", - "side-channel": "^1.0.4" - } - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, - "is-bigint": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", - "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", - "dev": true, - "requires": { - "has-bigints": "^1.0.1" - } - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-boolean-object": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", - "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-callable": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", - "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", - "dev": true - }, - "is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-negative-zero": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", - "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", - "dev": true - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "is-number-object": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", - "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true - }, - "is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "is-regex": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-shared-array-buffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", - "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2" - } - }, - "is-string": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", - "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-symbol": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", - "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", - "dev": true, - "requires": { - "has-symbols": "^1.0.2" - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true - }, - "is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true - }, - "is-weakref": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", - "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.2" - } - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "istanbul-lib-coverage": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", - "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", - "dev": true - }, - "istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", - "dev": true, - "requires": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", - "supports-color": "^7.1.0" - }, - "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dev": true, - "requires": { - "semver": "^6.0.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "istanbul-reports": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.4.tgz", - "integrity": "sha512-r1/DshN4KSE7xWEknZLLLLDn5CJybV3nw01VTkp6D5jzLuELlcbudfj/eSQFvrKsJuTVCGnePO7ho82Nw9zzfw==", - "dev": true, - "requires": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - } - }, - "jju": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", - "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=", - "dev": true - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true - }, - "json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true - }, - "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", - "dev": true - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "jsx-ast-utils": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.2.2.tgz", - "integrity": "sha512-HDAyJ4MNQBboGpUnHAVUNJs6X0lh058s6FuixsFGP7MgJYpD6Vasd6nzSG5iIfXu1zAYlHJ/zsOKNlrenTUBnw==", - "dev": true, - "requires": { - "array-includes": "^3.1.4", - "object.assign": "^4.1.2" - } - }, - "kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true - }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - } - }, - "lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true - }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, - "lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true - }, - "lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true - }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, - "requires": { - "js-tokens": "^3.0.0 || ^4.0.0" - } - }, - "loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", - "dev": true, - "requires": { - "get-func-name": "^2.0.0" - } - }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "make-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", - "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", - "dev": true, - "requires": { - "pify": "^4.0.1", - "semver": "^5.6.0" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, - "merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true - }, - "micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dev": true, - "requires": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true - }, - "mocha": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", - "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", - "dev": true, - "requires": { - "@ungap/promise-all-settled": "1.1.2", - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.3", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.2.0", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", - "minimatch": "4.2.1", - "ms": "2.1.3", - "nanoid": "3.3.1", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" - }, - "dependencies": { - "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "dev": true, - "requires": { - "ms": "2.1.2" - }, - "dependencies": { - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } - } - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", - "dev": true - } - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", - "dev": true - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "node-releases": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.3.tgz", - "integrity": "sha512-maHFz6OLqYxz+VQyCAtA3PTX4UP/53pa05fyDNc9CwjvJ0yEh6+xBwKsgCxMNhS8taUKBFYxfuiaD9U/55iFaw==", - "dev": true - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "object-inspect": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", - "dev": true - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - }, - "object.entries": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.5.tgz", - "integrity": "sha512-TyxmjUoZggd4OrrU1W66FMDG6CuqJxsFvymeyXI51+vQLN67zYfZseptRge703kKQdo4uccgAKebXFcRCzk4+g==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - } - }, - "object.fromentries": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.5.tgz", - "integrity": "sha512-CAyG5mWQRRiBU57Re4FKoTBjXfDoNwdFVH2Y1tS9PqCsfUTymAohOkEMSG3aRNKmv4lV3O7p1et7c187q6bynw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - } - }, - "object.hasown": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.0.tgz", - "integrity": "sha512-MhjYRfj3GBlhSkDHo6QmvgjRLXQ2zndabdf3nX0yTyZK9rPfxb6uRpAac8HXNLy1GpqWtZ81Qh4v3uOls2sRAg==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - } - }, - "object.values": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz", - "integrity": "sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "parent-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-2.0.0.tgz", - "integrity": "sha512-uo0Z9JJeWzv8BG+tRcapBKNJ0dro9cLyczGzulS6EfeyAdeC9sbojtW6XwvYxJkEne9En+J2XEl4zyglVeIwFg==", - "dev": true, - "requires": { - "callsites": "^3.1.0" - } - }, - "parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true - }, - "pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true - }, - "picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true - }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true - }, - "pirates": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", - "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", - "dev": true - }, - "pkg-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", - "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", - "dev": true, - "requires": { - "find-up": "^3.0.0" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - } - } - }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, - "prettier": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz", - "integrity": "sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==", - "dev": true - }, - "prop-types": { - "version": "15.8.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", - "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, - "requires": { - "loose-envify": "^1.4.0", - "object-assign": "^4.1.1", - "react-is": "^16.13.1" - } - }, - "queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true - }, - "randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "requires": { - "safe-buffer": "^5.1.0" - } - }, - "react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true - }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "regenerate": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", - "dev": true - }, - "regenerate-unicode-properties": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz", - "integrity": "sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw==", - "dev": true, - "requires": { - "regenerate": "^1.4.2" - } - }, - "regenerator-runtime": { - "version": "0.13.9", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "dev": true - }, - "regenerator-transform": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.0.tgz", - "integrity": "sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==", - "dev": true, - "requires": { - "@babel/runtime": "^7.8.4" - } - }, - "regexp.prototype.flags": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.2.tgz", - "integrity": "sha512-Ynz8fTQW5/1elh+jWU2EDDzeoNbD0OQ0R+D1VJU5ATOkUaro4A9YEkdN2ODQl/8UQFPPpZNw91fOcLFamM7Pww==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true - }, - "regexpu-core": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.0.1.tgz", - "integrity": "sha512-CriEZlrKK9VJw/xQGJpQM5rY88BtuL8DM+AEwvcThHilbxiTAy8vq4iJnd2tqq8wLmjbGZzP7ZcKFjbGkmEFrw==", - "dev": true, - "requires": { - "regenerate": "^1.4.2", - "regenerate-unicode-properties": "^10.0.1", - "regjsgen": "^0.6.0", - "regjsparser": "^0.8.2", - "unicode-match-property-ecmascript": "^2.0.0", - "unicode-match-property-value-ecmascript": "^2.0.0" - } - }, - "regjsgen": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.6.0.tgz", - "integrity": "sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA==", - "dev": true - }, - "regjsparser": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.8.4.tgz", - "integrity": "sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA==", - "dev": true, - "requires": { - "jsesc": "~0.5.0" - }, - "dependencies": { - "jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true - } - } - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "dev": true, - "requires": { - "is-core-module": "^2.8.1", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, - "resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true - }, - "resolve-global": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/resolve-global/-/resolve-global-1.0.0.tgz", - "integrity": "sha512-zFa12V4OLtT5XUX/Q4VLvTfBf+Ok0SPc1FNGM/z9ctUdiU618qwKpWnd0CHs3+RqROfyEg/DhuHbMWYqcgljEw==", - "dev": true, - "requires": { - "global-dirs": "^0.1.1" - } - }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "requires": { - "queue-microtask": "^1.2.2" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - }, - "serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, - "shallow-clone": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", - "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", - "dev": true, - "requires": { - "kind-of": "^6.0.2" - } - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - } - }, - "signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, - "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "string.prototype.matchall": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz", - "integrity": "sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", - "get-intrinsic": "^1.1.1", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "regexp.prototype.flags": "^1.4.1", - "side-channel": "^1.0.4" - } - }, - "string.prototype.trimend": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", - "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "string.prototype.trimstart": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", - "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true - }, - "test-exclude": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", - "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", - "dev": true, - "requires": { - "@istanbuljs/schema": "^0.1.2", - "glob": "^7.1.4", - "minimatch": "^3.0.4" - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "tsconfig-paths": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", - "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", - "dev": true, - "requires": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - }, - "dependencies": { - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - } - } - }, - "tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dev": true, - "requires": { - "tslib": "^1.8.1" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } - } - }, - "type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1" - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, - "typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, - "requires": { - "is-typedarray": "^1.0.0" - } - }, - "typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", - "dev": true - }, - "unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", - "which-boxed-primitive": "^1.0.2" - } - }, - "unicode-canonical-property-names-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", - "integrity": "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==", - "dev": true - }, - "unicode-match-property-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", - "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", - "dev": true, - "requires": { - "unicode-canonical-property-names-ecmascript": "^2.0.0", - "unicode-property-aliases-ecmascript": "^2.0.0" - } - }, - "unicode-match-property-value-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.0.0.tgz", - "integrity": "sha512-7Yhkc0Ye+t4PNYzOGKedDhXbYIBe1XEQYQxOPyhcXNMJ0WCABqqj6ckydd6pWRZTHV4GuCPKdBAUiMc60tsKVw==", - "dev": true - }, - "unicode-property-aliases-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz", - "integrity": "sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ==", - "dev": true - }, - "unique-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", - "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", - "dev": true, - "requires": { - "crypto-random-string": "^2.0.0" - } - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } - } - }, - "v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, - "v8-to-istanbul": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz", - "integrity": "sha512-FGtKtv3xIpR6BYhvgH8MI/y78oT7d8Au3ww4QIxymrCtZEh5b8gCw2siywE+puhEmuWKDtmfrvF5UlB298ut3w==", - "dev": true, - "requires": { - "@types/istanbul-lib-coverage": "^2.0.1", - "convert-source-map": "^1.6.0", - "source-map": "^0.7.3" - }, - "dependencies": { - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - } - } - }, - "vscode-languageserver-textdocument": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.4.tgz", - "integrity": "sha512-/xhqXP/2A2RSs+J8JNXpiiNVvvNM0oTosNVmQnunlKvq9o4mupHOBAnnzH0lwIPKazXKvAKsVp1kr+H/K4lgoQ==", - "dev": true - }, - "vscode-uri": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.3.tgz", - "integrity": "sha512-EcswR2S8bpR7fD0YPeS7r2xXExrScVMxg4MedACaWHEtx9ftCF/qHG1xGkolzTPcEmjTavCQgbVzHUIdTMzFGA==", - "dev": true - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-boxed-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", - "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", - "dev": true, - "requires": { - "is-bigint": "^1.0.1", - "is-boolean-object": "^1.1.0", - "is-number-object": "^1.0.4", - "is-string": "^1.0.5", - "is-symbol": "^1.0.3" - } - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true - }, - "workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", - "dev": true, - "requires": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" - } - }, - "xdg-basedir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", - "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", - "dev": true - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, - "yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true - }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "dependencies": { - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - } - } - }, - "yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true - }, - "yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "requires": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - } - }, - "yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true - } - } -} diff --git a/package.json b/package.json index 5ac3db3068..6d7f9b71db 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,18 @@ { "name": "graphql", - "version": "16.11.0", + "version": "17.0.0-alpha.8", "description": "A Query Language and Runtime which can target any service.", "license": "MIT", - "private": true, - "main": "index", - "module": "index.mjs", "typesVersions": { - ">=4.1.0": { + ">=4.4.0": { "*": [ "*" ] + }, + "*": { + "*": [ + "NotSupportedTSVersion.d.ts" + ] } }, "sideEffects": false, @@ -27,55 +29,11 @@ "graphql-js" ], "engines": { - "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" - }, - "scripts": { - "preversion": "bash -c '. ./resources/checkgit.sh && npm ci --ignore-scripts'", - "version": "node resources/gen-version.js && npm test && git add src/version.ts", - "fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.ts", - "changelog": "node resources/gen-changelog.js", - "benchmark": "node benchmark/benchmark.js", - "test": "npm run lint && npm run check && npm run testonly && npm run prettier:check && npm run check:spelling && npm run check:integrations", - "lint": "eslint --cache --max-warnings 0 .", - "check": "tsc --pretty", - "testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts", - "testonly:cover": "c8 npm run testonly", - "prettier": "prettier --write --list-different .", - "prettier:check": "prettier --check .", - "check:spelling": "cspell --cache --no-progress '**/*'", - "check:integrations": "npm run build:npm && npm run build:deno && mocha --full-trace integrationTests/*-test.js", - "build:npm": "node resources/build-npm.js", - "build:deno": "node resources/build-deno.js", - "gitpublish:npm": "bash ./resources/gitpublish.sh npm npmDist", - "gitpublish:deno": "bash ./resources/gitpublish.sh deno denoDist" - }, - "devDependencies": { - "@babel/core": "7.17.9", - "@babel/plugin-syntax-typescript": "7.16.7", - "@babel/plugin-transform-typescript": "7.16.8", - "@babel/preset-env": "7.16.11", - "@babel/register": "7.17.7", - "@types/chai": "4.3.1", - "@types/mocha": "9.1.0", - "@types/node": "17.0.24", - "@typescript-eslint/eslint-plugin": "5.19.0", - "@typescript-eslint/parser": "5.19.0", - "c8": "7.11.0", - "chai": "4.3.6", - "cspell": "5.19.7", - "eslint": "8.13.0", - "eslint-plugin-import": "2.26.0", - "eslint-plugin-internal-rules": "file:./resources/eslint-internal-rules", - "eslint-plugin-node": "11.1.0", - "eslint-plugin-react": "7.29.4", - "eslint-plugin-react-hooks": "4.4.0", - "eslint-plugin-simple-import-sort": "7.0.0", - "eslint-plugin-tsdoc": "0.2.16", - "mocha": "9.2.2", - "prettier": "2.6.2", - "typescript": "4.6.3" + "node": "^16.19.0 || ^18.14.0 || >=19.7.0" }, "publishConfig": { - "tag": "latest" - } + "tag": "alpha" + }, + "main": "index", + "module": "index.mjs" } diff --git a/resources/add-extension-to-import-paths.js b/resources/add-extension-to-import-paths.js deleted file mode 100644 index 3ec22d9dcc..0000000000 --- a/resources/add-extension-to-import-paths.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -/** - * Adds extension to all paths imported inside MJS files - * - * Transforms: - * - * import { foo } from './bar'; - * export { foo } from './bar'; - * - * to: - * - * import { foo } from './bar.mjs'; - * export { foo } from './bar.mjs'; - * - */ -module.exports = function addExtensionToImportPaths(context, { extension }) { - const { types } = context; - - return { - visitor: { - ImportDeclaration: replaceImportPath, - ExportNamedDeclaration: replaceImportPath, - }, - }; - - function replaceImportPath(path) { - // bail if the declaration doesn't have a source, e.g. "export { foo };" - if (!path.node.source) { - return; - } - - const source = path.node.source.value; - if (source.startsWith('./') || source.startsWith('../')) { - const newSourceNode = types.stringLiteral(source + '.' + extension); - path.get('source').replaceWith(newSourceNode); - } - } -}; diff --git a/resources/build-deno.js b/resources/build-deno.js deleted file mode 100644 index f0479a858a..0000000000 --- a/resources/build-deno.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); - -const babel = require('@babel/core'); - -const { - writeGeneratedFile, - readdirRecursive, - showDirStats, -} = require('./utils.js'); - -if (require.main === module) { - fs.rmSync('./denoDist', { recursive: true, force: true }); - fs.mkdirSync('./denoDist'); - - const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ }); - for (const filepath of srcFiles) { - const srcPath = path.join('./src', filepath); - const destPath = path.join('./denoDist', filepath); - - fs.mkdirSync(path.dirname(destPath), { recursive: true }); - if (filepath.endsWith('.ts')) { - const options = { babelrc: false, configFile: './.babelrc-deno.json' }; - const output = babel.transformFileSync(srcPath, options).code + '\n'; - writeGeneratedFile(destPath, output); - } - } - - fs.copyFileSync('./LICENSE', './denoDist/LICENSE'); - fs.copyFileSync('./README.md', './denoDist/README.md'); - - showDirStats('./denoDist'); -} diff --git a/resources/build-npm.js b/resources/build-npm.js deleted file mode 100644 index 7ff0cf079c..0000000000 --- a/resources/build-npm.js +++ /dev/null @@ -1,139 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); - -const ts = require('typescript'); -const babel = require('@babel/core'); - -const { - writeGeneratedFile, - readdirRecursive, - showDirStats, -} = require('./utils.js'); - -if (require.main === module) { - fs.rmSync('./npmDist', { recursive: true, force: true }); - fs.mkdirSync('./npmDist'); - - const packageJSON = buildPackageJSON(); - - const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ }); - for (const filepath of srcFiles) { - const srcPath = path.join('./src', filepath); - const destPath = path.join('./npmDist', filepath); - - fs.mkdirSync(path.dirname(destPath), { recursive: true }); - if (filepath.endsWith('.ts')) { - const cjs = babelBuild(srcPath, { envName: 'cjs' }); - writeGeneratedFile(destPath.replace(/\.ts$/, '.js'), cjs); - - const mjs = babelBuild(srcPath, { envName: 'mjs' }); - writeGeneratedFile(destPath.replace(/\.ts$/, '.mjs'), mjs); - } - } - - // Based on https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#getting-the-dts-from-a-javascript-file - const tsConfig = JSON.parse( - fs.readFileSync(require.resolve('../tsconfig.json'), 'utf-8'), - ); - assert( - tsConfig.compilerOptions, - '"tsconfig.json" should have `compilerOptions`', - ); - const tsOptions = { - ...tsConfig.compilerOptions, - noEmit: false, - declaration: true, - declarationDir: './npmDist', - emitDeclarationOnly: true, - }; - - const tsHost = ts.createCompilerHost(tsOptions); - tsHost.writeFile = (filepath, body) => { - writeGeneratedFile(filepath, body); - }; - - const tsProgram = ts.createProgram(['src/index.ts'], tsOptions, tsHost); - const tsResult = tsProgram.emit(); - assert( - !tsResult.emitSkipped, - 'Fail to generate `*.d.ts` files, please run `npm run check`', - ); - - assert(packageJSON.types === undefined, 'Unexpected "types" in package.json'); - const supportedTSVersions = Object.keys(packageJSON.typesVersions); - assert( - supportedTSVersions.length === 1, - 'Property "typesVersions" should have exactly one key.', - ); - // TODO: revisit once TS implements https://github.com/microsoft/TypeScript/issues/32166 - const notSupportedTSVersionFile = 'NotSupportedTSVersion.d.ts'; - fs.writeFileSync( - path.join('./npmDist', notSupportedTSVersionFile), - // Provoke syntax error to show this message - `"Package 'graphql' support only TS versions that are ${supportedTSVersions[0]}".`, - ); - packageJSON.typesVersions = { - ...packageJSON.typesVersions, - '*': { '*': [notSupportedTSVersionFile] }, - }; - - fs.copyFileSync('./LICENSE', './npmDist/LICENSE'); - fs.copyFileSync('./README.md', './npmDist/README.md'); - - // Should be done as the last step so only valid packages can be published - writeGeneratedFile('./npmDist/package.json', JSON.stringify(packageJSON)); - - showDirStats('./npmDist'); -} - -function babelBuild(srcPath, options) { - const { code } = babel.transformFileSync(srcPath, { - babelrc: false, - configFile: './.babelrc-npm.json', - ...options, - }); - return code + '\n'; -} - -function buildPackageJSON() { - const packageJSON = JSON.parse( - fs.readFileSync(require.resolve('../package.json'), 'utf-8'), - ); - - delete packageJSON.private; - delete packageJSON.scripts; - delete packageJSON.devDependencies; - - // TODO: move to integration tests - const publishTag = packageJSON.publishConfig?.tag; - assert(publishTag != null, 'Should have packageJSON.publishConfig defined!'); - - const { version } = packageJSON; - const versionMatch = /^\d+\.\d+\.\d+-?(?.*)?$/.exec(version); - if (!versionMatch) { - throw new Error('Version does not match semver spec: ' + version); - } - - const { preReleaseTag } = versionMatch.groups; - - if (preReleaseTag != null) { - const splittedTag = preReleaseTag.split('.'); - // Note: `experimental-*` take precedence over `alpha`, `beta` or `rc`. - const versionTag = splittedTag[2] ?? splittedTag[0]; - assert( - ['alpha', 'beta', 'rc'].includes(versionTag) || - versionTag.startsWith('experimental-'), - `"${versionTag}" tag is not supported.`, - ); - assert.equal( - versionTag, - publishTag, - 'Publish tag and version tag should match!', - ); - } - - return packageJSON; -} diff --git a/resources/checkgit.sh b/resources/checkgit.sh deleted file mode 100644 index e5e4c67cf2..0000000000 --- a/resources/checkgit.sh +++ /dev/null @@ -1,39 +0,0 @@ -# Exit immediately if any subcommand terminated -set -e -trap "exit 1" ERR - -# -# This script determines if current git state is the up to date main. If so -# it exits normally. If not it prompts for an explicit continue. This script -# intends to protect from versioning for NPM without first pushing changes -# and including any changes on main. -# - -# Check that local copy has no modifications -GIT_MODIFIED_FILES=$(git ls-files -dm 2> /dev/null); -GIT_STAGED_FILES=$(git diff --cached --name-only 2> /dev/null); -if [ "$GIT_MODIFIED_FILES" != "" -o "$GIT_STAGED_FILES" != "" ]; then - read -p "Git has local modifications. Continue? (y|N) " yn; - if [ "$yn" != "y" ]; then exit 1; fi; -fi; - -# First fetch to ensure git is up to date. Fail-fast if this fails. -git fetch; -if [[ $? -ne 0 ]]; then exit 1; fi; - -# Extract useful information. -GIT_BRANCH=$(git branch -v 2> /dev/null | sed '/^[^*]/d'); -GIT_BRANCH_NAME=$(echo "$GIT_BRANCH" | sed 's/* \([A-Za-z0-9_\-]*\).*/\1/'); -GIT_BRANCH_SYNC=$(echo "$GIT_BRANCH" | sed 's/* [^[]*.\([^]]*\).*/\1/'); - -# Check if main is checked out -if [ "$GIT_BRANCH_NAME" != "main" ]; then - read -p "Git not on main but $GIT_BRANCH_NAME. Continue? (y|N) " yn; - if [ "$yn" != "y" ]; then exit 1; fi; -fi; - -# Check if branch is synced with remote -if [ "$GIT_BRANCH_SYNC" != "" ]; then - read -p "Git not up to date but $GIT_BRANCH_SYNC. Continue? (y|N) " yn; - if [ "$yn" != "y" ]; then exit 1; fi; -fi; diff --git a/resources/diff-npm-package.js b/resources/diff-npm-package.js deleted file mode 100644 index c0d8d8c991..0000000000 --- a/resources/diff-npm-package.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -const os = require('os'); -const fs = require('fs'); -const path = require('path'); -const cp = require('child_process'); - -const LOCAL = 'local'; -const localRepoDir = path.join(__dirname, '..'); -const tmpDir = path.join(os.tmpdir(), 'graphql-js-npm-diff'); -fs.rmSync(tmpDir, { recursive: true, force: true }); -fs.mkdirSync(tmpDir); - -const args = process.argv.slice(2); -let [fromRevision, toRevision] = args; -if (args.length < 2) { - fromRevision = fromRevision ?? 'HEAD'; - toRevision = toRevision ?? LOCAL; - console.warn( - `Assuming you meant: diff-npm-package ${fromRevision} ${toRevision}`, - ); -} - -console.log(`πŸ“¦ Building NPM package for ${fromRevision}...`); -const fromPackage = prepareNPMPackage(fromRevision); - -console.log(`πŸ“¦ Building NPM package for ${toRevision}...`); -const toPackage = prepareNPMPackage(toRevision); - -console.log('βž–βž• Generating diff...'); -const diff = exec(`npm diff --diff=${fromPackage} --diff=${toPackage}`); - -if (diff === '') { - console.log('No changes found!'); -} else { - const reportPath = path.join(localRepoDir, 'npm-dist-diff.html'); - fs.writeFileSync(reportPath, generateReport(diff), 'utf-8'); - console.log('Report saved to: ', reportPath); -} - -function generateReport(diffString) { - return ` - - - - - - - - - - - -
- - - `; -} -function prepareNPMPackage(revision) { - if (revision === LOCAL) { - exec('npm --quiet run build:npm', { cwd: localRepoDir }); - return path.join(localRepoDir, 'npmDist'); - } - - // Returns the complete git hash for a given git revision reference. - const hash = exec(`git rev-parse "${revision}"`); - - const repoDir = path.join(tmpDir, hash); - fs.rmSync(repoDir, { recursive: true, force: true }); - fs.mkdirSync(repoDir); - exec(`git archive "${hash}" | tar -xC "${repoDir}"`); - exec('npm --quiet ci --ignore-scripts', { cwd: repoDir }); - exec('npm --quiet run build:npm', { cwd: repoDir }); - return path.join(repoDir, 'npmDist'); -} - -function exec(command, options = {}) { - const result = cp.execSync(command, { - encoding: 'utf-8', - stdio: ['inherit', 'pipe', 'inherit'], - ...options, - }); - return result?.trimEnd(); -} diff --git a/resources/eslint-internal-rules/README.md b/resources/eslint-internal-rules/README.md deleted file mode 100644 index cec9e87c9b..0000000000 --- a/resources/eslint-internal-rules/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Custom ESLint Rules - -This is a dummy npm package that allows us to treat it as an `eslint-plugin-graphql-internal`. -It's not actually published, nor are the rules here useful for users of graphql. - -**If you modify this rule, you must re-run `npm install` for it to take effect.** diff --git a/resources/eslint-internal-rules/index.js b/resources/eslint-internal-rules/index.js deleted file mode 100644 index 4acc530f3a..0000000000 --- a/resources/eslint-internal-rules/index.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -const onlyASCII = require('./only-ascii.js'); -const noDirImport = require('./no-dir-import.js'); -const requireToStringTag = require('./require-to-string-tag.js'); - -module.exports = { - rules: { - 'only-ascii': onlyASCII, - 'no-dir-import': noDirImport, - 'require-to-string-tag': requireToStringTag, - }, -}; diff --git a/resources/eslint-internal-rules/no-dir-import.js b/resources/eslint-internal-rules/no-dir-import.js deleted file mode 100644 index 5322039875..0000000000 --- a/resources/eslint-internal-rules/no-dir-import.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); - -module.exports = function noDirImportRule(context) { - return { - ImportDeclaration: checkImportPath, - ExportNamedDeclaration: checkImportPath, - }; - - function checkImportPath(node) { - const { source } = node; - - // bail if the declaration doesn't have a source, e.g. "export { foo };" - if (!source) { - return; - } - - const importPath = source.value; - if (importPath.startsWith('./') || importPath.startsWith('../')) { - const baseDir = path.dirname(context.getFilename()); - const resolvedPath = path.resolve(baseDir, importPath); - - if ( - fs.existsSync(resolvedPath) && - fs.statSync(resolvedPath).isDirectory() - ) { - context.report({ - node: source, - message: 'It is not allowed to import from directory', - }); - } - } - } -}; diff --git a/resources/eslint-internal-rules/only-ascii.js b/resources/eslint-internal-rules/only-ascii.js deleted file mode 100644 index f5ddbe1b68..0000000000 --- a/resources/eslint-internal-rules/only-ascii.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -module.exports = { - meta: { - schema: [ - { - type: 'object', - properties: { - allowEmoji: { - type: 'boolean', - }, - }, - additionalProperties: false, - }, - ], - }, - create: onlyASCII, -}; - -function onlyASCII(context) { - const regExp = - context.options[0]?.allowEmoji === true - ? /[^\p{ASCII}\p{Emoji}]+/gu - : /\P{ASCII}+/gu; - - return { - Program() { - const sourceCode = context.getSourceCode(); - const text = sourceCode.getText(); - - for (const match of text.matchAll(regExp)) { - context.report({ - loc: sourceCode.getLocFromIndex(match.index), - message: `Non-ASCII character "${match[0]}" found.`, - }); - } - }, - }; -} diff --git a/resources/eslint-internal-rules/package.json b/resources/eslint-internal-rules/package.json deleted file mode 100644 index 5912b1453e..0000000000 --- a/resources/eslint-internal-rules/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "eslint-plugin-graphql-internal", - "version": "0.0.0", - "private": true, - "engines": { - "node": ">= 14.0.0" - } -} diff --git a/resources/eslint-internal-rules/require-to-string-tag.js b/resources/eslint-internal-rules/require-to-string-tag.js deleted file mode 100644 index 517fd07eb3..0000000000 --- a/resources/eslint-internal-rules/require-to-string-tag.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -module.exports = function requireToStringTag(context) { - const sourceCode = context.getSourceCode(); - - return { - 'ExportNamedDeclaration > ClassDeclaration': (classNode) => { - const properties = classNode.body.body; - if (properties.some(isToStringTagProperty)) { - return; - } - - const jsDoc = context.getJSDocComment(classNode)?.value; - // FIXME: use proper TSDoc parser instead of includes once we fix TSDoc comments - if (jsDoc?.includes('@internal') === true) { - return; - } - - context.report({ - node: classNode, - message: - 'All classes in public API required to have [Symbol.toStringTag] method', - }); - }, - }; - - function isToStringTagProperty(propertyNode) { - if ( - propertyNode.type !== 'MethodDefinition' || - propertyNode.kind !== 'get' - ) { - return false; - } - const keyText = sourceCode.getText(propertyNode.key); - return keyText === 'Symbol.toStringTag'; - } -}; diff --git a/resources/gen-changelog.js b/resources/gen-changelog.js deleted file mode 100644 index 02bb634050..0000000000 --- a/resources/gen-changelog.js +++ /dev/null @@ -1,323 +0,0 @@ -'use strict'; - -const util = require('util'); -const https = require('https'); - -const packageJSON = require('../package.json'); - -const { exec } = require('./utils.js'); - -const graphqlRequest = util.promisify(graphqlRequestImpl); -const labelsConfig = { - 'PR: breaking change πŸ’₯': { - section: 'Breaking Change πŸ’₯', - }, - 'PR: deprecation ⚠': { - section: 'Deprecation ⚠', - }, - 'PR: feature πŸš€': { - section: 'New Feature πŸš€', - }, - 'PR: bug fix 🐞': { - section: 'Bug Fix 🐞', - }, - 'PR: docs πŸ“': { - section: 'Docs πŸ“', - fold: true, - }, - 'PR: polish πŸ’…': { - section: 'Polish πŸ’…', - fold: true, - }, - 'PR: internal 🏠': { - section: 'Internal 🏠', - fold: true, - }, - 'PR: dependency πŸ“¦': { - section: 'Dependency πŸ“¦', - fold: true, - }, -}; -const { GH_TOKEN } = process.env; - -if (!GH_TOKEN) { - console.error('Must provide GH_TOKEN as environment variable!'); - process.exit(1); -} - -if (!packageJSON.repository || typeof packageJSON.repository.url !== 'string') { - console.error('package.json is missing repository.url string!'); - process.exit(1); -} - -const repoURLMatch = - /https:\/\/github.com\/(?[^/]+)\/(?[^/]+).git/.exec( - packageJSON.repository.url, - ); -if (repoURLMatch == null) { - console.error('Cannot extract organization and repo name from repo URL!'); - process.exit(1); -} -const { githubOrg, githubRepo } = repoURLMatch.groups; - -getChangeLog() - .then((changelog) => process.stdout.write(changelog)) - .catch((error) => { - console.error(error); - process.exit(1); - }); - -function getChangeLog() { - const { version } = packageJSON; - - let tag = null; - let commitsList = exec(`git rev-list --reverse v${version}..`); - if (commitsList === '') { - const parentPackageJSON = exec('git cat-file blob HEAD~1:package.json'); - const parentVersion = JSON.parse(parentPackageJSON).version; - commitsList = exec(`git rev-list --reverse v${parentVersion}..HEAD~1`); - tag = `v${version}`; - } - - const date = exec('git log -1 --format=%cd --date=short'); - return getCommitsInfo(commitsList.split('\n')) - .then((commitsInfo) => getPRsInfo(commitsInfoToPRs(commitsInfo))) - .then((prsInfo) => genChangeLog(tag, date, prsInfo)); -} - -function genChangeLog(tag, date, allPRs) { - const byLabel = {}; - const committersByLogin = {}; - - for (const pr of allPRs) { - const labels = pr.labels.nodes - .map((label) => label.name) - .filter((label) => label.startsWith('PR: ')); - - if (labels.length === 0) { - throw new Error(`PR is missing label. See ${pr.url}`); - } - if (labels.length > 1) { - throw new Error( - `PR has conflicting labels: ${labels.join('\n')}\nSee ${pr.url}`, - ); - } - - const label = labels[0]; - if (!labelsConfig[label]) { - throw new Error(`Unknown label: ${label}. See ${pr.url}`); - } - byLabel[label] = byLabel[label] || []; - byLabel[label].push(pr); - committersByLogin[pr.author.login] = pr.author; - } - - let changelog = `## ${tag || 'Unreleased'} (${date})\n`; - for (const [label, config] of Object.entries(labelsConfig)) { - const prs = byLabel[label]; - if (prs) { - const shouldFold = config.fold && prs.length > 1; - - changelog += `\n#### ${config.section}\n`; - if (shouldFold) { - changelog += '
\n'; - changelog += ` ${prs.length} PRs were merged \n\n`; - } - - for (const pr of prs) { - const { number, url, author } = pr; - changelog += `* [#${number}](${url}) ${pr.title} ([@${author.login}](${author.url}))\n`; - } - - if (shouldFold) { - changelog += '
\n'; - } - } - } - - const committers = Object.values(committersByLogin).sort((a, b) => - (a.name || a.login).localeCompare(b.name || b.login), - ); - changelog += `\n#### Committers: ${committers.length}\n`; - for (const committer of committers) { - changelog += `* ${committer.name}([@${committer.login}](${committer.url}))\n`; - } - - return changelog; -} - -function graphqlRequestImpl(query, variables, cb) { - const resultCB = typeof variables === 'function' ? variables : cb; - - const req = https.request('https://api.github.com/graphql', { - method: 'POST', - headers: { - Authorization: 'bearer ' + GH_TOKEN, - 'Content-Type': 'application/json', - 'User-Agent': 'gen-changelog', - }, - }); - - req.on('response', (res) => { - let responseBody = ''; - - res.setEncoding('utf8'); - res.on('data', (d) => (responseBody += d)); - res.on('error', (error) => resultCB(error)); - - res.on('end', () => { - if (res.statusCode !== 200) { - return resultCB( - new Error( - `GitHub responded with ${res.statusCode}: ${res.statusMessage}\n` + - responseBody, - ), - ); - } - - let json; - try { - json = JSON.parse(responseBody); - } catch (error) { - return resultCB(error); - } - - if (json.errors) { - return resultCB( - new Error('Errors: ' + JSON.stringify(json.errors, null, 2)), - ); - } - - resultCB(undefined, json.data); - }); - }); - - req.on('error', (error) => resultCB(error)); - req.write(JSON.stringify({ query, variables })); - req.end(); -} - -async function batchCommitInfo(commits) { - let commitsSubQuery = ''; - for (const oid of commits) { - commitsSubQuery += ` - commit_${oid}: object(oid: "${oid}") { - ... on Commit { - oid - message - associatedPullRequests(first: 10) { - nodes { - number - repository { - nameWithOwner - } - } - } - } - } - `; - } - - const response = await graphqlRequest(` - { - repository(owner: "${githubOrg}", name: "${githubRepo}") { - ${commitsSubQuery} - } - } - `); - - const commitsInfo = []; - for (const oid of commits) { - commitsInfo.push(response.repository['commit_' + oid]); - } - return commitsInfo; -} - -async function batchPRInfo(prs) { - let prsSubQuery = ''; - for (const number of prs) { - prsSubQuery += ` - pr_${number}: pullRequest(number: ${number}) { - number - title - url - author { - login - url - ... on User { - name - } - } - labels(first: 10) { - nodes { - name - } - } - } - `; - } - - const response = await graphqlRequest(` - { - repository(owner: "${githubOrg}", name: "${githubRepo}") { - ${prsSubQuery} - } - } - `); - - const prsInfo = []; - for (const number of prs) { - prsInfo.push(response.repository['pr_' + number]); - } - return prsInfo; -} - -function commitsInfoToPRs(commits) { - const prs = {}; - for (const commit of commits) { - const associatedPRs = commit.associatedPullRequests.nodes.filter( - (pr) => pr.repository.nameWithOwner === `${githubOrg}/${githubRepo}`, - ); - if (associatedPRs.length === 0) { - const match = / \(#(?[0-9]+)\)$/m.exec(commit.message); - if (match) { - prs[parseInt(match.groups.prNumber, 10)] = true; - continue; - } - throw new Error( - `Commit ${commit.oid} has no associated PR: ${commit.message}`, - ); - } - if (associatedPRs.length > 1) { - throw new Error( - `Commit ${commit.oid} is associated with multiple PRs: ${commit.message}`, - ); - } - - prs[associatedPRs[0].number] = true; - } - - return Object.keys(prs); -} - -async function getPRsInfo(commits) { - // Split pr into batches of 50 to prevent timeouts - const prInfoPromises = []; - for (let i = 0; i < commits.length; i += 50) { - const batch = commits.slice(i, i + 50); - prInfoPromises.push(batchPRInfo(batch)); - } - - return (await Promise.all(prInfoPromises)).flat(); -} - -async function getCommitsInfo(commits) { - // Split commits into batches of 50 to prevent timeouts - const commitInfoPromises = []; - for (let i = 0; i < commits.length; i += 50) { - const batch = commits.slice(i, i + 50); - commitInfoPromises.push(batchCommitInfo(batch)); - } - - return (await Promise.all(commitInfoPromises)).flat(); -} diff --git a/resources/gen-version.js b/resources/gen-version.js deleted file mode 100644 index b73621bce7..0000000000 --- a/resources/gen-version.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -const { version } = require('../package.json'); - -const { writeGeneratedFile } = require('./utils.js'); - -const versionMatch = /^(\d+)\.(\d+)\.(\d+)-?(.*)?$/.exec(version); -if (!versionMatch) { - throw new Error('Version does not match semver spec: ' + version); -} - -const [, major, minor, patch, preReleaseTag] = versionMatch; - -const body = ` -// Note: This file is autogenerated using "resources/gen-version.js" script and -// automatically updated by "npm version" command. - -/** - * A string containing the version of the GraphQL.js library - */ -export const version = '${version}' as string; - -/** - * An object containing the components of the GraphQL.js version string - */ -export const versionInfo = Object.freeze({ - major: ${major} as number, - minor: ${minor} as number, - patch: ${patch} as number, - preReleaseTag: ${ - preReleaseTag ? `'${preReleaseTag}'` : 'null' - } as string | null, -}); -`; - -if (require.main === module) { - writeGeneratedFile('./src/version.ts', body); -} diff --git a/resources/inline-invariant.js b/resources/inline-invariant.js deleted file mode 100644 index d3f5a1b6f0..0000000000 --- a/resources/inline-invariant.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -/** - * Eliminates function call to `invariant` if the condition is met. - * - * Transforms: - * - * invariant(, ...) - * - * to: - * - * () || invariant(false ...) - */ -module.exports = function inlineInvariant(context) { - const invariantTemplate = context.template(` - (%%cond%%) || invariant(false, %%args%%) - `); - const assertTemplate = context.template(` - (%%cond%%) || devAssert(false, %%args%%) - `); - - return { - visitor: { - CallExpression(path) { - const node = path.node; - const parent = path.parent; - - if ( - parent.type !== 'ExpressionStatement' || - node.callee.type !== 'Identifier' || - node.arguments.length === 0 - ) { - return; - } - - const calleeName = node.callee.name; - if (calleeName === 'invariant') { - const [cond, args] = node.arguments; - - path.replaceWith(invariantTemplate({ cond, args })); - } else if (calleeName === 'devAssert') { - const [cond, args] = node.arguments; - path.replaceWith(assertTemplate({ cond, args })); - } - }, - }, - }; -}; diff --git a/resources/ts-register.js b/resources/ts-register.js deleted file mode 100644 index 649eb5fdd2..0000000000 --- a/resources/ts-register.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -require('@babel/register')({ extensions: ['.ts'] }); diff --git a/resources/utils.js b/resources/utils.js deleted file mode 100644 index 37cd83e801..0000000000 --- a/resources/utils.js +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const childProcess = require('child_process'); - -const prettier = require('prettier'); - -function exec(command, options) { - const output = childProcess.execSync(command, { - maxBuffer: 10 * 1024 * 1024, // 10MB - encoding: 'utf-8', - ...options, - }); - return output && output.trimEnd(); -} - -function readdirRecursive(dirPath, opts = {}) { - const { ignoreDir } = opts; - const result = []; - for (const dirent of fs.readdirSync(dirPath, { withFileTypes: true })) { - const name = dirent.name; - if (!dirent.isDirectory()) { - result.push(dirent.name); - continue; - } - - if (ignoreDir && ignoreDir.test(name)) { - continue; - } - const list = readdirRecursive(path.join(dirPath, name), opts).map((f) => - path.join(name, f), - ); - result.push(...list); - } - return result; -} - -function showDirStats(dirPath) { - const fileTypes = {}; - let totalSize = 0; - - for (const filepath of readdirRecursive(dirPath)) { - const name = filepath.split(path.sep).pop(); - const [base, ...splitExt] = name.split('.'); - const ext = splitExt.join('.'); - - const filetype = ext ? '*.' + ext : base; - fileTypes[filetype] = fileTypes[filetype] || { filepaths: [], size: 0 }; - - const { size } = fs.lstatSync(path.join(dirPath, filepath)); - totalSize += size; - fileTypes[filetype].size += size; - fileTypes[filetype].filepaths.push(filepath); - } - - let stats = []; - for (const [filetype, typeStats] of Object.entries(fileTypes)) { - const numFiles = typeStats.filepaths.length; - - if (numFiles > 1) { - stats.push([filetype + ' x' + numFiles, typeStats.size]); - } else { - stats.push([typeStats.filepaths[0], typeStats.size]); - } - } - stats.sort((a, b) => b[1] - a[1]); - stats = stats.map(([type, size]) => [type, (size / 1024).toFixed(2) + ' KB']); - - const typeMaxLength = Math.max(...stats.map((x) => x[0].length)); - const sizeMaxLength = Math.max(...stats.map((x) => x[1].length)); - for (const [type, size] of stats) { - console.log( - type.padStart(typeMaxLength) + ' | ' + size.padStart(sizeMaxLength), - ); - } - - console.log('-'.repeat(typeMaxLength + 3 + sizeMaxLength)); - const totalMB = (totalSize / 1024 / 1024).toFixed(2) + ' MB'; - console.log( - 'Total'.padStart(typeMaxLength) + ' | ' + totalMB.padStart(sizeMaxLength), - ); -} - -const prettierConfig = JSON.parse( - fs.readFileSync(require.resolve('../.prettierrc'), 'utf-8'), -); - -function writeGeneratedFile(filepath, body) { - const formatted = prettier.format(body, { filepath, ...prettierConfig }); - fs.writeFileSync(filepath, formatted); -} - -module.exports = { - exec, - readdirRecursive, - showDirStats, - writeGeneratedFile, -}; diff --git a/src/README.md b/src/README.md deleted file mode 100644 index 7a67bcb569..0000000000 --- a/src/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## GraphQL JS - -The primary `graphql` module includes everything you need to define a GraphQL -schema and fulfill GraphQL requests. - -```js -import { ... } from 'graphql'; // ES6 -var GraphQL = require('graphql'); // CommonJS -``` - -Each sub directory within is a sub-module of graphql-js: - -- [`graphql/language`](language/README.md): Parse and operate on the GraphQL - language. -- [`graphql/type`](type/README.md): Define GraphQL types and schema. -- [`graphql/validation`](validation/README.md): The Validation phase of - fulfilling a GraphQL result. -- [`graphql/execution`](execution/README.md): The Execution phase of fulfilling - a GraphQL request. -- [`graphql/error`](error/README.md): Creating and formatting GraphQL errors. -- [`graphql/utilities`](utilities/README.md): Common useful computations upon - the GraphQL language and type objects. -- [`graphql/subscription`](subscription/README.md): Subscribe to data updates. diff --git a/src/__testUtils__/__tests__/dedent-test.ts b/src/__testUtils__/__tests__/dedent-test.ts deleted file mode 100644 index dfaf28e979..0000000000 --- a/src/__testUtils__/__tests__/dedent-test.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent, dedentString } from '../dedent'; - -describe('dedentString', () => { - it('removes indentation in typical usage', () => { - const output = dedentString(` - type Query { - me: User - } - - type User { - id: ID - name: String - } - `); - expect(output).to.equal( - [ - 'type Query {', - ' me: User', - '}', - '', - 'type User {', - ' id: ID', - ' name: String', - '}', - ].join('\n'), - ); - }); - - it('removes only the first level of indentation', () => { - const output = dedentString(` - first - second - third - fourth - `); - expect(output).to.equal( - ['first', ' second', ' third', ' fourth'].join('\n'), - ); - }); - - it('does not escape special characters', () => { - const output = dedentString(` - type Root { - field(arg: String = "wi\th de\fault"): String - } - `); - expect(output).to.equal( - [ - 'type Root {', - ' field(arg: String = "wi\th de\fault"): String', - '}', - ].join('\n'), - ); - }); - - it('also removes indentation using tabs', () => { - const output = dedentString(` - \t\t type Query { - \t\t me: User - \t\t } - `); - expect(output).to.equal(['type Query {', ' me: User', '}'].join('\n')); - }); - - it('removes leading and trailing newlines', () => { - const output = dedentString(` - - - type Query { - me: User - } - - - `); - expect(output).to.equal(['type Query {', ' me: User', '}'].join('\n')); - }); - - it('removes all trailing spaces and tabs', () => { - const output = dedentString(` - type Query { - me: User - } - \t\t \t `); - expect(output).to.equal(['type Query {', ' me: User', '}'].join('\n')); - }); - - it('works on text without leading newline', () => { - const output = dedentString(` type Query { - me: User - } - `); - expect(output).to.equal(['type Query {', ' me: User', '}'].join('\n')); - }); -}); - -describe('dedent', () => { - it('removes indentation in typical usage', () => { - const output = dedent` - type Query { - me: User - } - `; - expect(output).to.equal(['type Query {', ' me: User', '}'].join('\n')); - }); - - it('supports expression interpolation', () => { - const name = 'John'; - const surname = 'Doe'; - const output = dedent` - { - "me": { - "name": "${name}", - "surname": "${surname}" - } - } - `; - expect(output).to.equal( - [ - '{', - ' "me": {', - ' "name": "John",', - ' "surname": "Doe"', - ' }', - '}', - ].join('\n'), - ); - }); -}); diff --git a/src/__testUtils__/__tests__/genFuzzStrings-test.ts b/src/__testUtils__/__tests__/genFuzzStrings-test.ts deleted file mode 100644 index 516ed00fe7..0000000000 --- a/src/__testUtils__/__tests__/genFuzzStrings-test.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { genFuzzStrings } from '../genFuzzStrings'; - -function expectFuzzStrings(options: { - allowedChars: ReadonlyArray; - maxLength: number; -}) { - return expect([...genFuzzStrings(options)]); -} - -describe('genFuzzStrings', () => { - it('always provide empty string', () => { - expectFuzzStrings({ allowedChars: [], maxLength: 0 }).to.deep.equal(['']); - expectFuzzStrings({ allowedChars: [], maxLength: 1 }).to.deep.equal(['']); - expectFuzzStrings({ allowedChars: ['a'], maxLength: 0 }).to.deep.equal([ - '', - ]); - }); - - it('generate strings with single character', () => { - expectFuzzStrings({ allowedChars: ['a'], maxLength: 1 }).to.deep.equal([ - '', - 'a', - ]); - - expectFuzzStrings({ - allowedChars: ['a', 'b', 'c'], - maxLength: 1, - }).to.deep.equal(['', 'a', 'b', 'c']); - }); - - it('generate strings with multiple character', () => { - expectFuzzStrings({ allowedChars: ['a'], maxLength: 2 }).to.deep.equal([ - '', - 'a', - 'aa', - ]); - - expectFuzzStrings({ - allowedChars: ['a', 'b', 'c'], - maxLength: 2, - }).to.deep.equal([ - '', - 'a', - 'b', - 'c', - 'aa', - 'ab', - 'ac', - 'ba', - 'bb', - 'bc', - 'ca', - 'cb', - 'cc', - ]); - }); - - it('generate strings longer than possible number of characters', () => { - expectFuzzStrings({ - allowedChars: ['a', 'b'], - maxLength: 3, - }).to.deep.equal([ - '', - 'a', - 'b', - 'aa', - 'ab', - 'ba', - 'bb', - 'aaa', - 'aab', - 'aba', - 'abb', - 'baa', - 'bab', - 'bba', - 'bbb', - ]); - }); -}); diff --git a/src/__testUtils__/__tests__/inspectStr-test.ts b/src/__testUtils__/__tests__/inspectStr-test.ts deleted file mode 100644 index 9c3eba3a95..0000000000 --- a/src/__testUtils__/__tests__/inspectStr-test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { inspectStr } from '../inspectStr'; - -describe('inspectStr', () => { - it('handles null and undefined values', () => { - expect(inspectStr(null)).to.equal('null'); - expect(inspectStr(undefined)).to.equal('null'); - }); - - it('correctly print various strings', () => { - expect(inspectStr('')).to.equal('``'); - expect(inspectStr('a')).to.equal('`a`'); - expect(inspectStr('"')).to.equal('`"`'); - expect(inspectStr("'")).to.equal("`'`"); - expect(inspectStr('\\"')).to.equal('`\\"`'); - }); -}); diff --git a/src/__testUtils__/__tests__/resolveOnNextTick-test.ts b/src/__testUtils__/__tests__/resolveOnNextTick-test.ts deleted file mode 100644 index 0916b44a0c..0000000000 --- a/src/__testUtils__/__tests__/resolveOnNextTick-test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { resolveOnNextTick } from '../resolveOnNextTick'; - -describe('resolveOnNextTick', () => { - it('resolves promise on the next tick', async () => { - const output = []; - - const promise1 = resolveOnNextTick().then(() => { - output.push('second'); - }); - const promise2 = resolveOnNextTick().then(() => { - output.push('third'); - }); - output.push('first'); - - await Promise.all([promise1, promise2]); - expect(output).to.deep.equal(['first', 'second', 'third']); - }); -}); diff --git a/src/__testUtils__/dedent.ts b/src/__testUtils__/dedent.ts deleted file mode 100644 index 7fc6b46345..0000000000 --- a/src/__testUtils__/dedent.ts +++ /dev/null @@ -1,41 +0,0 @@ -export function dedentString(string: string): string { - const trimmedStr = string - .replace(/^\n*/m, '') // remove leading newline - .replace(/[ \t\n]*$/, ''); // remove trailing spaces and tabs - - // fixes indentation by removing leading spaces and tabs from each line - let indent = ''; - for (const char of trimmedStr) { - if (char !== ' ' && char !== '\t') { - break; - } - indent += char; - } - - return trimmedStr.replace(RegExp('^' + indent, 'mg'), ''); // remove indent -} - -/** - * An ES6 string tag that fixes indentation and also trims string. - * - * Example usage: - * ```ts - * const str = dedent` - * { - * test - * } - * `; - * str === "{\n test\n}"; - * ``` - */ -export function dedent( - strings: ReadonlyArray, - ...values: ReadonlyArray -): string { - let str = strings[0]; - - for (let i = 1; i < strings.length; ++i) { - str += values[i - 1] + strings[i]; // interpolation - } - return dedentString(str); -} diff --git a/src/__testUtils__/expectJSON.ts b/src/__testUtils__/expectJSON.ts deleted file mode 100644 index 64e2ba5dea..0000000000 --- a/src/__testUtils__/expectJSON.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { expect } from 'chai'; - -import { isObjectLike } from '../jsutils/isObjectLike'; -import { mapValue } from '../jsutils/mapValue'; - -/** - * Deeply transforms an arbitrary value to a JSON-safe value by calling toJSON - * on any nested value which defines it. - */ -function toJSONDeep(value: unknown): unknown { - if (!isObjectLike(value)) { - return value; - } - - if (typeof value.toJSON === 'function') { - return value.toJSON(); - } - - if (Array.isArray(value)) { - return value.map(toJSONDeep); - } - - return mapValue(value, toJSONDeep); -} - -export function expectJSON(actual: unknown) { - const actualJSON = toJSONDeep(actual); - - return { - toDeepEqual(expected: unknown) { - const expectedJSON = toJSONDeep(expected); - expect(actualJSON).to.deep.equal(expectedJSON); - }, - toDeepNestedProperty(path: string, expected: unknown) { - const expectedJSON = toJSONDeep(expected); - expect(actualJSON).to.deep.nested.property(path, expectedJSON); - }, - }; -} - -export function expectToThrowJSON(fn: () => unknown) { - function mapException(): unknown { - try { - return fn(); - } catch (error) { - throw toJSONDeep(error); - } - } - - return expect(mapException).to.throw(); -} diff --git a/src/__testUtils__/genFuzzStrings.ts b/src/__testUtils__/genFuzzStrings.ts deleted file mode 100644 index f29e1bb860..0000000000 --- a/src/__testUtils__/genFuzzStrings.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Generator that produces all possible combinations of allowed characters. - */ -export function* genFuzzStrings(options: { - allowedChars: ReadonlyArray; - maxLength: number; -}): Generator { - const { allowedChars, maxLength } = options; - const numAllowedChars = allowedChars.length; - - let numCombinations = 0; - for (let length = 1; length <= maxLength; ++length) { - numCombinations += numAllowedChars ** length; - } - - yield ''; // special case for empty string - for (let combination = 0; combination < numCombinations; ++combination) { - let permutation = ''; - - let leftOver = combination; - while (leftOver >= 0) { - const reminder = leftOver % numAllowedChars; - permutation = allowedChars[reminder] + permutation; - leftOver = (leftOver - reminder) / numAllowedChars - 1; - } - - yield permutation; - } -} diff --git a/src/__testUtils__/inspectStr.ts b/src/__testUtils__/inspectStr.ts deleted file mode 100644 index 721d6e673a..0000000000 --- a/src/__testUtils__/inspectStr.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; - -/** - * Special inspect function to produce readable string literal for error messages in tests - */ -export function inspectStr(str: Maybe): string { - if (str == null) { - return 'null'; - } - return JSON.stringify(str) - .replace(/^"|"$/g, '`') - .replace(/\\"/g, '"') - .replace(/\\\\/g, '\\'); -} diff --git a/src/__testUtils__/kitchenSinkQuery.ts b/src/__testUtils__/kitchenSinkQuery.ts deleted file mode 100644 index 9ed9a7e983..0000000000 --- a/src/__testUtils__/kitchenSinkQuery.ts +++ /dev/null @@ -1,68 +0,0 @@ -export const kitchenSinkQuery: string = String.raw` -query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery { - whoever123is: node(id: [123, 456]) { - id - ... on User @onInlineFragment { - field2 { - id - alias: field1(first: 10, after: $foo) @include(if: $foo) { - id - ...frag @onFragmentSpread - } - } - } - ... @skip(unless: $foo) { - id - } - ... { - id - } - } -} - -mutation likeStory @onMutation { - like(story: 123) @onField { - story { - id @onField - } - } -} - -subscription StoryLikeSubscription( - $input: StoryLikeSubscribeInput @onVariableDefinition -) - @onSubscription { - storyLikeSubscribe(input: $input) { - story { - likers { - count - } - likeSentence { - text - } - } - } -} - -fragment frag on Friend @onFragmentDefinition { - foo( - size: $size - bar: $b - obj: { - key: "value" - block: """ - block string uses \""" - """ - } - ) -} - -{ - unnamed(truthy: true, falsy: false, nullish: null) - query -} - -query { - __typename -} -`; diff --git a/src/__testUtils__/kitchenSinkSDL.ts b/src/__testUtils__/kitchenSinkSDL.ts deleted file mode 100644 index 7b7a537783..0000000000 --- a/src/__testUtils__/kitchenSinkSDL.ts +++ /dev/null @@ -1,164 +0,0 @@ -export const kitchenSinkSDL = ` -"""This is a description of the schema as a whole.""" -schema { - query: QueryType - mutation: MutationType -} - -""" -This is a description -of the \`Foo\` type. -""" -type Foo implements Bar & Baz & Two { - "Description of the \`one\` field." - one: Type - """ - This is a description of the \`two\` field. - """ - two( - """ - This is a description of the \`argument\` argument. - """ - argument: InputType! - ): Type - """This is a description of the \`three\` field.""" - three(argument: InputType, other: String): Int - four(argument: String = "string"): String - five(argument: [String] = ["string", "string"]): String - six(argument: InputType = {key: "value"}): Type - seven(argument: Int = null): Type - eight(argument: OneOfInputType): Type -} - -type AnnotatedObject @onObject(arg: "value") { - annotatedField(arg: Type = "default" @onArgumentDefinition): Type @onField -} - -type UndefinedType - -extend type Foo { - seven(argument: [String]): Type -} - -extend type Foo @onType - -interface Bar { - one: Type - four(argument: String = "string"): String -} - -interface AnnotatedInterface @onInterface { - annotatedField(arg: Type @onArgumentDefinition): Type @onField -} - -interface UndefinedInterface - -extend interface Bar implements Two { - two(argument: InputType!): Type -} - -extend interface Bar @onInterface - -interface Baz implements Bar & Two { - one: Type - two(argument: InputType!): Type - four(argument: String = "string"): String -} - -union Feed = - | Story - | Article - | Advert - -union AnnotatedUnion @onUnion = A | B - -union AnnotatedUnionTwo @onUnion = | A | B - -union UndefinedUnion - -extend union Feed = Photo | Video - -extend union Feed @onUnion - -scalar CustomScalar - -scalar AnnotatedScalar @onScalar - -extend scalar CustomScalar @onScalar - -enum Site { - """ - This is a description of the \`DESKTOP\` value - """ - DESKTOP - - """This is a description of the \`MOBILE\` value""" - MOBILE - - "This is a description of the \`WEB\` value" - WEB -} - -enum AnnotatedEnum @onEnum { - ANNOTATED_VALUE @onEnumValue - OTHER_VALUE -} - -enum UndefinedEnum - -extend enum Site { - VR -} - -extend enum Site @onEnum - -input InputType { - key: String! - answer: Int = 42 -} - -input OneOfInputType @oneOf { - string: String - int: Int -} - -input AnnotatedInput @onInputObject { - annotatedField: Type @onInputFieldDefinition -} - -input UndefinedInput - -extend input InputType { - other: Float = 1.23e4 @onInputFieldDefinition -} - -extend input InputType @onInputObject - -""" -This is a description of the \`@skip\` directive -""" -directive @skip( - """This is a description of the \`if\` argument""" - if: Boolean! @onArgumentDefinition -) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - -directive @include(if: Boolean!) - on FIELD - | FRAGMENT_SPREAD - | INLINE_FRAGMENT - -directive @include2(if: Boolean!) on - | FIELD - | FRAGMENT_SPREAD - | INLINE_FRAGMENT - -directive @myRepeatableDir(name: String!) repeatable on - | OBJECT - | INTERFACE - -extend schema @onSchema - -extend schema @onSchema { - subscription: SubscriptionType -} -`; diff --git a/src/__testUtils__/resolveOnNextTick.ts b/src/__testUtils__/resolveOnNextTick.ts deleted file mode 100644 index 6dd50b3982..0000000000 --- a/src/__testUtils__/resolveOnNextTick.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function resolveOnNextTick(): Promise { - return Promise.resolve(undefined); -} diff --git a/src/__tests__/starWarsData.ts b/src/__tests__/starWarsData.ts deleted file mode 100644 index 60c4331bb6..0000000000 --- a/src/__tests__/starWarsData.ts +++ /dev/null @@ -1,154 +0,0 @@ -/** - * These are types which correspond to the schema. - * They represent the shape of the data visited during field resolution. - */ -export interface Character { - id: string; - name: string; - friends: ReadonlyArray; - appearsIn: ReadonlyArray; -} - -export interface Human { - type: 'Human'; - id: string; - name: string; - friends: ReadonlyArray; - appearsIn: ReadonlyArray; - homePlanet?: string; -} - -export interface Droid { - type: 'Droid'; - id: string; - name: string; - friends: ReadonlyArray; - appearsIn: ReadonlyArray; - primaryFunction: string; -} - -/** - * This defines a basic set of data for our Star Wars Schema. - * - * This data is hard coded for the sake of the demo, but you could imagine - * fetching this data from a backend service rather than from hardcoded - * JSON objects in a more complex demo. - */ - -const luke: Human = { - type: 'Human', - id: '1000', - name: 'Luke Skywalker', - friends: ['1002', '1003', '2000', '2001'], - appearsIn: [4, 5, 6], - homePlanet: 'Tatooine', -}; - -const vader: Human = { - type: 'Human', - id: '1001', - name: 'Darth Vader', - friends: ['1004'], - appearsIn: [4, 5, 6], - homePlanet: 'Tatooine', -}; - -const han: Human = { - type: 'Human', - id: '1002', - name: 'Han Solo', - friends: ['1000', '1003', '2001'], - appearsIn: [4, 5, 6], -}; - -const leia: Human = { - type: 'Human', - id: '1003', - name: 'Leia Organa', - friends: ['1000', '1002', '2000', '2001'], - appearsIn: [4, 5, 6], - homePlanet: 'Alderaan', -}; - -const tarkin: Human = { - type: 'Human', - id: '1004', - name: 'Wilhuff Tarkin', - friends: ['1001'], - appearsIn: [4], -}; - -const humanData: { [id: string]: Human } = { - [luke.id]: luke, - [vader.id]: vader, - [han.id]: han, - [leia.id]: leia, - [tarkin.id]: tarkin, -}; - -const threepio: Droid = { - type: 'Droid', - id: '2000', - name: 'C-3PO', - friends: ['1000', '1002', '1003', '2001'], - appearsIn: [4, 5, 6], - primaryFunction: 'Protocol', -}; - -const artoo: Droid = { - type: 'Droid', - id: '2001', - name: 'R2-D2', - friends: ['1000', '1002', '1003'], - appearsIn: [4, 5, 6], - primaryFunction: 'Astromech', -}; - -const droidData: { [id: string]: Droid } = { - [threepio.id]: threepio, - [artoo.id]: artoo, -}; - -/** - * Helper function to get a character by ID. - */ -function getCharacter(id: string): Promise { - // Returning a promise just to illustrate that GraphQL.js supports it. - return Promise.resolve(humanData[id] ?? droidData[id]); -} - -/** - * Allows us to query for a character's friends. - */ -export function getFriends( - character: Character, -): Array> { - // Notice that GraphQL accepts Arrays of Promises. - return character.friends.map((id) => getCharacter(id)); -} - -/** - * Allows us to fetch the undisputed hero of the Star Wars trilogy, R2-D2. - */ -export function getHero(episode: number): Character { - if (episode === 5) { - // Luke is the hero of Episode V. - return luke; - } - // Artoo is the hero otherwise. - return artoo; -} - -/** - * Allows us to query for the human with the given id. - */ -export function getHuman(id: string): Human | null { - return humanData[id]; -} - -/** - * Allows us to query for the droid with the given id. - */ -export function getDroid(id: string): Droid | null { - return droidData[id]; -} diff --git a/src/__tests__/starWarsIntrospection-test.ts b/src/__tests__/starWarsIntrospection-test.ts deleted file mode 100644 index d637787c4a..0000000000 --- a/src/__tests__/starWarsIntrospection-test.ts +++ /dev/null @@ -1,366 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { graphqlSync } from '../graphql'; - -import { StarWarsSchema } from './starWarsSchema'; - -function queryStarWars(source: string) { - const result = graphqlSync({ schema: StarWarsSchema, source }); - expect(Object.keys(result)).to.deep.equal(['data']); - return result.data; -} - -describe('Star Wars Introspection Tests', () => { - describe('Basic Introspection', () => { - it('Allows querying the schema for types', () => { - const data = queryStarWars(` - { - __schema { - types { - name - } - } - } - `); - - // Include all types used by StarWars schema, introspection types and - // standard directives. For example, `Boolean` is used in `@skip`, - // `@include` and also inside introspection types. - expect(data).to.deep.equal({ - __schema: { - types: [ - { name: 'Human' }, - { name: 'Character' }, - { name: 'String' }, - { name: 'Episode' }, - { name: 'Droid' }, - { name: 'Query' }, - { name: 'Boolean' }, - { name: '__Schema' }, - { name: '__Type' }, - { name: '__TypeKind' }, - { name: '__Field' }, - { name: '__InputValue' }, - { name: '__EnumValue' }, - { name: '__Directive' }, - { name: '__DirectiveLocation' }, - ], - }, - }); - }); - - it('Allows querying the schema for query type', () => { - const data = queryStarWars(` - { - __schema { - queryType { - name - } - } - } - `); - - expect(data).to.deep.equal({ - __schema: { - queryType: { - name: 'Query', - }, - }, - }); - }); - - it('Allows querying the schema for a specific type', () => { - const data = queryStarWars(` - { - __type(name: "Droid") { - name - } - } - `); - - expect(data).to.deep.equal({ - __type: { - name: 'Droid', - }, - }); - }); - - it('Allows querying the schema for an object kind', () => { - const data = queryStarWars(` - { - __type(name: "Droid") { - name - kind - } - } - `); - - expect(data).to.deep.equal({ - __type: { - name: 'Droid', - kind: 'OBJECT', - }, - }); - }); - - it('Allows querying the schema for an interface kind', () => { - const data = queryStarWars(` - { - __type(name: "Character") { - name - kind - } - } - `); - - expect(data).to.deep.equal({ - __type: { - name: 'Character', - kind: 'INTERFACE', - }, - }); - }); - - it('Allows querying the schema for object fields', () => { - const data = queryStarWars(` - { - __type(name: "Droid") { - name - fields { - name - type { - name - kind - } - } - } - } - `); - - expect(data).to.deep.equal({ - __type: { - name: 'Droid', - fields: [ - { - name: 'id', - type: { name: null, kind: 'NON_NULL' }, - }, - { - name: 'name', - type: { name: 'String', kind: 'SCALAR' }, - }, - { - name: 'friends', - type: { name: null, kind: 'LIST' }, - }, - { - name: 'appearsIn', - type: { name: null, kind: 'LIST' }, - }, - { - name: 'secretBackstory', - type: { name: 'String', kind: 'SCALAR' }, - }, - { - name: 'primaryFunction', - type: { name: 'String', kind: 'SCALAR' }, - }, - ], - }, - }); - }); - - it('Allows querying the schema for nested object fields', () => { - const data = queryStarWars(` - { - __type(name: "Droid") { - name - fields { - name - type { - name - kind - ofType { - name - kind - } - } - } - } - } - `); - - expect(data).to.deep.equal({ - __type: { - name: 'Droid', - fields: [ - { - name: 'id', - type: { - name: null, - kind: 'NON_NULL', - ofType: { - name: 'String', - kind: 'SCALAR', - }, - }, - }, - { - name: 'name', - type: { - name: 'String', - kind: 'SCALAR', - ofType: null, - }, - }, - { - name: 'friends', - type: { - name: null, - kind: 'LIST', - ofType: { - name: 'Character', - kind: 'INTERFACE', - }, - }, - }, - { - name: 'appearsIn', - type: { - name: null, - kind: 'LIST', - ofType: { - name: 'Episode', - kind: 'ENUM', - }, - }, - }, - { - name: 'secretBackstory', - type: { - name: 'String', - kind: 'SCALAR', - ofType: null, - }, - }, - { - name: 'primaryFunction', - type: { - name: 'String', - kind: 'SCALAR', - ofType: null, - }, - }, - ], - }, - }); - }); - - it('Allows querying the schema for field args', () => { - const data = queryStarWars(` - { - __schema { - queryType { - fields { - name - args { - name - description - type { - name - kind - ofType { - name - kind - } - } - defaultValue - } - } - } - } - } - `); - - expect(data).to.deep.equal({ - __schema: { - queryType: { - fields: [ - { - name: 'hero', - args: [ - { - defaultValue: null, - description: - 'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.', - name: 'episode', - type: { - kind: 'ENUM', - name: 'Episode', - ofType: null, - }, - }, - ], - }, - { - name: 'human', - args: [ - { - name: 'id', - description: 'id of the human', - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - }, - }, - defaultValue: null, - }, - ], - }, - { - name: 'droid', - args: [ - { - name: 'id', - description: 'id of the droid', - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - }, - }, - defaultValue: null, - }, - ], - }, - ], - }, - }, - }); - }); - - it('Allows querying the schema for documentation', () => { - const data = queryStarWars(` - { - __type(name: "Droid") { - name - description - } - } - `); - - expect(data).to.deep.equal({ - __type: { - name: 'Droid', - description: 'A mechanical creature in the Star Wars universe.', - }, - }); - }); - }); -}); diff --git a/src/__tests__/starWarsQuery-test.ts b/src/__tests__/starWarsQuery-test.ts deleted file mode 100644 index 2662079d01..0000000000 --- a/src/__tests__/starWarsQuery-test.ts +++ /dev/null @@ -1,497 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../__testUtils__/expectJSON'; - -import { graphql } from '../graphql'; - -import { StarWarsSchema as schema } from './starWarsSchema'; - -describe('Star Wars Query Tests', () => { - describe('Basic Queries', () => { - it('Correctly identifies R2-D2 as the hero of the Star Wars Saga', async () => { - const source = ` - query HeroNameQuery { - hero { - name - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - hero: { - name: 'R2-D2', - }, - }, - }); - }); - - it('Allows us to query for the ID and friends of R2-D2', async () => { - const source = ` - query HeroNameAndFriendsQuery { - hero { - id - name - friends { - name - } - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - hero: { - id: '2001', - name: 'R2-D2', - friends: [ - { - name: 'Luke Skywalker', - }, - { - name: 'Han Solo', - }, - { - name: 'Leia Organa', - }, - ], - }, - }, - }); - }); - }); - - describe('Nested Queries', () => { - it('Allows us to query for the friends of friends of R2-D2', async () => { - const source = ` - query NestedQuery { - hero { - name - friends { - name - appearsIn - friends { - name - } - } - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - hero: { - name: 'R2-D2', - friends: [ - { - name: 'Luke Skywalker', - appearsIn: ['NEW_HOPE', 'EMPIRE', 'JEDI'], - friends: [ - { - name: 'Han Solo', - }, - { - name: 'Leia Organa', - }, - { - name: 'C-3PO', - }, - { - name: 'R2-D2', - }, - ], - }, - { - name: 'Han Solo', - appearsIn: ['NEW_HOPE', 'EMPIRE', 'JEDI'], - friends: [ - { - name: 'Luke Skywalker', - }, - { - name: 'Leia Organa', - }, - { - name: 'R2-D2', - }, - ], - }, - { - name: 'Leia Organa', - appearsIn: ['NEW_HOPE', 'EMPIRE', 'JEDI'], - friends: [ - { - name: 'Luke Skywalker', - }, - { - name: 'Han Solo', - }, - { - name: 'C-3PO', - }, - { - name: 'R2-D2', - }, - ], - }, - ], - }, - }, - }); - }); - }); - - describe('Using IDs and query parameters to refetch objects', () => { - it('Allows us to query characters directly, using their IDs', async () => { - const source = ` - query FetchLukeAndC3POQuery { - human(id: "1000") { - name - } - droid(id: "2000") { - name - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - human: { - name: 'Luke Skywalker', - }, - droid: { - name: 'C-3PO', - }, - }, - }); - }); - - it('Allows us to create a generic query, then use it to fetch Luke Skywalker using his ID', async () => { - const source = ` - query FetchSomeIDQuery($someId: String!) { - human(id: $someId) { - name - } - } - `; - const variableValues = { someId: '1000' }; - - const result = await graphql({ schema, source, variableValues }); - expect(result).to.deep.equal({ - data: { - human: { - name: 'Luke Skywalker', - }, - }, - }); - }); - - it('Allows us to create a generic query, then use it to fetch Han Solo using his ID', async () => { - const source = ` - query FetchSomeIDQuery($someId: String!) { - human(id: $someId) { - name - } - } - `; - const variableValues = { someId: '1002' }; - - const result = await graphql({ schema, source, variableValues }); - expect(result).to.deep.equal({ - data: { - human: { - name: 'Han Solo', - }, - }, - }); - }); - - it('Allows us to create a generic query, then pass an invalid ID to get null back', async () => { - const source = ` - query humanQuery($id: String!) { - human(id: $id) { - name - } - } - `; - const variableValues = { id: 'not a valid id' }; - - const result = await graphql({ schema, source, variableValues }); - expect(result).to.deep.equal({ - data: { - human: null, - }, - }); - }); - }); - - describe('Using aliases to change the key in the response', () => { - it('Allows us to query for Luke, changing his key with an alias', async () => { - const source = ` - query FetchLukeAliased { - luke: human(id: "1000") { - name - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - luke: { - name: 'Luke Skywalker', - }, - }, - }); - }); - - it('Allows us to query for both Luke and Leia, using two root fields and an alias', async () => { - const source = ` - query FetchLukeAndLeiaAliased { - luke: human(id: "1000") { - name - } - leia: human(id: "1003") { - name - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - luke: { - name: 'Luke Skywalker', - }, - leia: { - name: 'Leia Organa', - }, - }, - }); - }); - }); - - describe('Uses fragments to express more complex queries', () => { - it('Allows us to query using duplicated content', async () => { - const source = ` - query DuplicateFields { - luke: human(id: "1000") { - name - homePlanet - } - leia: human(id: "1003") { - name - homePlanet - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - luke: { - name: 'Luke Skywalker', - homePlanet: 'Tatooine', - }, - leia: { - name: 'Leia Organa', - homePlanet: 'Alderaan', - }, - }, - }); - }); - - it('Allows us to use a fragment to avoid duplicating content', async () => { - const source = ` - query UseFragment { - luke: human(id: "1000") { - ...HumanFragment - } - leia: human(id: "1003") { - ...HumanFragment - } - } - - fragment HumanFragment on Human { - name - homePlanet - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - luke: { - name: 'Luke Skywalker', - homePlanet: 'Tatooine', - }, - leia: { - name: 'Leia Organa', - homePlanet: 'Alderaan', - }, - }, - }); - }); - }); - - describe('Using __typename to find the type of an object', () => { - it('Allows us to verify that R2-D2 is a droid', async () => { - const source = ` - query CheckTypeOfR2 { - hero { - __typename - name - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - hero: { - __typename: 'Droid', - name: 'R2-D2', - }, - }, - }); - }); - - it('Allows us to verify that Luke is a human', async () => { - const source = ` - query CheckTypeOfLuke { - hero(episode: EMPIRE) { - __typename - name - } - } - `; - - const result = await graphql({ schema, source }); - expect(result).to.deep.equal({ - data: { - hero: { - __typename: 'Human', - name: 'Luke Skywalker', - }, - }, - }); - }); - }); - - describe('Reporting errors raised in resolvers', () => { - it('Correctly reports error on accessing secretBackstory', async () => { - const source = ` - query HeroNameQuery { - hero { - name - secretBackstory - } - } - `; - - const result = await graphql({ schema, source }); - expectJSON(result).toDeepEqual({ - data: { - hero: { - name: 'R2-D2', - secretBackstory: null, - }, - }, - errors: [ - { - message: 'secretBackstory is secret.', - locations: [{ line: 5, column: 13 }], - path: ['hero', 'secretBackstory'], - }, - ], - }); - }); - - it('Correctly reports error on accessing secretBackstory in a list', async () => { - const source = ` - query HeroNameQuery { - hero { - name - friends { - name - secretBackstory - } - } - } - `; - - const result = await graphql({ schema, source }); - expectJSON(result).toDeepEqual({ - data: { - hero: { - name: 'R2-D2', - friends: [ - { - name: 'Luke Skywalker', - secretBackstory: null, - }, - { - name: 'Han Solo', - secretBackstory: null, - }, - { - name: 'Leia Organa', - secretBackstory: null, - }, - ], - }, - }, - errors: [ - { - message: 'secretBackstory is secret.', - locations: [{ line: 7, column: 15 }], - path: ['hero', 'friends', 0, 'secretBackstory'], - }, - { - message: 'secretBackstory is secret.', - locations: [{ line: 7, column: 15 }], - path: ['hero', 'friends', 1, 'secretBackstory'], - }, - { - message: 'secretBackstory is secret.', - locations: [{ line: 7, column: 15 }], - path: ['hero', 'friends', 2, 'secretBackstory'], - }, - ], - }); - }); - - it('Correctly reports error on accessing through an alias', async () => { - const source = ` - query HeroNameQuery { - mainHero: hero { - name - story: secretBackstory - } - } - `; - - const result = await graphql({ schema, source }); - expectJSON(result).toDeepEqual({ - data: { - mainHero: { - name: 'R2-D2', - story: null, - }, - }, - errors: [ - { - message: 'secretBackstory is secret.', - locations: [{ line: 5, column: 13 }], - path: ['mainHero', 'story'], - }, - ], - }); - }); - }); -}); diff --git a/src/__tests__/starWarsSchema.ts b/src/__tests__/starWarsSchema.ts deleted file mode 100644 index c646c8aea3..0000000000 --- a/src/__tests__/starWarsSchema.ts +++ /dev/null @@ -1,303 +0,0 @@ -import { - GraphQLEnumType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, -} from '../type/definition'; -import { GraphQLString } from '../type/scalars'; -import { GraphQLSchema } from '../type/schema'; - -import { getDroid, getFriends, getHero, getHuman } from './starWarsData'; - -/** - * This is designed to be an end-to-end test, demonstrating - * the full GraphQL stack. - * - * We will create a GraphQL schema that describes the major - * characters in the original Star Wars trilogy. - * - * NOTE: This may contain spoilers for the original Star - * Wars trilogy. - */ - -/** - * Using our shorthand to describe type systems, the type system for our - * Star Wars example is: - * - * ```graphql - * enum Episode { NEW_HOPE, EMPIRE, JEDI } - * - * interface Character { - * id: String! - * name: String - * friends: [Character] - * appearsIn: [Episode] - * } - * - * type Human implements Character { - * id: String! - * name: String - * friends: [Character] - * appearsIn: [Episode] - * homePlanet: String - * } - * - * type Droid implements Character { - * id: String! - * name: String - * friends: [Character] - * appearsIn: [Episode] - * primaryFunction: String - * } - * - * type Query { - * hero(episode: Episode): Character - * human(id: String!): Human - * droid(id: String!): Droid - * } - * ``` - * - * We begin by setting up our schema. - */ - -/** - * The original trilogy consists of three movies. - * - * This implements the following type system shorthand: - * ```graphql - * enum Episode { NEW_HOPE, EMPIRE, JEDI } - * ``` - */ -const episodeEnum = new GraphQLEnumType({ - name: 'Episode', - description: 'One of the films in the Star Wars Trilogy', - values: { - NEW_HOPE: { - value: 4, - description: 'Released in 1977.', - }, - EMPIRE: { - value: 5, - description: 'Released in 1980.', - }, - JEDI: { - value: 6, - description: 'Released in 1983.', - }, - }, -}); - -/** - * Characters in the Star Wars trilogy are either humans or droids. - * - * This implements the following type system shorthand: - * ```graphql - * interface Character { - * id: String! - * name: String - * friends: [Character] - * appearsIn: [Episode] - * secretBackstory: String - * } - * ``` - */ -const characterInterface: GraphQLInterfaceType = new GraphQLInterfaceType({ - name: 'Character', - description: 'A character in the Star Wars Trilogy', - fields: () => ({ - id: { - type: new GraphQLNonNull(GraphQLString), - description: 'The id of the character.', - }, - name: { - type: GraphQLString, - description: 'The name of the character.', - }, - friends: { - type: new GraphQLList(characterInterface), - description: - 'The friends of the character, or an empty list if they have none.', - }, - appearsIn: { - type: new GraphQLList(episodeEnum), - description: 'Which movies they appear in.', - }, - secretBackstory: { - type: GraphQLString, - description: 'All secrets about their past.', - }, - }), - resolveType(character) { - switch (character.type) { - case 'Human': - return humanType.name; - case 'Droid': - return droidType.name; - } - }, -}); - -/** - * We define our human type, which implements the character interface. - * - * This implements the following type system shorthand: - * ```graphql - * type Human : Character { - * id: String! - * name: String - * friends: [Character] - * appearsIn: [Episode] - * secretBackstory: String - * } - * ``` - */ -const humanType = new GraphQLObjectType({ - name: 'Human', - description: 'A humanoid creature in the Star Wars universe.', - fields: () => ({ - id: { - type: new GraphQLNonNull(GraphQLString), - description: 'The id of the human.', - }, - name: { - type: GraphQLString, - description: 'The name of the human.', - }, - friends: { - type: new GraphQLList(characterInterface), - description: - 'The friends of the human, or an empty list if they have none.', - resolve: (human) => getFriends(human), - }, - appearsIn: { - type: new GraphQLList(episodeEnum), - description: 'Which movies they appear in.', - }, - homePlanet: { - type: GraphQLString, - description: 'The home planet of the human, or null if unknown.', - }, - secretBackstory: { - type: GraphQLString, - description: 'Where are they from and how they came to be who they are.', - resolve() { - throw new Error('secretBackstory is secret.'); - }, - }, - }), - interfaces: [characterInterface], -}); - -/** - * The other type of character in Star Wars is a droid. - * - * This implements the following type system shorthand: - * ```graphql - * type Droid : Character { - * id: String! - * name: String - * friends: [Character] - * appearsIn: [Episode] - * secretBackstory: String - * primaryFunction: String - * } - * ``` - */ -const droidType = new GraphQLObjectType({ - name: 'Droid', - description: 'A mechanical creature in the Star Wars universe.', - fields: () => ({ - id: { - type: new GraphQLNonNull(GraphQLString), - description: 'The id of the droid.', - }, - name: { - type: GraphQLString, - description: 'The name of the droid.', - }, - friends: { - type: new GraphQLList(characterInterface), - description: - 'The friends of the droid, or an empty list if they have none.', - resolve: (droid) => getFriends(droid), - }, - appearsIn: { - type: new GraphQLList(episodeEnum), - description: 'Which movies they appear in.', - }, - secretBackstory: { - type: GraphQLString, - description: 'Construction date and the name of the designer.', - resolve() { - throw new Error('secretBackstory is secret.'); - }, - }, - primaryFunction: { - type: GraphQLString, - description: 'The primary function of the droid.', - }, - }), - interfaces: [characterInterface], -}); - -/** - * This is the type that will be the root of our query, and the - * entry point into our schema. It gives us the ability to fetch - * objects by their IDs, as well as to fetch the undisputed hero - * of the Star Wars trilogy, R2-D2, directly. - * - * This implements the following type system shorthand: - * ```graphql - * type Query { - * hero(episode: Episode): Character - * human(id: String!): Human - * droid(id: String!): Droid - * } - * ``` - */ -const queryType = new GraphQLObjectType({ - name: 'Query', - fields: () => ({ - hero: { - type: characterInterface, - args: { - episode: { - description: - 'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.', - type: episodeEnum, - }, - }, - resolve: (_source, { episode }) => getHero(episode), - }, - human: { - type: humanType, - args: { - id: { - description: 'id of the human', - type: new GraphQLNonNull(GraphQLString), - }, - }, - resolve: (_source, { id }) => getHuman(id), - }, - droid: { - type: droidType, - args: { - id: { - description: 'id of the droid', - type: new GraphQLNonNull(GraphQLString), - }, - }, - resolve: (_source, { id }) => getDroid(id), - }, - }), -}); - -/** - * Finally, we construct our schema (whose starting query type is the query - * type we defined above) and export it. - */ -export const StarWarsSchema: GraphQLSchema = new GraphQLSchema({ - query: queryType, - types: [humanType, droidType], -}); diff --git a/src/__tests__/starWarsValidation-test.ts b/src/__tests__/starWarsValidation-test.ts deleted file mode 100644 index 65e6c7f666..0000000000 --- a/src/__tests__/starWarsValidation-test.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../language/parser'; -import { Source } from '../language/source'; - -import { validate } from '../validation/validate'; - -import { StarWarsSchema } from './starWarsSchema'; - -/** - * Helper function to test a query and the expected response. - */ -function validationErrors(query: string) { - const source = new Source(query, 'StarWars.graphql'); - const ast = parse(source); - return validate(StarWarsSchema, ast); -} - -describe('Star Wars Validation Tests', () => { - describe('Basic Queries', () => { - it('Validates a complex but valid query', () => { - const query = ` - query NestedQueryWithFragment { - hero { - ...NameAndAppearances - friends { - ...NameAndAppearances - friends { - ...NameAndAppearances - } - } - } - } - - fragment NameAndAppearances on Character { - name - appearsIn - } - `; - return expect(validationErrors(query)).to.be.empty; - }); - - it('Notes that non-existent fields are invalid', () => { - const query = ` - query HeroSpaceshipQuery { - hero { - favoriteSpaceship - } - } - `; - return expect(validationErrors(query)).to.not.be.empty; - }); - - it('Requires fields on objects', () => { - const query = ` - query HeroNoFieldsQuery { - hero - } - `; - return expect(validationErrors(query)).to.not.be.empty; - }); - - it('Disallows fields on scalars', () => { - const query = ` - query HeroFieldsOnScalarQuery { - hero { - name { - firstCharacterOfName - } - } - } - `; - return expect(validationErrors(query)).to.not.be.empty; - }); - - it('Disallows object fields on interfaces', () => { - const query = ` - query DroidFieldOnCharacter { - hero { - name - primaryFunction - } - } - `; - return expect(validationErrors(query)).to.not.be.empty; - }); - - it('Allows object fields in fragments', () => { - const query = ` - query DroidFieldInFragment { - hero { - name - ...DroidFields - } - } - - fragment DroidFields on Droid { - primaryFunction - } - `; - return expect(validationErrors(query)).to.be.empty; - }); - - it('Allows object fields in inline fragments', () => { - const query = ` - query DroidFieldInFragment { - hero { - name - ... on Droid { - primaryFunction - } - } - } - `; - return expect(validationErrors(query)).to.be.empty; - }); - }); -}); diff --git a/src/__tests__/version-test.ts b/src/__tests__/version-test.ts deleted file mode 100644 index 3680512de8..0000000000 --- a/src/__tests__/version-test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { version, versionInfo } from '../version'; - -describe('Version', () => { - it('versionInfo', () => { - expect(versionInfo).to.be.an('object'); - expect(versionInfo).to.have.all.keys( - 'major', - 'minor', - 'patch', - 'preReleaseTag', - ); - - const { major, minor, patch, preReleaseTag } = versionInfo; - expect(major).to.be.a('number').at.least(0); - expect(minor).to.be.a('number').at.least(0); - expect(patch).to.be.a('number').at.least(0); - - // Can't be verified on all versions - /* c8 ignore start */ - switch (preReleaseTag?.split('.').length) { - case undefined: - break; - case 2: - expect(preReleaseTag).to.match( - /^(alpha|beta|rc|experimental-[\w-]+)\.\d+/, - ); - break; - case 4: - expect(preReleaseTag).to.match( - /^(alpha|beta|rc)\.\d+.experimental-[\w-]+\.\d+/, - ); - break; - default: - expect.fail('Invalid pre-release tag: ' + preReleaseTag); - } - /* c8 ignore stop */ - }); - - it('version', () => { - expect(version).to.be.a('string'); - - const { major, minor, patch, preReleaseTag } = versionInfo; - expect(version).to.equal( - // Can't be verified on all versions - /* c8 ignore next 3 */ - preReleaseTag === null - ? `${major}.${minor}.${patch}` - : `${major}.${minor}.${patch}-${preReleaseTag}`, - ); - }); -}); diff --git a/src/error/GraphQLError.ts b/src/error/GraphQLError.ts deleted file mode 100644 index 77a5e78779..0000000000 --- a/src/error/GraphQLError.ts +++ /dev/null @@ -1,312 +0,0 @@ -import { isObjectLike } from '../jsutils/isObjectLike'; -import type { Maybe } from '../jsutils/Maybe'; - -import type { ASTNode, Location } from '../language/ast'; -import type { SourceLocation } from '../language/location'; -import { getLocation } from '../language/location'; -import { printLocation, printSourceLocation } from '../language/printLocation'; -import type { Source } from '../language/source'; - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLErrorExtensions { - [attributeName: string]: unknown; -} - -/** - * Custom formatted extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLFormattedErrorExtensions { - [attributeName: string]: unknown; -} - -export interface GraphQLErrorOptions { - nodes?: ReadonlyArray | ASTNode | null; - source?: Maybe; - positions?: Maybe>; - path?: Maybe>; - originalError?: Maybe; - extensions?: Maybe; -} - -type BackwardsCompatibleArgs = - | [options?: GraphQLErrorOptions] - | [ - nodes?: GraphQLErrorOptions['nodes'], - source?: GraphQLErrorOptions['source'], - positions?: GraphQLErrorOptions['positions'], - path?: GraphQLErrorOptions['path'], - originalError?: GraphQLErrorOptions['originalError'], - extensions?: GraphQLErrorOptions['extensions'], - ]; - -function toNormalizedOptions( - args: BackwardsCompatibleArgs, -): GraphQLErrorOptions { - const firstArg = args[0]; - if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) { - return { - nodes: firstArg, - source: args[1], - positions: args[2], - path: args[3], - originalError: args[4], - extensions: args[5], - }; - } - return firstArg; -} - -/** - * A GraphQLError describes an Error found during the parse, validate, or - * execute phases of performing a GraphQL operation. In addition to a message - * and stack trace, it also includes information about the locations in a - * GraphQL document and/or execution result that correspond to the Error. - */ -export class GraphQLError extends Error { - /** - * An array of `{ line, column }` locations within the source GraphQL document - * which correspond to this error. - * - * Errors during validation often contain multiple locations, for example to - * point out two things with the same name. Errors during execution include a - * single location, the field which produced the error. - * - * Enumerable, and appears in the result of JSON.stringify(). - */ - readonly locations: ReadonlyArray | undefined; - - /** - * An array describing the JSON-path into the execution response which - * corresponds to this error. Only included for errors during execution. - * - * Enumerable, and appears in the result of JSON.stringify(). - */ - readonly path: ReadonlyArray | undefined; - - /** - * An array of GraphQL AST Nodes corresponding to this error. - */ - readonly nodes: ReadonlyArray | undefined; - - /** - * The source GraphQL document for the first location of this error. - * - * Note that if this Error represents more than one node, the source may not - * represent nodes after the first node. - */ - readonly source: Source | undefined; - - /** - * An array of character offsets within the source GraphQL document - * which correspond to this error. - */ - readonly positions: ReadonlyArray | undefined; - - /** - * The original error thrown from a field resolver during execution. - */ - readonly originalError: Error | undefined; - - /** - * Extension fields to add to the formatted error. - */ - readonly extensions: GraphQLErrorExtensions; - - constructor(message: string, options?: GraphQLErrorOptions); - /** - * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead. - */ - constructor( - message: string, - nodes?: ReadonlyArray | ASTNode | null, - source?: Maybe, - positions?: Maybe>, - path?: Maybe>, - originalError?: Maybe, - extensions?: Maybe, - ); - constructor(message: string, ...rawArgs: BackwardsCompatibleArgs) { - const { nodes, source, positions, path, originalError, extensions } = - toNormalizedOptions(rawArgs); - super(message); - - this.name = 'GraphQLError'; - this.path = path ?? undefined; - this.originalError = originalError ?? undefined; - - // Compute list of blame nodes. - this.nodes = undefinedIfEmpty( - Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined, - ); - - const nodeLocations = undefinedIfEmpty( - this.nodes - ?.map((node) => node.loc) - .filter((loc): loc is Location => loc != null), - ); - - // Compute locations in the source for the given nodes/positions. - this.source = source ?? nodeLocations?.[0]?.source; - - this.positions = positions ?? nodeLocations?.map((loc) => loc.start); - - this.locations = - positions && source - ? positions.map((pos) => getLocation(source, pos)) - : nodeLocations?.map((loc) => getLocation(loc.source, loc.start)); - - const originalExtensions = isObjectLike(originalError?.extensions) - ? originalError?.extensions - : undefined; - this.extensions = extensions ?? originalExtensions ?? Object.create(null); - - // Only properties prescribed by the spec should be enumerable. - // Keep the rest as non-enumerable. - Object.defineProperties(this, { - message: { - writable: true, - enumerable: true, - }, - name: { enumerable: false }, - nodes: { enumerable: false }, - source: { enumerable: false }, - positions: { enumerable: false }, - originalError: { enumerable: false }, - }); - - // Include (non-enumerable) stack trace. - /* c8 ignore start */ - // FIXME: https://github.com/graphql/graphql-js/issues/2317 - if (originalError?.stack) { - Object.defineProperty(this, 'stack', { - value: originalError.stack, - writable: true, - configurable: true, - }); - } else if (Error.captureStackTrace) { - Error.captureStackTrace(this, GraphQLError); - } else { - Object.defineProperty(this, 'stack', { - value: Error().stack, - writable: true, - configurable: true, - }); - } - /* c8 ignore stop */ - } - - get [Symbol.toStringTag](): string { - return 'GraphQLError'; - } - - toString(): string { - let output = this.message; - - if (this.nodes) { - for (const node of this.nodes) { - if (node.loc) { - output += '\n\n' + printLocation(node.loc); - } - } - } else if (this.source && this.locations) { - for (const location of this.locations) { - output += '\n\n' + printSourceLocation(this.source, location); - } - } - - return output; - } - - toJSON(): GraphQLFormattedError { - type WritableFormattedError = { - -readonly [P in keyof GraphQLFormattedError]: GraphQLFormattedError[P]; - }; - - const formattedError: WritableFormattedError = { - message: this.message, - }; - - if (this.locations != null) { - formattedError.locations = this.locations; - } - - if (this.path != null) { - formattedError.path = this.path; - } - - if (this.extensions != null && Object.keys(this.extensions).length > 0) { - formattedError.extensions = this.extensions; - } - - return formattedError; - } -} - -function undefinedIfEmpty( - array: Array | undefined, -): Array | undefined { - return array === undefined || array.length === 0 ? undefined : array; -} - -/** - * See: https://spec.graphql.org/draft/#sec-Errors - */ -export interface GraphQLFormattedError { - /** - * A short, human-readable summary of the problem that **SHOULD NOT** change - * from occurrence to occurrence of the problem, except for purposes of - * localization. - */ - readonly message: string; - /** - * If an error can be associated to a particular point in the requested - * GraphQL document, it should contain a list of locations. - */ - readonly locations?: ReadonlyArray; - /** - * If an error can be associated to a particular field in the GraphQL result, - * it _must_ contain an entry with the key `path` that details the path of - * the response field which experienced the error. This allows clients to - * identify whether a null result is intentional or caused by a runtime error. - */ - readonly path?: ReadonlyArray; - /** - * Reserved for implementors to extend the protocol however they see fit, - * and hence there are no additional restrictions on its contents. - */ - readonly extensions?: GraphQLFormattedErrorExtensions; -} - -/** - * Prints a GraphQLError to a string, representing useful location information - * about the error's position in the source. - * - * @deprecated Please use `error.toString` instead. Will be removed in v17 - */ -export function printError(error: GraphQLError): string { - return error.toString(); -} - -/** - * Given a GraphQLError, format it according to the rules described by the - * Response Format, Errors section of the GraphQL Specification. - * - * @deprecated Please use `error.toJSON` instead. Will be removed in v17 - */ -export function formatError(error: GraphQLError): GraphQLFormattedError { - return error.toJSON(); -} diff --git a/src/error/README.md b/src/error/README.md deleted file mode 100644 index 750c351033..0000000000 --- a/src/error/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## GraphQL Errors - -The `graphql/error` module is responsible for creating and formatting -GraphQL errors. - -```js -import { ... } from 'graphql/error'; // ES6 -var GraphQLError = require('graphql/error'); // CommonJS -``` diff --git a/src/error/__tests__/GraphQLError-test.ts b/src/error/__tests__/GraphQLError-test.ts deleted file mode 100644 index 1aa7d92f0c..0000000000 --- a/src/error/__tests__/GraphQLError-test.ts +++ /dev/null @@ -1,343 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { invariant } from '../../jsutils/invariant'; - -import { Kind } from '../../language/kinds'; -import { parse } from '../../language/parser'; -import { Source } from '../../language/source'; - -import { formatError, GraphQLError, printError } from '../GraphQLError'; - -const source = new Source(dedent` - { - field - } -`); -const ast = parse(source); -const operationNode = ast.definitions[0]; -invariant(operationNode.kind === Kind.OPERATION_DEFINITION); -const fieldNode = operationNode.selectionSet.selections[0]; -invariant(fieldNode); - -describe('GraphQLError', () => { - it('is a class and is a subclass of Error', () => { - expect(new GraphQLError('str')).to.be.instanceof(Error); - expect(new GraphQLError('str')).to.be.instanceof(GraphQLError); - }); - - it('has a name, message, extensions, and stack trace', () => { - const e = new GraphQLError('msg'); - - expect(e).to.deep.include({ - name: 'GraphQLError', - message: 'msg', - extensions: {}, - }); - expect(e.stack).to.be.a('string'); - }); - - it('enumerate only properties prescribed by the spec', () => { - const e = new GraphQLError('msg' /* message */, { - nodes: [fieldNode], - source, - positions: [1, 2, 3], - path: ['a', 'b', 'c'], - originalError: new Error('test'), - extensions: { foo: 'bar' }, - }); - - expect(Object.keys(e)).to.deep.equal([ - 'message', - 'path', - 'locations', - 'extensions', - ]); - }); - - it('uses the stack of an original error', () => { - const original = new Error('original'); - const e = new GraphQLError('msg', { - originalError: original, - }); - - expect(e).to.include({ - name: 'GraphQLError', - message: 'msg', - stack: original.stack, - originalError: original, - }); - }); - - it('creates new stack if original error has no stack', () => { - const original = new Error('original'); - const e = new GraphQLError('msg', { originalError: original }); - - expect(e).to.include({ - name: 'GraphQLError', - message: 'msg', - originalError: original, - }); - expect(e.stack).to.be.a('string'); - }); - - it('converts nodes to positions and locations', () => { - const e = new GraphQLError('msg', { nodes: [fieldNode] }); - expect(e).to.deep.include({ - source, - nodes: [fieldNode], - positions: [4], - locations: [{ line: 2, column: 3 }], - }); - }); - - it('converts single node to positions and locations', () => { - const e = new GraphQLError('msg', { nodes: fieldNode }); // Non-array value. - expect(e).to.deep.include({ - source, - nodes: [fieldNode], - positions: [4], - locations: [{ line: 2, column: 3 }], - }); - }); - - it('converts node with loc.start === 0 to positions and locations', () => { - const e = new GraphQLError('msg', { nodes: operationNode }); - expect(e).to.deep.include({ - source, - nodes: [operationNode], - positions: [0], - locations: [{ line: 1, column: 1 }], - }); - }); - - it('converts node without location to undefined source, positions and locations', () => { - const fieldNodeNoLocation = { - ...fieldNode, - loc: undefined, - }; - - const e = new GraphQLError('msg', { nodes: fieldNodeNoLocation }); - expect(e).to.deep.include({ - nodes: [fieldNodeNoLocation], - source: undefined, - positions: undefined, - locations: undefined, - }); - }); - - it('converts source and positions to locations', () => { - const e = new GraphQLError('msg', { source, positions: [6] }); - expect(e).to.deep.include({ - source, - nodes: undefined, - positions: [6], - locations: [{ line: 2, column: 5 }], - }); - }); - - it('defaults to original error extension only if extensions argument is not passed', () => { - class ErrorWithExtensions extends Error { - extensions: unknown; - - constructor(message: string) { - super(message); - this.extensions = { original: 'extensions' }; - } - } - - const original = new ErrorWithExtensions('original'); - const inheritedExtensions = new GraphQLError('InheritedExtensions', { - originalError: original, - }); - - expect(inheritedExtensions).to.deep.include({ - message: 'InheritedExtensions', - originalError: original, - extensions: { original: 'extensions' }, - }); - - const ownExtensions = new GraphQLError('OwnExtensions', { - originalError: original, - extensions: { own: 'extensions' }, - }); - - expect(ownExtensions).to.deep.include({ - message: 'OwnExtensions', - originalError: original, - extensions: { own: 'extensions' }, - }); - - const ownEmptyExtensions = new GraphQLError('OwnEmptyExtensions', { - originalError: original, - extensions: {}, - }); - - expect(ownEmptyExtensions).to.deep.include({ - message: 'OwnEmptyExtensions', - originalError: original, - extensions: {}, - }); - }); - - it('serializes to include all standard fields', () => { - const eShort = new GraphQLError('msg'); - expect(JSON.stringify(eShort, null, 2)).to.equal(dedent` - { - "message": "msg" - } - `); - - const path = ['path', 2, 'field']; - const extensions = { foo: 'bar' }; - const eFull = new GraphQLError('msg', { - nodes: fieldNode, - path, - extensions, - }); - - // We should try to keep order of fields stable - // Changing it wouldn't be breaking change but will fail some tests in other libraries. - expect(JSON.stringify(eFull, null, 2)).to.equal(dedent` - { - "message": "msg", - "locations": [ - { - "line": 2, - "column": 3 - } - ], - "path": [ - "path", - 2, - "field" - ], - "extensions": { - "foo": "bar" - } - } - `); - }); -}); - -describe('toString', () => { - it('Deprecated: prints an error using printError', () => { - const error = new GraphQLError('Error'); - expect(printError(error)).to.equal('Error'); - }); - - it('prints an error without location', () => { - const error = new GraphQLError('Error without location'); - expect(error.toString()).to.equal('Error without location'); - }); - - it('prints an error using node without location', () => { - const error = new GraphQLError('Error attached to node without location', { - nodes: parse('{ foo }', { noLocation: true }), - }); - expect(error.toString()).to.equal( - 'Error attached to node without location', - ); - }); - - it('prints an error with nodes from different sources', () => { - const docA = parse( - new Source( - dedent` - type Foo { - field: String - } - `, - 'SourceA', - ), - ); - const opA = docA.definitions[0]; - invariant(opA.kind === Kind.OBJECT_TYPE_DEFINITION && opA.fields); - const fieldA = opA.fields[0]; - - const docB = parse( - new Source( - dedent` - type Foo { - field: Int - } - `, - 'SourceB', - ), - ); - const opB = docB.definitions[0]; - invariant(opB.kind === Kind.OBJECT_TYPE_DEFINITION && opB.fields); - const fieldB = opB.fields[0]; - - const error = new GraphQLError('Example error with two nodes', [ - fieldA.type, - fieldB.type, - ]); - - expect(error.toString()).to.equal(dedent` - Example error with two nodes - - SourceA:2:10 - 1 | type Foo { - 2 | field: String - | ^ - 3 | } - - SourceB:2:10 - 1 | type Foo { - 2 | field: Int - | ^ - 3 | } - `); - }); -}); - -describe('toJSON', () => { - it('Deprecated: format an error using formatError', () => { - const error = new GraphQLError('Example Error'); - expect(formatError(error)).to.deep.equal({ - message: 'Example Error', - }); - }); - - it('includes path', () => { - const error = new GraphQLError('msg', { path: ['path', 3, 'to', 'field'] }); - - expect(error.toJSON()).to.deep.equal({ - message: 'msg', - path: ['path', 3, 'to', 'field'], - }); - }); - - it('includes extension fields', () => { - const error = new GraphQLError('msg', { - extensions: { foo: 'bar' }, - }); - - expect(error.toJSON()).to.deep.equal({ - message: 'msg', - extensions: { foo: 'bar' }, - }); - }); - - it('can be created with the legacy argument list', () => { - const error = new GraphQLError( - 'msg', - [operationNode], - source, - [6], - ['path', 2, 'a'], - new Error('I like turtles'), - { hee: 'I like turtles' }, - ); - - expect(error.toJSON()).to.deep.equal({ - message: 'msg', - locations: [{ column: 5, line: 2 }], - path: ['path', 2, 'a'], - extensions: { hee: 'I like turtles' }, - }); - }); -}); diff --git a/src/error/__tests__/locatedError-test.ts b/src/error/__tests__/locatedError-test.ts deleted file mode 100644 index e270d09a6d..0000000000 --- a/src/error/__tests__/locatedError-test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { GraphQLError } from '../GraphQLError'; -import { locatedError } from '../locatedError'; - -describe('locatedError', () => { - it('passes GraphQLError through', () => { - const e = new GraphQLError('msg', { path: ['path', 3, 'to', 'field'] }); - - expect(locatedError(e, [], [])).to.deep.equal(e); - }); - - it('wraps non-errors', () => { - const testObject = Object.freeze({}); - const error = locatedError(testObject, [], []); - - expect(error).to.be.instanceOf(GraphQLError); - expect(error.originalError).to.include({ - name: 'NonErrorThrown', - thrownValue: testObject, - }); - }); - - it('passes GraphQLError-ish through', () => { - const e = new Error(); - // @ts-expect-error - e.locations = []; - // @ts-expect-error - e.path = []; - // @ts-expect-error - e.nodes = []; - // @ts-expect-error - e.source = null; - // @ts-expect-error - e.positions = []; - e.name = 'GraphQLError'; - - expect(locatedError(e, [], [])).to.deep.equal(e); - }); - - it('does not pass through elasticsearch-like errors', () => { - const e = new Error('I am from elasticsearch'); - // @ts-expect-error - e.path = '/something/feed/_search'; - - expect(locatedError(e, [], [])).to.not.deep.equal(e); - }); -}); diff --git a/src/error/index.ts b/src/error/index.ts deleted file mode 100644 index 7e5d267f50..0000000000 --- a/src/error/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export { GraphQLError, printError, formatError } from './GraphQLError'; -export type { - GraphQLErrorOptions, - GraphQLFormattedError, - GraphQLErrorExtensions, - GraphQLFormattedErrorExtensions, -} from './GraphQLError'; - -export { syntaxError } from './syntaxError'; - -export { locatedError } from './locatedError'; diff --git a/src/error/locatedError.ts b/src/error/locatedError.ts deleted file mode 100644 index bafb9da9b6..0000000000 --- a/src/error/locatedError.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; -import { toError } from '../jsutils/toError'; - -import type { ASTNode } from '../language/ast'; - -import { GraphQLError } from './GraphQLError'; - -/** - * Given an arbitrary value, presumably thrown while attempting to execute a - * GraphQL operation, produce a new GraphQLError aware of the location in the - * document responsible for the original Error. - */ -export function locatedError( - rawOriginalError: unknown, - nodes: ASTNode | ReadonlyArray | undefined | null, - path?: Maybe>, -): GraphQLError { - const originalError = toError(rawOriginalError); - - // Note: this uses a brand-check to support GraphQL errors originating from other contexts. - if (isLocatedGraphQLError(originalError)) { - return originalError; - } - - return new GraphQLError(originalError.message, { - nodes: (originalError as GraphQLError).nodes ?? nodes, - source: (originalError as GraphQLError).source, - positions: (originalError as GraphQLError).positions, - path, - originalError, - }); -} - -function isLocatedGraphQLError(error: any): error is GraphQLError { - return Array.isArray(error.path); -} diff --git a/src/error/syntaxError.ts b/src/error/syntaxError.ts deleted file mode 100644 index 386ece72da..0000000000 --- a/src/error/syntaxError.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { Source } from '../language/source'; - -import { GraphQLError } from './GraphQLError'; - -/** - * Produces a GraphQLError representing a syntax error, containing useful - * descriptive information about the syntax error's position in the source. - */ -export function syntaxError( - source: Source, - position: number, - description: string, -): GraphQLError { - return new GraphQLError(`Syntax Error: ${description}`, { - source, - positions: [position], - }); -} diff --git a/src/execution/README.md b/src/execution/README.md deleted file mode 100644 index 6540f323fe..0000000000 --- a/src/execution/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## GraphQL Execution - -The `graphql/execution` module is responsible for the execution phase of -fulfilling a GraphQL request. - -```js -import { execute } from 'graphql/execution'; // ES6 -var GraphQLExecution = require('graphql/execution'); // CommonJS -``` diff --git a/src/execution/__tests__/abstract-test.ts b/src/execution/__tests__/abstract-test.ts deleted file mode 100644 index 5253d0d9e0..0000000000 --- a/src/execution/__tests__/abstract-test.ts +++ /dev/null @@ -1,643 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { parse } from '../../language/parser'; - -import { - assertInterfaceType, - GraphQLInterfaceType, - GraphQLList, - GraphQLObjectType, - GraphQLUnionType, -} from '../../type/definition'; -import { GraphQLBoolean, GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { execute, executeSync } from '../execute'; - -async function executeQuery(args: { - schema: GraphQLSchema; - query: string; - rootValue?: unknown; -}) { - const { schema, query, rootValue } = args; - const document = parse(query); - const result = executeSync({ - schema, - document, - rootValue, - contextValue: { async: false }, - }); - const asyncResult = await execute({ - schema, - document, - rootValue, - contextValue: { async: true }, - }); - - expectJSON(result).toDeepEqual(asyncResult); - return result; -} - -class Dog { - name: string; - woofs: boolean; - - constructor(name: string, woofs: boolean) { - this.name = name; - this.woofs = woofs; - } -} - -class Cat { - name: string; - meows: boolean; - - constructor(name: string, meows: boolean) { - this.name = name; - this.meows = meows; - } -} - -describe('Execute: Handles execution of abstract types', () => { - it('isTypeOf used to resolve runtime type for Interface', async () => { - const PetType = new GraphQLInterfaceType({ - name: 'Pet', - fields: { - name: { type: GraphQLString }, - }, - }); - - const DogType = new GraphQLObjectType({ - name: 'Dog', - interfaces: [PetType], - isTypeOf(obj, context) { - const isDog = obj instanceof Dog; - return context.async ? Promise.resolve(isDog) : isDog; - }, - fields: { - name: { type: GraphQLString }, - woofs: { type: GraphQLBoolean }, - }, - }); - - const CatType = new GraphQLObjectType({ - name: 'Cat', - interfaces: [PetType], - isTypeOf(obj, context) { - const isCat = obj instanceof Cat; - return context.async ? Promise.resolve(isCat) : isCat; - }, - fields: { - name: { type: GraphQLString }, - meows: { type: GraphQLBoolean }, - }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - pets: { - type: new GraphQLList(PetType), - resolve() { - return [new Dog('Odie', true), new Cat('Garfield', false)]; - }, - }, - }, - }), - types: [CatType, DogType], - }); - - const query = ` - { - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows - } - } - } - `; - - expect(await executeQuery({ schema, query })).to.deep.equal({ - data: { - pets: [ - { - name: 'Odie', - woofs: true, - }, - { - name: 'Garfield', - meows: false, - }, - ], - }, - }); - }); - - it('isTypeOf can throw', async () => { - const PetType = new GraphQLInterfaceType({ - name: 'Pet', - fields: { - name: { type: GraphQLString }, - }, - }); - - const DogType = new GraphQLObjectType({ - name: 'Dog', - interfaces: [PetType], - isTypeOf(_source, context) { - const error = new Error('We are testing this error'); - if (context.async) { - return Promise.reject(error); - } - throw error; - }, - fields: { - name: { type: GraphQLString }, - woofs: { type: GraphQLBoolean }, - }, - }); - - const CatType = new GraphQLObjectType({ - name: 'Cat', - interfaces: [PetType], - isTypeOf: undefined, - fields: { - name: { type: GraphQLString }, - meows: { type: GraphQLBoolean }, - }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - pets: { - type: new GraphQLList(PetType), - resolve() { - return [new Dog('Odie', true), new Cat('Garfield', false)]; - }, - }, - }, - }), - types: [DogType, CatType], - }); - - const query = ` - { - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows - } - } - } - `; - - expectJSON(await executeQuery({ schema, query })).toDeepEqual({ - data: { - pets: [null, null], - }, - errors: [ - { - message: 'We are testing this error', - locations: [{ line: 3, column: 9 }], - path: ['pets', 0], - }, - { - message: 'We are testing this error', - locations: [{ line: 3, column: 9 }], - path: ['pets', 1], - }, - ], - }); - }); - - it('isTypeOf can return false', async () => { - const PetType = new GraphQLInterfaceType({ - name: 'Pet', - fields: { - name: { type: GraphQLString }, - }, - }); - - const DogType = new GraphQLObjectType({ - name: 'Dog', - interfaces: [PetType], - isTypeOf(_source, context) { - return context.async ? Promise.resolve(false) : false; - }, - fields: { - name: { type: GraphQLString }, - woofs: { type: GraphQLBoolean }, - }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - pet: { - type: PetType, - resolve: () => ({}), - }, - }, - }), - types: [DogType], - }); - - const query = ` - { - pet { - name - } - } - `; - - expectJSON(await executeQuery({ schema, query })).toDeepEqual({ - data: { pet: null }, - errors: [ - { - message: - 'Abstract type "Pet" must resolve to an Object type at runtime for field "Query.pet". Either the "Pet" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.', - locations: [{ line: 3, column: 9 }], - path: ['pet'], - }, - ], - }); - }); - - it('isTypeOf used to resolve runtime type for Union', async () => { - const DogType = new GraphQLObjectType({ - name: 'Dog', - isTypeOf(obj, context) { - const isDog = obj instanceof Dog; - return context.async ? Promise.resolve(isDog) : isDog; - }, - fields: { - name: { type: GraphQLString }, - woofs: { type: GraphQLBoolean }, - }, - }); - - const CatType = new GraphQLObjectType({ - name: 'Cat', - isTypeOf(obj, context) { - const isCat = obj instanceof Cat; - return context.async ? Promise.resolve(isCat) : isCat; - }, - fields: { - name: { type: GraphQLString }, - meows: { type: GraphQLBoolean }, - }, - }); - - const PetType = new GraphQLUnionType({ - name: 'Pet', - types: [DogType, CatType], - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - pets: { - type: new GraphQLList(PetType), - resolve() { - return [new Dog('Odie', true), new Cat('Garfield', false)]; - }, - }, - }, - }), - }); - - const query = `{ - pets { - ... on Dog { - name - woofs - } - ... on Cat { - name - meows - } - } - }`; - - expect(await executeQuery({ schema, query })).to.deep.equal({ - data: { - pets: [ - { - name: 'Odie', - woofs: true, - }, - { - name: 'Garfield', - meows: false, - }, - ], - }, - }); - }); - - it('resolveType can throw', async () => { - const PetType = new GraphQLInterfaceType({ - name: 'Pet', - resolveType(_source, context) { - const error = new Error('We are testing this error'); - if (context.async) { - return Promise.reject(error); - } - throw error; - }, - fields: { - name: { type: GraphQLString }, - }, - }); - - const DogType = new GraphQLObjectType({ - name: 'Dog', - interfaces: [PetType], - fields: { - name: { type: GraphQLString }, - woofs: { type: GraphQLBoolean }, - }, - }); - - const CatType = new GraphQLObjectType({ - name: 'Cat', - interfaces: [PetType], - fields: { - name: { type: GraphQLString }, - meows: { type: GraphQLBoolean }, - }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - pets: { - type: new GraphQLList(PetType), - resolve() { - return [new Dog('Odie', true), new Cat('Garfield', false)]; - }, - }, - }, - }), - types: [CatType, DogType], - }); - - const query = ` - { - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows - } - } - } - `; - - expectJSON(await executeQuery({ schema, query })).toDeepEqual({ - data: { - pets: [null, null], - }, - errors: [ - { - message: 'We are testing this error', - locations: [{ line: 3, column: 9 }], - path: ['pets', 0], - }, - { - message: 'We are testing this error', - locations: [{ line: 3, column: 9 }], - path: ['pets', 1], - }, - ], - }); - }); - - it('resolve Union type using __typename on source object', async () => { - const schema = buildSchema(` - type Query { - pets: [Pet] - } - - union Pet = Cat | Dog - - type Cat { - name: String - meows: Boolean - } - - type Dog { - name: String - woofs: Boolean - } - `); - - const query = ` - { - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows - } - } - } - `; - - const rootValue = { - pets: [ - { - __typename: 'Dog', - name: 'Odie', - woofs: true, - }, - { - __typename: 'Cat', - name: 'Garfield', - meows: false, - }, - ], - }; - - expect(await executeQuery({ schema, query, rootValue })).to.deep.equal({ - data: { - pets: [ - { - name: 'Odie', - woofs: true, - }, - { - name: 'Garfield', - meows: false, - }, - ], - }, - }); - }); - - it('resolve Interface type using __typename on source object', async () => { - const schema = buildSchema(` - type Query { - pets: [Pet] - } - - interface Pet { - name: String - } - - type Cat implements Pet { - name: String - meows: Boolean - } - - type Dog implements Pet { - name: String - woofs: Boolean - } - `); - - const query = ` - { - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows - } - } - } - `; - - const rootValue = { - pets: [ - { - __typename: 'Dog', - name: 'Odie', - woofs: true, - }, - { - __typename: 'Cat', - name: 'Garfield', - meows: false, - }, - ], - }; - - expect(await executeQuery({ schema, query, rootValue })).to.deep.equal({ - data: { - pets: [ - { - name: 'Odie', - woofs: true, - }, - { - name: 'Garfield', - meows: false, - }, - ], - }, - }); - }); - - it('resolveType on Interface yields useful error', () => { - const schema = buildSchema(` - type Query { - pet: Pet - } - - interface Pet { - name: String - } - - type Cat implements Pet { - name: String - } - - type Dog implements Pet { - name: String - } - `); - - const document = parse(` - { - pet { - name - } - } - `); - - function expectError({ forTypeName }: { forTypeName: unknown }) { - const rootValue = { pet: { __typename: forTypeName } }; - const result = executeSync({ schema, document, rootValue }); - return { - toEqual(message: string) { - expectJSON(result).toDeepEqual({ - data: { pet: null }, - errors: [ - { - message, - locations: [{ line: 3, column: 9 }], - path: ['pet'], - }, - ], - }); - }, - }; - } - - expectError({ forTypeName: undefined }).toEqual( - 'Abstract type "Pet" must resolve to an Object type at runtime for field "Query.pet". Either the "Pet" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.', - ); - - expectError({ forTypeName: 'Human' }).toEqual( - 'Abstract type "Pet" was resolved to a type "Human" that does not exist inside the schema.', - ); - - expectError({ forTypeName: 'String' }).toEqual( - 'Abstract type "Pet" was resolved to a non-object type "String".', - ); - - expectError({ forTypeName: '__Schema' }).toEqual( - 'Runtime Object type "__Schema" is not a possible type for "Pet".', - ); - - // FIXME: workaround since we can't inject resolveType into SDL - // @ts-expect-error - assertInterfaceType(schema.getType('Pet')).resolveType = () => []; - expectError({ forTypeName: undefined }).toEqual( - 'Abstract type "Pet" must resolve to an Object type at runtime for field "Query.pet" with value { __typename: undefined }, received "[]".', - ); - - // FIXME: workaround since we can't inject resolveType into SDL - // @ts-expect-error - assertInterfaceType(schema.getType('Pet')).resolveType = () => - schema.getType('Cat'); - expectError({ forTypeName: undefined }).toEqual( - 'Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.', - ); - }); -}); diff --git a/src/execution/__tests__/directives-test.ts b/src/execution/__tests__/directives-test.ts deleted file mode 100644 index d94c0f2b8a..0000000000 --- a/src/execution/__tests__/directives-test.ts +++ /dev/null @@ -1,311 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import { GraphQLObjectType } from '../../type/definition'; -import { GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { executeSync } from '../execute'; - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'TestType', - fields: { - a: { type: GraphQLString }, - b: { type: GraphQLString }, - }, - }), -}); - -const rootValue = { - a() { - return 'a'; - }, - b() { - return 'b'; - }, -}; - -function executeTestQuery(query: string) { - const document = parse(query); - return executeSync({ schema, document, rootValue }); -} - -describe('Execute: handles directives', () => { - describe('works without directives', () => { - it('basic query works', () => { - const result = executeTestQuery('{ a, b }'); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - }); - - describe('works on scalars', () => { - it('if true includes scalar', () => { - const result = executeTestQuery('{ a, b @include(if: true) }'); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('if false omits on scalar', () => { - const result = executeTestQuery('{ a, b @include(if: false) }'); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - - it('unless false includes scalar', () => { - const result = executeTestQuery('{ a, b @skip(if: false) }'); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('unless true omits scalar', () => { - const result = executeTestQuery('{ a, b @skip(if: true) }'); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - }); - - describe('works on fragment spreads', () => { - it('if false omits fragment spread', () => { - const result = executeTestQuery(` - query { - a - ...Frag @include(if: false) - } - fragment Frag on TestType { - b - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - - it('if true includes fragment spread', () => { - const result = executeTestQuery(` - query { - a - ...Frag @include(if: true) - } - fragment Frag on TestType { - b - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('unless false includes fragment spread', () => { - const result = executeTestQuery(` - query { - a - ...Frag @skip(if: false) - } - fragment Frag on TestType { - b - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('unless true omits fragment spread', () => { - const result = executeTestQuery(` - query { - a - ...Frag @skip(if: true) - } - fragment Frag on TestType { - b - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - }); - - describe('works on inline fragment', () => { - it('if false omits inline fragment', () => { - const result = executeTestQuery(` - query { - a - ... on TestType @include(if: false) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - - it('if true includes inline fragment', () => { - const result = executeTestQuery(` - query { - a - ... on TestType @include(if: true) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('unless false includes inline fragment', () => { - const result = executeTestQuery(` - query { - a - ... on TestType @skip(if: false) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('unless true includes inline fragment', () => { - const result = executeTestQuery(` - query { - a - ... on TestType @skip(if: true) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - }); - - describe('works on anonymous inline fragment', () => { - it('if false omits anonymous inline fragment', () => { - const result = executeTestQuery(` - query { - a - ... @include(if: false) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - - it('if true includes anonymous inline fragment', () => { - const result = executeTestQuery(` - query { - a - ... @include(if: true) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('unless false includes anonymous inline fragment', () => { - const result = executeTestQuery(` - query Q { - a - ... @skip(if: false) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('unless true includes anonymous inline fragment', () => { - const result = executeTestQuery(` - query { - a - ... @skip(if: true) { - b - } - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - }); - - describe('works with skip and include directives', () => { - it('include and no skip', () => { - const result = executeTestQuery(` - { - a - b @include(if: true) @skip(if: false) - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b' }, - }); - }); - - it('include and skip', () => { - const result = executeTestQuery(` - { - a - b @include(if: true) @skip(if: true) - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - - it('no include or skip', () => { - const result = executeTestQuery(` - { - a - b @include(if: false) @skip(if: false) - } - `); - - expect(result).to.deep.equal({ - data: { a: 'a' }, - }); - }); - }); -}); diff --git a/src/execution/__tests__/executor-test.ts b/src/execution/__tests__/executor-test.ts deleted file mode 100644 index 0f0c5b2861..0000000000 --- a/src/execution/__tests__/executor-test.ts +++ /dev/null @@ -1,1394 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; -import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick'; - -import { inspect } from '../../jsutils/inspect'; -import { invariant } from '../../jsutils/invariant'; - -import { Kind } from '../../language/kinds'; -import { parse } from '../../language/parser'; - -import { - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, -} from '../../type/definition'; -import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { execute, executeSync } from '../execute'; - -describe('Execute: Handles basic execution tasks', () => { - it('throws if no document is provided', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - - // @ts-expect-error - expect(() => executeSync({ schema })).to.throw('Must provide document.'); - }); - - it('throws if no schema is provided', () => { - const document = parse('{ field }'); - - // @ts-expect-error - expect(() => executeSync({ document })).to.throw( - 'Expected undefined to be a GraphQL schema.', - ); - }); - - it('throws on invalid variables', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - fieldA: { - type: GraphQLString, - args: { argA: { type: GraphQLInt } }, - }, - }, - }), - }); - const document = parse(` - query ($a: Int) { - fieldA(argA: $a) - } - `); - const variableValues = '{ "a": 1 }'; - - // @ts-expect-error - expect(() => executeSync({ schema, document, variableValues })).to.throw( - 'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.', - ); - }); - - it('executes arbitrary code', async () => { - const data = { - a: () => 'Apple', - b: () => 'Banana', - c: () => 'Cookie', - d: () => 'Donut', - e: () => 'Egg', - f: 'Fish', - // Called only by DataType::pic static resolver - pic: (size: number) => 'Pic of size: ' + size, - deep: () => deepData, - promise: promiseData, - }; - - const deepData = { - a: () => 'Already Been Done', - b: () => 'Boring', - c: () => ['Contrived', undefined, 'Confusing'], - deeper: () => [data, null, data], - }; - - function promiseData() { - return Promise.resolve(data); - } - - const DataType: GraphQLObjectType = new GraphQLObjectType({ - name: 'DataType', - fields: () => ({ - a: { type: GraphQLString }, - b: { type: GraphQLString }, - c: { type: GraphQLString }, - d: { type: GraphQLString }, - e: { type: GraphQLString }, - f: { type: GraphQLString }, - pic: { - args: { size: { type: GraphQLInt } }, - type: GraphQLString, - resolve: (obj, { size }) => obj.pic(size), - }, - deep: { type: DeepDataType }, - promise: { type: DataType }, - }), - }); - - const DeepDataType = new GraphQLObjectType({ - name: 'DeepDataType', - fields: { - a: { type: GraphQLString }, - b: { type: GraphQLString }, - c: { type: new GraphQLList(GraphQLString) }, - deeper: { type: new GraphQLList(DataType) }, - }, - }); - - const document = parse(` - query ($size: Int) { - a, - b, - x: c - ...c - f - ...on DataType { - pic(size: $size) - promise { - a - } - } - deep { - a - b - c - deeper { - a - b - } - } - } - - fragment c on DataType { - d - e - } - `); - - const result = await execute({ - schema: new GraphQLSchema({ query: DataType }), - document, - rootValue: data, - variableValues: { size: 100 }, - }); - - expect(result).to.deep.equal({ - data: { - a: 'Apple', - b: 'Banana', - x: 'Cookie', - d: 'Donut', - e: 'Egg', - f: 'Fish', - pic: 'Pic of size: 100', - promise: { a: 'Apple' }, - deep: { - a: 'Already Been Done', - b: 'Boring', - c: ['Contrived', null, 'Confusing'], - deeper: [ - { a: 'Apple', b: 'Banana' }, - null, - { a: 'Apple', b: 'Banana' }, - ], - }, - }, - }); - }); - - it('merges parallel fragments', () => { - const Type: GraphQLObjectType = new GraphQLObjectType({ - name: 'Type', - fields: () => ({ - a: { type: GraphQLString, resolve: () => 'Apple' }, - b: { type: GraphQLString, resolve: () => 'Banana' }, - c: { type: GraphQLString, resolve: () => 'Cherry' }, - deep: { type: Type, resolve: () => ({}) }, - }), - }); - const schema = new GraphQLSchema({ query: Type }); - - const document = parse(` - { a, ...FragOne, ...FragTwo } - - fragment FragOne on Type { - b - deep { b, deeper: deep { b } } - } - - fragment FragTwo on Type { - c - deep { c, deeper: deep { c } } - } - `); - - const result = executeSync({ schema, document }); - expect(result).to.deep.equal({ - data: { - a: 'Apple', - b: 'Banana', - c: 'Cherry', - deep: { - b: 'Banana', - c: 'Cherry', - deeper: { - b: 'Banana', - c: 'Cherry', - }, - }, - }, - }); - }); - - it('provides info about current execution state', () => { - let resolvedInfo; - const testType = new GraphQLObjectType({ - name: 'Test', - fields: { - test: { - type: GraphQLString, - resolve(_val, _args, _ctx, info) { - resolvedInfo = info; - }, - }, - }, - }); - const schema = new GraphQLSchema({ query: testType }); - - const document = parse('query ($var: String) { result: test }'); - const rootValue = { root: 'val' }; - const variableValues = { var: 'abc' }; - - executeSync({ schema, document, rootValue, variableValues }); - - expect(resolvedInfo).to.have.all.keys( - 'fieldName', - 'fieldNodes', - 'returnType', - 'parentType', - 'path', - 'schema', - 'fragments', - 'rootValue', - 'operation', - 'variableValues', - ); - - const operation = document.definitions[0]; - invariant(operation.kind === Kind.OPERATION_DEFINITION); - - expect(resolvedInfo).to.include({ - fieldName: 'test', - returnType: GraphQLString, - parentType: testType, - schema, - rootValue, - operation, - }); - - const field = operation.selectionSet.selections[0]; - expect(resolvedInfo).to.deep.include({ - fieldNodes: [field], - path: { prev: undefined, key: 'result', typename: 'Test' }, - variableValues: { var: 'abc' }, - }); - }); - - it('populates path correctly with complex types', () => { - let path; - const someObject = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - test: { - type: GraphQLString, - resolve(_val, _args, _ctx, info) { - path = info.path; - }, - }, - }, - }); - const someUnion = new GraphQLUnionType({ - name: 'SomeUnion', - types: [someObject], - resolveType() { - return 'SomeObject'; - }, - }); - const testType = new GraphQLObjectType({ - name: 'SomeQuery', - fields: { - test: { - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(someUnion)), - ), - }, - }, - }); - const schema = new GraphQLSchema({ query: testType }); - const rootValue = { test: [{}] }; - const document = parse(` - query { - l1: test { - ... on SomeObject { - l2: test - } - } - } - `); - - executeSync({ schema, document, rootValue }); - - expect(path).to.deep.equal({ - key: 'l2', - typename: 'SomeObject', - prev: { - key: 0, - typename: undefined, - prev: { - key: 'l1', - typename: 'SomeQuery', - prev: undefined, - }, - }, - }); - }); - - it('threads root value context correctly', () => { - let resolvedRootValue; - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { - type: GraphQLString, - resolve(rootValueArg) { - resolvedRootValue = rootValueArg; - }, - }, - }, - }), - }); - - const document = parse('query Example { a }'); - const rootValue = { contextThing: 'thing' }; - - executeSync({ schema, document, rootValue }); - expect(resolvedRootValue).to.equal(rootValue); - }); - - it('correctly threads arguments', () => { - let resolvedArgs; - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - b: { - args: { - numArg: { type: GraphQLInt }, - stringArg: { type: GraphQLString }, - }, - type: GraphQLString, - resolve(_, args) { - resolvedArgs = args; - }, - }, - }, - }), - }); - - const document = parse(` - query Example { - b(numArg: 123, stringArg: "foo") - } - `); - - executeSync({ schema, document }); - expect(resolvedArgs).to.deep.equal({ numArg: 123, stringArg: 'foo' }); - }); - - it('nulls out error subtrees', async () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - sync: { type: GraphQLString }, - syncError: { type: GraphQLString }, - syncRawError: { type: GraphQLString }, - syncReturnError: { type: GraphQLString }, - syncReturnErrorList: { type: new GraphQLList(GraphQLString) }, - async: { type: GraphQLString }, - asyncReject: { type: GraphQLString }, - asyncRejectWithExtensions: { type: GraphQLString }, - asyncRawReject: { type: GraphQLString }, - asyncEmptyReject: { type: GraphQLString }, - asyncError: { type: GraphQLString }, - asyncRawError: { type: GraphQLString }, - asyncReturnError: { type: GraphQLString }, - asyncReturnErrorWithExtensions: { type: GraphQLString }, - }, - }), - }); - - const document = parse(` - { - sync - syncError - syncRawError - syncReturnError - syncReturnErrorList - async - asyncReject - asyncRawReject - asyncEmptyReject - asyncError - asyncRawError - asyncReturnError - asyncReturnErrorWithExtensions - } - `); - - const rootValue = { - sync() { - return 'sync'; - }, - syncError() { - throw new Error('Error getting syncError'); - }, - syncRawError() { - // eslint-disable-next-line @typescript-eslint/no-throw-literal - throw 'Error getting syncRawError'; - }, - syncReturnError() { - return new Error('Error getting syncReturnError'); - }, - syncReturnErrorList() { - return [ - 'sync0', - new Error('Error getting syncReturnErrorList1'), - 'sync2', - new Error('Error getting syncReturnErrorList3'), - ]; - }, - async() { - return new Promise((resolve) => resolve('async')); - }, - asyncReject() { - return new Promise((_, reject) => - reject(new Error('Error getting asyncReject')), - ); - }, - asyncRawReject() { - // eslint-disable-next-line prefer-promise-reject-errors - return Promise.reject('Error getting asyncRawReject'); - }, - asyncEmptyReject() { - // eslint-disable-next-line prefer-promise-reject-errors - return Promise.reject(); - }, - asyncError() { - return new Promise(() => { - throw new Error('Error getting asyncError'); - }); - }, - asyncRawError() { - return new Promise(() => { - // eslint-disable-next-line @typescript-eslint/no-throw-literal - throw 'Error getting asyncRawError'; - }); - }, - asyncReturnError() { - return Promise.resolve(new Error('Error getting asyncReturnError')); - }, - asyncReturnErrorWithExtensions() { - const error = new Error('Error getting asyncReturnErrorWithExtensions'); - // @ts-expect-error - error.extensions = { foo: 'bar' }; - - return Promise.resolve(error); - }, - }; - - const result = await execute({ schema, document, rootValue }); - expectJSON(result).toDeepEqual({ - data: { - sync: 'sync', - syncError: null, - syncRawError: null, - syncReturnError: null, - syncReturnErrorList: ['sync0', null, 'sync2', null], - async: 'async', - asyncReject: null, - asyncRawReject: null, - asyncEmptyReject: null, - asyncError: null, - asyncRawError: null, - asyncReturnError: null, - asyncReturnErrorWithExtensions: null, - }, - errors: [ - { - message: 'Error getting syncError', - locations: [{ line: 4, column: 9 }], - path: ['syncError'], - }, - { - message: 'Unexpected error value: "Error getting syncRawError"', - locations: [{ line: 5, column: 9 }], - path: ['syncRawError'], - }, - { - message: 'Error getting syncReturnError', - locations: [{ line: 6, column: 9 }], - path: ['syncReturnError'], - }, - { - message: 'Error getting syncReturnErrorList1', - locations: [{ line: 7, column: 9 }], - path: ['syncReturnErrorList', 1], - }, - { - message: 'Error getting syncReturnErrorList3', - locations: [{ line: 7, column: 9 }], - path: ['syncReturnErrorList', 3], - }, - { - message: 'Error getting asyncReject', - locations: [{ line: 9, column: 9 }], - path: ['asyncReject'], - }, - { - message: 'Unexpected error value: "Error getting asyncRawReject"', - locations: [{ line: 10, column: 9 }], - path: ['asyncRawReject'], - }, - { - message: 'Unexpected error value: undefined', - locations: [{ line: 11, column: 9 }], - path: ['asyncEmptyReject'], - }, - { - message: 'Error getting asyncError', - locations: [{ line: 12, column: 9 }], - path: ['asyncError'], - }, - { - message: 'Unexpected error value: "Error getting asyncRawError"', - locations: [{ line: 13, column: 9 }], - path: ['asyncRawError'], - }, - { - message: 'Error getting asyncReturnError', - locations: [{ line: 14, column: 9 }], - path: ['asyncReturnError'], - }, - { - message: 'Error getting asyncReturnErrorWithExtensions', - locations: [{ line: 15, column: 9 }], - path: ['asyncReturnErrorWithExtensions'], - extensions: { foo: 'bar' }, - }, - ], - }); - }); - - it('nulls error subtree for promise rejection #1071', async () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - foods: { - type: new GraphQLList( - new GraphQLObjectType({ - name: 'Food', - fields: { - name: { type: GraphQLString }, - }, - }), - ), - resolve() { - return Promise.reject(new Error('Oops')); - }, - }, - }, - }), - }); - - const document = parse(` - query { - foods { - name - } - } - `); - - const result = await execute({ schema, document }); - - expectJSON(result).toDeepEqual({ - data: { foods: null }, - errors: [ - { - locations: [{ column: 9, line: 3 }], - message: 'Oops', - path: ['foods'], - }, - ], - }); - }); - - it('handles sync errors combined with rejections', async () => { - let isAsyncResolverFinished = false; - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - syncNullError: { - type: new GraphQLNonNull(GraphQLString), - resolve: () => null, - }, - asyncNullError: { - type: new GraphQLNonNull(GraphQLString), - async resolve() { - await resolveOnNextTick(); - await resolveOnNextTick(); - await resolveOnNextTick(); - isAsyncResolverFinished = true; - return null; - }, - }, - }, - }), - }); - - // Order is important here, as the promise has to be created before the synchronous error is thrown - const document = parse(` - { - asyncNullError - syncNullError - } - `); - - const result = execute({ schema, document }); - - expect(isAsyncResolverFinished).to.equal(false); - expectJSON(await result).toDeepEqual({ - data: null, - errors: [ - { - message: - 'Cannot return null for non-nullable field Query.syncNullError.', - locations: [{ line: 4, column: 9 }], - path: ['syncNullError'], - }, - ], - }); - expect(isAsyncResolverFinished).to.equal(true); - }); - - it('Full response path is included for non-nullable fields', () => { - const A: GraphQLObjectType = new GraphQLObjectType({ - name: 'A', - fields: () => ({ - nullableA: { - type: A, - resolve: () => ({}), - }, - nonNullA: { - type: new GraphQLNonNull(A), - resolve: () => ({}), - }, - throws: { - type: new GraphQLNonNull(GraphQLString), - resolve: () => { - throw new Error('Catch me if you can'); - }, - }, - }), - }); - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'query', - fields: () => ({ - nullableA: { - type: A, - resolve: () => ({}), - }, - }), - }), - }); - - const document = parse(` - query { - nullableA { - aliasedA: nullableA { - nonNullA { - anotherA: nonNullA { - throws - } - } - } - } - } - `); - - const result = executeSync({ schema, document }); - expectJSON(result).toDeepEqual({ - data: { - nullableA: { - aliasedA: null, - }, - }, - errors: [ - { - message: 'Catch me if you can', - locations: [{ line: 7, column: 17 }], - path: ['nullableA', 'aliasedA', 'nonNullA', 'anotherA', 'throws'], - }, - ], - }); - }); - - it('uses the inline operation if no operation name is provided', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse('{ a }'); - const rootValue = { a: 'b' }; - - const result = executeSync({ schema, document, rootValue }); - expect(result).to.deep.equal({ data: { a: 'b' } }); - }); - - it('uses the only operation if no operation name is provided', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse('query Example { a }'); - const rootValue = { a: 'b' }; - - const result = executeSync({ schema, document, rootValue }); - expect(result).to.deep.equal({ data: { a: 'b' } }); - }); - - it('uses the named operation if operation name is provided', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - - const document = parse(` - query Example { first: a } - query OtherExample { second: a } - `); - const rootValue = { a: 'b' }; - const operationName = 'OtherExample'; - - const result = executeSync({ schema, document, rootValue, operationName }); - expect(result).to.deep.equal({ data: { second: 'b' } }); - }); - - it('provides error if no operation is provided', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse('fragment Example on Type { a }'); - const rootValue = { a: 'b' }; - - const result = executeSync({ schema, document, rootValue }); - expectJSON(result).toDeepEqual({ - errors: [{ message: 'Must provide an operation.' }], - }); - }); - - it('errors if no op name is provided with multiple operations', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse(` - query Example { a } - query OtherExample { a } - `); - - const result = executeSync({ schema, document }); - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Must provide operation name if query contains multiple operations.', - }, - ], - }); - }); - - it('errors if unknown operation name is provided', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse(` - query Example { a } - query OtherExample { a } - `); - const operationName = 'UnknownExample'; - - const result = executeSync({ schema, document, operationName }); - expectJSON(result).toDeepEqual({ - errors: [{ message: 'Unknown operation named "UnknownExample".' }], - }); - }); - - it('errors if empty string is provided as operation name', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse('{ a }'); - const operationName = ''; - - const result = executeSync({ schema, document, operationName }); - expectJSON(result).toDeepEqual({ - errors: [{ message: 'Unknown operation named "".' }], - }); - }); - - it('uses the query schema for queries', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Q', - fields: { - a: { type: GraphQLString }, - }, - }), - mutation: new GraphQLObjectType({ - name: 'M', - fields: { - c: { type: GraphQLString }, - }, - }), - subscription: new GraphQLObjectType({ - name: 'S', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse(` - query Q { a } - mutation M { c } - subscription S { a } - `); - const rootValue = { a: 'b', c: 'd' }; - const operationName = 'Q'; - - const result = executeSync({ schema, document, rootValue, operationName }); - expect(result).to.deep.equal({ data: { a: 'b' } }); - }); - - it('uses the mutation schema for mutations', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Q', - fields: { - a: { type: GraphQLString }, - }, - }), - mutation: new GraphQLObjectType({ - name: 'M', - fields: { - c: { type: GraphQLString }, - }, - }), - }); - const document = parse(` - query Q { a } - mutation M { c } - `); - const rootValue = { a: 'b', c: 'd' }; - const operationName = 'M'; - - const result = executeSync({ schema, document, rootValue, operationName }); - expect(result).to.deep.equal({ data: { c: 'd' } }); - }); - - it('uses the subscription schema for subscriptions', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Q', - fields: { - a: { type: GraphQLString }, - }, - }), - subscription: new GraphQLObjectType({ - name: 'S', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse(` - query Q { a } - subscription S { a } - `); - const rootValue = { a: 'b', c: 'd' }; - const operationName = 'S'; - - const result = executeSync({ schema, document, rootValue, operationName }); - expect(result).to.deep.equal({ data: { a: 'b' } }); - }); - - it('resolves to an error if schema does not support operation', () => { - const schema = new GraphQLSchema({ assumeValid: true }); - - const document = parse(` - query Q { __typename } - mutation M { __typename } - subscription S { __typename } - `); - - expectJSON( - executeSync({ schema, document, operationName: 'Q' }), - ).toDeepEqual({ - data: null, - errors: [ - { - message: 'Schema is not configured to execute query operation.', - locations: [{ line: 2, column: 7 }], - }, - ], - }); - - expectJSON( - executeSync({ schema, document, operationName: 'M' }), - ).toDeepEqual({ - data: null, - errors: [ - { - message: 'Schema is not configured to execute mutation operation.', - locations: [{ line: 3, column: 7 }], - }, - ], - }); - - expectJSON( - executeSync({ schema, document, operationName: 'S' }), - ).toDeepEqual({ - data: null, - errors: [ - { - message: - 'Schema is not configured to execute subscription operation.', - locations: [{ line: 4, column: 7 }], - }, - ], - }); - }); - - it('correct field ordering despite execution order', async () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - b: { type: GraphQLString }, - c: { type: GraphQLString }, - d: { type: GraphQLString }, - e: { type: GraphQLString }, - }, - }), - }); - const document = parse('{ a, b, c, d, e }'); - const rootValue = { - a: () => 'a', - b: () => new Promise((resolve) => resolve('b')), - c: () => 'c', - d: () => new Promise((resolve) => resolve('d')), - e: () => 'e', - }; - - const result = await execute({ schema, document, rootValue }); - expect(result).to.deep.equal({ - data: { a: 'a', b: 'b', c: 'c', d: 'd', e: 'e' }, - }); - }); - - it('Avoids recursion', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse(` - { - a - ...Frag - ...Frag - } - - fragment Frag on Type { - a, - ...Frag - } - `); - const rootValue = { a: 'b' }; - - const result = executeSync({ schema, document, rootValue }); - expect(result).to.deep.equal({ - data: { a: 'b' }, - }); - }); - - it('ignores missing sub selections on fields', () => { - const someType = new GraphQLObjectType({ - name: 'SomeType', - fields: { - b: { type: GraphQLString }, - }, - }); - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - a: { type: someType }, - }, - }), - }); - const document = parse('{ a }'); - const rootValue = { a: { b: 'c' } }; - - const result = executeSync({ schema, document, rootValue }); - expect(result).to.deep.equal({ - data: { a: {} }, - }); - }); - - it('does not include illegal fields in output', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Q', - fields: { - a: { type: GraphQLString }, - }, - }), - }); - const document = parse('{ thisIsIllegalDoNotIncludeMe }'); - - const result = executeSync({ schema, document }); - expect(result).to.deep.equal({ - data: {}, - }); - }); - - it('does not include arguments that were not set', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Type', - fields: { - field: { - type: GraphQLString, - resolve: (_source, args) => inspect(args), - args: { - a: { type: GraphQLBoolean }, - b: { type: GraphQLBoolean }, - c: { type: GraphQLBoolean }, - d: { type: GraphQLInt }, - e: { type: GraphQLInt }, - }, - }, - }, - }), - }); - const document = parse('{ field(a: true, c: false, e: 0) }'); - - const result = executeSync({ schema, document }); - expect(result).to.deep.equal({ - data: { - field: '{ a: true, c: false, e: 0 }', - }, - }); - }); - - it('fails when an isTypeOf check is not met', async () => { - class Special { - value: string; - - constructor(value: string) { - this.value = value; - } - } - - class NotSpecial { - value: string; - - constructor(value: string) { - this.value = value; - } - } - - const SpecialType = new GraphQLObjectType({ - name: 'SpecialType', - isTypeOf(obj, context) { - const result = obj instanceof Special; - return context?.async ? Promise.resolve(result) : result; - }, - fields: { value: { type: GraphQLString } }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - specials: { type: new GraphQLList(SpecialType) }, - }, - }), - }); - - const document = parse('{ specials { value } }'); - const rootValue = { - specials: [new Special('foo'), new NotSpecial('bar')], - }; - - const result = executeSync({ schema, document, rootValue }); - expectJSON(result).toDeepEqual({ - data: { - specials: [{ value: 'foo' }, null], - }, - errors: [ - { - message: - 'Expected value of type "SpecialType" but got: { value: "bar" }.', - locations: [{ line: 1, column: 3 }], - path: ['specials', 1], - }, - ], - }); - - const contextValue = { async: true }; - const asyncResult = await execute({ - schema, - document, - rootValue, - contextValue, - }); - expect(asyncResult).to.deep.equal(result); - }); - - it('fails when serialize of custom scalar does not return a value', () => { - const customScalar = new GraphQLScalarType({ - name: 'CustomScalar', - serialize() { - /* returns nothing */ - }, - }); - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - customScalar: { - type: customScalar, - resolve: () => 'CUSTOM_VALUE', - }, - }, - }), - }); - - const result = executeSync({ schema, document: parse('{ customScalar }') }); - expectJSON(result).toDeepEqual({ - data: { customScalar: null }, - errors: [ - { - message: - 'Expected `CustomScalar.serialize("CUSTOM_VALUE")` to return non-nullable value, returned: undefined', - locations: [{ line: 1, column: 3 }], - path: ['customScalar'], - }, - ], - }); - }); - - it('executes ignoring invalid non-executable definitions', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - foo: { type: GraphQLString }, - }, - }), - }); - - const document = parse(` - { foo } - - type Query { bar: String } - `); - - const result = executeSync({ schema, document }); - expect(result).to.deep.equal({ data: { foo: null } }); - }); - - it('uses a custom field resolver', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - foo: { type: GraphQLString }, - }, - }), - }); - const document = parse('{ foo }'); - - const result = executeSync({ - schema, - document, - fieldResolver(_source, _args, _context, info) { - // For the purposes of test, just return the name of the field! - return info.fieldName; - }, - }); - - expect(result).to.deep.equal({ data: { foo: 'foo' } }); - }); - - it('uses a custom type resolver', () => { - const document = parse('{ foo { bar } }'); - - const fooInterface = new GraphQLInterfaceType({ - name: 'FooInterface', - fields: { - bar: { type: GraphQLString }, - }, - }); - - const fooObject = new GraphQLObjectType({ - name: 'FooObject', - interfaces: [fooInterface], - fields: { - bar: { type: GraphQLString }, - }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - foo: { type: fooInterface }, - }, - }), - types: [fooObject], - }); - - const rootValue = { foo: { bar: 'bar' } }; - - let possibleTypes; - const result = executeSync({ - schema, - document, - rootValue, - typeResolver(_source, _context, info, abstractType) { - // Resolver should be able to figure out all possible types on its own - possibleTypes = info.schema.getPossibleTypes(abstractType); - - return 'FooObject'; - }, - }); - - expect(result).to.deep.equal({ data: { foo: { bar: 'bar' } } }); - expect(possibleTypes).to.deep.equal([fooObject]); - }); - - it('uses a different number of max coercion errors', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - dummy: { type: GraphQLString }, - }, - }), - mutation: new GraphQLObjectType({ - name: 'Mutation', - fields: { - updateUser: { - type: GraphQLString, - args: { - data: { - type: new GraphQLInputObjectType({ - name: 'User', - fields: { - email: { type: new GraphQLNonNull(GraphQLString) }, - }, - }), - }, - }, - }, - }, - }), - }); - - const document = parse(` - mutation ($data: User) { - updateUser(data: $data) - } - `); - - const options = { - maxCoercionErrors: 1, - }; - - const result = executeSync({ - schema, - document, - variableValues: { - data: { - email: '', - wrongArg: 'wrong', - wrongArg2: 'wrong', - wrongArg3: 'wrong', - }, - }, - options, - }); - - // Returns at least 2 errors, one for the first 'wrongArg', and one for coercion limit - expect(result.errors).to.have.lengthOf(options.maxCoercionErrors + 1); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$data" got invalid value { email: "", wrongArg: "wrong", wrongArg2: "wrong", wrongArg3: "wrong" }; Field "wrongArg" is not defined by type "User".', - locations: [{ line: 2, column: 17 }], - }, - { - message: - 'Too many errors processing variables, error limit reached. Execution aborted.', - }, - ], - }); - }); -}); diff --git a/src/execution/__tests__/lists-test.ts b/src/execution/__tests__/lists-test.ts deleted file mode 100644 index ac6460d547..0000000000 --- a/src/execution/__tests__/lists-test.ts +++ /dev/null @@ -1,225 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { parse } from '../../language/parser'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { execute, executeSync } from '../execute'; - -describe('Execute: Accepts any iterable as list value', () => { - function complete(rootValue: unknown) { - return executeSync({ - schema: buildSchema('type Query { listField: [String] }'), - document: parse('{ listField }'), - rootValue, - }); - } - - it('Accepts a Set as a List value', () => { - const listField = new Set(['apple', 'banana', 'apple', 'coconut']); - - expect(complete({ listField })).to.deep.equal({ - data: { listField: ['apple', 'banana', 'coconut'] }, - }); - }); - - it('Accepts an Generator function as a List value', () => { - function* listField() { - yield 'one'; - yield 2; - yield true; - } - - expect(complete({ listField })).to.deep.equal({ - data: { listField: ['one', '2', 'true'] }, - }); - }); - - it('Accepts function arguments as a List value', () => { - function getArgs(..._args: ReadonlyArray) { - return arguments; - } - const listField = getArgs('one', 'two'); - - expect(complete({ listField })).to.deep.equal({ - data: { listField: ['one', 'two'] }, - }); - }); - - it('Does not accept (Iterable) String-literal as a List value', () => { - const listField = 'Singular'; - - expectJSON(complete({ listField })).toDeepEqual({ - data: { listField: null }, - errors: [ - { - message: - 'Expected Iterable, but did not find one for field "Query.listField".', - locations: [{ line: 1, column: 3 }], - path: ['listField'], - }, - ], - }); - }); -}); - -describe('Execute: Handles list nullability', () => { - async function complete(args: { listField: unknown; as: string }) { - const { listField, as } = args; - const schema = buildSchema(`type Query { listField: ${as} }`); - const document = parse('{ listField }'); - - const result = await executeQuery(listField); - // Promise> === Array - expectJSON(await executeQuery(promisify(listField))).toDeepEqual(result); - if (Array.isArray(listField)) { - const listOfPromises = listField.map(promisify); - - // Array> === Array - expectJSON(await executeQuery(listOfPromises)).toDeepEqual(result); - // Promise>> === Array - expectJSON(await executeQuery(promisify(listOfPromises))).toDeepEqual( - result, - ); - } - return result; - - function executeQuery(listValue: unknown) { - return execute({ schema, document, rootValue: { listField: listValue } }); - } - - function promisify(value: unknown): Promise { - return value instanceof Error - ? Promise.reject(value) - : Promise.resolve(value); - } - } - - it('Contains values', async () => { - const listField = [1, 2]; - - expect(await complete({ listField, as: '[Int]' })).to.deep.equal({ - data: { listField: [1, 2] }, - }); - expect(await complete({ listField, as: '[Int]!' })).to.deep.equal({ - data: { listField: [1, 2] }, - }); - expect(await complete({ listField, as: '[Int!]' })).to.deep.equal({ - data: { listField: [1, 2] }, - }); - expect(await complete({ listField, as: '[Int!]!' })).to.deep.equal({ - data: { listField: [1, 2] }, - }); - }); - - it('Contains null', async () => { - const listField = [1, null, 2]; - const errors = [ - { - message: 'Cannot return null for non-nullable field Query.listField.', - locations: [{ line: 1, column: 3 }], - path: ['listField', 1], - }, - ]; - - expect(await complete({ listField, as: '[Int]' })).to.deep.equal({ - data: { listField: [1, null, 2] }, - }); - expect(await complete({ listField, as: '[Int]!' })).to.deep.equal({ - data: { listField: [1, null, 2] }, - }); - expectJSON(await complete({ listField, as: '[Int!]' })).toDeepEqual({ - data: { listField: null }, - errors, - }); - expectJSON(await complete({ listField, as: '[Int!]!' })).toDeepEqual({ - data: null, - errors, - }); - }); - - it('Returns null', async () => { - const listField = null; - const errors = [ - { - message: 'Cannot return null for non-nullable field Query.listField.', - locations: [{ line: 1, column: 3 }], - path: ['listField'], - }, - ]; - - expect(await complete({ listField, as: '[Int]' })).to.deep.equal({ - data: { listField: null }, - }); - expectJSON(await complete({ listField, as: '[Int]!' })).toDeepEqual({ - data: null, - errors, - }); - expect(await complete({ listField, as: '[Int!]' })).to.deep.equal({ - data: { listField: null }, - }); - expectJSON(await complete({ listField, as: '[Int!]!' })).toDeepEqual({ - data: null, - errors, - }); - }); - - it('Contains error', async () => { - const listField = [1, new Error('bad'), 2]; - const errors = [ - { - message: 'bad', - locations: [{ line: 1, column: 3 }], - path: ['listField', 1], - }, - ]; - - expectJSON(await complete({ listField, as: '[Int]' })).toDeepEqual({ - data: { listField: [1, null, 2] }, - errors, - }); - expectJSON(await complete({ listField, as: '[Int]!' })).toDeepEqual({ - data: { listField: [1, null, 2] }, - errors, - }); - expectJSON(await complete({ listField, as: '[Int!]' })).toDeepEqual({ - data: { listField: null }, - errors, - }); - expectJSON(await complete({ listField, as: '[Int!]!' })).toDeepEqual({ - data: null, - errors, - }); - }); - - it('Results in error', async () => { - const listField = new Error('bad'); - const errors = [ - { - message: 'bad', - locations: [{ line: 1, column: 3 }], - path: ['listField'], - }, - ]; - - expectJSON(await complete({ listField, as: '[Int]' })).toDeepEqual({ - data: { listField: null }, - errors, - }); - expectJSON(await complete({ listField, as: '[Int]!' })).toDeepEqual({ - data: null, - errors, - }); - expectJSON(await complete({ listField, as: '[Int!]' })).toDeepEqual({ - data: { listField: null }, - errors, - }); - expectJSON(await complete({ listField, as: '[Int!]!' })).toDeepEqual({ - data: null, - errors, - }); - }); -}); diff --git a/src/execution/__tests__/mapAsyncIterator-test.ts b/src/execution/__tests__/mapAsyncIterator-test.ts deleted file mode 100644 index ec01634e6a..0000000000 --- a/src/execution/__tests__/mapAsyncIterator-test.ts +++ /dev/null @@ -1,336 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { mapAsyncIterator } from '../mapAsyncIterator'; - -/* eslint-disable @typescript-eslint/require-await */ -describe('mapAsyncIterator', () => { - it('maps over async generator', async () => { - async function* source() { - yield 1; - yield 2; - yield 3; - } - - const doubles = mapAsyncIterator(source(), (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ value: 2, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 4, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 6, done: false }); - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - }); - - it('maps over async iterable', async () => { - const items = [1, 2, 3]; - - const iterable = { - [Symbol.asyncIterator]() { - return this; - }, - - next(): Promise> { - if (items.length > 0) { - const value = items[0]; - items.shift(); - return Promise.resolve({ done: false, value }); - } - - return Promise.resolve({ done: true, value: undefined }); - }, - }; - - const doubles = mapAsyncIterator(iterable, (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ value: 2, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 4, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 6, done: false }); - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - }); - - it('compatible with for-await-of', async () => { - async function* source() { - yield 1; - yield 2; - yield 3; - } - - const doubles = mapAsyncIterator(source(), (x) => x + x); - - const result = []; - for await (const x of doubles) { - result.push(x); - } - expect(result).to.deep.equal([2, 4, 6]); - }); - - it('maps over async values with async function', async () => { - async function* source() { - yield 1; - yield 2; - yield 3; - } - - const doubles = mapAsyncIterator(source(), (x) => Promise.resolve(x + x)); - - expect(await doubles.next()).to.deep.equal({ value: 2, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 4, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 6, done: false }); - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - }); - - it('allows returning early from mapped async generator', async () => { - async function* source() { - try { - yield 1; - /* c8 ignore next 2 */ - yield 2; - yield 3; // Shouldn't be reached. - } finally { - // eslint-disable-next-line no-unsafe-finally - return 'The End'; - } - } - - const doubles = mapAsyncIterator(source(), (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ value: 2, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 4, done: false }); - - // Early return - expect(await doubles.return('')).to.deep.equal({ - value: 'The End', - done: true, - }); - - // Subsequent next calls - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - }); - - it('allows returning early from mapped async iterable', async () => { - const items = [1, 2, 3]; - - const iterable = { - [Symbol.asyncIterator]() { - return this; - }, - next() { - const value = items[0]; - items.shift(); - return Promise.resolve({ - done: items.length === 0, - value, - }); - }, - }; - - const doubles = mapAsyncIterator(iterable, (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ value: 2, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 4, done: false }); - - // Early return - expect(await doubles.return(0)).to.deep.equal({ - value: undefined, - done: true, - }); - }); - - it('passes through early return from async values', async () => { - async function* source() { - try { - yield 'a'; - /* c8 ignore next 2 */ - yield 'b'; - yield 'c'; // Shouldn't be reached. - } finally { - yield 'Done'; - yield 'Last'; - } - } - - const doubles = mapAsyncIterator(source(), (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ value: 'aa', done: false }); - expect(await doubles.next()).to.deep.equal({ value: 'bb', done: false }); - - // Early return - expect(await doubles.return()).to.deep.equal({ - value: 'DoneDone', - done: false, - }); - - // Subsequent next calls may yield from finally block - expect(await doubles.next()).to.deep.equal({ - value: 'LastLast', - done: false, - }); - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - }); - - it('allows throwing errors through async iterable', async () => { - const items = [1, 2, 3]; - - const iterable = { - [Symbol.asyncIterator]() { - return this; - }, - next() { - const value = items[0]; - items.shift(); - return Promise.resolve({ - done: items.length === 0, - value, - }); - }, - }; - - const doubles = mapAsyncIterator(iterable, (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ value: 2, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 4, done: false }); - - // Throw error - let caughtError; - try { - /* c8 ignore next */ - await doubles.throw('ouch'); - } catch (e) { - caughtError = e; - } - expect(caughtError).to.equal('ouch'); - }); - - it('passes through caught errors through async generators', async () => { - async function* source() { - try { - yield 1; - /* c8 ignore next 2 */ - yield 2; - yield 3; // Shouldn't be reached. - } catch (e) { - yield e; - } - } - - const doubles = mapAsyncIterator(source(), (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ value: 2, done: false }); - expect(await doubles.next()).to.deep.equal({ value: 4, done: false }); - - // Throw error - expect(await doubles.throw('Ouch')).to.deep.equal({ - value: 'OuchOuch', - done: false, - }); - - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - expect(await doubles.next()).to.deep.equal({ - value: undefined, - done: true, - }); - }); - - it('does not normally map over thrown errors', async () => { - async function* source() { - yield 'Hello'; - throw new Error('Goodbye'); - } - - const doubles = mapAsyncIterator(source(), (x) => x + x); - - expect(await doubles.next()).to.deep.equal({ - value: 'HelloHello', - done: false, - }); - - let caughtError; - try { - /* c8 ignore next */ - await doubles.next(); - } catch (e) { - caughtError = e; - } - - expect(caughtError) - .to.be.an.instanceOf(Error) - .with.property('message', 'Goodbye'); - }); - - async function testClosesSourceWithMapper(mapper: (value: number) => T) { - let didVisitFinally = false; - - async function* source() { - try { - yield 1; - /* c8 ignore next 2 */ - yield 2; - yield 3; // Shouldn't be reached. - } finally { - didVisitFinally = true; - yield 1000; - } - } - - const throwOver1 = mapAsyncIterator(source(), mapper); - - expect(await throwOver1.next()).to.deep.equal({ value: 1, done: false }); - - let expectedError; - try { - /* c8 ignore next */ - await throwOver1.next(); - } catch (error) { - expectedError = error; - } - - expect(expectedError) - .to.be.an.instanceOf(Error) - .with.property('message', 'Cannot count to 2'); - - expect(await throwOver1.next()).to.deep.equal({ - value: undefined, - done: true, - }); - - expect(didVisitFinally).to.equal(true); - } - - it('closes source if mapper throws an error', async () => { - await testClosesSourceWithMapper((x) => { - if (x > 1) { - throw new Error('Cannot count to ' + x); - } - return x; - }); - }); - - it('closes source if mapper rejects', async () => { - await testClosesSourceWithMapper((x) => - x > 1 - ? Promise.reject(new Error('Cannot count to ' + x)) - : Promise.resolve(x), - ); - }); -}); diff --git a/src/execution/__tests__/mutations-test.ts b/src/execution/__tests__/mutations-test.ts deleted file mode 100644 index 0f0ad1cbf8..0000000000 --- a/src/execution/__tests__/mutations-test.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; -import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick'; - -import { parse } from '../../language/parser'; - -import { GraphQLObjectType } from '../../type/definition'; -import { GraphQLInt } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { execute, executeSync } from '../execute'; - -class NumberHolder { - theNumber: number; - - constructor(originalNumber: number) { - this.theNumber = originalNumber; - } -} - -class Root { - numberHolder: NumberHolder; - - constructor(originalNumber: number) { - this.numberHolder = new NumberHolder(originalNumber); - } - - immediatelyChangeTheNumber(newNumber: number): NumberHolder { - this.numberHolder.theNumber = newNumber; - return this.numberHolder; - } - - async promiseToChangeTheNumber(newNumber: number): Promise { - await resolveOnNextTick(); - return this.immediatelyChangeTheNumber(newNumber); - } - - failToChangeTheNumber(): NumberHolder { - throw new Error('Cannot change the number'); - } - - async promiseAndFailToChangeTheNumber(): Promise { - await resolveOnNextTick(); - throw new Error('Cannot change the number'); - } -} - -const numberHolderType = new GraphQLObjectType({ - fields: { - theNumber: { type: GraphQLInt }, - }, - name: 'NumberHolder', -}); - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - fields: { - numberHolder: { type: numberHolderType }, - }, - name: 'Query', - }), - mutation: new GraphQLObjectType({ - fields: { - immediatelyChangeTheNumber: { - type: numberHolderType, - args: { newNumber: { type: GraphQLInt } }, - resolve(obj, { newNumber }) { - return obj.immediatelyChangeTheNumber(newNumber); - }, - }, - promiseToChangeTheNumber: { - type: numberHolderType, - args: { newNumber: { type: GraphQLInt } }, - resolve(obj, { newNumber }) { - return obj.promiseToChangeTheNumber(newNumber); - }, - }, - failToChangeTheNumber: { - type: numberHolderType, - args: { newNumber: { type: GraphQLInt } }, - resolve(obj, { newNumber }) { - return obj.failToChangeTheNumber(newNumber); - }, - }, - promiseAndFailToChangeTheNumber: { - type: numberHolderType, - args: { newNumber: { type: GraphQLInt } }, - resolve(obj, { newNumber }) { - return obj.promiseAndFailToChangeTheNumber(newNumber); - }, - }, - }, - name: 'Mutation', - }), -}); - -describe('Execute: Handles mutation execution ordering', () => { - it('evaluates mutations serially', async () => { - const document = parse(` - mutation M { - first: immediatelyChangeTheNumber(newNumber: 1) { - theNumber - }, - second: promiseToChangeTheNumber(newNumber: 2) { - theNumber - }, - third: immediatelyChangeTheNumber(newNumber: 3) { - theNumber - } - fourth: promiseToChangeTheNumber(newNumber: 4) { - theNumber - }, - fifth: immediatelyChangeTheNumber(newNumber: 5) { - theNumber - } - } - `); - - const rootValue = new Root(6); - const mutationResult = await execute({ schema, document, rootValue }); - - expect(mutationResult).to.deep.equal({ - data: { - first: { theNumber: 1 }, - second: { theNumber: 2 }, - third: { theNumber: 3 }, - fourth: { theNumber: 4 }, - fifth: { theNumber: 5 }, - }, - }); - }); - - it('does not include illegal mutation fields in output', () => { - const document = parse('mutation { thisIsIllegalDoNotIncludeMe }'); - - const result = executeSync({ schema, document }); - expect(result).to.deep.equal({ - data: {}, - }); - }); - - it('evaluates mutations correctly in the presence of a failed mutation', async () => { - const document = parse(` - mutation M { - first: immediatelyChangeTheNumber(newNumber: 1) { - theNumber - }, - second: promiseToChangeTheNumber(newNumber: 2) { - theNumber - }, - third: failToChangeTheNumber(newNumber: 3) { - theNumber - } - fourth: promiseToChangeTheNumber(newNumber: 4) { - theNumber - }, - fifth: immediatelyChangeTheNumber(newNumber: 5) { - theNumber - } - sixth: promiseAndFailToChangeTheNumber(newNumber: 6) { - theNumber - } - } - `); - - const rootValue = new Root(6); - const result = await execute({ schema, document, rootValue }); - - expectJSON(result).toDeepEqual({ - data: { - first: { theNumber: 1 }, - second: { theNumber: 2 }, - third: null, - fourth: { theNumber: 4 }, - fifth: { theNumber: 5 }, - sixth: null, - }, - errors: [ - { - message: 'Cannot change the number', - locations: [{ line: 9, column: 9 }], - path: ['third'], - }, - { - message: 'Cannot change the number', - locations: [{ line: 18, column: 9 }], - path: ['sixth'], - }, - ], - }); - }); -}); diff --git a/src/execution/__tests__/nonnull-test.ts b/src/execution/__tests__/nonnull-test.ts deleted file mode 100644 index 427f2a64d6..0000000000 --- a/src/execution/__tests__/nonnull-test.ts +++ /dev/null @@ -1,714 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { parse } from '../../language/parser'; - -import { GraphQLNonNull, GraphQLObjectType } from '../../type/definition'; -import { GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import type { ExecutionResult } from '../execute'; -import { execute, executeSync } from '../execute'; - -const syncError = new Error('sync'); -const syncNonNullError = new Error('syncNonNull'); -const promiseError = new Error('promise'); -const promiseNonNullError = new Error('promiseNonNull'); - -const throwingData = { - sync() { - throw syncError; - }, - syncNonNull() { - throw syncNonNullError; - }, - promise() { - return new Promise(() => { - throw promiseError; - }); - }, - promiseNonNull() { - return new Promise(() => { - throw promiseNonNullError; - }); - }, - syncNest() { - return throwingData; - }, - syncNonNullNest() { - return throwingData; - }, - promiseNest() { - return new Promise((resolve) => { - resolve(throwingData); - }); - }, - promiseNonNullNest() { - return new Promise((resolve) => { - resolve(throwingData); - }); - }, -}; - -const nullingData = { - sync() { - return null; - }, - syncNonNull() { - return null; - }, - promise() { - return new Promise((resolve) => { - resolve(null); - }); - }, - promiseNonNull() { - return new Promise((resolve) => { - resolve(null); - }); - }, - syncNest() { - return nullingData; - }, - syncNonNullNest() { - return nullingData; - }, - promiseNest() { - return new Promise((resolve) => { - resolve(nullingData); - }); - }, - promiseNonNullNest() { - return new Promise((resolve) => { - resolve(nullingData); - }); - }, -}; - -const schema = buildSchema(` - type DataType { - sync: String - syncNonNull: String! - promise: String - promiseNonNull: String! - syncNest: DataType - syncNonNullNest: DataType! - promiseNest: DataType - promiseNonNullNest: DataType! - } - - schema { - query: DataType - } -`); - -function executeQuery( - query: string, - rootValue: unknown, -): ExecutionResult | Promise { - return execute({ schema, document: parse(query), rootValue }); -} - -function patch(str: string): string { - return str - .replace(/\bsync\b/g, 'promise') - .replace(/\bsyncNonNull\b/g, 'promiseNonNull'); -} - -// avoids also doing any nests -function patchData(data: ExecutionResult): ExecutionResult { - return JSON.parse(patch(JSON.stringify(data))); -} - -async function executeSyncAndAsync(query: string, rootValue: unknown) { - const syncResult = executeSync({ schema, document: parse(query), rootValue }); - const asyncResult = await execute({ - schema, - document: parse(patch(query)), - rootValue, - }); - - expectJSON(asyncResult).toDeepEqual(patchData(syncResult)); - return syncResult; -} - -describe('Execute: handles non-nullable types', () => { - describe('nulls a nullable field', () => { - const query = ` - { - sync - } - `; - - it('that returns null', async () => { - const result = await executeSyncAndAsync(query, nullingData); - expect(result).to.deep.equal({ - data: { sync: null }, - }); - }); - - it('that throws', async () => { - const result = await executeSyncAndAsync(query, throwingData); - expectJSON(result).toDeepEqual({ - data: { sync: null }, - errors: [ - { - message: syncError.message, - path: ['sync'], - locations: [{ line: 3, column: 9 }], - }, - ], - }); - }); - }); - - describe('nulls a returned object that contains a non-nullable field', () => { - const query = ` - { - syncNest { - syncNonNull, - } - } - `; - - it('that returns null', async () => { - const result = await executeSyncAndAsync(query, nullingData); - expectJSON(result).toDeepEqual({ - data: { syncNest: null }, - errors: [ - { - message: - 'Cannot return null for non-nullable field DataType.syncNonNull.', - path: ['syncNest', 'syncNonNull'], - locations: [{ line: 4, column: 11 }], - }, - ], - }); - }); - - it('that throws', async () => { - const result = await executeSyncAndAsync(query, throwingData); - expectJSON(result).toDeepEqual({ - data: { syncNest: null }, - errors: [ - { - message: syncNonNullError.message, - path: ['syncNest', 'syncNonNull'], - locations: [{ line: 4, column: 11 }], - }, - ], - }); - }); - }); - - describe('nulls a complex tree of nullable fields, each', () => { - const query = ` - { - syncNest { - sync - promise - syncNest { sync promise } - promiseNest { sync promise } - } - promiseNest { - sync - promise - syncNest { sync promise } - promiseNest { sync promise } - } - } - `; - const data = { - syncNest: { - sync: null, - promise: null, - syncNest: { sync: null, promise: null }, - promiseNest: { sync: null, promise: null }, - }, - promiseNest: { - sync: null, - promise: null, - syncNest: { sync: null, promise: null }, - promiseNest: { sync: null, promise: null }, - }, - }; - - it('that returns null', async () => { - const result = await executeQuery(query, nullingData); - expect(result).to.deep.equal({ data }); - }); - - it('that throws', async () => { - const result = await executeQuery(query, throwingData); - expectJSON(result).toDeepEqual({ - data, - errors: [ - { - message: syncError.message, - path: ['syncNest', 'sync'], - locations: [{ line: 4, column: 11 }], - }, - { - message: syncError.message, - path: ['syncNest', 'syncNest', 'sync'], - locations: [{ line: 6, column: 22 }], - }, - { - message: syncError.message, - path: ['syncNest', 'promiseNest', 'sync'], - locations: [{ line: 7, column: 25 }], - }, - { - message: syncError.message, - path: ['promiseNest', 'sync'], - locations: [{ line: 10, column: 11 }], - }, - { - message: syncError.message, - path: ['promiseNest', 'syncNest', 'sync'], - locations: [{ line: 12, column: 22 }], - }, - { - message: promiseError.message, - path: ['syncNest', 'promise'], - locations: [{ line: 5, column: 11 }], - }, - { - message: promiseError.message, - path: ['syncNest', 'syncNest', 'promise'], - locations: [{ line: 6, column: 27 }], - }, - { - message: syncError.message, - path: ['promiseNest', 'promiseNest', 'sync'], - locations: [{ line: 13, column: 25 }], - }, - { - message: promiseError.message, - path: ['syncNest', 'promiseNest', 'promise'], - locations: [{ line: 7, column: 30 }], - }, - { - message: promiseError.message, - path: ['promiseNest', 'promise'], - locations: [{ line: 11, column: 11 }], - }, - { - message: promiseError.message, - path: ['promiseNest', 'syncNest', 'promise'], - locations: [{ line: 12, column: 27 }], - }, - { - message: promiseError.message, - path: ['promiseNest', 'promiseNest', 'promise'], - locations: [{ line: 13, column: 30 }], - }, - ], - }); - }); - }); - - describe('nulls the first nullable object after a field in a long chain of non-null fields', () => { - const query = ` - { - syncNest { - syncNonNullNest { - promiseNonNullNest { - syncNonNullNest { - promiseNonNullNest { - syncNonNull - } - } - } - } - } - promiseNest { - syncNonNullNest { - promiseNonNullNest { - syncNonNullNest { - promiseNonNullNest { - syncNonNull - } - } - } - } - } - anotherNest: syncNest { - syncNonNullNest { - promiseNonNullNest { - syncNonNullNest { - promiseNonNullNest { - promiseNonNull - } - } - } - } - } - anotherPromiseNest: promiseNest { - syncNonNullNest { - promiseNonNullNest { - syncNonNullNest { - promiseNonNullNest { - promiseNonNull - } - } - } - } - } - } - `; - const data = { - syncNest: null, - promiseNest: null, - anotherNest: null, - anotherPromiseNest: null, - }; - - it('that returns null', async () => { - const result = await executeQuery(query, nullingData); - expectJSON(result).toDeepEqual({ - data, - errors: [ - { - message: - 'Cannot return null for non-nullable field DataType.syncNonNull.', - path: [ - 'syncNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNull', - ], - locations: [{ line: 8, column: 19 }], - }, - { - message: - 'Cannot return null for non-nullable field DataType.syncNonNull.', - path: [ - 'promiseNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNull', - ], - locations: [{ line: 19, column: 19 }], - }, - { - message: - 'Cannot return null for non-nullable field DataType.promiseNonNull.', - path: [ - 'anotherNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'promiseNonNull', - ], - locations: [{ line: 30, column: 19 }], - }, - { - message: - 'Cannot return null for non-nullable field DataType.promiseNonNull.', - path: [ - 'anotherPromiseNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'promiseNonNull', - ], - locations: [{ line: 41, column: 19 }], - }, - ], - }); - }); - - it('that throws', async () => { - const result = await executeQuery(query, throwingData); - expectJSON(result).toDeepEqual({ - data, - errors: [ - { - message: syncNonNullError.message, - path: [ - 'syncNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNull', - ], - locations: [{ line: 8, column: 19 }], - }, - { - message: syncNonNullError.message, - path: [ - 'promiseNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNull', - ], - locations: [{ line: 19, column: 19 }], - }, - { - message: promiseNonNullError.message, - path: [ - 'anotherNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'promiseNonNull', - ], - locations: [{ line: 30, column: 19 }], - }, - { - message: promiseNonNullError.message, - path: [ - 'anotherPromiseNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'syncNonNullNest', - 'promiseNonNullNest', - 'promiseNonNull', - ], - locations: [{ line: 41, column: 19 }], - }, - ], - }); - }); - }); - - describe('nulls the top level if non-nullable field', () => { - const query = ` - { - syncNonNull - } - `; - - it('that returns null', async () => { - const result = await executeSyncAndAsync(query, nullingData); - expectJSON(result).toDeepEqual({ - data: null, - errors: [ - { - message: - 'Cannot return null for non-nullable field DataType.syncNonNull.', - path: ['syncNonNull'], - locations: [{ line: 3, column: 9 }], - }, - ], - }); - }); - - it('that throws', async () => { - const result = await executeSyncAndAsync(query, throwingData); - expectJSON(result).toDeepEqual({ - data: null, - errors: [ - { - message: syncNonNullError.message, - path: ['syncNonNull'], - locations: [{ line: 3, column: 9 }], - }, - ], - }); - }); - }); - - describe('Handles non-null argument', () => { - const schemaWithNonNullArg = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - withNonNullArg: { - type: GraphQLString, - args: { - cannotBeNull: { - type: new GraphQLNonNull(GraphQLString), - }, - }, - resolve: (_, args) => 'Passed: ' + String(args.cannotBeNull), - }, - }, - }), - }); - - it('succeeds when passed non-null literal value', () => { - const result = executeSync({ - schema: schemaWithNonNullArg, - document: parse(` - query { - withNonNullArg (cannotBeNull: "literal value") - } - `), - }); - - expect(result).to.deep.equal({ - data: { - withNonNullArg: 'Passed: literal value', - }, - }); - }); - - it('succeeds when passed non-null variable value', () => { - const result = executeSync({ - schema: schemaWithNonNullArg, - document: parse(` - query ($testVar: String!) { - withNonNullArg (cannotBeNull: $testVar) - } - `), - variableValues: { - testVar: 'variable value', - }, - }); - - expect(result).to.deep.equal({ - data: { - withNonNullArg: 'Passed: variable value', - }, - }); - }); - - it('succeeds when missing variable has default value', () => { - const result = executeSync({ - schema: schemaWithNonNullArg, - document: parse(` - query ($testVar: String = "default value") { - withNonNullArg (cannotBeNull: $testVar) - } - `), - variableValues: { - // Intentionally missing variable - }, - }); - - expect(result).to.deep.equal({ - data: { - withNonNullArg: 'Passed: default value', - }, - }); - }); - - it('field error when missing non-null arg', () => { - // Note: validation should identify this issue first (missing args rule) - // however execution should still protect against this. - const result = executeSync({ - schema: schemaWithNonNullArg, - document: parse(` - query { - withNonNullArg - } - `), - }); - - expectJSON(result).toDeepEqual({ - data: { - withNonNullArg: null, - }, - errors: [ - { - message: - 'Argument "cannotBeNull" of required type "String!" was not provided.', - locations: [{ line: 3, column: 13 }], - path: ['withNonNullArg'], - }, - ], - }); - }); - - it('field error when non-null arg provided null', () => { - // Note: validation should identify this issue first (values of correct - // type rule) however execution should still protect against this. - const result = executeSync({ - schema: schemaWithNonNullArg, - document: parse(` - query { - withNonNullArg(cannotBeNull: null) - } - `), - }); - - expectJSON(result).toDeepEqual({ - data: { - withNonNullArg: null, - }, - errors: [ - { - message: - 'Argument "cannotBeNull" of non-null type "String!" must not be null.', - locations: [{ line: 3, column: 42 }], - path: ['withNonNullArg'], - }, - ], - }); - }); - - it('field error when non-null arg not provided variable value', () => { - // Note: validation should identify this issue first (variables in allowed - // position rule) however execution should still protect against this. - const result = executeSync({ - schema: schemaWithNonNullArg, - document: parse(` - query ($testVar: String) { - withNonNullArg(cannotBeNull: $testVar) - } - `), - variableValues: { - // Intentionally missing variable - }, - }); - - expectJSON(result).toDeepEqual({ - data: { - withNonNullArg: null, - }, - errors: [ - { - message: - 'Argument "cannotBeNull" of required type "String!" was provided the variable "$testVar" which was not provided a runtime value.', - locations: [{ line: 3, column: 42 }], - path: ['withNonNullArg'], - }, - ], - }); - }); - - it('field error when non-null arg provided variable with explicit null value', () => { - const result = executeSync({ - schema: schemaWithNonNullArg, - document: parse(` - query ($testVar: String = "default value") { - withNonNullArg (cannotBeNull: $testVar) - } - `), - variableValues: { - testVar: null, - }, - }); - - expectJSON(result).toDeepEqual({ - data: { - withNonNullArg: null, - }, - errors: [ - { - message: - 'Argument "cannotBeNull" of non-null type "String!" must not be null.', - locations: [{ line: 3, column: 43 }], - path: ['withNonNullArg'], - }, - ], - }); - }); - }); -}); diff --git a/src/execution/__tests__/oneof-test.ts b/src/execution/__tests__/oneof-test.ts deleted file mode 100644 index 82965afc24..0000000000 --- a/src/execution/__tests__/oneof-test.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { parse } from '../../language/parser'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import type { ExecutionResult } from '../execute'; -import { execute } from '../execute'; - -const schema = buildSchema(` - type Query { - test(input: TestInputObject!): TestObject - } - - input TestInputObject @oneOf { - a: String - b: Int - } - - type TestObject { - a: String - b: Int - } -`); - -function executeQuery( - query: string, - rootValue: unknown, - variableValues?: { [variable: string]: unknown }, -): ExecutionResult | Promise { - return execute({ schema, document: parse(query), rootValue, variableValues }); -} - -describe('Execute: Handles OneOf Input Objects', () => { - describe('OneOf Input Objects', () => { - const rootValue = { - test({ input }: { input: { a?: string; b?: number } }) { - return input; - }, - }; - - it('accepts a good default value', () => { - const query = ` - query ($input: TestInputObject! = {a: "abc"}) { - test(input: $input) { - a - b - } - } - `; - const result = executeQuery(query, rootValue); - - expectJSON(result).toDeepEqual({ - data: { - test: { - a: 'abc', - b: null, - }, - }, - }); - }); - - it('rejects a bad default value', () => { - const query = ` - query ($input: TestInputObject! = {a: "abc", b: 123}) { - test(input: $input) { - a - b - } - } - `; - const result = executeQuery(query, rootValue); - - expectJSON(result).toDeepEqual({ - data: { - test: null, - }, - errors: [ - { - locations: [{ column: 23, line: 3 }], - message: - // This type of error would be caught at validation-time - // hence the vague error message here. - 'Argument "input" of non-null type "TestInputObject!" must not be null.', - path: ['test'], - }, - ], - }); - }); - - it('accepts a good variable', () => { - const query = ` - query ($input: TestInputObject!) { - test(input: $input) { - a - b - } - } - `; - const result = executeQuery(query, rootValue, { input: { a: 'abc' } }); - - expectJSON(result).toDeepEqual({ - data: { - test: { - a: 'abc', - b: null, - }, - }, - }); - }); - - it('accepts a good variable with an undefined key', () => { - const query = ` - query ($input: TestInputObject!) { - test(input: $input) { - a - b - } - } - `; - const result = executeQuery(query, rootValue, { - input: { a: 'abc', b: undefined }, - }); - - expectJSON(result).toDeepEqual({ - data: { - test: { - a: 'abc', - b: null, - }, - }, - }); - }); - - it('rejects a variable with multiple non-null keys', () => { - const query = ` - query ($input: TestInputObject!) { - test(input: $input) { - a - b - } - } - `; - const result = executeQuery(query, rootValue, { - input: { a: 'abc', b: 123 }, - }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - locations: [{ column: 16, line: 2 }], - message: - 'Variable "$input" got invalid value { a: "abc", b: 123 }; Exactly one key must be specified for OneOf type "TestInputObject".', - }, - ], - }); - }); - - it('rejects a variable with multiple nullable keys', () => { - const query = ` - query ($input: TestInputObject!) { - test(input: $input) { - a - b - } - } - `; - const result = executeQuery(query, rootValue, { - input: { a: 'abc', b: null }, - }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - locations: [{ column: 16, line: 2 }], - message: - 'Variable "$input" got invalid value { a: "abc", b: null }; Exactly one key must be specified for OneOf type "TestInputObject".', - }, - ], - }); - }); - }); -}); diff --git a/src/execution/__tests__/resolve-test.ts b/src/execution/__tests__/resolve-test.ts deleted file mode 100644 index a34da196c6..0000000000 --- a/src/execution/__tests__/resolve-test.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import type { GraphQLFieldConfig } from '../../type/definition'; -import { GraphQLObjectType } from '../../type/definition'; -import { GraphQLInt, GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { executeSync } from '../execute'; - -describe('Execute: resolve function', () => { - function testSchema(testField: GraphQLFieldConfig) { - return new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - test: testField, - }, - }), - }); - } - - it('default function accesses properties', () => { - const result = executeSync({ - schema: testSchema({ type: GraphQLString }), - document: parse('{ test }'), - rootValue: { test: 'testValue' }, - }); - - expect(result).to.deep.equal({ - data: { - test: 'testValue', - }, - }); - }); - - it('default function calls methods', () => { - const rootValue = { - _secret: 'secretValue', - test() { - return this._secret; - }, - }; - - const result = executeSync({ - schema: testSchema({ type: GraphQLString }), - document: parse('{ test }'), - rootValue, - }); - expect(result).to.deep.equal({ - data: { - test: 'secretValue', - }, - }); - }); - - it('default function passes args and context', () => { - class Adder { - _num: number; - - constructor(num: number) { - this._num = num; - } - - test(args: { addend1: number }, context: { addend2: number }) { - return this._num + args.addend1 + context.addend2; - } - } - const rootValue = new Adder(700); - - const schema = testSchema({ - type: GraphQLInt, - args: { - addend1: { type: GraphQLInt }, - }, - }); - const contextValue = { addend2: 9 }; - const document = parse('{ test(addend1: 80) }'); - - const result = executeSync({ schema, document, rootValue, contextValue }); - expect(result).to.deep.equal({ - data: { test: 789 }, - }); - }); - - it('uses provided resolve function', () => { - const schema = testSchema({ - type: GraphQLString, - args: { - aStr: { type: GraphQLString }, - aInt: { type: GraphQLInt }, - }, - resolve: (source, args) => JSON.stringify([source, args]), - }); - - function executeQuery(query: string, rootValue?: unknown) { - const document = parse(query); - return executeSync({ schema, document, rootValue }); - } - - expect(executeQuery('{ test }')).to.deep.equal({ - data: { - test: '[null,{}]', - }, - }); - - expect(executeQuery('{ test }', 'Source!')).to.deep.equal({ - data: { - test: '["Source!",{}]', - }, - }); - - expect(executeQuery('{ test(aStr: "String!") }', 'Source!')).to.deep.equal({ - data: { - test: '["Source!",{"aStr":"String!"}]', - }, - }); - - expect( - executeQuery('{ test(aInt: -123, aStr: "String!") }', 'Source!'), - ).to.deep.equal({ - data: { - test: '["Source!",{"aStr":"String!","aInt":-123}]', - }, - }); - }); -}); diff --git a/src/execution/__tests__/schema-test.ts b/src/execution/__tests__/schema-test.ts deleted file mode 100644 index f9b4e47439..0000000000 --- a/src/execution/__tests__/schema-test.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import { - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, -} from '../../type/definition'; -import { - GraphQLBoolean, - GraphQLID, - GraphQLInt, - GraphQLString, -} from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { executeSync } from '../execute'; - -describe('Execute: Handles execution with a complex schema', () => { - it('executes using a schema', () => { - const BlogImage = new GraphQLObjectType({ - name: 'Image', - fields: { - url: { type: GraphQLString }, - width: { type: GraphQLInt }, - height: { type: GraphQLInt }, - }, - }); - - const BlogAuthor: GraphQLObjectType = new GraphQLObjectType({ - name: 'Author', - fields: () => ({ - id: { type: GraphQLString }, - name: { type: GraphQLString }, - pic: { - args: { width: { type: GraphQLInt }, height: { type: GraphQLInt } }, - type: BlogImage, - resolve: (obj, { width, height }) => obj.pic(width, height), - }, - recentArticle: { type: BlogArticle }, - }), - }); - - const BlogArticle = new GraphQLObjectType({ - name: 'Article', - fields: { - id: { type: new GraphQLNonNull(GraphQLString) }, - isPublished: { type: GraphQLBoolean }, - author: { type: BlogAuthor }, - title: { type: GraphQLString }, - body: { type: GraphQLString }, - keywords: { type: new GraphQLList(GraphQLString) }, - }, - }); - - const BlogQuery = new GraphQLObjectType({ - name: 'Query', - fields: { - article: { - type: BlogArticle, - args: { id: { type: GraphQLID } }, - resolve: (_, { id }) => article(id), - }, - feed: { - type: new GraphQLList(BlogArticle), - resolve: () => [ - article(1), - article(2), - article(3), - article(4), - article(5), - article(6), - article(7), - article(8), - article(9), - article(10), - ], - }, - }, - }); - - const BlogSchema = new GraphQLSchema({ - query: BlogQuery, - }); - - function article(id: number) { - return { - id, - isPublished: true, - author: { - id: 123, - name: 'John Smith', - pic: (width: number, height: number) => getPic(123, width, height), - recentArticle: () => article(1), - }, - title: 'My Article ' + id, - body: 'This is a post', - hidden: 'This data is not exposed in the schema', - keywords: ['foo', 'bar', 1, true, null], - }; - } - - function getPic(uid: number, width: number, height: number) { - return { - url: `cdn://${uid}`, - width: `${width}`, - height: `${height}`, - }; - } - - const document = parse(` - { - feed { - id, - title - }, - article(id: "1") { - ...articleFields, - author { - id, - name, - pic(width: 640, height: 480) { - url, - width, - height - }, - recentArticle { - ...articleFields, - keywords - } - } - } - } - - fragment articleFields on Article { - id, - isPublished, - title, - body, - hidden, - notDefined - } - `); - - // Note: this is intentionally not validating to ensure appropriate - // behavior occurs when executing an invalid query. - expect(executeSync({ schema: BlogSchema, document })).to.deep.equal({ - data: { - feed: [ - { id: '1', title: 'My Article 1' }, - { id: '2', title: 'My Article 2' }, - { id: '3', title: 'My Article 3' }, - { id: '4', title: 'My Article 4' }, - { id: '5', title: 'My Article 5' }, - { id: '6', title: 'My Article 6' }, - { id: '7', title: 'My Article 7' }, - { id: '8', title: 'My Article 8' }, - { id: '9', title: 'My Article 9' }, - { id: '10', title: 'My Article 10' }, - ], - article: { - id: '1', - isPublished: true, - title: 'My Article 1', - body: 'This is a post', - author: { - id: '123', - name: 'John Smith', - pic: { - url: 'cdn://123', - width: 640, - height: 480, - }, - recentArticle: { - id: '1', - isPublished: true, - title: 'My Article 1', - body: 'This is a post', - keywords: ['foo', 'bar', '1', 'true', null], - }, - }, - }, - }, - }); - }); -}); diff --git a/src/execution/__tests__/simplePubSub-test.ts b/src/execution/__tests__/simplePubSub-test.ts deleted file mode 100644 index e919d770e3..0000000000 --- a/src/execution/__tests__/simplePubSub-test.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { SimplePubSub } from './simplePubSub'; - -describe('SimplePubSub', () => { - it('subscribe async-iterator mock', async () => { - const pubsub = new SimplePubSub(); - const iterator = pubsub.getSubscriber((x) => x); - - // Queue up publishes - expect(pubsub.emit('Apple')).to.equal(true); - expect(pubsub.emit('Banana')).to.equal(true); - - // Read payloads - expect(await iterator.next()).to.deep.equal({ - done: false, - value: 'Apple', - }); - expect(await iterator.next()).to.deep.equal({ - done: false, - value: 'Banana', - }); - - // Read ahead - const i3 = iterator.next().then((x) => x); - const i4 = iterator.next().then((x) => x); - - // Publish - expect(pubsub.emit('Coconut')).to.equal(true); - expect(pubsub.emit('Durian')).to.equal(true); - - // Await out of order to get correct results - expect(await i4).to.deep.equal({ done: false, value: 'Durian' }); - expect(await i3).to.deep.equal({ done: false, value: 'Coconut' }); - - // Read ahead - const i5 = iterator.next().then((x) => x); - - // Terminate queue - await iterator.return(); - - // Publish is not caught after terminate - expect(pubsub.emit('Fig')).to.equal(false); - - // Find that cancelled read-ahead got a "done" result - expect(await i5).to.deep.equal({ done: true, value: undefined }); - - // And next returns empty completion value - expect(await iterator.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); -}); diff --git a/src/execution/__tests__/simplePubSub.ts b/src/execution/__tests__/simplePubSub.ts deleted file mode 100644 index 7efdf40e57..0000000000 --- a/src/execution/__tests__/simplePubSub.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { invariant } from '../../jsutils/invariant'; - -/** - * Create an AsyncIterator from an EventEmitter. Useful for mocking a - * PubSub system for tests. - */ -export class SimplePubSub { - private _subscribers: Set<(value: T) => void>; - - constructor() { - this._subscribers = new Set(); - } - - emit(event: T): boolean { - for (const subscriber of this._subscribers) { - subscriber(event); - } - return this._subscribers.size > 0; - } - - getSubscriber(transform: (value: T) => R): AsyncGenerator { - const pullQueue: Array<(result: IteratorResult) => void> = []; - const pushQueue: Array = []; - let listening = true; - this._subscribers.add(pushValue); - - const emptyQueue = () => { - listening = false; - this._subscribers.delete(pushValue); - for (const resolve of pullQueue) { - resolve({ value: undefined, done: true }); - } - pullQueue.length = 0; - pushQueue.length = 0; - }; - - return { - next(): Promise> { - if (!listening) { - return Promise.resolve({ value: undefined, done: true }); - } - - if (pushQueue.length > 0) { - const value = pushQueue[0]; - pushQueue.shift(); - return Promise.resolve({ value, done: false }); - } - return new Promise((resolve) => pullQueue.push(resolve)); - }, - return(): Promise> { - emptyQueue(); - return Promise.resolve({ value: undefined, done: true }); - }, - throw(error: unknown) { - emptyQueue(); - return Promise.reject(error); - }, - [Symbol.asyncIterator]() { - return this; - }, - }; - - function pushValue(event: T): void { - const value: R = transform(event); - if (pullQueue.length > 0) { - const receiver = pullQueue.shift(); - invariant(receiver); - receiver({ value, done: false }); - } else { - pushQueue.push(value); - } - } - } -} diff --git a/src/execution/__tests__/subscribe-test.ts b/src/execution/__tests__/subscribe-test.ts deleted file mode 100644 index e9ea0d0ace..0000000000 --- a/src/execution/__tests__/subscribe-test.ts +++ /dev/null @@ -1,1081 +0,0 @@ -import { assert, expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; -import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick'; - -import { invariant } from '../../jsutils/invariant'; -import { isAsyncIterable } from '../../jsutils/isAsyncIterable'; - -import { parse } from '../../language/parser'; - -import { GraphQLList, GraphQLObjectType } from '../../type/definition'; -import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { createSourceEventStream, subscribe } from '../subscribe'; - -import { SimplePubSub } from './simplePubSub'; - -interface Email { - from: string; - subject: string; - message: string; - unread: boolean; -} - -const EmailType = new GraphQLObjectType({ - name: 'Email', - fields: { - from: { type: GraphQLString }, - subject: { type: GraphQLString }, - message: { type: GraphQLString }, - unread: { type: GraphQLBoolean }, - }, -}); - -const InboxType = new GraphQLObjectType({ - name: 'Inbox', - fields: { - total: { - type: GraphQLInt, - resolve: (inbox) => inbox.emails.length, - }, - unread: { - type: GraphQLInt, - resolve: (inbox) => - inbox.emails.filter((email: any) => email.unread).length, - }, - emails: { type: new GraphQLList(EmailType) }, - }, -}); - -const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - inbox: { type: InboxType }, - }, -}); - -const EmailEventType = new GraphQLObjectType({ - name: 'EmailEvent', - fields: { - email: { type: EmailType }, - inbox: { type: InboxType }, - }, -}); - -const emailSchema = new GraphQLSchema({ - query: QueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - importantEmail: { - type: EmailEventType, - args: { - priority: { type: GraphQLInt }, - }, - }, - }, - }), -}); - -function createSubscription(pubsub: SimplePubSub) { - const document = parse(` - subscription ($priority: Int = 0) { - importantEmail(priority: $priority) { - email { - from - subject - } - inbox { - unread - total - } - } - } - `); - - const emails = [ - { - from: 'joe@graphql.org', - subject: 'Hello', - message: 'Hello World', - unread: false, - }, - ]; - - const data: any = { - inbox: { emails }, - // FIXME: we shouldn't use mapAsyncIterator here since it makes tests way more complex - importantEmail: pubsub.getSubscriber((newEmail) => { - emails.push(newEmail); - - return { - importantEmail: { - email: newEmail, - inbox: data.inbox, - }, - }; - }), - }; - - return subscribe({ schema: emailSchema, document, rootValue: data }); -} - -async function expectPromise(promise: Promise) { - let caughtError: Error; - - try { - /* c8 ignore next 2 */ - await promise; - expect.fail('promise should have thrown but did not'); - } catch (error) { - caughtError = error; - } - - return { - toReject() { - expect(caughtError).to.be.an.instanceOf(Error); - }, - toRejectWith(message: string) { - expect(caughtError).to.be.an.instanceOf(Error); - expect(caughtError).to.have.property('message', message); - }, - }; -} - -const DummyQueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - dummy: { type: GraphQLString }, - }, -}); - -/* eslint-disable @typescript-eslint/require-await */ -// Check all error cases when initializing the subscription. -describe('Subscription Initialization Phase', () => { - it('accepts multiple subscription fields defined in schema', async () => { - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString }, - bar: { type: GraphQLString }, - }, - }), - }); - - async function* fooGenerator() { - yield { foo: 'FooValue' }; - } - - const subscription = await subscribe({ - schema, - document: parse('subscription { foo }'), - rootValue: { foo: fooGenerator }, - }); - invariant(isAsyncIterable(subscription)); - - expect(await subscription.next()).to.deep.equal({ - done: false, - value: { data: { foo: 'FooValue' } }, - }); - - expect(await subscription.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('accepts type definition with sync subscribe function', async () => { - async function* fooGenerator() { - yield { foo: 'FooValue' }; - } - - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { - type: GraphQLString, - subscribe: fooGenerator, - }, - }, - }), - }); - - const subscription = await subscribe({ - schema, - document: parse('subscription { foo }'), - }); - invariant(isAsyncIterable(subscription)); - - expect(await subscription.next()).to.deep.equal({ - done: false, - value: { data: { foo: 'FooValue' } }, - }); - - expect(await subscription.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('accepts type definition with async subscribe function', async () => { - async function* fooGenerator() { - yield { foo: 'FooValue' }; - } - - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { - type: GraphQLString, - async subscribe() { - await resolveOnNextTick(); - return fooGenerator(); - }, - }, - }, - }), - }); - - const subscription = await subscribe({ - schema, - document: parse('subscription { foo }'), - }); - invariant(isAsyncIterable(subscription)); - - expect(await subscription.next()).to.deep.equal({ - done: false, - value: { data: { foo: 'FooValue' } }, - }); - - expect(await subscription.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('uses a custom default subscribeFieldResolver', async () => { - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString }, - }, - }), - }); - - async function* fooGenerator() { - yield { foo: 'FooValue' }; - } - - const subscription = await subscribe({ - schema, - document: parse('subscription { foo }'), - rootValue: { customFoo: fooGenerator }, - subscribeFieldResolver: (root) => root.customFoo(), - }); - invariant(isAsyncIterable(subscription)); - - expect(await subscription.next()).to.deep.equal({ - done: false, - value: { data: { foo: 'FooValue' } }, - }); - - expect(await subscription.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('should only resolve the first field of invalid multi-field', async () => { - async function* fooGenerator() { - yield { foo: 'FooValue' }; - } - - let didResolveFoo = false; - let didResolveBar = false; - - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { - type: GraphQLString, - subscribe() { - didResolveFoo = true; - return fooGenerator(); - }, - }, - bar: { - type: GraphQLString, - /* c8 ignore next 3 */ - subscribe() { - didResolveBar = true; - }, - }, - }, - }), - }); - - const subscription = await subscribe({ - schema, - document: parse('subscription { foo bar }'), - }); - invariant(isAsyncIterable(subscription)); - - expect(didResolveFoo).to.equal(true); - expect(didResolveBar).to.equal(false); - - expect(await subscription.next()).to.have.property('done', false); - - expect(await subscription.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('throws an error if some of required arguments are missing', async () => { - const document = parse('subscription { foo }'); - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString }, - }, - }), - }); - - // @ts-expect-error (schema must not be null) - (await expectPromise(subscribe({ schema: null, document }))).toRejectWith( - 'Expected null to be a GraphQL schema.', - ); - - // @ts-expect-error - (await expectPromise(subscribe({ document }))).toRejectWith( - 'Expected undefined to be a GraphQL schema.', - ); - - // @ts-expect-error (document must not be null) - (await expectPromise(subscribe({ schema, document: null }))).toRejectWith( - 'Must provide document.', - ); - - // @ts-expect-error - (await expectPromise(subscribe({ schema }))).toRejectWith( - 'Must provide document.', - ); - }); - - it('Deprecated: allows positional arguments to createSourceEventStream', async () => { - async function* fooGenerator() { - /* c8 ignore next 2 */ - yield { foo: 'FooValue' }; - } - - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString, subscribe: fooGenerator }, - }, - }), - }); - const document = parse('subscription { foo }'); - - const eventStream = await createSourceEventStream(schema, document); - assert(isAsyncIterable(eventStream)); - }); - - it('Deprecated: throws an error if document is missing when using positional arguments', async () => { - const document = parse('subscription { foo }'); - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString }, - }, - }), - }); - - // @ts-expect-error (schema must not be null) - (await expectPromise(createSourceEventStream(null, document))).toRejectWith( - 'Expected null to be a GraphQL schema.', - ); - - ( - await expectPromise( - createSourceEventStream( - // @ts-expect-error - undefined, - document, - ), - ) - ).toRejectWith('Expected undefined to be a GraphQL schema.'); - - // @ts-expect-error (document must not be null) - (await expectPromise(createSourceEventStream(schema, null))).toRejectWith( - 'Must provide document.', - ); - - // @ts-expect-error - (await expectPromise(createSourceEventStream(schema))).toRejectWith( - 'Must provide document.', - ); - }); - - it('resolves to an error if schema does not support subscriptions', async () => { - const schema = new GraphQLSchema({ query: DummyQueryType }); - const document = parse('subscription { unknownField }'); - - const result = await subscribe({ schema, document }); - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Schema is not configured to execute subscription operation.', - locations: [{ line: 1, column: 1 }], - }, - ], - }); - }); - - it('resolves to an error for unknown subscription field', async () => { - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString }, - }, - }), - }); - const document = parse('subscription { unknownField }'); - - const result = await subscribe({ schema, document }); - expectJSON(result).toDeepEqual({ - errors: [ - { - message: 'The subscription field "unknownField" is not defined.', - locations: [{ line: 1, column: 16 }], - }, - ], - }); - }); - - it('should pass through unexpected errors thrown in subscribe', async () => { - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString }, - }, - }), - }); - - // @ts-expect-error - (await expectPromise(subscribe({ schema, document: {} }))).toReject(); - }); - - it('throws an error if subscribe does not return an iterator', async () => { - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { - type: GraphQLString, - subscribe: () => 'test', - }, - }, - }), - }); - - const document = parse('subscription { foo }'); - - (await expectPromise(subscribe({ schema, document }))).toRejectWith( - 'Subscription field must return Async Iterable. Received: "test".', - ); - }); - - it('resolves to an error for subscription resolver errors', async () => { - async function subscribeWithFn(subscribeFn: () => unknown) { - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { type: GraphQLString, subscribe: subscribeFn }, - }, - }), - }); - const document = parse('subscription { foo }'); - const result = await subscribe({ schema, document }); - - expectJSON(await createSourceEventStream(schema, document)).toDeepEqual( - result, - ); - return result; - } - - const expectedResult = { - errors: [ - { - message: 'test error', - locations: [{ line: 1, column: 16 }], - path: ['foo'], - }, - ], - }; - - expectJSON( - // Returning an error - await subscribeWithFn(() => new Error('test error')), - ).toDeepEqual(expectedResult); - - expectJSON( - // Throwing an error - await subscribeWithFn(() => { - throw new Error('test error'); - }), - ).toDeepEqual(expectedResult); - - expectJSON( - // Resolving to an error - await subscribeWithFn(() => Promise.resolve(new Error('test error'))), - ).toDeepEqual(expectedResult); - - expectJSON( - // Rejecting with an error - await subscribeWithFn(() => Promise.reject(new Error('test error'))), - ).toDeepEqual(expectedResult); - }); - - it('resolves to an error if variables were wrong type', async () => { - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - foo: { - type: GraphQLString, - args: { arg: { type: GraphQLInt } }, - }, - }, - }), - }); - - const variableValues = { arg: 'meow' }; - const document = parse(` - subscription ($arg: Int) { - foo(arg: $arg) - } - `); - - // If we receive variables that cannot be coerced correctly, subscribe() will - // resolve to an ExecutionResult that contains an informative error description. - const result = await subscribe({ schema, document, variableValues }); - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$arg" got invalid value "meow"; Int cannot represent non-integer value: "meow"', - locations: [{ line: 2, column: 21 }], - }, - ], - }); - }); -}); - -// Once a subscription returns a valid AsyncIterator, it can still yield errors. -describe('Subscription Publish Phase', () => { - it('produces a payload for multiple subscribe in same subscription', async () => { - const pubsub = new SimplePubSub(); - - const subscription = await createSubscription(pubsub); - invariant(isAsyncIterable(subscription)); - - const secondSubscription = await createSubscription(pubsub); - invariant(isAsyncIterable(secondSubscription)); - - const payload1 = subscription.next(); - const payload2 = secondSubscription.next(); - - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Alright', - message: 'Tests are good', - unread: true, - }), - ).to.equal(true); - - const expectedPayload = { - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Alright', - }, - inbox: { - unread: 1, - total: 2, - }, - }, - }, - }, - }; - - expect(await payload1).to.deep.equal(expectedPayload); - expect(await payload2).to.deep.equal(expectedPayload); - }); - - it('produces a payload per subscription event', async () => { - const pubsub = new SimplePubSub(); - const subscription = await createSubscription(pubsub); - invariant(isAsyncIterable(subscription)); - - // Wait for the next subscription payload. - const payload = subscription.next(); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Alright', - message: 'Tests are good', - unread: true, - }), - ).to.equal(true); - - // The previously waited on payload now has a value. - expect(await payload).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Alright', - }, - inbox: { - unread: 1, - total: 2, - }, - }, - }, - }, - }); - - // Another new email arrives, before subscription.next() is called. - expect( - pubsub.emit({ - from: 'hyo@graphql.org', - subject: 'Tools', - message: 'I <3 making things', - unread: true, - }), - ).to.equal(true); - - // The next waited on payload will have a value. - expect(await subscription.next()).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'hyo@graphql.org', - subject: 'Tools', - }, - inbox: { - unread: 2, - total: 3, - }, - }, - }, - }, - }); - - // The client decides to disconnect. - expect(await subscription.return()).to.deep.equal({ - done: true, - value: undefined, - }); - - // Which may result in disconnecting upstream services as well. - expect( - pubsub.emit({ - from: 'adam@graphql.org', - subject: 'Important', - message: 'Read me please', - unread: true, - }), - ).to.equal(false); // No more listeners. - - // Awaiting a subscription after closing it results in completed results. - expect(await subscription.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('produces a payload when there are multiple events', async () => { - const pubsub = new SimplePubSub(); - const subscription = await createSubscription(pubsub); - invariant(isAsyncIterable(subscription)); - - let payload = subscription.next(); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Alright', - message: 'Tests are good', - unread: true, - }), - ).to.equal(true); - - expect(await payload).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Alright', - }, - inbox: { - unread: 1, - total: 2, - }, - }, - }, - }, - }); - - payload = subscription.next(); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Alright 2', - message: 'Tests are good 2', - unread: true, - }), - ).to.equal(true); - - expect(await payload).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Alright 2', - }, - inbox: { - unread: 2, - total: 3, - }, - }, - }, - }, - }); - }); - - it('should not trigger when subscription is already done', async () => { - const pubsub = new SimplePubSub(); - const subscription = await createSubscription(pubsub); - invariant(isAsyncIterable(subscription)); - - let payload = subscription.next(); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Alright', - message: 'Tests are good', - unread: true, - }), - ).to.equal(true); - - expect(await payload).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Alright', - }, - inbox: { - unread: 1, - total: 2, - }, - }, - }, - }, - }); - - payload = subscription.next(); - await subscription.return(); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Alright 2', - message: 'Tests are good 2', - unread: true, - }), - ).to.equal(false); - - expect(await payload).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('should not trigger when subscription is thrown', async () => { - const pubsub = new SimplePubSub(); - const subscription = await createSubscription(pubsub); - invariant(isAsyncIterable(subscription)); - - let payload = subscription.next(); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Alright', - message: 'Tests are good', - unread: true, - }), - ).to.equal(true); - - expect(await payload).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Alright', - }, - inbox: { - unread: 1, - total: 2, - }, - }, - }, - }, - }); - - payload = subscription.next(); - - // Throw error - let caughtError; - try { - /* c8 ignore next */ - await subscription.throw('ouch'); - } catch (e) { - caughtError = e; - } - expect(caughtError).to.equal('ouch'); - - expect(await payload).to.deep.equal({ - done: true, - value: undefined, - }); - }); - - it('event order is correct for multiple publishes', async () => { - const pubsub = new SimplePubSub(); - const subscription = await createSubscription(pubsub); - invariant(isAsyncIterable(subscription)); - - let payload = subscription.next(); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Message', - message: 'Tests are good', - unread: true, - }), - ).to.equal(true); - - // A new email arrives! - expect( - pubsub.emit({ - from: 'yuzhi@graphql.org', - subject: 'Message 2', - message: 'Tests are good 2', - unread: true, - }), - ).to.equal(true); - - expect(await payload).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Message', - }, - inbox: { - unread: 2, - total: 3, - }, - }, - }, - }, - }); - - payload = subscription.next(); - - expect(await payload).to.deep.equal({ - done: false, - value: { - data: { - importantEmail: { - email: { - from: 'yuzhi@graphql.org', - subject: 'Message 2', - }, - inbox: { - unread: 2, - total: 3, - }, - }, - }, - }, - }); - }); - - it('should handle error during execution of source event', async () => { - async function* generateMessages() { - yield 'Hello'; - yield 'Goodbye'; - yield 'Bonjour'; - } - - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - newMessage: { - type: GraphQLString, - subscribe: generateMessages, - resolve(message) { - if (message === 'Goodbye') { - throw new Error('Never leave.'); - } - return message; - }, - }, - }, - }), - }); - - const document = parse('subscription { newMessage }'); - const subscription = await subscribe({ schema, document }); - invariant(isAsyncIterable(subscription)); - - expect(await subscription.next()).to.deep.equal({ - done: false, - value: { - data: { newMessage: 'Hello' }, - }, - }); - - // An error in execution is presented as such. - expectJSON(await subscription.next()).toDeepEqual({ - done: false, - value: { - data: { newMessage: null }, - errors: [ - { - message: 'Never leave.', - locations: [{ line: 1, column: 16 }], - path: ['newMessage'], - }, - ], - }, - }); - - // However that does not close the response event stream. - // Subsequent events are still executed. - expectJSON(await subscription.next()).toDeepEqual({ - done: false, - value: { - data: { newMessage: 'Bonjour' }, - }, - }); - - expectJSON(await subscription.next()).toDeepEqual({ - done: true, - value: undefined, - }); - }); - - it('should pass through error thrown in source event stream', async () => { - async function* generateMessages() { - yield 'Hello'; - throw new Error('test error'); - } - - const schema = new GraphQLSchema({ - query: DummyQueryType, - subscription: new GraphQLObjectType({ - name: 'Subscription', - fields: { - newMessage: { - type: GraphQLString, - resolve: (message) => message, - subscribe: generateMessages, - }, - }, - }), - }); - - const document = parse('subscription { newMessage }'); - const subscription = await subscribe({ schema, document }); - invariant(isAsyncIterable(subscription)); - - expect(await subscription.next()).to.deep.equal({ - done: false, - value: { - data: { newMessage: 'Hello' }, - }, - }); - - (await expectPromise(subscription.next())).toRejectWith('test error'); - - expect(await subscription.next()).to.deep.equal({ - done: true, - value: undefined, - }); - }); -}); diff --git a/src/execution/__tests__/sync-test.ts b/src/execution/__tests__/sync-test.ts deleted file mode 100644 index 021f09fa3c..0000000000 --- a/src/execution/__tests__/sync-test.ts +++ /dev/null @@ -1,177 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { parse } from '../../language/parser'; - -import { GraphQLObjectType } from '../../type/definition'; -import { GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { validate } from '../../validation/validate'; - -import { graphqlSync } from '../../graphql'; - -import { execute, executeSync } from '../execute'; - -describe('Execute: synchronously when possible', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - syncField: { - type: GraphQLString, - resolve(rootValue) { - return rootValue; - }, - }, - asyncField: { - type: GraphQLString, - resolve(rootValue) { - return Promise.resolve(rootValue); - }, - }, - }, - }), - mutation: new GraphQLObjectType({ - name: 'Mutation', - fields: { - syncMutationField: { - type: GraphQLString, - resolve(rootValue) { - return rootValue; - }, - }, - }, - }), - }); - - it('does not return a Promise for initial errors', () => { - const doc = 'fragment Example on Query { syncField }'; - const result = execute({ - schema, - document: parse(doc), - rootValue: 'rootValue', - }); - expectJSON(result).toDeepEqual({ - errors: [{ message: 'Must provide an operation.' }], - }); - }); - - it('does not return a Promise if fields are all synchronous', () => { - const doc = 'query Example { syncField }'; - const result = execute({ - schema, - document: parse(doc), - rootValue: 'rootValue', - }); - expect(result).to.deep.equal({ data: { syncField: 'rootValue' } }); - }); - - it('does not return a Promise if mutation fields are all synchronous', () => { - const doc = 'mutation Example { syncMutationField }'; - const result = execute({ - schema, - document: parse(doc), - rootValue: 'rootValue', - }); - expect(result).to.deep.equal({ data: { syncMutationField: 'rootValue' } }); - }); - - it('returns a Promise if any field is asynchronous', async () => { - const doc = 'query Example { syncField, asyncField }'; - const result = execute({ - schema, - document: parse(doc), - rootValue: 'rootValue', - }); - expect(result).to.be.instanceOf(Promise); - expect(await result).to.deep.equal({ - data: { syncField: 'rootValue', asyncField: 'rootValue' }, - }); - }); - - describe('executeSync', () => { - it('does not return a Promise for sync execution', () => { - const doc = 'query Example { syncField }'; - const result = executeSync({ - schema, - document: parse(doc), - rootValue: 'rootValue', - }); - expect(result).to.deep.equal({ data: { syncField: 'rootValue' } }); - }); - - it('throws if encountering async execution', () => { - const doc = 'query Example { syncField, asyncField }'; - expect(() => { - executeSync({ - schema, - document: parse(doc), - rootValue: 'rootValue', - }); - }).to.throw('GraphQL execution failed to complete synchronously.'); - }); - }); - - describe('graphqlSync', () => { - it('report errors raised during schema validation', () => { - const badSchema = new GraphQLSchema({}); - const result = graphqlSync({ - schema: badSchema, - source: '{ __typename }', - }); - expectJSON(result).toDeepEqual({ - errors: [{ message: 'Query root type must be provided.' }], - }); - }); - - it('does not return a Promise for syntax errors', () => { - const doc = 'fragment Example on Query { { { syncField }'; - const result = graphqlSync({ - schema, - source: doc, - }); - expectJSON(result).toDeepEqual({ - errors: [ - { - message: 'Syntax Error: Expected Name, found "{".', - locations: [{ line: 1, column: 29 }], - }, - ], - }); - }); - - it('does not return a Promise for validation errors', () => { - const doc = 'fragment Example on Query { unknownField }'; - const validationErrors = validate(schema, parse(doc)); - const result = graphqlSync({ - schema, - source: doc, - }); - expect(result).to.deep.equal({ errors: validationErrors }); - }); - - it('does not return a Promise for sync execution', () => { - const doc = 'query Example { syncField }'; - const result = graphqlSync({ - schema, - source: doc, - rootValue: 'rootValue', - }); - expect(result).to.deep.equal({ data: { syncField: 'rootValue' } }); - }); - - it('throws if encountering async execution', () => { - const doc = 'query Example { syncField, asyncField }'; - expect(() => { - graphqlSync({ - schema, - source: doc, - rootValue: 'rootValue', - }); - }).to.throw('GraphQL execution failed to complete synchronously.'); - }); - }); -}); diff --git a/src/execution/__tests__/union-interface-test.ts b/src/execution/__tests__/union-interface-test.ts deleted file mode 100644 index 7089f2ba39..0000000000 --- a/src/execution/__tests__/union-interface-test.ts +++ /dev/null @@ -1,659 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import { - GraphQLInterfaceType, - GraphQLList, - GraphQLObjectType, - GraphQLUnionType, -} from '../../type/definition'; -import { GraphQLBoolean, GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { execute, executeSync } from '../execute'; - -class Dog { - name: string; - barks: boolean; - mother?: Dog; - father?: Dog; - progeny: ReadonlyArray; - - constructor(name: string, barks: boolean) { - this.name = name; - this.barks = barks; - this.progeny = []; - } -} - -class Cat { - name: string; - meows: boolean; - mother?: Cat; - father?: Cat; - progeny: ReadonlyArray; - - constructor(name: string, meows: boolean) { - this.name = name; - this.meows = meows; - this.progeny = []; - } -} - -class Person { - name: string; - pets?: ReadonlyArray; - friends?: ReadonlyArray; - - constructor( - name: string, - pets?: ReadonlyArray, - friends?: ReadonlyArray, - ) { - this.name = name; - this.pets = pets; - this.friends = friends; - } -} - -const NamedType = new GraphQLInterfaceType({ - name: 'Named', - fields: { - name: { type: GraphQLString }, - }, -}); - -const LifeType: GraphQLInterfaceType = new GraphQLInterfaceType({ - name: 'Life', - fields: () => ({ - progeny: { type: new GraphQLList(LifeType) }, - }), -}); - -const MammalType: GraphQLInterfaceType = new GraphQLInterfaceType({ - name: 'Mammal', - interfaces: [LifeType], - fields: () => ({ - progeny: { type: new GraphQLList(MammalType) }, - mother: { type: MammalType }, - father: { type: MammalType }, - }), -}); - -const DogType: GraphQLObjectType = new GraphQLObjectType({ - name: 'Dog', - interfaces: [MammalType, LifeType, NamedType], - fields: () => ({ - name: { type: GraphQLString }, - barks: { type: GraphQLBoolean }, - progeny: { type: new GraphQLList(DogType) }, - mother: { type: DogType }, - father: { type: DogType }, - }), - isTypeOf: (value) => value instanceof Dog, -}); - -const CatType: GraphQLObjectType = new GraphQLObjectType({ - name: 'Cat', - interfaces: [MammalType, LifeType, NamedType], - fields: () => ({ - name: { type: GraphQLString }, - meows: { type: GraphQLBoolean }, - progeny: { type: new GraphQLList(CatType) }, - mother: { type: CatType }, - father: { type: CatType }, - }), - isTypeOf: (value) => value instanceof Cat, -}); - -const PetType = new GraphQLUnionType({ - name: 'Pet', - types: [DogType, CatType], - resolveType(value) { - if (value instanceof Dog) { - return DogType.name; - } - if (value instanceof Cat) { - return CatType.name; - } - // Not reachable, all possible types have been considered. - expect.fail('Not reachable'); - }, -}); - -const PersonType: GraphQLObjectType = new GraphQLObjectType({ - name: 'Person', - interfaces: [NamedType, MammalType, LifeType], - fields: () => ({ - name: { type: GraphQLString }, - pets: { type: new GraphQLList(PetType) }, - friends: { type: new GraphQLList(NamedType) }, - progeny: { type: new GraphQLList(PersonType) }, - mother: { type: PersonType }, - father: { type: PersonType }, - }), - isTypeOf: (value) => value instanceof Person, -}); - -const schema = new GraphQLSchema({ - query: PersonType, - types: [PetType], -}); - -const garfield = new Cat('Garfield', false); -garfield.mother = new Cat("Garfield's Mom", false); -garfield.mother.progeny = [garfield]; - -const odie = new Dog('Odie', true); -odie.mother = new Dog("Odie's Mom", true); -odie.mother.progeny = [odie]; - -const liz = new Person('Liz'); -const john = new Person('John', [garfield, odie], [liz, odie]); - -const SearchableInterface = new GraphQLInterfaceType({ - name: 'Searchable', - fields: { - id: { type: GraphQLString }, - }, -}); - -const TypeA = new GraphQLObjectType({ - name: 'TypeA', - interfaces: [SearchableInterface], - fields: () => ({ - id: { type: GraphQLString }, - nameA: { type: GraphQLString }, - }), - isTypeOf: (_value, _context, _info) => - new Promise((_resolve, reject) => - // eslint-disable-next-line - setTimeout(() => reject(new Error('TypeA_isTypeOf_rejected')), 10), - ), -}); - -const TypeB = new GraphQLObjectType({ - name: 'TypeB', - interfaces: [SearchableInterface], - fields: () => ({ - id: { type: GraphQLString }, - nameB: { type: GraphQLString }, - }), - isTypeOf: (value: any, _context, _info) => value.id === 'b', -}); - -const queryTypeWithSearchable = new GraphQLObjectType({ - name: 'Query', - fields: { - person: { - type: PersonType, - resolve: () => john, - }, - search: { - type: SearchableInterface, - args: { id: { type: GraphQLString } }, - resolve: (_source, { id }) => { - if (id === 'a') { - return { id: 'a', nameA: 'Object A' }; - } else if (id === 'b') { - return { id: 'b', nameB: 'Object B' }; - } - }, - }, - }, -}); - -const schemaWithSearchable = new GraphQLSchema({ - query: queryTypeWithSearchable, - types: [ - PetType, - TypeA, - TypeB, - SearchableInterface, - PersonType, - DogType, - CatType, - ], -}); - -describe('Execute: Union and intersection types', () => { - it('can introspect on union and intersection types', () => { - const document = parse(` - { - Named: __type(name: "Named") { - kind - name - fields { name } - interfaces { name } - possibleTypes { name } - enumValues { name } - inputFields { name } - } - Mammal: __type(name: "Mammal") { - kind - name - fields { name } - interfaces { name } - possibleTypes { name } - enumValues { name } - inputFields { name } - } - Pet: __type(name: "Pet") { - kind - name - fields { name } - interfaces { name } - possibleTypes { name } - enumValues { name } - inputFields { name } - } - } - `); - - expect(executeSync({ schema, document })).to.deep.equal({ - data: { - Named: { - kind: 'INTERFACE', - name: 'Named', - fields: [{ name: 'name' }], - interfaces: [], - possibleTypes: [{ name: 'Dog' }, { name: 'Cat' }, { name: 'Person' }], - enumValues: null, - inputFields: null, - }, - Mammal: { - kind: 'INTERFACE', - name: 'Mammal', - fields: [{ name: 'progeny' }, { name: 'mother' }, { name: 'father' }], - interfaces: [{ name: 'Life' }], - possibleTypes: [{ name: 'Dog' }, { name: 'Cat' }, { name: 'Person' }], - enumValues: null, - inputFields: null, - }, - Pet: { - kind: 'UNION', - name: 'Pet', - fields: null, - interfaces: null, - possibleTypes: [{ name: 'Dog' }, { name: 'Cat' }], - enumValues: null, - inputFields: null, - }, - }, - }); - }); - - it('executes using union types', () => { - // NOTE: This is an *invalid* query, but it should be an *executable* query. - const document = parse(` - { - __typename - name - pets { - __typename - name - barks - meows - } - } - `); - - expect(executeSync({ schema, document, rootValue: john })).to.deep.equal({ - data: { - __typename: 'Person', - name: 'John', - pets: [ - { - __typename: 'Cat', - name: 'Garfield', - meows: false, - }, - { - __typename: 'Dog', - name: 'Odie', - barks: true, - }, - ], - }, - }); - }); - - it('executes union types with inline fragments', () => { - // This is the valid version of the query in the above test. - const document = parse(` - { - __typename - name - pets { - __typename - ... on Dog { - name - barks - } - ... on Cat { - name - meows - } - } - } - `); - - expect(executeSync({ schema, document, rootValue: john })).to.deep.equal({ - data: { - __typename: 'Person', - name: 'John', - pets: [ - { - __typename: 'Cat', - name: 'Garfield', - meows: false, - }, - { - __typename: 'Dog', - name: 'Odie', - barks: true, - }, - ], - }, - }); - }); - - it('executes using interface types', () => { - // NOTE: This is an *invalid* query, but it should be an *executable* query. - const document = parse(` - { - __typename - name - friends { - __typename - name - barks - meows - } - } - `); - - expect(executeSync({ schema, document, rootValue: john })).to.deep.equal({ - data: { - __typename: 'Person', - name: 'John', - friends: [ - { __typename: 'Person', name: 'Liz' }, - { __typename: 'Dog', name: 'Odie', barks: true }, - ], - }, - }); - }); - - it('executes interface types with inline fragments', () => { - // This is the valid version of the query in the above test. - const document = parse(` - { - __typename - name - friends { - __typename - name - ... on Dog { - barks - } - ... on Cat { - meows - } - - ... on Mammal { - mother { - __typename - ... on Dog { - name - barks - } - ... on Cat { - name - meows - } - } - } - } - } - `); - - expect(executeSync({ schema, document, rootValue: john })).to.deep.equal({ - data: { - __typename: 'Person', - name: 'John', - friends: [ - { - __typename: 'Person', - name: 'Liz', - mother: null, - }, - { - __typename: 'Dog', - name: 'Odie', - barks: true, - mother: { __typename: 'Dog', name: "Odie's Mom", barks: true }, - }, - ], - }, - }); - }); - - it('executes interface types with named fragments', () => { - const document = parse(` - { - __typename - name - friends { - __typename - name - ...DogBarks - ...CatMeows - } - } - - fragment DogBarks on Dog { - barks - } - - fragment CatMeows on Cat { - meows - } - `); - - expect(executeSync({ schema, document, rootValue: john })).to.deep.equal({ - data: { - __typename: 'Person', - name: 'John', - friends: [ - { - __typename: 'Person', - name: 'Liz', - }, - { - __typename: 'Dog', - name: 'Odie', - barks: true, - }, - ], - }, - }); - }); - - it('allows fragment conditions to be abstract types', () => { - const document = parse(` - { - __typename - name - pets { - ...PetFields, - ...on Mammal { - mother { - ...ProgenyFields - } - } - } - friends { ...FriendFields } - } - - fragment PetFields on Pet { - __typename - ... on Dog { - name - barks - } - ... on Cat { - name - meows - } - } - - fragment FriendFields on Named { - __typename - name - ... on Dog { - barks - } - ... on Cat { - meows - } - } - - fragment ProgenyFields on Life { - progeny { - __typename - } - } - `); - - expect(executeSync({ schema, document, rootValue: john })).to.deep.equal({ - data: { - __typename: 'Person', - name: 'John', - pets: [ - { - __typename: 'Cat', - name: 'Garfield', - meows: false, - mother: { progeny: [{ __typename: 'Cat' }] }, - }, - { - __typename: 'Dog', - name: 'Odie', - barks: true, - mother: { progeny: [{ __typename: 'Dog' }] }, - }, - ], - friends: [ - { - __typename: 'Person', - name: 'Liz', - }, - { - __typename: 'Dog', - name: 'Odie', - barks: true, - }, - ], - }, - }); - }); - - it('gets execution info in resolver', () => { - let encounteredContext; - let encounteredSchema; - let encounteredRootValue; - - const NamedType2: GraphQLInterfaceType = new GraphQLInterfaceType({ - name: 'Named', - fields: { - name: { type: GraphQLString }, - }, - resolveType(_source, context, info) { - encounteredContext = context; - encounteredSchema = info.schema; - encounteredRootValue = info.rootValue; - return PersonType2.name; - }, - }); - - const PersonType2: GraphQLObjectType = new GraphQLObjectType({ - name: 'Person', - interfaces: [NamedType2], - fields: { - name: { type: GraphQLString }, - friends: { type: new GraphQLList(NamedType2) }, - }, - }); - const schema2 = new GraphQLSchema({ query: PersonType2 }); - const document = parse('{ name, friends { name } }'); - const rootValue = new Person('John', [], [liz]); - const contextValue = { authToken: '123abc' }; - - const result = executeSync({ - schema: schema2, - document, - rootValue, - contextValue, - }); - expect(result).to.deep.equal({ - data: { - name: 'John', - friends: [{ name: 'Liz' }], - }, - }); - - expect(encounteredSchema).to.equal(schema2); - expect(encounteredRootValue).to.equal(rootValue); - expect(encounteredContext).to.equal(contextValue); - }); - - it('handles promises from isTypeOf correctly when a later type matches synchronously', async () => { - const document = parse(` - query TestSearch { - search(id: "b") { - __typename - id - ... on TypeA { - nameA - } - ... on TypeB { - nameB - } - } - } - `); - - let unhandledRejection: any = null; - const unhandledRejectionListener = (reason: any) => { - unhandledRejection = reason; - }; - // eslint-disable-next-line - process.on('unhandledRejection', unhandledRejectionListener); - - const result = await execute({ - schema: schemaWithSearchable, - document, - }); - - expect(result.errors).to.equal(undefined); - expect(result.data).to.deep.equal({ - search: { - __typename: 'TypeB', - id: 'b', - nameB: 'Object B', - }, - }); - - // Give the TypeA promise a chance to reject and the listener to fire - // eslint-disable-next-line - await new Promise((resolve) => setTimeout(resolve, 20)); - - // eslint-disable-next-line - process.removeListener('unhandledRejection', unhandledRejectionListener); - - expect(unhandledRejection).to.equal(null); - }); -}); diff --git a/src/execution/__tests__/variables-test.ts b/src/execution/__tests__/variables-test.ts deleted file mode 100644 index 3a859a0bdc..0000000000 --- a/src/execution/__tests__/variables-test.ts +++ /dev/null @@ -1,1139 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { inspect } from '../../jsutils/inspect'; -import { invariant } from '../../jsutils/invariant'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import { Kind } from '../../language/kinds'; -import { parse } from '../../language/parser'; - -import type { - GraphQLArgumentConfig, - GraphQLFieldConfig, -} from '../../type/definition'; -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLScalarType, -} from '../../type/definition'; -import { GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { executeSync } from '../execute'; -import { getVariableValues } from '../values'; - -const TestFaultyScalarGraphQLError = new GraphQLError( - 'FaultyScalarErrorMessage', - { - extensions: { - code: 'FaultyScalarErrorMessageExtensionCode', - }, - }, -); - -const TestFaultyScalar = new GraphQLScalarType({ - name: 'FaultyScalar', - parseValue() { - throw TestFaultyScalarGraphQLError; - }, - parseLiteral() { - throw TestFaultyScalarGraphQLError; - }, -}); - -const TestComplexScalar = new GraphQLScalarType({ - name: 'ComplexScalar', - parseValue(value) { - expect(value).to.equal('SerializedValue'); - return 'DeserializedValue'; - }, - parseLiteral(ast) { - expect(ast).to.include({ kind: 'StringValue', value: 'SerializedValue' }); - return 'DeserializedValue'; - }, -}); - -const TestInputObject = new GraphQLInputObjectType({ - name: 'TestInputObject', - fields: { - a: { type: GraphQLString }, - b: { type: new GraphQLList(GraphQLString) }, - c: { type: new GraphQLNonNull(GraphQLString) }, - d: { type: TestComplexScalar }, - e: { type: TestFaultyScalar }, - }, -}); - -const TestNestedInputObject = new GraphQLInputObjectType({ - name: 'TestNestedInputObject', - fields: { - na: { type: new GraphQLNonNull(TestInputObject) }, - nb: { type: new GraphQLNonNull(GraphQLString) }, - }, -}); - -const TestEnum = new GraphQLEnumType({ - name: 'TestEnum', - values: { - NULL: { value: null }, - UNDEFINED: { value: undefined }, - NAN: { value: NaN }, - FALSE: { value: false }, - CUSTOM: { value: 'custom value' }, - DEFAULT_VALUE: {}, - }, -}); - -function fieldWithInputArg( - inputArg: GraphQLArgumentConfig, -): GraphQLFieldConfig { - return { - type: GraphQLString, - args: { input: inputArg }, - resolve(_, args) { - if ('input' in args) { - return inspect(args.input); - } - }, - }; -} - -const TestType = new GraphQLObjectType({ - name: 'TestType', - fields: { - fieldWithEnumInput: fieldWithInputArg({ type: TestEnum }), - fieldWithNonNullableEnumInput: fieldWithInputArg({ - type: new GraphQLNonNull(TestEnum), - }), - fieldWithObjectInput: fieldWithInputArg({ type: TestInputObject }), - fieldWithNullableStringInput: fieldWithInputArg({ type: GraphQLString }), - fieldWithNonNullableStringInput: fieldWithInputArg({ - type: new GraphQLNonNull(GraphQLString), - }), - fieldWithDefaultArgumentValue: fieldWithInputArg({ - type: GraphQLString, - defaultValue: 'Hello World', - }), - fieldWithNonNullableStringInputAndDefaultArgumentValue: fieldWithInputArg({ - type: new GraphQLNonNull(GraphQLString), - defaultValue: 'Hello World', - }), - fieldWithNestedInputObject: fieldWithInputArg({ - type: TestNestedInputObject, - defaultValue: 'Hello World', - }), - list: fieldWithInputArg({ type: new GraphQLList(GraphQLString) }), - nnList: fieldWithInputArg({ - type: new GraphQLNonNull(new GraphQLList(GraphQLString)), - }), - listNN: fieldWithInputArg({ - type: new GraphQLList(new GraphQLNonNull(GraphQLString)), - }), - nnListNN: fieldWithInputArg({ - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(GraphQLString)), - ), - }), - }, -}); - -const schema = new GraphQLSchema({ query: TestType }); - -function executeQuery( - query: string, - variableValues?: { [variable: string]: unknown }, -) { - const document = parse(query); - return executeSync({ schema, document, variableValues }); -} - -describe('Execute: Handles inputs', () => { - describe('Handles objects and nullability', () => { - describe('using inline structs', () => { - it('executes with complex input', () => { - const result = executeQuery(` - { - fieldWithObjectInput(input: {a: "foo", b: ["bar"], c: "baz"}) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ a: "foo", b: ["bar"], c: "baz" }', - }, - }); - }); - - it('properly parses single value to list', () => { - const result = executeQuery(` - { - fieldWithObjectInput(input: {a: "foo", b: "bar", c: "baz"}) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ a: "foo", b: ["bar"], c: "baz" }', - }, - }); - }); - - it('properly parses null value to null', () => { - const result = executeQuery(` - { - fieldWithObjectInput(input: {a: null, b: null, c: "C", d: null}) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ a: null, b: null, c: "C", d: null }', - }, - }); - }); - - it('properly parses null value in list', () => { - const result = executeQuery(` - { - fieldWithObjectInput(input: {b: ["A",null,"C"], c: "C"}) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ b: ["A", null, "C"], c: "C" }', - }, - }); - }); - - it('does not use incorrect value', () => { - const result = executeQuery(` - { - fieldWithObjectInput(input: ["foo", "bar", "baz"]) - } - `); - - expectJSON(result).toDeepEqual({ - data: { - fieldWithObjectInput: null, - }, - errors: [ - { - message: - 'Argument "input" has invalid value ["foo", "bar", "baz"].', - path: ['fieldWithObjectInput'], - locations: [{ line: 3, column: 41 }], - }, - ], - }); - }); - - it('properly runs parseLiteral on complex scalar types', () => { - const result = executeQuery(` - { - fieldWithObjectInput(input: {c: "foo", d: "SerializedValue"}) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ c: "foo", d: "DeserializedValue" }', - }, - }); - }); - }); - - it('errors on faulty scalar type input', () => { - const result = executeQuery(` - { - fieldWithObjectInput(input: {c: "foo", e: "bar"}) - } - `); - - expectJSON(result).toDeepEqual({ - data: { - fieldWithObjectInput: null, - }, - errors: [ - { - message: 'Argument "input" has invalid value {c: "foo", e: "bar"}.', - path: ['fieldWithObjectInput'], - locations: [{ line: 3, column: 39 }], - }, - ], - }); - }); - - describe('using variables', () => { - const doc = ` - query ($input: TestInputObject) { - fieldWithObjectInput(input: $input) - } - `; - - it('executes with complex input', () => { - const params = { input: { a: 'foo', b: ['bar'], c: 'baz' } }; - const result = executeQuery(doc, params); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ a: "foo", b: ["bar"], c: "baz" }', - }, - }); - }); - - it('uses undefined when variable not provided', () => { - const result = executeQuery( - ` - query q($input: String) { - fieldWithNullableStringInput(input: $input) - }`, - { - // Intentionally missing variable values. - }, - ); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: null, - }, - }); - }); - - it('uses null when variable provided explicit null value', () => { - const result = executeQuery( - ` - query q($input: String) { - fieldWithNullableStringInput(input: $input) - }`, - { input: null }, - ); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: 'null', - }, - }); - }); - - it('uses default value when not provided', () => { - const result = executeQuery(` - query ($input: TestInputObject = {a: "foo", b: ["bar"], c: "baz"}) { - fieldWithObjectInput(input: $input) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ a: "foo", b: ["bar"], c: "baz" }', - }, - }); - }); - - it('does not use default value when provided', () => { - const result = executeQuery( - ` - query q($input: String = "Default value") { - fieldWithNullableStringInput(input: $input) - } - `, - { input: 'Variable value' }, - ); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: '"Variable value"', - }, - }); - }); - - it('uses explicit null value instead of default value', () => { - const result = executeQuery( - ` - query q($input: String = "Default value") { - fieldWithNullableStringInput(input: $input) - }`, - { input: null }, - ); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: 'null', - }, - }); - }); - - it('uses null default value when not provided', () => { - const result = executeQuery( - ` - query q($input: String = null) { - fieldWithNullableStringInput(input: $input) - }`, - { - // Intentionally missing variable values. - }, - ); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: 'null', - }, - }); - }); - - it('properly parses single value to list', () => { - const params = { input: { a: 'foo', b: 'bar', c: 'baz' } }; - const result = executeQuery(doc, params); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ a: "foo", b: ["bar"], c: "baz" }', - }, - }); - }); - - it('executes with complex scalar input', () => { - const params = { input: { c: 'foo', d: 'SerializedValue' } }; - const result = executeQuery(doc, params); - - expect(result).to.deep.equal({ - data: { - fieldWithObjectInput: '{ c: "foo", d: "DeserializedValue" }', - }, - }); - }); - - it('errors on faulty scalar type input', () => { - const params = { input: { c: 'foo', e: 'SerializedValue' } }; - const result = executeQuery(doc, params); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value "SerializedValue" at "input.e"; FaultyScalarErrorMessage', - locations: [{ line: 2, column: 16 }], - extensions: { code: 'FaultyScalarErrorMessageExtensionCode' }, - }, - ], - }); - }); - - it('errors on null for nested non-null', () => { - const params = { input: { a: 'foo', b: 'bar', c: null } }; - const result = executeQuery(doc, params); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value null at "input.c"; Expected non-nullable type "String!" not to be null.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('errors on incorrect type', () => { - const result = executeQuery(doc, { input: 'foo bar' }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value "foo bar"; Expected type "TestInputObject" to be an object.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('errors on omission of nested non-null', () => { - const result = executeQuery(doc, { input: { a: 'foo', b: 'bar' } }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value { a: "foo", b: "bar" }; Field "c" of required type "String!" was not provided.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('errors on deep nested errors and with many errors', () => { - const nestedDoc = ` - query ($input: TestNestedInputObject) { - fieldWithNestedObjectInput(input: $input) - } - `; - const result = executeQuery(nestedDoc, { input: { na: { a: 'foo' } } }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value { a: "foo" } at "input.na"; Field "c" of required type "String!" was not provided.', - locations: [{ line: 2, column: 18 }], - }, - { - message: - 'Variable "$input" got invalid value { na: { a: "foo" } }; Field "nb" of required type "String!" was not provided.', - locations: [{ line: 2, column: 18 }], - }, - ], - }); - }); - - it('errors on addition of unknown input field', () => { - const params = { - input: { a: 'foo', b: 'bar', c: 'baz', extra: 'dog' }, - }; - const result = executeQuery(doc, params); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value { a: "foo", b: "bar", c: "baz", extra: "dog" }; Field "extra" is not defined by type "TestInputObject".', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - }); - }); - - describe('Handles custom enum values', () => { - it('allows custom enum values as inputs', () => { - const result = executeQuery(` - { - null: fieldWithEnumInput(input: NULL) - NaN: fieldWithEnumInput(input: NAN) - false: fieldWithEnumInput(input: FALSE) - customValue: fieldWithEnumInput(input: CUSTOM) - defaultValue: fieldWithEnumInput(input: DEFAULT_VALUE) - } - `); - - expect(result).to.deep.equal({ - data: { - null: 'null', - NaN: 'NaN', - false: 'false', - customValue: '"custom value"', - defaultValue: '"DEFAULT_VALUE"', - }, - }); - }); - - it('allows non-nullable inputs to have null as enum custom value', () => { - const result = executeQuery(` - { - fieldWithNonNullableEnumInput(input: NULL) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNonNullableEnumInput: 'null', - }, - }); - }); - }); - - describe('Handles nullable scalars', () => { - it('allows nullable inputs to be omitted', () => { - const result = executeQuery(` - { - fieldWithNullableStringInput - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: null, - }, - }); - }); - - it('allows nullable inputs to be omitted in a variable', () => { - const result = executeQuery(` - query ($value: String) { - fieldWithNullableStringInput(input: $value) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: null, - }, - }); - }); - - it('allows nullable inputs to be omitted in an unlisted variable', () => { - const result = executeQuery(` - query { - fieldWithNullableStringInput(input: $value) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: null, - }, - }); - }); - - it('allows nullable inputs to be set to null in a variable', () => { - const doc = ` - query ($value: String) { - fieldWithNullableStringInput(input: $value) - } - `; - const result = executeQuery(doc, { value: null }); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: 'null', - }, - }); - }); - - it('allows nullable inputs to be set to a value in a variable', () => { - const doc = ` - query ($value: String) { - fieldWithNullableStringInput(input: $value) - } - `; - const result = executeQuery(doc, { value: 'a' }); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: '"a"', - }, - }); - }); - - it('allows nullable inputs to be set to a value directly', () => { - const result = executeQuery(` - { - fieldWithNullableStringInput(input: "a") - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: '"a"', - }, - }); - }); - }); - - describe('Handles non-nullable scalars', () => { - it('allows non-nullable variable to be omitted given a default', () => { - const result = executeQuery(` - query ($value: String! = "default") { - fieldWithNullableStringInput(input: $value) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNullableStringInput: '"default"', - }, - }); - }); - - it('allows non-nullable inputs to be omitted given a default', () => { - const result = executeQuery(` - query ($value: String = "default") { - fieldWithNonNullableStringInput(input: $value) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNonNullableStringInput: '"default"', - }, - }); - }); - - it('does not allow non-nullable inputs to be omitted in a variable', () => { - const result = executeQuery(` - query ($value: String!) { - fieldWithNonNullableStringInput(input: $value) - } - `); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$value" of required type "String!" was not provided.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('does not allow non-nullable inputs to be set to null in a variable', () => { - const doc = ` - query ($value: String!) { - fieldWithNonNullableStringInput(input: $value) - } - `; - const result = executeQuery(doc, { value: null }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$value" of non-null type "String!" must not be null.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('allows non-nullable inputs to be set to a value in a variable', () => { - const doc = ` - query ($value: String!) { - fieldWithNonNullableStringInput(input: $value) - } - `; - const result = executeQuery(doc, { value: 'a' }); - - expect(result).to.deep.equal({ - data: { - fieldWithNonNullableStringInput: '"a"', - }, - }); - }); - - it('allows non-nullable inputs to be set to a value directly', () => { - const result = executeQuery(` - { - fieldWithNonNullableStringInput(input: "a") - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNonNullableStringInput: '"a"', - }, - }); - }); - - it('reports error for missing non-nullable inputs', () => { - const result = executeQuery('{ fieldWithNonNullableStringInput }'); - - expectJSON(result).toDeepEqual({ - data: { - fieldWithNonNullableStringInput: null, - }, - errors: [ - { - message: - 'Argument "input" of required type "String!" was not provided.', - locations: [{ line: 1, column: 3 }], - path: ['fieldWithNonNullableStringInput'], - }, - ], - }); - }); - - it('reports error for array passed into string input', () => { - const doc = ` - query ($value: String!) { - fieldWithNonNullableStringInput(input: $value) - } - `; - const result = executeQuery(doc, { value: [1, 2, 3] }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$value" got invalid value [1, 2, 3]; String cannot represent a non string value: [1, 2, 3]', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - - expect(result).to.have.nested.property('errors[0].originalError'); - }); - - it('reports error for non-provided variables for non-nullable inputs', () => { - // Note: this test would typically fail validation before encountering - // this execution error, however for queries which previously validated - // and are being run against a new schema which have introduced a breaking - // change to make a formerly non-required argument required, this asserts - // failure before allowing the underlying code to receive a non-null value. - const result = executeQuery(` - { - fieldWithNonNullableStringInput(input: $foo) - } - `); - - expectJSON(result).toDeepEqual({ - data: { - fieldWithNonNullableStringInput: null, - }, - errors: [ - { - message: - 'Argument "input" of required type "String!" was provided the variable "$foo" which was not provided a runtime value.', - locations: [{ line: 3, column: 50 }], - path: ['fieldWithNonNullableStringInput'], - }, - ], - }); - }); - }); - - describe('Handles lists and nullability', () => { - it('allows lists to be null', () => { - const doc = ` - query ($input: [String]) { - list(input: $input) - } - `; - const result = executeQuery(doc, { input: null }); - - expect(result).to.deep.equal({ data: { list: 'null' } }); - }); - - it('allows lists to contain values', () => { - const doc = ` - query ($input: [String]) { - list(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A'] }); - - expect(result).to.deep.equal({ data: { list: '["A"]' } }); - }); - - it('allows lists to contain null', () => { - const doc = ` - query ($input: [String]) { - list(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A', null, 'B'] }); - - expect(result).to.deep.equal({ data: { list: '["A", null, "B"]' } }); - }); - - it('does not allow non-null lists to be null', () => { - const doc = ` - query ($input: [String]!) { - nnList(input: $input) - } - `; - const result = executeQuery(doc, { input: null }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" of non-null type "[String]!" must not be null.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('allows non-null lists to contain values', () => { - const doc = ` - query ($input: [String]!) { - nnList(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A'] }); - - expect(result).to.deep.equal({ data: { nnList: '["A"]' } }); - }); - - it('allows non-null lists to contain null', () => { - const doc = ` - query ($input: [String]!) { - nnList(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A', null, 'B'] }); - - expect(result).to.deep.equal({ data: { nnList: '["A", null, "B"]' } }); - }); - - it('allows lists of non-nulls to be null', () => { - const doc = ` - query ($input: [String!]) { - listNN(input: $input) - } - `; - const result = executeQuery(doc, { input: null }); - - expect(result).to.deep.equal({ data: { listNN: 'null' } }); - }); - - it('allows lists of non-nulls to contain values', () => { - const doc = ` - query ($input: [String!]) { - listNN(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A'] }); - - expect(result).to.deep.equal({ data: { listNN: '["A"]' } }); - }); - - it('does not allow lists of non-nulls to contain null', () => { - const doc = ` - query ($input: [String!]) { - listNN(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A', null, 'B'] }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value null at "input[1]"; Expected non-nullable type "String!" not to be null.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('does not allow non-null lists of non-nulls to be null', () => { - const doc = ` - query ($input: [String!]!) { - nnListNN(input: $input) - } - `; - const result = executeQuery(doc, { input: null }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" of non-null type "[String!]!" must not be null.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('allows non-null lists of non-nulls to contain values', () => { - const doc = ` - query ($input: [String!]!) { - nnListNN(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A'] }); - - expect(result).to.deep.equal({ data: { nnListNN: '["A"]' } }); - }); - - it('does not allow non-null lists of non-nulls to contain null', () => { - const doc = ` - query ($input: [String!]!) { - nnListNN(input: $input) - } - `; - const result = executeQuery(doc, { input: ['A', null, 'B'] }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" got invalid value null at "input[1]"; Expected non-nullable type "String!" not to be null.', - locations: [{ line: 2, column: 16 }], - }, - ], - }); - }); - - it('does not allow invalid types to be used as values', () => { - const doc = ` - query ($input: TestType!) { - fieldWithObjectInput(input: $input) - } - `; - const result = executeQuery(doc, { input: { list: ['A', 'B'] } }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" expected value of type "TestType!" which cannot be used as an input type.', - locations: [{ line: 2, column: 24 }], - }, - ], - }); - }); - - it('does not allow unknown types to be used as values', () => { - const doc = ` - query ($input: UnknownType!) { - fieldWithObjectInput(input: $input) - } - `; - const result = executeQuery(doc, { input: 'WhoKnows' }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$input" expected value of type "UnknownType!" which cannot be used as an input type.', - locations: [{ line: 2, column: 24 }], - }, - ], - }); - }); - }); - - describe('Execute: Uses argument default values', () => { - it('when no argument provided', () => { - const result = executeQuery('{ fieldWithDefaultArgumentValue }'); - - expect(result).to.deep.equal({ - data: { - fieldWithDefaultArgumentValue: '"Hello World"', - }, - }); - }); - - it('when omitted variable provided', () => { - const result = executeQuery(` - query ($optional: String) { - fieldWithDefaultArgumentValue(input: $optional) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithDefaultArgumentValue: '"Hello World"', - }, - }); - }); - - it('not when argument cannot be coerced', () => { - const result = executeQuery(` - { - fieldWithDefaultArgumentValue(input: WRONG_TYPE) - } - `); - - expectJSON(result).toDeepEqual({ - data: { - fieldWithDefaultArgumentValue: null, - }, - errors: [ - { - message: 'Argument "input" has invalid value WRONG_TYPE.', - locations: [{ line: 3, column: 48 }], - path: ['fieldWithDefaultArgumentValue'], - }, - ], - }); - }); - - it('when no runtime value is provided to a non-null argument', () => { - const result = executeQuery(` - query optionalVariable($optional: String) { - fieldWithNonNullableStringInputAndDefaultArgumentValue(input: $optional) - } - `); - - expect(result).to.deep.equal({ - data: { - fieldWithNonNullableStringInputAndDefaultArgumentValue: - '"Hello World"', - }, - }); - }); - }); - - describe('getVariableValues: limit maximum number of coercion errors', () => { - const doc = parse(` - query ($input: [String!]) { - listNN(input: $input) - } - `); - - const operation = doc.definitions[0]; - invariant(operation.kind === Kind.OPERATION_DEFINITION); - const { variableDefinitions } = operation; - invariant(variableDefinitions != null); - - const inputValue = { input: [0, 1, 2] }; - - function invalidValueError(value: number, index: number) { - return { - message: `Variable "$input" got invalid value ${value} at "input[${index}]"; String cannot represent a non string value: ${value}`, - locations: [{ line: 2, column: 14 }], - }; - } - - it('return all errors by default', () => { - const result = getVariableValues(schema, variableDefinitions, inputValue); - - expectJSON(result).toDeepEqual({ - errors: [ - invalidValueError(0, 0), - invalidValueError(1, 1), - invalidValueError(2, 2), - ], - }); - }); - - it('when maxErrors is equal to number of errors', () => { - const result = getVariableValues( - schema, - variableDefinitions, - inputValue, - { maxErrors: 3 }, - ); - - expectJSON(result).toDeepEqual({ - errors: [ - invalidValueError(0, 0), - invalidValueError(1, 1), - invalidValueError(2, 2), - ], - }); - }); - - it('when maxErrors is less than number of errors', () => { - const result = getVariableValues( - schema, - variableDefinitions, - inputValue, - { maxErrors: 2 }, - ); - - expectJSON(result).toDeepEqual({ - errors: [ - invalidValueError(0, 0), - invalidValueError(1, 1), - { - message: - 'Too many errors processing variables, error limit reached. Execution aborted.', - }, - ], - }); - }); - }); -}); diff --git a/src/execution/collectFields.ts b/src/execution/collectFields.ts deleted file mode 100644 index d0961bfae8..0000000000 --- a/src/execution/collectFields.ts +++ /dev/null @@ -1,212 +0,0 @@ -import type { ObjMap } from '../jsutils/ObjMap'; - -import type { - FieldNode, - FragmentDefinitionNode, - FragmentSpreadNode, - InlineFragmentNode, - SelectionSetNode, -} from '../language/ast'; -import { Kind } from '../language/kinds'; - -import type { GraphQLObjectType } from '../type/definition'; -import { isAbstractType } from '../type/definition'; -import { - GraphQLIncludeDirective, - GraphQLSkipDirective, -} from '../type/directives'; -import type { GraphQLSchema } from '../type/schema'; - -import { typeFromAST } from '../utilities/typeFromAST'; - -import { getDirectiveValues } from './values'; - -/** - * Given a selectionSet, collects all of the fields and returns them. - * - * CollectFields requires the "runtime type" of an object. For a field that - * returns an Interface or Union type, the "runtime type" will be the actual - * object type returned by that field. - * - * @internal - */ -export function collectFields( - schema: GraphQLSchema, - fragments: ObjMap, - variableValues: { [variable: string]: unknown }, - runtimeType: GraphQLObjectType, - selectionSet: SelectionSetNode, -): Map> { - const fields = new Map(); - collectFieldsImpl( - schema, - fragments, - variableValues, - runtimeType, - selectionSet, - fields, - new Set(), - ); - return fields; -} - -/** - * Given an array of field nodes, collects all of the subfields of the passed - * in fields, and returns them at the end. - * - * CollectSubFields requires the "return type" of an object. For a field that - * returns an Interface or Union type, the "return type" will be the actual - * object type returned by that field. - * - * @internal - */ -export function collectSubfields( - schema: GraphQLSchema, - fragments: ObjMap, - variableValues: { [variable: string]: unknown }, - returnType: GraphQLObjectType, - fieldNodes: ReadonlyArray, -): Map> { - const subFieldNodes = new Map(); - const visitedFragmentNames = new Set(); - for (const node of fieldNodes) { - if (node.selectionSet) { - collectFieldsImpl( - schema, - fragments, - variableValues, - returnType, - node.selectionSet, - subFieldNodes, - visitedFragmentNames, - ); - } - } - return subFieldNodes; -} - -function collectFieldsImpl( - schema: GraphQLSchema, - fragments: ObjMap, - variableValues: { [variable: string]: unknown }, - runtimeType: GraphQLObjectType, - selectionSet: SelectionSetNode, - fields: Map>, - visitedFragmentNames: Set, -): void { - for (const selection of selectionSet.selections) { - switch (selection.kind) { - case Kind.FIELD: { - if (!shouldIncludeNode(variableValues, selection)) { - continue; - } - const name = getFieldEntryKey(selection); - const fieldList = fields.get(name); - if (fieldList !== undefined) { - fieldList.push(selection); - } else { - fields.set(name, [selection]); - } - break; - } - case Kind.INLINE_FRAGMENT: { - if ( - !shouldIncludeNode(variableValues, selection) || - !doesFragmentConditionMatch(schema, selection, runtimeType) - ) { - continue; - } - collectFieldsImpl( - schema, - fragments, - variableValues, - runtimeType, - selection.selectionSet, - fields, - visitedFragmentNames, - ); - break; - } - case Kind.FRAGMENT_SPREAD: { - const fragName = selection.name.value; - if ( - visitedFragmentNames.has(fragName) || - !shouldIncludeNode(variableValues, selection) - ) { - continue; - } - visitedFragmentNames.add(fragName); - const fragment = fragments[fragName]; - if ( - !fragment || - !doesFragmentConditionMatch(schema, fragment, runtimeType) - ) { - continue; - } - collectFieldsImpl( - schema, - fragments, - variableValues, - runtimeType, - fragment.selectionSet, - fields, - visitedFragmentNames, - ); - break; - } - } - } -} - -/** - * Determines if a field should be included based on the `@include` and `@skip` - * directives, where `@skip` has higher precedence than `@include`. - */ -function shouldIncludeNode( - variableValues: { [variable: string]: unknown }, - node: FragmentSpreadNode | FieldNode | InlineFragmentNode, -): boolean { - const skip = getDirectiveValues(GraphQLSkipDirective, node, variableValues); - if (skip?.if === true) { - return false; - } - - const include = getDirectiveValues( - GraphQLIncludeDirective, - node, - variableValues, - ); - if (include?.if === false) { - return false; - } - return true; -} - -/** - * Determines if a fragment is applicable to the given type. - */ -function doesFragmentConditionMatch( - schema: GraphQLSchema, - fragment: FragmentDefinitionNode | InlineFragmentNode, - type: GraphQLObjectType, -): boolean { - const typeConditionNode = fragment.typeCondition; - if (!typeConditionNode) { - return true; - } - const conditionalType = typeFromAST(schema, typeConditionNode); - if (conditionalType === type) { - return true; - } - if (isAbstractType(conditionalType)) { - return schema.isSubType(conditionalType, type); - } - return false; -} - -/** - * Implements the logic to compute the key of a given field's entry - */ -function getFieldEntryKey(node: FieldNode): string { - return node.alias ? node.alias.value : node.name.value; -} diff --git a/src/execution/execute.ts b/src/execution/execute.ts deleted file mode 100644 index 3021354e28..0000000000 --- a/src/execution/execute.ts +++ /dev/null @@ -1,1079 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import { isIterableObject } from '../jsutils/isIterableObject'; -import { isObjectLike } from '../jsutils/isObjectLike'; -import { isPromise } from '../jsutils/isPromise'; -import type { Maybe } from '../jsutils/Maybe'; -import { memoize3 } from '../jsutils/memoize3'; -import type { ObjMap } from '../jsutils/ObjMap'; -import type { Path } from '../jsutils/Path'; -import { addPath, pathToArray } from '../jsutils/Path'; -import { promiseForObject } from '../jsutils/promiseForObject'; -import type { PromiseOrValue } from '../jsutils/PromiseOrValue'; -import { promiseReduce } from '../jsutils/promiseReduce'; - -import type { GraphQLFormattedError } from '../error/GraphQLError'; -import { GraphQLError } from '../error/GraphQLError'; -import { locatedError } from '../error/locatedError'; - -import type { - DocumentNode, - FieldNode, - FragmentDefinitionNode, - OperationDefinitionNode, -} from '../language/ast'; -import { OperationTypeNode } from '../language/ast'; -import { Kind } from '../language/kinds'; - -import type { - GraphQLAbstractType, - GraphQLField, - GraphQLFieldResolver, - GraphQLLeafType, - GraphQLList, - GraphQLObjectType, - GraphQLOutputType, - GraphQLResolveInfo, - GraphQLTypeResolver, -} from '../type/definition'; -import { - isAbstractType, - isLeafType, - isListType, - isNonNullType, - isObjectType, -} from '../type/definition'; -import { - SchemaMetaFieldDef, - TypeMetaFieldDef, - TypeNameMetaFieldDef, -} from '../type/introspection'; -import type { GraphQLSchema } from '../type/schema'; -import { assertValidSchema } from '../type/validate'; - -import { - collectFields, - collectSubfields as _collectSubfields, -} from './collectFields'; -import { getArgumentValues, getVariableValues } from './values'; - -/** - * A memoized collection of relevant subfields with regard to the return - * type. Memoizing ensures the subfields are not repeatedly calculated, which - * saves overhead when resolving lists of values. - */ -const collectSubfields = memoize3( - ( - exeContext: ExecutionContext, - returnType: GraphQLObjectType, - fieldNodes: ReadonlyArray, - ) => - _collectSubfields( - exeContext.schema, - exeContext.fragments, - exeContext.variableValues, - returnType, - fieldNodes, - ), -); - -/** - * Terminology - * - * "Definitions" are the generic name for top-level statements in the document. - * Examples of this include: - * 1) Operations (such as a query) - * 2) Fragments - * - * "Operations" are a generic name for requests in the document. - * Examples of this include: - * 1) query, - * 2) mutation - * - * "Selections" are the definitions that can appear legally and at - * single level of the query. These include: - * 1) field references e.g `a` - * 2) fragment "spreads" e.g. `...c` - * 3) inline fragment "spreads" e.g. `...on Type { a }` - */ - -/** - * Data that must be available at all points during query execution. - * - * Namely, schema of the type system that is currently executing, - * and the fragments defined in the query document - */ -export interface ExecutionContext { - schema: GraphQLSchema; - fragments: ObjMap; - rootValue: unknown; - contextValue: unknown; - operation: OperationDefinitionNode; - variableValues: { [variable: string]: unknown }; - fieldResolver: GraphQLFieldResolver; - typeResolver: GraphQLTypeResolver; - subscribeFieldResolver: GraphQLFieldResolver; - errors: Array; -} - -/** - * The result of GraphQL execution. - * - * - `errors` is included when any errors occurred as a non-empty array. - * - `data` is the result of a successful execution of the query. - * - `extensions` is reserved for adding non-standard properties. - */ -export interface ExecutionResult< - TData = ObjMap, - TExtensions = ObjMap, -> { - errors?: ReadonlyArray; - data?: TData | null; - extensions?: TExtensions; -} - -export interface FormattedExecutionResult< - TData = ObjMap, - TExtensions = ObjMap, -> { - errors?: ReadonlyArray; - data?: TData | null; - extensions?: TExtensions; -} - -export interface ExecutionArgs { - schema: GraphQLSchema; - document: DocumentNode; - rootValue?: unknown; - contextValue?: unknown; - variableValues?: Maybe<{ readonly [variable: string]: unknown }>; - operationName?: Maybe; - fieldResolver?: Maybe>; - typeResolver?: Maybe>; - subscribeFieldResolver?: Maybe>; - /** Additional execution options. */ - options?: { - /** Set the maximum number of errors allowed for coercing (defaults to 50). */ - maxCoercionErrors?: number; - }; -} - -/** - * Implements the "Executing requests" section of the GraphQL specification. - * - * Returns either a synchronous ExecutionResult (if all encountered resolvers - * are synchronous), or a Promise of an ExecutionResult that will eventually be - * resolved and never rejected. - * - * If the arguments to this function do not result in a legal execution context, - * a GraphQLError will be thrown immediately explaining the invalid input. - */ -export function execute(args: ExecutionArgs): PromiseOrValue { - // Temporary for v15 to v16 migration. Remove in v17 - devAssert( - arguments.length < 2, - 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', - ); - - const { schema, document, variableValues, rootValue } = args; - - // If arguments are missing or incorrect, throw an error. - assertValidExecutionArguments(schema, document, variableValues); - - // If a valid execution context cannot be created due to incorrect arguments, - // a "Response" with only errors is returned. - const exeContext = buildExecutionContext(args); - - // Return early errors if execution context failed. - if (!('schema' in exeContext)) { - return { errors: exeContext }; - } - - // Return a Promise that will eventually resolve to the data described by - // The "Response" section of the GraphQL specification. - // - // If errors are encountered while executing a GraphQL field, only that - // field and its descendants will be omitted, and sibling fields will still - // be executed. An execution which encounters errors will still result in a - // resolved Promise. - // - // Errors from sub-fields of a NonNull type may propagate to the top level, - // at which point we still log the error and null the parent field, which - // in this case is the entire response. - try { - const { operation } = exeContext; - const result = executeOperation(exeContext, operation, rootValue); - if (isPromise(result)) { - return result.then( - (data) => buildResponse(data, exeContext.errors), - (error) => { - exeContext.errors.push(error); - return buildResponse(null, exeContext.errors); - }, - ); - } - return buildResponse(result, exeContext.errors); - } catch (error) { - exeContext.errors.push(error); - return buildResponse(null, exeContext.errors); - } -} - -/** - * Also implements the "Executing requests" section of the GraphQL specification. - * However, it guarantees to complete synchronously (or throw an error) assuming - * that all field resolvers are also synchronous. - */ -export function executeSync(args: ExecutionArgs): ExecutionResult { - const result = execute(args); - - // Assert that the execution was synchronous. - if (isPromise(result)) { - throw new Error('GraphQL execution failed to complete synchronously.'); - } - - return result; -} - -/** - * Given a completed execution context and data, build the `{ errors, data }` - * response defined by the "Response" section of the GraphQL specification. - */ -function buildResponse( - data: ObjMap | null, - errors: ReadonlyArray, -): ExecutionResult { - return errors.length === 0 ? { data } : { errors, data }; -} - -/** - * Essential assertions before executing to provide developer feedback for - * improper use of the GraphQL library. - * - * @internal - */ -export function assertValidExecutionArguments( - schema: GraphQLSchema, - document: DocumentNode, - rawVariableValues: Maybe<{ readonly [variable: string]: unknown }>, -): void { - devAssert(document, 'Must provide document.'); - - // If the schema used for execution is invalid, throw an error. - assertValidSchema(schema); - - // Variables, if provided, must be an object. - devAssert( - rawVariableValues == null || isObjectLike(rawVariableValues), - 'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.', - ); -} - -/** - * Constructs a ExecutionContext object from the arguments passed to - * execute, which we will pass throughout the other execution methods. - * - * Throws a GraphQLError if a valid execution context cannot be created. - * - * @internal - */ -export function buildExecutionContext( - args: ExecutionArgs, -): ReadonlyArray | ExecutionContext { - const { - schema, - document, - rootValue, - contextValue, - variableValues: rawVariableValues, - operationName, - fieldResolver, - typeResolver, - subscribeFieldResolver, - options, - } = args; - - let operation: OperationDefinitionNode | undefined; - const fragments: ObjMap = Object.create(null); - for (const definition of document.definitions) { - switch (definition.kind) { - case Kind.OPERATION_DEFINITION: - if (operationName == null) { - if (operation !== undefined) { - return [ - new GraphQLError( - 'Must provide operation name if query contains multiple operations.', - ), - ]; - } - operation = definition; - } else if (definition.name?.value === operationName) { - operation = definition; - } - break; - case Kind.FRAGMENT_DEFINITION: - fragments[definition.name.value] = definition; - break; - default: - // ignore non-executable definitions - } - } - - if (!operation) { - if (operationName != null) { - return [new GraphQLError(`Unknown operation named "${operationName}".`)]; - } - return [new GraphQLError('Must provide an operation.')]; - } - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const variableDefinitions = operation.variableDefinitions ?? []; - - const coercedVariableValues = getVariableValues( - schema, - variableDefinitions, - rawVariableValues ?? {}, - { maxErrors: options?.maxCoercionErrors ?? 50 }, - ); - - if (coercedVariableValues.errors) { - return coercedVariableValues.errors; - } - - return { - schema, - fragments, - rootValue, - contextValue, - operation, - variableValues: coercedVariableValues.coerced, - fieldResolver: fieldResolver ?? defaultFieldResolver, - typeResolver: typeResolver ?? defaultTypeResolver, - subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver, - errors: [], - }; -} - -/** - * Implements the "Executing operations" section of the spec. - */ -function executeOperation( - exeContext: ExecutionContext, - operation: OperationDefinitionNode, - rootValue: unknown, -): PromiseOrValue | null> { - const rootType = exeContext.schema.getRootType(operation.operation); - if (rootType == null) { - throw new GraphQLError( - `Schema is not configured to execute ${operation.operation} operation.`, - { nodes: operation }, - ); - } - - const rootFields = collectFields( - exeContext.schema, - exeContext.fragments, - exeContext.variableValues, - rootType, - operation.selectionSet, - ); - const path = undefined; - - switch (operation.operation) { - case OperationTypeNode.QUERY: - return executeFields(exeContext, rootType, rootValue, path, rootFields); - case OperationTypeNode.MUTATION: - return executeFieldsSerially( - exeContext, - rootType, - rootValue, - path, - rootFields, - ); - case OperationTypeNode.SUBSCRIPTION: - // TODO: deprecate `subscribe` and move all logic here - // Temporary solution until we finish merging execute and subscribe together - return executeFields(exeContext, rootType, rootValue, path, rootFields); - } -} - -/** - * Implements the "Executing selection sets" section of the spec - * for fields that must be executed serially. - */ -function executeFieldsSerially( - exeContext: ExecutionContext, - parentType: GraphQLObjectType, - sourceValue: unknown, - path: Path | undefined, - fields: Map>, -): PromiseOrValue> { - return promiseReduce( - fields.entries(), - (results, [responseName, fieldNodes]) => { - const fieldPath = addPath(path, responseName, parentType.name); - const result = executeField( - exeContext, - parentType, - sourceValue, - fieldNodes, - fieldPath, - ); - if (result === undefined) { - return results; - } - if (isPromise(result)) { - return result.then((resolvedResult) => { - results[responseName] = resolvedResult; - return results; - }); - } - results[responseName] = result; - return results; - }, - Object.create(null), - ); -} - -/** - * Implements the "Executing selection sets" section of the spec - * for fields that may be executed in parallel. - */ -function executeFields( - exeContext: ExecutionContext, - parentType: GraphQLObjectType, - sourceValue: unknown, - path: Path | undefined, - fields: Map>, -): PromiseOrValue> { - const results = Object.create(null); - let containsPromise = false; - - try { - for (const [responseName, fieldNodes] of fields.entries()) { - const fieldPath = addPath(path, responseName, parentType.name); - const result = executeField( - exeContext, - parentType, - sourceValue, - fieldNodes, - fieldPath, - ); - - if (result !== undefined) { - results[responseName] = result; - if (isPromise(result)) { - containsPromise = true; - } - } - } - } catch (error) { - if (containsPromise) { - // Ensure that any promises returned by other fields are handled, as they may also reject. - return promiseForObject(results).finally(() => { - throw error; - }); - } - throw error; - } - - // If there are no promises, we can just return the object - if (!containsPromise) { - return results; - } - - // Otherwise, results is a map from field name to the result of resolving that - // field, which is possibly a promise. Return a promise that will return this - // same map, but with any promises replaced with the values they resolved to. - return promiseForObject(results); -} - -/** - * Implements the "Executing fields" section of the spec - * In particular, this function figures out the value that the field returns by - * calling its resolve function, then calls completeValue to complete promises, - * serialize scalars, or execute the sub-selection-set for objects. - */ -function executeField( - exeContext: ExecutionContext, - parentType: GraphQLObjectType, - source: unknown, - fieldNodes: ReadonlyArray, - path: Path, -): PromiseOrValue { - const fieldDef = getFieldDef(exeContext.schema, parentType, fieldNodes[0]); - if (!fieldDef) { - return; - } - - const returnType = fieldDef.type; - const resolveFn = fieldDef.resolve ?? exeContext.fieldResolver; - - const info = buildResolveInfo( - exeContext, - fieldDef, - fieldNodes, - parentType, - path, - ); - - // Get the resolve function, regardless of if its result is normal or abrupt (error). - try { - // Build a JS object of arguments from the field.arguments AST, using the - // variables scope to fulfill any variable references. - // TODO: find a way to memoize, in case this field is within a List type. - const args = getArgumentValues( - fieldDef, - fieldNodes[0], - exeContext.variableValues, - ); - - // The resolve function's optional third argument is a context value that - // is provided to every resolve function within an execution. It is commonly - // used to represent an authenticated user, or request-specific caches. - const contextValue = exeContext.contextValue; - - const result = resolveFn(source, args, contextValue, info); - - let completed; - if (isPromise(result)) { - completed = result.then((resolved) => - completeValue(exeContext, returnType, fieldNodes, info, path, resolved), - ); - } else { - completed = completeValue( - exeContext, - returnType, - fieldNodes, - info, - path, - result, - ); - } - - if (isPromise(completed)) { - // Note: we don't rely on a `catch` method, but we do expect "thenable" - // to take a second callback for the error case. - return completed.then(undefined, (rawError) => { - const error = locatedError(rawError, fieldNodes, pathToArray(path)); - return handleFieldError(error, returnType, exeContext); - }); - } - return completed; - } catch (rawError) { - const error = locatedError(rawError, fieldNodes, pathToArray(path)); - return handleFieldError(error, returnType, exeContext); - } -} - -/** - * @internal - */ -export function buildResolveInfo( - exeContext: ExecutionContext, - fieldDef: GraphQLField, - fieldNodes: ReadonlyArray, - parentType: GraphQLObjectType, - path: Path, -): GraphQLResolveInfo { - // The resolve function's optional fourth argument is a collection of - // information about the current execution state. - return { - fieldName: fieldDef.name, - fieldNodes, - returnType: fieldDef.type, - parentType, - path, - schema: exeContext.schema, - fragments: exeContext.fragments, - rootValue: exeContext.rootValue, - operation: exeContext.operation, - variableValues: exeContext.variableValues, - }; -} - -function handleFieldError( - error: GraphQLError, - returnType: GraphQLOutputType, - exeContext: ExecutionContext, -): null { - // If the field type is non-nullable, then it is resolved without any - // protection from errors, however it still properly locates the error. - if (isNonNullType(returnType)) { - throw error; - } - - // Otherwise, error protection is applied, logging the error and resolving - // a null value for this field if one is encountered. - exeContext.errors.push(error); - return null; -} - -/** - * Implements the instructions for completeValue as defined in the - * "Value Completion" section of the spec. - * - * If the field type is Non-Null, then this recursively completes the value - * for the inner type. It throws a field error if that completion returns null, - * as per the "Nullability" section of the spec. - * - * If the field type is a List, then this recursively completes the value - * for the inner type on each item in the list. - * - * If the field type is a Scalar or Enum, ensures the completed value is a legal - * value of the type by calling the `serialize` method of GraphQL type - * definition. - * - * If the field is an abstract type, determine the runtime type of the value - * and then complete based on that type - * - * Otherwise, the field type expects a sub-selection set, and will complete the - * value by executing all sub-selections. - */ -function completeValue( - exeContext: ExecutionContext, - returnType: GraphQLOutputType, - fieldNodes: ReadonlyArray, - info: GraphQLResolveInfo, - path: Path, - result: unknown, -): PromiseOrValue { - // If result is an Error, throw a located error. - if (result instanceof Error) { - throw result; - } - - // If field type is NonNull, complete for inner type, and throw field error - // if result is null. - if (isNonNullType(returnType)) { - const completed = completeValue( - exeContext, - returnType.ofType, - fieldNodes, - info, - path, - result, - ); - if (completed === null) { - throw new Error( - `Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`, - ); - } - return completed; - } - - // If result value is null or undefined then return null. - if (result == null) { - return null; - } - - // If field type is List, complete each item in the list with the inner type - if (isListType(returnType)) { - return completeListValue( - exeContext, - returnType, - fieldNodes, - info, - path, - result, - ); - } - - // If field type is a leaf type, Scalar or Enum, serialize to a valid value, - // returning null if serialization is not possible. - if (isLeafType(returnType)) { - return completeLeafValue(returnType, result); - } - - // If field type is an abstract type, Interface or Union, determine the - // runtime Object type and complete for that type. - if (isAbstractType(returnType)) { - return completeAbstractValue( - exeContext, - returnType, - fieldNodes, - info, - path, - result, - ); - } - - // If field type is Object, execute and complete all sub-selections. - if (isObjectType(returnType)) { - return completeObjectValue( - exeContext, - returnType, - fieldNodes, - info, - path, - result, - ); - } - /* c8 ignore next 6 */ - // Not reachable, all possible output types have been considered. - invariant( - false, - 'Cannot complete value of unexpected output type: ' + inspect(returnType), - ); -} - -/** - * Complete a list value by completing each item in the list with the - * inner type - */ -function completeListValue( - exeContext: ExecutionContext, - returnType: GraphQLList, - fieldNodes: ReadonlyArray, - info: GraphQLResolveInfo, - path: Path, - result: unknown, -): PromiseOrValue> { - if (!isIterableObject(result)) { - throw new GraphQLError( - `Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`, - ); - } - - // This is specified as a simple map, however we're optimizing the path - // where the list contains no Promises by avoiding creating another Promise. - const itemType = returnType.ofType; - let containsPromise = false; - const completedResults = Array.from(result, (item, index) => { - // No need to modify the info object containing the path, - // since from here on it is not ever accessed by resolver functions. - const itemPath = addPath(path, index, undefined); - try { - let completedItem; - if (isPromise(item)) { - completedItem = item.then((resolved) => - completeValue( - exeContext, - itemType, - fieldNodes, - info, - itemPath, - resolved, - ), - ); - } else { - completedItem = completeValue( - exeContext, - itemType, - fieldNodes, - info, - itemPath, - item, - ); - } - - if (isPromise(completedItem)) { - containsPromise = true; - // Note: we don't rely on a `catch` method, but we do expect "thenable" - // to take a second callback for the error case. - return completedItem.then(undefined, (rawError) => { - const error = locatedError( - rawError, - fieldNodes, - pathToArray(itemPath), - ); - return handleFieldError(error, itemType, exeContext); - }); - } - return completedItem; - } catch (rawError) { - const error = locatedError(rawError, fieldNodes, pathToArray(itemPath)); - return handleFieldError(error, itemType, exeContext); - } - }); - - return containsPromise ? Promise.all(completedResults) : completedResults; -} - -/** - * Complete a Scalar or Enum by serializing to a valid value, returning - * null if serialization is not possible. - */ -function completeLeafValue( - returnType: GraphQLLeafType, - result: unknown, -): unknown { - const serializedResult = returnType.serialize(result); - if (serializedResult == null) { - throw new Error( - `Expected \`${inspect(returnType)}.serialize(${inspect(result)})\` to ` + - `return non-nullable value, returned: ${inspect(serializedResult)}`, - ); - } - return serializedResult; -} - -/** - * Complete a value of an abstract type by determining the runtime object type - * of that value, then complete the value for that type. - */ -function completeAbstractValue( - exeContext: ExecutionContext, - returnType: GraphQLAbstractType, - fieldNodes: ReadonlyArray, - info: GraphQLResolveInfo, - path: Path, - result: unknown, -): PromiseOrValue> { - const resolveTypeFn = returnType.resolveType ?? exeContext.typeResolver; - const contextValue = exeContext.contextValue; - const runtimeType = resolveTypeFn(result, contextValue, info, returnType); - - if (isPromise(runtimeType)) { - return runtimeType.then((resolvedRuntimeType) => - completeObjectValue( - exeContext, - ensureValidRuntimeType( - resolvedRuntimeType, - exeContext, - returnType, - fieldNodes, - info, - result, - ), - fieldNodes, - info, - path, - result, - ), - ); - } - - return completeObjectValue( - exeContext, - ensureValidRuntimeType( - runtimeType, - exeContext, - returnType, - fieldNodes, - info, - result, - ), - fieldNodes, - info, - path, - result, - ); -} - -function ensureValidRuntimeType( - runtimeTypeName: unknown, - exeContext: ExecutionContext, - returnType: GraphQLAbstractType, - fieldNodes: ReadonlyArray, - info: GraphQLResolveInfo, - result: unknown, -): GraphQLObjectType { - if (runtimeTypeName == null) { - throw new GraphQLError( - `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}". Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`, - fieldNodes, - ); - } - - // releases before 16.0.0 supported returning `GraphQLObjectType` from `resolveType` - // TODO: remove in 17.0.0 release - if (isObjectType(runtimeTypeName)) { - throw new GraphQLError( - 'Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.', - ); - } - - if (typeof runtimeTypeName !== 'string') { - throw new GraphQLError( - `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with ` + - `value ${inspect(result)}, received "${inspect(runtimeTypeName)}".`, - ); - } - - const runtimeType = exeContext.schema.getType(runtimeTypeName); - if (runtimeType == null) { - throw new GraphQLError( - `Abstract type "${returnType.name}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`, - { nodes: fieldNodes }, - ); - } - - if (!isObjectType(runtimeType)) { - throw new GraphQLError( - `Abstract type "${returnType.name}" was resolved to a non-object type "${runtimeTypeName}".`, - { nodes: fieldNodes }, - ); - } - - if (!exeContext.schema.isSubType(returnType, runtimeType)) { - throw new GraphQLError( - `Runtime Object type "${runtimeType.name}" is not a possible type for "${returnType.name}".`, - { nodes: fieldNodes }, - ); - } - - return runtimeType; -} - -/** - * Complete an Object value by executing all sub-selections. - */ -function completeObjectValue( - exeContext: ExecutionContext, - returnType: GraphQLObjectType, - fieldNodes: ReadonlyArray, - info: GraphQLResolveInfo, - path: Path, - result: unknown, -): PromiseOrValue> { - // Collect sub-fields to execute to complete this value. - const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes); - - // If there is an isTypeOf predicate function, call it with the - // current result. If isTypeOf returns false, then raise an error rather - // than continuing execution. - if (returnType.isTypeOf) { - const isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info); - - if (isPromise(isTypeOf)) { - return isTypeOf.then((resolvedIsTypeOf) => { - if (!resolvedIsTypeOf) { - throw invalidReturnTypeError(returnType, result, fieldNodes); - } - return executeFields( - exeContext, - returnType, - result, - path, - subFieldNodes, - ); - }); - } - - if (!isTypeOf) { - throw invalidReturnTypeError(returnType, result, fieldNodes); - } - } - - return executeFields(exeContext, returnType, result, path, subFieldNodes); -} - -function invalidReturnTypeError( - returnType: GraphQLObjectType, - result: unknown, - fieldNodes: ReadonlyArray, -): GraphQLError { - return new GraphQLError( - `Expected value of type "${returnType.name}" but got: ${inspect(result)}.`, - { nodes: fieldNodes }, - ); -} - -/** - * If a resolveType function is not given, then a default resolve behavior is - * used which attempts two strategies: - * - * First, See if the provided value has a `__typename` field defined, if so, use - * that value as name of the resolved type. - * - * Otherwise, test each possible type for the abstract type by calling - * isTypeOf for the object being coerced, returning the first type that matches. - */ -export const defaultTypeResolver: GraphQLTypeResolver = - function (value, contextValue, info, abstractType) { - // First, look for `__typename`. - if (isObjectLike(value) && typeof value.__typename === 'string') { - return value.__typename; - } - - // Otherwise, test each possible type. - const possibleTypes = info.schema.getPossibleTypes(abstractType); - const promisedIsTypeOfResults = []; - - for (let i = 0; i < possibleTypes.length; i++) { - const type = possibleTypes[i]; - - if (type.isTypeOf) { - const isTypeOfResult = type.isTypeOf(value, contextValue, info); - - if (isPromise(isTypeOfResult)) { - promisedIsTypeOfResults[i] = isTypeOfResult; - } else if (isTypeOfResult) { - if (promisedIsTypeOfResults.length) { - // Explicitly ignore any promise rejections - Promise.allSettled(promisedIsTypeOfResults) - /* c8 ignore next 3 */ - .catch(() => { - // Do nothing - }); - } - return type.name; - } - } - } - - if (promisedIsTypeOfResults.length) { - return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => { - for (let i = 0; i < isTypeOfResults.length; i++) { - if (isTypeOfResults[i]) { - return possibleTypes[i].name; - } - } - }); - } - }; - -/** - * If a resolve function is not given, then a default resolve behavior is used - * which takes the property of the source object of the same name as the field - * and returns it as the result, or if it's a function, returns the result - * of calling that function while passing along args and context value. - */ -export const defaultFieldResolver: GraphQLFieldResolver = - function (source: any, args, contextValue, info) { - // ensure source is a value for which property access is acceptable. - if (isObjectLike(source) || typeof source === 'function') { - const property = source[info.fieldName]; - if (typeof property === 'function') { - return source[info.fieldName](args, contextValue, info); - } - return property; - } - }; - -/** - * This method looks up the field on the given type definition. - * It has special casing for the three introspection fields, - * __schema, __type and __typename. __typename is special because - * it can always be queried as a field, even in situations where no - * other fields are allowed, like on a Union. __schema and __type - * could get automatically added to the query type, but that would - * require mutating type definitions, which would cause issues. - * - * @internal - */ -export function getFieldDef( - schema: GraphQLSchema, - parentType: GraphQLObjectType, - fieldNode: FieldNode, -): Maybe> { - const fieldName = fieldNode.name.value; - - if ( - fieldName === SchemaMetaFieldDef.name && - schema.getQueryType() === parentType - ) { - return SchemaMetaFieldDef; - } else if ( - fieldName === TypeMetaFieldDef.name && - schema.getQueryType() === parentType - ) { - return TypeMetaFieldDef; - } else if (fieldName === TypeNameMetaFieldDef.name) { - return TypeNameMetaFieldDef; - } - return parentType.getFields()[fieldName]; -} diff --git a/src/execution/index.ts b/src/execution/index.ts deleted file mode 100644 index 7727e6d57c..0000000000 --- a/src/execution/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -export { pathToArray as responsePathAsArray } from '../jsutils/Path'; - -export { - execute, - executeSync, - defaultFieldResolver, - defaultTypeResolver, -} from './execute'; - -export type { - ExecutionArgs, - ExecutionResult, - FormattedExecutionResult, -} from './execute'; - -export { subscribe, createSourceEventStream } from './subscribe'; - -export { - getArgumentValues, - getVariableValues, - getDirectiveValues, -} from './values'; diff --git a/src/execution/mapAsyncIterator.ts b/src/execution/mapAsyncIterator.ts deleted file mode 100644 index 82e863c6c0..0000000000 --- a/src/execution/mapAsyncIterator.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { PromiseOrValue } from '../jsutils/PromiseOrValue'; - -/** - * Given an AsyncIterable and a callback function, return an AsyncIterator - * which produces values mapped via calling the callback function. - */ -export function mapAsyncIterator( - iterable: AsyncGenerator | AsyncIterable, - callback: (value: T) => PromiseOrValue, -): AsyncGenerator { - const iterator = iterable[Symbol.asyncIterator](); - - async function mapResult( - result: IteratorResult, - ): Promise> { - if (result.done) { - return result; - } - - try { - return { value: await callback(result.value), done: false }; - } catch (error) { - /* c8 ignore start */ - // FIXME: add test case - if (typeof iterator.return === 'function') { - try { - await iterator.return(); - } catch (_e) { - /* ignore error */ - } - } - throw error; - /* c8 ignore stop */ - } - } - - return { - async next() { - return mapResult(await iterator.next()); - }, - async return(): Promise> { - // If iterator.return() does not exist, then type R must be undefined. - return typeof iterator.return === 'function' - ? mapResult(await iterator.return()) - : { value: undefined as any, done: true }; - }, - async throw(error?: unknown) { - if (typeof iterator.throw === 'function') { - return mapResult(await iterator.throw(error)); - } - throw error; - }, - [Symbol.asyncIterator]() { - return this; - }, - }; -} diff --git a/src/execution/subscribe.ts b/src/execution/subscribe.ts deleted file mode 100644 index 8b20ec3374..0000000000 --- a/src/execution/subscribe.ts +++ /dev/null @@ -1,262 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; -import { isAsyncIterable } from '../jsutils/isAsyncIterable'; -import type { Maybe } from '../jsutils/Maybe'; -import { addPath, pathToArray } from '../jsutils/Path'; - -import { GraphQLError } from '../error/GraphQLError'; -import { locatedError } from '../error/locatedError'; - -import type { DocumentNode } from '../language/ast'; - -import type { GraphQLFieldResolver } from '../type/definition'; -import type { GraphQLSchema } from '../type/schema'; - -import { collectFields } from './collectFields'; -import type { - ExecutionArgs, - ExecutionContext, - ExecutionResult, -} from './execute'; -import { - assertValidExecutionArguments, - buildExecutionContext, - buildResolveInfo, - execute, - getFieldDef, -} from './execute'; -import { mapAsyncIterator } from './mapAsyncIterator'; -import { getArgumentValues } from './values'; - -/** - * Implements the "Subscribe" algorithm described in the GraphQL specification. - * - * Returns a Promise which resolves to either an AsyncIterator (if successful) - * or an ExecutionResult (error). The promise will be rejected if the schema or - * other arguments to this function are invalid, or if the resolved event stream - * is not an async iterable. - * - * If the client-provided arguments to this function do not result in a - * compliant subscription, a GraphQL Response (ExecutionResult) with - * descriptive errors and no data will be returned. - * - * If the source stream could not be created due to faulty subscription - * resolver logic or underlying systems, the promise will resolve to a single - * ExecutionResult containing `errors` and no `data`. - * - * If the operation succeeded, the promise resolves to an AsyncIterator, which - * yields a stream of ExecutionResults representing the response stream. - * - * Accepts either an object with named arguments, or individual arguments. - */ -export async function subscribe( - args: ExecutionArgs, -): Promise | ExecutionResult> { - // Temporary for v15 to v16 migration. Remove in v17 - devAssert( - arguments.length < 2, - 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', - ); - - const resultOrStream = await createSourceEventStream(args); - - if (!isAsyncIterable(resultOrStream)) { - return resultOrStream; - } - - // For each payload yielded from a subscription, map it over the normal - // GraphQL `execute` function, with `payload` as the rootValue. - // This implements the "MapSourceToResponseEvent" algorithm described in - // the GraphQL specification. The `execute` function provides the - // "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the - // "ExecuteQuery" algorithm, for which `execute` is also used. - const mapSourceToResponse = (payload: unknown) => - execute({ - ...args, - rootValue: payload, - }); - - // Map every source value to a ExecutionResult value as described above. - return mapAsyncIterator(resultOrStream, mapSourceToResponse); -} - -type BackwardsCompatibleArgs = - | [options: ExecutionArgs] - | [ - schema: ExecutionArgs['schema'], - document: ExecutionArgs['document'], - rootValue?: ExecutionArgs['rootValue'], - contextValue?: ExecutionArgs['contextValue'], - variableValues?: ExecutionArgs['variableValues'], - operationName?: ExecutionArgs['operationName'], - subscribeFieldResolver?: ExecutionArgs['subscribeFieldResolver'], - ]; - -function toNormalizedArgs(args: BackwardsCompatibleArgs): ExecutionArgs { - const firstArg = args[0]; - if (firstArg && 'document' in firstArg) { - return firstArg; - } - - return { - schema: firstArg, - // FIXME: when underlying TS bug fixed, see https://github.com/microsoft/TypeScript/issues/31613 - document: args[1] as DocumentNode, - rootValue: args[2], - contextValue: args[3], - variableValues: args[4], - operationName: args[5], - subscribeFieldResolver: args[6], - }; -} - -/** - * Implements the "CreateSourceEventStream" algorithm described in the - * GraphQL specification, resolving the subscription source event stream. - * - * Returns a Promise which resolves to either an AsyncIterable (if successful) - * or an ExecutionResult (error). The promise will be rejected if the schema or - * other arguments to this function are invalid, or if the resolved event stream - * is not an async iterable. - * - * If the client-provided arguments to this function do not result in a - * compliant subscription, a GraphQL Response (ExecutionResult) with - * descriptive errors and no data will be returned. - * - * If the the source stream could not be created due to faulty subscription - * resolver logic or underlying systems, the promise will resolve to a single - * ExecutionResult containing `errors` and no `data`. - * - * If the operation succeeded, the promise resolves to the AsyncIterable for the - * event stream returned by the resolver. - * - * A Source Event Stream represents a sequence of events, each of which triggers - * a GraphQL execution for that event. - * - * This may be useful when hosting the stateful subscription service in a - * different process or machine than the stateless GraphQL execution engine, - * or otherwise separating these two steps. For more on this, see the - * "Supporting Subscriptions at Scale" information in the GraphQL specification. - */ -export async function createSourceEventStream( - args: ExecutionArgs, -): Promise | ExecutionResult>; -/** @deprecated will be removed in next major version in favor of named arguments */ -export async function createSourceEventStream( - schema: GraphQLSchema, - document: DocumentNode, - rootValue?: unknown, - contextValue?: unknown, - variableValues?: Maybe<{ readonly [variable: string]: unknown }>, - operationName?: Maybe, - subscribeFieldResolver?: Maybe>, -): Promise | ExecutionResult>; -export async function createSourceEventStream( - ...rawArgs: BackwardsCompatibleArgs -) { - const args = toNormalizedArgs(rawArgs); - - const { schema, document, variableValues } = args; - - // If arguments are missing or incorrectly typed, this is an internal - // developer mistake which should throw an early error. - assertValidExecutionArguments(schema, document, variableValues); - - // If a valid execution context cannot be created due to incorrect arguments, - // a "Response" with only errors is returned. - const exeContext = buildExecutionContext(args); - - // Return early errors if execution context failed. - if (!('schema' in exeContext)) { - return { errors: exeContext }; - } - - try { - const eventStream = await executeSubscription(exeContext); - - // Assert field returned an event stream, otherwise yield an error. - if (!isAsyncIterable(eventStream)) { - throw new Error( - 'Subscription field must return Async Iterable. ' + - `Received: ${inspect(eventStream)}.`, - ); - } - - return eventStream; - } catch (error) { - // If it GraphQLError, report it as an ExecutionResult, containing only errors and no data. - // Otherwise treat the error as a system-class error and re-throw it. - if (error instanceof GraphQLError) { - return { errors: [error] }; - } - throw error; - } -} - -async function executeSubscription( - exeContext: ExecutionContext, -): Promise { - const { schema, fragments, operation, variableValues, rootValue } = - exeContext; - - const rootType = schema.getSubscriptionType(); - if (rootType == null) { - throw new GraphQLError( - 'Schema is not configured to execute subscription operation.', - { nodes: operation }, - ); - } - - const rootFields = collectFields( - schema, - fragments, - variableValues, - rootType, - operation.selectionSet, - ); - const [responseName, fieldNodes] = [...rootFields.entries()][0]; - const fieldDef = getFieldDef(schema, rootType, fieldNodes[0]); - - if (!fieldDef) { - const fieldName = fieldNodes[0].name.value; - throw new GraphQLError( - `The subscription field "${fieldName}" is not defined.`, - { nodes: fieldNodes }, - ); - } - - const path = addPath(undefined, responseName, rootType.name); - const info = buildResolveInfo( - exeContext, - fieldDef, - fieldNodes, - rootType, - path, - ); - - try { - // Implements the "ResolveFieldEventStream" algorithm from GraphQL specification. - // It differs from "ResolveFieldValue" due to providing a different `resolveFn`. - - // Build a JS object of arguments from the field.arguments AST, using the - // variables scope to fulfill any variable references. - const args = getArgumentValues(fieldDef, fieldNodes[0], variableValues); - - // The resolve function's optional third argument is a context value that - // is provided to every resolve function within an execution. It is commonly - // used to represent an authenticated user, or request-specific caches. - const contextValue = exeContext.contextValue; - - // Call the `subscribe()` resolver or the default resolver to produce an - // AsyncIterable yielding raw payloads. - const resolveFn = fieldDef.subscribe ?? exeContext.subscribeFieldResolver; - const eventStream = await resolveFn(rootValue, args, contextValue, info); - - if (eventStream instanceof Error) { - throw eventStream; - } - return eventStream; - } catch (error) { - throw locatedError(error, fieldNodes, pathToArray(path)); - } -} diff --git a/src/execution/values.ts b/src/execution/values.ts deleted file mode 100644 index d65ea9cf20..0000000000 --- a/src/execution/values.ts +++ /dev/null @@ -1,255 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { keyMap } from '../jsutils/keyMap'; -import type { Maybe } from '../jsutils/Maybe'; -import type { ObjMap } from '../jsutils/ObjMap'; -import { printPathArray } from '../jsutils/printPathArray'; - -import { GraphQLError } from '../error/GraphQLError'; - -import type { - DirectiveNode, - FieldNode, - VariableDefinitionNode, -} from '../language/ast'; -import { Kind } from '../language/kinds'; -import { print } from '../language/printer'; - -import type { GraphQLField } from '../type/definition'; -import { isInputType, isNonNullType } from '../type/definition'; -import type { GraphQLDirective } from '../type/directives'; -import type { GraphQLSchema } from '../type/schema'; - -import { coerceInputValue } from '../utilities/coerceInputValue'; -import { typeFromAST } from '../utilities/typeFromAST'; -import { valueFromAST } from '../utilities/valueFromAST'; - -type CoercedVariableValues = - | { errors: ReadonlyArray; coerced?: never } - | { coerced: { [variable: string]: unknown }; errors?: never }; - -/** - * Prepares an object map of variableValues of the correct type based on the - * provided variable definitions and arbitrary input. If the input cannot be - * parsed to match the variable definitions, a GraphQLError will be thrown. - * - * Note: The returned value is a plain Object with a prototype, since it is - * exposed to user code. Care should be taken to not pull values from the - * Object prototype. - */ -export function getVariableValues( - schema: GraphQLSchema, - varDefNodes: ReadonlyArray, - inputs: { readonly [variable: string]: unknown }, - options?: { maxErrors?: number }, -): CoercedVariableValues { - const errors = []; - const maxErrors = options?.maxErrors; - try { - const coerced = coerceVariableValues( - schema, - varDefNodes, - inputs, - (error) => { - if (maxErrors != null && errors.length >= maxErrors) { - throw new GraphQLError( - 'Too many errors processing variables, error limit reached. Execution aborted.', - ); - } - errors.push(error); - }, - ); - - if (errors.length === 0) { - return { coerced }; - } - } catch (error) { - errors.push(error); - } - - return { errors }; -} - -function coerceVariableValues( - schema: GraphQLSchema, - varDefNodes: ReadonlyArray, - inputs: { readonly [variable: string]: unknown }, - onError: (error: GraphQLError) => void, -): { [variable: string]: unknown } { - const coercedValues: { [variable: string]: unknown } = {}; - for (const varDefNode of varDefNodes) { - const varName = varDefNode.variable.name.value; - const varType = typeFromAST(schema, varDefNode.type); - if (!isInputType(varType)) { - // Must use input types for variables. This should be caught during - // validation, however is checked again here for safety. - const varTypeStr = print(varDefNode.type); - onError( - new GraphQLError( - `Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, - { nodes: varDefNode.type }, - ), - ); - continue; - } - - if (!hasOwnProperty(inputs, varName)) { - if (varDefNode.defaultValue) { - coercedValues[varName] = valueFromAST(varDefNode.defaultValue, varType); - } else if (isNonNullType(varType)) { - const varTypeStr = inspect(varType); - onError( - new GraphQLError( - `Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, - { nodes: varDefNode }, - ), - ); - } - continue; - } - - const value = inputs[varName]; - if (value === null && isNonNullType(varType)) { - const varTypeStr = inspect(varType); - onError( - new GraphQLError( - `Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, - { nodes: varDefNode }, - ), - ); - continue; - } - - coercedValues[varName] = coerceInputValue( - value, - varType, - (path, invalidValue, error) => { - let prefix = - `Variable "$${varName}" got invalid value ` + inspect(invalidValue); - if (path.length > 0) { - prefix += ` at "${varName}${printPathArray(path)}"`; - } - onError( - new GraphQLError(prefix + '; ' + error.message, { - nodes: varDefNode, - originalError: error, - }), - ); - }, - ); - } - - return coercedValues; -} - -/** - * Prepares an object map of argument values given a list of argument - * definitions and list of argument AST nodes. - * - * Note: The returned value is a plain Object with a prototype, since it is - * exposed to user code. Care should be taken to not pull values from the - * Object prototype. - */ -export function getArgumentValues( - def: GraphQLField | GraphQLDirective, - node: FieldNode | DirectiveNode, - variableValues?: Maybe>, -): { [argument: string]: unknown } { - const coercedValues: { [argument: string]: unknown } = {}; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const argumentNodes = node.arguments ?? []; - const argNodeMap = keyMap(argumentNodes, (arg) => arg.name.value); - - for (const argDef of def.args) { - const name = argDef.name; - const argType = argDef.type; - const argumentNode = argNodeMap[name]; - - if (!argumentNode) { - if (argDef.defaultValue !== undefined) { - coercedValues[name] = argDef.defaultValue; - } else if (isNonNullType(argType)) { - throw new GraphQLError( - `Argument "${name}" of required type "${inspect(argType)}" ` + - 'was not provided.', - { nodes: node }, - ); - } - continue; - } - - const valueNode = argumentNode.value; - let isNull = valueNode.kind === Kind.NULL; - - if (valueNode.kind === Kind.VARIABLE) { - const variableName = valueNode.name.value; - if ( - variableValues == null || - !hasOwnProperty(variableValues, variableName) - ) { - if (argDef.defaultValue !== undefined) { - coercedValues[name] = argDef.defaultValue; - } else if (isNonNullType(argType)) { - throw new GraphQLError( - `Argument "${name}" of required type "${inspect(argType)}" ` + - `was provided the variable "$${variableName}" which was not provided a runtime value.`, - { nodes: valueNode }, - ); - } - continue; - } - isNull = variableValues[variableName] == null; - } - - if (isNull && isNonNullType(argType)) { - throw new GraphQLError( - `Argument "${name}" of non-null type "${inspect(argType)}" ` + - 'must not be null.', - { nodes: valueNode }, - ); - } - - const coercedValue = valueFromAST(valueNode, argType, variableValues); - if (coercedValue === undefined) { - // Note: ValuesOfCorrectTypeRule validation should catch this before - // execution. This is a runtime check to ensure execution does not - // continue with an invalid argument value. - throw new GraphQLError( - `Argument "${name}" has invalid value ${print(valueNode)}.`, - { nodes: valueNode }, - ); - } - coercedValues[name] = coercedValue; - } - return coercedValues; -} - -/** - * Prepares an object map of argument values given a directive definition - * and a AST node which may contain directives. Optionally also accepts a map - * of variable values. - * - * If the directive does not exist on the node, returns undefined. - * - * Note: The returned value is a plain Object with a prototype, since it is - * exposed to user code. Care should be taken to not pull values from the - * Object prototype. - */ -export function getDirectiveValues( - directiveDef: GraphQLDirective, - node: { readonly directives?: ReadonlyArray }, - variableValues?: Maybe>, -): undefined | { [argument: string]: unknown } { - const directiveNode = node.directives?.find( - (directive) => directive.name.value === directiveDef.name, - ); - - if (directiveNode) { - return getArgumentValues(directiveDef, directiveNode, variableValues); - } -} - -function hasOwnProperty(obj: unknown, prop: string): boolean { - return Object.prototype.hasOwnProperty.call(obj, prop); -} diff --git a/src/graphql.ts b/src/graphql.ts deleted file mode 100644 index bc6fb9bb72..0000000000 --- a/src/graphql.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { devAssert } from './jsutils/devAssert'; -import { isPromise } from './jsutils/isPromise'; -import type { Maybe } from './jsutils/Maybe'; -import type { PromiseOrValue } from './jsutils/PromiseOrValue'; - -import { parse } from './language/parser'; -import type { Source } from './language/source'; - -import type { - GraphQLFieldResolver, - GraphQLTypeResolver, -} from './type/definition'; -import type { GraphQLSchema } from './type/schema'; -import { validateSchema } from './type/validate'; - -import { validate } from './validation/validate'; - -import type { ExecutionResult } from './execution/execute'; -import { execute } from './execution/execute'; - -/** - * This is the primary entry point function for fulfilling GraphQL operations - * by parsing, validating, and executing a GraphQL document along side a - * GraphQL schema. - * - * More sophisticated GraphQL servers, such as those which persist queries, - * may wish to separate the validation and execution phases to a static time - * tooling step, and a server runtime step. - * - * Accepts either an object with named arguments, or individual arguments: - * - * schema: - * The GraphQL type system to use when validating and executing a query. - * source: - * A GraphQL language formatted string representing the requested operation. - * rootValue: - * The value provided as the first argument to resolver functions on the top - * level type (e.g. the query object type). - * contextValue: - * The context value is provided as an argument to resolver functions after - * field arguments. It is used to pass shared information useful at any point - * during executing this query, for example the currently logged in user and - * connections to databases or other services. - * variableValues: - * A mapping of variable name to runtime value to use for all variables - * defined in the requestString. - * operationName: - * The name of the operation to use if requestString contains multiple - * possible operations. Can be omitted if requestString contains only - * one operation. - * fieldResolver: - * A resolver function to use when one is not provided by the schema. - * If not provided, the default field resolver is used (which looks for a - * value or method on the source value with the field's name). - * typeResolver: - * A type resolver function to use when none is provided by the schema. - * If not provided, the default type resolver is used (which looks for a - * `__typename` field or alternatively calls the `isTypeOf` method). - */ -export interface GraphQLArgs { - schema: GraphQLSchema; - source: string | Source; - rootValue?: unknown; - contextValue?: unknown; - variableValues?: Maybe<{ readonly [variable: string]: unknown }>; - operationName?: Maybe; - fieldResolver?: Maybe>; - typeResolver?: Maybe>; -} - -export function graphql(args: GraphQLArgs): Promise { - // Always return a Promise for a consistent API. - return new Promise((resolve) => resolve(graphqlImpl(args))); -} - -/** - * The graphqlSync function also fulfills GraphQL operations by parsing, - * validating, and executing a GraphQL document along side a GraphQL schema. - * However, it guarantees to complete synchronously (or throw an error) assuming - * that all field resolvers are also synchronous. - */ -export function graphqlSync(args: GraphQLArgs): ExecutionResult { - const result = graphqlImpl(args); - - // Assert that the execution was synchronous. - if (isPromise(result)) { - throw new Error('GraphQL execution failed to complete synchronously.'); - } - - return result; -} - -function graphqlImpl(args: GraphQLArgs): PromiseOrValue { - // Temporary for v15 to v16 migration. Remove in v17 - devAssert( - arguments.length < 2, - 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', - ); - - const { - schema, - source, - rootValue, - contextValue, - variableValues, - operationName, - fieldResolver, - typeResolver, - } = args; - - // Validate Schema - const schemaValidationErrors = validateSchema(schema); - if (schemaValidationErrors.length > 0) { - return { errors: schemaValidationErrors }; - } - - // Parse - let document; - try { - document = parse(source); - } catch (syntaxError) { - return { errors: [syntaxError] }; - } - - // Validate - const validationErrors = validate(schema, document); - if (validationErrors.length > 0) { - return { errors: validationErrors }; - } - - // Execute - return execute({ - schema, - document, - rootValue, - contextValue, - variableValues, - operationName, - fieldResolver, - typeResolver, - }); -} diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 73c713a203..0000000000 --- a/src/index.ts +++ /dev/null @@ -1,492 +0,0 @@ -/** - * GraphQL.js provides a reference implementation for the GraphQL specification - * but is also a useful utility for operating on GraphQL files and building - * sophisticated tools. - * - * This primary module exports a general purpose function for fulfilling all - * steps of the GraphQL specification in a single operation, but also includes - * utilities for every part of the GraphQL specification: - * - * - Parsing the GraphQL language. - * - Building a GraphQL type schema. - * - Validating a GraphQL request against a type schema. - * - Executing a GraphQL request against a type schema. - * - * This also includes utility functions for operating on GraphQL types and - * GraphQL documents to facilitate building tools. - * - * You may also import from each sub-directory directly. For example, the - * following two import statements are equivalent: - * - * ```ts - * import { parse } from 'graphql'; - * import { parse } from 'graphql/language'; - * ``` - * - * @packageDocumentation - */ - -// The GraphQL.js version info. -export { version, versionInfo } from './version'; - -// The primary entry point into fulfilling a GraphQL request. -export type { GraphQLArgs } from './graphql'; -export { graphql, graphqlSync } from './graphql'; - -// Create and operate on GraphQL type definitions and schema. -export { - resolveObjMapThunk, - resolveReadonlyArrayThunk, - // Definitions - GraphQLSchema, - GraphQLDirective, - GraphQLScalarType, - GraphQLObjectType, - GraphQLInterfaceType, - GraphQLUnionType, - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLList, - GraphQLNonNull, - // Standard GraphQL Scalars - specifiedScalarTypes, - GraphQLInt, - GraphQLFloat, - GraphQLString, - GraphQLBoolean, - GraphQLID, - // Int boundaries constants - GRAPHQL_MAX_INT, - GRAPHQL_MIN_INT, - // Built-in Directives defined by the Spec - specifiedDirectives, - GraphQLIncludeDirective, - GraphQLSkipDirective, - GraphQLDeprecatedDirective, - GraphQLSpecifiedByDirective, - GraphQLOneOfDirective, - // "Enum" of Type Kinds - TypeKind, - // Constant Deprecation Reason - DEFAULT_DEPRECATION_REASON, - // GraphQL Types for introspection. - introspectionTypes, - __Schema, - __Directive, - __DirectiveLocation, - __Type, - __Field, - __InputValue, - __EnumValue, - __TypeKind, - // Meta-field definitions. - SchemaMetaFieldDef, - TypeMetaFieldDef, - TypeNameMetaFieldDef, - // Predicates - isSchema, - isDirective, - isType, - isScalarType, - isObjectType, - isInterfaceType, - isUnionType, - isEnumType, - isInputObjectType, - isListType, - isNonNullType, - isInputType, - isOutputType, - isLeafType, - isCompositeType, - isAbstractType, - isWrappingType, - isNullableType, - isNamedType, - isRequiredArgument, - isRequiredInputField, - isSpecifiedScalarType, - isIntrospectionType, - isSpecifiedDirective, - // Assertions - assertSchema, - assertDirective, - assertType, - assertScalarType, - assertObjectType, - assertInterfaceType, - assertUnionType, - assertEnumType, - assertInputObjectType, - assertListType, - assertNonNullType, - assertInputType, - assertOutputType, - assertLeafType, - assertCompositeType, - assertAbstractType, - assertWrappingType, - assertNullableType, - assertNamedType, - // Un-modifiers - getNullableType, - getNamedType, - // Validate GraphQL schema. - validateSchema, - assertValidSchema, - // Upholds the spec rules about naming. - assertName, - assertEnumValueName, -} from './type/index'; - -export type { - GraphQLType, - GraphQLInputType, - GraphQLOutputType, - GraphQLLeafType, - GraphQLCompositeType, - GraphQLAbstractType, - GraphQLWrappingType, - GraphQLNullableType, - GraphQLNamedType, - GraphQLNamedInputType, - GraphQLNamedOutputType, - ThunkReadonlyArray, - ThunkObjMap, - GraphQLSchemaConfig, - GraphQLSchemaExtensions, - GraphQLDirectiveConfig, - GraphQLDirectiveExtensions, - GraphQLArgument, - GraphQLArgumentConfig, - GraphQLArgumentExtensions, - GraphQLEnumTypeConfig, - GraphQLEnumTypeExtensions, - GraphQLEnumValue, - GraphQLEnumValueConfig, - GraphQLEnumValueConfigMap, - GraphQLEnumValueExtensions, - GraphQLField, - GraphQLFieldConfig, - GraphQLFieldConfigArgumentMap, - GraphQLFieldConfigMap, - GraphQLFieldExtensions, - GraphQLFieldMap, - GraphQLFieldResolver, - GraphQLInputField, - GraphQLInputFieldConfig, - GraphQLInputFieldConfigMap, - GraphQLInputFieldExtensions, - GraphQLInputFieldMap, - GraphQLInputObjectTypeConfig, - GraphQLInputObjectTypeExtensions, - GraphQLInterfaceTypeConfig, - GraphQLInterfaceTypeExtensions, - GraphQLIsTypeOfFn, - GraphQLObjectTypeConfig, - GraphQLObjectTypeExtensions, - GraphQLResolveInfo, - ResponsePath, - GraphQLScalarTypeConfig, - GraphQLScalarTypeExtensions, - GraphQLTypeResolver, - GraphQLUnionTypeConfig, - GraphQLUnionTypeExtensions, - GraphQLScalarSerializer, - GraphQLScalarValueParser, - GraphQLScalarLiteralParser, -} from './type/index'; - -// Parse and operate on GraphQL language source files. -export { - Token, - Source, - Location, - OperationTypeNode, - getLocation, - // Print source location. - printLocation, - printSourceLocation, - // Lex - Lexer, - TokenKind, - // Parse - parse, - parseValue, - parseConstValue, - parseType, - // Print - print, - // Visit - visit, - visitInParallel, - getVisitFn, - getEnterLeaveForKind, - BREAK, - Kind, - DirectiveLocation, - // Predicates - isDefinitionNode, - isExecutableDefinitionNode, - isSelectionNode, - isValueNode, - isConstValueNode, - isTypeNode, - isTypeSystemDefinitionNode, - isTypeDefinitionNode, - isTypeSystemExtensionNode, - isTypeExtensionNode, -} from './language/index'; - -export type { - ParseOptions, - SourceLocation, - TokenKindEnum, - KindEnum, - DirectiveLocationEnum, - // Visitor utilities - ASTVisitor, - ASTVisitFn, - ASTVisitorKeyMap, - // AST nodes - ASTNode, - ASTKindToNode, - // Each kind of AST node - NameNode, - DocumentNode, - DefinitionNode, - ExecutableDefinitionNode, - OperationDefinitionNode, - VariableDefinitionNode, - VariableNode, - SelectionSetNode, - SelectionNode, - FieldNode, - ArgumentNode, - ConstArgumentNode, - FragmentSpreadNode, - InlineFragmentNode, - FragmentDefinitionNode, - ValueNode, - ConstValueNode, - IntValueNode, - FloatValueNode, - StringValueNode, - BooleanValueNode, - NullValueNode, - EnumValueNode, - ListValueNode, - ConstListValueNode, - ObjectValueNode, - ConstObjectValueNode, - ObjectFieldNode, - ConstObjectFieldNode, - DirectiveNode, - ConstDirectiveNode, - TypeNode, - NamedTypeNode, - ListTypeNode, - NonNullTypeNode, - TypeSystemDefinitionNode, - SchemaDefinitionNode, - OperationTypeDefinitionNode, - TypeDefinitionNode, - ScalarTypeDefinitionNode, - ObjectTypeDefinitionNode, - FieldDefinitionNode, - InputValueDefinitionNode, - InterfaceTypeDefinitionNode, - UnionTypeDefinitionNode, - EnumTypeDefinitionNode, - EnumValueDefinitionNode, - InputObjectTypeDefinitionNode, - DirectiveDefinitionNode, - TypeSystemExtensionNode, - SchemaExtensionNode, - TypeExtensionNode, - ScalarTypeExtensionNode, - ObjectTypeExtensionNode, - InterfaceTypeExtensionNode, - UnionTypeExtensionNode, - EnumTypeExtensionNode, - InputObjectTypeExtensionNode, -} from './language/index'; - -// Execute GraphQL queries. -export { - execute, - executeSync, - defaultFieldResolver, - defaultTypeResolver, - responsePathAsArray, - getArgumentValues, - getVariableValues, - getDirectiveValues, - subscribe, - createSourceEventStream, -} from './execution/index'; - -export type { - ExecutionArgs, - ExecutionResult, - FormattedExecutionResult, -} from './execution/index'; - -export type { SubscriptionArgs } from './subscription/index'; - -// Validate GraphQL documents. -export { - validate, - ValidationContext, - // All validation rules in the GraphQL Specification. - specifiedRules, - recommendedRules, - // Individual validation rules. - ExecutableDefinitionsRule, - FieldsOnCorrectTypeRule, - FragmentsOnCompositeTypesRule, - KnownArgumentNamesRule, - KnownDirectivesRule, - KnownFragmentNamesRule, - KnownTypeNamesRule, - LoneAnonymousOperationRule, - NoFragmentCyclesRule, - NoUndefinedVariablesRule, - NoUnusedFragmentsRule, - NoUnusedVariablesRule, - OverlappingFieldsCanBeMergedRule, - PossibleFragmentSpreadsRule, - ProvidedRequiredArgumentsRule, - ScalarLeafsRule, - SingleFieldSubscriptionsRule, - UniqueArgumentNamesRule, - UniqueDirectivesPerLocationRule, - UniqueFragmentNamesRule, - UniqueInputFieldNamesRule, - UniqueOperationNamesRule, - UniqueVariableNamesRule, - ValuesOfCorrectTypeRule, - VariablesAreInputTypesRule, - VariablesInAllowedPositionRule, - MaxIntrospectionDepthRule, - // SDL-specific validation rules - LoneSchemaDefinitionRule, - UniqueOperationTypesRule, - UniqueTypeNamesRule, - UniqueEnumValueNamesRule, - UniqueFieldDefinitionNamesRule, - UniqueArgumentDefinitionNamesRule, - UniqueDirectiveNamesRule, - PossibleTypeExtensionsRule, - // Custom validation rules - NoDeprecatedCustomRule, - NoSchemaIntrospectionCustomRule, -} from './validation/index'; - -export type { ValidationRule } from './validation/index'; - -// Create, format, and print GraphQL errors. -export { - GraphQLError, - syntaxError, - locatedError, - printError, - formatError, -} from './error/index'; - -export type { - GraphQLErrorOptions, - GraphQLFormattedError, - GraphQLErrorExtensions, - GraphQLFormattedErrorExtensions, -} from './error/index'; - -// Utilities for operating on GraphQL type schema and parsed sources. -export { - // Produce the GraphQL query recommended for a full schema introspection. - // Accepts optional IntrospectionOptions. - getIntrospectionQuery, - // Gets the target Operation from a Document. - getOperationAST, - // Gets the Type for the target Operation AST. - getOperationRootType, - // Convert a GraphQLSchema to an IntrospectionQuery. - introspectionFromSchema, - // Build a GraphQLSchema from an introspection result. - buildClientSchema, - // Build a GraphQLSchema from a parsed GraphQL Schema language AST. - buildASTSchema, - // Build a GraphQLSchema from a GraphQL schema language document. - buildSchema, - // Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. - extendSchema, - // Sort a GraphQLSchema. - lexicographicSortSchema, - // Print a GraphQLSchema to GraphQL Schema language. - printSchema, - // Print a GraphQLType to GraphQL Schema language. - printType, - // Prints the built-in introspection schema in the Schema Language format. - printIntrospectionSchema, - // Create a GraphQLType from a GraphQL language AST. - typeFromAST, - // Create a JavaScript value from a GraphQL language AST with a Type. - valueFromAST, - // Create a JavaScript value from a GraphQL language AST without a Type. - valueFromASTUntyped, - // Create a GraphQL language AST from a JavaScript value. - astFromValue, - // A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. - TypeInfo, - visitWithTypeInfo, - // Coerces a JavaScript value to a GraphQL type, or produces errors. - coerceInputValue, - // Concatenates multiple AST together. - concatAST, - // Separates an AST into an AST per Operation. - separateOperations, - // Strips characters that are not significant to the validity or execution of a GraphQL document. - stripIgnoredCharacters, - // Comparators for types - isEqualType, - isTypeSubTypeOf, - doTypesOverlap, - // Asserts a string is a valid GraphQL name. - assertValidName, - // Determine if a string is a valid GraphQL name. - isValidNameError, - // Compares two GraphQLSchemas and detects breaking changes. - BreakingChangeType, - DangerousChangeType, - findBreakingChanges, - findDangerousChanges, -} from './utilities/index'; - -export type { - IntrospectionOptions, - IntrospectionQuery, - IntrospectionSchema, - IntrospectionType, - IntrospectionInputType, - IntrospectionOutputType, - IntrospectionScalarType, - IntrospectionObjectType, - IntrospectionInterfaceType, - IntrospectionUnionType, - IntrospectionEnumType, - IntrospectionInputObjectType, - IntrospectionTypeRef, - IntrospectionInputTypeRef, - IntrospectionOutputTypeRef, - IntrospectionNamedTypeRef, - IntrospectionListTypeRef, - IntrospectionNonNullTypeRef, - IntrospectionField, - IntrospectionInputValue, - IntrospectionEnumValue, - IntrospectionDirective, - BuildSchemaOptions, - BreakingChange, - DangerousChange, - TypedQueryDocumentNode, -} from './utilities/index'; diff --git a/src/jsutils/ObjMap.ts b/src/jsutils/ObjMap.ts deleted file mode 100644 index 2c20282187..0000000000 --- a/src/jsutils/ObjMap.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface ObjMap { - [key: string]: T; -} - -export type ObjMapLike = ObjMap | { [key: string]: T }; - -export interface ReadOnlyObjMap { - readonly [key: string]: T; -} - -export type ReadOnlyObjMapLike = - | ReadOnlyObjMap - | { readonly [key: string]: T }; diff --git a/src/jsutils/Path.ts b/src/jsutils/Path.ts deleted file mode 100644 index 64f6c78358..0000000000 --- a/src/jsutils/Path.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Maybe } from './Maybe'; - -export interface Path { - readonly prev: Path | undefined; - readonly key: string | number; - readonly typename: string | undefined; -} - -/** - * Given a Path and a key, return a new Path containing the new key. - */ -export function addPath( - prev: Readonly | undefined, - key: string | number, - typename: string | undefined, -): Path { - return { prev, key, typename }; -} - -/** - * Given a Path, return an Array of the path keys. - */ -export function pathToArray( - path: Maybe>, -): Array { - const flattened = []; - let curr = path; - while (curr) { - flattened.push(curr.key); - curr = curr.prev; - } - return flattened.reverse(); -} diff --git a/src/jsutils/README.md b/src/jsutils/README.md deleted file mode 100644 index 9eb96485e1..0000000000 --- a/src/jsutils/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## JavaScript Utils - -This directory contains dependency-free JavaScript utility functions used -throughout the codebase. - -Each utility should belong in its own file and be the default export. - -These functions are not part of the module interface and are subject to change. diff --git a/src/jsutils/__tests__/Path-test.ts b/src/jsutils/__tests__/Path-test.ts deleted file mode 100644 index 43bca192c0..0000000000 --- a/src/jsutils/__tests__/Path-test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { addPath, pathToArray } from '../Path'; - -describe('Path', () => { - it('can create a Path', () => { - const first = addPath(undefined, 1, 'First'); - - expect(first).to.deep.equal({ - prev: undefined, - key: 1, - typename: 'First', - }); - }); - - it('can add a new key to an existing Path', () => { - const first = addPath(undefined, 1, 'First'); - const second = addPath(first, 'two', 'Second'); - - expect(second).to.deep.equal({ - prev: first, - key: 'two', - typename: 'Second', - }); - }); - - it('can convert a Path to an array of its keys', () => { - const root = addPath(undefined, 0, 'Root'); - const first = addPath(root, 'one', 'First'); - const second = addPath(first, 2, 'Second'); - - const path = pathToArray(second); - expect(path).to.deep.equal([0, 'one', 2]); - }); -}); diff --git a/src/jsutils/__tests__/didYouMean-test.ts b/src/jsutils/__tests__/didYouMean-test.ts deleted file mode 100644 index bc01e18080..0000000000 --- a/src/jsutils/__tests__/didYouMean-test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { didYouMean } from '../didYouMean'; - -describe('didYouMean', () => { - it('Does accept an empty list', () => { - expect(didYouMean([])).to.equal(''); - }); - - it('Handles single suggestion', () => { - expect(didYouMean(['A'])).to.equal(' Did you mean "A"?'); - }); - - it('Handles two suggestions', () => { - expect(didYouMean(['A', 'B'])).to.equal(' Did you mean "A" or "B"?'); - }); - - it('Handles multiple suggestions', () => { - expect(didYouMean(['A', 'B', 'C'])).to.equal( - ' Did you mean "A", "B", or "C"?', - ); - }); - - it('Limits to five suggestions', () => { - expect(didYouMean(['A', 'B', 'C', 'D', 'E', 'F'])).to.equal( - ' Did you mean "A", "B", "C", "D", or "E"?', - ); - }); - - it('Adds sub-message', () => { - expect(didYouMean('the letter', ['A'])).to.equal( - ' Did you mean the letter "A"?', - ); - }); -}); diff --git a/src/jsutils/__tests__/identityFunc-test.ts b/src/jsutils/__tests__/identityFunc-test.ts deleted file mode 100644 index 97cc25eb2f..0000000000 --- a/src/jsutils/__tests__/identityFunc-test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { identityFunc } from '../identityFunc'; - -describe('identityFunc', () => { - it('returns the first argument it receives', () => { - // @ts-expect-error (Expects an argument) - expect(identityFunc()).to.equal(undefined); - expect(identityFunc(undefined)).to.equal(undefined); - expect(identityFunc(null)).to.equal(null); - - const obj = {}; - expect(identityFunc(obj)).to.equal(obj); - }); -}); diff --git a/src/jsutils/__tests__/inspect-test.ts b/src/jsutils/__tests__/inspect-test.ts deleted file mode 100644 index d1ac17313a..0000000000 --- a/src/jsutils/__tests__/inspect-test.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { inspect } from '../inspect'; - -describe('inspect', () => { - it('undefined', () => { - expect(inspect(undefined)).to.equal('undefined'); - }); - - it('null', () => { - expect(inspect(null)).to.equal('null'); - }); - - it('boolean', () => { - expect(inspect(true)).to.equal('true'); - expect(inspect(false)).to.equal('false'); - }); - - it('string', () => { - expect(inspect('')).to.equal('""'); - expect(inspect('abc')).to.equal('"abc"'); - expect(inspect('"')).to.equal('"\\""'); - }); - - it('number', () => { - expect(inspect(0.0)).to.equal('0'); - expect(inspect(3.14)).to.equal('3.14'); - expect(inspect(NaN)).to.equal('NaN'); - expect(inspect(Infinity)).to.equal('Infinity'); - expect(inspect(-Infinity)).to.equal('-Infinity'); - }); - - it('function', () => { - const unnamedFuncStr = inspect( - // Never called and used as a placeholder - /* c8 ignore next */ - () => expect.fail('Should not be called'), - ); - expect(unnamedFuncStr).to.equal('[function]'); - - // Never called and used as a placeholder - /* c8 ignore next 3 */ - function namedFunc() { - expect.fail('Should not be called'); - } - expect(inspect(namedFunc)).to.equal('[function namedFunc]'); - }); - - it('array', () => { - expect(inspect([])).to.equal('[]'); - expect(inspect([null])).to.equal('[null]'); - expect(inspect([1, NaN])).to.equal('[1, NaN]'); - expect(inspect([['a', 'b'], 'c'])).to.equal('[["a", "b"], "c"]'); - - expect(inspect([[[]]])).to.equal('[[[]]]'); - expect(inspect([[['a']]])).to.equal('[[[Array]]]'); - - expect(inspect([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])).to.equal( - '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', - ); - - expect(inspect([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])).to.equal( - '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... 1 more item]', - ); - - expect(inspect([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])).to.equal( - '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... 2 more items]', - ); - }); - - it('object', () => { - expect(inspect({})).to.equal('{}'); - expect(inspect({ a: 1 })).to.equal('{ a: 1 }'); - expect(inspect({ a: 1, b: 2 })).to.equal('{ a: 1, b: 2 }'); - expect(inspect({ array: [null, 0] })).to.equal('{ array: [null, 0] }'); - - expect(inspect({ a: { b: {} } })).to.equal('{ a: { b: {} } }'); - expect(inspect({ a: { b: { c: 1 } } })).to.equal('{ a: { b: [Object] } }'); - - const map = Object.create(null); - map.a = true; - map.b = null; - expect(inspect(map)).to.equal('{ a: true, b: null }'); - }); - - it('use toJSON if provided', () => { - const object = { - toJSON() { - return ''; - }, - }; - - expect(inspect(object)).to.equal(''); - }); - - it('handles toJSON that return `this` should work', () => { - const object = { - toJSON() { - return this; - }, - }; - - expect(inspect(object)).to.equal('{ toJSON: [function toJSON] }'); - }); - - it('handles toJSON returning object values', () => { - const object = { - toJSON() { - return { json: 'value' }; - }, - }; - - expect(inspect(object)).to.equal('{ json: "value" }'); - }); - - it('handles toJSON function that uses this', () => { - const object = { - str: 'Hello World!', - toJSON() { - return this.str; - }, - }; - - expect(inspect(object)).to.equal('Hello World!'); - }); - - it('detect circular objects', () => { - const obj: { [name: string]: unknown } = {}; - obj.self = obj; - obj.deepSelf = { self: obj }; - - expect(inspect(obj)).to.equal( - '{ self: [Circular], deepSelf: { self: [Circular] } }', - ); - - const array: any = []; - array[0] = array; - array[1] = [array]; - - expect(inspect(array)).to.equal('[[Circular], [[Circular]]]'); - - const mixed: any = { array: [] }; - mixed.array[0] = mixed; - - expect(inspect(mixed)).to.equal('{ array: [[Circular]] }'); - - const customA = { - toJSON: () => customB, - }; - - const customB = { - toJSON: () => customA, - }; - - expect(inspect(customA)).to.equal('[Circular]'); - }); - - it('Use class names for the short form of an object', () => { - class Foo { - foo: string; - - constructor() { - this.foo = 'bar'; - } - } - - expect(inspect([[new Foo()]])).to.equal('[[[Foo]]]'); - - class Foo2 { - foo: string; - - [Symbol.toStringTag] = 'Bar'; - - constructor() { - this.foo = 'bar'; - } - } - expect(inspect([[new Foo2()]])).to.equal('[[[Bar]]]'); - - // eslint-disable-next-line func-names - const objectWithoutClassName = new (function (this: any) { - this.foo = 1; - } as any)(); - expect(inspect([[objectWithoutClassName]])).to.equal('[[[Object]]]'); - }); -}); diff --git a/src/jsutils/__tests__/instanceOf-test.ts b/src/jsutils/__tests__/instanceOf-test.ts deleted file mode 100644 index cbd649bfa8..0000000000 --- a/src/jsutils/__tests__/instanceOf-test.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { instanceOf } from '../instanceOf'; - -describe('instanceOf', () => { - it('do not throw on values without prototype', () => { - class Foo { - get [Symbol.toStringTag]() { - return 'Foo'; - } - } - - expect(instanceOf(true, Foo)).to.equal(false); - expect(instanceOf(null, Foo)).to.equal(false); - expect(instanceOf(Object.create(null), Foo)).to.equal(false); - }); - - it('detect name clashes with older versions of this lib', () => { - function oldVersion() { - class Foo {} - return Foo; - } - - function newVersion() { - class Foo { - get [Symbol.toStringTag]() { - return 'Foo'; - } - } - return Foo; - } - - const NewClass = newVersion(); - const OldClass = oldVersion(); - expect(instanceOf(new NewClass(), NewClass)).to.equal(true); - expect(() => instanceOf(new OldClass(), NewClass)).to.throw(); - }); - - it('allows instances to have share the same constructor name', () => { - function getMinifiedClass(tag: string) { - class SomeNameAfterMinification { - get [Symbol.toStringTag]() { - return tag; - } - } - return SomeNameAfterMinification; - } - - const Foo = getMinifiedClass('Foo'); - const Bar = getMinifiedClass('Bar'); - expect(instanceOf(new Foo(), Bar)).to.equal(false); - expect(instanceOf(new Bar(), Foo)).to.equal(false); - - const DuplicateOfFoo = getMinifiedClass('Foo'); - expect(() => instanceOf(new DuplicateOfFoo(), Foo)).to.throw(); - expect(() => instanceOf(new Foo(), DuplicateOfFoo)).to.throw(); - }); - - it('fails with descriptive error message', () => { - function getFoo() { - class Foo { - get [Symbol.toStringTag]() { - return 'Foo'; - } - } - return Foo; - } - const Foo1 = getFoo(); - const Foo2 = getFoo(); - - expect(() => instanceOf(new Foo1(), Foo2)).to.throw( - /^Cannot use Foo "{}" from another module or realm./m, - ); - expect(() => instanceOf(new Foo2(), Foo1)).to.throw( - /^Cannot use Foo "{}" from another module or realm./m, - ); - }); -}); diff --git a/src/jsutils/__tests__/invariant-test.ts b/src/jsutils/__tests__/invariant-test.ts deleted file mode 100644 index 2a438b69b3..0000000000 --- a/src/jsutils/__tests__/invariant-test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { invariant } from '../invariant'; - -describe('invariant', () => { - it('throws on false conditions', () => { - expect(() => invariant(false, 'Oops!')).to.throw('Oops!'); - }); - - it('use default error message', () => { - expect(() => invariant(false)).to.throw('Unexpected invariant triggered.'); - }); -}); diff --git a/src/jsutils/__tests__/isAsyncIterable-test.ts b/src/jsutils/__tests__/isAsyncIterable-test.ts deleted file mode 100644 index e62bb53433..0000000000 --- a/src/jsutils/__tests__/isAsyncIterable-test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { identityFunc } from '../identityFunc'; -import { isAsyncIterable } from '../isAsyncIterable'; - -describe('isAsyncIterable', () => { - it('should return `true` for AsyncIterable', () => { - const asyncIterable = { [Symbol.asyncIterator]: identityFunc }; - expect(isAsyncIterable(asyncIterable)).to.equal(true); - - async function* asyncGeneratorFunc() { - /* do nothing */ - } - - expect(isAsyncIterable(asyncGeneratorFunc())).to.equal(true); - - // But async generator function itself is not iterable - expect(isAsyncIterable(asyncGeneratorFunc)).to.equal(false); - }); - - it('should return `false` for all other values', () => { - expect(isAsyncIterable(null)).to.equal(false); - expect(isAsyncIterable(undefined)).to.equal(false); - - expect(isAsyncIterable('ABC')).to.equal(false); - expect(isAsyncIterable('0')).to.equal(false); - expect(isAsyncIterable('')).to.equal(false); - - expect(isAsyncIterable([])).to.equal(false); - expect(isAsyncIterable(new Int8Array(1))).to.equal(false); - - expect(isAsyncIterable({})).to.equal(false); - expect(isAsyncIterable({ iterable: true })).to.equal(false); - - const asyncIteratorWithoutSymbol = { next: identityFunc }; - expect(isAsyncIterable(asyncIteratorWithoutSymbol)).to.equal(false); - - const nonAsyncIterable = { [Symbol.iterator]: identityFunc }; - expect(isAsyncIterable(nonAsyncIterable)).to.equal(false); - - function* generatorFunc() { - /* do nothing */ - } - expect(isAsyncIterable(generatorFunc())).to.equal(false); - - const invalidAsyncIterable = { - [Symbol.asyncIterator]: { next: identityFunc }, - }; - expect(isAsyncIterable(invalidAsyncIterable)).to.equal(false); - }); -}); diff --git a/src/jsutils/__tests__/isIterableObject-test.ts b/src/jsutils/__tests__/isIterableObject-test.ts deleted file mode 100644 index c631cb4b80..0000000000 --- a/src/jsutils/__tests__/isIterableObject-test.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { identityFunc } from '../identityFunc'; -import { isIterableObject } from '../isIterableObject'; - -describe('isIterableObject', () => { - it('should return `true` for collections', () => { - expect(isIterableObject([])).to.equal(true); - expect(isIterableObject(new Int8Array(1))).to.equal(true); - - // eslint-disable-next-line no-new-wrappers - expect(isIterableObject(new String('ABC'))).to.equal(true); - - function getArguments() { - return arguments; - } - expect(isIterableObject(getArguments())).to.equal(true); - - const iterable = { [Symbol.iterator]: identityFunc }; - expect(isIterableObject(iterable)).to.equal(true); - - function* generatorFunc() { - /* do nothing */ - } - expect(isIterableObject(generatorFunc())).to.equal(true); - - // But generator function itself is not iterable - expect(isIterableObject(generatorFunc)).to.equal(false); - }); - - it('should return `false` for non-collections', () => { - expect(isIterableObject(null)).to.equal(false); - expect(isIterableObject(undefined)).to.equal(false); - - expect(isIterableObject('ABC')).to.equal(false); - expect(isIterableObject('0')).to.equal(false); - expect(isIterableObject('')).to.equal(false); - - expect(isIterableObject(1)).to.equal(false); - expect(isIterableObject(0)).to.equal(false); - expect(isIterableObject(NaN)).to.equal(false); - // eslint-disable-next-line no-new-wrappers - expect(isIterableObject(new Number(123))).to.equal(false); - - expect(isIterableObject(true)).to.equal(false); - expect(isIterableObject(false)).to.equal(false); - // eslint-disable-next-line no-new-wrappers - expect(isIterableObject(new Boolean(true))).to.equal(false); - - expect(isIterableObject({})).to.equal(false); - expect(isIterableObject({ iterable: true })).to.equal(false); - - const iteratorWithoutSymbol = { next: identityFunc }; - expect(isIterableObject(iteratorWithoutSymbol)).to.equal(false); - - const invalidIterable = { - [Symbol.iterator]: { next: identityFunc }, - }; - expect(isIterableObject(invalidIterable)).to.equal(false); - - const arrayLike: { [key: string]: unknown } = {}; - arrayLike[0] = 'Alpha'; - arrayLike[1] = 'Bravo'; - arrayLike[2] = 'Charlie'; - arrayLike.length = 3; - - expect(isIterableObject(arrayLike)).to.equal(false); - }); -}); diff --git a/src/jsutils/__tests__/isObjectLike-test.ts b/src/jsutils/__tests__/isObjectLike-test.ts deleted file mode 100644 index 536ecb5f88..0000000000 --- a/src/jsutils/__tests__/isObjectLike-test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { identityFunc } from '../identityFunc'; -import { isObjectLike } from '../isObjectLike'; - -describe('isObjectLike', () => { - it('should return `true` for objects', () => { - expect(isObjectLike({})).to.equal(true); - expect(isObjectLike(Object.create(null))).to.equal(true); - expect(isObjectLike(/a/)).to.equal(true); - expect(isObjectLike([])).to.equal(true); - }); - - it('should return `false` for non-objects', () => { - expect(isObjectLike(undefined)).to.equal(false); - expect(isObjectLike(null)).to.equal(false); - expect(isObjectLike(true)).to.equal(false); - expect(isObjectLike('')).to.equal(false); - expect(isObjectLike(identityFunc)).to.equal(false); - }); -}); diff --git a/src/jsutils/__tests__/naturalCompare-test.ts b/src/jsutils/__tests__/naturalCompare-test.ts deleted file mode 100644 index 4c5291e579..0000000000 --- a/src/jsutils/__tests__/naturalCompare-test.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { naturalCompare } from '../naturalCompare'; - -describe('naturalCompare', () => { - it('Handles empty strings', () => { - expect(naturalCompare('', '')).to.equal(0); - - expect(naturalCompare('', 'a')).to.equal(-1); - expect(naturalCompare('', '1')).to.equal(-1); - - expect(naturalCompare('a', '')).to.equal(1); - expect(naturalCompare('1', '')).to.equal(1); - }); - - it('Handles strings of different length', () => { - expect(naturalCompare('A', 'A')).to.equal(0); - expect(naturalCompare('A1', 'A1')).to.equal(0); - - expect(naturalCompare('A', 'AA')).to.equal(-1); - expect(naturalCompare('A1', 'A1A')).to.equal(-1); - - expect(naturalCompare('AA', 'A')).to.equal(1); - expect(naturalCompare('A1A', 'A1')).to.equal(1); - }); - - it('Handles numbers', () => { - expect(naturalCompare('0', '0')).to.equal(0); - expect(naturalCompare('1', '1')).to.equal(0); - - expect(naturalCompare('1', '2')).to.equal(-1); - expect(naturalCompare('2', '1')).to.equal(1); - - expect(naturalCompare('2', '11')).to.equal(-1); - expect(naturalCompare('11', '2')).to.equal(1); - }); - - it('Handles numbers with leading zeros', () => { - expect(naturalCompare('00', '00')).to.equal(0); - expect(naturalCompare('0', '00')).to.equal(-1); - expect(naturalCompare('00', '0')).to.equal(1); - - expect(naturalCompare('02', '11')).to.equal(-1); - expect(naturalCompare('11', '02')).to.equal(1); - - expect(naturalCompare('011', '200')).to.equal(-1); - expect(naturalCompare('200', '011')).to.equal(1); - }); - - it('Handles numbers embedded into names', () => { - expect(naturalCompare('a0a', 'a0a')).to.equal(0); - expect(naturalCompare('a0a', 'a9a')).to.equal(-1); - expect(naturalCompare('a9a', 'a0a')).to.equal(1); - - expect(naturalCompare('a00a', 'a00a')).to.equal(0); - expect(naturalCompare('a00a', 'a09a')).to.equal(-1); - expect(naturalCompare('a09a', 'a00a')).to.equal(1); - - expect(naturalCompare('a0a1', 'a0a1')).to.equal(0); - expect(naturalCompare('a0a1', 'a0a9')).to.equal(-1); - expect(naturalCompare('a0a9', 'a0a1')).to.equal(1); - - expect(naturalCompare('a10a11a', 'a10a11a')).to.equal(0); - expect(naturalCompare('a10a11a', 'a10a19a')).to.equal(-1); - expect(naturalCompare('a10a19a', 'a10a11a')).to.equal(1); - - expect(naturalCompare('a10a11a', 'a10a11a')).to.equal(0); - expect(naturalCompare('a10a11a', 'a10a11b')).to.equal(-1); - expect(naturalCompare('a10a11b', 'a10a11a')).to.equal(1); - }); -}); diff --git a/src/jsutils/__tests__/suggestionList-test.ts b/src/jsutils/__tests__/suggestionList-test.ts deleted file mode 100644 index 2b90524885..0000000000 --- a/src/jsutils/__tests__/suggestionList-test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { suggestionList } from '../suggestionList'; - -function expectSuggestions(input: string, options: ReadonlyArray) { - return expect(suggestionList(input, options)); -} - -describe('suggestionList', () => { - it('Returns results when input is empty', () => { - expectSuggestions('', ['a']).to.deep.equal(['a']); - }); - - it('Returns empty array when there are no options', () => { - expectSuggestions('input', []).to.deep.equal([]); - }); - - it('Returns options with small lexical distance', () => { - expectSuggestions('greenish', ['green']).to.deep.equal(['green']); - expectSuggestions('green', ['greenish']).to.deep.equal(['greenish']); - }); - - it('Rejects options with distance that exceeds threshold', () => { - // spell-checker:disable - expectSuggestions('aaaa', ['aaab']).to.deep.equal(['aaab']); - expectSuggestions('aaaa', ['aabb']).to.deep.equal(['aabb']); - expectSuggestions('aaaa', ['abbb']).to.deep.equal([]); - // spell-checker:enable - - expectSuggestions('ab', ['ca']).to.deep.equal([]); - }); - - it('Returns options with different case', () => { - // cSpell:ignore verylongstring - expectSuggestions('verylongstring', ['VERYLONGSTRING']).to.deep.equal([ - 'VERYLONGSTRING', - ]); - - expectSuggestions('VERYLONGSTRING', ['verylongstring']).to.deep.equal([ - 'verylongstring', - ]); - - expectSuggestions('VERYLONGSTRING', ['VeryLongString']).to.deep.equal([ - 'VeryLongString', - ]); - }); - - it('Returns options with transpositions', () => { - expectSuggestions('agr', ['arg']).to.deep.equal(['arg']); - expectSuggestions('214365879', ['123456789']).to.deep.equal(['123456789']); - }); - - it('Returns options sorted based on lexical distance', () => { - expectSuggestions('abc', ['a', 'ab', 'abc']).to.deep.equal([ - 'abc', - 'ab', - 'a', - ]); - }); - - it('Returns options with the same lexical distance sorted lexicographically', () => { - expectSuggestions('a', ['az', 'ax', 'ay']).to.deep.equal([ - 'ax', - 'ay', - 'az', - ]); - }); -}); diff --git a/src/jsutils/__tests__/toObjMap-test.ts b/src/jsutils/__tests__/toObjMap-test.ts deleted file mode 100644 index f9136b87b8..0000000000 --- a/src/jsutils/__tests__/toObjMap-test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import type { ObjMapLike } from '../ObjMap'; -import { toObjMap } from '../toObjMap'; - -// Workaround to make both ESLint happy -const __proto__ = '__proto__'; - -describe('toObjMap', () => { - it('convert undefined to ObjMap', () => { - const result = toObjMap(undefined); - expect(result).to.deep.equal({}); - expect(Object.getPrototypeOf(result)).to.equal(null); - }); - - it('convert null to ObjMap', () => { - const result = toObjMap(null); - expect(result).to.deep.equal({}); - expect(Object.getPrototypeOf(result)).to.equal(null); - }); - - it('convert empty object to ObjMap', () => { - const result = toObjMap({}); - expect(result).to.deep.equal({}); - expect(Object.getPrototypeOf(result)).to.equal(null); - }); - - it('convert object with own properties to ObjMap', () => { - const obj: ObjMapLike = Object.freeze({ foo: 'bar' }); - - const result = toObjMap(obj); - expect(result).to.deep.equal(obj); - expect(Object.getPrototypeOf(result)).to.equal(null); - }); - - it('convert object with __proto__ property to ObjMap', () => { - const protoObj = Object.freeze({ toString: false }); - const obj = Object.create(null); - obj[__proto__] = protoObj; - Object.freeze(obj); - - const result = toObjMap(obj); - expect(Object.keys(result)).to.deep.equal(['__proto__']); - expect(Object.getPrototypeOf(result)).to.equal(null); - expect(result[__proto__]).to.equal(protoObj); - }); - - it('passthrough empty ObjMap', () => { - const objMap = Object.create(null); - expect(toObjMap(objMap)).to.deep.equal(objMap); - }); - - it('passthrough ObjMap with properties', () => { - const objMap = Object.freeze({ - __proto__: null, - foo: 'bar', - }); - expect(toObjMap(objMap)).to.deep.equal(objMap); - }); -}); diff --git a/src/jsutils/devAssert.ts b/src/jsutils/devAssert.ts deleted file mode 100644 index ff97228b9f..0000000000 --- a/src/jsutils/devAssert.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function devAssert(condition: unknown, message: string): void { - const booleanCondition = Boolean(condition); - if (!booleanCondition) { - throw new Error(message); - } -} diff --git a/src/jsutils/didYouMean.ts b/src/jsutils/didYouMean.ts deleted file mode 100644 index 33e10a42c1..0000000000 --- a/src/jsutils/didYouMean.ts +++ /dev/null @@ -1,37 +0,0 @@ -const MAX_SUGGESTIONS = 5; - -/** - * Given [ A, B, C ] return ' Did you mean A, B, or C?'. - */ -export function didYouMean(suggestions: ReadonlyArray): string; -export function didYouMean( - subMessage: string, - suggestions: ReadonlyArray, -): string; -export function didYouMean( - firstArg: string | ReadonlyArray, - secondArg?: ReadonlyArray, -) { - const [subMessage, suggestionsArg] = secondArg - ? [firstArg as string, secondArg] - : [undefined, firstArg as ReadonlyArray]; - - let message = ' Did you mean '; - if (subMessage) { - message += subMessage + ' '; - } - - const suggestions = suggestionsArg.map((x) => `"${x}"`); - switch (suggestions.length) { - case 0: - return ''; - case 1: - return message + suggestions[0] + '?'; - case 2: - return message + suggestions[0] + ' or ' + suggestions[1] + '?'; - } - - const selected = suggestions.slice(0, MAX_SUGGESTIONS); - const lastItem = selected.pop(); - return message + selected.join(', ') + ', or ' + lastItem + '?'; -} diff --git a/src/jsutils/groupBy.ts b/src/jsutils/groupBy.ts deleted file mode 100644 index f3b0c076d1..0000000000 --- a/src/jsutils/groupBy.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Groups array items into a Map, given a function to produce grouping key. - */ -export function groupBy( - list: ReadonlyArray, - keyFn: (item: T) => K, -): Map> { - const result = new Map>(); - for (const item of list) { - const key = keyFn(item); - const group = result.get(key); - if (group === undefined) { - result.set(key, [item]); - } else { - group.push(item); - } - } - return result; -} diff --git a/src/jsutils/identityFunc.ts b/src/jsutils/identityFunc.ts deleted file mode 100644 index a249b51c34..0000000000 --- a/src/jsutils/identityFunc.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Returns the first argument it receives. - */ -export function identityFunc(x: T): T { - return x; -} diff --git a/src/jsutils/inspect.ts b/src/jsutils/inspect.ts deleted file mode 100644 index 514cbaad39..0000000000 --- a/src/jsutils/inspect.ts +++ /dev/null @@ -1,123 +0,0 @@ -const MAX_ARRAY_LENGTH = 10; -const MAX_RECURSIVE_DEPTH = 2; - -/** - * Used to print values in error messages. - */ -export function inspect(value: unknown): string { - return formatValue(value, []); -} - -function formatValue( - value: unknown, - seenValues: ReadonlyArray, -): string { - switch (typeof value) { - case 'string': - return JSON.stringify(value); - case 'function': - return value.name ? `[function ${value.name}]` : '[function]'; - case 'object': - return formatObjectValue(value, seenValues); - default: - return String(value); - } -} - -function formatObjectValue( - value: object | null, - previouslySeenValues: ReadonlyArray, -): string { - if (value === null) { - return 'null'; - } - - if (previouslySeenValues.includes(value)) { - return '[Circular]'; - } - - const seenValues = [...previouslySeenValues, value]; - - if (isJSONable(value)) { - const jsonValue = value.toJSON(); - - // check for infinite recursion - if (jsonValue !== value) { - return typeof jsonValue === 'string' - ? jsonValue - : formatValue(jsonValue, seenValues); - } - } else if (Array.isArray(value)) { - return formatArray(value, seenValues); - } - - return formatObject(value, seenValues); -} - -function isJSONable(value: any): value is { toJSON: () => unknown } { - return typeof value.toJSON === 'function'; -} - -function formatObject( - object: object, - seenValues: ReadonlyArray, -): string { - const entries = Object.entries(object); - if (entries.length === 0) { - return '{}'; - } - - if (seenValues.length > MAX_RECURSIVE_DEPTH) { - return '[' + getObjectTag(object) + ']'; - } - - const properties = entries.map( - ([key, value]) => key + ': ' + formatValue(value, seenValues), - ); - return '{ ' + properties.join(', ') + ' }'; -} - -function formatArray( - array: ReadonlyArray, - seenValues: ReadonlyArray, -): string { - if (array.length === 0) { - return '[]'; - } - - if (seenValues.length > MAX_RECURSIVE_DEPTH) { - return '[Array]'; - } - - const len = Math.min(MAX_ARRAY_LENGTH, array.length); - const remaining = array.length - len; - const items = []; - - for (let i = 0; i < len; ++i) { - items.push(formatValue(array[i], seenValues)); - } - - if (remaining === 1) { - items.push('... 1 more item'); - } else if (remaining > 1) { - items.push(`... ${remaining} more items`); - } - - return '[' + items.join(', ') + ']'; -} - -function getObjectTag(object: object): string { - const tag = Object.prototype.toString - .call(object) - .replace(/^\[object /, '') - .replace(/]$/, ''); - - if (tag === 'Object' && typeof object.constructor === 'function') { - const name = object.constructor.name; - if (typeof name === 'string' && name !== '') { - return name; - } - } - - return tag; -} diff --git a/src/jsutils/instanceOf.ts b/src/jsutils/instanceOf.ts deleted file mode 100644 index 27c4ab4d12..0000000000 --- a/src/jsutils/instanceOf.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { inspect } from './inspect'; - -/* c8 ignore next 3 */ -const isProduction = - globalThis.process && - // eslint-disable-next-line no-undef - process.env.NODE_ENV === 'production'; - -/** - * A replacement for instanceof which includes an error warning when multi-realm - * constructors are detected. - * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production - * See: https://webpack.js.org/guides/production/ - */ -export const instanceOf: (value: unknown, constructor: Constructor) => boolean = - /* c8 ignore next 6 */ - // FIXME: https://github.com/graphql/graphql-js/issues/2317 - isProduction - ? function instanceOf(value: unknown, constructor: Constructor): boolean { - return value instanceof constructor; - } - : function instanceOf(value: unknown, constructor: Constructor): boolean { - if (value instanceof constructor) { - return true; - } - if (typeof value === 'object' && value !== null) { - // Prefer Symbol.toStringTag since it is immune to minification. - const className = constructor.prototype[Symbol.toStringTag]; - const valueClassName = - // We still need to support constructor's name to detect conflicts with older versions of this library. - Symbol.toStringTag in value - ? // @ts-expect-error TS bug see, https://github.com/microsoft/TypeScript/issues/38009 - value[Symbol.toStringTag] - : value.constructor?.name; - if (className === valueClassName) { - const stringifiedValue = inspect(value); - throw new Error( - `Cannot use ${className} "${stringifiedValue}" from another module or realm. - -Ensure that there is only one instance of "graphql" in the node_modules -directory. If different versions of "graphql" are the dependencies of other -relied on modules, use "resolutions" to ensure only one version is installed. - -https://yarnpkg.com/en/docs/selective-version-resolutions - -Duplicate "graphql" modules cannot be used at the same time since different -versions may have different capabilities and behavior. The data from one -version used in the function from another could produce confusing and -spurious results.`, - ); - } - } - return false; - }; - -interface Constructor extends Function { - prototype: { - [Symbol.toStringTag]: string; - }; -} diff --git a/src/jsutils/invariant.ts b/src/jsutils/invariant.ts deleted file mode 100644 index f2c5d4c625..0000000000 --- a/src/jsutils/invariant.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function invariant( - condition: unknown, - message?: string, -): asserts condition { - const booleanCondition = Boolean(condition); - if (!booleanCondition) { - throw new Error( - message != null ? message : 'Unexpected invariant triggered.', - ); - } -} diff --git a/src/jsutils/isAsyncIterable.ts b/src/jsutils/isAsyncIterable.ts deleted file mode 100644 index 0eb4ab1d6e..0000000000 --- a/src/jsutils/isAsyncIterable.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Returns true if the provided object implements the AsyncIterator protocol via - * implementing a `Symbol.asyncIterator` method. - */ -export function isAsyncIterable( - maybeAsyncIterable: any, -): maybeAsyncIterable is AsyncIterable { - return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function'; -} diff --git a/src/jsutils/isIterableObject.ts b/src/jsutils/isIterableObject.ts deleted file mode 100644 index 5c9d6fb381..0000000000 --- a/src/jsutils/isIterableObject.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Returns true if the provided object is an Object (i.e. not a string literal) - * and implements the Iterator protocol. - * - * This may be used in place of [Array.isArray()][isArray] to determine if - * an object should be iterated-over e.g. Array, Map, Set, Int8Array, - * TypedArray, etc. but excludes string literals. - * - * @example - * ```ts - * isIterableObject([ 1, 2, 3 ]) // true - * isIterableObject(new Map()) // true - * isIterableObject('ABC') // false - * isIterableObject({ key: 'value' }) // false - * isIterableObject({ length: 1, 0: 'Alpha' }) // false - * ``` - */ -export function isIterableObject( - maybeIterable: any, -): maybeIterable is Iterable { - return ( - typeof maybeIterable === 'object' && - typeof maybeIterable?.[Symbol.iterator] === 'function' - ); -} diff --git a/src/jsutils/isObjectLike.ts b/src/jsutils/isObjectLike.ts deleted file mode 100644 index 1d43e26718..0000000000 --- a/src/jsutils/isObjectLike.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Return true if `value` is object-like. A value is object-like if it's not - * `null` and has a `typeof` result of "object". - */ -export function isObjectLike( - value: unknown, -): value is { [key: string]: unknown } { - return typeof value == 'object' && value !== null; -} diff --git a/src/jsutils/isPromise.ts b/src/jsutils/isPromise.ts deleted file mode 100644 index 5fc3c10458..0000000000 --- a/src/jsutils/isPromise.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Returns true if the value acts like a Promise, i.e. has a "then" function, - * otherwise returns false. - */ -export function isPromise(value: any): value is Promise { - return typeof value?.then === 'function'; -} diff --git a/src/jsutils/keyMap.ts b/src/jsutils/keyMap.ts deleted file mode 100644 index 592a98c83d..0000000000 --- a/src/jsutils/keyMap.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { ObjMap } from './ObjMap'; - -/** - * Creates a keyed JS object from an array, given a function to produce the keys - * for each value in the array. - * - * This provides a convenient lookup for the array items if the key function - * produces unique results. - * ```ts - * const phoneBook = [ - * { name: 'Jon', num: '555-1234' }, - * { name: 'Jenny', num: '867-5309' } - * ] - * - * const entriesByName = keyMap( - * phoneBook, - * entry => entry.name - * ) - * - * // { - * // Jon: { name: 'Jon', num: '555-1234' }, - * // Jenny: { name: 'Jenny', num: '867-5309' } - * // } - * - * const jennyEntry = entriesByName['Jenny'] - * - * // { name: 'Jenny', num: '857-6309' } - * ``` - */ -export function keyMap( - list: ReadonlyArray, - keyFn: (item: T) => string, -): ObjMap { - const result = Object.create(null); - for (const item of list) { - result[keyFn(item)] = item; - } - return result; -} diff --git a/src/jsutils/keyValMap.ts b/src/jsutils/keyValMap.ts deleted file mode 100644 index 94d688c2c1..0000000000 --- a/src/jsutils/keyValMap.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { ObjMap } from './ObjMap'; - -/** - * Creates a keyed JS object from an array, given a function to produce the keys - * and a function to produce the values from each item in the array. - * ```ts - * const phoneBook = [ - * { name: 'Jon', num: '555-1234' }, - * { name: 'Jenny', num: '867-5309' } - * ] - * - * // { Jon: '555-1234', Jenny: '867-5309' } - * const phonesByName = keyValMap( - * phoneBook, - * entry => entry.name, - * entry => entry.num - * ) - * ``` - */ -export function keyValMap( - list: ReadonlyArray, - keyFn: (item: T) => string, - valFn: (item: T) => V, -): ObjMap { - const result = Object.create(null); - for (const item of list) { - result[keyFn(item)] = valFn(item); - } - return result; -} diff --git a/src/jsutils/mapValue.ts b/src/jsutils/mapValue.ts deleted file mode 100644 index 32686a29c1..0000000000 --- a/src/jsutils/mapValue.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { ObjMap, ReadOnlyObjMap } from './ObjMap'; - -/** - * Creates an object map with the same keys as `map` and values generated by - * running each value of `map` thru `fn`. - */ -export function mapValue( - map: ReadOnlyObjMap, - fn: (value: T, key: string) => V, -): ObjMap { - const result = Object.create(null); - - for (const key of Object.keys(map)) { - result[key] = fn(map[key], key); - } - return result; -} diff --git a/src/jsutils/memoize3.ts b/src/jsutils/memoize3.ts deleted file mode 100644 index 213cb95d10..0000000000 --- a/src/jsutils/memoize3.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Memoizes the provided three-argument function. - */ -export function memoize3< - A1 extends object, - A2 extends object, - A3 extends object, - R, ->(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R { - let cache0: WeakMap>>; - - return function memoized(a1, a2, a3) { - if (cache0 === undefined) { - cache0 = new WeakMap(); - } - - let cache1 = cache0.get(a1); - if (cache1 === undefined) { - cache1 = new WeakMap(); - cache0.set(a1, cache1); - } - - let cache2 = cache1.get(a2); - if (cache2 === undefined) { - cache2 = new WeakMap(); - cache1.set(a2, cache2); - } - - let fnResult = cache2.get(a3); - if (fnResult === undefined) { - fnResult = fn(a1, a2, a3); - cache2.set(a3, fnResult); - } - - return fnResult; - }; -} diff --git a/src/jsutils/naturalCompare.ts b/src/jsutils/naturalCompare.ts deleted file mode 100644 index 7a56286306..0000000000 --- a/src/jsutils/naturalCompare.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Returns a number indicating whether a reference string comes before, or after, - * or is the same as the given string in natural sort order. - * - * See: https://en.wikipedia.org/wiki/Natural_sort_order - * - */ -export function naturalCompare(aStr: string, bStr: string): number { - let aIndex = 0; - let bIndex = 0; - - while (aIndex < aStr.length && bIndex < bStr.length) { - let aChar = aStr.charCodeAt(aIndex); - let bChar = bStr.charCodeAt(bIndex); - - if (isDigit(aChar) && isDigit(bChar)) { - let aNum = 0; - do { - ++aIndex; - aNum = aNum * 10 + aChar - DIGIT_0; - aChar = aStr.charCodeAt(aIndex); - } while (isDigit(aChar) && aNum > 0); - - let bNum = 0; - do { - ++bIndex; - bNum = bNum * 10 + bChar - DIGIT_0; - bChar = bStr.charCodeAt(bIndex); - } while (isDigit(bChar) && bNum > 0); - - if (aNum < bNum) { - return -1; - } - - if (aNum > bNum) { - return 1; - } - } else { - if (aChar < bChar) { - return -1; - } - if (aChar > bChar) { - return 1; - } - ++aIndex; - ++bIndex; - } - } - - return aStr.length - bStr.length; -} - -const DIGIT_0 = 48; -const DIGIT_9 = 57; - -function isDigit(code: number): boolean { - return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9; -} diff --git a/src/jsutils/printPathArray.ts b/src/jsutils/printPathArray.ts deleted file mode 100644 index 0d9fcc2b19..0000000000 --- a/src/jsutils/printPathArray.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Build a string describing the path. - */ -export function printPathArray(path: ReadonlyArray): string { - return path - .map((key) => - typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key, - ) - .join(''); -} diff --git a/src/jsutils/promiseForObject.ts b/src/jsutils/promiseForObject.ts deleted file mode 100644 index 1074676030..0000000000 --- a/src/jsutils/promiseForObject.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { ObjMap } from './ObjMap'; - -/** - * This function transforms a JS object `ObjMap>` into - * a `Promise>` - * - * This is akin to bluebird's `Promise.props`, but implemented only using - * `Promise.all` so it will work with any implementation of ES6 promises. - */ -export function promiseForObject( - object: ObjMap>, -): Promise> { - return Promise.all(Object.values(object)).then((resolvedValues) => { - const resolvedObject = Object.create(null); - for (const [i, key] of Object.keys(object).entries()) { - resolvedObject[key] = resolvedValues[i]; - } - return resolvedObject; - }); -} diff --git a/src/jsutils/promiseReduce.ts b/src/jsutils/promiseReduce.ts deleted file mode 100644 index 58db2e85c8..0000000000 --- a/src/jsutils/promiseReduce.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { isPromise } from './isPromise'; -import type { PromiseOrValue } from './PromiseOrValue'; - -/** - * Similar to Array.prototype.reduce(), however the reducing callback may return - * a Promise, in which case reduction will continue after each promise resolves. - * - * If the callback does not return a Promise, then this function will also not - * return a Promise. - */ -export function promiseReduce( - values: Iterable, - callbackFn: (accumulator: U, currentValue: T) => PromiseOrValue, - initialValue: PromiseOrValue, -): PromiseOrValue { - let accumulator = initialValue; - for (const value of values) { - accumulator = isPromise(accumulator) - ? accumulator.then((resolved) => callbackFn(resolved, value)) - : callbackFn(accumulator, value); - } - return accumulator; -} diff --git a/src/jsutils/suggestionList.ts b/src/jsutils/suggestionList.ts deleted file mode 100644 index 53ad685c8c..0000000000 --- a/src/jsutils/suggestionList.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { naturalCompare } from './naturalCompare'; - -/** - * Given an invalid input string and a list of valid options, returns a filtered - * list of valid options sorted based on their similarity with the input. - */ -export function suggestionList( - input: string, - options: ReadonlyArray, -): Array { - const optionsByDistance = Object.create(null); - const lexicalDistance = new LexicalDistance(input); - - const threshold = Math.floor(input.length * 0.4) + 1; - for (const option of options) { - const distance = lexicalDistance.measure(option, threshold); - if (distance !== undefined) { - optionsByDistance[option] = distance; - } - } - - return Object.keys(optionsByDistance).sort((a, b) => { - const distanceDiff = optionsByDistance[a] - optionsByDistance[b]; - return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b); - }); -} - -/** - * Computes the lexical distance between strings A and B. - * - * The "distance" between two strings is given by counting the minimum number - * of edits needed to transform string A into string B. An edit can be an - * insertion, deletion, or substitution of a single character, or a swap of two - * adjacent characters. - * - * Includes a custom alteration from Damerau-Levenshtein to treat case changes - * as a single edit which helps identify mis-cased values with an edit distance - * of 1. - * - * This distance can be useful for detecting typos in input or sorting - */ -class LexicalDistance { - _input: string; - _inputLowerCase: string; - _inputArray: Array; - _rows: [Array, Array, Array]; - - constructor(input: string) { - this._input = input; - this._inputLowerCase = input.toLowerCase(); - this._inputArray = stringToArray(this._inputLowerCase); - - this._rows = [ - new Array(input.length + 1).fill(0), - new Array(input.length + 1).fill(0), - new Array(input.length + 1).fill(0), - ]; - } - - measure(option: string, threshold: number): number | undefined { - if (this._input === option) { - return 0; - } - - const optionLowerCase = option.toLowerCase(); - - // Any case change counts as a single edit - if (this._inputLowerCase === optionLowerCase) { - return 1; - } - - let a = stringToArray(optionLowerCase); - let b = this._inputArray; - - if (a.length < b.length) { - const tmp = a; - a = b; - b = tmp; - } - const aLength = a.length; - const bLength = b.length; - - if (aLength - bLength > threshold) { - return undefined; - } - - const rows = this._rows; - for (let j = 0; j <= bLength; j++) { - rows[0][j] = j; - } - - for (let i = 1; i <= aLength; i++) { - const upRow = rows[(i - 1) % 3]; - const currentRow = rows[i % 3]; - - let smallestCell = (currentRow[0] = i); - for (let j = 1; j <= bLength; j++) { - const cost = a[i - 1] === b[j - 1] ? 0 : 1; - - let currentCell = Math.min( - upRow[j] + 1, // delete - currentRow[j - 1] + 1, // insert - upRow[j - 1] + cost, // substitute - ); - - if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { - // transposition - const doubleDiagonalCell = rows[(i - 2) % 3][j - 2]; - currentCell = Math.min(currentCell, doubleDiagonalCell + 1); - } - - if (currentCell < smallestCell) { - smallestCell = currentCell; - } - - currentRow[j] = currentCell; - } - - // Early exit, since distance can't go smaller than smallest element of the previous row. - if (smallestCell > threshold) { - return undefined; - } - } - - const distance = rows[aLength % 3][bLength]; - return distance <= threshold ? distance : undefined; - } -} - -function stringToArray(str: string): Array { - const strLength = str.length; - const array = new Array(strLength); - for (let i = 0; i < strLength; ++i) { - array[i] = str.charCodeAt(i); - } - return array; -} diff --git a/src/jsutils/toError.ts b/src/jsutils/toError.ts deleted file mode 100644 index 8d562273d6..0000000000 --- a/src/jsutils/toError.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { inspect } from './inspect'; - -/** - * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. - */ -export function toError(thrownValue: unknown): Error { - return thrownValue instanceof Error - ? thrownValue - : new NonErrorThrown(thrownValue); -} - -class NonErrorThrown extends Error { - thrownValue: unknown; - - constructor(thrownValue: unknown) { - super('Unexpected error value: ' + inspect(thrownValue)); - this.name = 'NonErrorThrown'; - this.thrownValue = thrownValue; - } -} diff --git a/src/jsutils/toObjMap.ts b/src/jsutils/toObjMap.ts deleted file mode 100644 index 6fe352db23..0000000000 --- a/src/jsutils/toObjMap.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Maybe } from './Maybe'; -import type { ReadOnlyObjMap, ReadOnlyObjMapLike } from './ObjMap'; - -export function toObjMap( - obj: Maybe>, -): ReadOnlyObjMap { - if (obj == null) { - return Object.create(null); - } - - if (Object.getPrototypeOf(obj) === null) { - return obj; - } - - const map = Object.create(null); - for (const [key, value] of Object.entries(obj)) { - map[key] = value; - } - return map; -} diff --git a/src/language/README.md b/src/language/README.md deleted file mode 100644 index 68cc9fd4a7..0000000000 --- a/src/language/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## GraphQL Language - -The `graphql/language` module is responsible for parsing and operating on the -GraphQL language. - -```js -import { ... } from 'graphql/language'; // ES6 -var GraphQLLanguage = require('graphql/language'); // CommonJS -``` diff --git a/src/language/__tests__/blockString-fuzz.ts b/src/language/__tests__/blockString-fuzz.ts deleted file mode 100644 index 4ed010ccb8..0000000000 --- a/src/language/__tests__/blockString-fuzz.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { genFuzzStrings } from '../../__testUtils__/genFuzzStrings'; -import { inspectStr } from '../../__testUtils__/inspectStr'; - -import { invariant } from '../../jsutils/invariant'; - -import { isPrintableAsBlockString, printBlockString } from '../blockString'; -import { Lexer } from '../lexer'; -import { Source } from '../source'; - -function lexValue(str: string): string { - const lexer = new Lexer(new Source(str)); - const value = lexer.advance().value; - - invariant(typeof value === 'string'); - invariant(lexer.advance().kind === '', 'Expected EOF'); - return value; -} - -function testPrintableBlockString( - testValue: string, - options?: { minimize: boolean }, -): void { - const blockString = printBlockString(testValue, options); - const printedValue = lexValue(blockString); - invariant( - testValue === printedValue, - dedent` - Expected lexValue(${inspectStr(blockString)}) - to equal ${inspectStr(testValue)} - but got ${inspectStr(printedValue)} - `, - ); -} - -function testNonPrintableBlockString(testValue: string): void { - const blockString = printBlockString(testValue); - const printedValue = lexValue(blockString); - invariant( - testValue !== printedValue, - dedent` - Expected lexValue(${inspectStr(blockString)}) - to not equal ${inspectStr(testValue)} - `, - ); -} - -describe('printBlockString', () => { - it('correctly print random strings', () => { - // Testing with length >7 is taking exponentially more time. However it is - // highly recommended to test with increased limit if you make any change. - for (const fuzzStr of genFuzzStrings({ - allowedChars: ['\n', '\t', ' ', '"', 'a', '\\'], - maxLength: 7, - })) { - if (!isPrintableAsBlockString(fuzzStr)) { - testNonPrintableBlockString(fuzzStr); - continue; - } - - testPrintableBlockString(fuzzStr); - testPrintableBlockString(fuzzStr, { minimize: true }); - } - }).timeout(20000); -}); diff --git a/src/language/__tests__/blockString-test.ts b/src/language/__tests__/blockString-test.ts deleted file mode 100644 index 21fa49b00a..0000000000 --- a/src/language/__tests__/blockString-test.ts +++ /dev/null @@ -1,289 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { - dedentBlockStringLines, - isPrintableAsBlockString, - printBlockString, -} from '../blockString'; - -function joinLines(...args: ReadonlyArray) { - return args.join('\n'); -} - -describe('dedentBlockStringLines', () => { - function expectDedent(lines: ReadonlyArray) { - return expect(dedentBlockStringLines(lines)); - } - - it('handles empty string', () => { - expectDedent(['']).to.deep.equal([]); - }); - - it('does not dedent first line', () => { - expectDedent([' a']).to.deep.equal([' a']); - expectDedent([' a', ' b']).to.deep.equal([' a', 'b']); - }); - - it('removes minimal indentation length', () => { - expectDedent(['', ' a', ' b']).to.deep.equal(['a', ' b']); - expectDedent(['', ' a', ' b']).to.deep.equal([' a', 'b']); - expectDedent(['', ' a', ' b', 'c']).to.deep.equal([' a', ' b', 'c']); - }); - - it('dedent both tab and space as single character', () => { - expectDedent(['', '\ta', ' b']).to.deep.equal(['a', ' b']); - expectDedent(['', '\t a', ' b']).to.deep.equal(['a', ' b']); - expectDedent(['', ' \t a', ' b']).to.deep.equal(['a', ' b']); - }); - - it('dedent do not take empty lines into account', () => { - expectDedent(['a', '', ' b']).to.deep.equal(['a', '', 'b']); - expectDedent(['a', ' ', ' b']).to.deep.equal(['a', '', 'b']); - }); - - it('removes uniform indentation from a string', () => { - const lines = [ - '', - ' Hello,', - ' World!', - '', - ' Yours,', - ' GraphQL.', - ]; - expectDedent(lines).to.deep.equal([ - 'Hello,', - ' World!', - '', - 'Yours,', - ' GraphQL.', - ]); - }); - - it('removes empty leading and trailing lines', () => { - const lines = [ - '', - '', - ' Hello,', - ' World!', - '', - ' Yours,', - ' GraphQL.', - '', - '', - ]; - expectDedent(lines).to.deep.equal([ - 'Hello,', - ' World!', - '', - 'Yours,', - ' GraphQL.', - ]); - }); - - it('removes blank leading and trailing lines', () => { - const lines = [ - ' ', - ' ', - ' Hello,', - ' World!', - '', - ' Yours,', - ' GraphQL.', - ' ', - ' ', - ]; - expectDedent(lines).to.deep.equal([ - 'Hello,', - ' World!', - '', - 'Yours,', - ' GraphQL.', - ]); - }); - - it('retains indentation from first line', () => { - const lines = [ - ' Hello,', - ' World!', - '', - ' Yours,', - ' GraphQL.', - ]; - expectDedent(lines).to.deep.equal([ - ' Hello,', - ' World!', - '', - 'Yours,', - ' GraphQL.', - ]); - }); - - it('does not alter trailing spaces', () => { - const lines = [ - ' ', - ' Hello, ', - ' World! ', - ' ', - ' Yours, ', - ' GraphQL. ', - ' ', - ]; - expectDedent(lines).to.deep.equal([ - 'Hello, ', - ' World! ', - ' ', - 'Yours, ', - ' GraphQL. ', - ]); - }); -}); - -describe('isPrintableAsBlockString', () => { - function expectPrintable(str: string) { - return expect(isPrintableAsBlockString(str)).to.equal(true); - } - - function expectNonPrintable(str: string) { - return expect(isPrintableAsBlockString(str)).to.equal(false); - } - - it('accepts valid strings', () => { - expectPrintable(''); - expectPrintable(' a'); - expectPrintable('\t"\n"'); - expectNonPrintable('\t"\n \n\t"'); - }); - - it('rejects strings with only whitespace', () => { - expectNonPrintable(' '); - expectNonPrintable('\t'); - expectNonPrintable('\t '); - expectNonPrintable(' \t'); - }); - - it('rejects strings with non-printable characters', () => { - expectNonPrintable('\x00'); - expectNonPrintable('a\x00b'); - }); - - it('rejects strings with only empty lines', () => { - expectNonPrintable('\n'); - expectNonPrintable('\n\n'); - expectNonPrintable('\n\n\n'); - expectNonPrintable(' \n \n'); - expectNonPrintable('\t\n\t\t\n'); - }); - - it('rejects strings with carriage return', () => { - expectNonPrintable('\r'); - expectNonPrintable('\n\r'); - expectNonPrintable('\r\n'); - expectNonPrintable('a\rb'); - }); - - it('rejects strings with leading empty lines', () => { - expectNonPrintable('\na'); - expectNonPrintable(' \na'); - expectNonPrintable('\t\na'); - expectNonPrintable('\n\na'); - }); - - it('rejects strings with trailing empty lines', () => { - expectNonPrintable('a\n'); - expectNonPrintable('a\n '); - expectNonPrintable('a\n\t'); - expectNonPrintable('a\n\n'); - }); -}); - -describe('printBlockString', () => { - function expectBlockString(str: string) { - return { - toEqual(expected: string | { readable: string; minimize: string }) { - const { readable, minimize } = - typeof expected === 'string' - ? { readable: expected, minimize: expected } - : expected; - - expect(printBlockString(str)).to.equal(readable); - expect(printBlockString(str, { minimize: true })).to.equal(minimize); - }, - }; - } - - it('does not escape characters', () => { - const str = '" \\ / \b \f \n \r \t'; - expectBlockString(str).toEqual({ - readable: '"""\n' + str + '\n"""', - minimize: '"""\n' + str + '"""', - }); - }); - - it('by default print block strings as single line', () => { - const str = 'one liner'; - expectBlockString(str).toEqual('"""one liner"""'); - }); - - it('by default print block strings ending with triple quotation as multi-line', () => { - const str = 'triple quotation """'; - expectBlockString(str).toEqual({ - readable: '"""\ntriple quotation \\"""\n"""', - minimize: '"""triple quotation \\""""""', - }); - }); - - it('correctly prints single-line with leading space', () => { - const str = ' space-led string'; - expectBlockString(str).toEqual('""" space-led string"""'); - }); - - it('correctly prints single-line with leading space and trailing quotation', () => { - const str = ' space-led value "quoted string"'; - expectBlockString(str).toEqual( - '""" space-led value "quoted string"\n"""', - ); - }); - - it('correctly prints single-line with trailing backslash', () => { - const str = 'backslash \\'; - expectBlockString(str).toEqual({ - readable: '"""\nbackslash \\\n"""', - minimize: '"""backslash \\\n"""', - }); - }); - - it('correctly prints multi-line with internal indent', () => { - const str = 'no indent\n with indent'; - expectBlockString(str).toEqual({ - readable: '"""\nno indent\n with indent\n"""', - minimize: '"""\nno indent\n with indent"""', - }); - }); - - it('correctly prints string with a first line indentation', () => { - const str = joinLines( - ' first ', - ' line ', - 'indentation', - ' string', - ); - - expectBlockString(str).toEqual({ - readable: joinLines( - '"""', - ' first ', - ' line ', - 'indentation', - ' string', - '"""', - ), - minimize: joinLines( - '""" first ', - ' line ', - 'indentation', - ' string"""', - ), - }); - }); -}); diff --git a/src/language/__tests__/lexer-test.ts b/src/language/__tests__/lexer-test.ts deleted file mode 100644 index 46bf971d0a..0000000000 --- a/src/language/__tests__/lexer-test.ts +++ /dev/null @@ -1,1207 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { expectToThrowJSON } from '../../__testUtils__/expectJSON'; - -import { inspect } from '../../jsutils/inspect'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { Token } from '../ast'; -import { isPunctuatorTokenKind, Lexer } from '../lexer'; -import { Source } from '../source'; -import { TokenKind } from '../tokenKind'; - -function lexOne(str: string) { - const lexer = new Lexer(new Source(str)); - return lexer.advance(); -} - -function lexSecond(str: string) { - const lexer = new Lexer(new Source(str)); - lexer.advance(); - return lexer.advance(); -} - -function expectSyntaxError(text: string) { - return expectToThrowJSON(() => lexSecond(text)); -} - -describe('Lexer', () => { - it('ignores BOM header', () => { - expect(lexOne('\uFEFF foo')).to.contain({ - kind: TokenKind.NAME, - start: 2, - end: 5, - value: 'foo', - }); - }); - - it('tracks line breaks', () => { - expect(lexOne('foo')).to.contain({ - kind: TokenKind.NAME, - start: 0, - end: 3, - line: 1, - column: 1, - value: 'foo', - }); - expect(lexOne('\nfoo')).to.contain({ - kind: TokenKind.NAME, - start: 1, - end: 4, - line: 2, - column: 1, - value: 'foo', - }); - expect(lexOne('\rfoo')).to.contain({ - kind: TokenKind.NAME, - start: 1, - end: 4, - line: 2, - column: 1, - value: 'foo', - }); - expect(lexOne('\r\nfoo')).to.contain({ - kind: TokenKind.NAME, - start: 2, - end: 5, - line: 2, - column: 1, - value: 'foo', - }); - expect(lexOne('\n\rfoo')).to.contain({ - kind: TokenKind.NAME, - start: 2, - end: 5, - line: 3, - column: 1, - value: 'foo', - }); - expect(lexOne('\r\r\n\nfoo')).to.contain({ - kind: TokenKind.NAME, - start: 4, - end: 7, - line: 4, - column: 1, - value: 'foo', - }); - expect(lexOne('\n\n\r\rfoo')).to.contain({ - kind: TokenKind.NAME, - start: 4, - end: 7, - line: 5, - column: 1, - value: 'foo', - }); - }); - - it('records line and column', () => { - expect(lexOne('\n \r\n \r foo\n')).to.contain({ - kind: TokenKind.NAME, - start: 8, - end: 11, - line: 4, - column: 3, - value: 'foo', - }); - }); - - it('can be Object.toStringified, JSON.stringified, or jsutils.inspected', () => { - const lexer = new Lexer(new Source('foo')); - const token = lexer.advance(); - - expect(Object.prototype.toString.call(lexer)).to.equal('[object Lexer]'); - - expect(Object.prototype.toString.call(token)).to.equal('[object Token]'); - expect(JSON.stringify(token)).to.equal( - '{"kind":"Name","value":"foo","line":1,"column":1}', - ); - expect(inspect(token)).to.equal( - '{ kind: "Name", value: "foo", line: 1, column: 1 }', - ); - }); - - it('skips whitespace and comments', () => { - expect( - lexOne(` - - foo - - -`), - ).to.contain({ - kind: TokenKind.NAME, - start: 6, - end: 9, - value: 'foo', - }); - - expect(lexOne('\t\tfoo\t\t')).to.contain({ - kind: TokenKind.NAME, - start: 2, - end: 5, - value: 'foo', - }); - - expect( - lexOne(` - #comment - foo#comment -`), - ).to.contain({ - kind: TokenKind.NAME, - start: 18, - end: 21, - value: 'foo', - }); - - expect(lexOne(',,,foo,,,')).to.contain({ - kind: TokenKind.NAME, - start: 3, - end: 6, - value: 'foo', - }); - }); - - it('errors respect whitespace', () => { - let caughtError; - try { - lexOne(['', '', ' ~', ''].join('\n')); - } catch (error) { - caughtError = error; - } - expect(String(caughtError)).to.equal(dedent` - Syntax Error: Unexpected character: "~". - - GraphQL request:3:2 - 2 | - 3 | ~ - | ^ - 4 | - `); - }); - - it('updates line numbers in error for file context', () => { - let caughtError; - try { - const str = ['', '', ' ~', ''].join('\n'); - const source = new Source(str, 'foo.js', { line: 11, column: 12 }); - new Lexer(source).advance(); - } catch (error) { - caughtError = error; - } - expect(String(caughtError)).to.equal(dedent` - Syntax Error: Unexpected character: "~". - - foo.js:13:6 - 12 | - 13 | ~ - | ^ - 14 | - `); - }); - - it('updates column numbers in error for file context', () => { - let caughtError; - try { - const source = new Source('~', 'foo.js', { line: 1, column: 5 }); - new Lexer(source).advance(); - } catch (error) { - caughtError = error; - } - expect(String(caughtError)).to.equal(dedent` - Syntax Error: Unexpected character: "~". - - foo.js:1:5 - 1 | ~ - | ^ - `); - }); - - it('lexes strings', () => { - expect(lexOne('""')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 2, - value: '', - }); - - expect(lexOne('"simple"')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 8, - value: 'simple', - }); - - expect(lexOne('" white space "')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 15, - value: ' white space ', - }); - - expect(lexOne('"quote \\""')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 10, - value: 'quote "', - }); - - expect(lexOne('"escaped \\n\\r\\b\\t\\f"')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 20, - value: 'escaped \n\r\b\t\f', - }); - - expect(lexOne('"slashes \\\\ \\/"')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 15, - value: 'slashes \\ /', - }); - - expect(lexOne('"unescaped unicode outside BMP \u{1f600}"')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 34, - value: 'unescaped unicode outside BMP \u{1f600}', - }); - - expect( - lexOne('"unescaped maximal unicode outside BMP \u{10ffff}"'), - ).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 42, - value: 'unescaped maximal unicode outside BMP \u{10ffff}', - }); - - expect(lexOne('"unicode \\u1234\\u5678\\u90AB\\uCDEF"')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 34, - value: 'unicode \u1234\u5678\u90AB\uCDEF', - }); - - expect(lexOne('"unicode \\u{1234}\\u{5678}\\u{90AB}\\u{CDEF}"')).to.contain( - { - kind: TokenKind.STRING, - start: 0, - end: 42, - value: 'unicode \u1234\u5678\u90AB\uCDEF', - }, - ); - - expect( - lexOne('"string with unicode escape outside BMP \\u{1F600}"'), - ).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 50, - value: 'string with unicode escape outside BMP \u{1f600}', - }); - - expect(lexOne('"string with minimal unicode escape \\u{0}"')).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 42, - value: 'string with minimal unicode escape \u{0}', - }); - - expect( - lexOne('"string with maximal unicode escape \\u{10FFFF}"'), - ).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 47, - value: 'string with maximal unicode escape \u{10FFFF}', - }); - - expect( - lexOne('"string with maximal minimal unicode escape \\u{00000000}"'), - ).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 57, - value: 'string with maximal minimal unicode escape \u{0}', - }); - - expect( - lexOne('"string with unicode surrogate pair escape \\uD83D\\uDE00"'), - ).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 56, - value: 'string with unicode surrogate pair escape \u{1f600}', - }); - - expect( - lexOne('"string with minimal surrogate pair escape \\uD800\\uDC00"'), - ).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 56, - value: 'string with minimal surrogate pair escape \u{10000}', - }); - - expect( - lexOne('"string with maximal surrogate pair escape \\uDBFF\\uDFFF"'), - ).to.contain({ - kind: TokenKind.STRING, - start: 0, - end: 56, - value: 'string with maximal surrogate pair escape \u{10FFFF}', - }); - }); - - it('lex reports useful string errors', () => { - expectSyntaxError('"').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 2 }], - }); - - expectSyntaxError('"""').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 4 }], - }); - - expectSyntaxError('""""').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 5 }], - }); - - expectSyntaxError('"no end quote').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 14 }], - }); - - expectSyntaxError("'single quotes'").to.deep.equal({ - message: - 'Syntax Error: Unexpected single quote character (\'), did you mean to use a double quote (")?', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('"bad surrogate \uDEAD"').to.deep.equal({ - message: 'Syntax Error: Invalid character within String: U+DEAD.', - locations: [{ line: 1, column: 16 }], - }); - - expectSyntaxError('"bad high surrogate pair \uDEAD\uDEAD"').to.deep.equal({ - message: 'Syntax Error: Invalid character within String: U+DEAD.', - locations: [{ line: 1, column: 26 }], - }); - - expectSyntaxError('"bad low surrogate pair \uD800\uD800"').to.deep.equal({ - message: 'Syntax Error: Invalid character within String: U+D800.', - locations: [{ line: 1, column: 25 }], - }); - - expectSyntaxError('"multi\nline"').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 7 }], - }); - - expectSyntaxError('"multi\rline"').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 7 }], - }); - - expectSyntaxError('"bad \\z esc"').to.deep.equal({ - message: 'Syntax Error: Invalid character escape sequence: "\\z".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\x esc"').to.deep.equal({ - message: 'Syntax Error: Invalid character escape sequence: "\\x".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\u1 esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u1 es".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\u0XX1 esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u0XX1".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\uXXXX esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uXXXX".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\uFXXX esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uFXXX".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\uXXXF esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uXXXF".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\u{} esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u{}".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\u{FXXX} esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u{FX".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\u{FFFF esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u{FFFF ".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"bad \\u{FFFF"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u{FFFF"".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('"too high \\u{110000} esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u{110000}".', - locations: [{ line: 1, column: 11 }], - }); - - expectSyntaxError('"way too high \\u{12345678} esc"').to.deep.equal({ - message: - 'Syntax Error: Invalid Unicode escape sequence: "\\u{12345678}".', - locations: [{ line: 1, column: 15 }], - }); - - expectSyntaxError('"too long \\u{000000000} esc"').to.deep.equal({ - message: - 'Syntax Error: Invalid Unicode escape sequence: "\\u{000000000".', - locations: [{ line: 1, column: 11 }], - }); - - expectSyntaxError('"bad surrogate \\uDEAD esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uDEAD".', - locations: [{ line: 1, column: 16 }], - }); - - expectSyntaxError('"bad surrogate \\u{DEAD} esc"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u{DEAD}".', - locations: [{ line: 1, column: 16 }], - }); - - expectSyntaxError( - '"cannot use braces for surrogate pair \\u{D83D}\\u{DE00} esc"', - ).to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\u{D83D}".', - locations: [{ line: 1, column: 39 }], - }); - - expectSyntaxError( - '"bad high surrogate pair \\uDEAD\\uDEAD esc"', - ).to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uDEAD".', - locations: [{ line: 1, column: 26 }], - }); - - expectSyntaxError( - '"bad low surrogate pair \\uD800\\uD800 esc"', - ).to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uD800".', - locations: [{ line: 1, column: 25 }], - }); - - expectSyntaxError( - '"cannot escape half a pair \uD83D\\uDE00 esc"', - ).to.deep.equal({ - message: 'Syntax Error: Invalid character within String: U+D83D.', - locations: [{ line: 1, column: 28 }], - }); - - expectSyntaxError( - '"cannot escape half a pair \\uD83D\uDE00 esc"', - ).to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uD83D".', - locations: [{ line: 1, column: 28 }], - }); - - expectSyntaxError('"bad \\uD83D\\not an escape"').to.deep.equal({ - message: 'Syntax Error: Invalid Unicode escape sequence: "\\uD83D".', - locations: [{ line: 1, column: 6 }], - }); - }); - - it('lexes block strings', () => { - expect(lexOne('""""""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 6, - line: 1, - column: 1, - value: '', - }); - - expect(lexOne('"""simple"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 12, - line: 1, - column: 1, - value: 'simple', - }); - - expect(lexOne('""" white space """')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 19, - line: 1, - column: 1, - value: ' white space ', - }); - - expect(lexOne('"""contains " quote"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 22, - line: 1, - column: 1, - value: 'contains " quote', - }); - - expect(lexOne('"""contains \\""" triple quote"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 32, - line: 1, - column: 1, - value: 'contains """ triple quote', - }); - - expect(lexOne('"""multi\nline"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 16, - line: 1, - column: 1, - value: 'multi\nline', - }); - - expect(lexOne('"""multi\rline\r\nnormalized"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 28, - line: 1, - column: 1, - value: 'multi\nline\nnormalized', - }); - - expect(lexOne('"""unescaped \\n\\r\\b\\t\\f\\u1234"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 32, - line: 1, - column: 1, - value: 'unescaped \\n\\r\\b\\t\\f\\u1234', - }); - - expect(lexOne('"""unescaped unicode outside BMP \u{1f600}"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 38, - line: 1, - column: 1, - value: 'unescaped unicode outside BMP \u{1f600}', - }); - - expect(lexOne('"""slashes \\\\ \\/"""')).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 19, - line: 1, - column: 1, - value: 'slashes \\\\ \\/', - }); - - expect( - lexOne(`""" - - spans - multiple - lines - - """`), - ).to.contain({ - kind: TokenKind.BLOCK_STRING, - start: 0, - end: 68, - line: 1, - column: 1, - value: 'spans\n multiple\n lines', - }); - }); - - it('advance line after lexing multiline block string', () => { - expect( - lexSecond(`""" - - spans - multiple - lines - - \n """ second_token`), - ).to.contain({ - kind: TokenKind.NAME, - start: 71, - end: 83, - line: 8, - column: 6, - value: 'second_token', - }); - - expect( - lexSecond( - [ - '""" \n', - 'spans \r\n', - 'multiple \n\r', - 'lines \n\n', - '"""\n second_token', - ].join(''), - ), - ).to.contain({ - kind: TokenKind.NAME, - start: 37, - end: 49, - line: 8, - column: 2, - value: 'second_token', - }); - }); - - it('lex reports useful block string errors', () => { - expectSyntaxError('"""').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 4 }], - }); - - expectSyntaxError('"""no end quote').to.deep.equal({ - message: 'Syntax Error: Unterminated string.', - locations: [{ line: 1, column: 16 }], - }); - - expectSyntaxError('"""contains invalid surrogate \uDEAD"""').to.deep.equal({ - message: 'Syntax Error: Invalid character within String: U+DEAD.', - locations: [{ line: 1, column: 31 }], - }); - }); - - it('lexes numbers', () => { - expect(lexOne('4')).to.contain({ - kind: TokenKind.INT, - start: 0, - end: 1, - value: '4', - }); - - expect(lexOne('4.123')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 5, - value: '4.123', - }); - - expect(lexOne('-4')).to.contain({ - kind: TokenKind.INT, - start: 0, - end: 2, - value: '-4', - }); - - expect(lexOne('9')).to.contain({ - kind: TokenKind.INT, - start: 0, - end: 1, - value: '9', - }); - - expect(lexOne('0')).to.contain({ - kind: TokenKind.INT, - start: 0, - end: 1, - value: '0', - }); - - expect(lexOne('-4.123')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 6, - value: '-4.123', - }); - - expect(lexOne('0.123')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 5, - value: '0.123', - }); - - expect(lexOne('123e4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 5, - value: '123e4', - }); - - expect(lexOne('123E4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 5, - value: '123E4', - }); - - expect(lexOne('123e-4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 6, - value: '123e-4', - }); - - expect(lexOne('123e+4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 6, - value: '123e+4', - }); - - expect(lexOne('-1.123e4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 8, - value: '-1.123e4', - }); - - expect(lexOne('-1.123E4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 8, - value: '-1.123E4', - }); - - expect(lexOne('-1.123e-4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 9, - value: '-1.123e-4', - }); - - expect(lexOne('-1.123e+4')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 9, - value: '-1.123e+4', - }); - - expect(lexOne('-1.123e4567')).to.contain({ - kind: TokenKind.FLOAT, - start: 0, - end: 11, - value: '-1.123e4567', - }); - }); - - it('lex reports useful number errors', () => { - expectSyntaxError('00').to.deep.equal({ - message: 'Syntax Error: Invalid number, unexpected digit after 0: "0".', - locations: [{ line: 1, column: 2 }], - }); - - expectSyntaxError('01').to.deep.equal({ - message: 'Syntax Error: Invalid number, unexpected digit after 0: "1".', - locations: [{ line: 1, column: 2 }], - }); - - expectSyntaxError('01.23').to.deep.equal({ - message: 'Syntax Error: Invalid number, unexpected digit after 0: "1".', - locations: [{ line: 1, column: 2 }], - }); - - expectSyntaxError('+1').to.deep.equal({ - message: 'Syntax Error: Unexpected character: "+".', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('1.').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: .', - locations: [{ line: 1, column: 3 }], - }); - - expectSyntaxError('1e').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: .', - locations: [{ line: 1, column: 3 }], - }); - - expectSyntaxError('1E').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: .', - locations: [{ line: 1, column: 3 }], - }); - - expectSyntaxError('1.e1').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "e".', - locations: [{ line: 1, column: 3 }], - }); - - expectSyntaxError('.123').to.deep.equal({ - message: 'Syntax Error: Unexpected character: ".".', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('1.A').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "A".', - locations: [{ line: 1, column: 3 }], - }); - - expectSyntaxError('-A').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "A".', - locations: [{ line: 1, column: 2 }], - }); - - expectSyntaxError('1.0e').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: .', - locations: [{ line: 1, column: 5 }], - }); - - expectSyntaxError('1.0eA').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "A".', - locations: [{ line: 1, column: 5 }], - }); - - expectSyntaxError('1.0e"').to.deep.equal({ - message: "Syntax Error: Invalid number, expected digit but got: '\"'.", - locations: [{ line: 1, column: 5 }], - }); - - expectSyntaxError('1.2e3e').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "e".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('1.2e3.4').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: ".".', - locations: [{ line: 1, column: 6 }], - }); - - expectSyntaxError('1.23.4').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: ".".', - locations: [{ line: 1, column: 5 }], - }); - }); - - it('lex does not allow name-start after a number', () => { - expectSyntaxError('0xF1').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "x".', - locations: [{ line: 1, column: 2 }], - }); - expectSyntaxError('0b10').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "b".', - locations: [{ line: 1, column: 2 }], - }); - expectSyntaxError('123abc').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "a".', - locations: [{ line: 1, column: 4 }], - }); - expectSyntaxError('1_234').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "_".', - locations: [{ line: 1, column: 2 }], - }); - expectSyntaxError('1\u00DF').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+00DF.', - locations: [{ line: 1, column: 2 }], - }); - expectSyntaxError('1.23f').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "f".', - locations: [{ line: 1, column: 5 }], - }); - expectSyntaxError('1.234_5').to.deep.equal({ - message: 'Syntax Error: Invalid number, expected digit but got: "_".', - locations: [{ line: 1, column: 6 }], - }); - }); - - it('lexes punctuation', () => { - expect(lexOne('!')).to.contain({ - kind: TokenKind.BANG, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('$')).to.contain({ - kind: TokenKind.DOLLAR, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('(')).to.contain({ - kind: TokenKind.PAREN_L, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne(')')).to.contain({ - kind: TokenKind.PAREN_R, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('...')).to.contain({ - kind: TokenKind.SPREAD, - start: 0, - end: 3, - value: undefined, - }); - - expect(lexOne(':')).to.contain({ - kind: TokenKind.COLON, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('=')).to.contain({ - kind: TokenKind.EQUALS, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('@')).to.contain({ - kind: TokenKind.AT, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('[')).to.contain({ - kind: TokenKind.BRACKET_L, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne(']')).to.contain({ - kind: TokenKind.BRACKET_R, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('{')).to.contain({ - kind: TokenKind.BRACE_L, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('|')).to.contain({ - kind: TokenKind.PIPE, - start: 0, - end: 1, - value: undefined, - }); - - expect(lexOne('}')).to.contain({ - kind: TokenKind.BRACE_R, - start: 0, - end: 1, - value: undefined, - }); - }); - - it('lex reports useful unknown character error', () => { - expectSyntaxError('..').to.deep.equal({ - message: 'Syntax Error: Unexpected character: ".".', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('~').to.deep.equal({ - message: 'Syntax Error: Unexpected character: "~".', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\x00').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+0000.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\b').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+0008.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\u00AA').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+00AA.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\u0AAA').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+0AAA.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\u203B').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+203B.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\u{1f600}').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+1F600.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\uD83D\uDE00').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+1F600.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\uD800\uDC00').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+10000.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\uDBFF\uDFFF').to.deep.equal({ - message: 'Syntax Error: Unexpected character: U+10FFFF.', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('\uDEAD').to.deep.equal({ - message: 'Syntax Error: Invalid character: U+DEAD.', - locations: [{ line: 1, column: 1 }], - }); - }); - - it('lex reports useful information for dashes in names', () => { - const source = new Source('a-b'); - const lexer = new Lexer(source); - const firstToken = lexer.advance(); - expect(firstToken).to.contain({ - kind: TokenKind.NAME, - start: 0, - end: 1, - value: 'a', - }); - - expect(() => lexer.advance()) - .throw(GraphQLError) - .that.deep.include({ - message: 'Syntax Error: Invalid number, expected digit but got: "b".', - locations: [{ line: 1, column: 3 }], - }); - }); - - it('produces double linked list of tokens, including comments', () => { - const source = new Source(` - { - #comment - field - } - `); - - const lexer = new Lexer(source); - const startToken = lexer.token; - let endToken; - do { - endToken = lexer.advance(); - // Lexer advances over ignored comment tokens to make writing parsers - // easier, but will include them in the linked list result. - expect(endToken.kind).to.not.equal(TokenKind.COMMENT); - } while (endToken.kind !== TokenKind.EOF); - - expect(startToken.prev).to.equal(null); - expect(endToken.next).to.equal(null); - - const tokens = []; - for (let tok: Token | null = startToken; tok; tok = tok.next) { - if (tokens.length) { - // Tokens are double-linked, prev should point to last seen token. - expect(tok.prev).to.equal(tokens[tokens.length - 1]); - } - tokens.push(tok); - } - - expect(tokens.map((tok) => tok.kind)).to.deep.equal([ - TokenKind.SOF, - TokenKind.BRACE_L, - TokenKind.COMMENT, - TokenKind.NAME, - TokenKind.BRACE_R, - TokenKind.EOF, - ]); - }); - - it('lexes comments', () => { - expect(lexOne('# Comment').prev).to.contain({ - kind: TokenKind.COMMENT, - start: 0, - end: 9, - value: ' Comment', - }); - expect(lexOne('# Comment\nAnother line').prev).to.contain({ - kind: TokenKind.COMMENT, - start: 0, - end: 9, - value: ' Comment', - }); - expect(lexOne('# Comment\r\nAnother line').prev).to.contain({ - kind: TokenKind.COMMENT, - start: 0, - end: 9, - value: ' Comment', - }); - expect(lexOne('# Comment \u{1f600}').prev).to.contain({ - kind: TokenKind.COMMENT, - start: 0, - end: 12, - value: ' Comment \u{1f600}', - }); - expectSyntaxError('# Invalid surrogate \uDEAD').to.deep.equal({ - message: 'Syntax Error: Invalid character: U+DEAD.', - locations: [{ line: 1, column: 21 }], - }); - }); -}); - -describe('isPunctuatorTokenKind', () => { - function isPunctuatorToken(text: string) { - return isPunctuatorTokenKind(lexOne(text).kind); - } - - it('returns true for punctuator tokens', () => { - expect(isPunctuatorToken('!')).to.equal(true); - expect(isPunctuatorToken('$')).to.equal(true); - expect(isPunctuatorToken('&')).to.equal(true); - expect(isPunctuatorToken('(')).to.equal(true); - expect(isPunctuatorToken(')')).to.equal(true); - expect(isPunctuatorToken('...')).to.equal(true); - expect(isPunctuatorToken(':')).to.equal(true); - expect(isPunctuatorToken('=')).to.equal(true); - expect(isPunctuatorToken('@')).to.equal(true); - expect(isPunctuatorToken('[')).to.equal(true); - expect(isPunctuatorToken(']')).to.equal(true); - expect(isPunctuatorToken('{')).to.equal(true); - expect(isPunctuatorToken('|')).to.equal(true); - expect(isPunctuatorToken('}')).to.equal(true); - }); - - it('returns false for non-punctuator tokens', () => { - expect(isPunctuatorToken('')).to.equal(false); - expect(isPunctuatorToken('name')).to.equal(false); - expect(isPunctuatorToken('1')).to.equal(false); - expect(isPunctuatorToken('3.14')).to.equal(false); - expect(isPunctuatorToken('"str"')).to.equal(false); - expect(isPunctuatorToken('"""str"""')).to.equal(false); - }); -}); diff --git a/src/language/__tests__/parser-test.ts b/src/language/__tests__/parser-test.ts deleted file mode 100644 index caa922a27d..0000000000 --- a/src/language/__tests__/parser-test.ts +++ /dev/null @@ -1,660 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { expectJSON, expectToThrowJSON } from '../../__testUtils__/expectJSON'; -import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery'; - -import { inspect } from '../../jsutils/inspect'; - -import { Kind } from '../kinds'; -import { parse, parseConstValue, parseType, parseValue } from '../parser'; -import { Source } from '../source'; -import { TokenKind } from '../tokenKind'; - -function expectSyntaxError(text: string) { - return expectToThrowJSON(() => parse(text)); -} - -describe('Parser', () => { - it('parse provides useful errors', () => { - let caughtError; - try { - parse('{'); - } catch (error) { - caughtError = error; - } - - expect(caughtError).to.deep.contain({ - message: 'Syntax Error: Expected Name, found .', - positions: [1], - locations: [{ line: 1, column: 2 }], - }); - - expect(String(caughtError)).to.equal(dedent` - Syntax Error: Expected Name, found . - - GraphQL request:1:2 - 1 | { - | ^ - `); - - expectSyntaxError(` - { ...MissingOn } - fragment MissingOn Type - `).to.deep.include({ - message: 'Syntax Error: Expected "on", found Name "Type".', - locations: [{ line: 3, column: 26 }], - }); - - expectSyntaxError('{ field: {} }').to.deep.include({ - message: 'Syntax Error: Expected Name, found "{".', - locations: [{ line: 1, column: 10 }], - }); - - expectSyntaxError('notAnOperation Foo { field }').to.deep.include({ - message: 'Syntax Error: Unexpected Name "notAnOperation".', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('...').to.deep.include({ - message: 'Syntax Error: Unexpected "...".', - locations: [{ line: 1, column: 1 }], - }); - - expectSyntaxError('{ ""').to.deep.include({ - message: 'Syntax Error: Expected Name, found String "".', - locations: [{ line: 1, column: 3 }], - }); - }); - - it('parse provides useful error when using source', () => { - let caughtError; - try { - parse(new Source('query', 'MyQuery.graphql')); - } catch (error) { - caughtError = error; - } - expect(String(caughtError)).to.equal(dedent` - Syntax Error: Expected "{", found . - - MyQuery.graphql:1:6 - 1 | query - | ^ - `); - }); - - it('exposes the tokenCount', () => { - expect(parse('{ foo }').tokenCount).to.equal(3); - expect(parse('{ foo(bar: "baz") }').tokenCount).to.equal(8); - }); - - it('limit maximum number of tokens', () => { - expect(() => parse('{ foo }', { maxTokens: 3 })).to.not.throw(); - expect(() => parse('{ foo }', { maxTokens: 2 })).to.throw( - 'Syntax Error: Document contains more that 2 tokens. Parsing aborted.', - ); - - expect(() => parse('{ foo(bar: "baz") }', { maxTokens: 8 })).to.not.throw(); - - expect(() => parse('{ foo(bar: "baz") }', { maxTokens: 7 })).to.throw( - 'Syntax Error: Document contains more that 7 tokens. Parsing aborted.', - ); - }); - - it('parses variable inline values', () => { - expect(() => - parse('{ field(complex: { a: { b: [ $var ] } }) }'), - ).to.not.throw(); - }); - - it('parses constant default values', () => { - expectSyntaxError( - 'query Foo($x: Complex = { a: { b: [ $var ] } }) { field }', - ).to.deep.equal({ - message: 'Syntax Error: Unexpected variable "$var" in constant value.', - locations: [{ line: 1, column: 37 }], - }); - }); - - it('parses variable definition directives', () => { - expect(() => - parse('query Foo($x: Boolean = false @bar) { field }'), - ).to.not.throw(); - }); - - it('does not accept fragments named "on"', () => { - expectSyntaxError('fragment on on on { on }').to.deep.equal({ - message: 'Syntax Error: Unexpected Name "on".', - locations: [{ line: 1, column: 10 }], - }); - }); - - it('does not accept fragments spread of "on"', () => { - expectSyntaxError('{ ...on }').to.deep.equal({ - message: 'Syntax Error: Expected Name, found "}".', - locations: [{ line: 1, column: 9 }], - }); - }); - - it('does not allow "true", "false", or "null" as enum value', () => { - expectSyntaxError('enum Test { VALID, true }').to.deep.equal({ - message: - 'Syntax Error: Name "true" is reserved and cannot be used for an enum value.', - locations: [{ line: 1, column: 20 }], - }); - - expectSyntaxError('enum Test { VALID, false }').to.deep.equal({ - message: - 'Syntax Error: Name "false" is reserved and cannot be used for an enum value.', - locations: [{ line: 1, column: 20 }], - }); - - expectSyntaxError('enum Test { VALID, null }').to.deep.equal({ - message: - 'Syntax Error: Name "null" is reserved and cannot be used for an enum value.', - locations: [{ line: 1, column: 20 }], - }); - }); - - it('parses multi-byte characters', () => { - // Note: \u0A0A could be naively interpreted as two line-feed chars. - const ast = parse(` - # This comment has a \u0A0A multi-byte character. - { field(arg: "Has a \u0A0A multi-byte character.") } - `); - - expect(ast).to.have.nested.property( - 'definitions[0].selectionSet.selections[0].arguments[0].value.value', - 'Has a \u0A0A multi-byte character.', - ); - }); - - it('parses kitchen sink', () => { - expect(() => parse(kitchenSinkQuery)).to.not.throw(); - }); - - it('allows non-keywords anywhere a Name is allowed', () => { - const nonKeywords = [ - 'on', - 'fragment', - 'query', - 'mutation', - 'subscription', - 'true', - 'false', - ]; - for (const keyword of nonKeywords) { - // You can't define or reference a fragment named `on`. - const fragmentName = keyword !== 'on' ? keyword : 'a'; - const document = ` - query ${keyword} { - ... ${fragmentName} - ... on ${keyword} { field } - } - fragment ${fragmentName} on Type { - ${keyword}(${keyword}: $${keyword}) - @${keyword}(${keyword}: ${keyword}) - } - `; - - expect(() => parse(document)).to.not.throw(); - } - }); - - it('parses anonymous mutation operations', () => { - expect(() => - parse(` - mutation { - mutationField - } - `), - ).to.not.throw(); - }); - - it('parses anonymous subscription operations', () => { - expect(() => - parse(` - subscription { - subscriptionField - } - `), - ).to.not.throw(); - }); - - it('parses named mutation operations', () => { - expect(() => - parse(` - mutation Foo { - mutationField - } - `), - ).to.not.throw(); - }); - - it('parses named subscription operations', () => { - expect(() => - parse(` - subscription Foo { - subscriptionField - } - `), - ).to.not.throw(); - }); - - it('creates ast', () => { - const result = parse(dedent` - { - node(id: 4) { - id, - name - } - } - `); - - expectJSON(result).toDeepEqual({ - kind: Kind.DOCUMENT, - loc: { start: 0, end: 40 }, - definitions: [ - { - kind: Kind.OPERATION_DEFINITION, - loc: { start: 0, end: 40 }, - operation: 'query', - name: undefined, - variableDefinitions: [], - directives: [], - selectionSet: { - kind: Kind.SELECTION_SET, - loc: { start: 0, end: 40 }, - selections: [ - { - kind: Kind.FIELD, - loc: { start: 4, end: 38 }, - alias: undefined, - name: { - kind: Kind.NAME, - loc: { start: 4, end: 8 }, - value: 'node', - }, - arguments: [ - { - kind: Kind.ARGUMENT, - name: { - kind: Kind.NAME, - loc: { start: 9, end: 11 }, - value: 'id', - }, - value: { - kind: Kind.INT, - loc: { start: 13, end: 14 }, - value: '4', - }, - loc: { start: 9, end: 14 }, - }, - ], - directives: [], - selectionSet: { - kind: Kind.SELECTION_SET, - loc: { start: 16, end: 38 }, - selections: [ - { - kind: Kind.FIELD, - loc: { start: 22, end: 24 }, - alias: undefined, - name: { - kind: Kind.NAME, - loc: { start: 22, end: 24 }, - value: 'id', - }, - arguments: [], - directives: [], - selectionSet: undefined, - }, - { - kind: Kind.FIELD, - loc: { start: 30, end: 34 }, - alias: undefined, - name: { - kind: Kind.NAME, - loc: { start: 30, end: 34 }, - value: 'name', - }, - arguments: [], - directives: [], - selectionSet: undefined, - }, - ], - }, - }, - ], - }, - }, - ], - }); - }); - - it('creates ast from nameless query without variables', () => { - const result = parse(dedent` - query { - node { - id - } - } - `); - - expectJSON(result).toDeepEqual({ - kind: Kind.DOCUMENT, - loc: { start: 0, end: 29 }, - definitions: [ - { - kind: Kind.OPERATION_DEFINITION, - loc: { start: 0, end: 29 }, - operation: 'query', - name: undefined, - variableDefinitions: [], - directives: [], - selectionSet: { - kind: Kind.SELECTION_SET, - loc: { start: 6, end: 29 }, - selections: [ - { - kind: Kind.FIELD, - loc: { start: 10, end: 27 }, - alias: undefined, - name: { - kind: Kind.NAME, - loc: { start: 10, end: 14 }, - value: 'node', - }, - arguments: [], - directives: [], - selectionSet: { - kind: Kind.SELECTION_SET, - loc: { start: 15, end: 27 }, - selections: [ - { - kind: Kind.FIELD, - loc: { start: 21, end: 23 }, - alias: undefined, - name: { - kind: Kind.NAME, - loc: { start: 21, end: 23 }, - value: 'id', - }, - arguments: [], - directives: [], - selectionSet: undefined, - }, - ], - }, - }, - ], - }, - }, - ], - }); - }); - - it('allows parsing without source location information', () => { - const result = parse('{ id }', { noLocation: true }); - expect('loc' in result).to.equal(false); - }); - - it('Legacy: allows parsing fragment defined variables', () => { - const document = 'fragment a($v: Boolean = false) on t { f(v: $v) }'; - - expect(() => - parse(document, { allowLegacyFragmentVariables: true }), - ).to.not.throw(); - expect(() => parse(document)).to.throw('Syntax Error'); - }); - - it('contains location that can be Object.toStringified, JSON.stringified, or jsutils.inspected', () => { - const { loc } = parse('{ id }'); - - expect(Object.prototype.toString.call(loc)).to.equal('[object Location]'); - expect(JSON.stringify(loc)).to.equal('{"start":0,"end":6}'); - expect(inspect(loc)).to.equal('{ start: 0, end: 6 }'); - }); - - it('contains references to source', () => { - const source = new Source('{ id }'); - const result = parse(source); - - expect(result).to.have.nested.property('loc.source', source); - }); - - it('contains references to start and end tokens', () => { - const result = parse('{ id }'); - - expect(result).to.have.nested.property( - 'loc.startToken.kind', - TokenKind.SOF, - ); - expect(result).to.have.nested.property('loc.endToken.kind', TokenKind.EOF); - }); - - describe('parseValue', () => { - it('parses null value', () => { - const result = parseValue('null'); - expectJSON(result).toDeepEqual({ - kind: Kind.NULL, - loc: { start: 0, end: 4 }, - }); - }); - - it('parses list values', () => { - const result = parseValue('[123 "abc"]'); - expectJSON(result).toDeepEqual({ - kind: Kind.LIST, - loc: { start: 0, end: 11 }, - values: [ - { - kind: Kind.INT, - loc: { start: 1, end: 4 }, - value: '123', - }, - { - kind: Kind.STRING, - loc: { start: 5, end: 10 }, - value: 'abc', - block: false, - }, - ], - }); - }); - - it('parses block strings', () => { - const result = parseValue('["""long""" "short"]'); - expectJSON(result).toDeepEqual({ - kind: Kind.LIST, - loc: { start: 0, end: 20 }, - values: [ - { - kind: Kind.STRING, - loc: { start: 1, end: 11 }, - value: 'long', - block: true, - }, - { - kind: Kind.STRING, - loc: { start: 12, end: 19 }, - value: 'short', - block: false, - }, - ], - }); - }); - - it('allows variables', () => { - const result = parseValue('{ field: $var }'); - expectJSON(result).toDeepEqual({ - kind: Kind.OBJECT, - loc: { start: 0, end: 15 }, - fields: [ - { - kind: Kind.OBJECT_FIELD, - loc: { start: 2, end: 13 }, - name: { - kind: Kind.NAME, - loc: { start: 2, end: 7 }, - value: 'field', - }, - value: { - kind: Kind.VARIABLE, - loc: { start: 9, end: 13 }, - name: { - kind: Kind.NAME, - loc: { start: 10, end: 13 }, - value: 'var', - }, - }, - }, - ], - }); - }); - - it('correct message for incomplete variable', () => { - expect(() => parseValue('$')) - .to.throw() - .to.deep.include({ - message: 'Syntax Error: Expected Name, found .', - locations: [{ line: 1, column: 2 }], - }); - }); - - it('correct message for unexpected token', () => { - expect(() => parseValue(':')) - .to.throw() - .to.deep.include({ - message: 'Syntax Error: Unexpected ":".', - locations: [{ line: 1, column: 1 }], - }); - }); - }); - - describe('parseConstValue', () => { - it('parses values', () => { - const result = parseConstValue('[123 "abc"]'); - expectJSON(result).toDeepEqual({ - kind: Kind.LIST, - loc: { start: 0, end: 11 }, - values: [ - { - kind: Kind.INT, - loc: { start: 1, end: 4 }, - value: '123', - }, - { - kind: Kind.STRING, - loc: { start: 5, end: 10 }, - value: 'abc', - block: false, - }, - ], - }); - }); - - it('does not allow variables', () => { - expect(() => parseConstValue('{ field: $var }')) - .to.throw() - .to.deep.include({ - message: - 'Syntax Error: Unexpected variable "$var" in constant value.', - locations: [{ line: 1, column: 10 }], - }); - }); - - it('correct message for unexpected token', () => { - expect(() => parseConstValue('$')) - .to.throw() - .to.deep.include({ - message: 'Syntax Error: Unexpected "$".', - locations: [{ line: 1, column: 1 }], - }); - }); - }); - - describe('parseType', () => { - it('parses well known types', () => { - const result = parseType('String'); - expectJSON(result).toDeepEqual({ - kind: Kind.NAMED_TYPE, - loc: { start: 0, end: 6 }, - name: { - kind: Kind.NAME, - loc: { start: 0, end: 6 }, - value: 'String', - }, - }); - }); - - it('parses custom types', () => { - const result = parseType('MyType'); - expectJSON(result).toDeepEqual({ - kind: Kind.NAMED_TYPE, - loc: { start: 0, end: 6 }, - name: { - kind: Kind.NAME, - loc: { start: 0, end: 6 }, - value: 'MyType', - }, - }); - }); - - it('parses list types', () => { - const result = parseType('[MyType]'); - expectJSON(result).toDeepEqual({ - kind: Kind.LIST_TYPE, - loc: { start: 0, end: 8 }, - type: { - kind: Kind.NAMED_TYPE, - loc: { start: 1, end: 7 }, - name: { - kind: Kind.NAME, - loc: { start: 1, end: 7 }, - value: 'MyType', - }, - }, - }); - }); - - it('parses non-null types', () => { - const result = parseType('MyType!'); - expectJSON(result).toDeepEqual({ - kind: Kind.NON_NULL_TYPE, - loc: { start: 0, end: 7 }, - type: { - kind: Kind.NAMED_TYPE, - loc: { start: 0, end: 6 }, - name: { - kind: Kind.NAME, - loc: { start: 0, end: 6 }, - value: 'MyType', - }, - }, - }); - }); - - it('parses nested types', () => { - const result = parseType('[MyType!]'); - expectJSON(result).toDeepEqual({ - kind: Kind.LIST_TYPE, - loc: { start: 0, end: 9 }, - type: { - kind: Kind.NON_NULL_TYPE, - loc: { start: 1, end: 8 }, - type: { - kind: Kind.NAMED_TYPE, - loc: { start: 1, end: 7 }, - name: { - kind: Kind.NAME, - loc: { start: 1, end: 7 }, - value: 'MyType', - }, - }, - }, - }); - }); - }); -}); diff --git a/src/language/__tests__/predicates-test.ts b/src/language/__tests__/predicates-test.ts deleted file mode 100644 index 13477f8de9..0000000000 --- a/src/language/__tests__/predicates-test.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import type { ASTNode } from '../ast'; -import { Kind } from '../kinds'; -import { parseValue } from '../parser'; -import { - isConstValueNode, - isDefinitionNode, - isExecutableDefinitionNode, - isSelectionNode, - isTypeDefinitionNode, - isTypeExtensionNode, - isTypeNode, - isTypeSystemDefinitionNode, - isTypeSystemExtensionNode, - isValueNode, -} from '../predicates'; - -function filterNodes(predicate: (node: ASTNode) => boolean): Array { - return Object.values(Kind).filter( - // @ts-expect-error create node only with kind - (kind) => predicate({ kind }), - ); -} - -describe('AST node predicates', () => { - it('isDefinitionNode', () => { - expect(filterNodes(isDefinitionNode)).to.deep.equal([ - 'OperationDefinition', - 'FragmentDefinition', - 'SchemaDefinition', - 'ScalarTypeDefinition', - 'ObjectTypeDefinition', - 'InterfaceTypeDefinition', - 'UnionTypeDefinition', - 'EnumTypeDefinition', - 'InputObjectTypeDefinition', - 'DirectiveDefinition', - 'SchemaExtension', - 'ScalarTypeExtension', - 'ObjectTypeExtension', - 'InterfaceTypeExtension', - 'UnionTypeExtension', - 'EnumTypeExtension', - 'InputObjectTypeExtension', - ]); - }); - - it('isExecutableDefinitionNode', () => { - expect(filterNodes(isExecutableDefinitionNode)).to.deep.equal([ - 'OperationDefinition', - 'FragmentDefinition', - ]); - }); - - it('isSelectionNode', () => { - expect(filterNodes(isSelectionNode)).to.deep.equal([ - 'Field', - 'FragmentSpread', - 'InlineFragment', - ]); - }); - - it('isValueNode', () => { - expect(filterNodes(isValueNode)).to.deep.equal([ - 'Variable', - 'IntValue', - 'FloatValue', - 'StringValue', - 'BooleanValue', - 'NullValue', - 'EnumValue', - 'ListValue', - 'ObjectValue', - ]); - }); - - it('isConstValueNode', () => { - expect(isConstValueNode(parseValue('"value"'))).to.equal(true); - expect(isConstValueNode(parseValue('$var'))).to.equal(false); - - expect(isConstValueNode(parseValue('{ field: "value" }'))).to.equal(true); - expect(isConstValueNode(parseValue('{ field: $var }'))).to.equal(false); - - expect(isConstValueNode(parseValue('[ "value" ]'))).to.equal(true); - expect(isConstValueNode(parseValue('[ $var ]'))).to.equal(false); - }); - - it('isTypeNode', () => { - expect(filterNodes(isTypeNode)).to.deep.equal([ - 'NamedType', - 'ListType', - 'NonNullType', - ]); - }); - - it('isTypeSystemDefinitionNode', () => { - expect(filterNodes(isTypeSystemDefinitionNode)).to.deep.equal([ - 'SchemaDefinition', - 'ScalarTypeDefinition', - 'ObjectTypeDefinition', - 'InterfaceTypeDefinition', - 'UnionTypeDefinition', - 'EnumTypeDefinition', - 'InputObjectTypeDefinition', - 'DirectiveDefinition', - ]); - }); - - it('isTypeDefinitionNode', () => { - expect(filterNodes(isTypeDefinitionNode)).to.deep.equal([ - 'ScalarTypeDefinition', - 'ObjectTypeDefinition', - 'InterfaceTypeDefinition', - 'UnionTypeDefinition', - 'EnumTypeDefinition', - 'InputObjectTypeDefinition', - ]); - }); - - it('isTypeSystemExtensionNode', () => { - expect(filterNodes(isTypeSystemExtensionNode)).to.deep.equal([ - 'SchemaExtension', - 'ScalarTypeExtension', - 'ObjectTypeExtension', - 'InterfaceTypeExtension', - 'UnionTypeExtension', - 'EnumTypeExtension', - 'InputObjectTypeExtension', - ]); - }); - - it('isTypeExtensionNode', () => { - expect(filterNodes(isTypeExtensionNode)).to.deep.equal([ - 'ScalarTypeExtension', - 'ObjectTypeExtension', - 'InterfaceTypeExtension', - 'UnionTypeExtension', - 'EnumTypeExtension', - 'InputObjectTypeExtension', - ]); - }); -}); diff --git a/src/language/__tests__/printLocation-test.ts b/src/language/__tests__/printLocation-test.ts deleted file mode 100644 index c5eac8cce5..0000000000 --- a/src/language/__tests__/printLocation-test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { printSourceLocation } from '../printLocation'; -import { Source } from '../source'; - -describe('printSourceLocation', () => { - it('prints minified documents', () => { - const minifiedSource = new Source( - 'query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String){someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD...on THIRD_ERROR_HERE}}}', - ); - - const firstLocation = printSourceLocation(minifiedSource, { - line: 1, - column: minifiedSource.body.indexOf('FIRST_ERROR_HERE') + 1, - }); - expect(firstLocation).to.equal(dedent` - GraphQL request:1:53 - 1 | query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String) - | ^ - | {someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD. - `); - - const secondLocation = printSourceLocation(minifiedSource, { - line: 1, - column: minifiedSource.body.indexOf('SECOND_ERROR_HERE') + 1, - }); - expect(secondLocation).to.equal(dedent` - GraphQL request:1:114 - 1 | query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String) - | {someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD. - | ^ - | ..on THIRD_ERROR_HERE}}} - `); - - const thirdLocation = printSourceLocation(minifiedSource, { - line: 1, - column: minifiedSource.body.indexOf('THIRD_ERROR_HERE') + 1, - }); - expect(thirdLocation).to.equal(dedent` - GraphQL request:1:166 - 1 | query SomeMinifiedQueryWithErrorInside($foo:String!=FIRST_ERROR_HERE$bar:String) - | {someField(foo:$foo bar:$bar baz:SECOND_ERROR_HERE){fieldA fieldB{fieldC fieldD. - | ..on THIRD_ERROR_HERE}}} - | ^ - `); - }); - - it('prints single digit line number with no padding', () => { - const result = printSourceLocation( - new Source('*', 'Test', { line: 9, column: 1 }), - { line: 1, column: 1 }, - ); - - expect(result).to.equal(dedent` - Test:9:1 - 9 | * - | ^ - `); - }); - - it('prints an line numbers with correct padding', () => { - const result = printSourceLocation( - new Source('*\n', 'Test', { line: 9, column: 1 }), - { line: 1, column: 1 }, - ); - - expect(result).to.equal(dedent` - Test:9:1 - 9 | * - | ^ - 10 | - `); - }); -}); diff --git a/src/language/__tests__/printString-test.ts b/src/language/__tests__/printString-test.ts deleted file mode 100644 index fff1bfeec0..0000000000 --- a/src/language/__tests__/printString-test.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { printString } from '../printString'; - -describe('printString', () => { - it('prints a simple string', () => { - expect(printString('hello world')).to.equal('"hello world"'); - }); - - it('escapes quotes', () => { - expect(printString('"hello world"')).to.equal('"\\"hello world\\""'); - }); - - it('does not escape single quote', () => { - expect(printString("who's test")).to.equal('"who\'s test"'); - }); - - it('escapes backslashes', () => { - expect(printString('escape: \\')).to.equal('"escape: \\\\"'); - }); - - it('escapes well-known control chars', () => { - expect(printString('\b\f\n\r\t')).to.equal('"\\b\\f\\n\\r\\t"'); - }); - - it('escapes zero byte', () => { - expect(printString('\x00')).to.equal('"\\u0000"'); - }); - - it('does not escape space', () => { - expect(printString(' ')).to.equal('" "'); - }); - - it('does not escape non-ascii character', () => { - expect(printString('\u21BB')).to.equal('"\u21BB"'); - }); - - it('does not escape supplementary character', () => { - expect(printString('\u{1f600}')).to.equal('"\u{1f600}"'); - }); - - it('escapes all control chars', () => { - /* spellchecker:ignore abcdefghijklmnopqrstuvwxyz */ - expect( - printString( - '\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007' + - '\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F' + - '\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017' + - '\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F' + - '\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027' + - '\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F' + - '\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037' + - '\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F' + - '\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047' + - '\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F' + - '\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057' + - '\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F' + - '\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067' + - '\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F' + - '\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077' + - '\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F' + - '\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087' + - '\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F' + - '\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097' + - '\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F', - ), - ).to.equal( - '"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007' + - '\\b\\t\\n\\u000B\\f\\r\\u000E\\u000F' + - '\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017' + - '\\u0018\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F' + - ' !\\"#$%&\'()*+,-./0123456789:;<=>?' + - '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_' + - '`abcdefghijklmnopqrstuvwxyz{|}~\\u007F' + - '\\u0080\\u0081\\u0082\\u0083\\u0084\\u0085\\u0086\\u0087' + - '\\u0088\\u0089\\u008A\\u008B\\u008C\\u008D\\u008E\\u008F' + - '\\u0090\\u0091\\u0092\\u0093\\u0094\\u0095\\u0096\\u0097' + - '\\u0098\\u0099\\u009A\\u009B\\u009C\\u009D\\u009E\\u009F"', - ); - }); -}); diff --git a/src/language/__tests__/printer-test.ts b/src/language/__tests__/printer-test.ts deleted file mode 100644 index 227e90dd44..0000000000 --- a/src/language/__tests__/printer-test.ts +++ /dev/null @@ -1,216 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent, dedentString } from '../../__testUtils__/dedent'; -import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery'; - -import { Kind } from '../kinds'; -import { parse } from '../parser'; -import { print } from '../printer'; - -describe('Printer: Query document', () => { - it('prints minimal ast', () => { - const ast = { - kind: Kind.FIELD, - name: { kind: Kind.NAME, value: 'foo' }, - } as const; - expect(print(ast)).to.equal('foo'); - }); - - it('produces helpful error messages', () => { - const badAST = { random: 'Data' }; - - // @ts-expect-error - expect(() => print(badAST)).to.throw( - 'Invalid AST Node: { random: "Data" }.', - ); - }); - - it('correctly prints non-query operations without name', () => { - const queryASTShorthanded = parse('query { id, name }'); - expect(print(queryASTShorthanded)).to.equal(dedent` - { - id - name - } - `); - - const mutationAST = parse('mutation { id, name }'); - expect(print(mutationAST)).to.equal(dedent` - mutation { - id - name - } - `); - - const queryASTWithArtifacts = parse( - 'query ($foo: TestType) @testDirective { id, name }', - ); - expect(print(queryASTWithArtifacts)).to.equal(dedent` - query ($foo: TestType) @testDirective { - id - name - } - `); - - const mutationASTWithArtifacts = parse( - 'mutation ($foo: TestType) @testDirective { id, name }', - ); - expect(print(mutationASTWithArtifacts)).to.equal(dedent` - mutation ($foo: TestType) @testDirective { - id - name - } - `); - }); - - it('prints query with variable directives', () => { - const queryASTWithVariableDirective = parse( - 'query ($foo: TestType = {a: 123} @testDirective(if: true) @test) { id }', - ); - expect(print(queryASTWithVariableDirective)).to.equal(dedent` - query ($foo: TestType = {a: 123} @testDirective(if: true) @test) { - id - } - `); - }); - - it('keeps arguments on one line if line is short (<= 80 chars)', () => { - const printed = print( - parse('{trip(wheelchair:false arriveBy:false){dateTime}}'), - ); - - expect(printed).to.equal(dedent` - { - trip(wheelchair: false, arriveBy: false) { - dateTime - } - } - `); - }); - - it('puts arguments on multiple lines if line is long (> 80 chars)', () => { - const printed = print( - parse( - '{trip(wheelchair:false arriveBy:false includePlannedCancellations:true transitDistanceReluctance:2000){dateTime}}', - ), - ); - - expect(printed).to.equal(dedent` - { - trip( - wheelchair: false - arriveBy: false - includePlannedCancellations: true - transitDistanceReluctance: 2000 - ) { - dateTime - } - } - `); - }); - - it('Legacy: prints fragment with variable directives', () => { - const queryASTWithVariableDirective = parse( - 'fragment Foo($foo: TestType @test) on TestType @testDirective { id }', - { allowLegacyFragmentVariables: true }, - ); - expect(print(queryASTWithVariableDirective)).to.equal(dedent` - fragment Foo($foo: TestType @test) on TestType @testDirective { - id - } - `); - }); - - it('Legacy: correctly prints fragment defined variables', () => { - const fragmentWithVariable = parse( - ` - fragment Foo($a: ComplexType, $b: Boolean = false) on TestType { - id - } - `, - { allowLegacyFragmentVariables: true }, - ); - expect(print(fragmentWithVariable)).to.equal(dedent` - fragment Foo($a: ComplexType, $b: Boolean = false) on TestType { - id - } - `); - }); - - it('prints kitchen sink without altering ast', () => { - const ast = parse(kitchenSinkQuery, { noLocation: true }); - - const astBeforePrintCall = JSON.stringify(ast); - const printed = print(ast); - const printedAST = parse(printed, { noLocation: true }); - - expect(printedAST).to.deep.equal(ast); - expect(JSON.stringify(ast)).to.equal(astBeforePrintCall); - - expect(printed).to.equal( - dedentString(String.raw` - query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery { - whoever123is: node(id: [123, 456]) { - id - ... on User @onInlineFragment { - field2 { - id - alias: field1(first: 10, after: $foo) @include(if: $foo) { - id - ...frag @onFragmentSpread - } - } - } - ... @skip(unless: $foo) { - id - } - ... { - id - } - } - } - - mutation likeStory @onMutation { - like(story: 123) @onField { - story { - id @onField - } - } - } - - subscription StoryLikeSubscription($input: StoryLikeSubscribeInput @onVariableDefinition) @onSubscription { - storyLikeSubscribe(input: $input) { - story { - likers { - count - } - likeSentence { - text - } - } - } - } - - fragment frag on Friend @onFragmentDefinition { - foo( - size: $size - bar: $b - obj: {key: "value", block: """ - block string uses \""" - """} - ) - } - - { - unnamed(truthy: true, falsy: false, nullish: null) - query - } - - { - __typename - } - `), - ); - }); -}); diff --git a/src/language/__tests__/schema-parser-test.ts b/src/language/__tests__/schema-parser-test.ts deleted file mode 100644 index cbb337c337..0000000000 --- a/src/language/__tests__/schema-parser-test.ts +++ /dev/null @@ -1,1106 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { expectJSON, expectToThrowJSON } from '../../__testUtils__/expectJSON'; -import { kitchenSinkSDL } from '../../__testUtils__/kitchenSinkSDL'; - -import { parse } from '../parser'; - -function expectSyntaxError(text: string) { - return expectToThrowJSON(() => parse(text)); -} - -function typeNode(name: unknown, loc: unknown) { - return { - kind: 'NamedType', - name: nameNode(name, loc), - loc, - }; -} - -function nameNode(name: unknown, loc: unknown) { - return { - kind: 'Name', - value: name, - loc, - }; -} - -function fieldNode(name: unknown, type: unknown, loc: unknown) { - return fieldNodeWithArgs(name, type, [], loc); -} - -function fieldNodeWithArgs( - name: unknown, - type: unknown, - args: unknown, - loc: unknown, -) { - return { - kind: 'FieldDefinition', - description: undefined, - name, - arguments: args, - type, - directives: [], - loc, - }; -} - -function enumValueNode(name: unknown, loc: unknown) { - return { - kind: 'EnumValueDefinition', - name: nameNode(name, loc), - description: undefined, - directives: [], - loc, - }; -} - -function inputValueNode( - name: unknown, - type: unknown, - defaultValue: unknown, - loc: unknown, -) { - return { - kind: 'InputValueDefinition', - name, - description: undefined, - type, - defaultValue, - directives: [], - loc, - }; -} - -describe('Schema Parser', () => { - it('Simple type', () => { - const doc = parse(dedent` - type Hello { - world: String - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [], - directives: [], - fields: [ - fieldNode( - nameNode('world', { start: 15, end: 20 }), - typeNode('String', { start: 22, end: 28 }), - { start: 15, end: 28 }, - ), - ], - loc: { start: 0, end: 30 }, - }, - ], - loc: { start: 0, end: 30 }, - }); - }); - - it('parses type with description string', () => { - const doc = parse(dedent` - "Description" - type Hello { - world: String - } - `); - - expectJSON(doc).toDeepNestedProperty('definitions[0].description', { - kind: 'StringValue', - value: 'Description', - block: false, - loc: { start: 0, end: 13 }, - }); - }); - - it('parses type with description multi-line string', () => { - const doc = parse(dedent` - """ - Description - """ - # Even with comments between them - type Hello { - world: String - } - `); - - expectJSON(doc).toDeepNestedProperty('definitions[0].description', { - kind: 'StringValue', - value: 'Description', - block: true, - loc: { start: 0, end: 19 }, - }); - }); - - it('parses schema with description string', () => { - const doc = parse(dedent` - "Description" - schema { - query: Foo - } - `); - - expectJSON(doc).toDeepNestedProperty('definitions[0].description', { - kind: 'StringValue', - value: 'Description', - block: false, - loc: { start: 0, end: 13 }, - }); - }); - - it('Description followed by something other than type system definition throws', () => { - expectSyntaxError('"Description" 1').to.deep.equal({ - message: 'Syntax Error: Unexpected Int "1".', - locations: [{ line: 1, column: 15 }], - }); - }); - - it('Simple extension', () => { - const doc = parse(dedent` - extend type Hello { - world: String - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeExtension', - name: nameNode('Hello', { start: 12, end: 17 }), - interfaces: [], - directives: [], - fields: [ - fieldNode( - nameNode('world', { start: 22, end: 27 }), - typeNode('String', { start: 29, end: 35 }), - { start: 22, end: 35 }, - ), - ], - loc: { start: 0, end: 37 }, - }, - ], - loc: { start: 0, end: 37 }, - }); - }); - - it('Object extension without fields', () => { - const doc = parse('extend type Hello implements Greeting'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeExtension', - name: nameNode('Hello', { start: 12, end: 17 }), - interfaces: [typeNode('Greeting', { start: 29, end: 37 })], - directives: [], - fields: [], - loc: { start: 0, end: 37 }, - }, - ], - loc: { start: 0, end: 37 }, - }); - }); - - it('Interface extension without fields', () => { - const doc = parse('extend interface Hello implements Greeting'); - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'InterfaceTypeExtension', - name: nameNode('Hello', { start: 17, end: 22 }), - interfaces: [typeNode('Greeting', { start: 34, end: 42 })], - directives: [], - fields: [], - loc: { start: 0, end: 42 }, - }, - ], - loc: { start: 0, end: 42 }, - }); - }); - - it('Object extension without fields followed by extension', () => { - const doc = parse(` - extend type Hello implements Greeting - - extend type Hello implements SecondGreeting - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeExtension', - name: nameNode('Hello', { start: 19, end: 24 }), - interfaces: [typeNode('Greeting', { start: 36, end: 44 })], - directives: [], - fields: [], - loc: { start: 7, end: 44 }, - }, - { - kind: 'ObjectTypeExtension', - name: nameNode('Hello', { start: 64, end: 69 }), - interfaces: [typeNode('SecondGreeting', { start: 81, end: 95 })], - directives: [], - fields: [], - loc: { start: 52, end: 95 }, - }, - ], - loc: { start: 0, end: 100 }, - }); - }); - - it('Extension without anything throws', () => { - expectSyntaxError('extend scalar Hello').to.deep.equal({ - message: 'Syntax Error: Unexpected .', - locations: [{ line: 1, column: 20 }], - }); - - expectSyntaxError('extend type Hello').to.deep.equal({ - message: 'Syntax Error: Unexpected .', - locations: [{ line: 1, column: 18 }], - }); - - expectSyntaxError('extend interface Hello').to.deep.equal({ - message: 'Syntax Error: Unexpected .', - locations: [{ line: 1, column: 23 }], - }); - - expectSyntaxError('extend union Hello').to.deep.equal({ - message: 'Syntax Error: Unexpected .', - locations: [{ line: 1, column: 19 }], - }); - - expectSyntaxError('extend enum Hello').to.deep.equal({ - message: 'Syntax Error: Unexpected .', - locations: [{ line: 1, column: 18 }], - }); - - expectSyntaxError('extend input Hello').to.deep.equal({ - message: 'Syntax Error: Unexpected .', - locations: [{ line: 1, column: 19 }], - }); - }); - - it('Interface extension without fields followed by extension', () => { - const doc = parse(` - extend interface Hello implements Greeting - - extend interface Hello implements SecondGreeting - `); - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'InterfaceTypeExtension', - name: nameNode('Hello', { start: 24, end: 29 }), - interfaces: [typeNode('Greeting', { start: 41, end: 49 })], - directives: [], - fields: [], - loc: { start: 7, end: 49 }, - }, - { - kind: 'InterfaceTypeExtension', - name: nameNode('Hello', { start: 74, end: 79 }), - interfaces: [typeNode('SecondGreeting', { start: 91, end: 105 })], - directives: [], - fields: [], - loc: { start: 57, end: 105 }, - }, - ], - loc: { start: 0, end: 110 }, - }); - }); - - it('Object extension do not include descriptions', () => { - expectSyntaxError(` - "Description" - extend type Hello { - world: String - } - `).to.deep.equal({ - message: - 'Syntax Error: Unexpected description, descriptions are supported only on type definitions.', - locations: [{ line: 2, column: 7 }], - }); - - expectSyntaxError(` - extend "Description" type Hello { - world: String - } - `).to.deep.equal({ - message: 'Syntax Error: Unexpected String "Description".', - locations: [{ line: 2, column: 14 }], - }); - }); - - it('Interface extension do not include descriptions', () => { - expectSyntaxError(` - "Description" - extend interface Hello { - world: String - } - `).to.deep.equal({ - message: - 'Syntax Error: Unexpected description, descriptions are supported only on type definitions.', - locations: [{ line: 2, column: 7 }], - }); - - expectSyntaxError(` - extend "Description" interface Hello { - world: String - } - `).to.deep.equal({ - message: 'Syntax Error: Unexpected String "Description".', - locations: [{ line: 2, column: 14 }], - }); - }); - - it('Schema extension', () => { - const body = ` - extend schema { - mutation: Mutation - }`; - const doc = parse(body); - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'SchemaExtension', - directives: [], - operationTypes: [ - { - kind: 'OperationTypeDefinition', - operation: 'mutation', - type: typeNode('Mutation', { start: 41, end: 49 }), - loc: { start: 31, end: 49 }, - }, - ], - loc: { start: 7, end: 57 }, - }, - ], - loc: { start: 0, end: 57 }, - }); - }); - - it('Schema extension with only directives', () => { - const body = 'extend schema @directive'; - const doc = parse(body); - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'SchemaExtension', - directives: [ - { - kind: 'Directive', - name: nameNode('directive', { start: 15, end: 24 }), - arguments: [], - loc: { start: 14, end: 24 }, - }, - ], - operationTypes: [], - loc: { start: 0, end: 24 }, - }, - ], - loc: { start: 0, end: 24 }, - }); - }); - - it('Schema extension without anything throws', () => { - expectSyntaxError('extend schema').to.deep.equal({ - message: 'Syntax Error: Unexpected .', - locations: [{ line: 1, column: 14 }], - }); - }); - - it('Schema extension with invalid operation type throws', () => { - expectSyntaxError('extend schema { unknown: SomeType }').to.deep.equal({ - message: 'Syntax Error: Unexpected Name "unknown".', - locations: [{ line: 1, column: 17 }], - }); - }); - - it('Simple non-null type', () => { - const doc = parse(dedent` - type Hello { - world: String! - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [], - directives: [], - fields: [ - fieldNode( - nameNode('world', { start: 15, end: 20 }), - { - kind: 'NonNullType', - type: typeNode('String', { start: 22, end: 28 }), - loc: { start: 22, end: 29 }, - }, - { start: 15, end: 29 }, - ), - ], - loc: { start: 0, end: 31 }, - }, - ], - loc: { start: 0, end: 31 }, - }); - }); - - it('Simple interface inheriting interface', () => { - const doc = parse('interface Hello implements World { field: String }'); - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'InterfaceTypeDefinition', - name: nameNode('Hello', { start: 10, end: 15 }), - description: undefined, - interfaces: [typeNode('World', { start: 27, end: 32 })], - directives: [], - fields: [ - fieldNode( - nameNode('field', { start: 35, end: 40 }), - typeNode('String', { start: 42, end: 48 }), - { start: 35, end: 48 }, - ), - ], - loc: { start: 0, end: 50 }, - }, - ], - loc: { start: 0, end: 50 }, - }); - }); - - it('Simple type inheriting interface', () => { - const doc = parse('type Hello implements World { field: String }'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [typeNode('World', { start: 22, end: 27 })], - directives: [], - fields: [ - fieldNode( - nameNode('field', { start: 30, end: 35 }), - typeNode('String', { start: 37, end: 43 }), - { start: 30, end: 43 }, - ), - ], - loc: { start: 0, end: 45 }, - }, - ], - loc: { start: 0, end: 45 }, - }); - }); - - it('Simple type inheriting multiple interfaces', () => { - const doc = parse('type Hello implements Wo & rld { field: String }'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [ - typeNode('Wo', { start: 22, end: 24 }), - typeNode('rld', { start: 27, end: 30 }), - ], - directives: [], - fields: [ - fieldNode( - nameNode('field', { start: 33, end: 38 }), - typeNode('String', { start: 40, end: 46 }), - { start: 33, end: 46 }, - ), - ], - loc: { start: 0, end: 48 }, - }, - ], - loc: { start: 0, end: 48 }, - }); - }); - - it('Simple interface inheriting multiple interfaces', () => { - const doc = parse('interface Hello implements Wo & rld { field: String }'); - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'InterfaceTypeDefinition', - name: nameNode('Hello', { start: 10, end: 15 }), - description: undefined, - interfaces: [ - typeNode('Wo', { start: 27, end: 29 }), - typeNode('rld', { start: 32, end: 35 }), - ], - directives: [], - fields: [ - fieldNode( - nameNode('field', { start: 38, end: 43 }), - typeNode('String', { start: 45, end: 51 }), - { start: 38, end: 51 }, - ), - ], - loc: { start: 0, end: 53 }, - }, - ], - loc: { start: 0, end: 53 }, - }); - }); - - it('Simple type inheriting multiple interfaces with leading ampersand', () => { - const doc = parse('type Hello implements & Wo & rld { field: String }'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [ - typeNode('Wo', { start: 24, end: 26 }), - typeNode('rld', { start: 29, end: 32 }), - ], - directives: [], - fields: [ - fieldNode( - nameNode('field', { start: 35, end: 40 }), - typeNode('String', { start: 42, end: 48 }), - { start: 35, end: 48 }, - ), - ], - loc: { start: 0, end: 50 }, - }, - ], - loc: { start: 0, end: 50 }, - }); - }); - - it('Simple interface inheriting multiple interfaces with leading ampersand', () => { - const doc = parse( - 'interface Hello implements & Wo & rld { field: String }', - ); - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'InterfaceTypeDefinition', - name: nameNode('Hello', { start: 10, end: 15 }), - description: undefined, - interfaces: [ - typeNode('Wo', { start: 29, end: 31 }), - typeNode('rld', { start: 34, end: 37 }), - ], - directives: [], - fields: [ - fieldNode( - nameNode('field', { start: 40, end: 45 }), - typeNode('String', { start: 47, end: 53 }), - { start: 40, end: 53 }, - ), - ], - loc: { start: 0, end: 55 }, - }, - ], - loc: { start: 0, end: 55 }, - }); - }); - - it('Single value enum', () => { - const doc = parse('enum Hello { WORLD }'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'EnumTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - directives: [], - values: [enumValueNode('WORLD', { start: 13, end: 18 })], - loc: { start: 0, end: 20 }, - }, - ], - loc: { start: 0, end: 20 }, - }); - }); - - it('Double value enum', () => { - const doc = parse('enum Hello { WO, RLD }'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'EnumTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - directives: [], - values: [ - enumValueNode('WO', { start: 13, end: 15 }), - enumValueNode('RLD', { start: 17, end: 20 }), - ], - loc: { start: 0, end: 22 }, - }, - ], - loc: { start: 0, end: 22 }, - }); - }); - - it('Simple interface', () => { - const doc = parse(dedent` - interface Hello { - world: String - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'InterfaceTypeDefinition', - name: nameNode('Hello', { start: 10, end: 15 }), - description: undefined, - interfaces: [], - directives: [], - fields: [ - fieldNode( - nameNode('world', { start: 20, end: 25 }), - typeNode('String', { start: 27, end: 33 }), - { start: 20, end: 33 }, - ), - ], - loc: { start: 0, end: 35 }, - }, - ], - loc: { start: 0, end: 35 }, - }); - }); - - it('Simple field with arg', () => { - const doc = parse(dedent` - type Hello { - world(flag: Boolean): String - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [], - directives: [], - fields: [ - fieldNodeWithArgs( - nameNode('world', { start: 15, end: 20 }), - typeNode('String', { start: 37, end: 43 }), - [ - inputValueNode( - nameNode('flag', { start: 21, end: 25 }), - typeNode('Boolean', { start: 27, end: 34 }), - undefined, - { start: 21, end: 34 }, - ), - ], - { start: 15, end: 43 }, - ), - ], - loc: { start: 0, end: 45 }, - }, - ], - loc: { start: 0, end: 45 }, - }); - }); - - it('Simple field with arg with default value', () => { - const doc = parse(dedent` - type Hello { - world(flag: Boolean = true): String - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [], - directives: [], - fields: [ - fieldNodeWithArgs( - nameNode('world', { start: 15, end: 20 }), - typeNode('String', { start: 44, end: 50 }), - [ - inputValueNode( - nameNode('flag', { start: 21, end: 25 }), - typeNode('Boolean', { start: 27, end: 34 }), - { - kind: 'BooleanValue', - value: true, - loc: { start: 37, end: 41 }, - }, - { start: 21, end: 41 }, - ), - ], - { start: 15, end: 50 }, - ), - ], - loc: { start: 0, end: 52 }, - }, - ], - loc: { start: 0, end: 52 }, - }); - }); - - it('Simple field with list arg', () => { - const doc = parse(dedent` - type Hello { - world(things: [String]): String - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [], - directives: [], - fields: [ - fieldNodeWithArgs( - nameNode('world', { start: 15, end: 20 }), - typeNode('String', { start: 40, end: 46 }), - [ - inputValueNode( - nameNode('things', { start: 21, end: 27 }), - { - kind: 'ListType', - type: typeNode('String', { start: 30, end: 36 }), - loc: { start: 29, end: 37 }, - }, - undefined, - { start: 21, end: 37 }, - ), - ], - { start: 15, end: 46 }, - ), - ], - loc: { start: 0, end: 48 }, - }, - ], - loc: { start: 0, end: 48 }, - }); - }); - - it('Simple field with two args', () => { - const doc = parse(dedent` - type Hello { - world(argOne: Boolean, argTwo: Int): String - } - `); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ObjectTypeDefinition', - name: nameNode('Hello', { start: 5, end: 10 }), - description: undefined, - interfaces: [], - directives: [], - fields: [ - fieldNodeWithArgs( - nameNode('world', { start: 15, end: 20 }), - typeNode('String', { start: 52, end: 58 }), - [ - inputValueNode( - nameNode('argOne', { start: 21, end: 27 }), - typeNode('Boolean', { start: 29, end: 36 }), - undefined, - { start: 21, end: 36 }, - ), - inputValueNode( - nameNode('argTwo', { start: 38, end: 44 }), - typeNode('Int', { start: 46, end: 49 }), - undefined, - { start: 38, end: 49 }, - ), - ], - { start: 15, end: 58 }, - ), - ], - loc: { start: 0, end: 60 }, - }, - ], - loc: { start: 0, end: 60 }, - }); - }); - - it('Simple union', () => { - const doc = parse('union Hello = World'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'UnionTypeDefinition', - name: nameNode('Hello', { start: 6, end: 11 }), - description: undefined, - directives: [], - types: [typeNode('World', { start: 14, end: 19 })], - loc: { start: 0, end: 19 }, - }, - ], - loc: { start: 0, end: 19 }, - }); - }); - - it('Union with two types', () => { - const doc = parse('union Hello = Wo | Rld'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'UnionTypeDefinition', - name: nameNode('Hello', { start: 6, end: 11 }), - description: undefined, - directives: [], - types: [ - typeNode('Wo', { start: 14, end: 16 }), - typeNode('Rld', { start: 19, end: 22 }), - ], - loc: { start: 0, end: 22 }, - }, - ], - loc: { start: 0, end: 22 }, - }); - }); - - it('Union with two types and leading pipe', () => { - const doc = parse('union Hello = | Wo | Rld'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'UnionTypeDefinition', - name: nameNode('Hello', { start: 6, end: 11 }), - description: undefined, - directives: [], - types: [ - typeNode('Wo', { start: 16, end: 18 }), - typeNode('Rld', { start: 21, end: 24 }), - ], - loc: { start: 0, end: 24 }, - }, - ], - loc: { start: 0, end: 24 }, - }); - }); - - it('Union fails with no types', () => { - expectSyntaxError('union Hello = |').to.deep.equal({ - message: 'Syntax Error: Expected Name, found .', - locations: [{ line: 1, column: 16 }], - }); - }); - - it('Union fails with leading double pipe', () => { - expectSyntaxError('union Hello = || Wo | Rld').to.deep.equal({ - message: 'Syntax Error: Expected Name, found "|".', - locations: [{ line: 1, column: 16 }], - }); - }); - - it('Union fails with double pipe', () => { - expectSyntaxError('union Hello = Wo || Rld').to.deep.equal({ - message: 'Syntax Error: Expected Name, found "|".', - locations: [{ line: 1, column: 19 }], - }); - }); - - it('Union fails with trailing pipe', () => { - expectSyntaxError('union Hello = | Wo | Rld |').to.deep.equal({ - message: 'Syntax Error: Expected Name, found .', - locations: [{ line: 1, column: 27 }], - }); - }); - - it('Scalar', () => { - const doc = parse('scalar Hello'); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'ScalarTypeDefinition', - name: nameNode('Hello', { start: 7, end: 12 }), - description: undefined, - directives: [], - loc: { start: 0, end: 12 }, - }, - ], - loc: { start: 0, end: 12 }, - }); - }); - - it('Simple input object', () => { - const doc = parse(` -input Hello { - world: String -}`); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'InputObjectTypeDefinition', - name: nameNode('Hello', { start: 7, end: 12 }), - description: undefined, - directives: [], - fields: [ - inputValueNode( - nameNode('world', { start: 17, end: 22 }), - typeNode('String', { start: 24, end: 30 }), - undefined, - { start: 17, end: 30 }, - ), - ], - loc: { start: 1, end: 32 }, - }, - ], - loc: { start: 0, end: 32 }, - }); - }); - - it('Simple input object with args should fail', () => { - expectSyntaxError(` - input Hello { - world(foo: Int): String - } - `).to.deep.equal({ - message: 'Syntax Error: Expected ":", found "(".', - locations: [{ line: 3, column: 14 }], - }); - }); - - it('Directive definition', () => { - const body = 'directive @foo on OBJECT | INTERFACE'; - const doc = parse(body); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'DirectiveDefinition', - description: undefined, - name: { - kind: 'Name', - value: 'foo', - loc: { start: 11, end: 14 }, - }, - arguments: [], - repeatable: false, - locations: [ - { - kind: 'Name', - value: 'OBJECT', - loc: { start: 18, end: 24 }, - }, - { - kind: 'Name', - value: 'INTERFACE', - loc: { start: 27, end: 36 }, - }, - ], - loc: { start: 0, end: 36 }, - }, - ], - loc: { start: 0, end: 36 }, - }); - }); - - it('Repeatable directive definition', () => { - const body = 'directive @foo repeatable on OBJECT | INTERFACE'; - const doc = parse(body); - - expectJSON(doc).toDeepEqual({ - kind: 'Document', - definitions: [ - { - kind: 'DirectiveDefinition', - description: undefined, - name: { - kind: 'Name', - value: 'foo', - loc: { start: 11, end: 14 }, - }, - arguments: [], - repeatable: true, - locations: [ - { - kind: 'Name', - value: 'OBJECT', - loc: { start: 29, end: 35 }, - }, - { - kind: 'Name', - value: 'INTERFACE', - loc: { start: 38, end: 47 }, - }, - ], - loc: { start: 0, end: 47 }, - }, - ], - loc: { start: 0, end: 47 }, - }); - }); - - it('Directive with incorrect locations', () => { - expectSyntaxError( - 'directive @foo on FIELD | INCORRECT_LOCATION', - ).to.deep.equal({ - message: 'Syntax Error: Unexpected Name "INCORRECT_LOCATION".', - locations: [{ line: 1, column: 27 }], - }); - }); - - it('parses kitchen sink schema', () => { - expect(() => parse(kitchenSinkSDL)).to.not.throw(); - }); -}); diff --git a/src/language/__tests__/schema-printer-test.ts b/src/language/__tests__/schema-printer-test.ts deleted file mode 100644 index 41cf6c5419..0000000000 --- a/src/language/__tests__/schema-printer-test.ts +++ /dev/null @@ -1,183 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { kitchenSinkSDL } from '../../__testUtils__/kitchenSinkSDL'; - -import { Kind } from '../kinds'; -import { parse } from '../parser'; -import { print } from '../printer'; - -describe('Printer: SDL document', () => { - it('prints minimal ast', () => { - const ast = { - kind: Kind.SCALAR_TYPE_DEFINITION, - name: { kind: Kind.NAME, value: 'foo' }, - } as const; - expect(print(ast)).to.equal('scalar foo'); - }); - - it('produces helpful error messages', () => { - const badAST = { random: 'Data' }; - - // @ts-expect-error - expect(() => print(badAST)).to.throw( - 'Invalid AST Node: { random: "Data" }.', - ); - }); - - it('prints kitchen sink without altering ast', () => { - const ast = parse(kitchenSinkSDL, { noLocation: true }); - - const astBeforePrintCall = JSON.stringify(ast); - const printed = print(ast); - const printedAST = parse(printed, { noLocation: true }); - - expect(printedAST).to.deep.equal(ast); - expect(JSON.stringify(ast)).to.equal(astBeforePrintCall); - - expect(printed).to.equal(dedent` - """This is a description of the schema as a whole.""" - schema { - query: QueryType - mutation: MutationType - } - - """ - This is a description - of the \`Foo\` type. - """ - type Foo implements Bar & Baz & Two { - "Description of the \`one\` field." - one: Type - """This is a description of the \`two\` field.""" - two( - """This is a description of the \`argument\` argument.""" - argument: InputType! - ): Type - """This is a description of the \`three\` field.""" - three(argument: InputType, other: String): Int - four(argument: String = "string"): String - five(argument: [String] = ["string", "string"]): String - six(argument: InputType = {key: "value"}): Type - seven(argument: Int = null): Type - eight(argument: OneOfInputType): Type - } - - type AnnotatedObject @onObject(arg: "value") { - annotatedField(arg: Type = "default" @onArgumentDefinition): Type @onField - } - - type UndefinedType - - extend type Foo { - seven(argument: [String]): Type - } - - extend type Foo @onType - - interface Bar { - one: Type - four(argument: String = "string"): String - } - - interface AnnotatedInterface @onInterface { - annotatedField(arg: Type @onArgumentDefinition): Type @onField - } - - interface UndefinedInterface - - extend interface Bar implements Two { - two(argument: InputType!): Type - } - - extend interface Bar @onInterface - - interface Baz implements Bar & Two { - one: Type - two(argument: InputType!): Type - four(argument: String = "string"): String - } - - union Feed = Story | Article | Advert - - union AnnotatedUnion @onUnion = A | B - - union AnnotatedUnionTwo @onUnion = A | B - - union UndefinedUnion - - extend union Feed = Photo | Video - - extend union Feed @onUnion - - scalar CustomScalar - - scalar AnnotatedScalar @onScalar - - extend scalar CustomScalar @onScalar - - enum Site { - """This is a description of the \`DESKTOP\` value""" - DESKTOP - """This is a description of the \`MOBILE\` value""" - MOBILE - "This is a description of the \`WEB\` value" - WEB - } - - enum AnnotatedEnum @onEnum { - ANNOTATED_VALUE @onEnumValue - OTHER_VALUE - } - - enum UndefinedEnum - - extend enum Site { - VR - } - - extend enum Site @onEnum - - input InputType { - key: String! - answer: Int = 42 - } - - input OneOfInputType @oneOf { - string: String - int: Int - } - - input AnnotatedInput @onInputObject { - annotatedField: Type @onInputFieldDefinition - } - - input UndefinedInput - - extend input InputType { - other: Float = 1.23e4 @onInputFieldDefinition - } - - extend input InputType @onInputObject - - """This is a description of the \`@skip\` directive""" - directive @skip( - """This is a description of the \`if\` argument""" - if: Boolean! @onArgumentDefinition - ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - - directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - - directive @include2(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - - directive @myRepeatableDir(name: String!) repeatable on OBJECT | INTERFACE - - extend schema @onSchema - - extend schema @onSchema { - subscription: SubscriptionType - } - `); - }); -}); diff --git a/src/language/__tests__/source-test.ts b/src/language/__tests__/source-test.ts deleted file mode 100644 index 6bf8a93e6d..0000000000 --- a/src/language/__tests__/source-test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { Source } from '../source'; - -describe('Source', () => { - it('asserts that a body was provided', () => { - // @ts-expect-error - expect(() => new Source()).to.throw( - 'Body must be a string. Received: undefined.', - ); - }); - - it('asserts that a valid body was provided', () => { - // @ts-expect-error - expect(() => new Source({})).to.throw( - 'Body must be a string. Received: {}.', - ); - }); - - it('can be Object.toStringified', () => { - const source = new Source(''); - - expect(Object.prototype.toString.call(source)).to.equal('[object Source]'); - }); - - it('rejects invalid locationOffset', () => { - function createSource(locationOffset: { line: number; column: number }) { - return new Source('', '', locationOffset); - } - - expect(() => createSource({ line: 0, column: 1 })).to.throw( - 'line in locationOffset is 1-indexed and must be positive.', - ); - expect(() => createSource({ line: -1, column: 1 })).to.throw( - 'line in locationOffset is 1-indexed and must be positive.', - ); - - expect(() => createSource({ line: 1, column: 0 })).to.throw( - 'column in locationOffset is 1-indexed and must be positive.', - ); - expect(() => createSource({ line: 1, column: -1 })).to.throw( - 'column in locationOffset is 1-indexed and must be positive.', - ); - }); -}); diff --git a/src/language/__tests__/visitor-test.ts b/src/language/__tests__/visitor-test.ts deleted file mode 100644 index 9149b103e3..0000000000 --- a/src/language/__tests__/visitor-test.ts +++ /dev/null @@ -1,1364 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery'; - -import type { ASTNode, SelectionSetNode } from '../ast'; -import { isNode } from '../ast'; -import { Kind } from '../kinds'; -import { parse } from '../parser'; -import type { ASTVisitor, ASTVisitorKeyMap } from '../visitor'; -import { BREAK, visit, visitInParallel } from '../visitor'; - -function checkVisitorFnArgs(ast: any, args: any, isEdited: boolean = false) { - const [node, key, parent, path, ancestors] = args; - - expect(node).to.be.an.instanceof(Object); - expect(node.kind).to.be.oneOf(Object.values(Kind)); - - const isRoot = key === undefined; - if (isRoot) { - if (!isEdited) { - expect(node).to.equal(ast); - } - expect(parent).to.equal(undefined); - expect(path).to.deep.equal([]); - expect(ancestors).to.deep.equal([]); - return; - } - - expect(typeof key).to.be.oneOf(['number', 'string']); - - expect(parent).to.have.property(key); - - expect(path).to.be.an.instanceof(Array); - expect(path[path.length - 1]).to.equal(key); - - expect(ancestors).to.be.an.instanceof(Array); - expect(ancestors.length).to.equal(path.length - 1); - - if (!isEdited) { - let currentNode = ast; - for (let i = 0; i < ancestors.length; ++i) { - expect(ancestors[i]).to.equal(currentNode); - - currentNode = currentNode[path[i]]; - expect(currentNode).to.not.equal(undefined); - } - - expect(parent).to.equal(currentNode); - expect(parent[key]).to.equal(node); - } -} - -function getValue(node: ASTNode) { - return 'value' in node ? node.value : undefined; -} - -describe('Visitor', () => { - it('handles empty visitor', () => { - const ast = parse('{ a }', { noLocation: true }); - expect(() => visit(ast, {})).to.not.throw(); - }); - - it('validates path argument', () => { - const visited: Array = []; - - const ast = parse('{ a }', { noLocation: true }); - - visit(ast, { - enter(_node, _key, _parent, path) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', path.slice()]); - }, - leave(_node, _key, _parent, path) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', path.slice()]); - }, - }); - - expect(visited).to.deep.equal([ - ['enter', []], - ['enter', ['definitions', 0]], - ['enter', ['definitions', 0, 'selectionSet']], - ['enter', ['definitions', 0, 'selectionSet', 'selections', 0]], - ['enter', ['definitions', 0, 'selectionSet', 'selections', 0, 'name']], - ['leave', ['definitions', 0, 'selectionSet', 'selections', 0, 'name']], - ['leave', ['definitions', 0, 'selectionSet', 'selections', 0]], - ['leave', ['definitions', 0, 'selectionSet']], - ['leave', ['definitions', 0]], - ['leave', []], - ]); - }); - - it('validates ancestors argument', () => { - const ast = parse('{ a }', { noLocation: true }); - const visitedNodes: Array = []; - - visit(ast, { - enter(node, key, parent, _path, ancestors) { - const inArray = typeof key === 'number'; - if (inArray) { - visitedNodes.push(parent); - } - visitedNodes.push(node); - - const expectedAncestors = visitedNodes.slice(0, -2); - expect(ancestors).to.deep.equal(expectedAncestors); - }, - leave(_node, key, _parent, _path, ancestors) { - const expectedAncestors = visitedNodes.slice(0, -2); - expect(ancestors).to.deep.equal(expectedAncestors); - - const inArray = typeof key === 'number'; - if (inArray) { - visitedNodes.pop(); - } - visitedNodes.pop(); - }, - }); - }); - - it('allows editing a node both on enter and on leave', () => { - const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true }); - - let selectionSet: SelectionSetNode; - - const editedAST = visit(ast, { - OperationDefinition: { - enter(node) { - checkVisitorFnArgs(ast, arguments); - selectionSet = node.selectionSet; - return { - ...node, - selectionSet: { - kind: 'SelectionSet', - selections: [], - }, - didEnter: true, - }; - }, - leave(node) { - checkVisitorFnArgs(ast, arguments, /* isEdited */ true); - return { - ...node, - selectionSet, - didLeave: true, - }; - }, - }, - }); - - expect(editedAST).to.deep.equal({ - ...ast, - definitions: [ - { - ...ast.definitions[0], - didEnter: true, - didLeave: true, - }, - ], - }); - }); - - it('allows editing the root node on enter and on leave', () => { - const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true }); - - const { definitions } = ast; - - const editedAST = visit(ast, { - Document: { - enter(node) { - checkVisitorFnArgs(ast, arguments); - return { - ...node, - definitions: [], - didEnter: true, - }; - }, - leave(node) { - checkVisitorFnArgs(ast, arguments, /* isEdited */ true); - return { - ...node, - definitions, - didLeave: true, - }; - }, - }, - }); - - expect(editedAST).to.deep.equal({ - ...ast, - didEnter: true, - didLeave: true, - }); - }); - - it('allows for editing on enter', () => { - const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true }); - const editedAST = visit(ast, { - enter(node) { - checkVisitorFnArgs(ast, arguments); - if (node.kind === 'Field' && node.name.value === 'b') { - return null; - } - }, - }); - - expect(ast).to.deep.equal( - parse('{ a, b, c { a, b, c } }', { noLocation: true }), - ); - - expect(editedAST).to.deep.equal( - parse('{ a, c { a, c } }', { noLocation: true }), - ); - }); - - it('allows for editing on leave', () => { - const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true }); - const editedAST = visit(ast, { - leave(node) { - checkVisitorFnArgs(ast, arguments, /* isEdited */ true); - if (node.kind === 'Field' && node.name.value === 'b') { - return null; - } - }, - }); - - expect(ast).to.deep.equal( - parse('{ a, b, c { a, b, c } }', { noLocation: true }), - ); - - expect(editedAST).to.deep.equal( - parse('{ a, c { a, c } }', { noLocation: true }), - ); - }); - - it('ignores false returned on leave', () => { - const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true }); - const returnedAST = visit(ast, { - leave() { - return false; - }, - }); - - expect(returnedAST).to.deep.equal( - parse('{ a, b, c { a, b, c } }', { noLocation: true }), - ); - }); - - it('visits edited node', () => { - const addedField = { - kind: 'Field', - name: { - kind: 'Name', - value: '__typename', - }, - }; - - let didVisitAddedField; - - const ast = parse('{ a { x } }', { noLocation: true }); - visit(ast, { - enter(node) { - checkVisitorFnArgs(ast, arguments, /* isEdited */ true); - if (node.kind === 'Field' && node.name.value === 'a') { - return { - kind: 'Field', - selectionSet: [addedField, node.selectionSet], - }; - } - if (node === addedField) { - didVisitAddedField = true; - } - }, - }); - - expect(didVisitAddedField).to.equal(true); - }); - - it('allows skipping a sub-tree', () => { - const visited: Array = []; - - const ast = parse('{ a, b { x }, c }', { noLocation: true }); - visit(ast, { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - if (node.kind === 'Field' && node.name.value === 'b') { - return false; - } - }, - - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - }, - }); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'c'], - ['leave', 'Name', 'c'], - ['leave', 'Field', undefined], - ['leave', 'SelectionSet', undefined], - ['leave', 'OperationDefinition', undefined], - ['leave', 'Document', undefined], - ]); - }); - - it('allows early exit while visiting', () => { - const visited: Array = []; - - const ast = parse('{ a, b { x }, c }', { noLocation: true }); - visit(ast, { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - if (node.kind === 'Name' && node.value === 'x') { - return BREAK; - } - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - }, - }); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'b'], - ['leave', 'Name', 'b'], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'x'], - ]); - }); - - it('allows early exit while leaving', () => { - const visited: Array = []; - - const ast = parse('{ a, b { x }, c }', { noLocation: true }); - visit(ast, { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - }, - - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - if (node.kind === 'Name' && node.value === 'x') { - return BREAK; - } - }, - }); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'b'], - ['leave', 'Name', 'b'], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'x'], - ['leave', 'Name', 'x'], - ]); - }); - - it('allows a named functions visitor API', () => { - const visited: Array = []; - - const ast = parse('{ a, b { x }, c }', { noLocation: true }); - visit(ast, { - Name(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - }, - SelectionSet: { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - }, - }, - }); - - expect(visited).to.deep.equal([ - ['enter', 'SelectionSet', undefined], - ['enter', 'Name', 'a'], - ['enter', 'Name', 'b'], - ['enter', 'SelectionSet', undefined], - ['enter', 'Name', 'x'], - ['leave', 'SelectionSet', undefined], - ['enter', 'Name', 'c'], - ['leave', 'SelectionSet', undefined], - ]); - }); - - it('visits only the specified `Kind` in visitorKeyMap', () => { - const visited: Array = []; - - const visitorKeyMap: ASTVisitorKeyMap = { - Document: ['definitions'], - OperationDefinition: ['name'], - }; - - const visitor: ASTVisitor = { - enter(node) { - visited.push(['enter', node.kind, getValue(node)]); - }, - leave(node) { - visited.push(['leave', node.kind, getValue(node)]); - }, - }; - - const exampleDocumentAST = parse(` - query ExampleOperation { - someField - } - `); - - visit(exampleDocumentAST, visitor, visitorKeyMap); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'Name', 'ExampleOperation'], - ['leave', 'Name', 'ExampleOperation'], - ['leave', 'OperationDefinition', undefined], - ['leave', 'Document', undefined], - ]); - }); - - it('Legacy: visits variables defined in fragments', () => { - const ast = parse('fragment a($v: Boolean = false) on t { f }', { - noLocation: true, - allowLegacyFragmentVariables: true, - }); - const visited: Array = []; - - visit(ast, { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - }, - }); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'FragmentDefinition', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['enter', 'VariableDefinition', undefined], - ['enter', 'Variable', undefined], - ['enter', 'Name', 'v'], - ['leave', 'Name', 'v'], - ['leave', 'Variable', undefined], - ['enter', 'NamedType', undefined], - ['enter', 'Name', 'Boolean'], - ['leave', 'Name', 'Boolean'], - ['leave', 'NamedType', undefined], - ['enter', 'BooleanValue', false], - ['leave', 'BooleanValue', false], - ['leave', 'VariableDefinition', undefined], - ['enter', 'NamedType', undefined], - ['enter', 'Name', 't'], - ['leave', 'Name', 't'], - ['leave', 'NamedType', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'f'], - ['leave', 'Name', 'f'], - ['leave', 'Field', undefined], - ['leave', 'SelectionSet', undefined], - ['leave', 'FragmentDefinition', undefined], - ['leave', 'Document', undefined], - ]); - }); - - it('visits kitchen sink', () => { - const ast = parse(kitchenSinkQuery); - const visited: Array = []; - const argsStack: Array = []; - - visit(ast, { - enter(node, key, parent) { - visited.push([ - 'enter', - node.kind, - key, - isNode(parent) ? parent.kind : undefined, - ]); - - checkVisitorFnArgs(ast, arguments); - argsStack.push([...arguments]); - }, - - leave(node, key, parent) { - visited.push([ - 'leave', - node.kind, - key, - isNode(parent) ? parent.kind : undefined, - ]); - - expect(argsStack.pop()).to.deep.equal([...arguments]); - }, - }); - - expect(argsStack).to.deep.equal([]); - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined, undefined], - ['enter', 'OperationDefinition', 0, undefined], - ['enter', 'Name', 'name', 'OperationDefinition'], - ['leave', 'Name', 'name', 'OperationDefinition'], - ['enter', 'VariableDefinition', 0, undefined], - ['enter', 'Variable', 'variable', 'VariableDefinition'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'variable', 'VariableDefinition'], - ['enter', 'NamedType', 'type', 'VariableDefinition'], - ['enter', 'Name', 'name', 'NamedType'], - ['leave', 'Name', 'name', 'NamedType'], - ['leave', 'NamedType', 'type', 'VariableDefinition'], - ['leave', 'VariableDefinition', 0, undefined], - ['enter', 'VariableDefinition', 1, undefined], - ['enter', 'Variable', 'variable', 'VariableDefinition'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'variable', 'VariableDefinition'], - ['enter', 'NamedType', 'type', 'VariableDefinition'], - ['enter', 'Name', 'name', 'NamedType'], - ['leave', 'Name', 'name', 'NamedType'], - ['leave', 'NamedType', 'type', 'VariableDefinition'], - ['enter', 'EnumValue', 'defaultValue', 'VariableDefinition'], - ['leave', 'EnumValue', 'defaultValue', 'VariableDefinition'], - ['leave', 'VariableDefinition', 1, undefined], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'alias', 'Field'], - ['leave', 'Name', 'alias', 'Field'], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'ListValue', 'value', 'Argument'], - ['enter', 'IntValue', 0, undefined], - ['leave', 'IntValue', 0, undefined], - ['enter', 'IntValue', 1, undefined], - ['leave', 'IntValue', 1, undefined], - ['leave', 'ListValue', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['enter', 'InlineFragment', 1, undefined], - ['enter', 'NamedType', 'typeCondition', 'InlineFragment'], - ['enter', 'Name', 'name', 'NamedType'], - ['leave', 'Name', 'name', 'NamedType'], - ['leave', 'NamedType', 'typeCondition', 'InlineFragment'], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'InlineFragment'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['enter', 'Field', 1, undefined], - ['enter', 'Name', 'alias', 'Field'], - ['leave', 'Name', 'alias', 'Field'], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'IntValue', 'value', 'Argument'], - ['leave', 'IntValue', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['enter', 'Argument', 1, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'Variable', 'value', 'Argument'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'value', 'Argument'], - ['leave', 'Argument', 1, undefined], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'Variable', 'value', 'Argument'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['enter', 'FragmentSpread', 1, undefined], - ['enter', 'Name', 'name', 'FragmentSpread'], - ['leave', 'Name', 'name', 'FragmentSpread'], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['leave', 'FragmentSpread', 1, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 1, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'InlineFragment'], - ['leave', 'InlineFragment', 1, undefined], - ['enter', 'InlineFragment', 2, undefined], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'Variable', 'value', 'Argument'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'InlineFragment'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'InlineFragment'], - ['leave', 'InlineFragment', 2, undefined], - ['enter', 'InlineFragment', 3, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'InlineFragment'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'InlineFragment'], - ['leave', 'InlineFragment', 3, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['leave', 'OperationDefinition', 0, undefined], - ['enter', 'OperationDefinition', 1, undefined], - ['enter', 'Name', 'name', 'OperationDefinition'], - ['leave', 'Name', 'name', 'OperationDefinition'], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'IntValue', 'value', 'Argument'], - ['leave', 'IntValue', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['leave', 'OperationDefinition', 1, undefined], - ['enter', 'OperationDefinition', 2, undefined], - ['enter', 'Name', 'name', 'OperationDefinition'], - ['leave', 'Name', 'name', 'OperationDefinition'], - ['enter', 'VariableDefinition', 0, undefined], - ['enter', 'Variable', 'variable', 'VariableDefinition'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'variable', 'VariableDefinition'], - ['enter', 'NamedType', 'type', 'VariableDefinition'], - ['enter', 'Name', 'name', 'NamedType'], - ['leave', 'Name', 'name', 'NamedType'], - ['leave', 'NamedType', 'type', 'VariableDefinition'], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['leave', 'VariableDefinition', 0, undefined], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'Variable', 'value', 'Argument'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 0, undefined], - ['enter', 'Field', 1, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'SelectionSet', 'selectionSet', 'Field'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 1, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['leave', 'OperationDefinition', 2, undefined], - ['enter', 'FragmentDefinition', 3, undefined], - ['enter', 'Name', 'name', 'FragmentDefinition'], - ['leave', 'Name', 'name', 'FragmentDefinition'], - ['enter', 'NamedType', 'typeCondition', 'FragmentDefinition'], - ['enter', 'Name', 'name', 'NamedType'], - ['leave', 'Name', 'name', 'NamedType'], - ['leave', 'NamedType', 'typeCondition', 'FragmentDefinition'], - ['enter', 'Directive', 0, undefined], - ['enter', 'Name', 'name', 'Directive'], - ['leave', 'Name', 'name', 'Directive'], - ['leave', 'Directive', 0, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'FragmentDefinition'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'Variable', 'value', 'Argument'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['enter', 'Argument', 1, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'Variable', 'value', 'Argument'], - ['enter', 'Name', 'name', 'Variable'], - ['leave', 'Name', 'name', 'Variable'], - ['leave', 'Variable', 'value', 'Argument'], - ['leave', 'Argument', 1, undefined], - ['enter', 'Argument', 2, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'ObjectValue', 'value', 'Argument'], - ['enter', 'ObjectField', 0, undefined], - ['enter', 'Name', 'name', 'ObjectField'], - ['leave', 'Name', 'name', 'ObjectField'], - ['enter', 'StringValue', 'value', 'ObjectField'], - ['leave', 'StringValue', 'value', 'ObjectField'], - ['leave', 'ObjectField', 0, undefined], - ['enter', 'ObjectField', 1, undefined], - ['enter', 'Name', 'name', 'ObjectField'], - ['leave', 'Name', 'name', 'ObjectField'], - ['enter', 'StringValue', 'value', 'ObjectField'], - ['leave', 'StringValue', 'value', 'ObjectField'], - ['leave', 'ObjectField', 1, undefined], - ['leave', 'ObjectValue', 'value', 'Argument'], - ['leave', 'Argument', 2, undefined], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'FragmentDefinition'], - ['leave', 'FragmentDefinition', 3, undefined], - ['enter', 'OperationDefinition', 4, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['enter', 'Argument', 0, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'BooleanValue', 'value', 'Argument'], - ['leave', 'BooleanValue', 'value', 'Argument'], - ['leave', 'Argument', 0, undefined], - ['enter', 'Argument', 1, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'BooleanValue', 'value', 'Argument'], - ['leave', 'BooleanValue', 'value', 'Argument'], - ['leave', 'Argument', 1, undefined], - ['enter', 'Argument', 2, undefined], - ['enter', 'Name', 'name', 'Argument'], - ['leave', 'Name', 'name', 'Argument'], - ['enter', 'NullValue', 'value', 'Argument'], - ['leave', 'NullValue', 'value', 'Argument'], - ['leave', 'Argument', 2, undefined], - ['leave', 'Field', 0, undefined], - ['enter', 'Field', 1, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 1, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['leave', 'OperationDefinition', 4, undefined], - ['enter', 'OperationDefinition', 5, undefined], - ['enter', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['enter', 'Field', 0, undefined], - ['enter', 'Name', 'name', 'Field'], - ['leave', 'Name', 'name', 'Field'], - ['leave', 'Field', 0, undefined], - ['leave', 'SelectionSet', 'selectionSet', 'OperationDefinition'], - ['leave', 'OperationDefinition', 5, undefined], - ['leave', 'Document', undefined, undefined], - ]); - }); - - describe('visitInParallel', () => { - // Note: nearly identical to the above test of the same test but - // using visitInParallel. - it('allows skipping a sub-tree', () => { - const visited: Array = []; - - const ast = parse('{ a, b { x }, c }'); - visit( - ast, - visitInParallel([ - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - if (node.kind === 'Field' && node.name.value === 'b') { - return false; - } - }, - - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - }, - }, - ]), - ); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'c'], - ['leave', 'Name', 'c'], - ['leave', 'Field', undefined], - ['leave', 'SelectionSet', undefined], - ['leave', 'OperationDefinition', undefined], - ['leave', 'Document', undefined], - ]); - }); - - it('allows skipping different sub-trees', () => { - const visited: Array = []; - - const ast = parse('{ a { x }, b { y} }'); - visit( - ast, - visitInParallel([ - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['no-a', 'enter', node.kind, getValue(node)]); - if (node.kind === 'Field' && node.name.value === 'a') { - return false; - } - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['no-a', 'leave', node.kind, getValue(node)]); - }, - }, - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['no-b', 'enter', node.kind, getValue(node)]); - if (node.kind === 'Field' && node.name.value === 'b') { - return false; - } - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['no-b', 'leave', node.kind, getValue(node)]); - }, - }, - ]), - ); - - expect(visited).to.deep.equal([ - ['no-a', 'enter', 'Document', undefined], - ['no-b', 'enter', 'Document', undefined], - ['no-a', 'enter', 'OperationDefinition', undefined], - ['no-b', 'enter', 'OperationDefinition', undefined], - ['no-a', 'enter', 'SelectionSet', undefined], - ['no-b', 'enter', 'SelectionSet', undefined], - ['no-a', 'enter', 'Field', undefined], - ['no-b', 'enter', 'Field', undefined], - ['no-b', 'enter', 'Name', 'a'], - ['no-b', 'leave', 'Name', 'a'], - ['no-b', 'enter', 'SelectionSet', undefined], - ['no-b', 'enter', 'Field', undefined], - ['no-b', 'enter', 'Name', 'x'], - ['no-b', 'leave', 'Name', 'x'], - ['no-b', 'leave', 'Field', undefined], - ['no-b', 'leave', 'SelectionSet', undefined], - ['no-b', 'leave', 'Field', undefined], - ['no-a', 'enter', 'Field', undefined], - ['no-b', 'enter', 'Field', undefined], - ['no-a', 'enter', 'Name', 'b'], - ['no-a', 'leave', 'Name', 'b'], - ['no-a', 'enter', 'SelectionSet', undefined], - ['no-a', 'enter', 'Field', undefined], - ['no-a', 'enter', 'Name', 'y'], - ['no-a', 'leave', 'Name', 'y'], - ['no-a', 'leave', 'Field', undefined], - ['no-a', 'leave', 'SelectionSet', undefined], - ['no-a', 'leave', 'Field', undefined], - ['no-a', 'leave', 'SelectionSet', undefined], - ['no-b', 'leave', 'SelectionSet', undefined], - ['no-a', 'leave', 'OperationDefinition', undefined], - ['no-b', 'leave', 'OperationDefinition', undefined], - ['no-a', 'leave', 'Document', undefined], - ['no-b', 'leave', 'Document', undefined], - ]); - }); - - // Note: nearly identical to the above test of the same test but - // using visitInParallel. - it('allows early exit while visiting', () => { - const visited: Array = []; - - const ast = parse('{ a, b { x }, c }'); - visit( - ast, - visitInParallel([ - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - if (node.kind === 'Name' && node.value === 'x') { - return BREAK; - } - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - }, - }, - ]), - ); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'b'], - ['leave', 'Name', 'b'], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'x'], - ]); - }); - - it('allows early exit from different points', () => { - const visited: Array = []; - - const ast = parse('{ a { y }, b { x } }'); - visit( - ast, - visitInParallel([ - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['break-a', 'enter', node.kind, getValue(node)]); - if (node.kind === 'Name' && node.value === 'a') { - return BREAK; - } - }, - /* c8 ignore next 3 */ - leave() { - expect.fail('Should not be called'); - }, - }, - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['break-b', 'enter', node.kind, getValue(node)]); - if (node.kind === 'Name' && node.value === 'b') { - return BREAK; - } - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['break-b', 'leave', node.kind, getValue(node)]); - }, - }, - ]), - ); - - expect(visited).to.deep.equal([ - ['break-a', 'enter', 'Document', undefined], - ['break-b', 'enter', 'Document', undefined], - ['break-a', 'enter', 'OperationDefinition', undefined], - ['break-b', 'enter', 'OperationDefinition', undefined], - ['break-a', 'enter', 'SelectionSet', undefined], - ['break-b', 'enter', 'SelectionSet', undefined], - ['break-a', 'enter', 'Field', undefined], - ['break-b', 'enter', 'Field', undefined], - ['break-a', 'enter', 'Name', 'a'], - ['break-b', 'enter', 'Name', 'a'], - ['break-b', 'leave', 'Name', 'a'], - ['break-b', 'enter', 'SelectionSet', undefined], - ['break-b', 'enter', 'Field', undefined], - ['break-b', 'enter', 'Name', 'y'], - ['break-b', 'leave', 'Name', 'y'], - ['break-b', 'leave', 'Field', undefined], - ['break-b', 'leave', 'SelectionSet', undefined], - ['break-b', 'leave', 'Field', undefined], - ['break-b', 'enter', 'Field', undefined], - ['break-b', 'enter', 'Name', 'b'], - ]); - }); - - // Note: nearly identical to the above test of the same test but - // using visitInParallel. - it('allows early exit while leaving', () => { - const visited: Array = []; - - const ast = parse('{ a, b { x }, c }'); - visit( - ast, - visitInParallel([ - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['leave', node.kind, getValue(node)]); - if (node.kind === 'Name' && node.value === 'x') { - return BREAK; - } - }, - }, - ]), - ); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'b'], - ['leave', 'Name', 'b'], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'x'], - ['leave', 'Name', 'x'], - ]); - }); - - it('allows early exit from leaving different points', () => { - const visited: Array = []; - - const ast = parse('{ a { y }, b { x } }'); - visit( - ast, - visitInParallel([ - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['break-a', 'enter', node.kind, getValue(node)]); - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['break-a', 'leave', node.kind, getValue(node)]); - if (node.kind === 'Field' && node.name.value === 'a') { - return BREAK; - } - }, - }, - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['break-b', 'enter', node.kind, getValue(node)]); - }, - leave(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['break-b', 'leave', node.kind, getValue(node)]); - if (node.kind === 'Field' && node.name.value === 'b') { - return BREAK; - } - }, - }, - ]), - ); - - expect(visited).to.deep.equal([ - ['break-a', 'enter', 'Document', undefined], - ['break-b', 'enter', 'Document', undefined], - ['break-a', 'enter', 'OperationDefinition', undefined], - ['break-b', 'enter', 'OperationDefinition', undefined], - ['break-a', 'enter', 'SelectionSet', undefined], - ['break-b', 'enter', 'SelectionSet', undefined], - ['break-a', 'enter', 'Field', undefined], - ['break-b', 'enter', 'Field', undefined], - ['break-a', 'enter', 'Name', 'a'], - ['break-b', 'enter', 'Name', 'a'], - ['break-a', 'leave', 'Name', 'a'], - ['break-b', 'leave', 'Name', 'a'], - ['break-a', 'enter', 'SelectionSet', undefined], - ['break-b', 'enter', 'SelectionSet', undefined], - ['break-a', 'enter', 'Field', undefined], - ['break-b', 'enter', 'Field', undefined], - ['break-a', 'enter', 'Name', 'y'], - ['break-b', 'enter', 'Name', 'y'], - ['break-a', 'leave', 'Name', 'y'], - ['break-b', 'leave', 'Name', 'y'], - ['break-a', 'leave', 'Field', undefined], - ['break-b', 'leave', 'Field', undefined], - ['break-a', 'leave', 'SelectionSet', undefined], - ['break-b', 'leave', 'SelectionSet', undefined], - ['break-a', 'leave', 'Field', undefined], - ['break-b', 'leave', 'Field', undefined], - ['break-b', 'enter', 'Field', undefined], - ['break-b', 'enter', 'Name', 'b'], - ['break-b', 'leave', 'Name', 'b'], - ['break-b', 'enter', 'SelectionSet', undefined], - ['break-b', 'enter', 'Field', undefined], - ['break-b', 'enter', 'Name', 'x'], - ['break-b', 'leave', 'Name', 'x'], - ['break-b', 'leave', 'Field', undefined], - ['break-b', 'leave', 'SelectionSet', undefined], - ['break-b', 'leave', 'Field', undefined], - ]); - }); - - it('allows for editing on enter', () => { - const visited: Array = []; - - const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true }); - const editedAST = visit( - ast, - visitInParallel([ - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - if (node.kind === 'Field' && node.name.value === 'b') { - return null; - } - }, - }, - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - }, - leave(node) { - checkVisitorFnArgs(ast, arguments, /* isEdited */ true); - visited.push(['leave', node.kind, getValue(node)]); - }, - }, - ]), - ); - - expect(ast).to.deep.equal( - parse('{ a, b, c { a, b, c } }', { noLocation: true }), - ); - - expect(editedAST).to.deep.equal( - parse('{ a, c { a, c } }', { noLocation: true }), - ); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'c'], - ['leave', 'Name', 'c'], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'c'], - ['leave', 'Name', 'c'], - ['leave', 'Field', undefined], - ['leave', 'SelectionSet', undefined], - ['leave', 'Field', undefined], - ['leave', 'SelectionSet', undefined], - ['leave', 'OperationDefinition', undefined], - ['leave', 'Document', undefined], - ]); - }); - - it('allows for editing on leave', () => { - const visited: Array = []; - - const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true }); - const editedAST = visit( - ast, - visitInParallel([ - { - leave(node) { - checkVisitorFnArgs(ast, arguments, /* isEdited */ true); - if (node.kind === 'Field' && node.name.value === 'b') { - return null; - } - }, - }, - { - enter(node) { - checkVisitorFnArgs(ast, arguments); - visited.push(['enter', node.kind, getValue(node)]); - }, - leave(node) { - checkVisitorFnArgs(ast, arguments, /* isEdited */ true); - visited.push(['leave', node.kind, getValue(node)]); - }, - }, - ]), - ); - - expect(ast).to.deep.equal( - parse('{ a, b, c { a, b, c } }', { noLocation: true }), - ); - - expect(editedAST).to.deep.equal( - parse('{ a, c { a, c } }', { noLocation: true }), - ); - - expect(visited).to.deep.equal([ - ['enter', 'Document', undefined], - ['enter', 'OperationDefinition', undefined], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'b'], - ['leave', 'Name', 'b'], - ['enter', 'Field', undefined], - ['enter', 'Name', 'c'], - ['leave', 'Name', 'c'], - ['enter', 'SelectionSet', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'a'], - ['leave', 'Name', 'a'], - ['leave', 'Field', undefined], - ['enter', 'Field', undefined], - ['enter', 'Name', 'b'], - ['leave', 'Name', 'b'], - ['enter', 'Field', undefined], - ['enter', 'Name', 'c'], - ['leave', 'Name', 'c'], - ['leave', 'Field', undefined], - ['leave', 'SelectionSet', undefined], - ['leave', 'Field', undefined], - ['leave', 'SelectionSet', undefined], - ['leave', 'OperationDefinition', undefined], - ['leave', 'Document', undefined], - ]); - }); - }); -}); diff --git a/src/language/ast.ts b/src/language/ast.ts deleted file mode 100644 index 6137eb6c1a..0000000000 --- a/src/language/ast.ts +++ /dev/null @@ -1,739 +0,0 @@ -import type { Kind } from './kinds'; -import type { Source } from './source'; -import type { TokenKind } from './tokenKind'; - -/** - * Contains a range of UTF-8 character offsets and token references that - * identify the region of the source from which the AST derived. - */ -export class Location { - /** - * The character offset at which this Node begins. - */ - readonly start: number; - - /** - * The character offset at which this Node ends. - */ - readonly end: number; - - /** - * The Token at which this Node begins. - */ - readonly startToken: Token; - - /** - * The Token at which this Node ends. - */ - readonly endToken: Token; - - /** - * The Source document the AST represents. - */ - readonly source: Source; - - constructor(startToken: Token, endToken: Token, source: Source) { - this.start = startToken.start; - this.end = endToken.end; - this.startToken = startToken; - this.endToken = endToken; - this.source = source; - } - - get [Symbol.toStringTag]() { - return 'Location'; - } - - toJSON(): { start: number; end: number } { - return { start: this.start, end: this.end }; - } -} - -/** - * Represents a range of characters represented by a lexical token - * within a Source. - */ -export class Token { - /** - * The kind of Token. - */ - readonly kind: TokenKind; - - /** - * The character offset at which this Node begins. - */ - readonly start: number; - - /** - * The character offset at which this Node ends. - */ - readonly end: number; - - /** - * The 1-indexed line number on which this Token appears. - */ - readonly line: number; - - /** - * The 1-indexed column number at which this Token begins. - */ - readonly column: number; - - /** - * For non-punctuation tokens, represents the interpreted value of the token. - * - * Note: is undefined for punctuation tokens, but typed as string for - * convenience in the parser. - */ - readonly value: string; - - /** - * Tokens exist as nodes in a double-linked-list amongst all tokens - * including ignored tokens. is always the first node and - * the last. - */ - readonly prev: Token | null; - readonly next: Token | null; - - constructor( - kind: TokenKind, - start: number, - end: number, - line: number, - column: number, - value?: string, - ) { - this.kind = kind; - this.start = start; - this.end = end; - this.line = line; - this.column = column; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - this.value = value!; - this.prev = null; - this.next = null; - } - - get [Symbol.toStringTag]() { - return 'Token'; - } - - toJSON(): { - kind: TokenKind; - value?: string; - line: number; - column: number; - } { - return { - kind: this.kind, - value: this.value, - line: this.line, - column: this.column, - }; - } -} - -/** - * The list of all possible AST node types. - */ -export type ASTNode = - | NameNode - | DocumentNode - | OperationDefinitionNode - | VariableDefinitionNode - | VariableNode - | SelectionSetNode - | FieldNode - | ArgumentNode - | FragmentSpreadNode - | InlineFragmentNode - | FragmentDefinitionNode - | IntValueNode - | FloatValueNode - | StringValueNode - | BooleanValueNode - | NullValueNode - | EnumValueNode - | ListValueNode - | ObjectValueNode - | ObjectFieldNode - | DirectiveNode - | NamedTypeNode - | ListTypeNode - | NonNullTypeNode - | SchemaDefinitionNode - | OperationTypeDefinitionNode - | ScalarTypeDefinitionNode - | ObjectTypeDefinitionNode - | FieldDefinitionNode - | InputValueDefinitionNode - | InterfaceTypeDefinitionNode - | UnionTypeDefinitionNode - | EnumTypeDefinitionNode - | EnumValueDefinitionNode - | InputObjectTypeDefinitionNode - | DirectiveDefinitionNode - | SchemaExtensionNode - | ScalarTypeExtensionNode - | ObjectTypeExtensionNode - | InterfaceTypeExtensionNode - | UnionTypeExtensionNode - | EnumTypeExtensionNode - | InputObjectTypeExtensionNode; - -/** - * Utility type listing all nodes indexed by their kind. - */ -export type ASTKindToNode = { - [NodeT in ASTNode as NodeT['kind']]: NodeT; -}; - -/** - * @internal - */ -export const QueryDocumentKeys: { - [NodeT in ASTNode as NodeT['kind']]: ReadonlyArray; -} = { - Name: [], - - Document: ['definitions'], - OperationDefinition: [ - 'name', - 'variableDefinitions', - 'directives', - 'selectionSet', - ], - VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], - Variable: ['name'], - SelectionSet: ['selections'], - Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], - Argument: ['name', 'value'], - - FragmentSpread: ['name', 'directives'], - InlineFragment: ['typeCondition', 'directives', 'selectionSet'], - FragmentDefinition: [ - 'name', - // Note: fragment variable definitions are deprecated and will removed in v17.0.0 - 'variableDefinitions', - 'typeCondition', - 'directives', - 'selectionSet', - ], - - IntValue: [], - FloatValue: [], - StringValue: [], - BooleanValue: [], - NullValue: [], - EnumValue: [], - ListValue: ['values'], - ObjectValue: ['fields'], - ObjectField: ['name', 'value'], - - Directive: ['name', 'arguments'], - - NamedType: ['name'], - ListType: ['type'], - NonNullType: ['type'], - - SchemaDefinition: ['description', 'directives', 'operationTypes'], - OperationTypeDefinition: ['type'], - - ScalarTypeDefinition: ['description', 'name', 'directives'], - ObjectTypeDefinition: [ - 'description', - 'name', - 'interfaces', - 'directives', - 'fields', - ], - FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'], - InputValueDefinition: [ - 'description', - 'name', - 'type', - 'defaultValue', - 'directives', - ], - InterfaceTypeDefinition: [ - 'description', - 'name', - 'interfaces', - 'directives', - 'fields', - ], - UnionTypeDefinition: ['description', 'name', 'directives', 'types'], - EnumTypeDefinition: ['description', 'name', 'directives', 'values'], - EnumValueDefinition: ['description', 'name', 'directives'], - InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'], - - DirectiveDefinition: ['description', 'name', 'arguments', 'locations'], - - SchemaExtension: ['directives', 'operationTypes'], - - ScalarTypeExtension: ['name', 'directives'], - ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'], - InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'], - UnionTypeExtension: ['name', 'directives', 'types'], - EnumTypeExtension: ['name', 'directives', 'values'], - InputObjectTypeExtension: ['name', 'directives', 'fields'], -}; - -const kindValues = new Set(Object.keys(QueryDocumentKeys)); -/** - * @internal - */ -export function isNode(maybeNode: any): maybeNode is ASTNode { - const maybeKind = maybeNode?.kind; - return typeof maybeKind === 'string' && kindValues.has(maybeKind); -} - -/** Name */ - -export interface NameNode { - readonly kind: Kind.NAME; - readonly loc?: Location; - readonly value: string; -} - -/** Document */ - -export interface DocumentNode { - readonly kind: Kind.DOCUMENT; - readonly loc?: Location; - readonly definitions: ReadonlyArray; - readonly tokenCount?: number | undefined; -} - -export type DefinitionNode = - | ExecutableDefinitionNode - | TypeSystemDefinitionNode - | TypeSystemExtensionNode; - -export type ExecutableDefinitionNode = - | OperationDefinitionNode - | FragmentDefinitionNode; - -export interface OperationDefinitionNode { - readonly kind: Kind.OPERATION_DEFINITION; - readonly loc?: Location; - readonly operation: OperationTypeNode; - readonly name?: NameNode; - readonly variableDefinitions?: ReadonlyArray; - readonly directives?: ReadonlyArray; - readonly selectionSet: SelectionSetNode; -} - -enum OperationTypeNode { - QUERY = 'query', - MUTATION = 'mutation', - SUBSCRIPTION = 'subscription', -} -export { OperationTypeNode }; - -export interface VariableDefinitionNode { - readonly kind: Kind.VARIABLE_DEFINITION; - readonly loc?: Location; - readonly variable: VariableNode; - readonly type: TypeNode; - readonly defaultValue?: ConstValueNode; - readonly directives?: ReadonlyArray; -} - -export interface VariableNode { - readonly kind: Kind.VARIABLE; - readonly loc?: Location; - readonly name: NameNode; -} - -export interface SelectionSetNode { - kind: Kind.SELECTION_SET; - loc?: Location; - selections: ReadonlyArray; -} - -export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode; - -export interface FieldNode { - readonly kind: Kind.FIELD; - readonly loc?: Location; - readonly alias?: NameNode; - readonly name: NameNode; - readonly arguments?: ReadonlyArray; - readonly directives?: ReadonlyArray; - readonly selectionSet?: SelectionSetNode; -} - -export interface ArgumentNode { - readonly kind: Kind.ARGUMENT; - readonly loc?: Location; - readonly name: NameNode; - readonly value: ValueNode; -} - -export interface ConstArgumentNode { - readonly kind: Kind.ARGUMENT; - readonly loc?: Location; - readonly name: NameNode; - readonly value: ConstValueNode; -} - -/** Fragments */ - -export interface FragmentSpreadNode { - readonly kind: Kind.FRAGMENT_SPREAD; - readonly loc?: Location; - readonly name: NameNode; - readonly directives?: ReadonlyArray; -} - -export interface InlineFragmentNode { - readonly kind: Kind.INLINE_FRAGMENT; - readonly loc?: Location; - readonly typeCondition?: NamedTypeNode; - readonly directives?: ReadonlyArray; - readonly selectionSet: SelectionSetNode; -} - -export interface FragmentDefinitionNode { - readonly kind: Kind.FRAGMENT_DEFINITION; - readonly loc?: Location; - readonly name: NameNode; - /** @deprecated variableDefinitions will be removed in v17.0.0 */ - readonly variableDefinitions?: ReadonlyArray; - readonly typeCondition: NamedTypeNode; - readonly directives?: ReadonlyArray; - readonly selectionSet: SelectionSetNode; -} - -/** Values */ - -export type ValueNode = - | VariableNode - | IntValueNode - | FloatValueNode - | StringValueNode - | BooleanValueNode - | NullValueNode - | EnumValueNode - | ListValueNode - | ObjectValueNode; - -export type ConstValueNode = - | IntValueNode - | FloatValueNode - | StringValueNode - | BooleanValueNode - | NullValueNode - | EnumValueNode - | ConstListValueNode - | ConstObjectValueNode; - -export interface IntValueNode { - readonly kind: Kind.INT; - readonly loc?: Location; - readonly value: string; -} - -export interface FloatValueNode { - readonly kind: Kind.FLOAT; - readonly loc?: Location; - readonly value: string; -} - -export interface StringValueNode { - readonly kind: Kind.STRING; - readonly loc?: Location; - readonly value: string; - readonly block?: boolean; -} - -export interface BooleanValueNode { - readonly kind: Kind.BOOLEAN; - readonly loc?: Location; - readonly value: boolean; -} - -export interface NullValueNode { - readonly kind: Kind.NULL; - readonly loc?: Location; -} - -export interface EnumValueNode { - readonly kind: Kind.ENUM; - readonly loc?: Location; - readonly value: string; -} - -export interface ListValueNode { - readonly kind: Kind.LIST; - readonly loc?: Location; - readonly values: ReadonlyArray; -} - -export interface ConstListValueNode { - readonly kind: Kind.LIST; - readonly loc?: Location; - readonly values: ReadonlyArray; -} - -export interface ObjectValueNode { - readonly kind: Kind.OBJECT; - readonly loc?: Location; - readonly fields: ReadonlyArray; -} - -export interface ConstObjectValueNode { - readonly kind: Kind.OBJECT; - readonly loc?: Location; - readonly fields: ReadonlyArray; -} - -export interface ObjectFieldNode { - readonly kind: Kind.OBJECT_FIELD; - readonly loc?: Location; - readonly name: NameNode; - readonly value: ValueNode; -} - -export interface ConstObjectFieldNode { - readonly kind: Kind.OBJECT_FIELD; - readonly loc?: Location; - readonly name: NameNode; - readonly value: ConstValueNode; -} - -/** Directives */ - -export interface DirectiveNode { - readonly kind: Kind.DIRECTIVE; - readonly loc?: Location; - readonly name: NameNode; - readonly arguments?: ReadonlyArray; -} - -export interface ConstDirectiveNode { - readonly kind: Kind.DIRECTIVE; - readonly loc?: Location; - readonly name: NameNode; - readonly arguments?: ReadonlyArray; -} - -/** Type Reference */ - -export type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode; - -export interface NamedTypeNode { - readonly kind: Kind.NAMED_TYPE; - readonly loc?: Location; - readonly name: NameNode; -} - -export interface ListTypeNode { - readonly kind: Kind.LIST_TYPE; - readonly loc?: Location; - readonly type: TypeNode; -} - -export interface NonNullTypeNode { - readonly kind: Kind.NON_NULL_TYPE; - readonly loc?: Location; - readonly type: NamedTypeNode | ListTypeNode; -} - -/** Type System Definition */ - -export type TypeSystemDefinitionNode = - | SchemaDefinitionNode - | TypeDefinitionNode - | DirectiveDefinitionNode; - -export interface SchemaDefinitionNode { - readonly kind: Kind.SCHEMA_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly directives?: ReadonlyArray; - readonly operationTypes: ReadonlyArray; -} - -export interface OperationTypeDefinitionNode { - readonly kind: Kind.OPERATION_TYPE_DEFINITION; - readonly loc?: Location; - readonly operation: OperationTypeNode; - readonly type: NamedTypeNode; -} - -/** Type Definition */ - -export type TypeDefinitionNode = - | ScalarTypeDefinitionNode - | ObjectTypeDefinitionNode - | InterfaceTypeDefinitionNode - | UnionTypeDefinitionNode - | EnumTypeDefinitionNode - | InputObjectTypeDefinitionNode; - -export interface ScalarTypeDefinitionNode { - readonly kind: Kind.SCALAR_TYPE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly directives?: ReadonlyArray; -} - -export interface ObjectTypeDefinitionNode { - readonly kind: Kind.OBJECT_TYPE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly interfaces?: ReadonlyArray; - readonly directives?: ReadonlyArray; - readonly fields?: ReadonlyArray; -} - -export interface FieldDefinitionNode { - readonly kind: Kind.FIELD_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly arguments?: ReadonlyArray; - readonly type: TypeNode; - readonly directives?: ReadonlyArray; -} - -export interface InputValueDefinitionNode { - readonly kind: Kind.INPUT_VALUE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly type: TypeNode; - readonly defaultValue?: ConstValueNode; - readonly directives?: ReadonlyArray; -} - -export interface InterfaceTypeDefinitionNode { - readonly kind: Kind.INTERFACE_TYPE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly interfaces?: ReadonlyArray; - readonly directives?: ReadonlyArray; - readonly fields?: ReadonlyArray; -} - -export interface UnionTypeDefinitionNode { - readonly kind: Kind.UNION_TYPE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly directives?: ReadonlyArray; - readonly types?: ReadonlyArray; -} - -export interface EnumTypeDefinitionNode { - readonly kind: Kind.ENUM_TYPE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly directives?: ReadonlyArray; - readonly values?: ReadonlyArray; -} - -export interface EnumValueDefinitionNode { - readonly kind: Kind.ENUM_VALUE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly directives?: ReadonlyArray; -} - -export interface InputObjectTypeDefinitionNode { - readonly kind: Kind.INPUT_OBJECT_TYPE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly directives?: ReadonlyArray; - readonly fields?: ReadonlyArray; -} - -/** Directive Definitions */ - -export interface DirectiveDefinitionNode { - readonly kind: Kind.DIRECTIVE_DEFINITION; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly arguments?: ReadonlyArray; - readonly repeatable: boolean; - readonly locations: ReadonlyArray; -} - -/** Type System Extensions */ - -export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode; - -export interface SchemaExtensionNode { - readonly kind: Kind.SCHEMA_EXTENSION; - readonly loc?: Location; - readonly directives?: ReadonlyArray; - readonly operationTypes?: ReadonlyArray; -} - -/** Type Extensions */ - -export type TypeExtensionNode = - | ScalarTypeExtensionNode - | ObjectTypeExtensionNode - | InterfaceTypeExtensionNode - | UnionTypeExtensionNode - | EnumTypeExtensionNode - | InputObjectTypeExtensionNode; - -export interface ScalarTypeExtensionNode { - readonly kind: Kind.SCALAR_TYPE_EXTENSION; - readonly loc?: Location; - readonly name: NameNode; - readonly directives?: ReadonlyArray; -} - -export interface ObjectTypeExtensionNode { - readonly kind: Kind.OBJECT_TYPE_EXTENSION; - readonly loc?: Location; - readonly name: NameNode; - readonly interfaces?: ReadonlyArray; - readonly directives?: ReadonlyArray; - readonly fields?: ReadonlyArray; -} - -export interface InterfaceTypeExtensionNode { - readonly kind: Kind.INTERFACE_TYPE_EXTENSION; - readonly loc?: Location; - readonly name: NameNode; - readonly interfaces?: ReadonlyArray; - readonly directives?: ReadonlyArray; - readonly fields?: ReadonlyArray; -} - -export interface UnionTypeExtensionNode { - readonly kind: Kind.UNION_TYPE_EXTENSION; - readonly loc?: Location; - readonly name: NameNode; - readonly directives?: ReadonlyArray; - readonly types?: ReadonlyArray; -} - -export interface EnumTypeExtensionNode { - readonly kind: Kind.ENUM_TYPE_EXTENSION; - readonly loc?: Location; - readonly name: NameNode; - readonly directives?: ReadonlyArray; - readonly values?: ReadonlyArray; -} - -export interface InputObjectTypeExtensionNode { - readonly kind: Kind.INPUT_OBJECT_TYPE_EXTENSION; - readonly loc?: Location; - readonly name: NameNode; - readonly directives?: ReadonlyArray; - readonly fields?: ReadonlyArray; -} diff --git a/src/language/blockString.ts b/src/language/blockString.ts deleted file mode 100644 index 1c200c183a..0000000000 --- a/src/language/blockString.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { isWhiteSpace } from './characterClasses'; - -/** - * Produces the value of a block string from its parsed raw value, similar to - * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. - * - * This implements the GraphQL spec's BlockStringValue() static algorithm. - * - * @internal - */ -export function dedentBlockStringLines( - lines: ReadonlyArray, -): Array { - let commonIndent = Number.MAX_SAFE_INTEGER; - let firstNonEmptyLine = null; - let lastNonEmptyLine = -1; - - for (let i = 0; i < lines.length; ++i) { - const line = lines[i]; - const indent = leadingWhitespace(line); - - if (indent === line.length) { - continue; // skip empty lines - } - - firstNonEmptyLine = firstNonEmptyLine ?? i; - lastNonEmptyLine = i; - - if (i !== 0 && indent < commonIndent) { - commonIndent = indent; - } - } - - return ( - lines - // Remove common indentation from all lines but first. - .map((line, i) => (i === 0 ? line : line.slice(commonIndent))) - // Remove leading and trailing blank lines. - .slice(firstNonEmptyLine ?? 0, lastNonEmptyLine + 1) - ); -} - -function leadingWhitespace(str: string): number { - let i = 0; - while (i < str.length && isWhiteSpace(str.charCodeAt(i))) { - ++i; - } - return i; -} - -/** - * @internal - */ -export function isPrintableAsBlockString(value: string): boolean { - if (value === '') { - return true; // empty string is printable - } - - let isEmptyLine = true; - let hasIndent = false; - let hasCommonIndent = true; - let seenNonEmptyLine = false; - - for (let i = 0; i < value.length; ++i) { - switch (value.codePointAt(i)) { - case 0x0000: - case 0x0001: - case 0x0002: - case 0x0003: - case 0x0004: - case 0x0005: - case 0x0006: - case 0x0007: - case 0x0008: - case 0x000b: - case 0x000c: - case 0x000e: - case 0x000f: - return false; // Has non-printable characters - - case 0x000d: // \r - return false; // Has \r or \r\n which will be replaced as \n - - case 10: // \n - if (isEmptyLine && !seenNonEmptyLine) { - return false; // Has leading new line - } - seenNonEmptyLine = true; - - isEmptyLine = true; - hasIndent = false; - break; - case 9: // \t - case 32: // - hasIndent ||= isEmptyLine; - break; - default: - hasCommonIndent &&= hasIndent; - isEmptyLine = false; - } - } - - if (isEmptyLine) { - return false; // Has trailing empty lines - } - - if (hasCommonIndent && seenNonEmptyLine) { - return false; // Has internal indent - } - - return true; -} - -/** - * Print a block string in the indented block form by adding a leading and - * trailing blank line. However, if a block string starts with whitespace and is - * a single-line, adding a leading blank line would strip that whitespace. - * - * @internal - */ -export function printBlockString( - value: string, - options?: { minimize?: boolean }, -): string { - const escapedValue = value.replace(/"""/g, '\\"""'); - - // Expand a block string's raw value into independent lines. - const lines = escapedValue.split(/\r\n|[\n\r]/g); - const isSingleLine = lines.length === 1; - - // If common indentation is found we can fix some of those cases by adding leading new line - const forceLeadingNewLine = - lines.length > 1 && - lines - .slice(1) - .every((line) => line.length === 0 || isWhiteSpace(line.charCodeAt(0))); - - // Trailing triple quotes just looks confusing but doesn't force trailing new line - const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""'); - - // Trailing quote (single or double) or slash forces trailing new line - const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes; - const hasTrailingSlash = value.endsWith('\\'); - const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash; - - const printAsMultipleLines = - !options?.minimize && - // add leading and trailing new lines only if it improves readability - (!isSingleLine || - value.length > 70 || - forceTrailingNewline || - forceLeadingNewLine || - hasTrailingTripleQuotes); - - let result = ''; - - // Format a multi-line block quote to account for leading space. - const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0)); - if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) { - result += '\n'; - } - - result += escapedValue; - if (printAsMultipleLines || forceTrailingNewline) { - result += '\n'; - } - - return '"""' + result + '"""'; -} diff --git a/src/language/characterClasses.ts b/src/language/characterClasses.ts deleted file mode 100644 index c1182d10da..0000000000 --- a/src/language/characterClasses.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * ``` - * WhiteSpace :: - * - "Horizontal Tab (U+0009)" - * - "Space (U+0020)" - * ``` - * @internal - */ -export function isWhiteSpace(code: number): boolean { - return code === 0x0009 || code === 0x0020; -} - -/** - * ``` - * Digit :: one of - * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` - * ``` - * @internal - */ -export function isDigit(code: number): boolean { - return code >= 0x0030 && code <= 0x0039; -} - -/** - * ``` - * Letter :: one of - * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M` - * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z` - * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m` - * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z` - * ``` - * @internal - */ -export function isLetter(code: number): boolean { - return ( - (code >= 0x0061 && code <= 0x007a) || // A-Z - (code >= 0x0041 && code <= 0x005a) // a-z - ); -} - -/** - * ``` - * NameStart :: - * - Letter - * - `_` - * ``` - * @internal - */ -export function isNameStart(code: number): boolean { - return isLetter(code) || code === 0x005f; -} - -/** - * ``` - * NameContinue :: - * - Letter - * - Digit - * - `_` - * ``` - * @internal - */ -export function isNameContinue(code: number): boolean { - return isLetter(code) || isDigit(code) || code === 0x005f; -} diff --git a/src/language/directiveLocation.ts b/src/language/directiveLocation.ts deleted file mode 100644 index 5c8aeb7240..0000000000 --- a/src/language/directiveLocation.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * The set of allowed directive location values. - */ -enum DirectiveLocation { - /** Request Definitions */ - QUERY = 'QUERY', - MUTATION = 'MUTATION', - SUBSCRIPTION = 'SUBSCRIPTION', - FIELD = 'FIELD', - FRAGMENT_DEFINITION = 'FRAGMENT_DEFINITION', - FRAGMENT_SPREAD = 'FRAGMENT_SPREAD', - INLINE_FRAGMENT = 'INLINE_FRAGMENT', - VARIABLE_DEFINITION = 'VARIABLE_DEFINITION', - /** Type System Definitions */ - SCHEMA = 'SCHEMA', - SCALAR = 'SCALAR', - OBJECT = 'OBJECT', - FIELD_DEFINITION = 'FIELD_DEFINITION', - ARGUMENT_DEFINITION = 'ARGUMENT_DEFINITION', - INTERFACE = 'INTERFACE', - UNION = 'UNION', - ENUM = 'ENUM', - ENUM_VALUE = 'ENUM_VALUE', - INPUT_OBJECT = 'INPUT_OBJECT', - INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION', -} -export { DirectiveLocation }; - -/** - * The enum type representing the directive location values. - * - * @deprecated Please use `DirectiveLocation`. Will be remove in v17. - */ -export type DirectiveLocationEnum = typeof DirectiveLocation; diff --git a/src/language/index.ts b/src/language/index.ts deleted file mode 100644 index ec4d195e1a..0000000000 --- a/src/language/index.ts +++ /dev/null @@ -1,109 +0,0 @@ -export { Source } from './source'; - -export { getLocation } from './location'; -export type { SourceLocation } from './location'; - -export { printLocation, printSourceLocation } from './printLocation'; - -export { Kind } from './kinds'; -export type { KindEnum } from './kinds'; - -export { TokenKind } from './tokenKind'; -export type { TokenKindEnum } from './tokenKind'; - -export { Lexer } from './lexer'; - -export { parse, parseValue, parseConstValue, parseType } from './parser'; -export type { ParseOptions } from './parser'; - -export { print } from './printer'; - -export { - visit, - visitInParallel, - getVisitFn, - getEnterLeaveForKind, - BREAK, -} from './visitor'; -export type { ASTVisitor, ASTVisitFn, ASTVisitorKeyMap } from './visitor'; - -export { Location, Token, OperationTypeNode } from './ast'; -export type { - ASTNode, - ASTKindToNode, - // Each kind of AST node - NameNode, - DocumentNode, - DefinitionNode, - ExecutableDefinitionNode, - OperationDefinitionNode, - VariableDefinitionNode, - VariableNode, - SelectionSetNode, - SelectionNode, - FieldNode, - ArgumentNode, - ConstArgumentNode, - FragmentSpreadNode, - InlineFragmentNode, - FragmentDefinitionNode, - ValueNode, - ConstValueNode, - IntValueNode, - FloatValueNode, - StringValueNode, - BooleanValueNode, - NullValueNode, - EnumValueNode, - ListValueNode, - ConstListValueNode, - ObjectValueNode, - ConstObjectValueNode, - ObjectFieldNode, - ConstObjectFieldNode, - DirectiveNode, - ConstDirectiveNode, - TypeNode, - NamedTypeNode, - ListTypeNode, - NonNullTypeNode, - TypeSystemDefinitionNode, - SchemaDefinitionNode, - OperationTypeDefinitionNode, - TypeDefinitionNode, - ScalarTypeDefinitionNode, - ObjectTypeDefinitionNode, - FieldDefinitionNode, - InputValueDefinitionNode, - InterfaceTypeDefinitionNode, - UnionTypeDefinitionNode, - EnumTypeDefinitionNode, - EnumValueDefinitionNode, - InputObjectTypeDefinitionNode, - DirectiveDefinitionNode, - TypeSystemExtensionNode, - SchemaExtensionNode, - TypeExtensionNode, - ScalarTypeExtensionNode, - ObjectTypeExtensionNode, - InterfaceTypeExtensionNode, - UnionTypeExtensionNode, - EnumTypeExtensionNode, - InputObjectTypeExtensionNode, -} from './ast'; - -export { - isDefinitionNode, - isExecutableDefinitionNode, - isSelectionNode, - isValueNode, - isConstValueNode, - isTypeNode, - isTypeSystemDefinitionNode, - isTypeDefinitionNode, - isTypeSystemExtensionNode, - isTypeExtensionNode, -} from './predicates'; - -export { DirectiveLocation } from './directiveLocation'; -export type { DirectiveLocationEnum } from './directiveLocation'; diff --git a/src/language/kinds.ts b/src/language/kinds.ts deleted file mode 100644 index cd05f66a3b..0000000000 --- a/src/language/kinds.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * The set of allowed kind values for AST nodes. - */ -enum Kind { - /** Name */ - NAME = 'Name', - - /** Document */ - DOCUMENT = 'Document', - OPERATION_DEFINITION = 'OperationDefinition', - VARIABLE_DEFINITION = 'VariableDefinition', - SELECTION_SET = 'SelectionSet', - FIELD = 'Field', - ARGUMENT = 'Argument', - - /** Fragments */ - FRAGMENT_SPREAD = 'FragmentSpread', - INLINE_FRAGMENT = 'InlineFragment', - FRAGMENT_DEFINITION = 'FragmentDefinition', - - /** Values */ - VARIABLE = 'Variable', - INT = 'IntValue', - FLOAT = 'FloatValue', - STRING = 'StringValue', - BOOLEAN = 'BooleanValue', - NULL = 'NullValue', - ENUM = 'EnumValue', - LIST = 'ListValue', - OBJECT = 'ObjectValue', - OBJECT_FIELD = 'ObjectField', - - /** Directives */ - DIRECTIVE = 'Directive', - - /** Types */ - NAMED_TYPE = 'NamedType', - LIST_TYPE = 'ListType', - NON_NULL_TYPE = 'NonNullType', - - /** Type System Definitions */ - SCHEMA_DEFINITION = 'SchemaDefinition', - OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition', - - /** Type Definitions */ - SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition', - OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition', - FIELD_DEFINITION = 'FieldDefinition', - INPUT_VALUE_DEFINITION = 'InputValueDefinition', - INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition', - UNION_TYPE_DEFINITION = 'UnionTypeDefinition', - ENUM_TYPE_DEFINITION = 'EnumTypeDefinition', - ENUM_VALUE_DEFINITION = 'EnumValueDefinition', - INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition', - - /** Directive Definitions */ - DIRECTIVE_DEFINITION = 'DirectiveDefinition', - - /** Type System Extensions */ - SCHEMA_EXTENSION = 'SchemaExtension', - - /** Type Extensions */ - SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension', - OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension', - INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension', - UNION_TYPE_EXTENSION = 'UnionTypeExtension', - ENUM_TYPE_EXTENSION = 'EnumTypeExtension', - INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension', -} -export { Kind }; - -/** - * The enum type representing the possible kind values of AST nodes. - * - * @deprecated Please use `Kind`. Will be remove in v17. - */ -export type KindEnum = typeof Kind; diff --git a/src/language/lexer.ts b/src/language/lexer.ts deleted file mode 100644 index 818f81b286..0000000000 --- a/src/language/lexer.ts +++ /dev/null @@ -1,854 +0,0 @@ -import { syntaxError } from '../error/syntaxError'; - -import { Token } from './ast'; -import { dedentBlockStringLines } from './blockString'; -import { isDigit, isNameContinue, isNameStart } from './characterClasses'; -import type { Source } from './source'; -import { TokenKind } from './tokenKind'; - -/** - * Given a Source object, creates a Lexer for that source. - * A Lexer is a stateful stream generator in that every time - * it is advanced, it returns the next token in the Source. Assuming the - * source lexes, the final Token emitted by the lexer will be of kind - * EOF, after which the lexer will repeatedly return the same EOF token - * whenever called. - */ -export class Lexer { - source: Source; - - /** - * The previously focused non-ignored token. - */ - lastToken: Token; - - /** - * The currently focused non-ignored token. - */ - token: Token; - - /** - * The (1-indexed) line containing the current token. - */ - line: number; - - /** - * The character offset at which the current line begins. - */ - lineStart: number; - - constructor(source: Source) { - const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0); - - this.source = source; - this.lastToken = startOfFileToken; - this.token = startOfFileToken; - this.line = 1; - this.lineStart = 0; - } - - get [Symbol.toStringTag]() { - return 'Lexer'; - } - - /** - * Advances the token stream to the next non-ignored token. - */ - advance(): Token { - this.lastToken = this.token; - const token = (this.token = this.lookahead()); - return token; - } - - /** - * Looks ahead and returns the next non-ignored token, but does not change - * the state of Lexer. - */ - lookahead(): Token { - let token = this.token; - if (token.kind !== TokenKind.EOF) { - do { - if (token.next) { - token = token.next; - } else { - // Read the next token and form a link in the token linked-list. - const nextToken = readNextToken(this, token.end); - // @ts-expect-error next is only mutable during parsing. - token.next = nextToken; - // @ts-expect-error prev is only mutable during parsing. - nextToken.prev = token; - token = nextToken; - } - } while (token.kind === TokenKind.COMMENT); - } - return token; - } -} - -/** - * @internal - */ -export function isPunctuatorTokenKind(kind: TokenKind): boolean { - return ( - kind === TokenKind.BANG || - kind === TokenKind.DOLLAR || - kind === TokenKind.AMP || - kind === TokenKind.PAREN_L || - kind === TokenKind.PAREN_R || - kind === TokenKind.SPREAD || - kind === TokenKind.COLON || - kind === TokenKind.EQUALS || - kind === TokenKind.AT || - kind === TokenKind.BRACKET_L || - kind === TokenKind.BRACKET_R || - kind === TokenKind.BRACE_L || - kind === TokenKind.PIPE || - kind === TokenKind.BRACE_R - ); -} - -/** - * A Unicode scalar value is any Unicode code point except surrogate code - * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and - * 0xE000 to 0x10FFFF. - * - * SourceCharacter :: - * - "Any Unicode scalar value" - */ -function isUnicodeScalarValue(code: number): boolean { - return ( - (code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff) - ); -} - -/** - * The GraphQL specification defines source text as a sequence of unicode scalar - * values (which Unicode defines to exclude surrogate code points). However - * JavaScript defines strings as a sequence of UTF-16 code units which may - * include surrogates. A surrogate pair is a valid source character as it - * encodes a supplementary code point (above U+FFFF), but unpaired surrogate - * code points are not valid source characters. - */ -function isSupplementaryCodePoint(body: string, location: number): boolean { - return ( - isLeadingSurrogate(body.charCodeAt(location)) && - isTrailingSurrogate(body.charCodeAt(location + 1)) - ); -} - -function isLeadingSurrogate(code: number): boolean { - return code >= 0xd800 && code <= 0xdbff; -} - -function isTrailingSurrogate(code: number): boolean { - return code >= 0xdc00 && code <= 0xdfff; -} - -/** - * Prints the code point (or end of file reference) at a given location in a - * source for use in error messages. - * - * Printable ASCII is printed quoted, while other points are printed in Unicode - * code point form (ie. U+1234). - */ -function printCodePointAt(lexer: Lexer, location: number): string { - const code = lexer.source.body.codePointAt(location); - - if (code === undefined) { - return TokenKind.EOF; - } else if (code >= 0x0020 && code <= 0x007e) { - // Printable ASCII - const char = String.fromCodePoint(code); - return char === '"' ? "'\"'" : `"${char}"`; - } - - // Unicode code point - return 'U+' + code.toString(16).toUpperCase().padStart(4, '0'); -} - -/** - * Create a token with line and column location information. - */ -function createToken( - lexer: Lexer, - kind: TokenKind, - start: number, - end: number, - value?: string, -): Token { - const line = lexer.line; - const col = 1 + start - lexer.lineStart; - return new Token(kind, start, end, line, col, value); -} - -/** - * Gets the next token from the source starting at the given position. - * - * This skips over whitespace until it finds the next lexable token, then lexes - * punctuators immediately or calls the appropriate helper function for more - * complicated tokens. - */ -function readNextToken(lexer: Lexer, start: number): Token { - const body = lexer.source.body; - const bodyLength = body.length; - let position = start; - - while (position < bodyLength) { - const code = body.charCodeAt(position); - - // SourceCharacter - switch (code) { - // Ignored :: - // - UnicodeBOM - // - WhiteSpace - // - LineTerminator - // - Comment - // - Comma - // - // UnicodeBOM :: "Byte Order Mark (U+FEFF)" - // - // WhiteSpace :: - // - "Horizontal Tab (U+0009)" - // - "Space (U+0020)" - // - // Comma :: , - case 0xfeff: // - case 0x0009: // \t - case 0x0020: // - case 0x002c: // , - ++position; - continue; - // LineTerminator :: - // - "New Line (U+000A)" - // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"] - // - "Carriage Return (U+000D)" "New Line (U+000A)" - case 0x000a: // \n - ++position; - ++lexer.line; - lexer.lineStart = position; - continue; - case 0x000d: // \r - if (body.charCodeAt(position + 1) === 0x000a) { - position += 2; - } else { - ++position; - } - ++lexer.line; - lexer.lineStart = position; - continue; - // Comment - case 0x0023: // # - return readComment(lexer, position); - // Token :: - // - Punctuator - // - Name - // - IntValue - // - FloatValue - // - StringValue - // - // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } - case 0x0021: // ! - return createToken(lexer, TokenKind.BANG, position, position + 1); - case 0x0024: // $ - return createToken(lexer, TokenKind.DOLLAR, position, position + 1); - case 0x0026: // & - return createToken(lexer, TokenKind.AMP, position, position + 1); - case 0x0028: // ( - return createToken(lexer, TokenKind.PAREN_L, position, position + 1); - case 0x0029: // ) - return createToken(lexer, TokenKind.PAREN_R, position, position + 1); - case 0x002e: // . - if ( - body.charCodeAt(position + 1) === 0x002e && - body.charCodeAt(position + 2) === 0x002e - ) { - return createToken(lexer, TokenKind.SPREAD, position, position + 3); - } - break; - case 0x003a: // : - return createToken(lexer, TokenKind.COLON, position, position + 1); - case 0x003d: // = - return createToken(lexer, TokenKind.EQUALS, position, position + 1); - case 0x0040: // @ - return createToken(lexer, TokenKind.AT, position, position + 1); - case 0x005b: // [ - return createToken(lexer, TokenKind.BRACKET_L, position, position + 1); - case 0x005d: // ] - return createToken(lexer, TokenKind.BRACKET_R, position, position + 1); - case 0x007b: // { - return createToken(lexer, TokenKind.BRACE_L, position, position + 1); - case 0x007c: // | - return createToken(lexer, TokenKind.PIPE, position, position + 1); - case 0x007d: // } - return createToken(lexer, TokenKind.BRACE_R, position, position + 1); - // StringValue - case 0x0022: // " - if ( - body.charCodeAt(position + 1) === 0x0022 && - body.charCodeAt(position + 2) === 0x0022 - ) { - return readBlockString(lexer, position); - } - return readString(lexer, position); - } - - // IntValue | FloatValue (Digit | -) - if (isDigit(code) || code === 0x002d) { - return readNumber(lexer, position, code); - } - - // Name - if (isNameStart(code)) { - return readName(lexer, position); - } - - throw syntaxError( - lexer.source, - position, - code === 0x0027 - ? 'Unexpected single quote character (\'), did you mean to use a double quote (")?' - : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) - ? `Unexpected character: ${printCodePointAt(lexer, position)}.` - : `Invalid character: ${printCodePointAt(lexer, position)}.`, - ); - } - - return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength); -} - -/** - * Reads a comment token from the source file. - * - * ``` - * Comment :: # CommentChar* [lookahead != CommentChar] - * - * CommentChar :: SourceCharacter but not LineTerminator - * ``` - */ -function readComment(lexer: Lexer, start: number): Token { - const body = lexer.source.body; - const bodyLength = body.length; - let position = start + 1; - - while (position < bodyLength) { - const code = body.charCodeAt(position); - - // LineTerminator (\n | \r) - if (code === 0x000a || code === 0x000d) { - break; - } - - // SourceCharacter - if (isUnicodeScalarValue(code)) { - ++position; - } else if (isSupplementaryCodePoint(body, position)) { - position += 2; - } else { - break; - } - } - - return createToken( - lexer, - TokenKind.COMMENT, - start, - position, - body.slice(start + 1, position), - ); -} - -/** - * Reads a number token from the source file, either a FloatValue or an IntValue - * depending on whether a FractionalPart or ExponentPart is encountered. - * - * ``` - * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}] - * - * IntegerPart :: - * - NegativeSign? 0 - * - NegativeSign? NonZeroDigit Digit* - * - * NegativeSign :: - - * - * NonZeroDigit :: Digit but not `0` - * - * FloatValue :: - * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}] - * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}] - * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}] - * - * FractionalPart :: . Digit+ - * - * ExponentPart :: ExponentIndicator Sign? Digit+ - * - * ExponentIndicator :: one of `e` `E` - * - * Sign :: one of + - - * ``` - */ -function readNumber(lexer: Lexer, start: number, firstCode: number): Token { - const body = lexer.source.body; - let position = start; - let code = firstCode; - let isFloat = false; - - // NegativeSign (-) - if (code === 0x002d) { - code = body.charCodeAt(++position); - } - - // Zero (0) - if (code === 0x0030) { - code = body.charCodeAt(++position); - if (isDigit(code)) { - throw syntaxError( - lexer.source, - position, - `Invalid number, unexpected digit after 0: ${printCodePointAt( - lexer, - position, - )}.`, - ); - } - } else { - position = readDigits(lexer, position, code); - code = body.charCodeAt(position); - } - - // Full stop (.) - if (code === 0x002e) { - isFloat = true; - - code = body.charCodeAt(++position); - position = readDigits(lexer, position, code); - code = body.charCodeAt(position); - } - - // E e - if (code === 0x0045 || code === 0x0065) { - isFloat = true; - - code = body.charCodeAt(++position); - // + - - if (code === 0x002b || code === 0x002d) { - code = body.charCodeAt(++position); - } - position = readDigits(lexer, position, code); - code = body.charCodeAt(position); - } - - // Numbers cannot be followed by . or NameStart - if (code === 0x002e || isNameStart(code)) { - throw syntaxError( - lexer.source, - position, - `Invalid number, expected digit but got: ${printCodePointAt( - lexer, - position, - )}.`, - ); - } - - return createToken( - lexer, - isFloat ? TokenKind.FLOAT : TokenKind.INT, - start, - position, - body.slice(start, position), - ); -} - -/** - * Returns the new position in the source after reading one or more digits. - */ -function readDigits(lexer: Lexer, start: number, firstCode: number): number { - if (!isDigit(firstCode)) { - throw syntaxError( - lexer.source, - start, - `Invalid number, expected digit but got: ${printCodePointAt( - lexer, - start, - )}.`, - ); - } - - const body = lexer.source.body; - let position = start + 1; // +1 to skip first firstCode - - while (isDigit(body.charCodeAt(position))) { - ++position; - } - - return position; -} - -/** - * Reads a single-quote string token from the source file. - * - * ``` - * StringValue :: - * - `""` [lookahead != `"`] - * - `"` StringCharacter+ `"` - * - * StringCharacter :: - * - SourceCharacter but not `"` or `\` or LineTerminator - * - `\u` EscapedUnicode - * - `\` EscapedCharacter - * - * EscapedUnicode :: - * - `{` HexDigit+ `}` - * - HexDigit HexDigit HexDigit HexDigit - * - * EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t` - * ``` - */ -function readString(lexer: Lexer, start: number): Token { - const body = lexer.source.body; - const bodyLength = body.length; - let position = start + 1; - let chunkStart = position; - let value = ''; - - while (position < bodyLength) { - const code = body.charCodeAt(position); - - // Closing Quote (") - if (code === 0x0022) { - value += body.slice(chunkStart, position); - return createToken(lexer, TokenKind.STRING, start, position + 1, value); - } - - // Escape Sequence (\) - if (code === 0x005c) { - value += body.slice(chunkStart, position); - const escape = - body.charCodeAt(position + 1) === 0x0075 // u - ? body.charCodeAt(position + 2) === 0x007b // { - ? readEscapedUnicodeVariableWidth(lexer, position) - : readEscapedUnicodeFixedWidth(lexer, position) - : readEscapedCharacter(lexer, position); - value += escape.value; - position += escape.size; - chunkStart = position; - continue; - } - - // LineTerminator (\n | \r) - if (code === 0x000a || code === 0x000d) { - break; - } - - // SourceCharacter - if (isUnicodeScalarValue(code)) { - ++position; - } else if (isSupplementaryCodePoint(body, position)) { - position += 2; - } else { - throw syntaxError( - lexer.source, - position, - `Invalid character within String: ${printCodePointAt( - lexer, - position, - )}.`, - ); - } - } - - throw syntaxError(lexer.source, position, 'Unterminated string.'); -} - -// The string value and lexed size of an escape sequence. -interface EscapeSequence { - value: string; - size: number; -} - -function readEscapedUnicodeVariableWidth( - lexer: Lexer, - position: number, -): EscapeSequence { - const body = lexer.source.body; - let point = 0; - let size = 3; - // Cannot be larger than 12 chars (\u{00000000}). - while (size < 12) { - const code = body.charCodeAt(position + size++); - // Closing Brace (}) - if (code === 0x007d) { - // Must be at least 5 chars (\u{0}) and encode a Unicode scalar value. - if (size < 5 || !isUnicodeScalarValue(point)) { - break; - } - return { value: String.fromCodePoint(point), size }; - } - // Append this hex digit to the code point. - point = (point << 4) | readHexDigit(code); - if (point < 0) { - break; - } - } - - throw syntaxError( - lexer.source, - position, - `Invalid Unicode escape sequence: "${body.slice( - position, - position + size, - )}".`, - ); -} - -function readEscapedUnicodeFixedWidth( - lexer: Lexer, - position: number, -): EscapeSequence { - const body = lexer.source.body; - const code = read16BitHexCode(body, position + 2); - - if (isUnicodeScalarValue(code)) { - return { value: String.fromCodePoint(code), size: 6 }; - } - - // GraphQL allows JSON-style surrogate pair escape sequences, but only when - // a valid pair is formed. - if (isLeadingSurrogate(code)) { - // \u - if ( - body.charCodeAt(position + 6) === 0x005c && - body.charCodeAt(position + 7) === 0x0075 - ) { - const trailingCode = read16BitHexCode(body, position + 8); - if (isTrailingSurrogate(trailingCode)) { - // JavaScript defines strings as a sequence of UTF-16 code units and - // encodes Unicode code points above U+FFFF using a surrogate pair of - // code units. Since this is a surrogate pair escape sequence, just - // include both codes into the JavaScript string value. Had JavaScript - // not been internally based on UTF-16, then this surrogate pair would - // be decoded to retrieve the supplementary code point. - return { value: String.fromCodePoint(code, trailingCode), size: 12 }; - } - } - } - - throw syntaxError( - lexer.source, - position, - `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`, - ); -} - -/** - * Reads four hexadecimal characters and returns the positive integer that 16bit - * hexadecimal string represents. For example, "000f" will return 15, and "dead" - * will return 57005. - * - * Returns a negative number if any char was not a valid hexadecimal digit. - */ -function read16BitHexCode(body: string, position: number): number { - // readHexDigit() returns -1 on error. ORing a negative value with any other - // value always produces a negative value. - return ( - (readHexDigit(body.charCodeAt(position)) << 12) | - (readHexDigit(body.charCodeAt(position + 1)) << 8) | - (readHexDigit(body.charCodeAt(position + 2)) << 4) | - readHexDigit(body.charCodeAt(position + 3)) - ); -} - -/** - * Reads a hexadecimal character and returns its positive integer value (0-15). - * - * '0' becomes 0, '9' becomes 9 - * 'A' becomes 10, 'F' becomes 15 - * 'a' becomes 10, 'f' becomes 15 - * - * Returns -1 if the provided character code was not a valid hexadecimal digit. - * - * HexDigit :: one of - * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` - * - `A` `B` `C` `D` `E` `F` - * - `a` `b` `c` `d` `e` `f` - */ -function readHexDigit(code: number): number { - return code >= 0x0030 && code <= 0x0039 // 0-9 - ? code - 0x0030 - : code >= 0x0041 && code <= 0x0046 // A-F - ? code - 0x0037 - : code >= 0x0061 && code <= 0x0066 // a-f - ? code - 0x0057 - : -1; -} - -/** - * | Escaped Character | Code Point | Character Name | - * | ----------------- | ---------- | ---------------------------- | - * | `"` | U+0022 | double quote | - * | `\` | U+005C | reverse solidus (back slash) | - * | `/` | U+002F | solidus (forward slash) | - * | `b` | U+0008 | backspace | - * | `f` | U+000C | form feed | - * | `n` | U+000A | line feed (new line) | - * | `r` | U+000D | carriage return | - * | `t` | U+0009 | horizontal tab | - */ -function readEscapedCharacter(lexer: Lexer, position: number): EscapeSequence { - const body = lexer.source.body; - const code = body.charCodeAt(position + 1); - switch (code) { - case 0x0022: // " - return { value: '\u0022', size: 2 }; - case 0x005c: // \ - return { value: '\u005c', size: 2 }; - case 0x002f: // / - return { value: '\u002f', size: 2 }; - case 0x0062: // b - return { value: '\u0008', size: 2 }; - case 0x0066: // f - return { value: '\u000c', size: 2 }; - case 0x006e: // n - return { value: '\u000a', size: 2 }; - case 0x0072: // r - return { value: '\u000d', size: 2 }; - case 0x0074: // t - return { value: '\u0009', size: 2 }; - } - throw syntaxError( - lexer.source, - position, - `Invalid character escape sequence: "${body.slice( - position, - position + 2, - )}".`, - ); -} - -/** - * Reads a block string token from the source file. - * - * ``` - * StringValue :: - * - `"""` BlockStringCharacter* `"""` - * - * BlockStringCharacter :: - * - SourceCharacter but not `"""` or `\"""` - * - `\"""` - * ``` - */ -function readBlockString(lexer: Lexer, start: number): Token { - const body = lexer.source.body; - const bodyLength = body.length; - let lineStart = lexer.lineStart; - - let position = start + 3; - let chunkStart = position; - let currentLine = ''; - - const blockLines = []; - while (position < bodyLength) { - const code = body.charCodeAt(position); - - // Closing Triple-Quote (""") - if ( - code === 0x0022 && - body.charCodeAt(position + 1) === 0x0022 && - body.charCodeAt(position + 2) === 0x0022 - ) { - currentLine += body.slice(chunkStart, position); - blockLines.push(currentLine); - - const token = createToken( - lexer, - TokenKind.BLOCK_STRING, - start, - position + 3, - // Return a string of the lines joined with U+000A. - dedentBlockStringLines(blockLines).join('\n'), - ); - - lexer.line += blockLines.length - 1; - lexer.lineStart = lineStart; - return token; - } - - // Escaped Triple-Quote (\""") - if ( - code === 0x005c && - body.charCodeAt(position + 1) === 0x0022 && - body.charCodeAt(position + 2) === 0x0022 && - body.charCodeAt(position + 3) === 0x0022 - ) { - currentLine += body.slice(chunkStart, position); - chunkStart = position + 1; // skip only slash - position += 4; - continue; - } - - // LineTerminator - if (code === 0x000a || code === 0x000d) { - currentLine += body.slice(chunkStart, position); - blockLines.push(currentLine); - - if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) { - position += 2; - } else { - ++position; - } - - currentLine = ''; - chunkStart = position; - lineStart = position; - continue; - } - - // SourceCharacter - if (isUnicodeScalarValue(code)) { - ++position; - } else if (isSupplementaryCodePoint(body, position)) { - position += 2; - } else { - throw syntaxError( - lexer.source, - position, - `Invalid character within String: ${printCodePointAt( - lexer, - position, - )}.`, - ); - } - } - - throw syntaxError(lexer.source, position, 'Unterminated string.'); -} - -/** - * Reads an alphanumeric + underscore name from the source. - * - * ``` - * Name :: - * - NameStart NameContinue* [lookahead != NameContinue] - * ``` - */ -function readName(lexer: Lexer, start: number): Token { - const body = lexer.source.body; - const bodyLength = body.length; - let position = start + 1; - - while (position < bodyLength) { - const code = body.charCodeAt(position); - if (isNameContinue(code)) { - ++position; - } else { - break; - } - } - - return createToken( - lexer, - TokenKind.NAME, - start, - position, - body.slice(start, position), - ); -} diff --git a/src/language/location.ts b/src/language/location.ts deleted file mode 100644 index 36d97f3cca..0000000000 --- a/src/language/location.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { invariant } from '../jsutils/invariant'; - -import type { Source } from './source'; - -const LineRegExp = /\r\n|[\n\r]/g; - -/** - * Represents a location in a Source. - */ -export interface SourceLocation { - readonly line: number; - readonly column: number; -} - -/** - * Takes a Source and a UTF-8 character offset, and returns the corresponding - * line and column as a SourceLocation. - */ -export function getLocation(source: Source, position: number): SourceLocation { - let lastLineStart = 0; - let line = 1; - - for (const match of source.body.matchAll(LineRegExp)) { - invariant(typeof match.index === 'number'); - if (match.index >= position) { - break; - } - lastLineStart = match.index + match[0].length; - line += 1; - } - - return { line, column: position + 1 - lastLineStart }; -} diff --git a/src/language/parser.ts b/src/language/parser.ts deleted file mode 100644 index 03e4166210..0000000000 --- a/src/language/parser.ts +++ /dev/null @@ -1,1602 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; - -import type { GraphQLError } from '../error/GraphQLError'; -import { syntaxError } from '../error/syntaxError'; - -import type { - ArgumentNode, - BooleanValueNode, - ConstArgumentNode, - ConstDirectiveNode, - ConstListValueNode, - ConstObjectFieldNode, - ConstObjectValueNode, - ConstValueNode, - DefinitionNode, - DirectiveDefinitionNode, - DirectiveNode, - DocumentNode, - EnumTypeDefinitionNode, - EnumTypeExtensionNode, - EnumValueDefinitionNode, - EnumValueNode, - FieldDefinitionNode, - FieldNode, - FloatValueNode, - FragmentDefinitionNode, - FragmentSpreadNode, - InlineFragmentNode, - InputObjectTypeDefinitionNode, - InputObjectTypeExtensionNode, - InputValueDefinitionNode, - InterfaceTypeDefinitionNode, - InterfaceTypeExtensionNode, - IntValueNode, - ListTypeNode, - ListValueNode, - NamedTypeNode, - NameNode, - NonNullTypeNode, - NullValueNode, - ObjectFieldNode, - ObjectTypeDefinitionNode, - ObjectTypeExtensionNode, - ObjectValueNode, - OperationDefinitionNode, - OperationTypeDefinitionNode, - ScalarTypeDefinitionNode, - ScalarTypeExtensionNode, - SchemaDefinitionNode, - SchemaExtensionNode, - SelectionNode, - SelectionSetNode, - StringValueNode, - Token, - TypeNode, - TypeSystemExtensionNode, - UnionTypeDefinitionNode, - UnionTypeExtensionNode, - ValueNode, - VariableDefinitionNode, - VariableNode, -} from './ast'; -import { Location, OperationTypeNode } from './ast'; -import { DirectiveLocation } from './directiveLocation'; -import { Kind } from './kinds'; -import { isPunctuatorTokenKind, Lexer } from './lexer'; -import { isSource, Source } from './source'; -import { TokenKind } from './tokenKind'; - -/** - * Configuration options to control parser behavior - */ -export interface ParseOptions { - /** - * By default, the parser creates AST nodes that know the location - * in the source that they correspond to. This configuration flag - * disables that behavior for performance or testing. - */ - noLocation?: boolean; - - /** - * Parser CPU and memory usage is linear to the number of tokens in a document - * however in extreme cases it becomes quadratic due to memory exhaustion. - * Parsing happens before validation so even invalid queries can burn lots of - * CPU time and memory. - * To prevent this you can set a maximum number of tokens allowed within a document. - */ - maxTokens?: number | undefined; - - /** - * @deprecated will be removed in the v17.0.0 - * - * If enabled, the parser will understand and parse variable definitions - * contained in a fragment definition. They'll be represented in the - * `variableDefinitions` field of the FragmentDefinitionNode. - * - * The syntax is identical to normal, query-defined variables. For example: - * - * ```graphql - * fragment A($var: Boolean = false) on T { - * ... - * } - * ``` - */ - allowLegacyFragmentVariables?: boolean; -} - -/** - * Given a GraphQL source, parses it into a Document. - * Throws GraphQLError if a syntax error is encountered. - */ -export function parse( - source: string | Source, - options?: ParseOptions | undefined, -): DocumentNode { - const parser = new Parser(source, options); - const document = parser.parseDocument(); - Object.defineProperty(document, 'tokenCount', { - enumerable: false, - value: parser.tokenCount, - }); - return document; -} - -/** - * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for - * that value. - * Throws GraphQLError if a syntax error is encountered. - * - * This is useful within tools that operate upon GraphQL Values directly and - * in isolation of complete GraphQL documents. - * - * Consider providing the results to the utility function: valueFromAST(). - */ -export function parseValue( - source: string | Source, - options?: ParseOptions | undefined, -): ValueNode { - const parser = new Parser(source, options); - parser.expectToken(TokenKind.SOF); - const value = parser.parseValueLiteral(false); - parser.expectToken(TokenKind.EOF); - return value; -} - -/** - * Similar to parseValue(), but raises a parse error if it encounters a - * variable. The return type will be a constant value. - */ -export function parseConstValue( - source: string | Source, - options?: ParseOptions | undefined, -): ConstValueNode { - const parser = new Parser(source, options); - parser.expectToken(TokenKind.SOF); - const value = parser.parseConstValueLiteral(); - parser.expectToken(TokenKind.EOF); - return value; -} - -/** - * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for - * that type. - * Throws GraphQLError if a syntax error is encountered. - * - * This is useful within tools that operate upon GraphQL Types directly and - * in isolation of complete GraphQL documents. - * - * Consider providing the results to the utility function: typeFromAST(). - */ -export function parseType( - source: string | Source, - options?: ParseOptions | undefined, -): TypeNode { - const parser = new Parser(source, options); - parser.expectToken(TokenKind.SOF); - const type = parser.parseTypeReference(); - parser.expectToken(TokenKind.EOF); - return type; -} - -/** - * This class is exported only to assist people in implementing their own parsers - * without duplicating too much code and should be used only as last resort for cases - * such as experimental syntax or if certain features could not be contributed upstream. - * - * It is still part of the internal API and is versioned, so any changes to it are never - * considered breaking changes. If you still need to support multiple versions of the - * library, please use the `versionInfo` variable for version detection. - * - * @internal - */ -export class Parser { - protected _options: ParseOptions; - protected _lexer: Lexer; - protected _tokenCounter: number; - - constructor(source: string | Source, options: ParseOptions = {}) { - const sourceObj = isSource(source) ? source : new Source(source); - - this._lexer = new Lexer(sourceObj); - this._options = options; - this._tokenCounter = 0; - } - - get tokenCount(): number { - return this._tokenCounter; - } - - /** - * Converts a name lex token into a name parse node. - */ - parseName(): NameNode { - const token = this.expectToken(TokenKind.NAME); - return this.node(token, { - kind: Kind.NAME, - value: token.value, - }); - } - - // Implements the parsing rules in the Document section. - - /** - * Document : Definition+ - */ - parseDocument(): DocumentNode { - return this.node(this._lexer.token, { - kind: Kind.DOCUMENT, - definitions: this.many( - TokenKind.SOF, - this.parseDefinition, - TokenKind.EOF, - ), - }); - } - - /** - * Definition : - * - ExecutableDefinition - * - TypeSystemDefinition - * - TypeSystemExtension - * - * ExecutableDefinition : - * - OperationDefinition - * - FragmentDefinition - * - * TypeSystemDefinition : - * - SchemaDefinition - * - TypeDefinition - * - DirectiveDefinition - * - * TypeDefinition : - * - ScalarTypeDefinition - * - ObjectTypeDefinition - * - InterfaceTypeDefinition - * - UnionTypeDefinition - * - EnumTypeDefinition - * - InputObjectTypeDefinition - */ - parseDefinition(): DefinitionNode { - if (this.peek(TokenKind.BRACE_L)) { - return this.parseOperationDefinition(); - } - - // Many definitions begin with a description and require a lookahead. - const hasDescription = this.peekDescription(); - const keywordToken = hasDescription - ? this._lexer.lookahead() - : this._lexer.token; - - if (keywordToken.kind === TokenKind.NAME) { - switch (keywordToken.value) { - case 'schema': - return this.parseSchemaDefinition(); - case 'scalar': - return this.parseScalarTypeDefinition(); - case 'type': - return this.parseObjectTypeDefinition(); - case 'interface': - return this.parseInterfaceTypeDefinition(); - case 'union': - return this.parseUnionTypeDefinition(); - case 'enum': - return this.parseEnumTypeDefinition(); - case 'input': - return this.parseInputObjectTypeDefinition(); - case 'directive': - return this.parseDirectiveDefinition(); - } - - if (hasDescription) { - throw syntaxError( - this._lexer.source, - this._lexer.token.start, - 'Unexpected description, descriptions are supported only on type definitions.', - ); - } - - switch (keywordToken.value) { - case 'query': - case 'mutation': - case 'subscription': - return this.parseOperationDefinition(); - case 'fragment': - return this.parseFragmentDefinition(); - case 'extend': - return this.parseTypeSystemExtension(); - } - } - - throw this.unexpected(keywordToken); - } - - // Implements the parsing rules in the Operations section. - - /** - * OperationDefinition : - * - SelectionSet - * - OperationType Name? VariableDefinitions? Directives? SelectionSet - */ - parseOperationDefinition(): OperationDefinitionNode { - const start = this._lexer.token; - if (this.peek(TokenKind.BRACE_L)) { - return this.node(start, { - kind: Kind.OPERATION_DEFINITION, - operation: OperationTypeNode.QUERY, - name: undefined, - variableDefinitions: [], - directives: [], - selectionSet: this.parseSelectionSet(), - }); - } - const operation = this.parseOperationType(); - let name; - if (this.peek(TokenKind.NAME)) { - name = this.parseName(); - } - return this.node(start, { - kind: Kind.OPERATION_DEFINITION, - operation, - name, - variableDefinitions: this.parseVariableDefinitions(), - directives: this.parseDirectives(false), - selectionSet: this.parseSelectionSet(), - }); - } - - /** - * OperationType : one of query mutation subscription - */ - parseOperationType(): OperationTypeNode { - const operationToken = this.expectToken(TokenKind.NAME); - switch (operationToken.value) { - case 'query': - return OperationTypeNode.QUERY; - case 'mutation': - return OperationTypeNode.MUTATION; - case 'subscription': - return OperationTypeNode.SUBSCRIPTION; - } - - throw this.unexpected(operationToken); - } - - /** - * VariableDefinitions : ( VariableDefinition+ ) - */ - parseVariableDefinitions(): Array { - return this.optionalMany( - TokenKind.PAREN_L, - this.parseVariableDefinition, - TokenKind.PAREN_R, - ); - } - - /** - * VariableDefinition : Variable : Type DefaultValue? Directives[Const]? - */ - parseVariableDefinition(): VariableDefinitionNode { - return this.node(this._lexer.token, { - kind: Kind.VARIABLE_DEFINITION, - variable: this.parseVariable(), - type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()), - defaultValue: this.expectOptionalToken(TokenKind.EQUALS) - ? this.parseConstValueLiteral() - : undefined, - directives: this.parseConstDirectives(), - }); - } - - /** - * Variable : $ Name - */ - parseVariable(): VariableNode { - const start = this._lexer.token; - this.expectToken(TokenKind.DOLLAR); - return this.node(start, { - kind: Kind.VARIABLE, - name: this.parseName(), - }); - } - - /** - * ``` - * SelectionSet : { Selection+ } - * ``` - */ - parseSelectionSet(): SelectionSetNode { - return this.node(this._lexer.token, { - kind: Kind.SELECTION_SET, - selections: this.many( - TokenKind.BRACE_L, - this.parseSelection, - TokenKind.BRACE_R, - ), - }); - } - - /** - * Selection : - * - Field - * - FragmentSpread - * - InlineFragment - */ - parseSelection(): SelectionNode { - return this.peek(TokenKind.SPREAD) - ? this.parseFragment() - : this.parseField(); - } - - /** - * Field : Alias? Name Arguments? Directives? SelectionSet? - * - * Alias : Name : - */ - parseField(): FieldNode { - const start = this._lexer.token; - - const nameOrAlias = this.parseName(); - let alias; - let name; - if (this.expectOptionalToken(TokenKind.COLON)) { - alias = nameOrAlias; - name = this.parseName(); - } else { - name = nameOrAlias; - } - - return this.node(start, { - kind: Kind.FIELD, - alias, - name, - arguments: this.parseArguments(false), - directives: this.parseDirectives(false), - selectionSet: this.peek(TokenKind.BRACE_L) - ? this.parseSelectionSet() - : undefined, - }); - } - - /** - * Arguments[Const] : ( Argument[?Const]+ ) - */ - parseArguments(isConst: true): Array; - parseArguments(isConst: boolean): Array; - parseArguments(isConst: boolean): Array { - const item = isConst ? this.parseConstArgument : this.parseArgument; - return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R); - } - - /** - * Argument[Const] : Name : Value[?Const] - */ - parseArgument(isConst: true): ConstArgumentNode; - parseArgument(isConst?: boolean): ArgumentNode; - parseArgument(isConst: boolean = false): ArgumentNode { - const start = this._lexer.token; - const name = this.parseName(); - - this.expectToken(TokenKind.COLON); - return this.node(start, { - kind: Kind.ARGUMENT, - name, - value: this.parseValueLiteral(isConst), - }); - } - - parseConstArgument(): ConstArgumentNode { - return this.parseArgument(true); - } - - // Implements the parsing rules in the Fragments section. - - /** - * Corresponds to both FragmentSpread and InlineFragment in the spec. - * - * FragmentSpread : ... FragmentName Directives? - * - * InlineFragment : ... TypeCondition? Directives? SelectionSet - */ - parseFragment(): FragmentSpreadNode | InlineFragmentNode { - const start = this._lexer.token; - this.expectToken(TokenKind.SPREAD); - - const hasTypeCondition = this.expectOptionalKeyword('on'); - if (!hasTypeCondition && this.peek(TokenKind.NAME)) { - return this.node(start, { - kind: Kind.FRAGMENT_SPREAD, - name: this.parseFragmentName(), - directives: this.parseDirectives(false), - }); - } - return this.node(start, { - kind: Kind.INLINE_FRAGMENT, - typeCondition: hasTypeCondition ? this.parseNamedType() : undefined, - directives: this.parseDirectives(false), - selectionSet: this.parseSelectionSet(), - }); - } - - /** - * FragmentDefinition : - * - fragment FragmentName on TypeCondition Directives? SelectionSet - * - * TypeCondition : NamedType - */ - parseFragmentDefinition(): FragmentDefinitionNode { - const start = this._lexer.token; - this.expectKeyword('fragment'); - // Legacy support for defining variables within fragments changes - // the grammar of FragmentDefinition: - // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet - if (this._options.allowLegacyFragmentVariables === true) { - return this.node(start, { - kind: Kind.FRAGMENT_DEFINITION, - name: this.parseFragmentName(), - variableDefinitions: this.parseVariableDefinitions(), - typeCondition: (this.expectKeyword('on'), this.parseNamedType()), - directives: this.parseDirectives(false), - selectionSet: this.parseSelectionSet(), - }); - } - return this.node(start, { - kind: Kind.FRAGMENT_DEFINITION, - name: this.parseFragmentName(), - typeCondition: (this.expectKeyword('on'), this.parseNamedType()), - directives: this.parseDirectives(false), - selectionSet: this.parseSelectionSet(), - }); - } - - /** - * FragmentName : Name but not `on` - */ - parseFragmentName(): NameNode { - if (this._lexer.token.value === 'on') { - throw this.unexpected(); - } - return this.parseName(); - } - - // Implements the parsing rules in the Values section. - - /** - * Value[Const] : - * - [~Const] Variable - * - IntValue - * - FloatValue - * - StringValue - * - BooleanValue - * - NullValue - * - EnumValue - * - ListValue[?Const] - * - ObjectValue[?Const] - * - * BooleanValue : one of `true` `false` - * - * NullValue : `null` - * - * EnumValue : Name but not `true`, `false` or `null` - */ - parseValueLiteral(isConst: true): ConstValueNode; - parseValueLiteral(isConst: boolean): ValueNode; - parseValueLiteral(isConst: boolean): ValueNode { - const token = this._lexer.token; - switch (token.kind) { - case TokenKind.BRACKET_L: - return this.parseList(isConst); - case TokenKind.BRACE_L: - return this.parseObject(isConst); - case TokenKind.INT: - this.advanceLexer(); - return this.node(token, { - kind: Kind.INT, - value: token.value, - }); - case TokenKind.FLOAT: - this.advanceLexer(); - return this.node(token, { - kind: Kind.FLOAT, - value: token.value, - }); - case TokenKind.STRING: - case TokenKind.BLOCK_STRING: - return this.parseStringLiteral(); - case TokenKind.NAME: - this.advanceLexer(); - switch (token.value) { - case 'true': - return this.node(token, { - kind: Kind.BOOLEAN, - value: true, - }); - case 'false': - return this.node(token, { - kind: Kind.BOOLEAN, - value: false, - }); - case 'null': - return this.node(token, { kind: Kind.NULL }); - default: - return this.node(token, { - kind: Kind.ENUM, - value: token.value, - }); - } - case TokenKind.DOLLAR: - if (isConst) { - this.expectToken(TokenKind.DOLLAR); - if (this._lexer.token.kind === TokenKind.NAME) { - const varName = this._lexer.token.value; - throw syntaxError( - this._lexer.source, - token.start, - `Unexpected variable "$${varName}" in constant value.`, - ); - } else { - throw this.unexpected(token); - } - } - return this.parseVariable(); - default: - throw this.unexpected(); - } - } - - parseConstValueLiteral(): ConstValueNode { - return this.parseValueLiteral(true); - } - - parseStringLiteral(): StringValueNode { - const token = this._lexer.token; - this.advanceLexer(); - return this.node(token, { - kind: Kind.STRING, - value: token.value, - block: token.kind === TokenKind.BLOCK_STRING, - }); - } - - /** - * ListValue[Const] : - * - [ ] - * - [ Value[?Const]+ ] - */ - parseList(isConst: true): ConstListValueNode; - parseList(isConst: boolean): ListValueNode; - parseList(isConst: boolean): ListValueNode { - const item = () => this.parseValueLiteral(isConst); - return this.node(this._lexer.token, { - kind: Kind.LIST, - values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R), - }); - } - - /** - * ``` - * ObjectValue[Const] : - * - { } - * - { ObjectField[?Const]+ } - * ``` - */ - parseObject(isConst: true): ConstObjectValueNode; - parseObject(isConst: boolean): ObjectValueNode; - parseObject(isConst: boolean): ObjectValueNode { - const item = () => this.parseObjectField(isConst); - return this.node(this._lexer.token, { - kind: Kind.OBJECT, - fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R), - }); - } - - /** - * ObjectField[Const] : Name : Value[?Const] - */ - parseObjectField(isConst: true): ConstObjectFieldNode; - parseObjectField(isConst: boolean): ObjectFieldNode; - parseObjectField(isConst: boolean): ObjectFieldNode { - const start = this._lexer.token; - const name = this.parseName(); - this.expectToken(TokenKind.COLON); - return this.node(start, { - kind: Kind.OBJECT_FIELD, - name, - value: this.parseValueLiteral(isConst), - }); - } - - // Implements the parsing rules in the Directives section. - - /** - * Directives[Const] : Directive[?Const]+ - */ - parseDirectives(isConst: true): Array; - parseDirectives(isConst: boolean): Array; - parseDirectives(isConst: boolean): Array { - const directives = []; - while (this.peek(TokenKind.AT)) { - directives.push(this.parseDirective(isConst)); - } - return directives; - } - - parseConstDirectives(): Array { - return this.parseDirectives(true); - } - - /** - * ``` - * Directive[Const] : @ Name Arguments[?Const]? - * ``` - */ - parseDirective(isConst: true): ConstDirectiveNode; - parseDirective(isConst: boolean): DirectiveNode; - parseDirective(isConst: boolean): DirectiveNode { - const start = this._lexer.token; - this.expectToken(TokenKind.AT); - return this.node(start, { - kind: Kind.DIRECTIVE, - name: this.parseName(), - arguments: this.parseArguments(isConst), - }); - } - - // Implements the parsing rules in the Types section. - - /** - * Type : - * - NamedType - * - ListType - * - NonNullType - */ - parseTypeReference(): TypeNode { - const start = this._lexer.token; - let type; - if (this.expectOptionalToken(TokenKind.BRACKET_L)) { - const innerType = this.parseTypeReference(); - this.expectToken(TokenKind.BRACKET_R); - type = this.node(start, { - kind: Kind.LIST_TYPE, - type: innerType, - }); - } else { - type = this.parseNamedType(); - } - - if (this.expectOptionalToken(TokenKind.BANG)) { - return this.node(start, { - kind: Kind.NON_NULL_TYPE, - type, - }); - } - - return type; - } - - /** - * NamedType : Name - */ - parseNamedType(): NamedTypeNode { - return this.node(this._lexer.token, { - kind: Kind.NAMED_TYPE, - name: this.parseName(), - }); - } - - // Implements the parsing rules in the Type Definition section. - - peekDescription(): boolean { - return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING); - } - - /** - * Description : StringValue - */ - parseDescription(): undefined | StringValueNode { - if (this.peekDescription()) { - return this.parseStringLiteral(); - } - } - - /** - * ``` - * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } - * ``` - */ - parseSchemaDefinition(): SchemaDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('schema'); - const directives = this.parseConstDirectives(); - const operationTypes = this.many( - TokenKind.BRACE_L, - this.parseOperationTypeDefinition, - TokenKind.BRACE_R, - ); - return this.node(start, { - kind: Kind.SCHEMA_DEFINITION, - description, - directives, - operationTypes, - }); - } - - /** - * OperationTypeDefinition : OperationType : NamedType - */ - parseOperationTypeDefinition(): OperationTypeDefinitionNode { - const start = this._lexer.token; - const operation = this.parseOperationType(); - this.expectToken(TokenKind.COLON); - const type = this.parseNamedType(); - return this.node(start, { - kind: Kind.OPERATION_TYPE_DEFINITION, - operation, - type, - }); - } - - /** - * ScalarTypeDefinition : Description? scalar Name Directives[Const]? - */ - parseScalarTypeDefinition(): ScalarTypeDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('scalar'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - return this.node(start, { - kind: Kind.SCALAR_TYPE_DEFINITION, - description, - name, - directives, - }); - } - - /** - * ObjectTypeDefinition : - * Description? - * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? - */ - parseObjectTypeDefinition(): ObjectTypeDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('type'); - const name = this.parseName(); - const interfaces = this.parseImplementsInterfaces(); - const directives = this.parseConstDirectives(); - const fields = this.parseFieldsDefinition(); - return this.node(start, { - kind: Kind.OBJECT_TYPE_DEFINITION, - description, - name, - interfaces, - directives, - fields, - }); - } - - /** - * ImplementsInterfaces : - * - implements `&`? NamedType - * - ImplementsInterfaces & NamedType - */ - parseImplementsInterfaces(): Array { - return this.expectOptionalKeyword('implements') - ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) - : []; - } - - /** - * ``` - * FieldsDefinition : { FieldDefinition+ } - * ``` - */ - parseFieldsDefinition(): Array { - return this.optionalMany( - TokenKind.BRACE_L, - this.parseFieldDefinition, - TokenKind.BRACE_R, - ); - } - - /** - * FieldDefinition : - * - Description? Name ArgumentsDefinition? : Type Directives[Const]? - */ - parseFieldDefinition(): FieldDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - const name = this.parseName(); - const args = this.parseArgumentDefs(); - this.expectToken(TokenKind.COLON); - const type = this.parseTypeReference(); - const directives = this.parseConstDirectives(); - return this.node(start, { - kind: Kind.FIELD_DEFINITION, - description, - name, - arguments: args, - type, - directives, - }); - } - - /** - * ArgumentsDefinition : ( InputValueDefinition+ ) - */ - parseArgumentDefs(): Array { - return this.optionalMany( - TokenKind.PAREN_L, - this.parseInputValueDef, - TokenKind.PAREN_R, - ); - } - - /** - * InputValueDefinition : - * - Description? Name : Type DefaultValue? Directives[Const]? - */ - parseInputValueDef(): InputValueDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - const name = this.parseName(); - this.expectToken(TokenKind.COLON); - const type = this.parseTypeReference(); - let defaultValue; - if (this.expectOptionalToken(TokenKind.EQUALS)) { - defaultValue = this.parseConstValueLiteral(); - } - const directives = this.parseConstDirectives(); - return this.node(start, { - kind: Kind.INPUT_VALUE_DEFINITION, - description, - name, - type, - defaultValue, - directives, - }); - } - - /** - * InterfaceTypeDefinition : - * - Description? interface Name Directives[Const]? FieldsDefinition? - */ - parseInterfaceTypeDefinition(): InterfaceTypeDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('interface'); - const name = this.parseName(); - const interfaces = this.parseImplementsInterfaces(); - const directives = this.parseConstDirectives(); - const fields = this.parseFieldsDefinition(); - return this.node(start, { - kind: Kind.INTERFACE_TYPE_DEFINITION, - description, - name, - interfaces, - directives, - fields, - }); - } - - /** - * UnionTypeDefinition : - * - Description? union Name Directives[Const]? UnionMemberTypes? - */ - parseUnionTypeDefinition(): UnionTypeDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('union'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - const types = this.parseUnionMemberTypes(); - return this.node(start, { - kind: Kind.UNION_TYPE_DEFINITION, - description, - name, - directives, - types, - }); - } - - /** - * UnionMemberTypes : - * - = `|`? NamedType - * - UnionMemberTypes | NamedType - */ - parseUnionMemberTypes(): Array { - return this.expectOptionalToken(TokenKind.EQUALS) - ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) - : []; - } - - /** - * EnumTypeDefinition : - * - Description? enum Name Directives[Const]? EnumValuesDefinition? - */ - parseEnumTypeDefinition(): EnumTypeDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('enum'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - const values = this.parseEnumValuesDefinition(); - return this.node(start, { - kind: Kind.ENUM_TYPE_DEFINITION, - description, - name, - directives, - values, - }); - } - - /** - * ``` - * EnumValuesDefinition : { EnumValueDefinition+ } - * ``` - */ - parseEnumValuesDefinition(): Array { - return this.optionalMany( - TokenKind.BRACE_L, - this.parseEnumValueDefinition, - TokenKind.BRACE_R, - ); - } - - /** - * EnumValueDefinition : Description? EnumValue Directives[Const]? - */ - parseEnumValueDefinition(): EnumValueDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - const name = this.parseEnumValueName(); - const directives = this.parseConstDirectives(); - return this.node(start, { - kind: Kind.ENUM_VALUE_DEFINITION, - description, - name, - directives, - }); - } - - /** - * EnumValue : Name but not `true`, `false` or `null` - */ - parseEnumValueName(): NameNode { - if ( - this._lexer.token.value === 'true' || - this._lexer.token.value === 'false' || - this._lexer.token.value === 'null' - ) { - throw syntaxError( - this._lexer.source, - this._lexer.token.start, - `${getTokenDesc( - this._lexer.token, - )} is reserved and cannot be used for an enum value.`, - ); - } - return this.parseName(); - } - - /** - * InputObjectTypeDefinition : - * - Description? input Name Directives[Const]? InputFieldsDefinition? - */ - parseInputObjectTypeDefinition(): InputObjectTypeDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('input'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - const fields = this.parseInputFieldsDefinition(); - return this.node(start, { - kind: Kind.INPUT_OBJECT_TYPE_DEFINITION, - description, - name, - directives, - fields, - }); - } - - /** - * ``` - * InputFieldsDefinition : { InputValueDefinition+ } - * ``` - */ - parseInputFieldsDefinition(): Array { - return this.optionalMany( - TokenKind.BRACE_L, - this.parseInputValueDef, - TokenKind.BRACE_R, - ); - } - - /** - * TypeSystemExtension : - * - SchemaExtension - * - TypeExtension - * - * TypeExtension : - * - ScalarTypeExtension - * - ObjectTypeExtension - * - InterfaceTypeExtension - * - UnionTypeExtension - * - EnumTypeExtension - * - InputObjectTypeDefinition - */ - parseTypeSystemExtension(): TypeSystemExtensionNode { - const keywordToken = this._lexer.lookahead(); - - if (keywordToken.kind === TokenKind.NAME) { - switch (keywordToken.value) { - case 'schema': - return this.parseSchemaExtension(); - case 'scalar': - return this.parseScalarTypeExtension(); - case 'type': - return this.parseObjectTypeExtension(); - case 'interface': - return this.parseInterfaceTypeExtension(); - case 'union': - return this.parseUnionTypeExtension(); - case 'enum': - return this.parseEnumTypeExtension(); - case 'input': - return this.parseInputObjectTypeExtension(); - } - } - - throw this.unexpected(keywordToken); - } - - /** - * ``` - * SchemaExtension : - * - extend schema Directives[Const]? { OperationTypeDefinition+ } - * - extend schema Directives[Const] - * ``` - */ - parseSchemaExtension(): SchemaExtensionNode { - const start = this._lexer.token; - this.expectKeyword('extend'); - this.expectKeyword('schema'); - const directives = this.parseConstDirectives(); - const operationTypes = this.optionalMany( - TokenKind.BRACE_L, - this.parseOperationTypeDefinition, - TokenKind.BRACE_R, - ); - if (directives.length === 0 && operationTypes.length === 0) { - throw this.unexpected(); - } - return this.node(start, { - kind: Kind.SCHEMA_EXTENSION, - directives, - operationTypes, - }); - } - - /** - * ScalarTypeExtension : - * - extend scalar Name Directives[Const] - */ - parseScalarTypeExtension(): ScalarTypeExtensionNode { - const start = this._lexer.token; - this.expectKeyword('extend'); - this.expectKeyword('scalar'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - if (directives.length === 0) { - throw this.unexpected(); - } - return this.node(start, { - kind: Kind.SCALAR_TYPE_EXTENSION, - name, - directives, - }); - } - - /** - * ObjectTypeExtension : - * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition - * - extend type Name ImplementsInterfaces? Directives[Const] - * - extend type Name ImplementsInterfaces - */ - parseObjectTypeExtension(): ObjectTypeExtensionNode { - const start = this._lexer.token; - this.expectKeyword('extend'); - this.expectKeyword('type'); - const name = this.parseName(); - const interfaces = this.parseImplementsInterfaces(); - const directives = this.parseConstDirectives(); - const fields = this.parseFieldsDefinition(); - if ( - interfaces.length === 0 && - directives.length === 0 && - fields.length === 0 - ) { - throw this.unexpected(); - } - return this.node(start, { - kind: Kind.OBJECT_TYPE_EXTENSION, - name, - interfaces, - directives, - fields, - }); - } - - /** - * InterfaceTypeExtension : - * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition - * - extend interface Name ImplementsInterfaces? Directives[Const] - * - extend interface Name ImplementsInterfaces - */ - parseInterfaceTypeExtension(): InterfaceTypeExtensionNode { - const start = this._lexer.token; - this.expectKeyword('extend'); - this.expectKeyword('interface'); - const name = this.parseName(); - const interfaces = this.parseImplementsInterfaces(); - const directives = this.parseConstDirectives(); - const fields = this.parseFieldsDefinition(); - if ( - interfaces.length === 0 && - directives.length === 0 && - fields.length === 0 - ) { - throw this.unexpected(); - } - return this.node(start, { - kind: Kind.INTERFACE_TYPE_EXTENSION, - name, - interfaces, - directives, - fields, - }); - } - - /** - * UnionTypeExtension : - * - extend union Name Directives[Const]? UnionMemberTypes - * - extend union Name Directives[Const] - */ - parseUnionTypeExtension(): UnionTypeExtensionNode { - const start = this._lexer.token; - this.expectKeyword('extend'); - this.expectKeyword('union'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - const types = this.parseUnionMemberTypes(); - if (directives.length === 0 && types.length === 0) { - throw this.unexpected(); - } - return this.node(start, { - kind: Kind.UNION_TYPE_EXTENSION, - name, - directives, - types, - }); - } - - /** - * EnumTypeExtension : - * - extend enum Name Directives[Const]? EnumValuesDefinition - * - extend enum Name Directives[Const] - */ - parseEnumTypeExtension(): EnumTypeExtensionNode { - const start = this._lexer.token; - this.expectKeyword('extend'); - this.expectKeyword('enum'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - const values = this.parseEnumValuesDefinition(); - if (directives.length === 0 && values.length === 0) { - throw this.unexpected(); - } - return this.node(start, { - kind: Kind.ENUM_TYPE_EXTENSION, - name, - directives, - values, - }); - } - - /** - * InputObjectTypeExtension : - * - extend input Name Directives[Const]? InputFieldsDefinition - * - extend input Name Directives[Const] - */ - parseInputObjectTypeExtension(): InputObjectTypeExtensionNode { - const start = this._lexer.token; - this.expectKeyword('extend'); - this.expectKeyword('input'); - const name = this.parseName(); - const directives = this.parseConstDirectives(); - const fields = this.parseInputFieldsDefinition(); - if (directives.length === 0 && fields.length === 0) { - throw this.unexpected(); - } - return this.node(start, { - kind: Kind.INPUT_OBJECT_TYPE_EXTENSION, - name, - directives, - fields, - }); - } - - /** - * ``` - * DirectiveDefinition : - * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations - * ``` - */ - parseDirectiveDefinition(): DirectiveDefinitionNode { - const start = this._lexer.token; - const description = this.parseDescription(); - this.expectKeyword('directive'); - this.expectToken(TokenKind.AT); - const name = this.parseName(); - const args = this.parseArgumentDefs(); - const repeatable = this.expectOptionalKeyword('repeatable'); - this.expectKeyword('on'); - const locations = this.parseDirectiveLocations(); - return this.node(start, { - kind: Kind.DIRECTIVE_DEFINITION, - description, - name, - arguments: args, - repeatable, - locations, - }); - } - - /** - * DirectiveLocations : - * - `|`? DirectiveLocation - * - DirectiveLocations | DirectiveLocation - */ - parseDirectiveLocations(): Array { - return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation); - } - - /* - * DirectiveLocation : - * - ExecutableDirectiveLocation - * - TypeSystemDirectiveLocation - * - * ExecutableDirectiveLocation : one of - * `QUERY` - * `MUTATION` - * `SUBSCRIPTION` - * `FIELD` - * `FRAGMENT_DEFINITION` - * `FRAGMENT_SPREAD` - * `INLINE_FRAGMENT` - * - * TypeSystemDirectiveLocation : one of - * `SCHEMA` - * `SCALAR` - * `OBJECT` - * `FIELD_DEFINITION` - * `ARGUMENT_DEFINITION` - * `INTERFACE` - * `UNION` - * `ENUM` - * `ENUM_VALUE` - * `INPUT_OBJECT` - * `INPUT_FIELD_DEFINITION` - */ - parseDirectiveLocation(): NameNode { - const start = this._lexer.token; - const name = this.parseName(); - if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) { - return name; - } - throw this.unexpected(start); - } - - // Core parsing utility functions - - /** - * Returns a node that, if configured to do so, sets a "loc" field as a - * location object, used to identify the place in the source that created a - * given parsed object. - */ - node(startToken: Token, node: T): T { - if (this._options.noLocation !== true) { - node.loc = new Location( - startToken, - this._lexer.lastToken, - this._lexer.source, - ); - } - return node; - } - - /** - * Determines if the next token is of a given kind - */ - peek(kind: TokenKind): boolean { - return this._lexer.token.kind === kind; - } - - /** - * If the next token is of the given kind, return that token after advancing the lexer. - * Otherwise, do not change the parser state and throw an error. - */ - expectToken(kind: TokenKind): Token { - const token = this._lexer.token; - if (token.kind === kind) { - this.advanceLexer(); - return token; - } - - throw syntaxError( - this._lexer.source, - token.start, - `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`, - ); - } - - /** - * If the next token is of the given kind, return "true" after advancing the lexer. - * Otherwise, do not change the parser state and return "false". - */ - expectOptionalToken(kind: TokenKind): boolean { - const token = this._lexer.token; - if (token.kind === kind) { - this.advanceLexer(); - return true; - } - return false; - } - - /** - * If the next token is a given keyword, advance the lexer. - * Otherwise, do not change the parser state and throw an error. - */ - expectKeyword(value: string): void { - const token = this._lexer.token; - if (token.kind === TokenKind.NAME && token.value === value) { - this.advanceLexer(); - } else { - throw syntaxError( - this._lexer.source, - token.start, - `Expected "${value}", found ${getTokenDesc(token)}.`, - ); - } - } - - /** - * If the next token is a given keyword, return "true" after advancing the lexer. - * Otherwise, do not change the parser state and return "false". - */ - expectOptionalKeyword(value: string): boolean { - const token = this._lexer.token; - if (token.kind === TokenKind.NAME && token.value === value) { - this.advanceLexer(); - return true; - } - return false; - } - - /** - * Helper function for creating an error when an unexpected lexed token is encountered. - */ - unexpected(atToken?: Maybe): GraphQLError { - const token = atToken ?? this._lexer.token; - return syntaxError( - this._lexer.source, - token.start, - `Unexpected ${getTokenDesc(token)}.`, - ); - } - - /** - * Returns a possibly empty list of parse nodes, determined by the parseFn. - * This list begins with a lex token of openKind and ends with a lex token of closeKind. - * Advances the parser to the next lex token after the closing token. - */ - any( - openKind: TokenKind, - parseFn: () => T, - closeKind: TokenKind, - ): Array { - this.expectToken(openKind); - const nodes = []; - while (!this.expectOptionalToken(closeKind)) { - nodes.push(parseFn.call(this)); - } - return nodes; - } - - /** - * Returns a list of parse nodes, determined by the parseFn. - * It can be empty only if open token is missing otherwise it will always return non-empty list - * that begins with a lex token of openKind and ends with a lex token of closeKind. - * Advances the parser to the next lex token after the closing token. - */ - optionalMany( - openKind: TokenKind, - parseFn: () => T, - closeKind: TokenKind, - ): Array { - if (this.expectOptionalToken(openKind)) { - const nodes = []; - do { - nodes.push(parseFn.call(this)); - } while (!this.expectOptionalToken(closeKind)); - return nodes; - } - return []; - } - - /** - * Returns a non-empty list of parse nodes, determined by the parseFn. - * This list begins with a lex token of openKind and ends with a lex token of closeKind. - * Advances the parser to the next lex token after the closing token. - */ - many( - openKind: TokenKind, - parseFn: () => T, - closeKind: TokenKind, - ): Array { - this.expectToken(openKind); - const nodes = []; - do { - nodes.push(parseFn.call(this)); - } while (!this.expectOptionalToken(closeKind)); - return nodes; - } - - /** - * Returns a non-empty list of parse nodes, determined by the parseFn. - * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind. - * Advances the parser to the next lex token after last item in the list. - */ - delimitedMany(delimiterKind: TokenKind, parseFn: () => T): Array { - this.expectOptionalToken(delimiterKind); - - const nodes = []; - do { - nodes.push(parseFn.call(this)); - } while (this.expectOptionalToken(delimiterKind)); - return nodes; - } - - advanceLexer(): void { - const { maxTokens } = this._options; - const token = this._lexer.advance(); - - if (token.kind !== TokenKind.EOF) { - ++this._tokenCounter; - if (maxTokens !== undefined && this._tokenCounter > maxTokens) { - throw syntaxError( - this._lexer.source, - token.start, - `Document contains more that ${maxTokens} tokens. Parsing aborted.`, - ); - } - } - } -} - -/** - * A helper function to describe a token as a string for debugging. - */ -function getTokenDesc(token: Token): string { - const value = token.value; - return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : ''); -} - -/** - * A helper function to describe a token kind as a string for debugging. - */ -function getTokenKindDesc(kind: TokenKind): string { - return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind; -} diff --git a/src/language/predicates.ts b/src/language/predicates.ts deleted file mode 100644 index a390f4ee55..0000000000 --- a/src/language/predicates.ts +++ /dev/null @@ -1,112 +0,0 @@ -import type { - ASTNode, - ConstValueNode, - DefinitionNode, - ExecutableDefinitionNode, - SelectionNode, - TypeDefinitionNode, - TypeExtensionNode, - TypeNode, - TypeSystemDefinitionNode, - TypeSystemExtensionNode, - ValueNode, -} from './ast'; -import { Kind } from './kinds'; - -export function isDefinitionNode(node: ASTNode): node is DefinitionNode { - return ( - isExecutableDefinitionNode(node) || - isTypeSystemDefinitionNode(node) || - isTypeSystemExtensionNode(node) - ); -} - -export function isExecutableDefinitionNode( - node: ASTNode, -): node is ExecutableDefinitionNode { - return ( - node.kind === Kind.OPERATION_DEFINITION || - node.kind === Kind.FRAGMENT_DEFINITION - ); -} - -export function isSelectionNode(node: ASTNode): node is SelectionNode { - return ( - node.kind === Kind.FIELD || - node.kind === Kind.FRAGMENT_SPREAD || - node.kind === Kind.INLINE_FRAGMENT - ); -} - -export function isValueNode(node: ASTNode): node is ValueNode { - return ( - node.kind === Kind.VARIABLE || - node.kind === Kind.INT || - node.kind === Kind.FLOAT || - node.kind === Kind.STRING || - node.kind === Kind.BOOLEAN || - node.kind === Kind.NULL || - node.kind === Kind.ENUM || - node.kind === Kind.LIST || - node.kind === Kind.OBJECT - ); -} - -export function isConstValueNode(node: ASTNode): node is ConstValueNode { - return ( - isValueNode(node) && - (node.kind === Kind.LIST - ? node.values.some(isConstValueNode) - : node.kind === Kind.OBJECT - ? node.fields.some((field) => isConstValueNode(field.value)) - : node.kind !== Kind.VARIABLE) - ); -} - -export function isTypeNode(node: ASTNode): node is TypeNode { - return ( - node.kind === Kind.NAMED_TYPE || - node.kind === Kind.LIST_TYPE || - node.kind === Kind.NON_NULL_TYPE - ); -} - -export function isTypeSystemDefinitionNode( - node: ASTNode, -): node is TypeSystemDefinitionNode { - return ( - node.kind === Kind.SCHEMA_DEFINITION || - isTypeDefinitionNode(node) || - node.kind === Kind.DIRECTIVE_DEFINITION - ); -} - -export function isTypeDefinitionNode( - node: ASTNode, -): node is TypeDefinitionNode { - return ( - node.kind === Kind.SCALAR_TYPE_DEFINITION || - node.kind === Kind.OBJECT_TYPE_DEFINITION || - node.kind === Kind.INTERFACE_TYPE_DEFINITION || - node.kind === Kind.UNION_TYPE_DEFINITION || - node.kind === Kind.ENUM_TYPE_DEFINITION || - node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION - ); -} - -export function isTypeSystemExtensionNode( - node: ASTNode, -): node is TypeSystemExtensionNode { - return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node); -} - -export function isTypeExtensionNode(node: ASTNode): node is TypeExtensionNode { - return ( - node.kind === Kind.SCALAR_TYPE_EXTENSION || - node.kind === Kind.OBJECT_TYPE_EXTENSION || - node.kind === Kind.INTERFACE_TYPE_EXTENSION || - node.kind === Kind.UNION_TYPE_EXTENSION || - node.kind === Kind.ENUM_TYPE_EXTENSION || - node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION - ); -} diff --git a/src/language/printLocation.ts b/src/language/printLocation.ts deleted file mode 100644 index 3d44f5cea5..0000000000 --- a/src/language/printLocation.ts +++ /dev/null @@ -1,80 +0,0 @@ -import type { Location } from './ast'; -import type { SourceLocation } from './location'; -import { getLocation } from './location'; -import type { Source } from './source'; - -/** - * Render a helpful description of the location in the GraphQL Source document. - */ -export function printLocation(location: Location): string { - return printSourceLocation( - location.source, - getLocation(location.source, location.start), - ); -} - -/** - * Render a helpful description of the location in the GraphQL Source document. - */ -export function printSourceLocation( - source: Source, - sourceLocation: SourceLocation, -): string { - const firstLineColumnOffset = source.locationOffset.column - 1; - const body = ''.padStart(firstLineColumnOffset) + source.body; - - const lineIndex = sourceLocation.line - 1; - const lineOffset = source.locationOffset.line - 1; - const lineNum = sourceLocation.line + lineOffset; - - const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0; - const columnNum = sourceLocation.column + columnOffset; - const locationStr = `${source.name}:${lineNum}:${columnNum}\n`; - - const lines = body.split(/\r\n|[\n\r]/g); - const locationLine = lines[lineIndex]; - - // Special case for minified documents - if (locationLine.length > 120) { - const subLineIndex = Math.floor(columnNum / 80); - const subLineColumnNum = columnNum % 80; - const subLines: Array = []; - for (let i = 0; i < locationLine.length; i += 80) { - subLines.push(locationLine.slice(i, i + 80)); - } - - return ( - locationStr + - printPrefixedLines([ - [`${lineNum} |`, subLines[0]], - ...subLines - .slice(1, subLineIndex + 1) - .map((subLine) => ['|', subLine] as const), - ['|', '^'.padStart(subLineColumnNum)], - ['|', subLines[subLineIndex + 1]], - ]) - ); - } - - return ( - locationStr + - printPrefixedLines([ - // Lines specified like this: ["prefix", "string"], - [`${lineNum - 1} |`, lines[lineIndex - 1]], - [`${lineNum} |`, locationLine], - ['|', '^'.padStart(columnNum)], - [`${lineNum + 1} |`, lines[lineIndex + 1]], - ]) - ); -} - -function printPrefixedLines( - lines: ReadonlyArray, -): string { - const existingLines = lines.filter(([_, line]) => line !== undefined); - - const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length)); - return existingLines - .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : '')) - .join('\n'); -} diff --git a/src/language/printString.ts b/src/language/printString.ts deleted file mode 100644 index b091bcc2c1..0000000000 --- a/src/language/printString.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Prints a string as a GraphQL StringValue literal. Replaces control characters - * and excluded characters (" U+0022 and \\ U+005C) with escape sequences. - */ -export function printString(str: string): string { - return `"${str.replace(escapedRegExp, escapedReplacer)}"`; -} - -// eslint-disable-next-line no-control-regex -const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g; - -function escapedReplacer(str: string): string { - return escapeSequences[str.charCodeAt(0)]; -} - -// prettier-ignore -const escapeSequences = [ - '\\u0000', '\\u0001', '\\u0002', '\\u0003', '\\u0004', '\\u0005', '\\u0006', '\\u0007', - '\\b', '\\t', '\\n', '\\u000B', '\\f', '\\r', '\\u000E', '\\u000F', - '\\u0010', '\\u0011', '\\u0012', '\\u0013', '\\u0014', '\\u0015', '\\u0016', '\\u0017', - '\\u0018', '\\u0019', '\\u001A', '\\u001B', '\\u001C', '\\u001D', '\\u001E', '\\u001F', - '', '', '\\"', '', '', '', '', '', - '', '', '', '', '', '', '', '', // 2F - '', '', '', '', '', '', '', '', - '', '', '', '', '', '', '', '', // 3F - '', '', '', '', '', '', '', '', - '', '', '', '', '', '', '', '', // 4F - '', '', '', '', '', '', '', '', - '', '', '', '', '\\\\', '', '', '', // 5F - '', '', '', '', '', '', '', '', - '', '', '', '', '', '', '', '', // 6F - '', '', '', '', '', '', '', '', - '', '', '', '', '', '', '', '\\u007F', - '\\u0080', '\\u0081', '\\u0082', '\\u0083', '\\u0084', '\\u0085', '\\u0086', '\\u0087', - '\\u0088', '\\u0089', '\\u008A', '\\u008B', '\\u008C', '\\u008D', '\\u008E', '\\u008F', - '\\u0090', '\\u0091', '\\u0092', '\\u0093', '\\u0094', '\\u0095', '\\u0096', '\\u0097', - '\\u0098', '\\u0099', '\\u009A', '\\u009B', '\\u009C', '\\u009D', '\\u009E', '\\u009F', -]; diff --git a/src/language/printer.ts b/src/language/printer.ts deleted file mode 100644 index e95c118d8b..0000000000 --- a/src/language/printer.ts +++ /dev/null @@ -1,347 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; - -import type { ASTNode } from './ast'; -import { printBlockString } from './blockString'; -import { printString } from './printString'; -import type { ASTReducer } from './visitor'; -import { visit } from './visitor'; - -/** - * Converts an AST into a string, using one set of reasonable - * formatting rules. - */ -export function print(ast: ASTNode): string { - return visit(ast, printDocASTReducer); -} - -const MAX_LINE_LENGTH = 80; - -const printDocASTReducer: ASTReducer = { - Name: { leave: (node) => node.value }, - Variable: { leave: (node) => '$' + node.name }, - - // Document - - Document: { - leave: (node) => join(node.definitions, '\n\n'), - }, - - OperationDefinition: { - leave(node) { - const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')'); - const prefix = join( - [ - node.operation, - join([node.name, varDefs]), - join(node.directives, ' '), - ], - ' ', - ); - - // Anonymous queries with no directives or variable definitions can use - // the query short form. - return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet; - }, - }, - - VariableDefinition: { - leave: ({ variable, type, defaultValue, directives }) => - variable + - ': ' + - type + - wrap(' = ', defaultValue) + - wrap(' ', join(directives, ' ')), - }, - SelectionSet: { leave: ({ selections }) => block(selections) }, - - Field: { - leave({ alias, name, arguments: args, directives, selectionSet }) { - const prefix = wrap('', alias, ': ') + name; - let argsLine = prefix + wrap('(', join(args, ', '), ')'); - - if (argsLine.length > MAX_LINE_LENGTH) { - argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)'); - } - - return join([argsLine, join(directives, ' '), selectionSet], ' '); - }, - }, - - Argument: { leave: ({ name, value }) => name + ': ' + value }, - - // Fragments - - FragmentSpread: { - leave: ({ name, directives }) => - '...' + name + wrap(' ', join(directives, ' ')), - }, - - InlineFragment: { - leave: ({ typeCondition, directives, selectionSet }) => - join( - [ - '...', - wrap('on ', typeCondition), - join(directives, ' '), - selectionSet, - ], - ' ', - ), - }, - - FragmentDefinition: { - leave: ({ - name, - typeCondition, - variableDefinitions, - directives, - selectionSet, - }) => - // Note: fragment variable definitions are experimental and may be changed - // or removed in the future. - `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + - `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + - selectionSet, - }, - - // Value - - IntValue: { leave: ({ value }) => value }, - FloatValue: { leave: ({ value }) => value }, - StringValue: { - leave: ({ value, block: isBlockString }) => - isBlockString ? printBlockString(value) : printString(value), - }, - BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') }, - NullValue: { leave: () => 'null' }, - EnumValue: { leave: ({ value }) => value }, - ListValue: { leave: ({ values }) => '[' + join(values, ', ') + ']' }, - ObjectValue: { leave: ({ fields }) => '{' + join(fields, ', ') + '}' }, - ObjectField: { leave: ({ name, value }) => name + ': ' + value }, - - // Directive - - Directive: { - leave: ({ name, arguments: args }) => - '@' + name + wrap('(', join(args, ', '), ')'), - }, - - // Type - - NamedType: { leave: ({ name }) => name }, - ListType: { leave: ({ type }) => '[' + type + ']' }, - NonNullType: { leave: ({ type }) => type + '!' }, - - // Type System Definitions - - SchemaDefinition: { - leave: ({ description, directives, operationTypes }) => - wrap('', description, '\n') + - join(['schema', join(directives, ' '), block(operationTypes)], ' '), - }, - - OperationTypeDefinition: { - leave: ({ operation, type }) => operation + ': ' + type, - }, - - ScalarTypeDefinition: { - leave: ({ description, name, directives }) => - wrap('', description, '\n') + - join(['scalar', name, join(directives, ' ')], ' '), - }, - - ObjectTypeDefinition: { - leave: ({ description, name, interfaces, directives, fields }) => - wrap('', description, '\n') + - join( - [ - 'type', - name, - wrap('implements ', join(interfaces, ' & ')), - join(directives, ' '), - block(fields), - ], - ' ', - ), - }, - - FieldDefinition: { - leave: ({ description, name, arguments: args, type, directives }) => - wrap('', description, '\n') + - name + - (hasMultilineItems(args) - ? wrap('(\n', indent(join(args, '\n')), '\n)') - : wrap('(', join(args, ', '), ')')) + - ': ' + - type + - wrap(' ', join(directives, ' ')), - }, - - InputValueDefinition: { - leave: ({ description, name, type, defaultValue, directives }) => - wrap('', description, '\n') + - join( - [name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], - ' ', - ), - }, - - InterfaceTypeDefinition: { - leave: ({ description, name, interfaces, directives, fields }) => - wrap('', description, '\n') + - join( - [ - 'interface', - name, - wrap('implements ', join(interfaces, ' & ')), - join(directives, ' '), - block(fields), - ], - ' ', - ), - }, - - UnionTypeDefinition: { - leave: ({ description, name, directives, types }) => - wrap('', description, '\n') + - join( - ['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], - ' ', - ), - }, - - EnumTypeDefinition: { - leave: ({ description, name, directives, values }) => - wrap('', description, '\n') + - join(['enum', name, join(directives, ' '), block(values)], ' '), - }, - - EnumValueDefinition: { - leave: ({ description, name, directives }) => - wrap('', description, '\n') + join([name, join(directives, ' ')], ' '), - }, - - InputObjectTypeDefinition: { - leave: ({ description, name, directives, fields }) => - wrap('', description, '\n') + - join(['input', name, join(directives, ' '), block(fields)], ' '), - }, - - DirectiveDefinition: { - leave: ({ description, name, arguments: args, repeatable, locations }) => - wrap('', description, '\n') + - 'directive @' + - name + - (hasMultilineItems(args) - ? wrap('(\n', indent(join(args, '\n')), '\n)') - : wrap('(', join(args, ', '), ')')) + - (repeatable ? ' repeatable' : '') + - ' on ' + - join(locations, ' | '), - }, - - SchemaExtension: { - leave: ({ directives, operationTypes }) => - join( - ['extend schema', join(directives, ' '), block(operationTypes)], - ' ', - ), - }, - - ScalarTypeExtension: { - leave: ({ name, directives }) => - join(['extend scalar', name, join(directives, ' ')], ' '), - }, - - ObjectTypeExtension: { - leave: ({ name, interfaces, directives, fields }) => - join( - [ - 'extend type', - name, - wrap('implements ', join(interfaces, ' & ')), - join(directives, ' '), - block(fields), - ], - ' ', - ), - }, - - InterfaceTypeExtension: { - leave: ({ name, interfaces, directives, fields }) => - join( - [ - 'extend interface', - name, - wrap('implements ', join(interfaces, ' & ')), - join(directives, ' '), - block(fields), - ], - ' ', - ), - }, - - UnionTypeExtension: { - leave: ({ name, directives, types }) => - join( - [ - 'extend union', - name, - join(directives, ' '), - wrap('= ', join(types, ' | ')), - ], - ' ', - ), - }, - - EnumTypeExtension: { - leave: ({ name, directives, values }) => - join(['extend enum', name, join(directives, ' '), block(values)], ' '), - }, - - InputObjectTypeExtension: { - leave: ({ name, directives, fields }) => - join(['extend input', name, join(directives, ' '), block(fields)], ' '), - }, -}; - -/** - * Given maybeArray, print an empty string if it is null or empty, otherwise - * print all items together separated by separator if provided - */ -function join( - maybeArray: Maybe>, - separator = '', -): string { - return maybeArray?.filter((x) => x).join(separator) ?? ''; -} - -/** - * Given array, print each item on its own line, wrapped in an indented `{ }` block. - */ -function block(array: Maybe>): string { - return wrap('{\n', indent(join(array, '\n')), '\n}'); -} - -/** - * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string. - */ -function wrap( - start: string, - maybeString: Maybe, - end: string = '', -): string { - return maybeString != null && maybeString !== '' - ? start + maybeString + end - : ''; -} - -function indent(str: string): string { - return wrap(' ', str.replace(/\n/g, '\n ')); -} - -function hasMultilineItems(maybeArray: Maybe>): boolean { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - return maybeArray?.some((str) => str.includes('\n')) ?? false; -} diff --git a/src/language/source.ts b/src/language/source.ts deleted file mode 100644 index 15f65fceee..0000000000 --- a/src/language/source.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; -import { instanceOf } from '../jsutils/instanceOf'; - -interface Location { - line: number; - column: number; -} - -/** - * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are - * optional, but they are useful for clients who store GraphQL documents in source files. - * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might - * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`. - * The `line` and `column` properties in `locationOffset` are 1-indexed. - */ -export class Source { - body: string; - name: string; - locationOffset: Location; - - constructor( - body: string, - name: string = 'GraphQL request', - locationOffset: Location = { line: 1, column: 1 }, - ) { - devAssert( - typeof body === 'string', - `Body must be a string. Received: ${inspect(body)}.`, - ); - - this.body = body; - this.name = name; - this.locationOffset = locationOffset; - devAssert( - this.locationOffset.line > 0, - 'line in locationOffset is 1-indexed and must be positive.', - ); - devAssert( - this.locationOffset.column > 0, - 'column in locationOffset is 1-indexed and must be positive.', - ); - } - - get [Symbol.toStringTag]() { - return 'Source'; - } -} - -/** - * Test if the given value is a Source object. - * - * @internal - */ -export function isSource(source: unknown): source is Source { - return instanceOf(source, Source); -} diff --git a/src/language/tokenKind.ts b/src/language/tokenKind.ts deleted file mode 100644 index 0c260df99e..0000000000 --- a/src/language/tokenKind.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * An exported enum describing the different kinds of tokens that the - * lexer emits. - */ -enum TokenKind { - SOF = '', - EOF = '', - BANG = '!', - DOLLAR = '$', - AMP = '&', - PAREN_L = '(', - PAREN_R = ')', - SPREAD = '...', - COLON = ':', - EQUALS = '=', - AT = '@', - BRACKET_L = '[', - BRACKET_R = ']', - BRACE_L = '{', - PIPE = '|', - BRACE_R = '}', - NAME = 'Name', - INT = 'Int', - FLOAT = 'Float', - STRING = 'String', - BLOCK_STRING = 'BlockString', - COMMENT = 'Comment', -} -export { TokenKind }; - -/** - * The enum type representing the token kinds values. - * - * @deprecated Please use `TokenKind`. Will be remove in v17. - */ -export type TokenKindEnum = typeof TokenKind; diff --git a/src/language/visitor.ts b/src/language/visitor.ts deleted file mode 100644 index b392feeff0..0000000000 --- a/src/language/visitor.ts +++ /dev/null @@ -1,409 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; - -import type { ASTNode } from './ast'; -import { isNode, QueryDocumentKeys } from './ast'; -import { Kind } from './kinds'; - -/** - * A visitor is provided to visit, it contains the collection of - * relevant functions to be called during the visitor's traversal. - */ -export type ASTVisitor = EnterLeaveVisitor | KindVisitor; - -type KindVisitor = { - readonly [NodeT in ASTNode as NodeT['kind']]?: - | ASTVisitFn - | EnterLeaveVisitor; -}; - -interface EnterLeaveVisitor { - readonly enter?: ASTVisitFn; - readonly leave?: ASTVisitFn; -} - -/** - * A visitor is comprised of visit functions, which are called on each node - * during the visitor's traversal. - */ -export type ASTVisitFn = ( - /** The current node being visiting. */ - node: TVisitedNode, - /** The index or key to this node from the parent node or Array. */ - key: string | number | undefined, - /** The parent immediately above this node, which may be an Array. */ - parent: ASTNode | ReadonlyArray | undefined, - /** The key path to get to this node from the root node. */ - path: ReadonlyArray, - /** - * All nodes and Arrays visited before reaching parent of this node. - * These correspond to array indices in `path`. - * Note: ancestors includes arrays which contain the parent of visited node. - */ - ancestors: ReadonlyArray>, -) => any; - -/** - * A reducer is comprised of reducer functions which convert AST nodes into - * another form. - */ -export type ASTReducer = { - readonly [NodeT in ASTNode as NodeT['kind']]?: { - readonly enter?: ASTVisitFn; - readonly leave: ASTReducerFn; - }; -}; - -type ASTReducerFn = ( - /** The current node being visiting. */ - node: { [K in keyof TReducedNode]: ReducedField }, - /** The index or key to this node from the parent node or Array. */ - key: string | number | undefined, - /** The parent immediately above this node, which may be an Array. */ - parent: ASTNode | ReadonlyArray | undefined, - /** The key path to get to this node from the root node. */ - path: ReadonlyArray, - /** - * All nodes and Arrays visited before reaching parent of this node. - * These correspond to array indices in `path`. - * Note: ancestors includes arrays which contain the parent of visited node. - */ - ancestors: ReadonlyArray>, -) => R; - -type ReducedField = T extends null | undefined - ? T - : T extends ReadonlyArray - ? ReadonlyArray - : R; - -/** - * A KeyMap describes each the traversable properties of each kind of node. - * - * @deprecated Please inline it. Will be removed in v17 - */ -export type ASTVisitorKeyMap = { - [NodeT in ASTNode as NodeT['kind']]?: ReadonlyArray; -}; - -export const BREAK: unknown = Object.freeze({}); - -/** - * visit() will walk through an AST using a depth-first traversal, calling - * the visitor's enter function at each node in the traversal, and calling the - * leave function after visiting that node and all of its child nodes. - * - * By returning different values from the enter and leave functions, the - * behavior of the visitor can be altered, including skipping over a sub-tree of - * the AST (by returning false), editing the AST by returning a value or null - * to remove the value, or to stop the whole traversal by returning BREAK. - * - * When using visit() to edit an AST, the original AST will not be modified, and - * a new version of the AST with the changes applied will be returned from the - * visit function. - * - * ```ts - * const editedAST = visit(ast, { - * enter(node, key, parent, path, ancestors) { - * // @return - * // undefined: no action - * // false: skip visiting this node - * // visitor.BREAK: stop visiting altogether - * // null: delete this node - * // any value: replace this node with the returned value - * }, - * leave(node, key, parent, path, ancestors) { - * // @return - * // undefined: no action - * // false: no action - * // visitor.BREAK: stop visiting altogether - * // null: delete this node - * // any value: replace this node with the returned value - * } - * }); - * ``` - * - * Alternatively to providing enter() and leave() functions, a visitor can - * instead provide functions named the same as the kinds of AST nodes, or - * enter/leave visitors at a named key, leading to three permutations of the - * visitor API: - * - * 1) Named visitors triggered when entering a node of a specific kind. - * - * ```ts - * visit(ast, { - * Kind(node) { - * // enter the "Kind" node - * } - * }) - * ``` - * - * 2) Named visitors that trigger upon entering and leaving a node of a specific kind. - * - * ```ts - * visit(ast, { - * Kind: { - * enter(node) { - * // enter the "Kind" node - * } - * leave(node) { - * // leave the "Kind" node - * } - * } - * }) - * ``` - * - * 3) Generic visitors that trigger upon entering and leaving any node. - * - * ```ts - * visit(ast, { - * enter(node) { - * // enter any node - * }, - * leave(node) { - * // leave any node - * } - * }) - * ``` - */ -export function visit( - root: N, - visitor: ASTVisitor, - visitorKeys?: ASTVisitorKeyMap, -): N; -export function visit( - root: ASTNode, - visitor: ASTReducer, - visitorKeys?: ASTVisitorKeyMap, -): R; -export function visit( - root: ASTNode, - visitor: ASTVisitor | ASTReducer, - visitorKeys: ASTVisitorKeyMap = QueryDocumentKeys, -): any { - const enterLeaveMap = new Map>(); - for (const kind of Object.values(Kind)) { - enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); - } - - /* eslint-disable no-undef-init */ - let stack: any = undefined; - let inArray = Array.isArray(root); - let keys: any = [root]; - let index = -1; - let edits = []; - let node: any = root; - let key: any = undefined; - let parent: any = undefined; - const path: any = []; - const ancestors = []; - /* eslint-enable no-undef-init */ - - do { - index++; - const isLeaving = index === keys.length; - const isEdited = isLeaving && edits.length !== 0; - if (isLeaving) { - key = ancestors.length === 0 ? undefined : path[path.length - 1]; - node = parent; - parent = ancestors.pop(); - if (isEdited) { - if (inArray) { - node = node.slice(); - - let editOffset = 0; - for (const [editKey, editValue] of edits) { - const arrayKey = editKey - editOffset; - if (editValue === null) { - node.splice(arrayKey, 1); - editOffset++; - } else { - node[arrayKey] = editValue; - } - } - } else { - node = { ...node }; - for (const [editKey, editValue] of edits) { - node[editKey] = editValue; - } - } - } - index = stack.index; - keys = stack.keys; - edits = stack.edits; - inArray = stack.inArray; - stack = stack.prev; - } else if (parent) { - key = inArray ? index : keys[index]; - node = parent[key]; - if (node === null || node === undefined) { - continue; - } - path.push(key); - } - - let result; - if (!Array.isArray(node)) { - devAssert(isNode(node), `Invalid AST Node: ${inspect(node)}.`); - - const visitFn = isLeaving - ? enterLeaveMap.get(node.kind)?.leave - : enterLeaveMap.get(node.kind)?.enter; - - result = visitFn?.call(visitor, node, key, parent, path, ancestors); - - if (result === BREAK) { - break; - } - - if (result === false) { - if (!isLeaving) { - path.pop(); - continue; - } - } else if (result !== undefined) { - edits.push([key, result]); - if (!isLeaving) { - if (isNode(result)) { - node = result; - } else { - path.pop(); - continue; - } - } - } - } - - if (result === undefined && isEdited) { - edits.push([key, node]); - } - - if (isLeaving) { - path.pop(); - } else { - stack = { inArray, index, keys, edits, prev: stack }; - inArray = Array.isArray(node); - keys = inArray ? node : (visitorKeys as any)[node.kind] ?? []; - index = -1; - edits = []; - if (parent) { - ancestors.push(parent); - } - parent = node; - } - } while (stack !== undefined); - - if (edits.length !== 0) { - // New root - return edits[edits.length - 1][1]; - } - - return root; -} - -/** - * Creates a new visitor instance which delegates to many visitors to run in - * parallel. Each visitor will be visited for each node before moving on. - * - * If a prior visitor edits a node, no following visitors will see that node. - */ -export function visitInParallel( - visitors: ReadonlyArray, -): ASTVisitor { - const skipping = new Array(visitors.length).fill(null); - const mergedVisitor = Object.create(null); - - for (const kind of Object.values(Kind)) { - let hasVisitor = false; - const enterList = new Array(visitors.length).fill(undefined); - const leaveList = new Array(visitors.length).fill(undefined); - - for (let i = 0; i < visitors.length; ++i) { - const { enter, leave } = getEnterLeaveForKind(visitors[i], kind); - hasVisitor ||= enter != null || leave != null; - enterList[i] = enter; - leaveList[i] = leave; - } - - if (!hasVisitor) { - continue; - } - - const mergedEnterLeave: EnterLeaveVisitor = { - enter(...args) { - const node = args[0]; - for (let i = 0; i < visitors.length; i++) { - if (skipping[i] === null) { - const result = enterList[i]?.apply(visitors[i], args); - if (result === false) { - skipping[i] = node; - } else if (result === BREAK) { - skipping[i] = BREAK; - } else if (result !== undefined) { - return result; - } - } - } - }, - leave(...args) { - const node = args[0]; - for (let i = 0; i < visitors.length; i++) { - if (skipping[i] === null) { - const result = leaveList[i]?.apply(visitors[i], args); - if (result === BREAK) { - skipping[i] = BREAK; - } else if (result !== undefined && result !== false) { - return result; - } - } else if (skipping[i] === node) { - skipping[i] = null; - } - } - }, - }; - - mergedVisitor[kind] = mergedEnterLeave; - } - - return mergedVisitor; -} - -/** - * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind. - */ -export function getEnterLeaveForKind( - visitor: ASTVisitor, - kind: Kind, -): EnterLeaveVisitor { - const kindVisitor: - | ASTVisitFn - | EnterLeaveVisitor - | undefined = (visitor as any)[kind]; - - if (typeof kindVisitor === 'object') { - // { Kind: { enter() {}, leave() {} } } - return kindVisitor; - } else if (typeof kindVisitor === 'function') { - // { Kind() {} } - return { enter: kindVisitor, leave: undefined }; - } - - // { enter() {}, leave() {} } - return { enter: (visitor as any).enter, leave: (visitor as any).leave }; -} - -/** - * Given a visitor instance, if it is leaving or not, and a node kind, return - * the function the visitor runtime should call. - * - * @deprecated Please use `getEnterLeaveForKind` instead. Will be removed in v17 - */ -/* c8 ignore next 8 */ -export function getVisitFn( - visitor: ASTVisitor, - kind: Kind, - isLeaving: boolean, -): ASTVisitFn | undefined { - const { enter, leave } = getEnterLeaveForKind(visitor, kind); - return isLeaving ? leave : enter; -} diff --git a/src/subscription/README.md b/src/subscription/README.md deleted file mode 100644 index 7e099d2cfc..0000000000 --- a/src/subscription/README.md +++ /dev/null @@ -1,10 +0,0 @@ -## GraphQL Subscription - -NOTE: the `graphql/subscription` module has been deprecated with its exported functions integrated into the `graphql/execution` module, to better conform with the terminology of the GraphQL specification. For backwards compatibility, the `graphql/subscription` module currently re-exports the moved functions from the `graphql/execution` module. In the next major release, the `graphql/subscription` module will be dropped entirely. - -The `graphql/subscription` module is responsible for subscribing to updates on specific data. - -```js -import { subscribe, createSourceEventStream } from 'graphql/subscription'; // ES6 -var GraphQLSubscription = require('graphql/subscription'); // CommonJS -``` diff --git a/src/subscription/index.ts b/src/subscription/index.ts deleted file mode 100644 index 9de1b86968..0000000000 --- a/src/subscription/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * NOTE: the `graphql/subscription` module has been deprecated with its - * exported functions integrated into the `graphql/execution` module, to - * better conform with the terminology of the GraphQL specification. - * - * For backwards compatibility, the `graphql/subscription` module - * currently re-exports the moved functions from the `graphql/execution` - * module. In the next major release, the `graphql/subscription` module - * will be dropped entirely. - */ - -import type { ExecutionArgs } from '../execution/execute'; - -/** - * @deprecated use ExecutionArgs instead. Will be removed in v17 - * - * ExecutionArgs has been broadened to include all properties within SubscriptionArgs. - * The SubscriptionArgs type is retained for backwards compatibility. - */ -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface SubscriptionArgs extends ExecutionArgs {} - -export { subscribe, createSourceEventStream } from '../execution/subscribe'; diff --git a/src/type/README.md b/src/type/README.md deleted file mode 100644 index 1c03491a3a..0000000000 --- a/src/type/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## GraphQL Type System - -The `graphql/type` module is responsible for defining GraphQL types and schema. - -```js -import { ... } from 'graphql/type'; // ES6 -var GraphQLType = require('graphql/type'); // CommonJS -``` diff --git a/src/type/__tests__/assertName-test.ts b/src/type/__tests__/assertName-test.ts deleted file mode 100644 index 268b1c6ecb..0000000000 --- a/src/type/__tests__/assertName-test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { assertEnumValueName, assertName } from '../assertName'; - -describe('assertName', () => { - it('passthrough valid name', () => { - expect(assertName('_ValidName123')).to.equal('_ValidName123'); - }); - - it('throws for non-strings', () => { - // @ts-expect-error - expect(() => assertName({})).to.throw('Expected name to be a string.'); - }); - - it('throws on empty strings', () => { - expect(() => assertName('')).to.throw( - 'Expected name to be a non-empty string.', - ); - }); - - it('throws for names with invalid characters', () => { - expect(() => assertName('>--()-->')).to.throw( - 'Names must only contain [_a-zA-Z0-9] but ">--()-->" does not.', - ); - }); - - it('throws for names starting with invalid characters', () => { - expect(() => assertName('42MeaningsOfLife')).to.throw( - 'Names must start with [_a-zA-Z] but "42MeaningsOfLife" does not.', - ); - }); -}); - -describe('assertEnumValueName', () => { - it('passthrough valid name', () => { - expect(assertEnumValueName('_ValidName123')).to.equal('_ValidName123'); - }); - - it('throws on empty strings', () => { - expect(() => assertEnumValueName('')).to.throw( - 'Expected name to be a non-empty string.', - ); - }); - - it('throws for names with invalid characters', () => { - expect(() => assertEnumValueName('>--()-->')).to.throw( - 'Names must only contain [_a-zA-Z0-9] but ">--()-->" does not.', - ); - }); - - it('throws for names starting with invalid characters', () => { - expect(() => assertEnumValueName('42MeaningsOfLife')).to.throw( - 'Names must start with [_a-zA-Z] but "42MeaningsOfLife" does not.', - ); - }); - - it('throws for restricted names', () => { - expect(() => assertEnumValueName('true')).to.throw( - 'Enum values cannot be named: true', - ); - expect(() => assertEnumValueName('false')).to.throw( - 'Enum values cannot be named: false', - ); - expect(() => assertEnumValueName('null')).to.throw( - 'Enum values cannot be named: null', - ); - }); -}); diff --git a/src/type/__tests__/definition-test.ts b/src/type/__tests__/definition-test.ts deleted file mode 100644 index 19d482915a..0000000000 --- a/src/type/__tests__/definition-test.ts +++ /dev/null @@ -1,1009 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { identityFunc } from '../../jsutils/identityFunc'; -import { inspect } from '../../jsutils/inspect'; - -import { parseValue } from '../../language/parser'; - -import type { GraphQLNullableType, GraphQLType } from '../definition'; -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, -} from '../definition'; - -const ScalarType = new GraphQLScalarType({ name: 'Scalar' }); -const ObjectType = new GraphQLObjectType({ name: 'Object', fields: {} }); -const InterfaceType = new GraphQLInterfaceType({ - name: 'Interface', - fields: {}, -}); -const UnionType = new GraphQLUnionType({ name: 'Union', types: [ObjectType] }); -const EnumType = new GraphQLEnumType({ name: 'Enum', values: { foo: {} } }); -const InputObjectType = new GraphQLInputObjectType({ - name: 'InputObject', - fields: {}, -}); - -const ListOfScalarsType = new GraphQLList(ScalarType); -const NonNullScalarType = new GraphQLNonNull(ScalarType); -const ListOfNonNullScalarsType = new GraphQLList(NonNullScalarType); -const NonNullListOfScalars = new GraphQLNonNull(ListOfScalarsType); - -/* c8 ignore next */ -const dummyFunc = () => expect.fail('Never called and used as a placeholder'); - -describe('Type System: Scalars', () => { - it('accepts a Scalar type defining serialize', () => { - expect(() => new GraphQLScalarType({ name: 'SomeScalar' })).to.not.throw(); - }); - - it('accepts a Scalar type defining specifiedByURL', () => { - expect( - () => - new GraphQLScalarType({ - name: 'SomeScalar', - specifiedByURL: 'https://example.com/foo_spec', - }), - ).not.to.throw(); - }); - - it('accepts a Scalar type defining parseValue and parseLiteral', () => { - expect( - () => - new GraphQLScalarType({ - name: 'SomeScalar', - parseValue: dummyFunc, - parseLiteral: dummyFunc, - }), - ).to.not.throw(); - }); - - it('provides default methods if omitted', () => { - const scalar = new GraphQLScalarType({ name: 'Foo' }); - - expect(scalar.serialize).to.equal(identityFunc); - expect(scalar.parseValue).to.equal(identityFunc); - expect(scalar.parseLiteral).to.be.a('function'); - }); - - it('use parseValue for parsing literals if parseLiteral omitted', () => { - const scalar = new GraphQLScalarType({ - name: 'Foo', - parseValue(value) { - return 'parseValue: ' + inspect(value); - }, - }); - - expect(scalar.parseLiteral(parseValue('null'))).to.equal( - 'parseValue: null', - ); - expect(scalar.parseLiteral(parseValue('{ foo: "bar" }'))).to.equal( - 'parseValue: { foo: "bar" }', - ); - expect( - scalar.parseLiteral(parseValue('{ foo: { bar: $var } }'), { var: 'baz' }), - ).to.equal('parseValue: { foo: { bar: "baz" } }'); - }); - - it('rejects a Scalar type without name', () => { - // @ts-expect-error - expect(() => new GraphQLScalarType({})).to.throw('Must provide name.'); - }); - - it('rejects a Scalar type defining serialize with an incorrect type', () => { - expect( - () => - new GraphQLScalarType({ - name: 'SomeScalar', - // @ts-expect-error - serialize: {}, - }), - ).to.throw( - 'SomeScalar must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.', - ); - }); - - it('rejects a Scalar type defining parseLiteral but not parseValue', () => { - expect( - () => - new GraphQLScalarType({ - name: 'SomeScalar', - parseLiteral: dummyFunc, - }), - ).to.throw( - 'SomeScalar must provide both "parseValue" and "parseLiteral" functions.', - ); - }); - - it('rejects a Scalar type defining parseValue and parseLiteral with an incorrect type', () => { - expect( - () => - new GraphQLScalarType({ - name: 'SomeScalar', - // @ts-expect-error - parseValue: {}, - // @ts-expect-error - parseLiteral: {}, - }), - ).to.throw( - 'SomeScalar must provide both "parseValue" and "parseLiteral" functions.', - ); - }); - - it('rejects a Scalar type defining specifiedByURL with an incorrect type', () => { - expect( - () => - new GraphQLScalarType({ - name: 'SomeScalar', - // @ts-expect-error - specifiedByURL: {}, - }), - ).to.throw( - 'SomeScalar must provide "specifiedByURL" as a string, but got: {}.', - ); - }); -}); - -describe('Type System: Objects', () => { - it('does not mutate passed field definitions', () => { - const outputFields = { - field1: { type: ScalarType }, - field2: { - type: ScalarType, - args: { - id: { type: ScalarType }, - }, - }, - }; - const testObject1 = new GraphQLObjectType({ - name: 'Test1', - fields: outputFields, - }); - const testObject2 = new GraphQLObjectType({ - name: 'Test2', - fields: outputFields, - }); - - expect(testObject1.getFields()).to.deep.equal(testObject2.getFields()); - expect(outputFields).to.deep.equal({ - field1: { - type: ScalarType, - }, - field2: { - type: ScalarType, - args: { - id: { type: ScalarType }, - }, - }, - }); - - const inputFields = { - field1: { type: ScalarType }, - field2: { type: ScalarType }, - }; - const testInputObject1 = new GraphQLInputObjectType({ - name: 'Test1', - fields: inputFields, - }); - const testInputObject2 = new GraphQLInputObjectType({ - name: 'Test2', - fields: inputFields, - }); - - expect(testInputObject1.getFields()).to.deep.equal( - testInputObject2.getFields(), - ); - expect(inputFields).to.deep.equal({ - field1: { type: ScalarType }, - field2: { type: ScalarType }, - }); - }); - - it('defines an object type with deprecated field', () => { - const TypeWithDeprecatedField = new GraphQLObjectType({ - name: 'foo', - fields: { - bar: { - type: ScalarType, - deprecationReason: 'A terrible reason', - }, - baz: { - type: ScalarType, - deprecationReason: '', - }, - }, - }); - - expect(TypeWithDeprecatedField.getFields().bar).to.include({ - name: 'bar', - deprecationReason: 'A terrible reason', - }); - - expect(TypeWithDeprecatedField.getFields().baz).to.include({ - name: 'baz', - deprecationReason: '', - }); - }); - - it('accepts an Object type with a field function', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: () => ({ - f: { type: ScalarType }, - }), - }); - expect(objType.getFields()).to.deep.equal({ - f: { - name: 'f', - description: undefined, - type: ScalarType, - args: [], - resolve: undefined, - subscribe: undefined, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - }); - }); - - it('accepts an Object type with field args', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - f: { - type: ScalarType, - args: { - arg: { type: ScalarType }, - }, - }, - }, - }); - expect(objType.getFields()).to.deep.equal({ - f: { - name: 'f', - description: undefined, - type: ScalarType, - args: [ - { - name: 'arg', - description: undefined, - type: ScalarType, - defaultValue: undefined, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - ], - resolve: undefined, - subscribe: undefined, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - }); - }); - - it('accepts an Object type with array interfaces', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: {}, - interfaces: [InterfaceType], - }); - expect(objType.getInterfaces()).to.deep.equal([InterfaceType]); - }); - - it('accepts an Object type with interfaces as a function returning an array', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: {}, - interfaces: () => [InterfaceType], - }); - expect(objType.getInterfaces()).to.deep.equal([InterfaceType]); - }); - - it('accepts a lambda as an Object field resolver', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - f: { - type: ScalarType, - resolve: dummyFunc, - }, - }, - }); - expect(() => objType.getFields()).to.not.throw(); - }); - - it('rejects an Object type with invalid name', () => { - expect( - () => new GraphQLObjectType({ name: 'bad-name', fields: {} }), - ).to.throw('Names must only contain [_a-zA-Z0-9] but "bad-name" does not.'); - }); - - it('rejects an Object type field with undefined config', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - // @ts-expect-error (must not be undefined) - f: undefined, - }, - }); - expect(() => objType.getFields()).to.throw( - 'SomeObject.f field config must be an object.', - ); - }); - - it('rejects an Object type with incorrectly typed fields', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - // @ts-expect-error - fields: [{ field: ScalarType }], - }); - expect(() => objType.getFields()).to.throw( - 'SomeObject fields must be an object with field names as keys or a function which returns such an object.', - ); - }); - - it('rejects an Object type with incorrectly named fields', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - 'bad-name': { type: ScalarType }, - }, - }); - expect(() => objType.getFields()).to.throw( - 'Names must only contain [_a-zA-Z0-9] but "bad-name" does not.', - ); - }); - - it('rejects an Object type with a field function that returns incorrect type', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - // @ts-expect-error (Wrong type of return) - fields() { - return [{ field: ScalarType }]; - }, - }); - expect(() => objType.getFields()).to.throw(); - }); - - it('rejects an Object type with incorrectly typed field args', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - badField: { - type: ScalarType, - // @ts-expect-error - args: [{ badArg: ScalarType }], - }, - }, - }); - expect(() => objType.getFields()).to.throw( - 'SomeObject.badField args must be an object with argument names as keys.', - ); - }); - - it('rejects an Object type with incorrectly named field args', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - badField: { - type: ScalarType, - args: { - 'bad-name': { type: ScalarType }, - }, - }, - }, - }); - expect(() => objType.getFields()).to.throw( - 'Names must only contain [_a-zA-Z0-9] but "bad-name" does not.', - ); - }); - - it('rejects an Object type with incorrectly typed interfaces', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: {}, - // @ts-expect-error - interfaces: {}, - }); - expect(() => objType.getInterfaces()).to.throw( - 'SomeObject interfaces must be an Array or a function which returns an Array.', - ); - }); - - it('rejects an Object type with interfaces as a function returning an incorrect type', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: {}, - // @ts-expect-error (Expected interfaces to return array) - interfaces() { - return {}; - }, - }); - expect(() => objType.getInterfaces()).to.throw( - 'SomeObject interfaces must be an Array or a function which returns an Array.', - ); - }); - - it('rejects an empty Object field resolver', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - // @ts-expect-error (Expected resolve to be a function) - field: { type: ScalarType, resolve: {} }, - }, - }); - - expect(() => objType.getFields()).to.throw( - 'SomeObject.field field resolver must be a function if provided, but got: {}.', - ); - }); - - it('rejects a constant scalar value resolver', () => { - const objType = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - // @ts-expect-error (Expected resolve to be a function) - field: { type: ScalarType, resolve: 0 }, - }, - }); - - expect(() => objType.getFields()).to.throw( - 'SomeObject.field field resolver must be a function if provided, but got: 0.', - ); - }); - - it('rejects an Object type with an incorrect type for isTypeOf', () => { - expect( - () => - new GraphQLObjectType({ - name: 'AnotherObject', - fields: {}, - // @ts-expect-error - isTypeOf: {}, - }), - ).to.throw( - 'AnotherObject must provide "isTypeOf" as a function, but got: {}.', - ); - }); -}); - -describe('Type System: Interfaces', () => { - it('accepts an Interface type defining resolveType', () => { - expect( - () => - new GraphQLInterfaceType({ - name: 'AnotherInterface', - fields: { f: { type: ScalarType } }, - }), - ).to.not.throw(); - }); - - it('accepts an Interface type with an array of interfaces', () => { - const implementing = new GraphQLInterfaceType({ - name: 'AnotherInterface', - fields: {}, - interfaces: [InterfaceType], - }); - expect(implementing.getInterfaces()).to.deep.equal([InterfaceType]); - }); - - it('accepts an Interface type with interfaces as a function returning an array', () => { - const implementing = new GraphQLInterfaceType({ - name: 'AnotherInterface', - fields: {}, - interfaces: () => [InterfaceType], - }); - expect(implementing.getInterfaces()).to.deep.equal([InterfaceType]); - }); - - it('rejects an Interface type with invalid name', () => { - expect( - () => new GraphQLInterfaceType({ name: 'bad-name', fields: {} }), - ).to.throw('Names must only contain [_a-zA-Z0-9] but "bad-name" does not.'); - }); - - it('rejects an Interface type with incorrectly typed interfaces', () => { - const objType = new GraphQLInterfaceType({ - name: 'AnotherInterface', - fields: {}, - // @ts-expect-error - interfaces: {}, - }); - expect(() => objType.getInterfaces()).to.throw( - 'AnotherInterface interfaces must be an Array or a function which returns an Array.', - ); - }); - - it('rejects an Interface type with interfaces as a function returning an incorrect type', () => { - const objType = new GraphQLInterfaceType({ - name: 'AnotherInterface', - fields: {}, - // @ts-expect-error (Expected Array return) - interfaces() { - return {}; - }, - }); - expect(() => objType.getInterfaces()).to.throw( - 'AnotherInterface interfaces must be an Array or a function which returns an Array.', - ); - }); - - it('rejects an Interface type with an incorrect type for resolveType', () => { - expect( - () => - new GraphQLInterfaceType({ - name: 'AnotherInterface', - fields: {}, - // @ts-expect-error - resolveType: {}, - }), - ).to.throw( - 'AnotherInterface must provide "resolveType" as a function, but got: {}.', - ); - }); -}); - -describe('Type System: Unions', () => { - it('accepts a Union type defining resolveType', () => { - expect( - () => - new GraphQLUnionType({ - name: 'SomeUnion', - types: [ObjectType], - }), - ).to.not.throw(); - }); - - it('accepts a Union type with array types', () => { - const unionType = new GraphQLUnionType({ - name: 'SomeUnion', - types: [ObjectType], - }); - expect(unionType.getTypes()).to.deep.equal([ObjectType]); - }); - - it('accepts a Union type with function returning an array of types', () => { - const unionType = new GraphQLUnionType({ - name: 'SomeUnion', - types: () => [ObjectType], - }); - expect(unionType.getTypes()).to.deep.equal([ObjectType]); - }); - - it('accepts a Union type without types', () => { - const unionType = new GraphQLUnionType({ - name: 'SomeUnion', - types: [], - }); - expect(unionType.getTypes()).to.deep.equal([]); - }); - - it('rejects an Union type with invalid name', () => { - expect( - () => new GraphQLUnionType({ name: 'bad-name', types: [] }), - ).to.throw('Names must only contain [_a-zA-Z0-9] but "bad-name" does not.'); - }); - - it('rejects an Union type with an incorrect type for resolveType', () => { - expect( - () => - new GraphQLUnionType({ - name: 'SomeUnion', - types: [], - // @ts-expect-error - resolveType: {}, - }), - ).to.throw( - 'SomeUnion must provide "resolveType" as a function, but got: {}.', - ); - }); - - it('rejects a Union type with incorrectly typed types', () => { - const unionType = new GraphQLUnionType({ - name: 'SomeUnion', - // @ts-expect-error - types: { ObjectType }, - }); - - expect(() => unionType.getTypes()).to.throw( - 'Must provide Array of types or a function which returns such an array for Union SomeUnion.', - ); - }); -}); - -describe('Type System: Enums', () => { - it('defines an enum type with deprecated value', () => { - const EnumTypeWithDeprecatedValue = new GraphQLEnumType({ - name: 'EnumWithDeprecatedValue', - values: { - foo: { deprecationReason: 'Just because' }, - bar: { deprecationReason: '' }, - }, - }); - - expect(EnumTypeWithDeprecatedValue.getValues()[0]).to.include({ - name: 'foo', - deprecationReason: 'Just because', - }); - - expect(EnumTypeWithDeprecatedValue.getValues()[1]).to.include({ - name: 'bar', - deprecationReason: '', - }); - }); - - it('defines an enum type with a value of `null` and `undefined`', () => { - const EnumTypeWithNullishValue = new GraphQLEnumType({ - name: 'EnumWithNullishValue', - values: { - NULL: { value: null }, - NAN: { value: NaN }, - NO_CUSTOM_VALUE: { value: undefined }, - }, - }); - - expect(EnumTypeWithNullishValue.getValues()).to.deep.equal([ - { - name: 'NULL', - description: undefined, - value: null, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - { - name: 'NAN', - description: undefined, - value: NaN, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - { - name: 'NO_CUSTOM_VALUE', - description: undefined, - value: 'NO_CUSTOM_VALUE', - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - ]); - }); - - it('accepts a well defined Enum type with empty value definition', () => { - const enumType = new GraphQLEnumType({ - name: 'SomeEnum', - values: { - FOO: {}, - BAR: {}, - }, - }); - expect(enumType.getValue('FOO')).has.property('value', 'FOO'); - expect(enumType.getValue('BAR')).has.property('value', 'BAR'); - }); - - it('accepts a well defined Enum type with internal value definition', () => { - const enumType = new GraphQLEnumType({ - name: 'SomeEnum', - values: { - FOO: { value: 10 }, - BAR: { value: 20 }, - }, - }); - expect(enumType.getValue('FOO')).has.property('value', 10); - expect(enumType.getValue('BAR')).has.property('value', 20); - }); - - it('rejects an Enum type with invalid name', () => { - expect( - () => new GraphQLEnumType({ name: 'bad-name', values: {} }), - ).to.throw('Names must only contain [_a-zA-Z0-9] but "bad-name" does not.'); - }); - - it('rejects an Enum type with incorrectly typed values', () => { - expect( - () => - new GraphQLEnumType({ - name: 'SomeEnum', - // @ts-expect-error - values: [{ FOO: 10 }], - }), - ).to.throw('SomeEnum values must be an object with value names as keys.'); - }); - - it('rejects an Enum type with incorrectly named values', () => { - expect( - () => - new GraphQLEnumType({ - name: 'SomeEnum', - values: { - 'bad-name': {}, - }, - }), - ).to.throw('Names must only contain [_a-zA-Z0-9] but "bad-name" does not.'); - }); - - it('rejects an Enum type with missing value definition', () => { - expect( - () => - new GraphQLEnumType({ - name: 'SomeEnum', - // @ts-expect-error (must not be null) - values: { FOO: null }, - }), - ).to.throw( - 'SomeEnum.FOO must refer to an object with a "value" key representing an internal value but got: null.', - ); - }); - - it('rejects an Enum type with incorrectly typed value definition', () => { - expect( - () => - new GraphQLEnumType({ - name: 'SomeEnum', - // @ts-expect-error - values: { FOO: 10 }, - }), - ).to.throw( - 'SomeEnum.FOO must refer to an object with a "value" key representing an internal value but got: 10.', - ); - }); -}); - -describe('Type System: Input Objects', () => { - describe('Input Objects must have fields', () => { - it('accepts an Input Object type with fields', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { - f: { type: ScalarType }, - }, - }); - expect(inputObjType.getFields()).to.deep.equal({ - f: { - name: 'f', - description: undefined, - type: ScalarType, - defaultValue: undefined, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - }); - }); - - it('accepts an Input Object type with a field function', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: () => ({ - f: { type: ScalarType }, - }), - }); - expect(inputObjType.getFields()).to.deep.equal({ - f: { - name: 'f', - description: undefined, - type: ScalarType, - defaultValue: undefined, - extensions: {}, - deprecationReason: undefined, - astNode: undefined, - }, - }); - }); - - it('rejects an Input Object type with invalid name', () => { - expect( - () => new GraphQLInputObjectType({ name: 'bad-name', fields: {} }), - ).to.throw( - 'Names must only contain [_a-zA-Z0-9] but "bad-name" does not.', - ); - }); - - it('rejects an Input Object type with incorrect fields', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - // @ts-expect-error - fields: [], - }); - expect(() => inputObjType.getFields()).to.throw( - 'SomeInputObject fields must be an object with field names as keys or a function which returns such an object.', - ); - }); - - it('rejects an Input Object type with fields function that returns incorrect type', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - // @ts-expect-error - fields: () => [], - }); - expect(() => inputObjType.getFields()).to.throw( - 'SomeInputObject fields must be an object with field names as keys or a function which returns such an object.', - ); - }); - - it('rejects an Input Object type with incorrectly named fields', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { - 'bad-name': { type: ScalarType }, - }, - }); - expect(() => inputObjType.getFields()).to.throw( - 'Names must only contain [_a-zA-Z0-9] but "bad-name" does not.', - ); - }); - }); - - describe('Input Object fields must not have resolvers', () => { - it('rejects an Input Object type with resolvers', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { - // @ts-expect-error (Input fields cannot have resolvers) - f: { type: ScalarType, resolve: dummyFunc }, - }, - }); - expect(() => inputObjType.getFields()).to.throw( - 'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.', - ); - }); - - it('rejects an Input Object type with resolver constant', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { - // @ts-expect-error (Input fields cannot have resolvers) - f: { type: ScalarType, resolve: {} }, - }, - }); - expect(() => inputObjType.getFields()).to.throw( - 'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.', - ); - }); - }); - - it('Deprecation reason is preserved on fields', () => { - const inputObjType = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { - deprecatedField: { - type: ScalarType, - deprecationReason: 'not used anymore', - }, - }, - }); - expect(inputObjType.toConfig()).to.have.nested.property( - 'fields.deprecatedField.deprecationReason', - 'not used anymore', - ); - }); -}); - -describe('Type System: List', () => { - function expectList(type: GraphQLType) { - return expect(() => new GraphQLList(type)); - } - - it('accepts an type as item type of list', () => { - expectList(ScalarType).to.not.throw(); - expectList(ObjectType).to.not.throw(); - expectList(UnionType).to.not.throw(); - expectList(InterfaceType).to.not.throw(); - expectList(EnumType).to.not.throw(); - expectList(InputObjectType).to.not.throw(); - expectList(ListOfScalarsType).to.not.throw(); - expectList(NonNullScalarType).to.not.throw(); - }); - - it('rejects a non-type as item type of list', () => { - // @ts-expect-error - expectList({}).to.throw('Expected {} to be a GraphQL type.'); - // @ts-expect-error - expectList(String).to.throw( - 'Expected [function String] to be a GraphQL type.', - ); - // @ts-expect-error (must provide type) - expectList(null).to.throw('Expected null to be a GraphQL type.'); - // @ts-expect-error (must provide type) - expectList(undefined).to.throw('Expected undefined to be a GraphQL type.'); - }); -}); - -describe('Type System: Non-Null', () => { - function expectNonNull(type: GraphQLNullableType) { - return expect(() => new GraphQLNonNull(type)); - } - - it('accepts an type as nullable type of non-null', () => { - expectNonNull(ScalarType).to.not.throw(); - expectNonNull(ObjectType).to.not.throw(); - expectNonNull(UnionType).to.not.throw(); - expectNonNull(InterfaceType).to.not.throw(); - expectNonNull(EnumType).to.not.throw(); - expectNonNull(InputObjectType).to.not.throw(); - expectNonNull(ListOfScalarsType).to.not.throw(); - expectNonNull(ListOfNonNullScalarsType).to.not.throw(); - }); - - it('rejects a non-type as nullable type of non-null', () => { - expectNonNull(NonNullScalarType).to.throw( - 'Expected Scalar! to be a GraphQL nullable type.', - ); - // @ts-expect-error - expectNonNull({}).to.throw('Expected {} to be a GraphQL nullable type.'); - // @ts-expect-error - expectNonNull(String).to.throw( - 'Expected [function String] to be a GraphQL nullable type.', - ); - // @ts-expect-error (must provide type) - expectNonNull(null).to.throw( - 'Expected null to be a GraphQL nullable type.', - ); - // @ts-expect-error (must provide type) - expectNonNull(undefined).to.throw( - 'Expected undefined to be a GraphQL nullable type.', - ); - }); -}); - -describe('Type System: test utility methods', () => { - it('stringifies types', () => { - expect(String(ScalarType)).to.equal('Scalar'); - expect(String(ObjectType)).to.equal('Object'); - expect(String(InterfaceType)).to.equal('Interface'); - expect(String(UnionType)).to.equal('Union'); - expect(String(EnumType)).to.equal('Enum'); - expect(String(InputObjectType)).to.equal('InputObject'); - - expect(String(NonNullScalarType)).to.equal('Scalar!'); - expect(String(ListOfScalarsType)).to.equal('[Scalar]'); - expect(String(NonNullListOfScalars)).to.equal('[Scalar]!'); - expect(String(ListOfNonNullScalarsType)).to.equal('[Scalar!]'); - expect(String(new GraphQLList(ListOfScalarsType))).to.equal('[[Scalar]]'); - }); - - it('JSON.stringifies types', () => { - expect(JSON.stringify(ScalarType)).to.equal('"Scalar"'); - expect(JSON.stringify(ObjectType)).to.equal('"Object"'); - expect(JSON.stringify(InterfaceType)).to.equal('"Interface"'); - expect(JSON.stringify(UnionType)).to.equal('"Union"'); - expect(JSON.stringify(EnumType)).to.equal('"Enum"'); - expect(JSON.stringify(InputObjectType)).to.equal('"InputObject"'); - - expect(JSON.stringify(NonNullScalarType)).to.equal('"Scalar!"'); - expect(JSON.stringify(ListOfScalarsType)).to.equal('"[Scalar]"'); - expect(JSON.stringify(NonNullListOfScalars)).to.equal('"[Scalar]!"'); - expect(JSON.stringify(ListOfNonNullScalarsType)).to.equal('"[Scalar!]"'); - expect(JSON.stringify(new GraphQLList(ListOfScalarsType))).to.equal( - '"[[Scalar]]"', - ); - }); - - it('Object.toStringifies types', () => { - function toString(obj: unknown): string { - return Object.prototype.toString.call(obj); - } - - expect(toString(ScalarType)).to.equal('[object GraphQLScalarType]'); - expect(toString(ObjectType)).to.equal('[object GraphQLObjectType]'); - expect(toString(InterfaceType)).to.equal('[object GraphQLInterfaceType]'); - expect(toString(UnionType)).to.equal('[object GraphQLUnionType]'); - expect(toString(EnumType)).to.equal('[object GraphQLEnumType]'); - expect(toString(InputObjectType)).to.equal( - '[object GraphQLInputObjectType]', - ); - expect(toString(NonNullScalarType)).to.equal('[object GraphQLNonNull]'); - expect(toString(ListOfScalarsType)).to.equal('[object GraphQLList]'); - }); -}); diff --git a/src/type/__tests__/directive-test.ts b/src/type/__tests__/directive-test.ts deleted file mode 100644 index 110a3cc940..0000000000 --- a/src/type/__tests__/directive-test.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { DirectiveLocation } from '../../language/directiveLocation'; - -import { GraphQLDirective } from '../directives'; -import { GraphQLInt, GraphQLString } from '../scalars'; - -describe('Type System: Directive', () => { - it('defines a directive with no args', () => { - const directive = new GraphQLDirective({ - name: 'Foo', - locations: [DirectiveLocation.QUERY], - }); - - expect(directive).to.deep.include({ - name: 'Foo', - args: [], - isRepeatable: false, - locations: ['QUERY'], - }); - }); - - it('defines a directive with multiple args', () => { - const directive = new GraphQLDirective({ - name: 'Foo', - args: { - foo: { type: GraphQLString }, - bar: { type: GraphQLInt }, - }, - locations: [DirectiveLocation.QUERY], - }); - - expect(directive).to.deep.include({ - name: 'Foo', - args: [ - { - name: 'foo', - description: undefined, - type: GraphQLString, - defaultValue: undefined, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - { - name: 'bar', - description: undefined, - type: GraphQLInt, - defaultValue: undefined, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - ], - isRepeatable: false, - locations: ['QUERY'], - }); - }); - - it('defines a repeatable directive', () => { - const directive = new GraphQLDirective({ - name: 'Foo', - isRepeatable: true, - locations: [DirectiveLocation.QUERY], - }); - - expect(directive).to.deep.include({ - name: 'Foo', - args: [], - isRepeatable: true, - locations: ['QUERY'], - }); - }); - - it('can be stringified, JSON.stringified and Object.toStringified', () => { - const directive = new GraphQLDirective({ - name: 'Foo', - locations: [DirectiveLocation.QUERY], - }); - - expect(String(directive)).to.equal('@Foo'); - expect(JSON.stringify(directive)).to.equal('"@Foo"'); - expect(Object.prototype.toString.call(directive)).to.equal( - '[object GraphQLDirective]', - ); - }); - - it('rejects a directive with invalid name', () => { - expect( - () => - new GraphQLDirective({ - name: 'bad-name', - locations: [DirectiveLocation.QUERY], - }), - ).to.throw('Names must only contain [_a-zA-Z0-9] but "bad-name" does not.'); - }); - - it('rejects a directive with incorrectly typed args', () => { - expect( - () => - new GraphQLDirective({ - name: 'Foo', - locations: [DirectiveLocation.QUERY], - // @ts-expect-error - args: [], - }), - ).to.throw('@Foo args must be an object with argument names as keys.'); - }); - - it('rejects a directive with incorrectly named arg', () => { - expect( - () => - new GraphQLDirective({ - name: 'Foo', - locations: [DirectiveLocation.QUERY], - args: { - 'bad-name': { type: GraphQLString }, - }, - }), - ).to.throw('Names must only contain [_a-zA-Z0-9] but "bad-name" does not.'); - }); - - it('rejects a directive with undefined locations', () => { - // @ts-expect-error - expect(() => new GraphQLDirective({ name: 'Foo' })).to.throw( - '@Foo locations must be an Array.', - ); - }); - - it('rejects a directive with incorrectly typed locations', () => { - // @ts-expect-error - expect(() => new GraphQLDirective({ name: 'Foo', locations: {} })).to.throw( - '@Foo locations must be an Array.', - ); - }); -}); diff --git a/src/type/__tests__/enumType-test.ts b/src/type/__tests__/enumType-test.ts deleted file mode 100644 index d5cfadc635..0000000000 --- a/src/type/__tests__/enumType-test.ts +++ /dev/null @@ -1,431 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { introspectionFromSchema } from '../../utilities/introspectionFromSchema'; - -import { graphqlSync } from '../../graphql'; - -import { GraphQLEnumType, GraphQLObjectType } from '../definition'; -import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../scalars'; -import { GraphQLSchema } from '../schema'; - -const ColorType = new GraphQLEnumType({ - name: 'Color', - values: { - RED: { value: 0 }, - GREEN: { value: 1 }, - BLUE: { value: 2 }, - }, -}); - -const Complex1 = { someRandomObject: new Date() }; -const Complex2 = { someRandomValue: 123 }; - -const ComplexEnum = new GraphQLEnumType({ - name: 'Complex', - values: { - ONE: { value: Complex1 }, - TWO: { value: Complex2 }, - }, -}); - -const ThunkValuesEnum = new GraphQLEnumType({ - name: 'ThunkValues', - values: () => ({ - A: { value: 'a' }, - B: { value: 'b' }, - }), -}); - -const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - colorEnum: { - type: ColorType, - args: { - fromEnum: { type: ColorType }, - fromInt: { type: GraphQLInt }, - fromString: { type: GraphQLString }, - }, - resolve(_source, { fromEnum, fromInt, fromString }) { - return fromInt !== undefined - ? fromInt - : fromString !== undefined - ? fromString - : fromEnum; - }, - }, - colorInt: { - type: GraphQLInt, - args: { - fromEnum: { type: ColorType }, - }, - resolve(_source, { fromEnum }) { - return fromEnum; - }, - }, - complexEnum: { - type: ComplexEnum, - args: { - fromEnum: { - type: ComplexEnum, - // Note: defaultValue is provided an *internal* representation for - // Enums, rather than the string name. - defaultValue: Complex1, - }, - provideGoodValue: { type: GraphQLBoolean }, - provideBadValue: { type: GraphQLBoolean }, - }, - resolve(_source, { fromEnum, provideGoodValue, provideBadValue }) { - if (provideGoodValue) { - // Note: this is one of the references of the internal values which - // ComplexEnum allows. - return Complex2; - } - if (provideBadValue) { - // Note: similar shape, but not the same *reference* - // as Complex2 above. Enum internal values require === equality. - return { someRandomValue: 123 }; - } - return fromEnum; - }, - }, - thunkValuesString: { - type: GraphQLString, - args: { - fromEnum: { type: ThunkValuesEnum }, - }, - resolve(_source, { fromEnum }) { - return fromEnum; - }, - }, - }, -}); - -const MutationType = new GraphQLObjectType({ - name: 'Mutation', - fields: { - favoriteEnum: { - type: ColorType, - args: { color: { type: ColorType } }, - resolve: (_source, { color }) => color, - }, - }, -}); - -const SubscriptionType = new GraphQLObjectType({ - name: 'Subscription', - fields: { - subscribeToEnum: { - type: ColorType, - args: { color: { type: ColorType } }, - resolve: (_source, { color }) => color, - }, - }, -}); - -const schema = new GraphQLSchema({ - query: QueryType, - mutation: MutationType, - subscription: SubscriptionType, -}); - -function executeQuery( - source: string, - variableValues?: { readonly [variable: string]: unknown }, -) { - return graphqlSync({ schema, source, variableValues }); -} - -describe('Type System: Enum Values', () => { - it('accepts enum literals as input', () => { - const result = executeQuery('{ colorInt(fromEnum: GREEN) }'); - - expect(result).to.deep.equal({ - data: { colorInt: 1 }, - }); - }); - - it('enum may be output type', () => { - const result = executeQuery('{ colorEnum(fromInt: 1) }'); - - expect(result).to.deep.equal({ - data: { colorEnum: 'GREEN' }, - }); - }); - - it('enum may be both input and output type', () => { - const result = executeQuery('{ colorEnum(fromEnum: GREEN) }'); - - expect(result).to.deep.equal({ - data: { colorEnum: 'GREEN' }, - }); - }); - - it('does not accept string literals', () => { - const result = executeQuery('{ colorEnum(fromEnum: "GREEN") }'); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Enum "Color" cannot represent non-enum value: "GREEN". Did you mean the enum value "GREEN"?', - locations: [{ line: 1, column: 23 }], - }, - ], - }); - }); - - it('does not accept values not in the enum', () => { - const result = executeQuery('{ colorEnum(fromEnum: GREENISH) }'); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Value "GREENISH" does not exist in "Color" enum. Did you mean the enum value "GREEN"?', - locations: [{ line: 1, column: 23 }], - }, - ], - }); - }); - - it('does not accept values with incorrect casing', () => { - const result = executeQuery('{ colorEnum(fromEnum: green) }'); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Value "green" does not exist in "Color" enum. Did you mean the enum value "GREEN" or "RED"?', - locations: [{ line: 1, column: 23 }], - }, - ], - }); - }); - - it('does not accept incorrect internal value', () => { - const result = executeQuery('{ colorEnum(fromString: "GREEN") }'); - - expectJSON(result).toDeepEqual({ - data: { colorEnum: null }, - errors: [ - { - message: 'Enum "Color" cannot represent value: "GREEN"', - locations: [{ line: 1, column: 3 }], - path: ['colorEnum'], - }, - ], - }); - }); - - it('does not accept internal value in place of enum literal', () => { - const result = executeQuery('{ colorEnum(fromEnum: 1) }'); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: 'Enum "Color" cannot represent non-enum value: 1.', - locations: [{ line: 1, column: 23 }], - }, - ], - }); - }); - - it('does not accept enum literal in place of int', () => { - const result = executeQuery('{ colorEnum(fromInt: GREEN) }'); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: 'Int cannot represent non-integer value: GREEN', - locations: [{ line: 1, column: 22 }], - }, - ], - }); - }); - - it('accepts JSON string as enum variable', () => { - const doc = 'query ($color: Color!) { colorEnum(fromEnum: $color) }'; - const result = executeQuery(doc, { color: 'BLUE' }); - - expect(result).to.deep.equal({ - data: { colorEnum: 'BLUE' }, - }); - }); - - it('accepts enum literals as input arguments to mutations', () => { - const doc = 'mutation ($color: Color!) { favoriteEnum(color: $color) }'; - const result = executeQuery(doc, { color: 'GREEN' }); - - expect(result).to.deep.equal({ - data: { favoriteEnum: 'GREEN' }, - }); - }); - - it('accepts enum literals as input arguments to subscriptions', () => { - const doc = - 'subscription ($color: Color!) { subscribeToEnum(color: $color) }'; - const result = executeQuery(doc, { color: 'GREEN' }); - - expect(result).to.deep.equal({ - data: { subscribeToEnum: 'GREEN' }, - }); - }); - - it('does not accept internal value as enum variable', () => { - const doc = 'query ($color: Color!) { colorEnum(fromEnum: $color) }'; - const result = executeQuery(doc, { color: 2 }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$color" got invalid value 2; Enum "Color" cannot represent non-string value: 2.', - locations: [{ line: 1, column: 8 }], - }, - ], - }); - }); - - it('does not accept string variables as enum input', () => { - const doc = 'query ($color: String!) { colorEnum(fromEnum: $color) }'; - const result = executeQuery(doc, { color: 'BLUE' }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$color" of type "String!" used in position expecting type "Color".', - locations: [ - { line: 1, column: 8 }, - { line: 1, column: 47 }, - ], - }, - ], - }); - }); - - it('does not accept internal value variable as enum input', () => { - const doc = 'query ($color: Int!) { colorEnum(fromEnum: $color) }'; - const result = executeQuery(doc, { color: 2 }); - - expectJSON(result).toDeepEqual({ - errors: [ - { - message: - 'Variable "$color" of type "Int!" used in position expecting type "Color".', - locations: [ - { line: 1, column: 8 }, - { line: 1, column: 44 }, - ], - }, - ], - }); - }); - - it('enum value may have an internal value of 0', () => { - const result = executeQuery(` - { - colorEnum(fromEnum: RED) - colorInt(fromEnum: RED) - } - `); - - expect(result).to.deep.equal({ - data: { - colorEnum: 'RED', - colorInt: 0, - }, - }); - }); - - it('enum inputs may be nullable', () => { - const result = executeQuery(` - { - colorEnum - colorInt - } - `); - - expect(result).to.deep.equal({ - data: { - colorEnum: null, - colorInt: null, - }, - }); - }); - - it('presents a getValues() API for complex enums', () => { - const values = ComplexEnum.getValues(); - expect(values).to.have.deep.ordered.members([ - { - name: 'ONE', - description: undefined, - value: Complex1, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - { - name: 'TWO', - description: undefined, - value: Complex2, - deprecationReason: undefined, - extensions: {}, - astNode: undefined, - }, - ]); - }); - - it('presents a getValue() API for complex enums', () => { - const oneValue = ComplexEnum.getValue('ONE'); - expect(oneValue).to.include({ name: 'ONE', value: Complex1 }); - - // @ts-expect-error - const badUsage = ComplexEnum.getValue(Complex1); - expect(badUsage).to.equal(undefined); - }); - - it('may be internally represented with complex values', () => { - const result = executeQuery(` - { - first: complexEnum - second: complexEnum(fromEnum: TWO) - good: complexEnum(provideGoodValue: true) - bad: complexEnum(provideBadValue: true) - } - `); - - expectJSON(result).toDeepEqual({ - data: { - first: 'ONE', - second: 'TWO', - good: 'TWO', - bad: null, - }, - errors: [ - { - message: - 'Enum "Complex" cannot represent value: { someRandomValue: 123 }', - locations: [{ line: 6, column: 9 }], - path: ['bad'], - }, - ], - }); - }); - - it('may have values specified via a callback', () => { - const result = executeQuery('{ thunkValuesString(fromEnum: B) }'); - - expect(result).to.deep.equal({ - data: { thunkValuesString: 'b' }, - }); - }); - - it('can be introspected without error', () => { - expect(() => introspectionFromSchema(schema)).to.not.throw(); - }); -}); diff --git a/src/type/__tests__/extensions-test.ts b/src/type/__tests__/extensions-test.ts deleted file mode 100644 index 4fb0827485..0000000000 --- a/src/type/__tests__/extensions-test.ts +++ /dev/null @@ -1,393 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { invariant } from '../../jsutils/invariant'; - -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, -} from '../definition'; -import { GraphQLDirective } from '../directives'; -import { GraphQLSchema } from '../schema'; - -const dummyType = new GraphQLScalarType({ name: 'DummyScalar' }); - -function expectObjMap(value: unknown) { - invariant(value != null && typeof value === 'object'); - expect(Object.getPrototypeOf(value)).to.equal(null); - return expect(value); -} - -describe('Type System: Extensions', () => { - describe('GraphQLScalarType', () => { - it('without extensions', () => { - const someScalar = new GraphQLScalarType({ name: 'SomeScalar' }); - expect(someScalar.extensions).to.deep.equal({}); - - const config = someScalar.toConfig(); - expect(config.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const scalarExtensions = Object.freeze({ SomeScalarExt: 'scalar' }); - const someScalar = new GraphQLScalarType({ - name: 'SomeScalar', - extensions: scalarExtensions, - }); - - expectObjMap(someScalar.extensions).to.deep.equal(scalarExtensions); - - const config = someScalar.toConfig(); - expectObjMap(config.extensions).to.deep.equal(scalarExtensions); - }); - }); - - describe('GraphQLObjectType', () => { - it('without extensions', () => { - const someObject = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - someField: { - type: dummyType, - args: { - someArg: { - type: dummyType, - }, - }, - }, - }, - }); - - expect(someObject.extensions).to.deep.equal({}); - const someField = someObject.getFields().someField; - expect(someField.extensions).to.deep.equal({}); - const someArg = someField.args[0]; - expect(someArg.extensions).to.deep.equal({}); - - const config = someObject.toConfig(); - expect(config.extensions).to.deep.equal({}); - const someFieldConfig = config.fields.someField; - expect(someFieldConfig.extensions).to.deep.equal({}); - invariant(someFieldConfig.args); - const someArgConfig = someFieldConfig.args.someArg; - expect(someArgConfig.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const objectExtensions = Object.freeze({ SomeObjectExt: 'object' }); - const fieldExtensions = Object.freeze({ SomeFieldExt: 'field' }); - const argExtensions = Object.freeze({ SomeArgExt: 'arg' }); - - const someObject = new GraphQLObjectType({ - name: 'SomeObject', - fields: { - someField: { - type: dummyType, - args: { - someArg: { - type: dummyType, - extensions: argExtensions, - }, - }, - extensions: fieldExtensions, - }, - }, - extensions: objectExtensions, - }); - - expectObjMap(someObject.extensions).to.deep.equal(objectExtensions); - const someField = someObject.getFields().someField; - expectObjMap(someField.extensions).to.deep.equal(fieldExtensions); - const someArg = someField.args[0]; - expectObjMap(someArg.extensions).to.deep.equal(argExtensions); - - const config = someObject.toConfig(); - expectObjMap(config.extensions).to.deep.equal(objectExtensions); - const someFieldConfig = config.fields.someField; - expectObjMap(someFieldConfig.extensions).to.deep.equal(fieldExtensions); - invariant(someFieldConfig.args); - const someArgConfig = someFieldConfig.args.someArg; - expectObjMap(someArgConfig.extensions).to.deep.equal(argExtensions); - }); - }); - - describe('GraphQLInterfaceType', () => { - it('without extensions', () => { - const someInterface = new GraphQLInterfaceType({ - name: 'SomeInterface', - fields: { - someField: { - type: dummyType, - args: { - someArg: { - type: dummyType, - }, - }, - }, - }, - }); - - expect(someInterface.extensions).to.deep.equal({}); - const someField = someInterface.getFields().someField; - expect(someField.extensions).to.deep.equal({}); - const someArg = someField.args[0]; - expect(someArg.extensions).to.deep.equal({}); - - const config = someInterface.toConfig(); - expect(config.extensions).to.deep.equal({}); - const someFieldConfig = config.fields.someField; - expect(someFieldConfig.extensions).to.deep.equal({}); - invariant(someFieldConfig.args); - const someArgConfig = someFieldConfig.args.someArg; - expect(someArgConfig.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const interfaceExtensions = Object.freeze({ - SomeInterfaceExt: 'interface', - }); - const fieldExtensions = Object.freeze({ SomeFieldExt: 'field' }); - const argExtensions = Object.freeze({ SomeArgExt: 'arg' }); - - const someInterface = new GraphQLInterfaceType({ - name: 'SomeInterface', - fields: { - someField: { - type: dummyType, - args: { - someArg: { - type: dummyType, - extensions: argExtensions, - }, - }, - extensions: fieldExtensions, - }, - }, - extensions: interfaceExtensions, - }); - - expectObjMap(someInterface.extensions).to.deep.equal(interfaceExtensions); - const someField = someInterface.getFields().someField; - expectObjMap(someField.extensions).to.deep.equal(fieldExtensions); - const someArg = someField.args[0]; - expectObjMap(someArg.extensions).to.deep.equal(argExtensions); - - const config = someInterface.toConfig(); - expectObjMap(config.extensions).to.deep.equal(interfaceExtensions); - const someFieldConfig = config.fields.someField; - expectObjMap(someFieldConfig.extensions).to.deep.equal(fieldExtensions); - invariant(someFieldConfig.args); - const someArgConfig = someFieldConfig.args.someArg; - expectObjMap(someArgConfig.extensions).to.deep.equal(argExtensions); - }); - }); - - describe('GraphQLUnionType', () => { - it('without extensions', () => { - const someUnion = new GraphQLUnionType({ - name: 'SomeUnion', - types: [], - }); - - expect(someUnion.extensions).to.deep.equal({}); - - const config = someUnion.toConfig(); - expect(config.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const unionExtensions = Object.freeze({ SomeUnionExt: 'union' }); - - const someUnion = new GraphQLUnionType({ - name: 'SomeUnion', - types: [], - extensions: unionExtensions, - }); - - expectObjMap(someUnion.extensions).to.deep.equal(unionExtensions); - - const config = someUnion.toConfig(); - expectObjMap(config.extensions).to.deep.equal(unionExtensions); - }); - }); - - describe('GraphQLEnumType', () => { - it('without extensions', () => { - const someEnum = new GraphQLEnumType({ - name: 'SomeEnum', - values: { - SOME_VALUE: {}, - }, - }); - - expect(someEnum.extensions).to.deep.equal({}); - const someValue = someEnum.getValues()[0]; - expect(someValue.extensions).to.deep.equal({}); - - const config = someEnum.toConfig(); - expect(config.extensions).to.deep.equal({}); - const someValueConfig = config.values.SOME_VALUE; - expect(someValueConfig.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const enumExtensions = Object.freeze({ SomeEnumExt: 'enum' }); - const valueExtensions = Object.freeze({ SomeValueExt: 'value' }); - - const someEnum = new GraphQLEnumType({ - name: 'SomeEnum', - values: { - SOME_VALUE: { - extensions: valueExtensions, - }, - }, - extensions: enumExtensions, - }); - - expectObjMap(someEnum.extensions).to.deep.equal(enumExtensions); - const someValue = someEnum.getValues()[0]; - expectObjMap(someValue.extensions).to.deep.equal(valueExtensions); - - const config = someEnum.toConfig(); - expectObjMap(config.extensions).to.deep.equal(enumExtensions); - const someValueConfig = config.values.SOME_VALUE; - expectObjMap(someValueConfig.extensions).to.deep.equal(valueExtensions); - }); - }); - - describe('GraphQLInputObjectType', () => { - it('without extensions', () => { - const someInputObject = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { - someInputField: { - type: dummyType, - }, - }, - }); - - expect(someInputObject.extensions).to.deep.equal({}); - const someInputField = someInputObject.getFields().someInputField; - expect(someInputField.extensions).to.deep.equal({}); - - const config = someInputObject.toConfig(); - expect(config.extensions).to.deep.equal({}); - const someInputFieldConfig = config.fields.someInputField; - expect(someInputFieldConfig.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const inputObjectExtensions = Object.freeze({ - SomeInputObjectExt: 'inputObject', - }); - const inputFieldExtensions = Object.freeze({ - SomeInputFieldExt: 'inputField', - }); - - const someInputObject = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { - someInputField: { - type: dummyType, - extensions: inputFieldExtensions, - }, - }, - extensions: inputObjectExtensions, - }); - - expectObjMap(someInputObject.extensions).to.deep.equal( - inputObjectExtensions, - ); - const someInputField = someInputObject.getFields().someInputField; - expectObjMap(someInputField.extensions).to.deep.equal( - inputFieldExtensions, - ); - - const config = someInputObject.toConfig(); - expectObjMap(config.extensions).to.deep.equal(inputObjectExtensions); - const someInputFieldConfig = config.fields.someInputField; - expectObjMap(someInputFieldConfig.extensions).to.deep.equal( - inputFieldExtensions, - ); - }); - }); - - describe('GraphQLDirective', () => { - it('without extensions', () => { - const someDirective = new GraphQLDirective({ - name: 'SomeDirective', - args: { - someArg: { - type: dummyType, - }, - }, - locations: [], - }); - - expect(someDirective.extensions).to.deep.equal({}); - const someArg = someDirective.args[0]; - expect(someArg.extensions).to.deep.equal({}); - - const config = someDirective.toConfig(); - expect(config.extensions).to.deep.equal({}); - const someArgConfig = config.args.someArg; - expect(someArgConfig.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const directiveExtensions = Object.freeze({ - SomeDirectiveExt: 'directive', - }); - const argExtensions = Object.freeze({ SomeArgExt: 'arg' }); - - const someDirective = new GraphQLDirective({ - name: 'SomeDirective', - args: { - someArg: { - type: dummyType, - extensions: argExtensions, - }, - }, - locations: [], - extensions: directiveExtensions, - }); - - expectObjMap(someDirective.extensions).to.deep.equal(directiveExtensions); - const someArg = someDirective.args[0]; - expectObjMap(someArg.extensions).to.deep.equal(argExtensions); - - const config = someDirective.toConfig(); - expectObjMap(config.extensions).to.deep.equal(directiveExtensions); - const someArgConfig = config.args.someArg; - expectObjMap(someArgConfig.extensions).to.deep.equal(argExtensions); - }); - }); - - describe('GraphQLSchema', () => { - it('without extensions', () => { - const schema = new GraphQLSchema({}); - - expect(schema.extensions).to.deep.equal({}); - - const config = schema.toConfig(); - expect(config.extensions).to.deep.equal({}); - }); - - it('with extensions', () => { - const schemaExtensions = Object.freeze({ - schemaExtension: 'schema', - }); - - const schema = new GraphQLSchema({ extensions: schemaExtensions }); - - expectObjMap(schema.extensions).to.deep.equal(schemaExtensions); - - const config = schema.toConfig(); - expectObjMap(config.extensions).to.deep.equal(schemaExtensions); - }); - }); -}); diff --git a/src/type/__tests__/introspection-test.ts b/src/type/__tests__/introspection-test.ts deleted file mode 100644 index 8c5cacba0d..0000000000 --- a/src/type/__tests__/introspection-test.ts +++ /dev/null @@ -1,1757 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { buildSchema } from '../../utilities/buildASTSchema'; -import { getIntrospectionQuery } from '../../utilities/getIntrospectionQuery'; - -import { graphqlSync } from '../../graphql'; - -import type { GraphQLResolveInfo } from '../definition'; - -describe('Introspection', () => { - it('executes an introspection query', () => { - const schema = buildSchema(` - type SomeObject { - someField: String - } - - schema { - query: SomeObject - } - `); - - const source = getIntrospectionQuery({ - descriptions: false, - specifiedByUrl: true, - directiveIsRepeatable: true, - }); - - const result = graphqlSync({ schema, source }); - expect(result).to.deep.equal({ - data: { - __schema: { - queryType: { name: 'SomeObject', kind: 'OBJECT' }, - mutationType: null, - subscriptionType: null, - types: [ - { - kind: 'OBJECT', - name: 'SomeObject', - specifiedByURL: null, - fields: [ - { - name: 'someField', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'SCALAR', - name: 'String', - specifiedByURL: null, - fields: null, - inputFields: null, - interfaces: null, - enumValues: null, - possibleTypes: null, - }, - { - kind: 'SCALAR', - name: 'Boolean', - specifiedByURL: null, - fields: null, - inputFields: null, - interfaces: null, - enumValues: null, - possibleTypes: null, - }, - { - kind: 'OBJECT', - name: '__Schema', - specifiedByURL: null, - fields: [ - { - name: 'description', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'types', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'queryType', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'mutationType', - args: [], - type: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'subscriptionType', - args: [], - type: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'directives', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Directive', - ofType: null, - }, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'OBJECT', - name: '__Type', - specifiedByURL: null, - fields: [ - { - name: 'kind', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'ENUM', - name: '__TypeKind', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'name', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'description', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'specifiedByURL', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'fields', - args: [ - { - name: 'includeDeprecated', - type: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - defaultValue: 'false', - }, - ], - type: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Field', - ofType: null, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'interfaces', - args: [], - type: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'possibleTypes', - args: [], - type: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'enumValues', - args: [ - { - name: 'includeDeprecated', - type: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - defaultValue: 'false', - }, - ], - type: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__EnumValue', - ofType: null, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'inputFields', - args: [ - { - name: 'includeDeprecated', - type: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - defaultValue: 'false', - }, - ], - type: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__InputValue', - ofType: null, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'ofType', - args: [], - type: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'isOneOf', - args: [], - type: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'ENUM', - name: '__TypeKind', - specifiedByURL: null, - fields: null, - inputFields: null, - interfaces: null, - enumValues: [ - { - name: 'SCALAR', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'OBJECT', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'INTERFACE', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'UNION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'ENUM', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'INPUT_OBJECT', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'LIST', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'NON_NULL', - isDeprecated: false, - deprecationReason: null, - }, - ], - possibleTypes: null, - }, - { - kind: 'OBJECT', - name: '__Field', - specifiedByURL: null, - fields: [ - { - name: 'name', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'description', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'args', - args: [ - { - name: 'includeDeprecated', - type: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - defaultValue: 'false', - }, - ], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__InputValue', - ofType: null, - }, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'type', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'isDeprecated', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'deprecationReason', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'OBJECT', - name: '__InputValue', - specifiedByURL: null, - fields: [ - { - name: 'name', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'description', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'type', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__Type', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'defaultValue', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'isDeprecated', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'deprecationReason', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'OBJECT', - name: '__EnumValue', - specifiedByURL: null, - fields: [ - { - name: 'name', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'description', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'isDeprecated', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'deprecationReason', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'OBJECT', - name: '__Directive', - specifiedByURL: null, - fields: [ - { - name: 'name', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'description', - args: [], - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'isRepeatable', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'locations', - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'ENUM', - name: '__DirectiveLocation', - ofType: null, - }, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'args', - args: [ - { - name: 'includeDeprecated', - type: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - defaultValue: 'false', - }, - ], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'LIST', - name: null, - ofType: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'OBJECT', - name: '__InputValue', - ofType: null, - }, - }, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'ENUM', - name: '__DirectiveLocation', - specifiedByURL: null, - fields: null, - inputFields: null, - interfaces: null, - enumValues: [ - { - name: 'QUERY', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'MUTATION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'SUBSCRIPTION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'FIELD', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'FRAGMENT_DEFINITION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'FRAGMENT_SPREAD', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'INLINE_FRAGMENT', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'VARIABLE_DEFINITION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'SCHEMA', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'SCALAR', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'OBJECT', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'FIELD_DEFINITION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'ARGUMENT_DEFINITION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'INTERFACE', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'UNION', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'ENUM', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'ENUM_VALUE', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'INPUT_OBJECT', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'INPUT_FIELD_DEFINITION', - isDeprecated: false, - deprecationReason: null, - }, - ], - possibleTypes: null, - }, - ], - directives: [ - { - name: 'include', - isRepeatable: false, - locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'], - args: [ - { - defaultValue: null, - name: 'if', - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - }, - }, - ], - }, - { - name: 'skip', - isRepeatable: false, - locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'], - args: [ - { - defaultValue: null, - name: 'if', - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'Boolean', - ofType: null, - }, - }, - }, - ], - }, - { - name: 'deprecated', - isRepeatable: false, - locations: [ - 'FIELD_DEFINITION', - 'ARGUMENT_DEFINITION', - 'INPUT_FIELD_DEFINITION', - 'ENUM_VALUE', - ], - args: [ - { - defaultValue: '"No longer supported"', - name: 'reason', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - ], - }, - { - name: 'specifiedBy', - isRepeatable: false, - locations: ['SCALAR'], - args: [ - { - defaultValue: null, - name: 'url', - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - }, - ], - }, - { - name: 'oneOf', - isRepeatable: false, - locations: ['INPUT_OBJECT'], - args: [], - }, - ], - }, - }, - }); - }); - - it('introspects on input object', () => { - const schema = buildSchema(` - input SomeInputObject { - a: String = "tes\\t de\\fault" - b: [String] - c: String = null - } - - type Query { - someField(someArg: SomeInputObject): String - } - `); - - const source = ` - { - __type(name: "SomeInputObject") { - kind - name - inputFields { - name - type { ...TypeRef } - defaultValue - } - } - } - - fragment TypeRef on __Type { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - } - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - kind: 'INPUT_OBJECT', - name: 'SomeInputObject', - inputFields: [ - { - name: 'a', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - defaultValue: '"tes\\t de\\fault"', - }, - { - name: 'b', - type: { - kind: 'LIST', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - defaultValue: null, - }, - { - name: 'c', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - defaultValue: 'null', - }, - ], - }, - }, - }); - }); - - it('introspects any default value', () => { - const schema = buildSchema(` - input InputObjectWithDefaultValues { - a: String = "Emoji: \\u{1F600}" - b: Complex = {x: ["abc"], y: 123} - } - - input Complex { - x: [String] - y: Int - } - - type Query { - someField(someArg: InputObjectWithDefaultValues): String - } - `); - - const source = ` - { - __type(name: "InputObjectWithDefaultValues") { - inputFields { - name - defaultValue - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - inputFields: [ - { - name: 'a', - defaultValue: '"Emoji: \u{1F600}"', - }, - { - name: 'b', - defaultValue: '{x: ["abc"], y: 123}', - }, - ], - }, - }, - }); - }); - - it('supports the __type root field', () => { - const schema = buildSchema(` - type Query { - someField: String - } - `); - - const source = ` - { - __type(name: "Query") { - name - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { name: 'Query' }, - }, - }); - }); - - it('identifies deprecated fields', () => { - const schema = buildSchema(` - type Query { - nonDeprecated: String - deprecated: String @deprecated(reason: "Removed in 1.0") - deprecatedWithEmptyReason: String @deprecated(reason: "") - } - `); - - const source = ` - { - __type(name: "Query") { - fields(includeDeprecated: true) { - name - isDeprecated, - deprecationReason - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - fields: [ - { - name: 'nonDeprecated', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'deprecated', - isDeprecated: true, - deprecationReason: 'Removed in 1.0', - }, - { - name: 'deprecatedWithEmptyReason', - isDeprecated: true, - deprecationReason: '', - }, - ], - }, - }, - }); - }); - - it('respects the includeDeprecated parameter for fields', () => { - const schema = buildSchema(` - type Query { - nonDeprecated: String - deprecated: String @deprecated(reason: "Removed in 1.0") - } - `); - - const source = ` - { - __type(name: "Query") { - trueFields: fields(includeDeprecated: true) { - name - } - falseFields: fields(includeDeprecated: false) { - name - } - omittedFields: fields { - name - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - trueFields: [{ name: 'nonDeprecated' }, { name: 'deprecated' }], - falseFields: [{ name: 'nonDeprecated' }], - omittedFields: [{ name: 'nonDeprecated' }], - }, - }, - }); - }); - - it('identifies deprecated args', () => { - const schema = buildSchema(` - type Query { - someField( - nonDeprecated: String - deprecated: String @deprecated(reason: "Removed in 1.0") - deprecatedWithEmptyReason: String @deprecated(reason: "") - ): String - } - `); - - const source = ` - { - __type(name: "Query") { - fields { - args(includeDeprecated: true) { - name - isDeprecated, - deprecationReason - } - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - fields: [ - { - args: [ - { - name: 'nonDeprecated', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'deprecated', - isDeprecated: true, - deprecationReason: 'Removed in 1.0', - }, - { - name: 'deprecatedWithEmptyReason', - isDeprecated: true, - deprecationReason: '', - }, - ], - }, - ], - }, - }, - }); - }); - - it('respects the includeDeprecated parameter for args', () => { - const schema = buildSchema(` - type Query { - someField( - nonDeprecated: String - deprecated: String @deprecated(reason: "Removed in 1.0") - ): String - } - `); - - const source = ` - { - __type(name: "Query") { - fields { - trueArgs: args(includeDeprecated: true) { - name - } - falseArgs: args(includeDeprecated: false) { - name - } - omittedArgs: args { - name - } - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - fields: [ - { - trueArgs: [{ name: 'nonDeprecated' }, { name: 'deprecated' }], - falseArgs: [{ name: 'nonDeprecated' }], - omittedArgs: [{ name: 'nonDeprecated' }], - }, - ], - }, - }, - }); - }); - - it('identifies deprecated enum values', () => { - const schema = buildSchema(` - enum SomeEnum { - NON_DEPRECATED - DEPRECATED @deprecated(reason: "Removed in 1.0") - ALSO_NON_DEPRECATED - } - - type Query { - someField(someArg: SomeEnum): String - } - `); - - const source = ` - { - __type(name: "SomeEnum") { - enumValues(includeDeprecated: true) { - name - isDeprecated, - deprecationReason - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - enumValues: [ - { - name: 'NON_DEPRECATED', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'DEPRECATED', - isDeprecated: true, - deprecationReason: 'Removed in 1.0', - }, - { - name: 'ALSO_NON_DEPRECATED', - isDeprecated: false, - deprecationReason: null, - }, - ], - }, - }, - }); - }); - - it('respects the includeDeprecated parameter for enum values', () => { - const schema = buildSchema(` - enum SomeEnum { - NON_DEPRECATED - DEPRECATED @deprecated(reason: "Removed in 1.0") - DEPRECATED_WITH_EMPTY_REASON @deprecated(reason: "") - ALSO_NON_DEPRECATED - } - - type Query { - someField(someArg: SomeEnum): String - } - `); - - const source = ` - { - __type(name: "SomeEnum") { - trueValues: enumValues(includeDeprecated: true) { - name - } - falseValues: enumValues(includeDeprecated: false) { - name - } - omittedValues: enumValues { - name - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - trueValues: [ - { name: 'NON_DEPRECATED' }, - { name: 'DEPRECATED' }, - { name: 'DEPRECATED_WITH_EMPTY_REASON' }, - { name: 'ALSO_NON_DEPRECATED' }, - ], - falseValues: [ - { name: 'NON_DEPRECATED' }, - { name: 'ALSO_NON_DEPRECATED' }, - ], - omittedValues: [ - { name: 'NON_DEPRECATED' }, - { name: 'ALSO_NON_DEPRECATED' }, - ], - }, - }, - }); - }); - - it('identifies deprecated for input fields', () => { - const schema = buildSchema(` - input SomeInputObject { - nonDeprecated: String - deprecated: String @deprecated(reason: "Removed in 1.0") - deprecatedWithEmptyReason: String @deprecated(reason: "") - } - - type Query { - someField(someArg: SomeInputObject): String - } - `); - - const source = ` - { - __type(name: "SomeInputObject") { - inputFields(includeDeprecated: true) { - name - isDeprecated, - deprecationReason - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - inputFields: [ - { - name: 'nonDeprecated', - isDeprecated: false, - deprecationReason: null, - }, - { - name: 'deprecated', - isDeprecated: true, - deprecationReason: 'Removed in 1.0', - }, - { - name: 'deprecatedWithEmptyReason', - isDeprecated: true, - deprecationReason: '', - }, - ], - }, - }, - }); - }); - - it('respects the includeDeprecated parameter for input fields', () => { - const schema = buildSchema(` - input SomeInputObject { - nonDeprecated: String - deprecated: String @deprecated(reason: "Removed in 1.0") - } - - type Query { - someField(someArg: SomeInputObject): String - } - `); - - const source = ` - { - __type(name: "SomeInputObject") { - trueFields: inputFields(includeDeprecated: true) { - name - } - falseFields: inputFields(includeDeprecated: false) { - name - } - omittedFields: inputFields { - name - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - __type: { - trueFields: [{ name: 'nonDeprecated' }, { name: 'deprecated' }], - falseFields: [{ name: 'nonDeprecated' }], - omittedFields: [{ name: 'nonDeprecated' }], - }, - }, - }); - }); - - it('identifies oneOf for input objects', () => { - const schema = buildSchema(` - input SomeInputObject @oneOf { - a: String - } - - input AnotherInputObject { - a: String - b: String - } - - type Query { - someField(someArg: SomeInputObject): String - anotherField(anotherArg: AnotherInputObject): String - } - `); - - const source = ` - { - oneOfInputObject: __type(name: "SomeInputObject") { - isOneOf - } - inputObject: __type(name: "AnotherInputObject") { - isOneOf - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - oneOfInputObject: { - isOneOf: true, - }, - inputObject: { - isOneOf: false, - }, - }, - }); - }); - - it('returns null for oneOf for other types', () => { - const schema = buildSchema(` - type SomeObject implements SomeInterface { - fieldA: String - } - enum SomeEnum { - SomeObject - } - interface SomeInterface { - fieldA: String - } - union SomeUnion = SomeObject - type Query { - someField(enum: SomeEnum): SomeUnion - anotherField(enum: SomeEnum): SomeInterface - } - `); - - const source = ` - { - object: __type(name: "SomeObject") { - isOneOf - } - enum: __type(name: "SomeEnum") { - isOneOf - } - interface: __type(name: "SomeInterface") { - isOneOf - } - scalar: __type(name: "String") { - isOneOf - } - union: __type(name: "SomeUnion") { - isOneOf - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - object: { isOneOf: null }, - enum: { isOneOf: null }, - interface: { isOneOf: null }, - scalar: { isOneOf: null }, - union: { isOneOf: null }, - }, - }); - }); - - it('fails as expected on the __type root field without an arg', () => { - const schema = buildSchema(` - type Query { - someField: String - } - `); - - const source = ` - { - __type { - name - } - } - `; - - expectJSON(graphqlSync({ schema, source })).toDeepEqual({ - errors: [ - { - message: - 'Field "__type" argument "name" of type "String!" is required, but it was not provided.', - locations: [{ line: 3, column: 9 }], - }, - ], - }); - }); - - it('exposes descriptions', () => { - const schema = buildSchema(` - """Enum description""" - enum SomeEnum { - """Value description""" - VALUE - } - - """Object description""" - type SomeObject { - """Field description""" - someField(arg: SomeEnum): String - } - - """Schema description""" - schema { - query: SomeObject - } - `); - - const source = ` - { - Schema: __schema { description } - SomeObject: __type(name: "SomeObject") { - description, - fields { - name - description - } - } - SomeEnum: __type(name: "SomeEnum") { - description - enumValues { - name - description - } - } - } - `; - - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - Schema: { - description: 'Schema description', - }, - SomeEnum: { - description: 'Enum description', - enumValues: [ - { - name: 'VALUE', - description: 'Value description', - }, - ], - }, - SomeObject: { - description: 'Object description', - fields: [ - { - name: 'someField', - description: 'Field description', - }, - ], - }, - }, - }); - }); - - it('executes an introspection query without calling global resolvers', () => { - const schema = buildSchema(` - type Query { - someField: String - } - `); - - const source = getIntrospectionQuery({ - specifiedByUrl: true, - directiveIsRepeatable: true, - schemaDescription: true, - }); - - /* c8 ignore start */ - function fieldResolver( - _1: any, - _2: any, - _3: any, - info: GraphQLResolveInfo, - ): never { - expect.fail(`Called on ${info.parentType.name}::${info.fieldName}`); - } - - function typeResolver(_1: any, _2: any, info: GraphQLResolveInfo): never { - expect.fail(`Called on ${info.parentType.name}::${info.fieldName}`); - } - /* c8 ignore stop */ - - const result = graphqlSync({ - schema, - source, - fieldResolver, - typeResolver, - }); - expect(result).to.not.have.property('errors'); - }); -}); diff --git a/src/type/__tests__/predicate-test.ts b/src/type/__tests__/predicate-test.ts deleted file mode 100644 index 81e721e7df..0000000000 --- a/src/type/__tests__/predicate-test.ts +++ /dev/null @@ -1,704 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { DirectiveLocation } from '../../language/directiveLocation'; - -import type { - GraphQLArgument, - GraphQLInputField, - GraphQLInputType, -} from '../definition'; -import { - assertAbstractType, - assertCompositeType, - assertEnumType, - assertInputObjectType, - assertInputType, - assertInterfaceType, - assertLeafType, - assertListType, - assertNamedType, - assertNonNullType, - assertNullableType, - assertObjectType, - assertOutputType, - assertScalarType, - assertType, - assertUnionType, - assertWrappingType, - getNamedType, - getNullableType, - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, - isAbstractType, - isCompositeType, - isEnumType, - isInputObjectType, - isInputType, - isInterfaceType, - isLeafType, - isListType, - isNamedType, - isNonNullType, - isNullableType, - isObjectType, - isOutputType, - isRequiredArgument, - isRequiredInputField, - isScalarType, - isType, - isUnionType, - isWrappingType, -} from '../definition'; -import { - assertDirective, - GraphQLDeprecatedDirective, - GraphQLDirective, - GraphQLIncludeDirective, - GraphQLSkipDirective, - isDirective, - isSpecifiedDirective, -} from '../directives'; -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLID, - GraphQLInt, - GraphQLString, - isSpecifiedScalarType, -} from '../scalars'; - -const ObjectType = new GraphQLObjectType({ name: 'Object', fields: {} }); -const InterfaceType = new GraphQLInterfaceType({ - name: 'Interface', - fields: {}, -}); -const UnionType = new GraphQLUnionType({ name: 'Union', types: [ObjectType] }); -const EnumType = new GraphQLEnumType({ name: 'Enum', values: { foo: {} } }); -const InputObjectType = new GraphQLInputObjectType({ - name: 'InputObject', - fields: {}, -}); -const ScalarType = new GraphQLScalarType({ name: 'Scalar' }); -const Directive = new GraphQLDirective({ - name: 'Directive', - locations: [DirectiveLocation.QUERY], -}); - -describe('Type predicates', () => { - describe('isType', () => { - it('returns true for unwrapped types', () => { - expect(isType(GraphQLString)).to.equal(true); - expect(() => assertType(GraphQLString)).to.not.throw(); - expect(isType(ObjectType)).to.equal(true); - expect(() => assertType(ObjectType)).to.not.throw(); - }); - - it('returns true for wrapped types', () => { - expect(isType(new GraphQLNonNull(GraphQLString))).to.equal(true); - expect(() => - assertType(new GraphQLNonNull(GraphQLString)), - ).to.not.throw(); - }); - - it('returns false for type classes (rather than instances)', () => { - expect(isType(GraphQLObjectType)).to.equal(false); - expect(() => assertType(GraphQLObjectType)).to.throw(); - }); - - it('returns false for random garbage', () => { - expect(isType({ what: 'is this' })).to.equal(false); - expect(() => assertType({ what: 'is this' })).to.throw(); - }); - }); - - describe('isScalarType', () => { - it('returns true for spec defined scalar', () => { - expect(isScalarType(GraphQLString)).to.equal(true); - expect(() => assertScalarType(GraphQLString)).to.not.throw(); - }); - - it('returns true for custom scalar', () => { - expect(isScalarType(ScalarType)).to.equal(true); - expect(() => assertScalarType(ScalarType)).to.not.throw(); - }); - - it('returns false for scalar class (rather than instance)', () => { - expect(isScalarType(GraphQLScalarType)).to.equal(false); - expect(() => assertScalarType(GraphQLScalarType)).to.throw(); - }); - - it('returns false for wrapped scalar', () => { - expect(isScalarType(new GraphQLList(ScalarType))).to.equal(false); - expect(() => assertScalarType(new GraphQLList(ScalarType))).to.throw(); - }); - - it('returns false for non-scalar', () => { - expect(isScalarType(EnumType)).to.equal(false); - expect(() => assertScalarType(EnumType)).to.throw(); - expect(isScalarType(Directive)).to.equal(false); - expect(() => assertScalarType(Directive)).to.throw(); - }); - - it('returns false for random garbage', () => { - expect(isScalarType({ what: 'is this' })).to.equal(false); - expect(() => assertScalarType({ what: 'is this' })).to.throw(); - }); - }); - - describe('isSpecifiedScalarType', () => { - it('returns true for specified scalars', () => { - expect(isSpecifiedScalarType(GraphQLString)).to.equal(true); - expect(isSpecifiedScalarType(GraphQLInt)).to.equal(true); - expect(isSpecifiedScalarType(GraphQLFloat)).to.equal(true); - expect(isSpecifiedScalarType(GraphQLBoolean)).to.equal(true); - expect(isSpecifiedScalarType(GraphQLID)).to.equal(true); - }); - - it('returns false for custom scalar', () => { - expect(isSpecifiedScalarType(ScalarType)).to.equal(false); - }); - }); - - describe('isObjectType', () => { - it('returns true for object type', () => { - expect(isObjectType(ObjectType)).to.equal(true); - expect(() => assertObjectType(ObjectType)).to.not.throw(); - }); - - it('returns false for wrapped object type', () => { - expect(isObjectType(new GraphQLList(ObjectType))).to.equal(false); - expect(() => assertObjectType(new GraphQLList(ObjectType))).to.throw(); - }); - - it('returns false for non-object type', () => { - expect(isObjectType(InterfaceType)).to.equal(false); - expect(() => assertObjectType(InterfaceType)).to.throw(); - }); - }); - - describe('isInterfaceType', () => { - it('returns true for interface type', () => { - expect(isInterfaceType(InterfaceType)).to.equal(true); - expect(() => assertInterfaceType(InterfaceType)).to.not.throw(); - }); - - it('returns false for wrapped interface type', () => { - expect(isInterfaceType(new GraphQLList(InterfaceType))).to.equal(false); - expect(() => - assertInterfaceType(new GraphQLList(InterfaceType)), - ).to.throw(); - }); - - it('returns false for non-interface type', () => { - expect(isInterfaceType(ObjectType)).to.equal(false); - expect(() => assertInterfaceType(ObjectType)).to.throw(); - }); - }); - - describe('isUnionType', () => { - it('returns true for union type', () => { - expect(isUnionType(UnionType)).to.equal(true); - expect(() => assertUnionType(UnionType)).to.not.throw(); - }); - - it('returns false for wrapped union type', () => { - expect(isUnionType(new GraphQLList(UnionType))).to.equal(false); - expect(() => assertUnionType(new GraphQLList(UnionType))).to.throw(); - }); - - it('returns false for non-union type', () => { - expect(isUnionType(ObjectType)).to.equal(false); - expect(() => assertUnionType(ObjectType)).to.throw(); - }); - }); - - describe('isEnumType', () => { - it('returns true for enum type', () => { - expect(isEnumType(EnumType)).to.equal(true); - expect(() => assertEnumType(EnumType)).to.not.throw(); - }); - - it('returns false for wrapped enum type', () => { - expect(isEnumType(new GraphQLList(EnumType))).to.equal(false); - expect(() => assertEnumType(new GraphQLList(EnumType))).to.throw(); - }); - - it('returns false for non-enum type', () => { - expect(isEnumType(ScalarType)).to.equal(false); - expect(() => assertEnumType(ScalarType)).to.throw(); - }); - }); - - describe('isInputObjectType', () => { - it('returns true for input object type', () => { - expect(isInputObjectType(InputObjectType)).to.equal(true); - expect(() => assertInputObjectType(InputObjectType)).to.not.throw(); - }); - - it('returns false for wrapped input object type', () => { - expect(isInputObjectType(new GraphQLList(InputObjectType))).to.equal( - false, - ); - expect(() => - assertInputObjectType(new GraphQLList(InputObjectType)), - ).to.throw(); - }); - - it('returns false for non-input-object type', () => { - expect(isInputObjectType(ObjectType)).to.equal(false); - expect(() => assertInputObjectType(ObjectType)).to.throw(); - }); - }); - - describe('isListType', () => { - it('returns true for a list wrapped type', () => { - expect(isListType(new GraphQLList(ObjectType))).to.equal(true); - expect(() => assertListType(new GraphQLList(ObjectType))).to.not.throw(); - }); - - it('returns false for an unwrapped type', () => { - expect(isListType(ObjectType)).to.equal(false); - expect(() => assertListType(ObjectType)).to.throw(); - }); - - it('returns false for a non-list wrapped type', () => { - expect( - isListType(new GraphQLNonNull(new GraphQLList(ObjectType))), - ).to.equal(false); - expect(() => - assertListType(new GraphQLNonNull(new GraphQLList(ObjectType))), - ).to.throw(); - }); - }); - - describe('isNonNullType', () => { - it('returns true for a non-null wrapped type', () => { - expect(isNonNullType(new GraphQLNonNull(ObjectType))).to.equal(true); - expect(() => - assertNonNullType(new GraphQLNonNull(ObjectType)), - ).to.not.throw(); - }); - - it('returns false for an unwrapped type', () => { - expect(isNonNullType(ObjectType)).to.equal(false); - expect(() => assertNonNullType(ObjectType)).to.throw(); - }); - - it('returns false for a not non-null wrapped type', () => { - expect( - isNonNullType(new GraphQLList(new GraphQLNonNull(ObjectType))), - ).to.equal(false); - expect(() => - assertNonNullType(new GraphQLList(new GraphQLNonNull(ObjectType))), - ).to.throw(); - }); - }); - - describe('isInputType', () => { - function expectInputType(type: unknown) { - expect(isInputType(type)).to.equal(true); - expect(() => assertInputType(type)).to.not.throw(); - } - - it('returns true for an input type', () => { - expectInputType(GraphQLString); - expectInputType(EnumType); - expectInputType(InputObjectType); - }); - - it('returns true for a wrapped input type', () => { - expectInputType(new GraphQLList(GraphQLString)); - expectInputType(new GraphQLList(EnumType)); - expectInputType(new GraphQLList(InputObjectType)); - - expectInputType(new GraphQLNonNull(GraphQLString)); - expectInputType(new GraphQLNonNull(EnumType)); - expectInputType(new GraphQLNonNull(InputObjectType)); - }); - - function expectNonInputType(type: unknown) { - expect(isInputType(type)).to.equal(false); - expect(() => assertInputType(type)).to.throw(); - } - - it('returns false for an output type', () => { - expectNonInputType(ObjectType); - expectNonInputType(InterfaceType); - expectNonInputType(UnionType); - }); - - it('returns false for a wrapped output type', () => { - expectNonInputType(new GraphQLList(ObjectType)); - expectNonInputType(new GraphQLList(InterfaceType)); - expectNonInputType(new GraphQLList(UnionType)); - - expectNonInputType(new GraphQLNonNull(ObjectType)); - expectNonInputType(new GraphQLNonNull(InterfaceType)); - expectNonInputType(new GraphQLNonNull(UnionType)); - }); - }); - - describe('isOutputType', () => { - function expectOutputType(type: unknown) { - expect(isOutputType(type)).to.equal(true); - expect(() => assertOutputType(type)).to.not.throw(); - } - - it('returns true for an output type', () => { - expectOutputType(GraphQLString); - expectOutputType(ObjectType); - expectOutputType(InterfaceType); - expectOutputType(UnionType); - expectOutputType(EnumType); - }); - - it('returns true for a wrapped output type', () => { - expectOutputType(new GraphQLList(GraphQLString)); - expectOutputType(new GraphQLList(ObjectType)); - expectOutputType(new GraphQLList(InterfaceType)); - expectOutputType(new GraphQLList(UnionType)); - expectOutputType(new GraphQLList(EnumType)); - - expectOutputType(new GraphQLNonNull(GraphQLString)); - expectOutputType(new GraphQLNonNull(ObjectType)); - expectOutputType(new GraphQLNonNull(InterfaceType)); - expectOutputType(new GraphQLNonNull(UnionType)); - expectOutputType(new GraphQLNonNull(EnumType)); - }); - - function expectNonOutputType(type: unknown) { - expect(isOutputType(type)).to.equal(false); - expect(() => assertOutputType(type)).to.throw(); - } - - it('returns false for an input type', () => { - expectNonOutputType(InputObjectType); - }); - - it('returns false for a wrapped input type', () => { - expectNonOutputType(new GraphQLList(InputObjectType)); - expectNonOutputType(new GraphQLNonNull(InputObjectType)); - }); - }); - - describe('isLeafType', () => { - it('returns true for scalar and enum types', () => { - expect(isLeafType(ScalarType)).to.equal(true); - expect(() => assertLeafType(ScalarType)).to.not.throw(); - expect(isLeafType(EnumType)).to.equal(true); - expect(() => assertLeafType(EnumType)).to.not.throw(); - }); - - it('returns false for wrapped leaf type', () => { - expect(isLeafType(new GraphQLList(ScalarType))).to.equal(false); - expect(() => assertLeafType(new GraphQLList(ScalarType))).to.throw(); - }); - - it('returns false for non-leaf type', () => { - expect(isLeafType(ObjectType)).to.equal(false); - expect(() => assertLeafType(ObjectType)).to.throw(); - }); - - it('returns false for wrapped non-leaf type', () => { - expect(isLeafType(new GraphQLList(ObjectType))).to.equal(false); - expect(() => assertLeafType(new GraphQLList(ObjectType))).to.throw(); - }); - }); - - describe('isCompositeType', () => { - it('returns true for object, interface, and union types', () => { - expect(isCompositeType(ObjectType)).to.equal(true); - expect(() => assertCompositeType(ObjectType)).to.not.throw(); - expect(isCompositeType(InterfaceType)).to.equal(true); - expect(() => assertCompositeType(InterfaceType)).to.not.throw(); - expect(isCompositeType(UnionType)).to.equal(true); - expect(() => assertCompositeType(UnionType)).to.not.throw(); - }); - - it('returns false for wrapped composite type', () => { - expect(isCompositeType(new GraphQLList(ObjectType))).to.equal(false); - expect(() => assertCompositeType(new GraphQLList(ObjectType))).to.throw(); - }); - - it('returns false for non-composite type', () => { - expect(isCompositeType(InputObjectType)).to.equal(false); - expect(() => assertCompositeType(InputObjectType)).to.throw(); - }); - - it('returns false for wrapped non-composite type', () => { - expect(isCompositeType(new GraphQLList(InputObjectType))).to.equal(false); - expect(() => - assertCompositeType(new GraphQLList(InputObjectType)), - ).to.throw(); - }); - }); - - describe('isAbstractType', () => { - it('returns true for interface and union types', () => { - expect(isAbstractType(InterfaceType)).to.equal(true); - expect(() => assertAbstractType(InterfaceType)).to.not.throw(); - expect(isAbstractType(UnionType)).to.equal(true); - expect(() => assertAbstractType(UnionType)).to.not.throw(); - }); - - it('returns false for wrapped abstract type', () => { - expect(isAbstractType(new GraphQLList(InterfaceType))).to.equal(false); - expect(() => - assertAbstractType(new GraphQLList(InterfaceType)), - ).to.throw(); - }); - - it('returns false for non-abstract type', () => { - expect(isAbstractType(ObjectType)).to.equal(false); - expect(() => assertAbstractType(ObjectType)).to.throw(); - }); - - it('returns false for wrapped non-abstract type', () => { - expect(isAbstractType(new GraphQLList(ObjectType))).to.equal(false); - expect(() => assertAbstractType(new GraphQLList(ObjectType))).to.throw(); - }); - }); - - describe('isWrappingType', () => { - it('returns true for list and non-null types', () => { - expect(isWrappingType(new GraphQLList(ObjectType))).to.equal(true); - expect(() => - assertWrappingType(new GraphQLList(ObjectType)), - ).to.not.throw(); - expect(isWrappingType(new GraphQLNonNull(ObjectType))).to.equal(true); - expect(() => - assertWrappingType(new GraphQLNonNull(ObjectType)), - ).to.not.throw(); - }); - - it('returns false for unwrapped types', () => { - expect(isWrappingType(ObjectType)).to.equal(false); - expect(() => assertWrappingType(ObjectType)).to.throw(); - }); - }); - - describe('isNullableType', () => { - it('returns true for unwrapped types', () => { - expect(isNullableType(ObjectType)).to.equal(true); - expect(() => assertNullableType(ObjectType)).to.not.throw(); - }); - - it('returns true for list of non-null types', () => { - expect( - isNullableType(new GraphQLList(new GraphQLNonNull(ObjectType))), - ).to.equal(true); - expect(() => - assertNullableType(new GraphQLList(new GraphQLNonNull(ObjectType))), - ).to.not.throw(); - }); - - it('returns false for non-null types', () => { - expect(isNullableType(new GraphQLNonNull(ObjectType))).to.equal(false); - expect(() => - assertNullableType(new GraphQLNonNull(ObjectType)), - ).to.throw(); - }); - }); - - describe('getNullableType', () => { - it('returns undefined for no type', () => { - expect(getNullableType(undefined)).to.equal(undefined); - expect(getNullableType(null)).to.equal(undefined); - }); - - it('returns self for a nullable type', () => { - expect(getNullableType(ObjectType)).to.equal(ObjectType); - const listOfObj = new GraphQLList(ObjectType); - expect(getNullableType(listOfObj)).to.equal(listOfObj); - }); - - it('unwraps non-null type', () => { - expect(getNullableType(new GraphQLNonNull(ObjectType))).to.equal( - ObjectType, - ); - }); - }); - - describe('isNamedType', () => { - it('returns true for unwrapped types', () => { - expect(isNamedType(ObjectType)).to.equal(true); - expect(() => assertNamedType(ObjectType)).to.not.throw(); - }); - - it('returns false for list and non-null types', () => { - expect(isNamedType(new GraphQLList(ObjectType))).to.equal(false); - expect(() => assertNamedType(new GraphQLList(ObjectType))).to.throw(); - expect(isNamedType(new GraphQLNonNull(ObjectType))).to.equal(false); - expect(() => assertNamedType(new GraphQLNonNull(ObjectType))).to.throw(); - }); - }); - - describe('getNamedType', () => { - it('returns undefined for no type', () => { - expect(getNamedType(undefined)).to.equal(undefined); - expect(getNamedType(null)).to.equal(undefined); - }); - - it('returns self for a unwrapped type', () => { - expect(getNamedType(ObjectType)).to.equal(ObjectType); - }); - - it('unwraps wrapper types', () => { - expect(getNamedType(new GraphQLNonNull(ObjectType))).to.equal(ObjectType); - expect(getNamedType(new GraphQLList(ObjectType))).to.equal(ObjectType); - }); - - it('unwraps deeply wrapper types', () => { - expect( - getNamedType( - new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ObjectType))), - ), - ).to.equal(ObjectType); - }); - }); - - describe('isRequiredArgument', () => { - function buildArg(config: { - type: GraphQLInputType; - defaultValue?: unknown; - }): GraphQLArgument { - return { - name: 'someArg', - type: config.type, - description: undefined, - defaultValue: config.defaultValue, - deprecationReason: null, - extensions: Object.create(null), - astNode: undefined, - }; - } - - it('returns true for required arguments', () => { - const requiredArg = buildArg({ - type: new GraphQLNonNull(GraphQLString), - }); - expect(isRequiredArgument(requiredArg)).to.equal(true); - }); - - it('returns false for optional arguments', () => { - const optArg1 = buildArg({ - type: GraphQLString, - }); - expect(isRequiredArgument(optArg1)).to.equal(false); - - const optArg2 = buildArg({ - type: GraphQLString, - defaultValue: null, - }); - expect(isRequiredArgument(optArg2)).to.equal(false); - - const optArg3 = buildArg({ - type: new GraphQLList(new GraphQLNonNull(GraphQLString)), - }); - expect(isRequiredArgument(optArg3)).to.equal(false); - - const optArg4 = buildArg({ - type: new GraphQLNonNull(GraphQLString), - defaultValue: 'default', - }); - expect(isRequiredArgument(optArg4)).to.equal(false); - }); - }); - - describe('isRequiredInputField', () => { - function buildInputField(config: { - type: GraphQLInputType; - defaultValue?: unknown; - }): GraphQLInputField { - return { - name: 'someInputField', - type: config.type, - description: undefined, - defaultValue: config.defaultValue, - deprecationReason: null, - extensions: Object.create(null), - astNode: undefined, - }; - } - - it('returns true for required input field', () => { - const requiredField = buildInputField({ - type: new GraphQLNonNull(GraphQLString), - }); - expect(isRequiredInputField(requiredField)).to.equal(true); - }); - - it('returns false for optional input field', () => { - const optField1 = buildInputField({ - type: GraphQLString, - }); - expect(isRequiredInputField(optField1)).to.equal(false); - - const optField2 = buildInputField({ - type: GraphQLString, - defaultValue: null, - }); - expect(isRequiredInputField(optField2)).to.equal(false); - - const optField3 = buildInputField({ - type: new GraphQLList(new GraphQLNonNull(GraphQLString)), - }); - expect(isRequiredInputField(optField3)).to.equal(false); - - const optField4 = buildInputField({ - type: new GraphQLNonNull(GraphQLString), - defaultValue: 'default', - }); - expect(isRequiredInputField(optField4)).to.equal(false); - }); - }); -}); - -describe('Directive predicates', () => { - describe('isDirective', () => { - it('returns true for spec defined directive', () => { - expect(isDirective(GraphQLSkipDirective)).to.equal(true); - expect(() => assertDirective(GraphQLSkipDirective)).to.not.throw(); - }); - - it('returns true for custom directive', () => { - expect(isDirective(Directive)).to.equal(true); - expect(() => assertDirective(Directive)).to.not.throw(); - }); - - it('returns false for directive class (rather than instance)', () => { - expect(isDirective(GraphQLDirective)).to.equal(false); - expect(() => assertDirective(GraphQLDirective)).to.throw(); - }); - - it('returns false for non-directive', () => { - expect(isDirective(EnumType)).to.equal(false); - expect(() => assertDirective(EnumType)).to.throw(); - expect(isDirective(ScalarType)).to.equal(false); - expect(() => assertDirective(ScalarType)).to.throw(); - }); - - it('returns false for random garbage', () => { - expect(isDirective({ what: 'is this' })).to.equal(false); - expect(() => assertDirective({ what: 'is this' })).to.throw(); - }); - }); - describe('isSpecifiedDirective', () => { - it('returns true for specified directives', () => { - expect(isSpecifiedDirective(GraphQLIncludeDirective)).to.equal(true); - expect(isSpecifiedDirective(GraphQLSkipDirective)).to.equal(true); - expect(isSpecifiedDirective(GraphQLDeprecatedDirective)).to.equal(true); - }); - - it('returns false for custom directive', () => { - expect(isSpecifiedDirective(Directive)).to.equal(false); - }); - }); -}); diff --git a/src/type/__tests__/scalars-test.ts b/src/type/__tests__/scalars-test.ts deleted file mode 100644 index 4d563aee10..0000000000 --- a/src/type/__tests__/scalars-test.ts +++ /dev/null @@ -1,654 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parseValue as parseValueToAST } from '../../language/parser'; - -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLID, - GraphQLInt, - GraphQLString, -} from '../scalars'; - -describe('Type System: Specified scalar types', () => { - describe('GraphQLInt', () => { - it('parseValue', () => { - function parseValue(value: unknown) { - return GraphQLInt.parseValue(value); - } - - expect(parseValue(1)).to.equal(1); - expect(parseValue(0)).to.equal(0); - expect(parseValue(-1)).to.equal(-1); - - expect(() => parseValue(9876504321)).to.throw( - 'Int cannot represent non 32-bit signed integer value: 9876504321', - ); - expect(() => parseValue(-9876504321)).to.throw( - 'Int cannot represent non 32-bit signed integer value: -9876504321', - ); - expect(() => parseValue(0.1)).to.throw( - 'Int cannot represent non-integer value: 0.1', - ); - expect(() => parseValue(NaN)).to.throw( - 'Int cannot represent non-integer value: NaN', - ); - expect(() => parseValue(Infinity)).to.throw( - 'Int cannot represent non-integer value: Infinity', - ); - - expect(() => parseValue(undefined)).to.throw( - 'Int cannot represent non-integer value: undefined', - ); - expect(() => parseValue(null)).to.throw( - 'Int cannot represent non-integer value: null', - ); - expect(() => parseValue('')).to.throw( - 'Int cannot represent non-integer value: ""', - ); - expect(() => parseValue('123')).to.throw( - 'Int cannot represent non-integer value: "123"', - ); - expect(() => parseValue(false)).to.throw( - 'Int cannot represent non-integer value: false', - ); - expect(() => parseValue(true)).to.throw( - 'Int cannot represent non-integer value: true', - ); - expect(() => parseValue([1])).to.throw( - 'Int cannot represent non-integer value: [1]', - ); - expect(() => parseValue({ value: 1 })).to.throw( - 'Int cannot represent non-integer value: { value: 1 }', - ); - }); - - it('parseLiteral', () => { - function parseLiteral(str: string) { - return GraphQLInt.parseLiteral(parseValueToAST(str), undefined); - } - - expect(parseLiteral('1')).to.equal(1); - expect(parseLiteral('0')).to.equal(0); - expect(parseLiteral('-1')).to.equal(-1); - - expect(() => parseLiteral('9876504321')).to.throw( - 'Int cannot represent non 32-bit signed integer value: 9876504321', - ); - expect(() => parseLiteral('-9876504321')).to.throw( - 'Int cannot represent non 32-bit signed integer value: -9876504321', - ); - - expect(() => parseLiteral('1.0')).to.throw( - 'Int cannot represent non-integer value: 1.0', - ); - expect(() => parseLiteral('null')).to.throw( - 'Int cannot represent non-integer value: null', - ); - expect(() => parseLiteral('""')).to.throw( - 'Int cannot represent non-integer value: ""', - ); - expect(() => parseLiteral('"123"')).to.throw( - 'Int cannot represent non-integer value: "123"', - ); - expect(() => parseLiteral('false')).to.throw( - 'Int cannot represent non-integer value: false', - ); - expect(() => parseLiteral('[1]')).to.throw( - 'Int cannot represent non-integer value: [1]', - ); - expect(() => parseLiteral('{ value: 1 }')).to.throw( - 'Int cannot represent non-integer value: {value: 1}', - ); - expect(() => parseLiteral('ENUM_VALUE')).to.throw( - 'Int cannot represent non-integer value: ENUM_VALUE', - ); - expect(() => parseLiteral('$var')).to.throw( - 'Int cannot represent non-integer value: $var', - ); - }); - - it('serialize', () => { - function serialize(value: unknown) { - return GraphQLInt.serialize(value); - } - - expect(serialize(1)).to.equal(1); - expect(serialize('123')).to.equal(123); - expect(serialize(0)).to.equal(0); - expect(serialize(-1)).to.equal(-1); - expect(serialize(1e5)).to.equal(100000); - expect(serialize(false)).to.equal(0); - expect(serialize(true)).to.equal(1); - - const customValueOfObj = { - value: 5, - valueOf() { - return this.value; - }, - }; - expect(serialize(customValueOfObj)).to.equal(5); - - // The GraphQL specification does not allow serializing non-integer values - // as Int to avoid accidental data loss. - expect(() => serialize(0.1)).to.throw( - 'Int cannot represent non-integer value: 0.1', - ); - expect(() => serialize(1.1)).to.throw( - 'Int cannot represent non-integer value: 1.1', - ); - expect(() => serialize(-1.1)).to.throw( - 'Int cannot represent non-integer value: -1.1', - ); - expect(() => serialize('-1.1')).to.throw( - 'Int cannot represent non-integer value: "-1.1"', - ); - - // Maybe a safe JavaScript int, but bigger than 2^32, so not - // representable as a GraphQL Int - expect(() => serialize(9876504321)).to.throw( - 'Int cannot represent non 32-bit signed integer value: 9876504321', - ); - expect(() => serialize(-9876504321)).to.throw( - 'Int cannot represent non 32-bit signed integer value: -9876504321', - ); - - // Too big to represent as an Int in JavaScript or GraphQL - expect(() => serialize(1e100)).to.throw( - 'Int cannot represent non 32-bit signed integer value: 1e+100', - ); - expect(() => serialize(-1e100)).to.throw( - 'Int cannot represent non 32-bit signed integer value: -1e+100', - ); - expect(() => serialize('one')).to.throw( - 'Int cannot represent non-integer value: "one"', - ); - - // Doesn't represent number - expect(() => serialize('')).to.throw( - 'Int cannot represent non-integer value: ""', - ); - expect(() => serialize(NaN)).to.throw( - 'Int cannot represent non-integer value: NaN', - ); - expect(() => serialize(Infinity)).to.throw( - 'Int cannot represent non-integer value: Infinity', - ); - expect(() => serialize([5])).to.throw( - 'Int cannot represent non-integer value: [5]', - ); - }); - }); - - describe('GraphQLFloat', () => { - it('parseValue', () => { - function parseValue(value: unknown) { - return GraphQLFloat.parseValue(value); - } - - expect(parseValue(1)).to.equal(1); - expect(parseValue(0)).to.equal(0); - expect(parseValue(-1)).to.equal(-1); - expect(parseValue(0.1)).to.equal(0.1); - expect(parseValue(Math.PI)).to.equal(Math.PI); - - expect(() => parseValue(NaN)).to.throw( - 'Float cannot represent non numeric value: NaN', - ); - expect(() => parseValue(Infinity)).to.throw( - 'Float cannot represent non numeric value: Infinity', - ); - - expect(() => parseValue(undefined)).to.throw( - 'Float cannot represent non numeric value: undefined', - ); - expect(() => parseValue(null)).to.throw( - 'Float cannot represent non numeric value: null', - ); - expect(() => parseValue('')).to.throw( - 'Float cannot represent non numeric value: ""', - ); - expect(() => parseValue('123')).to.throw( - 'Float cannot represent non numeric value: "123"', - ); - expect(() => parseValue('123.5')).to.throw( - 'Float cannot represent non numeric value: "123.5"', - ); - expect(() => parseValue(false)).to.throw( - 'Float cannot represent non numeric value: false', - ); - expect(() => parseValue(true)).to.throw( - 'Float cannot represent non numeric value: true', - ); - expect(() => parseValue([0.1])).to.throw( - 'Float cannot represent non numeric value: [0.1]', - ); - expect(() => parseValue({ value: 0.1 })).to.throw( - 'Float cannot represent non numeric value: { value: 0.1 }', - ); - }); - - it('parseLiteral', () => { - function parseLiteral(str: string) { - return GraphQLFloat.parseLiteral(parseValueToAST(str), undefined); - } - - expect(parseLiteral('1')).to.equal(1); - expect(parseLiteral('0')).to.equal(0); - expect(parseLiteral('-1')).to.equal(-1); - expect(parseLiteral('0.1')).to.equal(0.1); - expect(parseLiteral(Math.PI.toString())).to.equal(Math.PI); - - expect(() => parseLiteral('null')).to.throw( - 'Float cannot represent non numeric value: null', - ); - expect(() => parseLiteral('""')).to.throw( - 'Float cannot represent non numeric value: ""', - ); - expect(() => parseLiteral('"123"')).to.throw( - 'Float cannot represent non numeric value: "123"', - ); - expect(() => parseLiteral('"123.5"')).to.throw( - 'Float cannot represent non numeric value: "123.5"', - ); - expect(() => parseLiteral('false')).to.throw( - 'Float cannot represent non numeric value: false', - ); - expect(() => parseLiteral('[0.1]')).to.throw( - 'Float cannot represent non numeric value: [0.1]', - ); - expect(() => parseLiteral('{ value: 0.1 }')).to.throw( - 'Float cannot represent non numeric value: {value: 0.1}', - ); - expect(() => parseLiteral('ENUM_VALUE')).to.throw( - 'Float cannot represent non numeric value: ENUM_VALUE', - ); - expect(() => parseLiteral('$var')).to.throw( - 'Float cannot represent non numeric value: $var', - ); - }); - - it('serialize', () => { - function serialize(value: unknown) { - return GraphQLFloat.serialize(value); - } - - expect(serialize(1)).to.equal(1.0); - expect(serialize(0)).to.equal(0.0); - expect(serialize('123.5')).to.equal(123.5); - expect(serialize(-1)).to.equal(-1.0); - expect(serialize(0.1)).to.equal(0.1); - expect(serialize(1.1)).to.equal(1.1); - expect(serialize(-1.1)).to.equal(-1.1); - expect(serialize('-1.1')).to.equal(-1.1); - expect(serialize(false)).to.equal(0.0); - expect(serialize(true)).to.equal(1.0); - - const customValueOfObj = { - value: 5.5, - valueOf() { - return this.value; - }, - }; - expect(serialize(customValueOfObj)).to.equal(5.5); - - expect(() => serialize(NaN)).to.throw( - 'Float cannot represent non numeric value: NaN', - ); - expect(() => serialize(Infinity)).to.throw( - 'Float cannot represent non numeric value: Infinity', - ); - expect(() => serialize('one')).to.throw( - 'Float cannot represent non numeric value: "one"', - ); - expect(() => serialize('')).to.throw( - 'Float cannot represent non numeric value: ""', - ); - expect(() => serialize([5])).to.throw( - 'Float cannot represent non numeric value: [5]', - ); - }); - }); - - describe('GraphQLString', () => { - it('parseValue', () => { - function parseValue(value: unknown) { - return GraphQLString.parseValue(value); - } - - expect(parseValue('foo')).to.equal('foo'); - - expect(() => parseValue(undefined)).to.throw( - 'String cannot represent a non string value: undefined', - ); - expect(() => parseValue(null)).to.throw( - 'String cannot represent a non string value: null', - ); - expect(() => parseValue(1)).to.throw( - 'String cannot represent a non string value: 1', - ); - expect(() => parseValue(NaN)).to.throw( - 'String cannot represent a non string value: NaN', - ); - expect(() => parseValue(false)).to.throw( - 'String cannot represent a non string value: false', - ); - expect(() => parseValue(['foo'])).to.throw( - 'String cannot represent a non string value: ["foo"]', - ); - expect(() => parseValue({ value: 'foo' })).to.throw( - 'String cannot represent a non string value: { value: "foo" }', - ); - }); - - it('parseLiteral', () => { - function parseLiteral(str: string) { - return GraphQLString.parseLiteral(parseValueToAST(str), undefined); - } - - expect(parseLiteral('"foo"')).to.equal('foo'); - expect(parseLiteral('"""bar"""')).to.equal('bar'); - - expect(() => parseLiteral('null')).to.throw( - 'String cannot represent a non string value: null', - ); - expect(() => parseLiteral('1')).to.throw( - 'String cannot represent a non string value: 1', - ); - expect(() => parseLiteral('0.1')).to.throw( - 'String cannot represent a non string value: 0.1', - ); - expect(() => parseLiteral('false')).to.throw( - 'String cannot represent a non string value: false', - ); - expect(() => parseLiteral('["foo"]')).to.throw( - 'String cannot represent a non string value: ["foo"]', - ); - expect(() => parseLiteral('{ value: "foo" }')).to.throw( - 'String cannot represent a non string value: {value: "foo"}', - ); - expect(() => parseLiteral('ENUM_VALUE')).to.throw( - 'String cannot represent a non string value: ENUM_VALUE', - ); - expect(() => parseLiteral('$var')).to.throw( - 'String cannot represent a non string value: $var', - ); - }); - - it('serialize', () => { - function serialize(value: unknown) { - return GraphQLString.serialize(value); - } - - expect(serialize('string')).to.equal('string'); - expect(serialize(1)).to.equal('1'); - expect(serialize(-1.1)).to.equal('-1.1'); - expect(serialize(true)).to.equal('true'); - expect(serialize(false)).to.equal('false'); - - const valueOf = () => 'valueOf string'; - const toJSON = () => 'toJSON string'; - - const valueOfAndToJSONValue = { valueOf, toJSON }; - expect(serialize(valueOfAndToJSONValue)).to.equal('valueOf string'); - - const onlyToJSONValue = { toJSON }; - expect(serialize(onlyToJSONValue)).to.equal('toJSON string'); - - expect(() => serialize(NaN)).to.throw( - 'String cannot represent value: NaN', - ); - - expect(() => serialize([1])).to.throw( - 'String cannot represent value: [1]', - ); - - const badObjValue = {}; - expect(() => serialize(badObjValue)).to.throw( - 'String cannot represent value: {}', - ); - - const badValueOfObjValue = { valueOf: 'valueOf string' }; - expect(() => serialize(badValueOfObjValue)).to.throw( - 'String cannot represent value: { valueOf: "valueOf string" }', - ); - }); - }); - - describe('GraphQLBoolean', () => { - it('parseValue', () => { - function parseValue(value: unknown) { - return GraphQLBoolean.parseValue(value); - } - - expect(parseValue(true)).to.equal(true); - expect(parseValue(false)).to.equal(false); - - expect(() => parseValue(undefined)).to.throw( - 'Boolean cannot represent a non boolean value: undefined', - ); - expect(() => parseValue(null)).to.throw( - 'Boolean cannot represent a non boolean value: null', - ); - expect(() => parseValue(0)).to.throw( - 'Boolean cannot represent a non boolean value: 0', - ); - expect(() => parseValue(1)).to.throw( - 'Boolean cannot represent a non boolean value: 1', - ); - expect(() => parseValue(NaN)).to.throw( - 'Boolean cannot represent a non boolean value: NaN', - ); - expect(() => parseValue('')).to.throw( - 'Boolean cannot represent a non boolean value: ""', - ); - expect(() => parseValue('false')).to.throw( - 'Boolean cannot represent a non boolean value: "false"', - ); - expect(() => parseValue([false])).to.throw( - 'Boolean cannot represent a non boolean value: [false]', - ); - expect(() => parseValue({ value: false })).to.throw( - 'Boolean cannot represent a non boolean value: { value: false }', - ); - }); - - it('parseLiteral', () => { - function parseLiteral(str: string) { - return GraphQLBoolean.parseLiteral(parseValueToAST(str), undefined); - } - - expect(parseLiteral('true')).to.equal(true); - expect(parseLiteral('false')).to.equal(false); - - expect(() => parseLiteral('null')).to.throw( - 'Boolean cannot represent a non boolean value: null', - ); - expect(() => parseLiteral('0')).to.throw( - 'Boolean cannot represent a non boolean value: 0', - ); - expect(() => parseLiteral('1')).to.throw( - 'Boolean cannot represent a non boolean value: 1', - ); - expect(() => parseLiteral('0.1')).to.throw( - 'Boolean cannot represent a non boolean value: 0.1', - ); - expect(() => parseLiteral('""')).to.throw( - 'Boolean cannot represent a non boolean value: ""', - ); - expect(() => parseLiteral('"false"')).to.throw( - 'Boolean cannot represent a non boolean value: "false"', - ); - expect(() => parseLiteral('[false]')).to.throw( - 'Boolean cannot represent a non boolean value: [false]', - ); - expect(() => parseLiteral('{ value: false }')).to.throw( - 'Boolean cannot represent a non boolean value: {value: false}', - ); - expect(() => parseLiteral('ENUM_VALUE')).to.throw( - 'Boolean cannot represent a non boolean value: ENUM_VALUE', - ); - expect(() => parseLiteral('$var')).to.throw( - 'Boolean cannot represent a non boolean value: $var', - ); - }); - - it('serialize', () => { - function serialize(value: unknown) { - return GraphQLBoolean.serialize(value); - } - - expect(serialize(1)).to.equal(true); - expect(serialize(0)).to.equal(false); - expect(serialize(true)).to.equal(true); - expect(serialize(false)).to.equal(false); - expect( - serialize({ - value: true, - valueOf() { - return (this as { value: boolean }).value; - }, - }), - ).to.equal(true); - - expect(() => serialize(NaN)).to.throw( - 'Boolean cannot represent a non boolean value: NaN', - ); - expect(() => serialize('')).to.throw( - 'Boolean cannot represent a non boolean value: ""', - ); - expect(() => serialize('true')).to.throw( - 'Boolean cannot represent a non boolean value: "true"', - ); - expect(() => serialize([false])).to.throw( - 'Boolean cannot represent a non boolean value: [false]', - ); - expect(() => serialize({})).to.throw( - 'Boolean cannot represent a non boolean value: {}', - ); - }); - }); - - describe('GraphQLID', () => { - it('parseValue', () => { - function parseValue(value: unknown) { - return GraphQLID.parseValue(value); - } - - expect(parseValue('')).to.equal(''); - expect(parseValue('1')).to.equal('1'); - expect(parseValue('foo')).to.equal('foo'); - expect(parseValue(1)).to.equal('1'); - expect(parseValue(0)).to.equal('0'); - expect(parseValue(-1)).to.equal('-1'); - - // Maximum and minimum safe numbers in JS - expect(parseValue(9007199254740991)).to.equal('9007199254740991'); - expect(parseValue(-9007199254740991)).to.equal('-9007199254740991'); - - expect(() => parseValue(undefined)).to.throw( - 'ID cannot represent value: undefined', - ); - expect(() => parseValue(null)).to.throw( - 'ID cannot represent value: null', - ); - expect(() => parseValue(0.1)).to.throw('ID cannot represent value: 0.1'); - expect(() => parseValue(NaN)).to.throw('ID cannot represent value: NaN'); - expect(() => parseValue(Infinity)).to.throw( - 'ID cannot represent value: Inf', - ); - expect(() => parseValue(false)).to.throw( - 'ID cannot represent value: false', - ); - expect(() => GraphQLID.parseValue(['1'])).to.throw( - 'ID cannot represent value: ["1"]', - ); - expect(() => GraphQLID.parseValue({ value: '1' })).to.throw( - 'ID cannot represent value: { value: "1" }', - ); - }); - - it('parseLiteral', () => { - function parseLiteral(str: string) { - return GraphQLID.parseLiteral(parseValueToAST(str), undefined); - } - - expect(parseLiteral('""')).to.equal(''); - expect(parseLiteral('"1"')).to.equal('1'); - expect(parseLiteral('"foo"')).to.equal('foo'); - expect(parseLiteral('"""foo"""')).to.equal('foo'); - expect(parseLiteral('1')).to.equal('1'); - expect(parseLiteral('0')).to.equal('0'); - expect(parseLiteral('-1')).to.equal('-1'); - - // Support arbitrary long numbers even if they can't be represented in JS - expect(parseLiteral('90071992547409910')).to.equal('90071992547409910'); - expect(parseLiteral('-90071992547409910')).to.equal('-90071992547409910'); - - expect(() => parseLiteral('null')).to.throw( - 'ID cannot represent a non-string and non-integer value: null', - ); - expect(() => parseLiteral('0.1')).to.throw( - 'ID cannot represent a non-string and non-integer value: 0.1', - ); - expect(() => parseLiteral('false')).to.throw( - 'ID cannot represent a non-string and non-integer value: false', - ); - expect(() => parseLiteral('["1"]')).to.throw( - 'ID cannot represent a non-string and non-integer value: ["1"]', - ); - expect(() => parseLiteral('{ value: "1" }')).to.throw( - 'ID cannot represent a non-string and non-integer value: {value: "1"}', - ); - expect(() => parseLiteral('ENUM_VALUE')).to.throw( - 'ID cannot represent a non-string and non-integer value: ENUM_VALUE', - ); - expect(() => parseLiteral('$var')).to.throw( - 'ID cannot represent a non-string and non-integer value: $var', - ); - }); - - it('serialize', () => { - function serialize(value: unknown) { - return GraphQLID.serialize(value); - } - - expect(serialize('string')).to.equal('string'); - expect(serialize('false')).to.equal('false'); - expect(serialize('')).to.equal(''); - expect(serialize(123)).to.equal('123'); - expect(serialize(0)).to.equal('0'); - expect(serialize(-1)).to.equal('-1'); - - const valueOf = () => 'valueOf ID'; - const toJSON = () => 'toJSON ID'; - - const valueOfAndToJSONValue = { valueOf, toJSON }; - expect(serialize(valueOfAndToJSONValue)).to.equal('valueOf ID'); - - const onlyToJSONValue = { toJSON }; - expect(serialize(onlyToJSONValue)).to.equal('toJSON ID'); - - const badObjValue = { - _id: false, - valueOf() { - return this._id; - }, - }; - expect(() => serialize(badObjValue)).to.throw( - 'ID cannot represent value: { _id: false, valueOf: [function valueOf] }', - ); - - expect(() => serialize(true)).to.throw('ID cannot represent value: true'); - - expect(() => serialize(3.14)).to.throw('ID cannot represent value: 3.14'); - - expect(() => serialize({})).to.throw('ID cannot represent value: {}'); - - expect(() => serialize(['abc'])).to.throw( - 'ID cannot represent value: ["abc"]', - ); - }); - }); -}); diff --git a/src/type/__tests__/schema-test.ts b/src/type/__tests__/schema-test.ts deleted file mode 100644 index 8a31b50ada..0000000000 --- a/src/type/__tests__/schema-test.ts +++ /dev/null @@ -1,409 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { DirectiveLocation } from '../../language/directiveLocation'; - -import { printSchema } from '../../utilities/printSchema'; - -import { - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLObjectType, - GraphQLScalarType, -} from '../definition'; -import { GraphQLDirective } from '../directives'; -import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../scalars'; -import { GraphQLSchema } from '../schema'; - -describe('Type System: Schema', () => { - it('Define sample schema', () => { - const BlogImage = new GraphQLObjectType({ - name: 'Image', - fields: { - url: { type: GraphQLString }, - width: { type: GraphQLInt }, - height: { type: GraphQLInt }, - }, - }); - - const BlogAuthor: GraphQLObjectType = new GraphQLObjectType({ - name: 'Author', - fields: () => ({ - id: { type: GraphQLString }, - name: { type: GraphQLString }, - pic: { - args: { width: { type: GraphQLInt }, height: { type: GraphQLInt } }, - type: BlogImage, - }, - recentArticle: { type: BlogArticle }, - }), - }); - - const BlogArticle: GraphQLObjectType = new GraphQLObjectType({ - name: 'Article', - fields: { - id: { type: GraphQLString }, - isPublished: { type: GraphQLBoolean }, - author: { type: BlogAuthor }, - title: { type: GraphQLString }, - body: { type: GraphQLString }, - }, - }); - - const BlogQuery = new GraphQLObjectType({ - name: 'Query', - fields: { - article: { - args: { id: { type: GraphQLString } }, - type: BlogArticle, - }, - feed: { - type: new GraphQLList(BlogArticle), - }, - }, - }); - - const BlogMutation = new GraphQLObjectType({ - name: 'Mutation', - fields: { - writeArticle: { - type: BlogArticle, - }, - }, - }); - - const BlogSubscription = new GraphQLObjectType({ - name: 'Subscription', - fields: { - articleSubscribe: { - args: { id: { type: GraphQLString } }, - type: BlogArticle, - }, - }, - }); - - const schema = new GraphQLSchema({ - description: 'Sample schema', - query: BlogQuery, - mutation: BlogMutation, - subscription: BlogSubscription, - }); - - expect(printSchema(schema)).to.equal(dedent` - """Sample schema""" - schema { - query: Query - mutation: Mutation - subscription: Subscription - } - - type Query { - article(id: String): Article - feed: [Article] - } - - type Article { - id: String - isPublished: Boolean - author: Author - title: String - body: String - } - - type Author { - id: String - name: String - pic(width: Int, height: Int): Image - recentArticle: Article - } - - type Image { - url: String - width: Int - height: Int - } - - type Mutation { - writeArticle: Article - } - - type Subscription { - articleSubscribe(id: String): Article - } - `); - }); - - describe('Root types', () => { - const testType = new GraphQLObjectType({ name: 'TestType', fields: {} }); - - it('defines a query root', () => { - const schema = new GraphQLSchema({ query: testType }); - expect(schema.getQueryType()).to.equal(testType); - expect(schema.getTypeMap()).to.include.keys('TestType'); - }); - - it('defines a mutation root', () => { - const schema = new GraphQLSchema({ mutation: testType }); - expect(schema.getMutationType()).to.equal(testType); - expect(schema.getTypeMap()).to.include.keys('TestType'); - }); - - it('defines a subscription root', () => { - const schema = new GraphQLSchema({ subscription: testType }); - expect(schema.getSubscriptionType()).to.equal(testType); - expect(schema.getTypeMap()).to.include.keys('TestType'); - }); - }); - - describe('Type Map', () => { - it('includes interface possible types in the type map', () => { - const SomeInterface = new GraphQLInterfaceType({ - name: 'SomeInterface', - fields: {}, - }); - - const SomeSubtype = new GraphQLObjectType({ - name: 'SomeSubtype', - fields: {}, - interfaces: [SomeInterface], - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - iface: { type: SomeInterface }, - }, - }), - types: [SomeSubtype], - }); - - expect(schema.getType('SomeInterface')).to.equal(SomeInterface); - expect(schema.getType('SomeSubtype')).to.equal(SomeSubtype); - - expect(schema.isSubType(SomeInterface, SomeSubtype)).to.equal(true); - }); - - it("includes interface's thunk subtypes in the type map", () => { - const SomeInterface = new GraphQLInterfaceType({ - name: 'SomeInterface', - fields: {}, - interfaces: () => [AnotherInterface], - }); - - const AnotherInterface = new GraphQLInterfaceType({ - name: 'AnotherInterface', - fields: {}, - }); - - const SomeSubtype = new GraphQLObjectType({ - name: 'SomeSubtype', - fields: {}, - interfaces: () => [SomeInterface], - }); - - const schema = new GraphQLSchema({ types: [SomeSubtype] }); - - expect(schema.getType('SomeInterface')).to.equal(SomeInterface); - expect(schema.getType('AnotherInterface')).to.equal(AnotherInterface); - expect(schema.getType('SomeSubtype')).to.equal(SomeSubtype); - }); - - it('includes nested input objects in the map', () => { - const NestedInputObject = new GraphQLInputObjectType({ - name: 'NestedInputObject', - fields: {}, - }); - - const SomeInputObject = new GraphQLInputObjectType({ - name: 'SomeInputObject', - fields: { nested: { type: NestedInputObject } }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - something: { - type: GraphQLString, - args: { input: { type: SomeInputObject } }, - }, - }, - }), - }); - - expect(schema.getType('SomeInputObject')).to.equal(SomeInputObject); - expect(schema.getType('NestedInputObject')).to.equal(NestedInputObject); - }); - - it('includes input types only used in directives', () => { - const directive = new GraphQLDirective({ - name: 'dir', - locations: [DirectiveLocation.OBJECT], - args: { - arg: { - type: new GraphQLInputObjectType({ name: 'Foo', fields: {} }), - }, - argList: { - type: new GraphQLList( - new GraphQLInputObjectType({ name: 'Bar', fields: {} }), - ), - }, - }, - }); - const schema = new GraphQLSchema({ directives: [directive] }); - - expect(schema.getTypeMap()).to.include.keys('Foo', 'Bar'); - }); - }); - - it('preserves the order of user provided types', () => { - const aType = new GraphQLObjectType({ - name: 'A', - fields: { - sub: { type: new GraphQLScalarType({ name: 'ASub' }) }, - }, - }); - const zType = new GraphQLObjectType({ - name: 'Z', - fields: { - sub: { type: new GraphQLScalarType({ name: 'ZSub' }) }, - }, - }); - const queryType = new GraphQLObjectType({ - name: 'Query', - fields: { - a: { type: aType }, - z: { type: zType }, - sub: { type: new GraphQLScalarType({ name: 'QuerySub' }) }, - }, - }); - const schema = new GraphQLSchema({ - types: [zType, queryType, aType], - query: queryType, - }); - - const typeNames = Object.keys(schema.getTypeMap()); - expect(typeNames).to.deep.equal([ - 'Z', - 'ZSub', - 'Query', - 'QuerySub', - 'A', - 'ASub', - 'Boolean', - 'String', - '__Schema', - '__Type', - '__TypeKind', - '__Field', - '__InputValue', - '__EnumValue', - '__Directive', - '__DirectiveLocation', - ]); - - // Also check that this order is stable - const copySchema = new GraphQLSchema(schema.toConfig()); - expect(Object.keys(copySchema.getTypeMap())).to.deep.equal(typeNames); - }); - - it('can be Object.toStringified', () => { - const schema = new GraphQLSchema({}); - - expect(Object.prototype.toString.call(schema)).to.equal( - '[object GraphQLSchema]', - ); - }); - - describe('Validity', () => { - describe('when not assumed valid', () => { - it('configures the schema to still needing validation', () => { - expect( - new GraphQLSchema({ - assumeValid: false, - }).__validationErrors, - ).to.equal(undefined); - }); - - it('checks the configuration for mistakes', () => { - // @ts-expect-error - expect(() => new GraphQLSchema(JSON.parse)).to.throw(); - // @ts-expect-error - expect(() => new GraphQLSchema({ types: {} })).to.throw(); - // @ts-expect-error - expect(() => new GraphQLSchema({ directives: {} })).to.throw(); - }); - }); - - describe('A Schema must contain uniquely named types', () => { - it('rejects a Schema which redefines a built-in type', () => { - const FakeString = new GraphQLScalarType({ name: 'String' }); - - const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - normal: { type: GraphQLString }, - fake: { type: FakeString }, - }, - }); - - expect(() => new GraphQLSchema({ query: QueryType })).to.throw( - 'Schema must contain uniquely named types but contains multiple types named "String".', - ); - }); - - it('rejects a Schema when a provided type has no name', () => { - const query = new GraphQLObjectType({ - name: 'Query', - fields: { foo: { type: GraphQLString } }, - }); - const types = [{}, query, {}]; - - // @ts-expect-error - expect(() => new GraphQLSchema({ query, types })).to.throw( - 'One of the provided types for building the Schema is missing a name.', - ); - }); - - it('rejects a Schema which defines an object type twice', () => { - const types = [ - new GraphQLObjectType({ name: 'SameName', fields: {} }), - new GraphQLObjectType({ name: 'SameName', fields: {} }), - ]; - - expect(() => new GraphQLSchema({ types })).to.throw( - 'Schema must contain uniquely named types but contains multiple types named "SameName".', - ); - }); - - it('rejects a Schema which defines fields with conflicting types', () => { - const fields = {}; - const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - a: { type: new GraphQLObjectType({ name: 'SameName', fields }) }, - b: { type: new GraphQLObjectType({ name: 'SameName', fields }) }, - }, - }); - - expect(() => new GraphQLSchema({ query: QueryType })).to.throw( - 'Schema must contain uniquely named types but contains multiple types named "SameName".', - ); - }); - }); - - describe('when assumed valid', () => { - it('configures the schema to have no errors', () => { - expect( - new GraphQLSchema({ - assumeValid: true, - }).__validationErrors, - ).to.deep.equal([]); - }); - }); - }); -}); diff --git a/src/type/__tests__/validation-test.ts b/src/type/__tests__/validation-test.ts deleted file mode 100644 index d5b8773700..0000000000 --- a/src/type/__tests__/validation-test.ts +++ /dev/null @@ -1,2687 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { inspect } from '../../jsutils/inspect'; - -import { DirectiveLocation } from '../../language/directiveLocation'; -import { parse } from '../../language/parser'; - -import { buildSchema } from '../../utilities/buildASTSchema'; -import { extendSchema } from '../../utilities/extendSchema'; - -import type { - GraphQLArgumentConfig, - GraphQLFieldConfig, - GraphQLInputFieldConfig, - GraphQLInputType, - GraphQLNamedType, - GraphQLOutputType, -} from '../definition'; -import { - assertEnumType, - assertInputObjectType, - assertInterfaceType, - assertObjectType, - assertScalarType, - assertUnionType, - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLUnionType, -} from '../definition'; -import { assertDirective, GraphQLDirective } from '../directives'; -import { GraphQLString } from '../scalars'; -import { GraphQLSchema } from '../schema'; -import { assertValidSchema, validateSchema } from '../validate'; - -const SomeSchema = buildSchema(` - scalar SomeScalar - - interface SomeInterface { f: SomeObject } - - type SomeObject implements SomeInterface { f: SomeObject } - - union SomeUnion = SomeObject - - enum SomeEnum { ONLY } - - input SomeInputObject { val: String = "hello" } - - directive @SomeDirective on QUERY -`); - -const SomeScalarType = assertScalarType(SomeSchema.getType('SomeScalar')); -const SomeInterfaceType = assertInterfaceType( - SomeSchema.getType('SomeInterface'), -); -const SomeObjectType = assertObjectType(SomeSchema.getType('SomeObject')); -const SomeUnionType = assertUnionType(SomeSchema.getType('SomeUnion')); -const SomeEnumType = assertEnumType(SomeSchema.getType('SomeEnum')); -const SomeInputObjectType = assertInputObjectType( - SomeSchema.getType('SomeInputObject'), -); - -const SomeDirective = assertDirective(SomeSchema.getDirective('SomeDirective')); - -function withModifiers( - type: T, -): Array | GraphQLNonNull>> { - return [ - type, - new GraphQLList(type), - new GraphQLNonNull(type), - new GraphQLNonNull(new GraphQLList(type)), - ]; -} - -const outputTypes: ReadonlyArray = [ - ...withModifiers(GraphQLString), - ...withModifiers(SomeScalarType), - ...withModifiers(SomeEnumType), - ...withModifiers(SomeObjectType), - ...withModifiers(SomeUnionType), - ...withModifiers(SomeInterfaceType), -]; - -const notOutputTypes: ReadonlyArray = [ - ...withModifiers(SomeInputObjectType), -]; - -const inputTypes: ReadonlyArray = [ - ...withModifiers(GraphQLString), - ...withModifiers(SomeScalarType), - ...withModifiers(SomeEnumType), - ...withModifiers(SomeInputObjectType), -]; - -const notInputTypes: ReadonlyArray = [ - ...withModifiers(SomeObjectType), - ...withModifiers(SomeUnionType), - ...withModifiers(SomeInterfaceType), -]; - -function schemaWithFieldType(type: GraphQLOutputType): GraphQLSchema { - return new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { f: { type } }, - }), - }); -} - -describe('Type System: A Schema must have Object root types', () => { - it('accepts a Schema whose query type is an object type', () => { - const schema = buildSchema(` - type Query { - test: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - - const schemaWithDef = buildSchema(` - schema { - query: QueryRoot - } - - type QueryRoot { - test: String - } - `); - expectJSON(validateSchema(schemaWithDef)).toDeepEqual([]); - }); - - it('accepts a Schema whose query and mutation types are object types', () => { - const schema = buildSchema(` - type Query { - test: String - } - - type Mutation { - test: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - - const schemaWithDef = buildSchema(` - schema { - query: QueryRoot - mutation: MutationRoot - } - - type QueryRoot { - test: String - } - - type MutationRoot { - test: String - } - `); - expectJSON(validateSchema(schemaWithDef)).toDeepEqual([]); - }); - - it('accepts a Schema whose query and subscription types are object types', () => { - const schema = buildSchema(` - type Query { - test: String - } - - type Subscription { - test: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - - const schemaWithDef = buildSchema(` - schema { - query: QueryRoot - subscription: SubscriptionRoot - } - - type QueryRoot { - test: String - } - - type SubscriptionRoot { - test: String - } - `); - expectJSON(validateSchema(schemaWithDef)).toDeepEqual([]); - }); - - it('rejects a Schema without a query type', () => { - const schema = buildSchema(` - type Mutation { - test: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Query root type must be provided.', - }, - ]); - - const schemaWithDef = buildSchema(` - schema { - mutation: MutationRoot - } - - type MutationRoot { - test: String - } - `); - expectJSON(validateSchema(schemaWithDef)).toDeepEqual([ - { - message: 'Query root type must be provided.', - locations: [{ line: 2, column: 7 }], - }, - ]); - }); - - it('rejects a Schema whose query root type is not an Object type', () => { - const schema = buildSchema(` - input Query { - test: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Query root type must be Object type, it cannot be Query.', - locations: [{ line: 2, column: 7 }], - }, - ]); - - const schemaWithDef = buildSchema(` - schema { - query: SomeInputObject - } - - input SomeInputObject { - test: String - } - `); - expectJSON(validateSchema(schemaWithDef)).toDeepEqual([ - { - message: - 'Query root type must be Object type, it cannot be SomeInputObject.', - locations: [{ line: 3, column: 16 }], - }, - ]); - }); - - it('rejects a Schema whose mutation type is an input type', () => { - const schema = buildSchema(` - type Query { - field: String - } - - input Mutation { - test: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Mutation root type must be Object type if provided, it cannot be Mutation.', - locations: [{ line: 6, column: 7 }], - }, - ]); - - const schemaWithDef = buildSchema(` - schema { - query: Query - mutation: SomeInputObject - } - - type Query { - field: String - } - - input SomeInputObject { - test: String - } - `); - expectJSON(validateSchema(schemaWithDef)).toDeepEqual([ - { - message: - 'Mutation root type must be Object type if provided, it cannot be SomeInputObject.', - locations: [{ line: 4, column: 19 }], - }, - ]); - }); - - it('rejects a Schema whose subscription type is an input type', () => { - const schema = buildSchema(` - type Query { - field: String - } - - input Subscription { - test: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Subscription root type must be Object type if provided, it cannot be Subscription.', - locations: [{ line: 6, column: 7 }], - }, - ]); - - const schemaWithDef = buildSchema(` - schema { - query: Query - subscription: SomeInputObject - } - - type Query { - field: String - } - - input SomeInputObject { - test: String - } - `); - expectJSON(validateSchema(schemaWithDef)).toDeepEqual([ - { - message: - 'Subscription root type must be Object type if provided, it cannot be SomeInputObject.', - locations: [{ line: 4, column: 23 }], - }, - ]); - }); - - it('rejects a Schema extended with invalid root types', () => { - let schema = buildSchema(` - input SomeInputObject { - test: String - } - `); - - schema = extendSchema( - schema, - parse(` - extend schema { - query: SomeInputObject - } - `), - ); - - schema = extendSchema( - schema, - parse(` - extend schema { - mutation: SomeInputObject - } - `), - ); - - schema = extendSchema( - schema, - parse(` - extend schema { - subscription: SomeInputObject - } - `), - ); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Query root type must be Object type, it cannot be SomeInputObject.', - locations: [{ line: 3, column: 18 }], - }, - { - message: - 'Mutation root type must be Object type if provided, it cannot be SomeInputObject.', - locations: [{ line: 3, column: 21 }], - }, - { - message: - 'Subscription root type must be Object type if provided, it cannot be SomeInputObject.', - locations: [{ line: 3, column: 25 }], - }, - ]); - }); - - it('rejects a Schema whose types are incorrectly typed', () => { - const schema = new GraphQLSchema({ - query: SomeObjectType, - // @ts-expect-error - types: [{ name: 'SomeType' }, SomeDirective], - }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Expected GraphQL named type but got: { name: "SomeType" }.', - }, - { - message: 'Expected GraphQL named type but got: @SomeDirective.', - locations: [{ line: 14, column: 3 }], - }, - ]); - }); - - it('rejects a Schema whose directives are incorrectly typed', () => { - const schema = new GraphQLSchema({ - query: SomeObjectType, - // @ts-expect-error - directives: [null, 'SomeDirective', SomeScalarType], - }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Expected directive but got: null.', - }, - { - message: 'Expected directive but got: "SomeDirective".', - }, - { - message: 'Expected directive but got: SomeScalar.', - locations: [{ line: 2, column: 3 }], - }, - ]); - }); - - it('rejects a Schema whose directives have empty locations', () => { - const badDirective = new GraphQLDirective({ - name: 'BadDirective', - args: {}, - locations: [], - }); - const schema = new GraphQLSchema({ - query: SomeObjectType, - directives: [badDirective], - }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Directive @BadDirective must include 1 or more locations.', - }, - ]); - }); -}); - -describe('Type System: Objects must have fields', () => { - it('accepts an Object type with fields object', () => { - const schema = buildSchema(` - type Query { - field: SomeObject - } - - type SomeObject { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Object type with missing fields', () => { - const schema = buildSchema(` - type Query { - test: IncompleteObject - } - - type IncompleteObject - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Type IncompleteObject must define one or more fields.', - locations: [{ line: 6, column: 7 }], - }, - ]); - - const manualSchema = schemaWithFieldType( - new GraphQLObjectType({ - name: 'IncompleteObject', - fields: {}, - }), - ); - expectJSON(validateSchema(manualSchema)).toDeepEqual([ - { - message: 'Type IncompleteObject must define one or more fields.', - }, - ]); - - const manualSchema2 = schemaWithFieldType( - new GraphQLObjectType({ - name: 'IncompleteObject', - fields() { - return {}; - }, - }), - ); - expectJSON(validateSchema(manualSchema2)).toDeepEqual([ - { - message: 'Type IncompleteObject must define one or more fields.', - }, - ]); - }); - - it('rejects an Object type with incorrectly named fields', () => { - const schema = schemaWithFieldType( - new GraphQLObjectType({ - name: 'SomeObject', - fields: { - __badName: { type: GraphQLString }, - }, - }), - ); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Name "__badName" must not begin with "__", which is reserved by GraphQL introspection.', - }, - ]); - }); -}); - -describe('Type System: Fields args must be properly named', () => { - it('accepts field args with valid names', () => { - const schema = schemaWithFieldType( - new GraphQLObjectType({ - name: 'SomeObject', - fields: { - goodField: { - type: GraphQLString, - args: { - goodArg: { type: GraphQLString }, - }, - }, - }, - }), - ); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects field arg with invalid names', () => { - const schema = schemaWithFieldType( - new GraphQLObjectType({ - name: 'SomeObject', - fields: { - badField: { - type: GraphQLString, - args: { - __badName: { type: GraphQLString }, - }, - }, - }, - }), - ); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Name "__badName" must not begin with "__", which is reserved by GraphQL introspection.', - }, - ]); - }); -}); - -describe('Type System: Union types must be valid', () => { - it('accepts a Union type with member types', () => { - const schema = buildSchema(` - type Query { - test: GoodUnion - } - - type TypeA { - field: String - } - - type TypeB { - field: String - } - - union GoodUnion = - | TypeA - | TypeB - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects a Union type with empty types', () => { - let schema = buildSchema(` - type Query { - test: BadUnion - } - - union BadUnion - `); - - schema = extendSchema( - schema, - parse(` - directive @test on UNION - - extend union BadUnion @test - `), - ); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Union type BadUnion must define one or more member types.', - locations: [ - { line: 6, column: 7 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('rejects a Union type with duplicated member type', () => { - let schema = buildSchema(` - type Query { - test: BadUnion - } - - type TypeA { - field: String - } - - type TypeB { - field: String - } - - union BadUnion = - | TypeA - | TypeB - | TypeA - `); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Union type BadUnion can only include type TypeA once.', - locations: [ - { line: 15, column: 11 }, - { line: 17, column: 11 }, - ], - }, - ]); - - schema = extendSchema(schema, parse('extend union BadUnion = TypeB')); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Union type BadUnion can only include type TypeA once.', - locations: [ - { line: 15, column: 11 }, - { line: 17, column: 11 }, - ], - }, - { - message: 'Union type BadUnion can only include type TypeB once.', - locations: [ - { line: 16, column: 11 }, - { line: 1, column: 25 }, - ], - }, - ]); - }); - - it('rejects a Union type with non-Object members types', () => { - let schema = buildSchema(` - type Query { - test: BadUnion - } - - type TypeA { - field: String - } - - type TypeB { - field: String - } - - union BadUnion = - | TypeA - | String - | TypeB - `); - - schema = extendSchema(schema, parse('extend union BadUnion = Int')); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Union type BadUnion can only include Object types, it cannot include String.', - locations: [{ line: 16, column: 11 }], - }, - { - message: - 'Union type BadUnion can only include Object types, it cannot include Int.', - locations: [{ line: 1, column: 25 }], - }, - ]); - - const badUnionMemberTypes = [ - GraphQLString, - new GraphQLNonNull(SomeObjectType), - new GraphQLList(SomeObjectType), - SomeInterfaceType, - SomeUnionType, - SomeEnumType, - SomeInputObjectType, - ]; - for (const memberType of badUnionMemberTypes) { - const badUnion = new GraphQLUnionType({ - name: 'BadUnion', - // @ts-expect-error - types: [memberType], - }); - const badSchema = schemaWithFieldType(badUnion); - expectJSON(validateSchema(badSchema)).toDeepEqual([ - { - message: - 'Union type BadUnion can only include Object types, ' + - `it cannot include ${inspect(memberType)}.`, - }, - ]); - } - }); -}); - -describe('Type System: Input Objects must have fields', () => { - it('accepts an Input Object type with fields', () => { - const schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - input SomeInputObject { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Input Object type with missing fields', () => { - let schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - input SomeInputObject - `); - - schema = extendSchema( - schema, - parse(` - directive @test on INPUT_OBJECT - - extend input SomeInputObject @test - `), - ); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Input Object type SomeInputObject must define one or more fields.', - locations: [ - { line: 6, column: 7 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('accepts an Input Object with breakable circular reference', () => { - const schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - input SomeInputObject { - self: SomeInputObject - arrayOfSelf: [SomeInputObject] - nonNullArrayOfSelf: [SomeInputObject]! - nonNullArrayOfNonNullSelf: [SomeInputObject!]! - intermediateSelf: AnotherInputObject - } - - input AnotherInputObject { - parent: SomeInputObject - } - `); - - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Input Object with non-breakable circular reference', () => { - const schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - input SomeInputObject { - nonNullSelf: SomeInputObject! - } - `); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Cannot reference Input Object "SomeInputObject" within itself through a series of non-null fields: "nonNullSelf".', - locations: [{ line: 7, column: 9 }], - }, - ]); - }); - - it('rejects Input Objects with non-breakable circular reference spread across them', () => { - const schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - input SomeInputObject { - startLoop: AnotherInputObject! - } - - input AnotherInputObject { - nextInLoop: YetAnotherInputObject! - } - - input YetAnotherInputObject { - closeLoop: SomeInputObject! - } - `); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Cannot reference Input Object "SomeInputObject" within itself through a series of non-null fields: "startLoop.nextInLoop.closeLoop".', - locations: [ - { line: 7, column: 9 }, - { line: 11, column: 9 }, - { line: 15, column: 9 }, - ], - }, - ]); - }); - - it('rejects Input Objects with multiple non-breakable circular reference', () => { - const schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - input SomeInputObject { - startLoop: AnotherInputObject! - } - - input AnotherInputObject { - closeLoop: SomeInputObject! - startSecondLoop: YetAnotherInputObject! - } - - input YetAnotherInputObject { - closeSecondLoop: AnotherInputObject! - nonNullSelf: YetAnotherInputObject! - } - `); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Cannot reference Input Object "SomeInputObject" within itself through a series of non-null fields: "startLoop.closeLoop".', - locations: [ - { line: 7, column: 9 }, - { line: 11, column: 9 }, - ], - }, - { - message: - 'Cannot reference Input Object "AnotherInputObject" within itself through a series of non-null fields: "startSecondLoop.closeSecondLoop".', - locations: [ - { line: 12, column: 9 }, - { line: 16, column: 9 }, - ], - }, - { - message: - 'Cannot reference Input Object "YetAnotherInputObject" within itself through a series of non-null fields: "nonNullSelf".', - locations: [{ line: 17, column: 9 }], - }, - ]); - }); - - it('rejects an Input Object type with incorrectly typed fields', () => { - const schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - type SomeObject { - field: String - } - - union SomeUnion = SomeObject - - input SomeInputObject { - badObject: SomeObject - badUnion: SomeUnion - goodInputObject: SomeInputObject - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of SomeInputObject.badObject must be Input Type but got: SomeObject.', - locations: [{ line: 13, column: 20 }], - }, - { - message: - 'The type of SomeInputObject.badUnion must be Input Type but got: SomeUnion.', - locations: [{ line: 14, column: 19 }], - }, - ]); - }); - - it('rejects an Input Object type with required argument that is deprecated', () => { - const schema = buildSchema(` - type Query { - field(arg: SomeInputObject): String - } - - input SomeInputObject { - badField: String! @deprecated - optionalField: String @deprecated - anotherOptionalField: String! = "" @deprecated - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Required input field SomeInputObject.badField cannot be deprecated.', - locations: [ - { line: 7, column: 27 }, - { line: 7, column: 19 }, - ], - }, - ]); - }); -}); - -describe('Type System: Enum types must be well defined', () => { - it('rejects an Enum type without values', () => { - let schema = buildSchema(` - type Query { - field: SomeEnum - } - - enum SomeEnum - `); - - schema = extendSchema( - schema, - parse(` - directive @test on ENUM - - extend enum SomeEnum @test - `), - ); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Enum type SomeEnum must define one or more values.', - locations: [ - { line: 6, column: 7 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('rejects an Enum type with incorrectly named values', () => { - const schema = schemaWithFieldType( - new GraphQLEnumType({ - name: 'SomeEnum', - values: { - __badName: {}, - }, - }), - ); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Name "__badName" must not begin with "__", which is reserved by GraphQL introspection.', - }, - ]); - }); -}); - -describe('Type System: Object fields must have output types', () => { - function schemaWithObjectField( - fieldConfig: GraphQLFieldConfig, - ): GraphQLSchema { - const BadObjectType = new GraphQLObjectType({ - name: 'BadObject', - fields: { - badField: fieldConfig, - }, - }); - - return new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - f: { type: BadObjectType }, - }, - }), - types: [SomeObjectType], - }); - } - - for (const type of outputTypes) { - const typeName = inspect(type); - it(`accepts an output type as an Object field type: ${typeName}`, () => { - const schema = schemaWithObjectField({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - } - - it('rejects an empty Object field type', () => { - // @ts-expect-error (type field must not be undefined) - const schema = schemaWithObjectField({ type: undefined }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of BadObject.badField must be Output Type but got: undefined.', - }, - ]); - }); - - for (const type of notOutputTypes) { - const typeStr = inspect(type); - it(`rejects a non-output type as an Object field type: ${typeStr}`, () => { - // @ts-expect-error - const schema = schemaWithObjectField({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: `The type of BadObject.badField must be Output Type but got: ${typeStr}.`, - }, - ]); - }); - } - - it('rejects a non-type value as an Object field type', () => { - // @ts-expect-error - const schema = schemaWithObjectField({ type: Number }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of BadObject.badField must be Output Type but got: [function Number].', - }, - { - message: 'Expected GraphQL named type but got: [function Number].', - }, - ]); - }); - - it('rejects with relevant locations for a non-output type as an Object field type', () => { - const schema = buildSchema(` - type Query { - field: [SomeInputObject] - } - - input SomeInputObject { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of Query.field must be Output Type but got: [SomeInputObject].', - locations: [{ line: 3, column: 16 }], - }, - ]); - }); -}); - -describe('Type System: Objects can only implement unique interfaces', () => { - it('rejects an Object implementing a non-type value', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'BadObject', - // @ts-expect-error (interfaces must not contain undefined) - interfaces: [undefined], - fields: { f: { type: GraphQLString } }, - }), - }); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Type BadObject must only implement Interface types, it cannot implement undefined.', - }, - ]); - }); - - it('rejects an Object implementing a non-Interface type', () => { - const schema = buildSchema(` - type Query { - test: BadObject - } - - input SomeInputObject { - field: String - } - - type BadObject implements SomeInputObject { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Type BadObject must only implement Interface types, it cannot implement SomeInputObject.', - locations: [{ line: 10, column: 33 }], - }, - ]); - }); - - it('rejects an Object implementing the same interface twice', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String - } - - type AnotherObject implements AnotherInterface & AnotherInterface { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'Type AnotherObject can only implement AnotherInterface once.', - locations: [ - { line: 10, column: 37 }, - { line: 10, column: 56 }, - ], - }, - ]); - }); - - it('rejects an Object implementing the same interface twice due to extension', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String - } - - type AnotherObject implements AnotherInterface { - field: String - } - `); - const extendedSchema = extendSchema( - schema, - parse('extend type AnotherObject implements AnotherInterface'), - ); - expectJSON(validateSchema(extendedSchema)).toDeepEqual([ - { - message: 'Type AnotherObject can only implement AnotherInterface once.', - locations: [ - { line: 10, column: 37 }, - { line: 1, column: 38 }, - ], - }, - ]); - }); -}); - -describe('Type System: Interface extensions should be valid', () => { - it('rejects an Object implementing the extended interface due to missing field', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String - } - - type AnotherObject implements AnotherInterface { - field: String - } - `); - const extendedSchema = extendSchema( - schema, - parse(` - extend interface AnotherInterface { - newField: String - } - - extend type AnotherObject { - differentNewField: String - } - `), - ); - expectJSON(validateSchema(extendedSchema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.newField expected but AnotherObject does not provide it.', - locations: [ - { line: 3, column: 11 }, - { line: 10, column: 7 }, - { line: 6, column: 9 }, - ], - }, - ]); - }); - - it('rejects an Object implementing the extended interface due to missing field args', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String - } - - type AnotherObject implements AnotherInterface { - field: String - } - `); - const extendedSchema = extendSchema( - schema, - parse(` - extend interface AnotherInterface { - newField(test: Boolean): String - } - - extend type AnotherObject { - newField: String - } - `), - ); - expectJSON(validateSchema(extendedSchema)).toDeepEqual([ - { - message: - 'Interface field argument AnotherInterface.newField(test:) expected but AnotherObject.newField does not provide it.', - locations: [ - { line: 3, column: 20 }, - { line: 7, column: 11 }, - ], - }, - ]); - }); - - it('rejects Objects implementing the extended interface due to mismatching interface type', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String - } - - type AnotherObject implements AnotherInterface { - field: String - } - `); - const extendedSchema = extendSchema( - schema, - parse(` - extend interface AnotherInterface { - newInterfaceField: NewInterface - } - - interface NewInterface { - newField: String - } - - interface MismatchingInterface { - newField: String - } - - extend type AnotherObject { - newInterfaceField: MismatchingInterface - } - - # Required to prevent unused interface errors - type DummyObject implements NewInterface & MismatchingInterface { - newField: String - } - `), - ); - expectJSON(validateSchema(extendedSchema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.newInterfaceField expects type NewInterface but AnotherObject.newInterfaceField is type MismatchingInterface.', - locations: [ - { line: 3, column: 30 }, - { line: 15, column: 30 }, - ], - }, - ]); - }); -}); - -describe('Type System: Interface fields must have output types', () => { - function schemaWithInterfaceField( - fieldConfig: GraphQLFieldConfig, - ): GraphQLSchema { - const fields = { badField: fieldConfig }; - - const BadInterfaceType = new GraphQLInterfaceType({ - name: 'BadInterface', - fields, - }); - - const BadImplementingType = new GraphQLObjectType({ - name: 'BadImplementing', - interfaces: [BadInterfaceType], - fields, - }); - - return new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - f: { type: BadInterfaceType }, - }, - }), - types: [BadImplementingType, SomeObjectType], - }); - } - - for (const type of outputTypes) { - const typeName = inspect(type); - it(`accepts an output type as an Interface field type: ${typeName}`, () => { - const schema = schemaWithInterfaceField({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - } - - it('rejects an empty Interface field type', () => { - // @ts-expect-error (type field must not be undefined) - const schema = schemaWithInterfaceField({ type: undefined }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of BadImplementing.badField must be Output Type but got: undefined.', - }, - { - message: - 'The type of BadInterface.badField must be Output Type but got: undefined.', - }, - ]); - }); - - for (const type of notOutputTypes) { - const typeStr = inspect(type); - it(`rejects a non-output type as an Interface field type: ${typeStr}`, () => { - // @ts-expect-error - const schema = schemaWithInterfaceField({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: `The type of BadImplementing.badField must be Output Type but got: ${typeStr}.`, - }, - { - message: `The type of BadInterface.badField must be Output Type but got: ${typeStr}.`, - }, - ]); - }); - } - - it('rejects a non-type value as an Interface field type', () => { - // @ts-expect-error - const schema = schemaWithInterfaceField({ type: Number }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of BadImplementing.badField must be Output Type but got: [function Number].', - }, - { - message: - 'The type of BadInterface.badField must be Output Type but got: [function Number].', - }, - { - message: 'Expected GraphQL named type but got: [function Number].', - }, - ]); - }); - - it('rejects a non-output type as an Interface field type with locations', () => { - const schema = buildSchema(` - type Query { - test: SomeInterface - } - - interface SomeInterface { - field: SomeInputObject - } - - input SomeInputObject { - foo: String - } - - type SomeObject implements SomeInterface { - field: SomeInputObject - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of SomeInterface.field must be Output Type but got: SomeInputObject.', - locations: [{ line: 7, column: 16 }], - }, - { - message: - 'The type of SomeObject.field must be Output Type but got: SomeInputObject.', - locations: [{ line: 15, column: 16 }], - }, - ]); - }); - - it('accepts an interface not implemented by at least one object', () => { - const schema = buildSchema(` - type Query { - test: SomeInterface - } - - interface SomeInterface { - foo: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); -}); - -describe('Type System: Arguments must have input types', () => { - function schemaWithArg(argConfig: GraphQLArgumentConfig): GraphQLSchema { - const BadObjectType = new GraphQLObjectType({ - name: 'BadObject', - fields: { - badField: { - type: GraphQLString, - args: { - badArg: argConfig, - }, - }, - }, - }); - - return new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - f: { type: BadObjectType }, - }, - }), - directives: [ - new GraphQLDirective({ - name: 'BadDirective', - args: { - badArg: argConfig, - }, - locations: [DirectiveLocation.QUERY], - }), - ], - }); - } - - for (const type of inputTypes) { - const typeName = inspect(type); - it(`accepts an input type as a field arg type: ${typeName}`, () => { - const schema = schemaWithArg({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - } - - it('rejects an empty field arg type', () => { - // @ts-expect-error (type field must not be undefined) - const schema = schemaWithArg({ type: undefined }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of @BadDirective(badArg:) must be Input Type but got: undefined.', - }, - { - message: - 'The type of BadObject.badField(badArg:) must be Input Type but got: undefined.', - }, - ]); - }); - - for (const type of notInputTypes) { - const typeStr = inspect(type); - it(`rejects a non-input type as a field arg type: ${typeStr}`, () => { - // @ts-expect-error - const schema = schemaWithArg({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: `The type of @BadDirective(badArg:) must be Input Type but got: ${typeStr}.`, - }, - { - message: `The type of BadObject.badField(badArg:) must be Input Type but got: ${typeStr}.`, - }, - ]); - }); - } - - it('rejects a non-type value as a field arg type', () => { - // @ts-expect-error - const schema = schemaWithArg({ type: Number }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of @BadDirective(badArg:) must be Input Type but got: [function Number].', - }, - { - message: - 'The type of BadObject.badField(badArg:) must be Input Type but got: [function Number].', - }, - { - message: 'Expected GraphQL named type but got: [function Number].', - }, - ]); - }); - - it('rejects a required argument that is deprecated', () => { - const schema = buildSchema(` - directive @BadDirective( - badArg: String! @deprecated - optionalArg: String @deprecated - anotherOptionalArg: String! = "" @deprecated - ) on FIELD - - type Query { - test( - badArg: String! @deprecated - optionalArg: String @deprecated - anotherOptionalArg: String! = "" @deprecated - ): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Required argument @BadDirective(badArg:) cannot be deprecated.', - locations: [ - { line: 3, column: 25 }, - { line: 3, column: 17 }, - ], - }, - { - message: 'Required argument Query.test(badArg:) cannot be deprecated.', - locations: [ - { line: 10, column: 27 }, - { line: 10, column: 19 }, - ], - }, - ]); - }); - - it('rejects a non-input type as a field arg with locations', () => { - const schema = buildSchema(` - type Query { - test(arg: SomeObject): String - } - - type SomeObject { - foo: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of Query.test(arg:) must be Input Type but got: SomeObject.', - locations: [{ line: 3, column: 19 }], - }, - ]); - }); -}); - -describe('Type System: Input Object fields must have input types', () => { - function schemaWithInputField( - inputFieldConfig: GraphQLInputFieldConfig, - ): GraphQLSchema { - const BadInputObjectType = new GraphQLInputObjectType({ - name: 'BadInputObject', - fields: { - badField: inputFieldConfig, - }, - }); - - return new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - f: { - type: GraphQLString, - args: { - badArg: { type: BadInputObjectType }, - }, - }, - }, - }), - }); - } - - for (const type of inputTypes) { - const typeName = inspect(type); - it(`accepts an input type as an input field type: ${typeName}`, () => { - const schema = schemaWithInputField({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - } - - it('rejects an empty input field type', () => { - // @ts-expect-error (type field must not be undefined) - const schema = schemaWithInputField({ type: undefined }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of BadInputObject.badField must be Input Type but got: undefined.', - }, - ]); - }); - - for (const type of notInputTypes) { - const typeStr = inspect(type); - it(`rejects a non-input type as an input field type: ${typeStr}`, () => { - // @ts-expect-error - const schema = schemaWithInputField({ type }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: `The type of BadInputObject.badField must be Input Type but got: ${typeStr}.`, - }, - ]); - }); - } - - it('rejects a non-type value as an input field type', () => { - // @ts-expect-error - const schema = schemaWithInputField({ type: Number }); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of BadInputObject.badField must be Input Type but got: [function Number].', - }, - { - message: 'Expected GraphQL named type but got: [function Number].', - }, - ]); - }); - - it('rejects a non-input type as an input object field with locations', () => { - const schema = buildSchema(` - type Query { - test(arg: SomeInputObject): String - } - - input SomeInputObject { - foo: SomeObject - } - - type SomeObject { - bar: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'The type of SomeInputObject.foo must be Input Type but got: SomeObject.', - locations: [{ line: 7, column: 14 }], - }, - ]); - }); -}); - -describe('Type System: OneOf Input Object fields must be nullable', () => { - it('rejects non-nullable fields', () => { - const schema = buildSchema(` - type Query { - test(arg: SomeInputObject): String - } - - input SomeInputObject @oneOf { - a: String - b: String! - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: 'OneOf input field SomeInputObject.b must be nullable.', - locations: [{ line: 8, column: 12 }], - }, - ]); - }); - - it('rejects fields with default values', () => { - const schema = buildSchema(` - type Query { - test(arg: SomeInputObject): String - } - - input SomeInputObject @oneOf { - a: String - b: String = "foo" - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'OneOf input field SomeInputObject.b cannot have a default value.', - locations: [{ line: 8, column: 9 }], - }, - ]); - }); -}); - -describe('Objects must adhere to Interface they implement', () => { - it('accepts an Object which implements an Interface', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - field(input: String): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('accepts an Object which implements an Interface along with more fields', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - field(input: String): String - anotherField: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('accepts an Object which implements an Interface field along with additional optional arguments', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - field(input: String, anotherInput: String): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Object missing an Interface field', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - anotherField: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.field expected but AnotherObject does not provide it.', - locations: [ - { line: 7, column: 9 }, - { line: 10, column: 7 }, - ], - }, - ]); - }); - - it('rejects an Object with an incorrectly typed Interface field', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - field(input: String): Int - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.field expects type String but AnotherObject.field is type Int.', - locations: [ - { line: 7, column: 31 }, - { line: 11, column: 31 }, - ], - }, - ]); - }); - - it('rejects an Object with a differently typed Interface field', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - type A { foo: String } - type B { foo: String } - - interface AnotherInterface { - field: A - } - - type AnotherObject implements AnotherInterface { - field: B - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.field expects type A but AnotherObject.field is type B.', - locations: [ - { line: 10, column: 16 }, - { line: 14, column: 16 }, - ], - }, - ]); - }); - - it('accepts an Object with a subtyped Interface field (interface)', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: AnotherInterface - } - - type AnotherObject implements AnotherInterface { - field: AnotherObject - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('accepts an Object with a subtyped Interface field (union)', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - type SomeObject { - field: String - } - - union SomeUnionType = SomeObject - - interface AnotherInterface { - field: SomeUnionType - } - - type AnotherObject implements AnotherInterface { - field: SomeObject - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Object missing an Interface argument', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field argument AnotherInterface.field(input:) expected but AnotherObject.field does not provide it.', - locations: [ - { line: 7, column: 15 }, - { line: 11, column: 9 }, - ], - }, - ]); - }); - - it('rejects an Object with an incorrectly typed Interface argument', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - field(input: Int): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field argument AnotherInterface.field(input:) expects type String but AnotherObject.field(input:) is type Int.', - locations: [ - { line: 7, column: 22 }, - { line: 11, column: 22 }, - ], - }, - ]); - }); - - it('rejects an Object with both an incorrectly typed field and argument', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(input: String): String - } - - type AnotherObject implements AnotherInterface { - field(input: Int): Int - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.field expects type String but AnotherObject.field is type Int.', - locations: [ - { line: 7, column: 31 }, - { line: 11, column: 28 }, - ], - }, - { - message: - 'Interface field argument AnotherInterface.field(input:) expects type String but AnotherObject.field(input:) is type Int.', - locations: [ - { line: 7, column: 22 }, - { line: 11, column: 22 }, - ], - }, - ]); - }); - - it('rejects an Object which implements an Interface field along with additional required arguments', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field(baseArg: String): String - } - - type AnotherObject implements AnotherInterface { - field( - baseArg: String, - requiredArg: String! - optionalArg1: String, - optionalArg2: String = "", - ): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Object field AnotherObject.field includes required argument requiredArg that is missing from the Interface field AnotherInterface.field.', - locations: [ - { line: 13, column: 11 }, - { line: 7, column: 9 }, - ], - }, - ]); - }); - - it('accepts an Object with an equivalently wrapped Interface field type', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: [String]! - } - - type AnotherObject implements AnotherInterface { - field: [String]! - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Object with a non-list Interface field list type', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: [String] - } - - type AnotherObject implements AnotherInterface { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.field expects type [String] but AnotherObject.field is type String.', - locations: [ - { line: 7, column: 16 }, - { line: 11, column: 16 }, - ], - }, - ]); - }); - - it('rejects an Object with a list Interface field non-list type', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String - } - - type AnotherObject implements AnotherInterface { - field: [String] - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.field expects type String but AnotherObject.field is type [String].', - locations: [ - { line: 7, column: 16 }, - { line: 11, column: 16 }, - ], - }, - ]); - }); - - it('accepts an Object with a subset non-null Interface field type', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String - } - - type AnotherObject implements AnotherInterface { - field: String! - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Object with a superset nullable Interface field type', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface AnotherInterface { - field: String! - } - - type AnotherObject implements AnotherInterface { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field AnotherInterface.field expects type String! but AnotherObject.field is type String.', - locations: [ - { line: 7, column: 16 }, - { line: 11, column: 16 }, - ], - }, - ]); - }); - - it('rejects an Object missing a transitive interface', () => { - const schema = buildSchema(` - type Query { - test: AnotherObject - } - - interface SuperInterface { - field: String! - } - - interface AnotherInterface implements SuperInterface { - field: String! - } - - type AnotherObject implements AnotherInterface { - field: String! - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Type AnotherObject must implement SuperInterface because it is implemented by AnotherInterface.', - locations: [ - { line: 10, column: 45 }, - { line: 14, column: 37 }, - ], - }, - ]); - }); -}); - -describe('Interfaces must adhere to Interface they implement', () => { - it('accepts an Interface which implements an Interface', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - field(input: String): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('accepts an Interface which implements an Interface along with more fields', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - field(input: String): String - anotherField: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('accepts an Interface which implements an Interface field along with additional optional arguments', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - field(input: String, anotherInput: String): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Interface missing an Interface field', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - anotherField: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field ParentInterface.field expected but ChildInterface does not provide it.', - locations: [ - { line: 7, column: 9 }, - { line: 10, column: 7 }, - ], - }, - ]); - }); - - it('rejects an Interface with an incorrectly typed Interface field', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - field(input: String): Int - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field ParentInterface.field expects type String but ChildInterface.field is type Int.', - locations: [ - { line: 7, column: 31 }, - { line: 11, column: 31 }, - ], - }, - ]); - }); - - it('rejects an Interface with a differently typed Interface field', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - type A { foo: String } - type B { foo: String } - - interface ParentInterface { - field: A - } - - interface ChildInterface implements ParentInterface { - field: B - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field ParentInterface.field expects type A but ChildInterface.field is type B.', - locations: [ - { line: 10, column: 16 }, - { line: 14, column: 16 }, - ], - }, - ]); - }); - - it('accepts an Interface with a subtyped Interface field (interface)', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field: ParentInterface - } - - interface ChildInterface implements ParentInterface { - field: ChildInterface - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('accepts an Interface with a subtyped Interface field (union)', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - type SomeObject { - field: String - } - - union SomeUnionType = SomeObject - - interface ParentInterface { - field: SomeUnionType - } - - interface ChildInterface implements ParentInterface { - field: SomeObject - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Interface implementing a non-Interface type', () => { - const schema = buildSchema(` - type Query { - field: String - } - - input SomeInputObject { - field: String - } - - interface BadInterface implements SomeInputObject { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Type BadInterface must only implement Interface types, it cannot implement SomeInputObject.', - locations: [{ line: 10, column: 41 }], - }, - ]); - }); - - it('rejects an Interface missing an Interface argument', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field argument ParentInterface.field(input:) expected but ChildInterface.field does not provide it.', - locations: [ - { line: 7, column: 15 }, - { line: 11, column: 9 }, - ], - }, - ]); - }); - - it('rejects an Interface with an incorrectly typed Interface argument', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - field(input: Int): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field argument ParentInterface.field(input:) expects type String but ChildInterface.field(input:) is type Int.', - locations: [ - { line: 7, column: 22 }, - { line: 11, column: 22 }, - ], - }, - ]); - }); - - it('rejects an Interface with both an incorrectly typed field and argument', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(input: String): String - } - - interface ChildInterface implements ParentInterface { - field(input: Int): Int - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field ParentInterface.field expects type String but ChildInterface.field is type Int.', - locations: [ - { line: 7, column: 31 }, - { line: 11, column: 28 }, - ], - }, - { - message: - 'Interface field argument ParentInterface.field(input:) expects type String but ChildInterface.field(input:) is type Int.', - locations: [ - { line: 7, column: 22 }, - { line: 11, column: 22 }, - ], - }, - ]); - }); - - it('rejects an Interface which implements an Interface field along with additional required arguments', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field(baseArg: String): String - } - - interface ChildInterface implements ParentInterface { - field( - baseArg: String, - requiredArg: String! - optionalArg1: String, - optionalArg2: String = "", - ): String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Object field ChildInterface.field includes required argument requiredArg that is missing from the Interface field ParentInterface.field.', - locations: [ - { line: 13, column: 11 }, - { line: 7, column: 9 }, - ], - }, - ]); - }); - - it('accepts an Interface with an equivalently wrapped Interface field type', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field: [String]! - } - - interface ChildInterface implements ParentInterface { - field: [String]! - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Interface with a non-list Interface field list type', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field: [String] - } - - interface ChildInterface implements ParentInterface { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field ParentInterface.field expects type [String] but ChildInterface.field is type String.', - locations: [ - { line: 7, column: 16 }, - { line: 11, column: 16 }, - ], - }, - ]); - }); - - it('rejects an Interface with a list Interface field non-list type', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field: String - } - - interface ChildInterface implements ParentInterface { - field: [String] - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field ParentInterface.field expects type String but ChildInterface.field is type [String].', - locations: [ - { line: 7, column: 16 }, - { line: 11, column: 16 }, - ], - }, - ]); - }); - - it('accepts an Interface with a subset non-null Interface field type', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field: String - } - - interface ChildInterface implements ParentInterface { - field: String! - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([]); - }); - - it('rejects an Interface with a superset nullable Interface field type', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface ParentInterface { - field: String! - } - - interface ChildInterface implements ParentInterface { - field: String - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Interface field ParentInterface.field expects type String! but ChildInterface.field is type String.', - locations: [ - { line: 7, column: 16 }, - { line: 11, column: 16 }, - ], - }, - ]); - }); - - it('rejects an Object missing a transitive interface', () => { - const schema = buildSchema(` - type Query { - test: ChildInterface - } - - interface SuperInterface { - field: String! - } - - interface ParentInterface implements SuperInterface { - field: String! - } - - interface ChildInterface implements ParentInterface { - field: String! - } - `); - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Type ChildInterface must implement SuperInterface because it is implemented by ParentInterface.', - locations: [ - { line: 10, column: 44 }, - { line: 14, column: 43 }, - ], - }, - ]); - }); - - it('rejects a self reference interface', () => { - const schema = buildSchema(` - type Query { - test: FooInterface - } - - interface FooInterface implements FooInterface { - field: String - } - `); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Type FooInterface cannot implement itself because it would create a circular reference.', - locations: [{ line: 6, column: 41 }], - }, - ]); - }); - - it('rejects a circular Interface implementation', () => { - const schema = buildSchema(` - type Query { - test: FooInterface - } - - interface FooInterface implements BarInterface { - field: String - } - - interface BarInterface implements FooInterface { - field: String - } - `); - - expectJSON(validateSchema(schema)).toDeepEqual([ - { - message: - 'Type FooInterface cannot implement BarInterface because it would create a circular reference.', - locations: [ - { line: 10, column: 41 }, - { line: 6, column: 41 }, - ], - }, - { - message: - 'Type BarInterface cannot implement FooInterface because it would create a circular reference.', - locations: [ - { line: 6, column: 41 }, - { line: 10, column: 41 }, - ], - }, - ]); - }); -}); - -describe('assertValidSchema', () => { - it('does not throw on valid schemas', () => { - const schema = buildSchema(` - type Query { - foo: String - } - `); - expect(() => assertValidSchema(schema)).to.not.throw(); - }); - - it('combines multiple errors', () => { - const schema = buildSchema('type SomeType'); - expect(() => assertValidSchema(schema)).to.throw(dedent` - Query root type must be provided. - - Type SomeType must define one or more fields.`); - }); -}); diff --git a/src/type/assertName.ts b/src/type/assertName.ts deleted file mode 100644 index f4f96fda4e..0000000000 --- a/src/type/assertName.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; - -import { GraphQLError } from '../error/GraphQLError'; - -import { isNameContinue, isNameStart } from '../language/characterClasses'; - -/** - * Upholds the spec rules about naming. - */ -export function assertName(name: string): string { - devAssert(name != null, 'Must provide name.'); - devAssert(typeof name === 'string', 'Expected name to be a string.'); - - if (name.length === 0) { - throw new GraphQLError('Expected name to be a non-empty string.'); - } - - for (let i = 1; i < name.length; ++i) { - if (!isNameContinue(name.charCodeAt(i))) { - throw new GraphQLError( - `Names must only contain [_a-zA-Z0-9] but "${name}" does not.`, - ); - } - } - - if (!isNameStart(name.charCodeAt(0))) { - throw new GraphQLError( - `Names must start with [_a-zA-Z] but "${name}" does not.`, - ); - } - - return name; -} - -/** - * Upholds the spec rules about naming enum values. - * - * @internal - */ -export function assertEnumValueName(name: string): string { - if (name === 'true' || name === 'false' || name === 'null') { - throw new GraphQLError(`Enum values cannot be named: ${name}`); - } - return assertName(name); -} diff --git a/src/type/definition.ts b/src/type/definition.ts deleted file mode 100644 index 7eaac560dc..0000000000 --- a/src/type/definition.ts +++ /dev/null @@ -1,1767 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { didYouMean } from '../jsutils/didYouMean'; -import { identityFunc } from '../jsutils/identityFunc'; -import { inspect } from '../jsutils/inspect'; -import { instanceOf } from '../jsutils/instanceOf'; -import { isObjectLike } from '../jsutils/isObjectLike'; -import { keyMap } from '../jsutils/keyMap'; -import { keyValMap } from '../jsutils/keyValMap'; -import { mapValue } from '../jsutils/mapValue'; -import type { Maybe } from '../jsutils/Maybe'; -import type { ObjMap } from '../jsutils/ObjMap'; -import type { Path } from '../jsutils/Path'; -import type { PromiseOrValue } from '../jsutils/PromiseOrValue'; -import { suggestionList } from '../jsutils/suggestionList'; -import { toObjMap } from '../jsutils/toObjMap'; - -import { GraphQLError } from '../error/GraphQLError'; - -import type { - EnumTypeDefinitionNode, - EnumTypeExtensionNode, - EnumValueDefinitionNode, - FieldDefinitionNode, - FieldNode, - FragmentDefinitionNode, - InputObjectTypeDefinitionNode, - InputObjectTypeExtensionNode, - InputValueDefinitionNode, - InterfaceTypeDefinitionNode, - InterfaceTypeExtensionNode, - ObjectTypeDefinitionNode, - ObjectTypeExtensionNode, - OperationDefinitionNode, - ScalarTypeDefinitionNode, - ScalarTypeExtensionNode, - UnionTypeDefinitionNode, - UnionTypeExtensionNode, - ValueNode, -} from '../language/ast'; -import { Kind } from '../language/kinds'; -import { print } from '../language/printer'; - -import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped'; - -import { assertEnumValueName, assertName } from './assertName'; -import type { GraphQLSchema } from './schema'; - -// Predicates & Assertions - -/** - * These are all of the possible kinds of types. - */ -export type GraphQLType = - | GraphQLScalarType - | GraphQLObjectType - | GraphQLInterfaceType - | GraphQLUnionType - | GraphQLEnumType - | GraphQLInputObjectType - | GraphQLList - | GraphQLNonNull< - | GraphQLScalarType - | GraphQLObjectType - | GraphQLInterfaceType - | GraphQLUnionType - | GraphQLEnumType - | GraphQLInputObjectType - | GraphQLList - >; - -export function isType(type: unknown): type is GraphQLType { - return ( - isScalarType(type) || - isObjectType(type) || - isInterfaceType(type) || - isUnionType(type) || - isEnumType(type) || - isInputObjectType(type) || - isListType(type) || - isNonNullType(type) - ); -} - -export function assertType(type: unknown): GraphQLType { - if (!isType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL type.`); - } - return type; -} - -/** - * There are predicates for each kind of GraphQL type. - */ -export function isScalarType(type: unknown): type is GraphQLScalarType { - return instanceOf(type, GraphQLScalarType); -} - -export function assertScalarType(type: unknown): GraphQLScalarType { - if (!isScalarType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL Scalar type.`); - } - return type; -} - -export function isObjectType(type: unknown): type is GraphQLObjectType { - return instanceOf(type, GraphQLObjectType); -} - -export function assertObjectType(type: unknown): GraphQLObjectType { - if (!isObjectType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL Object type.`); - } - return type; -} - -export function isInterfaceType(type: unknown): type is GraphQLInterfaceType { - return instanceOf(type, GraphQLInterfaceType); -} - -export function assertInterfaceType(type: unknown): GraphQLInterfaceType { - if (!isInterfaceType(type)) { - throw new Error( - `Expected ${inspect(type)} to be a GraphQL Interface type.`, - ); - } - return type; -} - -export function isUnionType(type: unknown): type is GraphQLUnionType { - return instanceOf(type, GraphQLUnionType); -} - -export function assertUnionType(type: unknown): GraphQLUnionType { - if (!isUnionType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL Union type.`); - } - return type; -} - -export function isEnumType(type: unknown): type is GraphQLEnumType { - return instanceOf(type, GraphQLEnumType); -} - -export function assertEnumType(type: unknown): GraphQLEnumType { - if (!isEnumType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL Enum type.`); - } - return type; -} - -export function isInputObjectType( - type: unknown, -): type is GraphQLInputObjectType { - return instanceOf(type, GraphQLInputObjectType); -} - -export function assertInputObjectType(type: unknown): GraphQLInputObjectType { - if (!isInputObjectType(type)) { - throw new Error( - `Expected ${inspect(type)} to be a GraphQL Input Object type.`, - ); - } - return type; -} - -export function isListType( - type: GraphQLInputType, -): type is GraphQLList; -export function isListType( - type: GraphQLOutputType, -): type is GraphQLList; -export function isListType(type: unknown): type is GraphQLList; -export function isListType(type: unknown): type is GraphQLList { - return instanceOf(type, GraphQLList); -} - -export function assertListType(type: unknown): GraphQLList { - if (!isListType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL List type.`); - } - return type; -} - -export function isNonNullType( - type: GraphQLInputType, -): type is GraphQLNonNull; -export function isNonNullType( - type: GraphQLOutputType, -): type is GraphQLNonNull; -export function isNonNullType( - type: unknown, -): type is GraphQLNonNull; -export function isNonNullType( - type: unknown, -): type is GraphQLNonNull { - return instanceOf(type, GraphQLNonNull); -} - -export function assertNonNullType(type: unknown): GraphQLNonNull { - if (!isNonNullType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL Non-Null type.`); - } - return type; -} - -/** - * These types may be used as input types for arguments and directives. - */ -export type GraphQLInputType = - | GraphQLScalarType - | GraphQLEnumType - | GraphQLInputObjectType - | GraphQLList - | GraphQLNonNull< - | GraphQLScalarType - | GraphQLEnumType - | GraphQLInputObjectType - | GraphQLList - >; - -export function isInputType(type: unknown): type is GraphQLInputType { - return ( - isScalarType(type) || - isEnumType(type) || - isInputObjectType(type) || - (isWrappingType(type) && isInputType(type.ofType)) - ); -} - -export function assertInputType(type: unknown): GraphQLInputType { - if (!isInputType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL input type.`); - } - return type; -} - -/** - * These types may be used as output types as the result of fields. - */ -export type GraphQLOutputType = - | GraphQLScalarType - | GraphQLObjectType - | GraphQLInterfaceType - | GraphQLUnionType - | GraphQLEnumType - | GraphQLList - | GraphQLNonNull< - | GraphQLScalarType - | GraphQLObjectType - | GraphQLInterfaceType - | GraphQLUnionType - | GraphQLEnumType - | GraphQLList - >; - -export function isOutputType(type: unknown): type is GraphQLOutputType { - return ( - isScalarType(type) || - isObjectType(type) || - isInterfaceType(type) || - isUnionType(type) || - isEnumType(type) || - (isWrappingType(type) && isOutputType(type.ofType)) - ); -} - -export function assertOutputType(type: unknown): GraphQLOutputType { - if (!isOutputType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL output type.`); - } - return type; -} - -/** - * These types may describe types which may be leaf values. - */ -export type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType; - -export function isLeafType(type: unknown): type is GraphQLLeafType { - return isScalarType(type) || isEnumType(type); -} - -export function assertLeafType(type: unknown): GraphQLLeafType { - if (!isLeafType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL leaf type.`); - } - return type; -} - -/** - * These types may describe the parent context of a selection set. - */ -export type GraphQLCompositeType = - | GraphQLObjectType - | GraphQLInterfaceType - | GraphQLUnionType; - -export function isCompositeType(type: unknown): type is GraphQLCompositeType { - return isObjectType(type) || isInterfaceType(type) || isUnionType(type); -} - -export function assertCompositeType(type: unknown): GraphQLCompositeType { - if (!isCompositeType(type)) { - throw new Error( - `Expected ${inspect(type)} to be a GraphQL composite type.`, - ); - } - return type; -} - -/** - * These types may describe the parent context of a selection set. - */ -export type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType; - -export function isAbstractType(type: unknown): type is GraphQLAbstractType { - return isInterfaceType(type) || isUnionType(type); -} - -export function assertAbstractType(type: unknown): GraphQLAbstractType { - if (!isAbstractType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL abstract type.`); - } - return type; -} - -/** - * List Type Wrapper - * - * A list is a wrapping type which points to another type. - * Lists are often created within the context of defining the fields of - * an object type. - * - * Example: - * - * ```ts - * const PersonType = new GraphQLObjectType({ - * name: 'Person', - * fields: () => ({ - * parents: { type: new GraphQLList(PersonType) }, - * children: { type: new GraphQLList(PersonType) }, - * }) - * }) - * ``` - */ -export class GraphQLList { - readonly ofType: T; - - constructor(ofType: T) { - devAssert( - isType(ofType), - `Expected ${inspect(ofType)} to be a GraphQL type.`, - ); - - this.ofType = ofType; - } - - get [Symbol.toStringTag]() { - return 'GraphQLList'; - } - - toString(): string { - return '[' + String(this.ofType) + ']'; - } - - toJSON(): string { - return this.toString(); - } -} - -/** - * Non-Null Type Wrapper - * - * A non-null is a wrapping type which points to another type. - * Non-null types enforce that their values are never null and can ensure - * an error is raised if this ever occurs during a request. It is useful for - * fields which you can make a strong guarantee on non-nullability, for example - * usually the id field of a database row will never be null. - * - * Example: - * - * ```ts - * const RowType = new GraphQLObjectType({ - * name: 'Row', - * fields: () => ({ - * id: { type: new GraphQLNonNull(GraphQLString) }, - * }) - * }) - * ``` - * Note: the enforcement of non-nullability occurs within the executor. - */ -export class GraphQLNonNull { - readonly ofType: T; - - constructor(ofType: T) { - devAssert( - isNullableType(ofType), - `Expected ${inspect(ofType)} to be a GraphQL nullable type.`, - ); - - this.ofType = ofType; - } - - get [Symbol.toStringTag]() { - return 'GraphQLNonNull'; - } - - toString(): string { - return String(this.ofType) + '!'; - } - - toJSON(): string { - return this.toString(); - } -} - -/** - * These types wrap and modify other types - */ - -export type GraphQLWrappingType = - | GraphQLList - | GraphQLNonNull; - -export function isWrappingType(type: unknown): type is GraphQLWrappingType { - return isListType(type) || isNonNullType(type); -} - -export function assertWrappingType(type: unknown): GraphQLWrappingType { - if (!isWrappingType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL wrapping type.`); - } - return type; -} - -/** - * These types can all accept null as a value. - */ -export type GraphQLNullableType = - | GraphQLScalarType - | GraphQLObjectType - | GraphQLInterfaceType - | GraphQLUnionType - | GraphQLEnumType - | GraphQLInputObjectType - | GraphQLList; - -export function isNullableType(type: unknown): type is GraphQLNullableType { - return isType(type) && !isNonNullType(type); -} - -export function assertNullableType(type: unknown): GraphQLNullableType { - if (!isNullableType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL nullable type.`); - } - return type; -} - -export function getNullableType(type: undefined | null): void; -export function getNullableType( - type: T | GraphQLNonNull, -): T; -export function getNullableType( - type: Maybe, -): GraphQLNullableType | undefined; -export function getNullableType( - type: Maybe, -): GraphQLNullableType | undefined { - if (type) { - return isNonNullType(type) ? type.ofType : type; - } -} - -/** - * These named types do not include modifiers like List or NonNull. - */ -export type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType; - -export type GraphQLNamedInputType = - | GraphQLScalarType - | GraphQLEnumType - | GraphQLInputObjectType; - -export type GraphQLNamedOutputType = - | GraphQLScalarType - | GraphQLObjectType - | GraphQLInterfaceType - | GraphQLUnionType - | GraphQLEnumType; - -export function isNamedType(type: unknown): type is GraphQLNamedType { - return ( - isScalarType(type) || - isObjectType(type) || - isInterfaceType(type) || - isUnionType(type) || - isEnumType(type) || - isInputObjectType(type) - ); -} - -export function assertNamedType(type: unknown): GraphQLNamedType { - if (!isNamedType(type)) { - throw new Error(`Expected ${inspect(type)} to be a GraphQL named type.`); - } - return type; -} - -export function getNamedType(type: undefined | null): void; -export function getNamedType(type: GraphQLInputType): GraphQLNamedInputType; -export function getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType; -export function getNamedType(type: GraphQLType): GraphQLNamedType; -export function getNamedType( - type: Maybe, -): GraphQLNamedType | undefined; -export function getNamedType( - type: Maybe, -): GraphQLNamedType | undefined { - if (type) { - let unwrappedType = type; - while (isWrappingType(unwrappedType)) { - unwrappedType = unwrappedType.ofType; - } - return unwrappedType; - } -} - -/** - * Used while defining GraphQL types to allow for circular references in - * otherwise immutable type definitions. - */ -export type ThunkReadonlyArray = (() => ReadonlyArray) | ReadonlyArray; -export type ThunkObjMap = (() => ObjMap) | ObjMap; - -export function resolveReadonlyArrayThunk( - thunk: ThunkReadonlyArray, -): ReadonlyArray { - return typeof thunk === 'function' ? thunk() : thunk; -} - -export function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap { - return typeof thunk === 'function' ? thunk() : thunk; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLScalarTypeExtensions { - [attributeName: string]: unknown; -} - -/** - * Scalar Type Definition - * - * The leaf values of any request and input values to arguments are - * Scalars (or Enums) and are defined with a name and a series of functions - * used to parse input from ast or variables and to ensure validity. - * - * If a type's serialize function returns `null` or does not return a value - * (i.e. it returns `undefined`) then an error will be raised and a `null` - * value will be returned in the response. It is always better to validate - * - * Example: - * - * ```ts - * const OddType = new GraphQLScalarType({ - * name: 'Odd', - * serialize(value) { - * if (!Number.isFinite(value)) { - * throw new Error( - * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`, - * ); - * } - * - * if (value % 2 === 0) { - * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`); - * } - * return value; - * } - * }); - * ``` - */ -export class GraphQLScalarType { - name: string; - description: Maybe; - specifiedByURL: Maybe; - serialize: GraphQLScalarSerializer; - parseValue: GraphQLScalarValueParser; - parseLiteral: GraphQLScalarLiteralParser; - extensions: Readonly; - astNode: Maybe; - extensionASTNodes: ReadonlyArray; - - constructor(config: Readonly>) { - const parseValue = - config.parseValue ?? - (identityFunc as GraphQLScalarValueParser); - - this.name = assertName(config.name); - this.description = config.description; - this.specifiedByURL = config.specifiedByURL; - this.serialize = - config.serialize ?? (identityFunc as GraphQLScalarSerializer); - this.parseValue = parseValue; - this.parseLiteral = - config.parseLiteral ?? - ((node, variables) => parseValue(valueFromASTUntyped(node, variables))); - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - this.extensionASTNodes = config.extensionASTNodes ?? []; - - devAssert( - config.specifiedByURL == null || - typeof config.specifiedByURL === 'string', - `${this.name} must provide "specifiedByURL" as a string, ` + - `but got: ${inspect(config.specifiedByURL)}.`, - ); - - devAssert( - config.serialize == null || typeof config.serialize === 'function', - `${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`, - ); - - if (config.parseLiteral) { - devAssert( - typeof config.parseValue === 'function' && - typeof config.parseLiteral === 'function', - `${this.name} must provide both "parseValue" and "parseLiteral" functions.`, - ); - } - } - - get [Symbol.toStringTag]() { - return 'GraphQLScalarType'; - } - - toConfig(): GraphQLScalarTypeNormalizedConfig { - return { - name: this.name, - description: this.description, - specifiedByURL: this.specifiedByURL, - serialize: this.serialize, - parseValue: this.parseValue, - parseLiteral: this.parseLiteral, - extensions: this.extensions, - astNode: this.astNode, - extensionASTNodes: this.extensionASTNodes, - }; - } - - toString(): string { - return this.name; - } - - toJSON(): string { - return this.toString(); - } -} - -export type GraphQLScalarSerializer = ( - outputValue: unknown, -) => TExternal; - -export type GraphQLScalarValueParser = ( - inputValue: unknown, -) => TInternal; - -export type GraphQLScalarLiteralParser = ( - valueNode: ValueNode, - variables?: Maybe>, -) => TInternal; - -export interface GraphQLScalarTypeConfig { - name: string; - description?: Maybe; - specifiedByURL?: Maybe; - /** Serializes an internal value to include in a response. */ - serialize?: GraphQLScalarSerializer; - /** Parses an externally provided value to use as an input. */ - parseValue?: GraphQLScalarValueParser; - /** Parses an externally provided literal value to use as an input. */ - parseLiteral?: GraphQLScalarLiteralParser; - extensions?: Maybe>; - astNode?: Maybe; - extensionASTNodes?: Maybe>; -} - -interface GraphQLScalarTypeNormalizedConfig - extends GraphQLScalarTypeConfig { - serialize: GraphQLScalarSerializer; - parseValue: GraphQLScalarValueParser; - parseLiteral: GraphQLScalarLiteralParser; - extensions: Readonly; - extensionASTNodes: ReadonlyArray; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - * - * We've provided these template arguments because this is an open type and - * you may find them useful. - */ -export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> { - [attributeName: string]: unknown; -} - -/** - * Object Type Definition - * - * Almost all of the GraphQL types you define will be object types. Object types - * have a name, but most importantly describe their fields. - * - * Example: - * - * ```ts - * const AddressType = new GraphQLObjectType({ - * name: 'Address', - * fields: { - * street: { type: GraphQLString }, - * number: { type: GraphQLInt }, - * formatted: { - * type: GraphQLString, - * resolve(obj) { - * return obj.number + ' ' + obj.street - * } - * } - * } - * }); - * ``` - * - * When two types need to refer to each other, or a type needs to refer to - * itself in a field, you can use a function expression (aka a closure or a - * thunk) to supply the fields lazily. - * - * Example: - * - * ```ts - * const PersonType = new GraphQLObjectType({ - * name: 'Person', - * fields: () => ({ - * name: { type: GraphQLString }, - * bestFriend: { type: PersonType }, - * }) - * }); - * ``` - */ -export class GraphQLObjectType { - name: string; - description: Maybe; - isTypeOf: Maybe>; - extensions: Readonly>; - astNode: Maybe; - extensionASTNodes: ReadonlyArray; - - private _fields: ThunkObjMap>; - private _interfaces: ThunkReadonlyArray; - - constructor(config: Readonly>) { - this.name = assertName(config.name); - this.description = config.description; - this.isTypeOf = config.isTypeOf; - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - this.extensionASTNodes = config.extensionASTNodes ?? []; - - this._fields = () => defineFieldMap(config); - this._interfaces = () => defineInterfaces(config); - devAssert( - config.isTypeOf == null || typeof config.isTypeOf === 'function', - `${this.name} must provide "isTypeOf" as a function, ` + - `but got: ${inspect(config.isTypeOf)}.`, - ); - } - - get [Symbol.toStringTag]() { - return 'GraphQLObjectType'; - } - - getFields(): GraphQLFieldMap { - if (typeof this._fields === 'function') { - this._fields = this._fields(); - } - return this._fields; - } - - getInterfaces(): ReadonlyArray { - if (typeof this._interfaces === 'function') { - this._interfaces = this._interfaces(); - } - return this._interfaces; - } - - toConfig(): GraphQLObjectTypeNormalizedConfig { - return { - name: this.name, - description: this.description, - interfaces: this.getInterfaces(), - fields: fieldsToFieldsConfig(this.getFields()), - isTypeOf: this.isTypeOf, - extensions: this.extensions, - astNode: this.astNode, - extensionASTNodes: this.extensionASTNodes, - }; - } - - toString(): string { - return this.name; - } - - toJSON(): string { - return this.toString(); - } -} - -function defineInterfaces( - config: Readonly< - GraphQLObjectTypeConfig | GraphQLInterfaceTypeConfig - >, -): ReadonlyArray { - const interfaces = resolveReadonlyArrayThunk(config.interfaces ?? []); - devAssert( - Array.isArray(interfaces), - `${config.name} interfaces must be an Array or a function which returns an Array.`, - ); - return interfaces; -} - -function defineFieldMap( - config: Readonly< - | GraphQLObjectTypeConfig - | GraphQLInterfaceTypeConfig - >, -): GraphQLFieldMap { - const fieldMap = resolveObjMapThunk(config.fields); - devAssert( - isPlainObj(fieldMap), - `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, - ); - - return mapValue(fieldMap, (fieldConfig, fieldName) => { - devAssert( - isPlainObj(fieldConfig), - `${config.name}.${fieldName} field config must be an object.`, - ); - devAssert( - fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function', - `${config.name}.${fieldName} field resolver must be a function if ` + - `provided, but got: ${inspect(fieldConfig.resolve)}.`, - ); - - const argsConfig = fieldConfig.args ?? {}; - devAssert( - isPlainObj(argsConfig), - `${config.name}.${fieldName} args must be an object with argument names as keys.`, - ); - - return { - name: assertName(fieldName), - description: fieldConfig.description, - type: fieldConfig.type, - args: defineArguments(argsConfig), - resolve: fieldConfig.resolve, - subscribe: fieldConfig.subscribe, - deprecationReason: fieldConfig.deprecationReason, - extensions: toObjMap(fieldConfig.extensions), - astNode: fieldConfig.astNode, - }; - }); -} - -export function defineArguments( - config: GraphQLFieldConfigArgumentMap, -): ReadonlyArray { - return Object.entries(config).map(([argName, argConfig]) => ({ - name: assertName(argName), - description: argConfig.description, - type: argConfig.type, - defaultValue: argConfig.defaultValue, - deprecationReason: argConfig.deprecationReason, - extensions: toObjMap(argConfig.extensions), - astNode: argConfig.astNode, - })); -} - -function isPlainObj(obj: unknown): boolean { - return isObjectLike(obj) && !Array.isArray(obj); -} - -function fieldsToFieldsConfig( - fields: GraphQLFieldMap, -): GraphQLFieldConfigMap { - return mapValue(fields, (field) => ({ - description: field.description, - type: field.type, - args: argsToArgsConfig(field.args), - resolve: field.resolve, - subscribe: field.subscribe, - deprecationReason: field.deprecationReason, - extensions: field.extensions, - astNode: field.astNode, - })); -} - -/** - * @internal - */ -export function argsToArgsConfig( - args: ReadonlyArray, -): GraphQLFieldConfigArgumentMap { - return keyValMap( - args, - (arg) => arg.name, - (arg) => ({ - description: arg.description, - type: arg.type, - defaultValue: arg.defaultValue, - deprecationReason: arg.deprecationReason, - extensions: arg.extensions, - astNode: arg.astNode, - }), - ); -} - -export interface GraphQLObjectTypeConfig { - name: string; - description?: Maybe; - interfaces?: ThunkReadonlyArray; - fields: ThunkObjMap>; - isTypeOf?: Maybe>; - extensions?: Maybe>>; - astNode?: Maybe; - extensionASTNodes?: Maybe>; -} - -interface GraphQLObjectTypeNormalizedConfig - extends GraphQLObjectTypeConfig { - interfaces: ReadonlyArray; - fields: GraphQLFieldConfigMap; - extensions: Readonly>; - extensionASTNodes: ReadonlyArray; -} - -export type GraphQLTypeResolver = ( - value: TSource, - context: TContext, - info: GraphQLResolveInfo, - abstractType: GraphQLAbstractType, -) => PromiseOrValue; - -export type GraphQLIsTypeOfFn = ( - source: TSource, - context: TContext, - info: GraphQLResolveInfo, -) => PromiseOrValue; - -export type GraphQLFieldResolver< - TSource, - TContext, - TArgs = any, - TResult = unknown, -> = ( - source: TSource, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, -) => TResult; - -export interface GraphQLResolveInfo { - readonly fieldName: string; - readonly fieldNodes: ReadonlyArray; - readonly returnType: GraphQLOutputType; - readonly parentType: GraphQLObjectType; - readonly path: Path; - readonly schema: GraphQLSchema; - readonly fragments: ObjMap; - readonly rootValue: unknown; - readonly operation: OperationDefinitionNode; - readonly variableValues: { [variable: string]: unknown }; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - * - * We've provided these template arguments because this is an open type and - * you may find them useful. - */ -export interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> { - [attributeName: string]: unknown; -} - -export interface GraphQLFieldConfig { - description?: Maybe; - type: GraphQLOutputType; - args?: GraphQLFieldConfigArgumentMap; - resolve?: GraphQLFieldResolver; - subscribe?: GraphQLFieldResolver; - deprecationReason?: Maybe; - extensions?: Maybe< - Readonly> - >; - astNode?: Maybe; -} - -export type GraphQLFieldConfigArgumentMap = ObjMap; - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLArgumentExtensions { - [attributeName: string]: unknown; -} - -export interface GraphQLArgumentConfig { - description?: Maybe; - type: GraphQLInputType; - defaultValue?: unknown; - deprecationReason?: Maybe; - extensions?: Maybe>; - astNode?: Maybe; -} - -export type GraphQLFieldConfigMap = ObjMap< - GraphQLFieldConfig ->; - -export interface GraphQLField { - name: string; - description: Maybe; - type: GraphQLOutputType; - args: ReadonlyArray; - resolve?: GraphQLFieldResolver; - subscribe?: GraphQLFieldResolver; - deprecationReason: Maybe; - extensions: Readonly>; - astNode: Maybe; -} - -export interface GraphQLArgument { - name: string; - description: Maybe; - type: GraphQLInputType; - defaultValue: unknown; - deprecationReason: Maybe; - extensions: Readonly; - astNode: Maybe; -} - -export function isRequiredArgument(arg: GraphQLArgument): boolean { - return isNonNullType(arg.type) && arg.defaultValue === undefined; -} - -export type GraphQLFieldMap = ObjMap< - GraphQLField ->; - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLInterfaceTypeExtensions { - [attributeName: string]: unknown; -} - -/** - * Interface Type Definition - * - * When a field can return one of a heterogeneous set of types, a Interface type - * is used to describe what types are possible, what fields are in common across - * all types, as well as a function to determine which type is actually used - * when the field is resolved. - * - * Example: - * - * ```ts - * const EntityType = new GraphQLInterfaceType({ - * name: 'Entity', - * fields: { - * name: { type: GraphQLString } - * } - * }); - * ``` - */ -export class GraphQLInterfaceType { - name: string; - description: Maybe; - resolveType: Maybe>; - extensions: Readonly; - astNode: Maybe; - extensionASTNodes: ReadonlyArray; - - private _fields: ThunkObjMap>; - private _interfaces: ThunkReadonlyArray; - - constructor(config: Readonly>) { - this.name = assertName(config.name); - this.description = config.description; - this.resolveType = config.resolveType; - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - this.extensionASTNodes = config.extensionASTNodes ?? []; - - this._fields = defineFieldMap.bind(undefined, config); - this._interfaces = defineInterfaces.bind(undefined, config); - devAssert( - config.resolveType == null || typeof config.resolveType === 'function', - `${this.name} must provide "resolveType" as a function, ` + - `but got: ${inspect(config.resolveType)}.`, - ); - } - - get [Symbol.toStringTag]() { - return 'GraphQLInterfaceType'; - } - - getFields(): GraphQLFieldMap { - if (typeof this._fields === 'function') { - this._fields = this._fields(); - } - return this._fields; - } - - getInterfaces(): ReadonlyArray { - if (typeof this._interfaces === 'function') { - this._interfaces = this._interfaces(); - } - return this._interfaces; - } - - toConfig(): GraphQLInterfaceTypeNormalizedConfig { - return { - name: this.name, - description: this.description, - interfaces: this.getInterfaces(), - fields: fieldsToFieldsConfig(this.getFields()), - resolveType: this.resolveType, - extensions: this.extensions, - astNode: this.astNode, - extensionASTNodes: this.extensionASTNodes, - }; - } - - toString(): string { - return this.name; - } - - toJSON(): string { - return this.toString(); - } -} - -export interface GraphQLInterfaceTypeConfig { - name: string; - description?: Maybe; - interfaces?: ThunkReadonlyArray; - fields: ThunkObjMap>; - /** - * Optionally provide a custom type resolver function. If one is not provided, - * the default implementation will call `isTypeOf` on each implementing - * Object type. - */ - resolveType?: Maybe>; - extensions?: Maybe>; - astNode?: Maybe; - extensionASTNodes?: Maybe>; -} - -export interface GraphQLInterfaceTypeNormalizedConfig - extends GraphQLInterfaceTypeConfig { - interfaces: ReadonlyArray; - fields: GraphQLFieldConfigMap; - extensions: Readonly; - extensionASTNodes: ReadonlyArray; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLUnionTypeExtensions { - [attributeName: string]: unknown; -} - -/** - * Union Type Definition - * - * When a field can return one of a heterogeneous set of types, a Union type - * is used to describe what types are possible as well as providing a function - * to determine which type is actually used when the field is resolved. - * - * Example: - * - * ```ts - * const PetType = new GraphQLUnionType({ - * name: 'Pet', - * types: [ DogType, CatType ], - * resolveType(value) { - * if (value instanceof Dog) { - * return DogType; - * } - * if (value instanceof Cat) { - * return CatType; - * } - * } - * }); - * ``` - */ -export class GraphQLUnionType { - name: string; - description: Maybe; - resolveType: Maybe>; - extensions: Readonly; - astNode: Maybe; - extensionASTNodes: ReadonlyArray; - - private _types: ThunkReadonlyArray; - - constructor(config: Readonly>) { - this.name = assertName(config.name); - this.description = config.description; - this.resolveType = config.resolveType; - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - this.extensionASTNodes = config.extensionASTNodes ?? []; - - this._types = defineTypes.bind(undefined, config); - devAssert( - config.resolveType == null || typeof config.resolveType === 'function', - `${this.name} must provide "resolveType" as a function, ` + - `but got: ${inspect(config.resolveType)}.`, - ); - } - - get [Symbol.toStringTag]() { - return 'GraphQLUnionType'; - } - - getTypes(): ReadonlyArray { - if (typeof this._types === 'function') { - this._types = this._types(); - } - return this._types; - } - - toConfig(): GraphQLUnionTypeNormalizedConfig { - return { - name: this.name, - description: this.description, - types: this.getTypes(), - resolveType: this.resolveType, - extensions: this.extensions, - astNode: this.astNode, - extensionASTNodes: this.extensionASTNodes, - }; - } - - toString(): string { - return this.name; - } - - toJSON(): string { - return this.toString(); - } -} - -function defineTypes( - config: Readonly>, -): ReadonlyArray { - const types = resolveReadonlyArrayThunk(config.types); - devAssert( - Array.isArray(types), - `Must provide Array of types or a function which returns such an array for Union ${config.name}.`, - ); - return types; -} - -export interface GraphQLUnionTypeConfig { - name: string; - description?: Maybe; - types: ThunkReadonlyArray; - /** - * Optionally provide a custom type resolver function. If one is not provided, - * the default implementation will call `isTypeOf` on each implementing - * Object type. - */ - resolveType?: Maybe>; - extensions?: Maybe>; - astNode?: Maybe; - extensionASTNodes?: Maybe>; -} - -interface GraphQLUnionTypeNormalizedConfig - extends GraphQLUnionTypeConfig { - types: ReadonlyArray; - extensions: Readonly; - extensionASTNodes: ReadonlyArray; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLEnumTypeExtensions { - [attributeName: string]: unknown; -} - -/** - * Enum Type Definition - * - * Some leaf values of requests and input values are Enums. GraphQL serializes - * Enum values as strings, however internally Enums can be represented by any - * kind of type, often integers. - * - * Example: - * - * ```ts - * const RGBType = new GraphQLEnumType({ - * name: 'RGB', - * values: { - * RED: { value: 0 }, - * GREEN: { value: 1 }, - * BLUE: { value: 2 } - * } - * }); - * ``` - * - * Note: If a value is not provided in a definition, the name of the enum value - * will be used as its internal value. - */ -export class GraphQLEnumType /* */ { - name: string; - description: Maybe; - extensions: Readonly; - astNode: Maybe; - extensionASTNodes: ReadonlyArray; - - private _values: - | ReadonlyArray */> - | (() => GraphQLEnumValueConfigMap); - - private _valueLookup: ReadonlyMap | null; - private _nameLookup: ObjMap | null; - - constructor(config: Readonly */>) { - this.name = assertName(config.name); - this.description = config.description; - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - this.extensionASTNodes = config.extensionASTNodes ?? []; - - this._values = - typeof config.values === 'function' - ? config.values - : defineEnumValues(this.name, config.values); - this._valueLookup = null; - this._nameLookup = null; - } - - get [Symbol.toStringTag]() { - return 'GraphQLEnumType'; - } - - getValues(): ReadonlyArray */> { - if (typeof this._values === 'function') { - this._values = defineEnumValues(this.name, this._values()); - } - return this._values; - } - - getValue(name: string): Maybe { - if (this._nameLookup === null) { - this._nameLookup = keyMap(this.getValues(), (value) => value.name); - } - return this._nameLookup[name]; - } - - serialize(outputValue: unknown /* T */): Maybe { - if (this._valueLookup === null) { - this._valueLookup = new Map( - this.getValues().map((enumValue) => [enumValue.value, enumValue]), - ); - } - const enumValue = this._valueLookup.get(outputValue); - if (enumValue === undefined) { - throw new GraphQLError( - `Enum "${this.name}" cannot represent value: ${inspect(outputValue)}`, - ); - } - return enumValue.name; - } - - parseValue(inputValue: unknown): Maybe /* T */ { - if (typeof inputValue !== 'string') { - const valueStr = inspect(inputValue); - throw new GraphQLError( - `Enum "${this.name}" cannot represent non-string value: ${valueStr}.` + - didYouMeanEnumValue(this, valueStr), - ); - } - - const enumValue = this.getValue(inputValue); - if (enumValue == null) { - throw new GraphQLError( - `Value "${inputValue}" does not exist in "${this.name}" enum.` + - didYouMeanEnumValue(this, inputValue), - ); - } - return enumValue.value; - } - - parseLiteral( - valueNode: ValueNode, - _variables: Maybe>, - ): Maybe /* T */ { - // Note: variables will be resolved to a value before calling this function. - if (valueNode.kind !== Kind.ENUM) { - const valueStr = print(valueNode); - throw new GraphQLError( - `Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` + - didYouMeanEnumValue(this, valueStr), - { nodes: valueNode }, - ); - } - - const enumValue = this.getValue(valueNode.value); - if (enumValue == null) { - const valueStr = print(valueNode); - throw new GraphQLError( - `Value "${valueStr}" does not exist in "${this.name}" enum.` + - didYouMeanEnumValue(this, valueStr), - { nodes: valueNode }, - ); - } - return enumValue.value; - } - - toConfig(): GraphQLEnumTypeNormalizedConfig { - const values = keyValMap( - this.getValues(), - (value) => value.name, - (value) => ({ - description: value.description, - value: value.value, - deprecationReason: value.deprecationReason, - extensions: value.extensions, - astNode: value.astNode, - }), - ); - - return { - name: this.name, - description: this.description, - values, - extensions: this.extensions, - astNode: this.astNode, - extensionASTNodes: this.extensionASTNodes, - }; - } - - toString(): string { - return this.name; - } - - toJSON(): string { - return this.toString(); - } -} - -function didYouMeanEnumValue( - enumType: GraphQLEnumType, - unknownValueStr: string, -): string { - const allNames = enumType.getValues().map((value) => value.name); - const suggestedValues = suggestionList(unknownValueStr, allNames); - - return didYouMean('the enum value', suggestedValues); -} - -function defineEnumValues( - typeName: string, - valueMap: GraphQLEnumValueConfigMap /* */, -): ReadonlyArray */> { - devAssert( - isPlainObj(valueMap), - `${typeName} values must be an object with value names as keys.`, - ); - return Object.entries(valueMap).map(([valueName, valueConfig]) => { - devAssert( - isPlainObj(valueConfig), - `${typeName}.${valueName} must refer to an object with a "value" key ` + - `representing an internal value but got: ${inspect(valueConfig)}.`, - ); - return { - name: assertEnumValueName(valueName), - description: valueConfig.description, - value: valueConfig.value !== undefined ? valueConfig.value : valueName, - deprecationReason: valueConfig.deprecationReason, - extensions: toObjMap(valueConfig.extensions), - astNode: valueConfig.astNode, - }; - }); -} - -export interface GraphQLEnumTypeConfig { - name: string; - description?: Maybe; - values: ThunkObjMap */>; - extensions?: Maybe>; - astNode?: Maybe; - extensionASTNodes?: Maybe>; -} - -interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig { - values: ObjMap */>; - extensions: Readonly; - extensionASTNodes: ReadonlyArray; -} - -export type GraphQLEnumValueConfigMap /* */ = - ObjMap */>; - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLEnumValueExtensions { - [attributeName: string]: unknown; -} - -export interface GraphQLEnumValueConfig { - description?: Maybe; - value?: any /* T */; - deprecationReason?: Maybe; - extensions?: Maybe>; - astNode?: Maybe; -} - -export interface GraphQLEnumValue { - name: string; - description: Maybe; - value: any /* T */; - deprecationReason: Maybe; - extensions: Readonly; - astNode: Maybe; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLInputObjectTypeExtensions { - [attributeName: string]: unknown; -} - -/** - * Input Object Type Definition - * - * An input object defines a structured collection of fields which may be - * supplied to a field argument. - * - * Using `NonNull` will ensure that a value must be provided by the query - * - * Example: - * - * ```ts - * const GeoPoint = new GraphQLInputObjectType({ - * name: 'GeoPoint', - * fields: { - * lat: { type: new GraphQLNonNull(GraphQLFloat) }, - * lon: { type: new GraphQLNonNull(GraphQLFloat) }, - * alt: { type: GraphQLFloat, defaultValue: 0 }, - * } - * }); - * ``` - */ -export class GraphQLInputObjectType { - name: string; - description: Maybe; - extensions: Readonly; - astNode: Maybe; - extensionASTNodes: ReadonlyArray; - isOneOf: boolean; - - private _fields: ThunkObjMap; - - constructor(config: Readonly) { - this.name = assertName(config.name); - this.description = config.description; - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - this.extensionASTNodes = config.extensionASTNodes ?? []; - this.isOneOf = config.isOneOf ?? false; - - this._fields = defineInputFieldMap.bind(undefined, config); - } - - get [Symbol.toStringTag]() { - return 'GraphQLInputObjectType'; - } - - getFields(): GraphQLInputFieldMap { - if (typeof this._fields === 'function') { - this._fields = this._fields(); - } - return this._fields; - } - - toConfig(): GraphQLInputObjectTypeNormalizedConfig { - const fields = mapValue(this.getFields(), (field) => ({ - description: field.description, - type: field.type, - defaultValue: field.defaultValue, - deprecationReason: field.deprecationReason, - extensions: field.extensions, - astNode: field.astNode, - })); - - return { - name: this.name, - description: this.description, - fields, - extensions: this.extensions, - astNode: this.astNode, - extensionASTNodes: this.extensionASTNodes, - isOneOf: this.isOneOf, - }; - } - - toString(): string { - return this.name; - } - - toJSON(): string { - return this.toString(); - } -} - -function defineInputFieldMap( - config: Readonly, -): GraphQLInputFieldMap { - const fieldMap = resolveObjMapThunk(config.fields); - devAssert( - isPlainObj(fieldMap), - `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, - ); - return mapValue(fieldMap, (fieldConfig, fieldName) => { - devAssert( - !('resolve' in fieldConfig), - `${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`, - ); - - return { - name: assertName(fieldName), - description: fieldConfig.description, - type: fieldConfig.type, - defaultValue: fieldConfig.defaultValue, - deprecationReason: fieldConfig.deprecationReason, - extensions: toObjMap(fieldConfig.extensions), - astNode: fieldConfig.astNode, - }; - }); -} - -export interface GraphQLInputObjectTypeConfig { - name: string; - description?: Maybe; - fields: ThunkObjMap; - extensions?: Maybe>; - astNode?: Maybe; - extensionASTNodes?: Maybe>; - isOneOf?: boolean; -} - -interface GraphQLInputObjectTypeNormalizedConfig - extends GraphQLInputObjectTypeConfig { - fields: GraphQLInputFieldConfigMap; - extensions: Readonly; - extensionASTNodes: ReadonlyArray; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLInputFieldExtensions { - [attributeName: string]: unknown; -} - -export interface GraphQLInputFieldConfig { - description?: Maybe; - type: GraphQLInputType; - defaultValue?: unknown; - deprecationReason?: Maybe; - extensions?: Maybe>; - astNode?: Maybe; -} - -export type GraphQLInputFieldConfigMap = ObjMap; - -export interface GraphQLInputField { - name: string; - description: Maybe; - type: GraphQLInputType; - defaultValue: unknown; - deprecationReason: Maybe; - extensions: Readonly; - astNode: Maybe; -} - -export function isRequiredInputField(field: GraphQLInputField): boolean { - return isNonNullType(field.type) && field.defaultValue === undefined; -} - -export type GraphQLInputFieldMap = ObjMap; diff --git a/src/type/directives.ts b/src/type/directives.ts deleted file mode 100644 index 6881f20532..0000000000 --- a/src/type/directives.ts +++ /dev/null @@ -1,237 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; -import { instanceOf } from '../jsutils/instanceOf'; -import { isObjectLike } from '../jsutils/isObjectLike'; -import type { Maybe } from '../jsutils/Maybe'; -import { toObjMap } from '../jsutils/toObjMap'; - -import type { DirectiveDefinitionNode } from '../language/ast'; -import { DirectiveLocation } from '../language/directiveLocation'; - -import { assertName } from './assertName'; -import type { - GraphQLArgument, - GraphQLFieldConfigArgumentMap, -} from './definition'; -import { - argsToArgsConfig, - defineArguments, - GraphQLNonNull, -} from './definition'; -import { GraphQLBoolean, GraphQLString } from './scalars'; - -/** - * Test if the given value is a GraphQL directive. - */ -export function isDirective(directive: unknown): directive is GraphQLDirective { - return instanceOf(directive, GraphQLDirective); -} - -export function assertDirective(directive: unknown): GraphQLDirective { - if (!isDirective(directive)) { - throw new Error( - `Expected ${inspect(directive)} to be a GraphQL directive.`, - ); - } - return directive; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLDirectiveExtensions { - [attributeName: string]: unknown; -} - -/** - * Directives are used by the GraphQL runtime as a way of modifying execution - * behavior. Type system creators will usually not create these directly. - */ -export class GraphQLDirective { - name: string; - description: Maybe; - locations: ReadonlyArray; - args: ReadonlyArray; - isRepeatable: boolean; - extensions: Readonly; - astNode: Maybe; - - constructor(config: Readonly) { - this.name = assertName(config.name); - this.description = config.description; - this.locations = config.locations; - this.isRepeatable = config.isRepeatable ?? false; - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - - devAssert( - Array.isArray(config.locations), - `@${config.name} locations must be an Array.`, - ); - - const args = config.args ?? {}; - devAssert( - isObjectLike(args) && !Array.isArray(args), - `@${config.name} args must be an object with argument names as keys.`, - ); - - this.args = defineArguments(args); - } - - get [Symbol.toStringTag]() { - return 'GraphQLDirective'; - } - - toConfig(): GraphQLDirectiveNormalizedConfig { - return { - name: this.name, - description: this.description, - locations: this.locations, - args: argsToArgsConfig(this.args), - isRepeatable: this.isRepeatable, - extensions: this.extensions, - astNode: this.astNode, - }; - } - - toString(): string { - return '@' + this.name; - } - - toJSON(): string { - return this.toString(); - } -} - -export interface GraphQLDirectiveConfig { - name: string; - description?: Maybe; - locations: ReadonlyArray; - args?: Maybe; - isRepeatable?: Maybe; - extensions?: Maybe>; - astNode?: Maybe; -} - -interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig { - args: GraphQLFieldConfigArgumentMap; - isRepeatable: boolean; - extensions: Readonly; -} - -/** - * Used to conditionally include fields or fragments. - */ -export const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({ - name: 'include', - description: - 'Directs the executor to include this field or fragment only when the `if` argument is true.', - locations: [ - DirectiveLocation.FIELD, - DirectiveLocation.FRAGMENT_SPREAD, - DirectiveLocation.INLINE_FRAGMENT, - ], - args: { - if: { - type: new GraphQLNonNull(GraphQLBoolean), - description: 'Included when true.', - }, - }, -}); - -/** - * Used to conditionally skip (exclude) fields or fragments. - */ -export const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({ - name: 'skip', - description: - 'Directs the executor to skip this field or fragment when the `if` argument is true.', - locations: [ - DirectiveLocation.FIELD, - DirectiveLocation.FRAGMENT_SPREAD, - DirectiveLocation.INLINE_FRAGMENT, - ], - args: { - if: { - type: new GraphQLNonNull(GraphQLBoolean), - description: 'Skipped when true.', - }, - }, -}); - -/** - * Constant string used for default reason for a deprecation. - */ -export const DEFAULT_DEPRECATION_REASON = 'No longer supported'; - -/** - * Used to declare element of a GraphQL schema as deprecated. - */ -export const GraphQLDeprecatedDirective: GraphQLDirective = - new GraphQLDirective({ - name: 'deprecated', - description: 'Marks an element of a GraphQL schema as no longer supported.', - locations: [ - DirectiveLocation.FIELD_DEFINITION, - DirectiveLocation.ARGUMENT_DEFINITION, - DirectiveLocation.INPUT_FIELD_DEFINITION, - DirectiveLocation.ENUM_VALUE, - ], - args: { - reason: { - type: GraphQLString, - description: - 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).', - defaultValue: DEFAULT_DEPRECATION_REASON, - }, - }, - }); - -/** - * Used to provide a URL for specifying the behavior of custom scalar definitions. - */ -export const GraphQLSpecifiedByDirective: GraphQLDirective = - new GraphQLDirective({ - name: 'specifiedBy', - description: 'Exposes a URL that specifies the behavior of this scalar.', - locations: [DirectiveLocation.SCALAR], - args: { - url: { - type: new GraphQLNonNull(GraphQLString), - description: 'The URL that specifies the behavior of this scalar.', - }, - }, - }); - -/** - * Used to indicate an Input Object is a OneOf Input Object. - */ -export const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({ - name: 'oneOf', - description: - 'Indicates exactly one field must be supplied and this field must not be `null`.', - locations: [DirectiveLocation.INPUT_OBJECT], - args: {}, -}); - -/** - * The full list of specified directives. - */ -export const specifiedDirectives: ReadonlyArray = - Object.freeze([ - GraphQLIncludeDirective, - GraphQLSkipDirective, - GraphQLDeprecatedDirective, - GraphQLSpecifiedByDirective, - GraphQLOneOfDirective, - ]); - -export function isSpecifiedDirective(directive: GraphQLDirective): boolean { - return specifiedDirectives.some(({ name }) => name === directive.name); -} diff --git a/src/type/index.ts b/src/type/index.ts deleted file mode 100644 index cf276d1e02..0000000000 --- a/src/type/index.ts +++ /dev/null @@ -1,187 +0,0 @@ -export type { Path as ResponsePath } from '../jsutils/Path'; - -export { - // Predicate - isSchema, - // Assertion - assertSchema, - // GraphQL Schema definition - GraphQLSchema, -} from './schema'; -export type { GraphQLSchemaConfig, GraphQLSchemaExtensions } from './schema'; - -export { - resolveObjMapThunk, - resolveReadonlyArrayThunk, - // Predicates - isType, - isScalarType, - isObjectType, - isInterfaceType, - isUnionType, - isEnumType, - isInputObjectType, - isListType, - isNonNullType, - isInputType, - isOutputType, - isLeafType, - isCompositeType, - isAbstractType, - isWrappingType, - isNullableType, - isNamedType, - isRequiredArgument, - isRequiredInputField, - // Assertions - assertType, - assertScalarType, - assertObjectType, - assertInterfaceType, - assertUnionType, - assertEnumType, - assertInputObjectType, - assertListType, - assertNonNullType, - assertInputType, - assertOutputType, - assertLeafType, - assertCompositeType, - assertAbstractType, - assertWrappingType, - assertNullableType, - assertNamedType, - // Un-modifiers - getNullableType, - getNamedType, - // Definitions - GraphQLScalarType, - GraphQLObjectType, - GraphQLInterfaceType, - GraphQLUnionType, - GraphQLEnumType, - GraphQLInputObjectType, - // Type Wrappers - GraphQLList, - GraphQLNonNull, -} from './definition'; - -export type { - GraphQLType, - GraphQLInputType, - GraphQLOutputType, - GraphQLLeafType, - GraphQLCompositeType, - GraphQLAbstractType, - GraphQLWrappingType, - GraphQLNullableType, - GraphQLNamedType, - GraphQLNamedInputType, - GraphQLNamedOutputType, - ThunkReadonlyArray, - ThunkObjMap, - GraphQLArgument, - GraphQLArgumentConfig, - GraphQLArgumentExtensions, - GraphQLEnumTypeConfig, - GraphQLEnumTypeExtensions, - GraphQLEnumValue, - GraphQLEnumValueConfig, - GraphQLEnumValueConfigMap, - GraphQLEnumValueExtensions, - GraphQLField, - GraphQLFieldConfig, - GraphQLFieldConfigArgumentMap, - GraphQLFieldConfigMap, - GraphQLFieldExtensions, - GraphQLFieldMap, - GraphQLFieldResolver, - GraphQLInputField, - GraphQLInputFieldConfig, - GraphQLInputFieldConfigMap, - GraphQLInputFieldExtensions, - GraphQLInputFieldMap, - GraphQLInputObjectTypeConfig, - GraphQLInputObjectTypeExtensions, - GraphQLInterfaceTypeConfig, - GraphQLInterfaceTypeExtensions, - GraphQLIsTypeOfFn, - GraphQLObjectTypeConfig, - GraphQLObjectTypeExtensions, - GraphQLResolveInfo, - GraphQLScalarTypeConfig, - GraphQLScalarTypeExtensions, - GraphQLTypeResolver, - GraphQLUnionTypeConfig, - GraphQLUnionTypeExtensions, - GraphQLScalarSerializer, - GraphQLScalarValueParser, - GraphQLScalarLiteralParser, -} from './definition'; - -export { - // Predicate - isDirective, - // Assertion - assertDirective, - // Directives Definition - GraphQLDirective, - // Built-in Directives defined by the Spec - isSpecifiedDirective, - specifiedDirectives, - GraphQLIncludeDirective, - GraphQLSkipDirective, - GraphQLDeprecatedDirective, - GraphQLSpecifiedByDirective, - GraphQLOneOfDirective, - // Constant Deprecation Reason - DEFAULT_DEPRECATION_REASON, -} from './directives'; - -export type { - GraphQLDirectiveConfig, - GraphQLDirectiveExtensions, -} from './directives'; - -// Common built-in scalar instances. -export { - // Predicate - isSpecifiedScalarType, - // Standard GraphQL Scalars - specifiedScalarTypes, - GraphQLInt, - GraphQLFloat, - GraphQLString, - GraphQLBoolean, - GraphQLID, - // Int boundaries constants - GRAPHQL_MAX_INT, - GRAPHQL_MIN_INT, -} from './scalars'; - -export { - // Predicate - isIntrospectionType, - // GraphQL Types for introspection. - introspectionTypes, - __Schema, - __Directive, - __DirectiveLocation, - __Type, - __Field, - __InputValue, - __EnumValue, - __TypeKind, - // "Enum" of Type Kinds - TypeKind, - // Meta-field definitions. - SchemaMetaFieldDef, - TypeMetaFieldDef, - TypeNameMetaFieldDef, -} from './introspection'; - -// Validate GraphQL schema. -export { validateSchema, assertValidSchema } from './validate'; - -// Upholds the spec rules about naming. -export { assertName, assertEnumValueName } from './assertName'; diff --git a/src/type/introspection.ts b/src/type/introspection.ts deleted file mode 100644 index 2c66ca5098..0000000000 --- a/src/type/introspection.ts +++ /dev/null @@ -1,565 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; - -import { DirectiveLocation } from '../language/directiveLocation'; -import { print } from '../language/printer'; - -import { astFromValue } from '../utilities/astFromValue'; - -import type { - GraphQLEnumValue, - GraphQLField, - GraphQLFieldConfigMap, - GraphQLInputField, - GraphQLNamedType, - GraphQLType, -} from './definition'; -import { - GraphQLEnumType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - isAbstractType, - isEnumType, - isInputObjectType, - isInterfaceType, - isListType, - isNonNullType, - isObjectType, - isScalarType, - isUnionType, -} from './definition'; -import type { GraphQLDirective } from './directives'; -import { GraphQLBoolean, GraphQLString } from './scalars'; -import type { GraphQLSchema } from './schema'; - -export const __Schema: GraphQLObjectType = new GraphQLObjectType({ - name: '__Schema', - description: - 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', - fields: () => - ({ - description: { - type: GraphQLString, - resolve: (schema) => schema.description, - }, - types: { - description: 'A list of all types supported by this server.', - type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Type))), - resolve(schema) { - return Object.values(schema.getTypeMap()); - }, - }, - queryType: { - description: 'The type that query operations will be rooted at.', - type: new GraphQLNonNull(__Type), - resolve: (schema) => schema.getQueryType(), - }, - mutationType: { - description: - 'If this server supports mutation, the type that mutation operations will be rooted at.', - type: __Type, - resolve: (schema) => schema.getMutationType(), - }, - subscriptionType: { - description: - 'If this server support subscription, the type that subscription operations will be rooted at.', - type: __Type, - resolve: (schema) => schema.getSubscriptionType(), - }, - directives: { - description: 'A list of all directives supported by this server.', - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(__Directive)), - ), - resolve: (schema) => schema.getDirectives(), - }, - } as GraphQLFieldConfigMap), -}); - -export const __Directive: GraphQLObjectType = new GraphQLObjectType({ - name: '__Directive', - description: - "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", - fields: () => - ({ - name: { - type: new GraphQLNonNull(GraphQLString), - resolve: (directive) => directive.name, - }, - description: { - type: GraphQLString, - resolve: (directive) => directive.description, - }, - isRepeatable: { - type: new GraphQLNonNull(GraphQLBoolean), - resolve: (directive) => directive.isRepeatable, - }, - locations: { - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(__DirectiveLocation)), - ), - resolve: (directive) => directive.locations, - }, - args: { - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(__InputValue)), - ), - args: { - includeDeprecated: { - type: GraphQLBoolean, - defaultValue: false, - }, - }, - resolve(field, { includeDeprecated }) { - return includeDeprecated - ? field.args - : field.args.filter((arg) => arg.deprecationReason == null); - }, - }, - } as GraphQLFieldConfigMap), -}); - -export const __DirectiveLocation: GraphQLEnumType = new GraphQLEnumType({ - name: '__DirectiveLocation', - description: - 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.', - values: { - QUERY: { - value: DirectiveLocation.QUERY, - description: 'Location adjacent to a query operation.', - }, - MUTATION: { - value: DirectiveLocation.MUTATION, - description: 'Location adjacent to a mutation operation.', - }, - SUBSCRIPTION: { - value: DirectiveLocation.SUBSCRIPTION, - description: 'Location adjacent to a subscription operation.', - }, - FIELD: { - value: DirectiveLocation.FIELD, - description: 'Location adjacent to a field.', - }, - FRAGMENT_DEFINITION: { - value: DirectiveLocation.FRAGMENT_DEFINITION, - description: 'Location adjacent to a fragment definition.', - }, - FRAGMENT_SPREAD: { - value: DirectiveLocation.FRAGMENT_SPREAD, - description: 'Location adjacent to a fragment spread.', - }, - INLINE_FRAGMENT: { - value: DirectiveLocation.INLINE_FRAGMENT, - description: 'Location adjacent to an inline fragment.', - }, - VARIABLE_DEFINITION: { - value: DirectiveLocation.VARIABLE_DEFINITION, - description: 'Location adjacent to a variable definition.', - }, - SCHEMA: { - value: DirectiveLocation.SCHEMA, - description: 'Location adjacent to a schema definition.', - }, - SCALAR: { - value: DirectiveLocation.SCALAR, - description: 'Location adjacent to a scalar definition.', - }, - OBJECT: { - value: DirectiveLocation.OBJECT, - description: 'Location adjacent to an object type definition.', - }, - FIELD_DEFINITION: { - value: DirectiveLocation.FIELD_DEFINITION, - description: 'Location adjacent to a field definition.', - }, - ARGUMENT_DEFINITION: { - value: DirectiveLocation.ARGUMENT_DEFINITION, - description: 'Location adjacent to an argument definition.', - }, - INTERFACE: { - value: DirectiveLocation.INTERFACE, - description: 'Location adjacent to an interface definition.', - }, - UNION: { - value: DirectiveLocation.UNION, - description: 'Location adjacent to a union definition.', - }, - ENUM: { - value: DirectiveLocation.ENUM, - description: 'Location adjacent to an enum definition.', - }, - ENUM_VALUE: { - value: DirectiveLocation.ENUM_VALUE, - description: 'Location adjacent to an enum value definition.', - }, - INPUT_OBJECT: { - value: DirectiveLocation.INPUT_OBJECT, - description: 'Location adjacent to an input object type definition.', - }, - INPUT_FIELD_DEFINITION: { - value: DirectiveLocation.INPUT_FIELD_DEFINITION, - description: 'Location adjacent to an input object field definition.', - }, - }, -}); - -export const __Type: GraphQLObjectType = new GraphQLObjectType({ - name: '__Type', - description: - 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', - fields: () => - ({ - kind: { - type: new GraphQLNonNull(__TypeKind), - resolve(type) { - if (isScalarType(type)) { - return TypeKind.SCALAR; - } - if (isObjectType(type)) { - return TypeKind.OBJECT; - } - if (isInterfaceType(type)) { - return TypeKind.INTERFACE; - } - if (isUnionType(type)) { - return TypeKind.UNION; - } - if (isEnumType(type)) { - return TypeKind.ENUM; - } - if (isInputObjectType(type)) { - return TypeKind.INPUT_OBJECT; - } - if (isListType(type)) { - return TypeKind.LIST; - } - if (isNonNullType(type)) { - return TypeKind.NON_NULL; - } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered) - invariant(false, `Unexpected type: "${inspect(type)}".`); - }, - }, - name: { - type: GraphQLString, - resolve: (type) => ('name' in type ? type.name : undefined), - }, - description: { - type: GraphQLString, - resolve: (type) => - // FIXME: add test case - /* c8 ignore next */ - 'description' in type ? type.description : undefined, - }, - specifiedByURL: { - type: GraphQLString, - resolve: (obj) => - 'specifiedByURL' in obj ? obj.specifiedByURL : undefined, - }, - fields: { - type: new GraphQLList(new GraphQLNonNull(__Field)), - args: { - includeDeprecated: { type: GraphQLBoolean, defaultValue: false }, - }, - resolve(type, { includeDeprecated }) { - if (isObjectType(type) || isInterfaceType(type)) { - const fields = Object.values(type.getFields()); - return includeDeprecated - ? fields - : fields.filter((field) => field.deprecationReason == null); - } - }, - }, - interfaces: { - type: new GraphQLList(new GraphQLNonNull(__Type)), - resolve(type) { - if (isObjectType(type) || isInterfaceType(type)) { - return type.getInterfaces(); - } - }, - }, - possibleTypes: { - type: new GraphQLList(new GraphQLNonNull(__Type)), - resolve(type, _args, _context, { schema }) { - if (isAbstractType(type)) { - return schema.getPossibleTypes(type); - } - }, - }, - enumValues: { - type: new GraphQLList(new GraphQLNonNull(__EnumValue)), - args: { - includeDeprecated: { type: GraphQLBoolean, defaultValue: false }, - }, - resolve(type, { includeDeprecated }) { - if (isEnumType(type)) { - const values = type.getValues(); - return includeDeprecated - ? values - : values.filter((field) => field.deprecationReason == null); - } - }, - }, - inputFields: { - type: new GraphQLList(new GraphQLNonNull(__InputValue)), - args: { - includeDeprecated: { - type: GraphQLBoolean, - defaultValue: false, - }, - }, - resolve(type, { includeDeprecated }) { - if (isInputObjectType(type)) { - const values = Object.values(type.getFields()); - return includeDeprecated - ? values - : values.filter((field) => field.deprecationReason == null); - } - }, - }, - ofType: { - type: __Type, - resolve: (type) => ('ofType' in type ? type.ofType : undefined), - }, - isOneOf: { - type: GraphQLBoolean, - resolve: (type) => { - if (isInputObjectType(type)) { - return type.isOneOf; - } - }, - }, - } as GraphQLFieldConfigMap), -}); - -export const __Field: GraphQLObjectType = new GraphQLObjectType({ - name: '__Field', - description: - 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.', - fields: () => - ({ - name: { - type: new GraphQLNonNull(GraphQLString), - resolve: (field) => field.name, - }, - description: { - type: GraphQLString, - resolve: (field) => field.description, - }, - args: { - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(__InputValue)), - ), - args: { - includeDeprecated: { - type: GraphQLBoolean, - defaultValue: false, - }, - }, - resolve(field, { includeDeprecated }) { - return includeDeprecated - ? field.args - : field.args.filter((arg) => arg.deprecationReason == null); - }, - }, - type: { - type: new GraphQLNonNull(__Type), - resolve: (field) => field.type, - }, - isDeprecated: { - type: new GraphQLNonNull(GraphQLBoolean), - resolve: (field) => field.deprecationReason != null, - }, - deprecationReason: { - type: GraphQLString, - resolve: (field) => field.deprecationReason, - }, - } as GraphQLFieldConfigMap, unknown>), -}); - -export const __InputValue: GraphQLObjectType = new GraphQLObjectType({ - name: '__InputValue', - description: - 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.', - fields: () => - ({ - name: { - type: new GraphQLNonNull(GraphQLString), - resolve: (inputValue) => inputValue.name, - }, - description: { - type: GraphQLString, - resolve: (inputValue) => inputValue.description, - }, - type: { - type: new GraphQLNonNull(__Type), - resolve: (inputValue) => inputValue.type, - }, - defaultValue: { - type: GraphQLString, - description: - 'A GraphQL-formatted string representing the default value for this input value.', - resolve(inputValue) { - const { type, defaultValue } = inputValue; - const valueAST = astFromValue(defaultValue, type); - return valueAST ? print(valueAST) : null; - }, - }, - isDeprecated: { - type: new GraphQLNonNull(GraphQLBoolean), - resolve: (field) => field.deprecationReason != null, - }, - deprecationReason: { - type: GraphQLString, - resolve: (obj) => obj.deprecationReason, - }, - } as GraphQLFieldConfigMap), -}); - -export const __EnumValue: GraphQLObjectType = new GraphQLObjectType({ - name: '__EnumValue', - description: - 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.', - fields: () => - ({ - name: { - type: new GraphQLNonNull(GraphQLString), - resolve: (enumValue) => enumValue.name, - }, - description: { - type: GraphQLString, - resolve: (enumValue) => enumValue.description, - }, - isDeprecated: { - type: new GraphQLNonNull(GraphQLBoolean), - resolve: (enumValue) => enumValue.deprecationReason != null, - }, - deprecationReason: { - type: GraphQLString, - resolve: (enumValue) => enumValue.deprecationReason, - }, - } as GraphQLFieldConfigMap), -}); - -enum TypeKind { - SCALAR = 'SCALAR', - OBJECT = 'OBJECT', - INTERFACE = 'INTERFACE', - UNION = 'UNION', - ENUM = 'ENUM', - INPUT_OBJECT = 'INPUT_OBJECT', - LIST = 'LIST', - NON_NULL = 'NON_NULL', -} -export { TypeKind }; - -export const __TypeKind: GraphQLEnumType = new GraphQLEnumType({ - name: '__TypeKind', - description: 'An enum describing what kind of type a given `__Type` is.', - values: { - SCALAR: { - value: TypeKind.SCALAR, - description: 'Indicates this type is a scalar.', - }, - OBJECT: { - value: TypeKind.OBJECT, - description: - 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', - }, - INTERFACE: { - value: TypeKind.INTERFACE, - description: - 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', - }, - UNION: { - value: TypeKind.UNION, - description: - 'Indicates this type is a union. `possibleTypes` is a valid field.', - }, - ENUM: { - value: TypeKind.ENUM, - description: - 'Indicates this type is an enum. `enumValues` is a valid field.', - }, - INPUT_OBJECT: { - value: TypeKind.INPUT_OBJECT, - description: - 'Indicates this type is an input object. `inputFields` is a valid field.', - }, - LIST: { - value: TypeKind.LIST, - description: 'Indicates this type is a list. `ofType` is a valid field.', - }, - NON_NULL: { - value: TypeKind.NON_NULL, - description: - 'Indicates this type is a non-null. `ofType` is a valid field.', - }, - }, -}); - -/** - * Note that these are GraphQLField and not GraphQLFieldConfig, - * so the format for args is different. - */ - -export const SchemaMetaFieldDef: GraphQLField = { - name: '__schema', - type: new GraphQLNonNull(__Schema), - description: 'Access the current type schema of this server.', - args: [], - resolve: (_source, _args, _context, { schema }) => schema, - deprecationReason: undefined, - extensions: Object.create(null), - astNode: undefined, -}; - -export const TypeMetaFieldDef: GraphQLField = { - name: '__type', - type: __Type, - description: 'Request the type information of a single type.', - args: [ - { - name: 'name', - description: undefined, - type: new GraphQLNonNull(GraphQLString), - defaultValue: undefined, - deprecationReason: undefined, - extensions: Object.create(null), - astNode: undefined, - }, - ], - resolve: (_source, { name }, _context, { schema }) => schema.getType(name), - deprecationReason: undefined, - extensions: Object.create(null), - astNode: undefined, -}; - -export const TypeNameMetaFieldDef: GraphQLField = { - name: '__typename', - type: new GraphQLNonNull(GraphQLString), - description: 'The name of the current Object type at runtime.', - args: [], - resolve: (_source, _args, _context, { parentType }) => parentType.name, - deprecationReason: undefined, - extensions: Object.create(null), - astNode: undefined, -}; - -export const introspectionTypes: ReadonlyArray = - Object.freeze([ - __Schema, - __Directive, - __DirectiveLocation, - __Type, - __Field, - __InputValue, - __EnumValue, - __TypeKind, - ]); - -export function isIntrospectionType(type: GraphQLNamedType): boolean { - return introspectionTypes.some(({ name }) => type.name === name); -} diff --git a/src/type/scalars.ts b/src/type/scalars.ts deleted file mode 100644 index 4990347887..0000000000 --- a/src/type/scalars.ts +++ /dev/null @@ -1,284 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { isObjectLike } from '../jsutils/isObjectLike'; - -import { GraphQLError } from '../error/GraphQLError'; - -import { Kind } from '../language/kinds'; -import { print } from '../language/printer'; - -import type { GraphQLNamedType } from './definition'; -import { GraphQLScalarType } from './definition'; - -/** - * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). - * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1 - * */ -export const GRAPHQL_MAX_INT = 2147483647; - -/** - * Minimum possible Int value as per GraphQL Spec (32-bit signed integer). - * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1) - * */ -export const GRAPHQL_MIN_INT = -2147483648; - -export const GraphQLInt = new GraphQLScalarType({ - name: 'Int', - description: - 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.', - - serialize(outputValue) { - const coercedValue = serializeObject(outputValue); - - if (typeof coercedValue === 'boolean') { - return coercedValue ? 1 : 0; - } - - let num = coercedValue; - if (typeof coercedValue === 'string' && coercedValue !== '') { - num = Number(coercedValue); - } - - if (typeof num !== 'number' || !Number.isInteger(num)) { - throw new GraphQLError( - `Int cannot represent non-integer value: ${inspect(coercedValue)}`, - ); - } - if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { - throw new GraphQLError( - 'Int cannot represent non 32-bit signed integer value: ' + - inspect(coercedValue), - ); - } - return num; - }, - - parseValue(inputValue) { - if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) { - throw new GraphQLError( - `Int cannot represent non-integer value: ${inspect(inputValue)}`, - ); - } - if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) { - throw new GraphQLError( - `Int cannot represent non 32-bit signed integer value: ${inputValue}`, - ); - } - return inputValue; - }, - - parseLiteral(valueNode) { - if (valueNode.kind !== Kind.INT) { - throw new GraphQLError( - `Int cannot represent non-integer value: ${print(valueNode)}`, - { nodes: valueNode }, - ); - } - const num = parseInt(valueNode.value, 10); - if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { - throw new GraphQLError( - `Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, - { nodes: valueNode }, - ); - } - return num; - }, -}); - -export const GraphQLFloat = new GraphQLScalarType({ - name: 'Float', - description: - 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).', - - serialize(outputValue) { - const coercedValue = serializeObject(outputValue); - - if (typeof coercedValue === 'boolean') { - return coercedValue ? 1 : 0; - } - - let num = coercedValue; - if (typeof coercedValue === 'string' && coercedValue !== '') { - num = Number(coercedValue); - } - - if (typeof num !== 'number' || !Number.isFinite(num)) { - throw new GraphQLError( - `Float cannot represent non numeric value: ${inspect(coercedValue)}`, - ); - } - return num; - }, - - parseValue(inputValue) { - if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) { - throw new GraphQLError( - `Float cannot represent non numeric value: ${inspect(inputValue)}`, - ); - } - return inputValue; - }, - - parseLiteral(valueNode) { - if (valueNode.kind !== Kind.FLOAT && valueNode.kind !== Kind.INT) { - throw new GraphQLError( - `Float cannot represent non numeric value: ${print(valueNode)}`, - valueNode, - ); - } - return parseFloat(valueNode.value); - }, -}); - -export const GraphQLString = new GraphQLScalarType({ - name: 'String', - description: - 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', - - serialize(outputValue) { - const coercedValue = serializeObject(outputValue); - - // Serialize string, boolean and number values to a string, but do not - // attempt to coerce object, function, symbol, or other types as strings. - if (typeof coercedValue === 'string') { - return coercedValue; - } - if (typeof coercedValue === 'boolean') { - return coercedValue ? 'true' : 'false'; - } - if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) { - return coercedValue.toString(); - } - throw new GraphQLError( - `String cannot represent value: ${inspect(outputValue)}`, - ); - }, - - parseValue(inputValue) { - if (typeof inputValue !== 'string') { - throw new GraphQLError( - `String cannot represent a non string value: ${inspect(inputValue)}`, - ); - } - return inputValue; - }, - - parseLiteral(valueNode) { - if (valueNode.kind !== Kind.STRING) { - throw new GraphQLError( - `String cannot represent a non string value: ${print(valueNode)}`, - { nodes: valueNode }, - ); - } - return valueNode.value; - }, -}); - -export const GraphQLBoolean = new GraphQLScalarType({ - name: 'Boolean', - description: 'The `Boolean` scalar type represents `true` or `false`.', - - serialize(outputValue) { - const coercedValue = serializeObject(outputValue); - - if (typeof coercedValue === 'boolean') { - return coercedValue; - } - if (Number.isFinite(coercedValue)) { - return coercedValue !== 0; - } - throw new GraphQLError( - `Boolean cannot represent a non boolean value: ${inspect(coercedValue)}`, - ); - }, - - parseValue(inputValue) { - if (typeof inputValue !== 'boolean') { - throw new GraphQLError( - `Boolean cannot represent a non boolean value: ${inspect(inputValue)}`, - ); - } - return inputValue; - }, - - parseLiteral(valueNode) { - if (valueNode.kind !== Kind.BOOLEAN) { - throw new GraphQLError( - `Boolean cannot represent a non boolean value: ${print(valueNode)}`, - { nodes: valueNode }, - ); - } - return valueNode.value; - }, -}); - -export const GraphQLID = new GraphQLScalarType({ - name: 'ID', - description: - 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.', - - serialize(outputValue) { - const coercedValue = serializeObject(outputValue); - - if (typeof coercedValue === 'string') { - return coercedValue; - } - if (Number.isInteger(coercedValue)) { - return String(coercedValue); - } - throw new GraphQLError( - `ID cannot represent value: ${inspect(outputValue)}`, - ); - }, - - parseValue(inputValue) { - if (typeof inputValue === 'string') { - return inputValue; - } - if (typeof inputValue === 'number' && Number.isInteger(inputValue)) { - return inputValue.toString(); - } - throw new GraphQLError(`ID cannot represent value: ${inspect(inputValue)}`); - }, - - parseLiteral(valueNode) { - if (valueNode.kind !== Kind.STRING && valueNode.kind !== Kind.INT) { - throw new GraphQLError( - 'ID cannot represent a non-string and non-integer value: ' + - print(valueNode), - { nodes: valueNode }, - ); - } - return valueNode.value; - }, -}); - -export const specifiedScalarTypes: ReadonlyArray = - Object.freeze([ - GraphQLString, - GraphQLInt, - GraphQLFloat, - GraphQLBoolean, - GraphQLID, - ]); - -export function isSpecifiedScalarType(type: GraphQLNamedType): boolean { - return specifiedScalarTypes.some(({ name }) => type.name === name); -} - -// Support serializing objects with custom valueOf() or toJSON() functions - -// a common way to represent a complex value which can be represented as -// a string (ex: MongoDB id objects). -function serializeObject(outputValue: unknown): unknown { - if (isObjectLike(outputValue)) { - if (typeof outputValue.valueOf === 'function') { - const valueOfResult = outputValue.valueOf(); - if (!isObjectLike(valueOfResult)) { - return valueOfResult; - } - } - if (typeof outputValue.toJSON === 'function') { - return outputValue.toJSON(); - } - } - return outputValue; -} diff --git a/src/type/schema.ts b/src/type/schema.ts deleted file mode 100644 index 97c2782145..0000000000 --- a/src/type/schema.ts +++ /dev/null @@ -1,437 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; -import { instanceOf } from '../jsutils/instanceOf'; -import { isObjectLike } from '../jsutils/isObjectLike'; -import type { Maybe } from '../jsutils/Maybe'; -import type { ObjMap } from '../jsutils/ObjMap'; -import { toObjMap } from '../jsutils/toObjMap'; - -import type { GraphQLError } from '../error/GraphQLError'; - -import type { - SchemaDefinitionNode, - SchemaExtensionNode, -} from '../language/ast'; -import { OperationTypeNode } from '../language/ast'; - -import type { - GraphQLAbstractType, - GraphQLInterfaceType, - GraphQLNamedType, - GraphQLObjectType, - GraphQLType, -} from './definition'; -import { - getNamedType, - isInputObjectType, - isInterfaceType, - isObjectType, - isUnionType, -} from './definition'; -import type { GraphQLDirective } from './directives'; -import { isDirective, specifiedDirectives } from './directives'; -import { __Schema } from './introspection'; - -/** - * Test if the given value is a GraphQL schema. - */ -export function isSchema(schema: unknown): schema is GraphQLSchema { - return instanceOf(schema, GraphQLSchema); -} - -export function assertSchema(schema: unknown): GraphQLSchema { - if (!isSchema(schema)) { - throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`); - } - return schema; -} - -/** - * Custom extensions - * - * @remarks - * Use a unique identifier name for your extension, for example the name of - * your library or project. Do not use a shortened identifier as this increases - * the risk of conflicts. We recommend you add at most one extension field, - * an object which can contain all the values you need. - */ -export interface GraphQLSchemaExtensions { - [attributeName: string]: unknown; -} - -/** - * Schema Definition - * - * A Schema is created by supplying the root types of each type of operation, - * query and mutation (optional). A schema definition is then supplied to the - * validator and executor. - * - * Example: - * - * ```ts - * const MyAppSchema = new GraphQLSchema({ - * query: MyAppQueryRootType, - * mutation: MyAppMutationRootType, - * }) - * ``` - * - * Note: When the schema is constructed, by default only the types that are - * reachable by traversing the root types are included, other types must be - * explicitly referenced. - * - * Example: - * - * ```ts - * const characterInterface = new GraphQLInterfaceType({ - * name: 'Character', - * ... - * }); - * - * const humanType = new GraphQLObjectType({ - * name: 'Human', - * interfaces: [characterInterface], - * ... - * }); - * - * const droidType = new GraphQLObjectType({ - * name: 'Droid', - * interfaces: [characterInterface], - * ... - * }); - * - * const schema = new GraphQLSchema({ - * query: new GraphQLObjectType({ - * name: 'Query', - * fields: { - * hero: { type: characterInterface, ... }, - * } - * }), - * ... - * // Since this schema references only the `Character` interface it's - * // necessary to explicitly list the types that implement it if - * // you want them to be included in the final schema. - * types: [humanType, droidType], - * }) - * ``` - * - * Note: If an array of `directives` are provided to GraphQLSchema, that will be - * the exact list of directives represented and allowed. If `directives` is not - * provided then a default set of the specified directives (e.g. `@include` and - * `@skip`) will be used. If you wish to provide *additional* directives to these - * specified directives, you must explicitly declare them. Example: - * - * ```ts - * const MyAppSchema = new GraphQLSchema({ - * ... - * directives: specifiedDirectives.concat([ myCustomDirective ]), - * }) - * ``` - */ -export class GraphQLSchema { - description: Maybe; - extensions: Readonly; - astNode: Maybe; - extensionASTNodes: ReadonlyArray; - - // Used as a cache for validateSchema(). - __validationErrors: Maybe>; - - private _queryType: Maybe; - private _mutationType: Maybe; - private _subscriptionType: Maybe; - private _directives: ReadonlyArray; - private _typeMap: TypeMap; - private _subTypeMap: ObjMap>; - private _implementationsMap: ObjMap<{ - objects: Array; - interfaces: Array; - }>; - - constructor(config: Readonly) { - // If this schema was built from a source known to be valid, then it may be - // marked with assumeValid to avoid an additional type system validation. - this.__validationErrors = config.assumeValid === true ? [] : undefined; - - // Check for common mistakes during construction to produce early errors. - devAssert(isObjectLike(config), 'Must provide configuration object.'); - devAssert( - !config.types || Array.isArray(config.types), - `"types" must be Array if provided but got: ${inspect(config.types)}.`, - ); - devAssert( - !config.directives || Array.isArray(config.directives), - '"directives" must be Array if provided but got: ' + - `${inspect(config.directives)}.`, - ); - - this.description = config.description; - this.extensions = toObjMap(config.extensions); - this.astNode = config.astNode; - this.extensionASTNodes = config.extensionASTNodes ?? []; - - this._queryType = config.query; - this._mutationType = config.mutation; - this._subscriptionType = config.subscription; - // Provide specified directives (e.g. @include and @skip) by default. - this._directives = config.directives ?? specifiedDirectives; - - // To preserve order of user-provided types, we add first to add them to - // the set of "collected" types, so `collectReferencedTypes` ignore them. - const allReferencedTypes: Set = new Set(config.types); - if (config.types != null) { - for (const type of config.types) { - // When we ready to process this type, we remove it from "collected" types - // and then add it together with all dependent types in the correct position. - allReferencedTypes.delete(type); - collectReferencedTypes(type, allReferencedTypes); - } - } - - if (this._queryType != null) { - collectReferencedTypes(this._queryType, allReferencedTypes); - } - if (this._mutationType != null) { - collectReferencedTypes(this._mutationType, allReferencedTypes); - } - if (this._subscriptionType != null) { - collectReferencedTypes(this._subscriptionType, allReferencedTypes); - } - - for (const directive of this._directives) { - // Directives are not validated until validateSchema() is called. - if (isDirective(directive)) { - for (const arg of directive.args) { - collectReferencedTypes(arg.type, allReferencedTypes); - } - } - } - collectReferencedTypes(__Schema, allReferencedTypes); - - // Storing the resulting map for reference by the schema. - this._typeMap = Object.create(null); - this._subTypeMap = Object.create(null); - // Keep track of all implementations by interface name. - this._implementationsMap = Object.create(null); - - for (const namedType of allReferencedTypes) { - if (namedType == null) { - continue; - } - - const typeName = namedType.name; - devAssert( - typeName, - 'One of the provided types for building the Schema is missing a name.', - ); - if (this._typeMap[typeName] !== undefined) { - throw new Error( - `Schema must contain uniquely named types but contains multiple types named "${typeName}".`, - ); - } - this._typeMap[typeName] = namedType; - - if (isInterfaceType(namedType)) { - // Store implementations by interface. - for (const iface of namedType.getInterfaces()) { - if (isInterfaceType(iface)) { - let implementations = this._implementationsMap[iface.name]; - if (implementations === undefined) { - implementations = this._implementationsMap[iface.name] = { - objects: [], - interfaces: [], - }; - } - - implementations.interfaces.push(namedType); - } - } - } else if (isObjectType(namedType)) { - // Store implementations by objects. - for (const iface of namedType.getInterfaces()) { - if (isInterfaceType(iface)) { - let implementations = this._implementationsMap[iface.name]; - if (implementations === undefined) { - implementations = this._implementationsMap[iface.name] = { - objects: [], - interfaces: [], - }; - } - - implementations.objects.push(namedType); - } - } - } - } - } - - get [Symbol.toStringTag]() { - return 'GraphQLSchema'; - } - - getQueryType(): Maybe { - return this._queryType; - } - - getMutationType(): Maybe { - return this._mutationType; - } - - getSubscriptionType(): Maybe { - return this._subscriptionType; - } - - getRootType(operation: OperationTypeNode): Maybe { - switch (operation) { - case OperationTypeNode.QUERY: - return this.getQueryType(); - case OperationTypeNode.MUTATION: - return this.getMutationType(); - case OperationTypeNode.SUBSCRIPTION: - return this.getSubscriptionType(); - } - } - - getTypeMap(): TypeMap { - return this._typeMap; - } - - getType(name: string): GraphQLNamedType | undefined { - return this.getTypeMap()[name]; - } - - getPossibleTypes( - abstractType: GraphQLAbstractType, - ): ReadonlyArray { - return isUnionType(abstractType) - ? abstractType.getTypes() - : this.getImplementations(abstractType).objects; - } - - getImplementations(interfaceType: GraphQLInterfaceType): { - objects: ReadonlyArray; - interfaces: ReadonlyArray; - } { - const implementations = this._implementationsMap[interfaceType.name]; - return implementations ?? { objects: [], interfaces: [] }; - } - - isSubType( - abstractType: GraphQLAbstractType, - maybeSubType: GraphQLObjectType | GraphQLInterfaceType, - ): boolean { - let map = this._subTypeMap[abstractType.name]; - if (map === undefined) { - map = Object.create(null); - - if (isUnionType(abstractType)) { - for (const type of abstractType.getTypes()) { - map[type.name] = true; - } - } else { - const implementations = this.getImplementations(abstractType); - for (const type of implementations.objects) { - map[type.name] = true; - } - for (const type of implementations.interfaces) { - map[type.name] = true; - } - } - - this._subTypeMap[abstractType.name] = map; - } - return map[maybeSubType.name] !== undefined; - } - - getDirectives(): ReadonlyArray { - return this._directives; - } - - getDirective(name: string): Maybe { - return this.getDirectives().find((directive) => directive.name === name); - } - - toConfig(): GraphQLSchemaNormalizedConfig { - return { - description: this.description, - query: this.getQueryType(), - mutation: this.getMutationType(), - subscription: this.getSubscriptionType(), - types: Object.values(this.getTypeMap()), - directives: this.getDirectives(), - extensions: this.extensions, - astNode: this.astNode, - extensionASTNodes: this.extensionASTNodes, - assumeValid: this.__validationErrors !== undefined, - }; - } -} - -type TypeMap = ObjMap; - -export interface GraphQLSchemaValidationOptions { - /** - * When building a schema from a GraphQL service's introspection result, it - * might be safe to assume the schema is valid. Set to true to assume the - * produced schema is valid. - * - * Default: false - */ - assumeValid?: boolean; -} - -export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { - description?: Maybe; - query?: Maybe; - mutation?: Maybe; - subscription?: Maybe; - types?: Maybe>; - directives?: Maybe>; - extensions?: Maybe>; - astNode?: Maybe; - extensionASTNodes?: Maybe>; -} - -/** - * @internal - */ -export interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig { - description: Maybe; - types: ReadonlyArray; - directives: ReadonlyArray; - extensions: Readonly; - extensionASTNodes: ReadonlyArray; - assumeValid: boolean; -} - -function collectReferencedTypes( - type: GraphQLType, - typeSet: Set, -): Set { - const namedType = getNamedType(type); - - if (!typeSet.has(namedType)) { - typeSet.add(namedType); - if (isUnionType(namedType)) { - for (const memberType of namedType.getTypes()) { - collectReferencedTypes(memberType, typeSet); - } - } else if (isObjectType(namedType) || isInterfaceType(namedType)) { - for (const interfaceType of namedType.getInterfaces()) { - collectReferencedTypes(interfaceType, typeSet); - } - - for (const field of Object.values(namedType.getFields())) { - collectReferencedTypes(field.type, typeSet); - for (const arg of field.args) { - collectReferencedTypes(arg.type, typeSet); - } - } - } else if (isInputObjectType(namedType)) { - for (const field of Object.values(namedType.getFields())) { - collectReferencedTypes(field.type, typeSet); - } - } - } - - return typeSet; -} diff --git a/src/type/validate.ts b/src/type/validate.ts deleted file mode 100644 index 56ad63fc64..0000000000 --- a/src/type/validate.ts +++ /dev/null @@ -1,656 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import type { Maybe } from '../jsutils/Maybe'; - -import { GraphQLError } from '../error/GraphQLError'; - -import type { - ASTNode, - DirectiveNode, - InterfaceTypeDefinitionNode, - InterfaceTypeExtensionNode, - NamedTypeNode, - ObjectTypeDefinitionNode, - ObjectTypeExtensionNode, - UnionTypeDefinitionNode, - UnionTypeExtensionNode, -} from '../language/ast'; -import { OperationTypeNode } from '../language/ast'; - -import { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators'; - -import type { - GraphQLEnumType, - GraphQLInputField, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLObjectType, - GraphQLUnionType, -} from './definition'; -import { - isEnumType, - isInputObjectType, - isInputType, - isInterfaceType, - isNamedType, - isNonNullType, - isObjectType, - isOutputType, - isRequiredArgument, - isRequiredInputField, - isUnionType, -} from './definition'; -import { GraphQLDeprecatedDirective, isDirective } from './directives'; -import { isIntrospectionType } from './introspection'; -import type { GraphQLSchema } from './schema'; -import { assertSchema } from './schema'; - -/** - * Implements the "Type Validation" sub-sections of the specification's - * "Type System" section. - * - * Validation runs synchronously, returning an array of encountered errors, or - * an empty array if no errors were encountered and the Schema is valid. - */ -export function validateSchema( - schema: GraphQLSchema, -): ReadonlyArray { - // First check to ensure the provided value is in fact a GraphQLSchema. - assertSchema(schema); - - // If this Schema has already been validated, return the previous results. - if (schema.__validationErrors) { - return schema.__validationErrors; - } - - // Validate the schema, producing a list of errors. - const context = new SchemaValidationContext(schema); - validateRootTypes(context); - validateDirectives(context); - validateTypes(context); - - // Persist the results of validation before returning to ensure validation - // does not run multiple times for this schema. - const errors = context.getErrors(); - schema.__validationErrors = errors; - return errors; -} - -/** - * Utility function which asserts a schema is valid by throwing an error if - * it is invalid. - */ -export function assertValidSchema(schema: GraphQLSchema): void { - const errors = validateSchema(schema); - if (errors.length !== 0) { - throw new Error(errors.map((error) => error.message).join('\n\n')); - } -} - -class SchemaValidationContext { - readonly _errors: Array; - readonly schema: GraphQLSchema; - - constructor(schema: GraphQLSchema) { - this._errors = []; - this.schema = schema; - } - - reportError( - message: string, - nodes?: ReadonlyArray> | Maybe, - ): void { - const _nodes = Array.isArray(nodes) - ? (nodes.filter(Boolean) as ReadonlyArray) - : (nodes as Maybe); - this._errors.push(new GraphQLError(message, { nodes: _nodes })); - } - - getErrors(): ReadonlyArray { - return this._errors; - } -} - -function validateRootTypes(context: SchemaValidationContext): void { - const schema = context.schema; - const queryType = schema.getQueryType(); - if (!queryType) { - context.reportError('Query root type must be provided.', schema.astNode); - } else if (!isObjectType(queryType)) { - context.reportError( - `Query root type must be Object type, it cannot be ${inspect( - queryType, - )}.`, - getOperationTypeNode(schema, OperationTypeNode.QUERY) ?? - (queryType as any).astNode, - ); - } - - const mutationType = schema.getMutationType(); - if (mutationType && !isObjectType(mutationType)) { - context.reportError( - 'Mutation root type must be Object type if provided, it cannot be ' + - `${inspect(mutationType)}.`, - getOperationTypeNode(schema, OperationTypeNode.MUTATION) ?? - (mutationType as any).astNode, - ); - } - - const subscriptionType = schema.getSubscriptionType(); - if (subscriptionType && !isObjectType(subscriptionType)) { - context.reportError( - 'Subscription root type must be Object type if provided, it cannot be ' + - `${inspect(subscriptionType)}.`, - getOperationTypeNode(schema, OperationTypeNode.SUBSCRIPTION) ?? - (subscriptionType as any).astNode, - ); - } -} - -function getOperationTypeNode( - schema: GraphQLSchema, - operation: OperationTypeNode, -): Maybe { - return [schema.astNode, ...schema.extensionASTNodes] - .flatMap( - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - (schemaNode) => /* c8 ignore next */ schemaNode?.operationTypes ?? [], - ) - .find((operationNode) => operationNode.operation === operation)?.type; -} - -function validateDirectives(context: SchemaValidationContext): void { - for (const directive of context.schema.getDirectives()) { - // Ensure all directives are in fact GraphQL directives. - if (!isDirective(directive)) { - context.reportError( - `Expected directive but got: ${inspect(directive)}.`, - (directive as any)?.astNode, - ); - continue; - } - - // Ensure they are named correctly. - validateName(context, directive); - - if (directive.locations.length === 0) { - context.reportError( - `Directive @${directive.name} must include 1 or more locations.`, - directive.astNode, - ); - } - - // Ensure the arguments are valid. - for (const arg of directive.args) { - // Ensure they are named correctly. - validateName(context, arg); - - // Ensure the type is an input type. - if (!isInputType(arg.type)) { - context.reportError( - `The type of @${directive.name}(${arg.name}:) must be Input Type ` + - `but got: ${inspect(arg.type)}.`, - arg.astNode, - ); - } - - if (isRequiredArgument(arg) && arg.deprecationReason != null) { - context.reportError( - `Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`, - [getDeprecatedDirectiveNode(arg.astNode), arg.astNode?.type], - ); - } - } - } -} - -function validateName( - context: SchemaValidationContext, - node: { readonly name: string; readonly astNode: Maybe }, -): void { - // Ensure names are valid, however introspection types opt out. - if (node.name.startsWith('__')) { - context.reportError( - `Name "${node.name}" must not begin with "__", which is reserved by GraphQL introspection.`, - node.astNode, - ); - } -} - -function validateTypes(context: SchemaValidationContext): void { - const validateInputObjectCircularRefs = - createInputObjectCircularRefsValidator(context); - const typeMap = context.schema.getTypeMap(); - for (const type of Object.values(typeMap)) { - // Ensure all provided types are in fact GraphQL type. - if (!isNamedType(type)) { - context.reportError( - `Expected GraphQL named type but got: ${inspect(type)}.`, - (type as any).astNode, - ); - continue; - } - - // Ensure it is named correctly (excluding introspection types). - if (!isIntrospectionType(type)) { - validateName(context, type); - } - - if (isObjectType(type)) { - // Ensure fields are valid - validateFields(context, type); - - // Ensure objects implement the interfaces they claim to. - validateInterfaces(context, type); - } else if (isInterfaceType(type)) { - // Ensure fields are valid. - validateFields(context, type); - - // Ensure interfaces implement the interfaces they claim to. - validateInterfaces(context, type); - } else if (isUnionType(type)) { - // Ensure Unions include valid member types. - validateUnionMembers(context, type); - } else if (isEnumType(type)) { - // Ensure Enums have valid values. - validateEnumValues(context, type); - } else if (isInputObjectType(type)) { - // Ensure Input Object fields are valid. - validateInputFields(context, type); - - // Ensure Input Objects do not contain non-nullable circular references - validateInputObjectCircularRefs(type); - } - } -} - -function validateFields( - context: SchemaValidationContext, - type: GraphQLObjectType | GraphQLInterfaceType, -): void { - const fields = Object.values(type.getFields()); - - // Objects and Interfaces both must define one or more fields. - if (fields.length === 0) { - context.reportError(`Type ${type.name} must define one or more fields.`, [ - type.astNode, - ...type.extensionASTNodes, - ]); - } - - for (const field of fields) { - // Ensure they are named correctly. - validateName(context, field); - - // Ensure the type is an output type - if (!isOutputType(field.type)) { - context.reportError( - `The type of ${type.name}.${field.name} must be Output Type ` + - `but got: ${inspect(field.type)}.`, - field.astNode?.type, - ); - } - - // Ensure the arguments are valid - for (const arg of field.args) { - const argName = arg.name; - - // Ensure they are named correctly. - validateName(context, arg); - - // Ensure the type is an input type - if (!isInputType(arg.type)) { - context.reportError( - `The type of ${type.name}.${field.name}(${argName}:) must be Input ` + - `Type but got: ${inspect(arg.type)}.`, - arg.astNode?.type, - ); - } - - if (isRequiredArgument(arg) && arg.deprecationReason != null) { - context.reportError( - `Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`, - [getDeprecatedDirectiveNode(arg.astNode), arg.astNode?.type], - ); - } - } - } -} - -function validateInterfaces( - context: SchemaValidationContext, - type: GraphQLObjectType | GraphQLInterfaceType, -): void { - const ifaceTypeNames = Object.create(null); - for (const iface of type.getInterfaces()) { - if (!isInterfaceType(iface)) { - context.reportError( - `Type ${inspect(type)} must only implement Interface types, ` + - `it cannot implement ${inspect(iface)}.`, - getAllImplementsInterfaceNodes(type, iface), - ); - continue; - } - - if (type === iface) { - context.reportError( - `Type ${type.name} cannot implement itself because it would create a circular reference.`, - getAllImplementsInterfaceNodes(type, iface), - ); - continue; - } - - if (ifaceTypeNames[iface.name]) { - context.reportError( - `Type ${type.name} can only implement ${iface.name} once.`, - getAllImplementsInterfaceNodes(type, iface), - ); - continue; - } - - ifaceTypeNames[iface.name] = true; - - validateTypeImplementsAncestors(context, type, iface); - validateTypeImplementsInterface(context, type, iface); - } -} - -function validateTypeImplementsInterface( - context: SchemaValidationContext, - type: GraphQLObjectType | GraphQLInterfaceType, - iface: GraphQLInterfaceType, -): void { - const typeFieldMap = type.getFields(); - - // Assert each interface field is implemented. - for (const ifaceField of Object.values(iface.getFields())) { - const fieldName = ifaceField.name; - const typeField = typeFieldMap[fieldName]; - - // Assert interface field exists on type. - if (!typeField) { - context.reportError( - `Interface field ${iface.name}.${fieldName} expected but ${type.name} does not provide it.`, - [ifaceField.astNode, type.astNode, ...type.extensionASTNodes], - ); - continue; - } - - // Assert interface field type is satisfied by type field type, by being - // a valid subtype. (covariant) - if (!isTypeSubTypeOf(context.schema, typeField.type, ifaceField.type)) { - context.reportError( - `Interface field ${iface.name}.${fieldName} expects type ` + - `${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` + - `is type ${inspect(typeField.type)}.`, - [ifaceField.astNode?.type, typeField.astNode?.type], - ); - } - - // Assert each interface field arg is implemented. - for (const ifaceArg of ifaceField.args) { - const argName = ifaceArg.name; - const typeArg = typeField.args.find((arg) => arg.name === argName); - - // Assert interface field arg exists on object field. - if (!typeArg) { - context.reportError( - `Interface field argument ${iface.name}.${fieldName}(${argName}:) expected but ${type.name}.${fieldName} does not provide it.`, - [ifaceArg.astNode, typeField.astNode], - ); - continue; - } - - // Assert interface field arg type matches object field arg type. - // (invariant) - // TODO: change to contravariant? - if (!isEqualType(ifaceArg.type, typeArg.type)) { - context.reportError( - `Interface field argument ${iface.name}.${fieldName}(${argName}:) ` + - `expects type ${inspect(ifaceArg.type)} but ` + - `${type.name}.${fieldName}(${argName}:) is type ` + - `${inspect(typeArg.type)}.`, - [ifaceArg.astNode?.type, typeArg.astNode?.type], - ); - } - - // TODO: validate default values? - } - - // Assert additional arguments must not be required. - for (const typeArg of typeField.args) { - const argName = typeArg.name; - const ifaceArg = ifaceField.args.find((arg) => arg.name === argName); - if (!ifaceArg && isRequiredArgument(typeArg)) { - context.reportError( - `Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, - [typeArg.astNode, ifaceField.astNode], - ); - } - } - } -} - -function validateTypeImplementsAncestors( - context: SchemaValidationContext, - type: GraphQLObjectType | GraphQLInterfaceType, - iface: GraphQLInterfaceType, -): void { - const ifaceInterfaces = type.getInterfaces(); - for (const transitive of iface.getInterfaces()) { - if (!ifaceInterfaces.includes(transitive)) { - context.reportError( - transitive === type - ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` - : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, - [ - ...getAllImplementsInterfaceNodes(iface, transitive), - ...getAllImplementsInterfaceNodes(type, iface), - ], - ); - } - } -} - -function validateUnionMembers( - context: SchemaValidationContext, - union: GraphQLUnionType, -): void { - const memberTypes = union.getTypes(); - - if (memberTypes.length === 0) { - context.reportError( - `Union type ${union.name} must define one or more member types.`, - [union.astNode, ...union.extensionASTNodes], - ); - } - - const includedTypeNames = Object.create(null); - for (const memberType of memberTypes) { - if (includedTypeNames[memberType.name]) { - context.reportError( - `Union type ${union.name} can only include type ${memberType.name} once.`, - getUnionMemberTypeNodes(union, memberType.name), - ); - continue; - } - includedTypeNames[memberType.name] = true; - if (!isObjectType(memberType)) { - context.reportError( - `Union type ${union.name} can only include Object types, ` + - `it cannot include ${inspect(memberType)}.`, - getUnionMemberTypeNodes(union, String(memberType)), - ); - } - } -} - -function validateEnumValues( - context: SchemaValidationContext, - enumType: GraphQLEnumType, -): void { - const enumValues = enumType.getValues(); - - if (enumValues.length === 0) { - context.reportError( - `Enum type ${enumType.name} must define one or more values.`, - [enumType.astNode, ...enumType.extensionASTNodes], - ); - } - - for (const enumValue of enumValues) { - // Ensure valid name. - validateName(context, enumValue); - } -} - -function validateInputFields( - context: SchemaValidationContext, - inputObj: GraphQLInputObjectType, -): void { - const fields = Object.values(inputObj.getFields()); - - if (fields.length === 0) { - context.reportError( - `Input Object type ${inputObj.name} must define one or more fields.`, - [inputObj.astNode, ...inputObj.extensionASTNodes], - ); - } - - // Ensure the arguments are valid - for (const field of fields) { - // Ensure they are named correctly. - validateName(context, field); - - // Ensure the type is an input type - if (!isInputType(field.type)) { - context.reportError( - `The type of ${inputObj.name}.${field.name} must be Input Type ` + - `but got: ${inspect(field.type)}.`, - field.astNode?.type, - ); - } - - if (isRequiredInputField(field) && field.deprecationReason != null) { - context.reportError( - `Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, - [getDeprecatedDirectiveNode(field.astNode), field.astNode?.type], - ); - } - - if (inputObj.isOneOf) { - validateOneOfInputObjectField(inputObj, field, context); - } - } -} - -function validateOneOfInputObjectField( - type: GraphQLInputObjectType, - field: GraphQLInputField, - context: SchemaValidationContext, -): void { - if (isNonNullType(field.type)) { - context.reportError( - `OneOf input field ${type.name}.${field.name} must be nullable.`, - field.astNode?.type, - ); - } - - if (field.defaultValue !== undefined) { - context.reportError( - `OneOf input field ${type.name}.${field.name} cannot have a default value.`, - field.astNode, - ); - } -} - -function createInputObjectCircularRefsValidator( - context: SchemaValidationContext, -): (inputObj: GraphQLInputObjectType) => void { - // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. - // Tracks already visited types to maintain O(N) and to ensure that cycles - // are not redundantly reported. - const visitedTypes = Object.create(null); - - // Array of types nodes used to produce meaningful errors - const fieldPath: Array = []; - - // Position in the type path - const fieldPathIndexByTypeName = Object.create(null); - - return detectCycleRecursive; - - // This does a straight-forward DFS to find cycles. - // It does not terminate when a cycle was found but continues to explore - // the graph to find all possible cycles. - function detectCycleRecursive(inputObj: GraphQLInputObjectType): void { - if (visitedTypes[inputObj.name]) { - return; - } - - visitedTypes[inputObj.name] = true; - fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; - - const fields = Object.values(inputObj.getFields()); - for (const field of fields) { - if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) { - const fieldType = field.type.ofType; - const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; - - fieldPath.push(field); - if (cycleIndex === undefined) { - detectCycleRecursive(fieldType); - } else { - const cyclePath = fieldPath.slice(cycleIndex); - const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join('.'); - context.reportError( - `Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`, - cyclePath.map((fieldObj) => fieldObj.astNode), - ); - } - fieldPath.pop(); - } - } - - fieldPathIndexByTypeName[inputObj.name] = undefined; - } -} - -function getAllImplementsInterfaceNodes( - type: GraphQLObjectType | GraphQLInterfaceType, - iface: GraphQLInterfaceType, -): ReadonlyArray { - const { astNode, extensionASTNodes } = type; - const nodes: ReadonlyArray< - | ObjectTypeDefinitionNode - | ObjectTypeExtensionNode - | InterfaceTypeDefinitionNode - | InterfaceTypeExtensionNode - > = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - return nodes - .flatMap((typeNode) => /* c8 ignore next */ typeNode.interfaces ?? []) - .filter((ifaceNode) => ifaceNode.name.value === iface.name); -} - -function getUnionMemberTypeNodes( - union: GraphQLUnionType, - typeName: string, -): Maybe> { - const { astNode, extensionASTNodes } = union; - const nodes: ReadonlyArray = - astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - return nodes - .flatMap((unionNode) => /* c8 ignore next */ unionNode.types ?? []) - .filter((typeNode) => typeNode.name.value === typeName); -} - -function getDeprecatedDirectiveNode( - definitionNode: Maybe<{ readonly directives?: ReadonlyArray }>, -): Maybe { - return definitionNode?.directives?.find( - (node) => node.name.value === GraphQLDeprecatedDirective.name, - ); -} diff --git a/src/utilities/README.md b/src/utilities/README.md deleted file mode 100644 index 0e626e2325..0000000000 --- a/src/utilities/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## GraphQL Utilities - -The `graphql/utilities` module contains common useful computations to use with -the GraphQL language and type objects. - -```js -import { ... } from 'graphql/utilities'; // ES6 -var GraphQLUtilities = require('graphql/utilities'); // CommonJS -``` diff --git a/src/utilities/TypeInfo.ts b/src/utilities/TypeInfo.ts deleted file mode 100644 index e72dfb01fb..0000000000 --- a/src/utilities/TypeInfo.ts +++ /dev/null @@ -1,363 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; - -import type { ASTNode, FieldNode } from '../language/ast'; -import { isNode } from '../language/ast'; -import { Kind } from '../language/kinds'; -import type { ASTVisitor } from '../language/visitor'; -import { getEnterLeaveForKind } from '../language/visitor'; - -import type { - GraphQLArgument, - GraphQLCompositeType, - GraphQLEnumValue, - GraphQLField, - GraphQLInputField, - GraphQLInputType, - GraphQLOutputType, - GraphQLType, -} from '../type/definition'; -import { - getNamedType, - getNullableType, - isCompositeType, - isEnumType, - isInputObjectType, - isInputType, - isInterfaceType, - isListType, - isObjectType, - isOutputType, -} from '../type/definition'; -import type { GraphQLDirective } from '../type/directives'; -import { - SchemaMetaFieldDef, - TypeMetaFieldDef, - TypeNameMetaFieldDef, -} from '../type/introspection'; -import type { GraphQLSchema } from '../type/schema'; - -import { typeFromAST } from './typeFromAST'; - -/** - * TypeInfo is a utility class which, given a GraphQL schema, can keep track - * of the current field and type definitions at any point in a GraphQL document - * AST during a recursive descent by calling `enter(node)` and `leave(node)`. - */ -export class TypeInfo { - private _schema: GraphQLSchema; - private _typeStack: Array>; - private _parentTypeStack: Array>; - private _inputTypeStack: Array>; - private _fieldDefStack: Array>>; - private _defaultValueStack: Array>; - private _directive: Maybe; - private _argument: Maybe; - private _enumValue: Maybe; - private _getFieldDef: GetFieldDefFn; - - constructor( - schema: GraphQLSchema, - /** - * Initial type may be provided in rare cases to facilitate traversals - * beginning somewhere other than documents. - */ - initialType?: Maybe, - - /** @deprecated will be removed in 17.0.0 */ - getFieldDefFn?: GetFieldDefFn, - ) { - this._schema = schema; - this._typeStack = []; - this._parentTypeStack = []; - this._inputTypeStack = []; - this._fieldDefStack = []; - this._defaultValueStack = []; - this._directive = null; - this._argument = null; - this._enumValue = null; - this._getFieldDef = getFieldDefFn ?? getFieldDef; - if (initialType) { - if (isInputType(initialType)) { - this._inputTypeStack.push(initialType); - } - if (isCompositeType(initialType)) { - this._parentTypeStack.push(initialType); - } - if (isOutputType(initialType)) { - this._typeStack.push(initialType); - } - } - } - - get [Symbol.toStringTag]() { - return 'TypeInfo'; - } - - getType(): Maybe { - if (this._typeStack.length > 0) { - return this._typeStack[this._typeStack.length - 1]; - } - } - - getParentType(): Maybe { - if (this._parentTypeStack.length > 0) { - return this._parentTypeStack[this._parentTypeStack.length - 1]; - } - } - - getInputType(): Maybe { - if (this._inputTypeStack.length > 0) { - return this._inputTypeStack[this._inputTypeStack.length - 1]; - } - } - - getParentInputType(): Maybe { - if (this._inputTypeStack.length > 1) { - return this._inputTypeStack[this._inputTypeStack.length - 2]; - } - } - - getFieldDef(): Maybe> { - if (this._fieldDefStack.length > 0) { - return this._fieldDefStack[this._fieldDefStack.length - 1]; - } - } - - getDefaultValue(): Maybe { - if (this._defaultValueStack.length > 0) { - return this._defaultValueStack[this._defaultValueStack.length - 1]; - } - } - - getDirective(): Maybe { - return this._directive; - } - - getArgument(): Maybe { - return this._argument; - } - - getEnumValue(): Maybe { - return this._enumValue; - } - - enter(node: ASTNode) { - const schema = this._schema; - // Note: many of the types below are explicitly typed as "unknown" to drop - // any assumptions of a valid schema to ensure runtime types are properly - // checked before continuing since TypeInfo is used as part of validation - // which occurs before guarantees of schema and document validity. - switch (node.kind) { - case Kind.SELECTION_SET: { - const namedType: unknown = getNamedType(this.getType()); - this._parentTypeStack.push( - isCompositeType(namedType) ? namedType : undefined, - ); - break; - } - case Kind.FIELD: { - const parentType = this.getParentType(); - let fieldDef; - let fieldType: unknown; - if (parentType) { - fieldDef = this._getFieldDef(schema, parentType, node); - if (fieldDef) { - fieldType = fieldDef.type; - } - } - this._fieldDefStack.push(fieldDef); - this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined); - break; - } - case Kind.DIRECTIVE: - this._directive = schema.getDirective(node.name.value); - break; - case Kind.OPERATION_DEFINITION: { - const rootType = schema.getRootType(node.operation); - this._typeStack.push(isObjectType(rootType) ? rootType : undefined); - break; - } - case Kind.INLINE_FRAGMENT: - case Kind.FRAGMENT_DEFINITION: { - const typeConditionAST = node.typeCondition; - const outputType: unknown = typeConditionAST - ? typeFromAST(schema, typeConditionAST) - : getNamedType(this.getType()); - this._typeStack.push(isOutputType(outputType) ? outputType : undefined); - break; - } - case Kind.VARIABLE_DEFINITION: { - const inputType: unknown = typeFromAST(schema, node.type); - this._inputTypeStack.push( - isInputType(inputType) ? inputType : undefined, - ); - break; - } - case Kind.ARGUMENT: { - let argDef; - let argType: unknown; - const fieldOrDirective = this.getDirective() ?? this.getFieldDef(); - if (fieldOrDirective) { - argDef = fieldOrDirective.args.find( - (arg) => arg.name === node.name.value, - ); - if (argDef) { - argType = argDef.type; - } - } - this._argument = argDef; - this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined); - this._inputTypeStack.push(isInputType(argType) ? argType : undefined); - break; - } - case Kind.LIST: { - const listType: unknown = getNullableType(this.getInputType()); - const itemType: unknown = isListType(listType) - ? listType.ofType - : listType; - // List positions never have a default value. - this._defaultValueStack.push(undefined); - this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined); - break; - } - case Kind.OBJECT_FIELD: { - const objectType: unknown = getNamedType(this.getInputType()); - let inputFieldType: GraphQLInputType | undefined; - let inputField: GraphQLInputField | undefined; - if (isInputObjectType(objectType)) { - inputField = objectType.getFields()[node.name.value]; - if (inputField) { - inputFieldType = inputField.type; - } - } - this._defaultValueStack.push( - inputField ? inputField.defaultValue : undefined, - ); - this._inputTypeStack.push( - isInputType(inputFieldType) ? inputFieldType : undefined, - ); - break; - } - case Kind.ENUM: { - const enumType: unknown = getNamedType(this.getInputType()); - let enumValue; - if (isEnumType(enumType)) { - enumValue = enumType.getValue(node.value); - } - this._enumValue = enumValue; - break; - } - default: - // Ignore other nodes - } - } - - leave(node: ASTNode) { - switch (node.kind) { - case Kind.SELECTION_SET: - this._parentTypeStack.pop(); - break; - case Kind.FIELD: - this._fieldDefStack.pop(); - this._typeStack.pop(); - break; - case Kind.DIRECTIVE: - this._directive = null; - break; - case Kind.OPERATION_DEFINITION: - case Kind.INLINE_FRAGMENT: - case Kind.FRAGMENT_DEFINITION: - this._typeStack.pop(); - break; - case Kind.VARIABLE_DEFINITION: - this._inputTypeStack.pop(); - break; - case Kind.ARGUMENT: - this._argument = null; - this._defaultValueStack.pop(); - this._inputTypeStack.pop(); - break; - case Kind.LIST: - case Kind.OBJECT_FIELD: - this._defaultValueStack.pop(); - this._inputTypeStack.pop(); - break; - case Kind.ENUM: - this._enumValue = null; - break; - default: - // Ignore other nodes - } - } -} - -type GetFieldDefFn = ( - schema: GraphQLSchema, - parentType: GraphQLType, - fieldNode: FieldNode, -) => Maybe>; - -/** - * Not exactly the same as the executor's definition of getFieldDef, in this - * statically evaluated environment we do not always have an Object type, - * and need to handle Interface and Union types. - */ -function getFieldDef( - schema: GraphQLSchema, - parentType: GraphQLType, - fieldNode: FieldNode, -): Maybe> { - const name = fieldNode.name.value; - if ( - name === SchemaMetaFieldDef.name && - schema.getQueryType() === parentType - ) { - return SchemaMetaFieldDef; - } - if (name === TypeMetaFieldDef.name && schema.getQueryType() === parentType) { - return TypeMetaFieldDef; - } - if (name === TypeNameMetaFieldDef.name && isCompositeType(parentType)) { - return TypeNameMetaFieldDef; - } - if (isObjectType(parentType) || isInterfaceType(parentType)) { - return parentType.getFields()[name]; - } -} - -/** - * Creates a new visitor instance which maintains a provided TypeInfo instance - * along with visiting visitor. - */ -export function visitWithTypeInfo( - typeInfo: TypeInfo, - visitor: ASTVisitor, -): ASTVisitor { - return { - enter(...args) { - const node = args[0]; - typeInfo.enter(node); - const fn = getEnterLeaveForKind(visitor, node.kind).enter; - if (fn) { - const result = fn.apply(visitor, args); - if (result !== undefined) { - typeInfo.leave(node); - if (isNode(result)) { - typeInfo.enter(result); - } - } - return result; - } - }, - leave(...args) { - const node = args[0]; - const fn = getEnterLeaveForKind(visitor, node.kind).leave; - let result; - if (fn) { - result = fn.apply(visitor, args); - } - typeInfo.leave(node); - return result; - }, - }; -} diff --git a/src/utilities/__tests__/TypeInfo-test.ts b/src/utilities/__tests__/TypeInfo-test.ts deleted file mode 100644 index 5c04458c51..0000000000 --- a/src/utilities/__tests__/TypeInfo-test.ts +++ /dev/null @@ -1,460 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { invariant } from '../../jsutils/invariant'; - -import { parse, parseValue } from '../../language/parser'; -import { print } from '../../language/printer'; -import { visit } from '../../language/visitor'; - -import { getNamedType, isCompositeType } from '../../type/definition'; -import { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../buildASTSchema'; -import { TypeInfo, visitWithTypeInfo } from '../TypeInfo'; - -const testSchema = buildSchema(` - interface Pet { - name: String - } - - type Dog implements Pet { - name: String - } - - type Cat implements Pet { - name: String - } - - type Human { - name: String - pets: [Pet] - } - - type Alien { - name(surname: Boolean): String - } - - type QueryRoot { - human(id: ID): Human - alien: Alien - } - - schema { - query: QueryRoot - } -`); - -describe('TypeInfo', () => { - const schema = new GraphQLSchema({}); - - it('can be Object.toStringified', () => { - const typeInfo = new TypeInfo(schema); - - expect(Object.prototype.toString.call(typeInfo)).to.equal( - '[object TypeInfo]', - ); - }); - - it('allow all methods to be called before entering any node', () => { - const typeInfo = new TypeInfo(schema); - - expect(typeInfo.getType()).to.equal(undefined); - expect(typeInfo.getParentType()).to.equal(undefined); - expect(typeInfo.getInputType()).to.equal(undefined); - expect(typeInfo.getParentInputType()).to.equal(undefined); - expect(typeInfo.getFieldDef()).to.equal(undefined); - expect(typeInfo.getDefaultValue()).to.equal(undefined); - expect(typeInfo.getDirective()).to.equal(null); - expect(typeInfo.getArgument()).to.equal(null); - expect(typeInfo.getEnumValue()).to.equal(null); - }); -}); - -describe('visitWithTypeInfo', () => { - it('supports different operation types', () => { - const schema = buildSchema(` - schema { - query: QueryRoot - mutation: MutationRoot - subscription: SubscriptionRoot - } - - type QueryRoot { - foo: String - } - - type MutationRoot { - bar: String - } - - type SubscriptionRoot { - baz: String - } - `); - const ast = parse(` - query { foo } - mutation { bar } - subscription { baz } - `); - const typeInfo = new TypeInfo(schema); - - const rootTypes: any = {}; - visit( - ast, - visitWithTypeInfo(typeInfo, { - OperationDefinition(node) { - rootTypes[node.operation] = String(typeInfo.getType()); - }, - }), - ); - - expect(rootTypes).to.deep.equal({ - query: 'QueryRoot', - mutation: 'MutationRoot', - subscription: 'SubscriptionRoot', - }); - }); - - it('provide exact same arguments to wrapped visitor', () => { - const ast = parse( - '{ human(id: 4) { name, pets { ... { name } }, unknown } }', - ); - - const visitorArgs: Array = []; - visit(ast, { - enter(...args) { - visitorArgs.push(['enter', ...args]); - }, - leave(...args) { - visitorArgs.push(['leave', ...args]); - }, - }); - - const wrappedVisitorArgs: Array = []; - const typeInfo = new TypeInfo(testSchema); - visit( - ast, - visitWithTypeInfo(typeInfo, { - enter(...args) { - wrappedVisitorArgs.push(['enter', ...args]); - }, - leave(...args) { - wrappedVisitorArgs.push(['leave', ...args]); - }, - }), - ); - - expect(visitorArgs).to.deep.equal(wrappedVisitorArgs); - }); - - it('maintains type info during visit', () => { - const visited: Array = []; - - const typeInfo = new TypeInfo(testSchema); - - const ast = parse( - '{ human(id: 4) { name, pets { ... { name } }, unknown } }', - ); - - visit( - ast, - visitWithTypeInfo(typeInfo, { - enter(node) { - const parentType = typeInfo.getParentType(); - const type = typeInfo.getType(); - const inputType = typeInfo.getInputType(); - visited.push([ - 'enter', - node.kind, - node.kind === 'Name' ? node.value : null, - parentType ? String(parentType) : null, - type ? String(type) : null, - inputType ? String(inputType) : null, - ]); - }, - leave(node) { - const parentType = typeInfo.getParentType(); - const type = typeInfo.getType(); - const inputType = typeInfo.getInputType(); - visited.push([ - 'leave', - node.kind, - node.kind === 'Name' ? node.value : null, - parentType ? String(parentType) : null, - type ? String(type) : null, - inputType ? String(inputType) : null, - ]); - }, - }), - ); - - expect(visited).to.deep.equal([ - ['enter', 'Document', null, null, null, null], - ['enter', 'OperationDefinition', null, null, 'QueryRoot', null], - ['enter', 'SelectionSet', null, 'QueryRoot', 'QueryRoot', null], - ['enter', 'Field', null, 'QueryRoot', 'Human', null], - ['enter', 'Name', 'human', 'QueryRoot', 'Human', null], - ['leave', 'Name', 'human', 'QueryRoot', 'Human', null], - ['enter', 'Argument', null, 'QueryRoot', 'Human', 'ID'], - ['enter', 'Name', 'id', 'QueryRoot', 'Human', 'ID'], - ['leave', 'Name', 'id', 'QueryRoot', 'Human', 'ID'], - ['enter', 'IntValue', null, 'QueryRoot', 'Human', 'ID'], - ['leave', 'IntValue', null, 'QueryRoot', 'Human', 'ID'], - ['leave', 'Argument', null, 'QueryRoot', 'Human', 'ID'], - ['enter', 'SelectionSet', null, 'Human', 'Human', null], - ['enter', 'Field', null, 'Human', 'String', null], - ['enter', 'Name', 'name', 'Human', 'String', null], - ['leave', 'Name', 'name', 'Human', 'String', null], - ['leave', 'Field', null, 'Human', 'String', null], - ['enter', 'Field', null, 'Human', '[Pet]', null], - ['enter', 'Name', 'pets', 'Human', '[Pet]', null], - ['leave', 'Name', 'pets', 'Human', '[Pet]', null], - ['enter', 'SelectionSet', null, 'Pet', '[Pet]', null], - ['enter', 'InlineFragment', null, 'Pet', 'Pet', null], - ['enter', 'SelectionSet', null, 'Pet', 'Pet', null], - ['enter', 'Field', null, 'Pet', 'String', null], - ['enter', 'Name', 'name', 'Pet', 'String', null], - ['leave', 'Name', 'name', 'Pet', 'String', null], - ['leave', 'Field', null, 'Pet', 'String', null], - ['leave', 'SelectionSet', null, 'Pet', 'Pet', null], - ['leave', 'InlineFragment', null, 'Pet', 'Pet', null], - ['leave', 'SelectionSet', null, 'Pet', '[Pet]', null], - ['leave', 'Field', null, 'Human', '[Pet]', null], - ['enter', 'Field', null, 'Human', null, null], - ['enter', 'Name', 'unknown', 'Human', null, null], - ['leave', 'Name', 'unknown', 'Human', null, null], - ['leave', 'Field', null, 'Human', null, null], - ['leave', 'SelectionSet', null, 'Human', 'Human', null], - ['leave', 'Field', null, 'QueryRoot', 'Human', null], - ['leave', 'SelectionSet', null, 'QueryRoot', 'QueryRoot', null], - ['leave', 'OperationDefinition', null, null, 'QueryRoot', null], - ['leave', 'Document', null, null, null, null], - ]); - }); - - it('maintains type info during edit', () => { - const visited: Array = []; - const typeInfo = new TypeInfo(testSchema); - - const ast = parse('{ human(id: 4) { name, pets }, alien }'); - const editedAST = visit( - ast, - visitWithTypeInfo(typeInfo, { - enter(node) { - const parentType = typeInfo.getParentType(); - const type = typeInfo.getType(); - const inputType = typeInfo.getInputType(); - visited.push([ - 'enter', - node.kind, - node.kind === 'Name' ? node.value : null, - parentType ? String(parentType) : null, - type ? String(type) : null, - inputType ? String(inputType) : null, - ]); - - // Make a query valid by adding missing selection sets. - if ( - node.kind === 'Field' && - !node.selectionSet && - isCompositeType(getNamedType(type)) - ) { - return { - ...node, - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { kind: 'Name', value: '__typename' }, - }, - ], - }, - }; - } - }, - leave(node) { - const parentType = typeInfo.getParentType(); - const type = typeInfo.getType(); - const inputType = typeInfo.getInputType(); - visited.push([ - 'leave', - node.kind, - node.kind === 'Name' ? node.value : null, - parentType ? String(parentType) : null, - type ? String(type) : null, - inputType ? String(inputType) : null, - ]); - }, - }), - ); - - expect(print(ast)).to.deep.equal( - print(parse('{ human(id: 4) { name, pets }, alien }')), - ); - - expect(print(editedAST)).to.deep.equal( - print( - parse( - '{ human(id: 4) { name, pets { __typename } }, alien { __typename } }', - ), - ), - ); - - expect(visited).to.deep.equal([ - ['enter', 'Document', null, null, null, null], - ['enter', 'OperationDefinition', null, null, 'QueryRoot', null], - ['enter', 'SelectionSet', null, 'QueryRoot', 'QueryRoot', null], - ['enter', 'Field', null, 'QueryRoot', 'Human', null], - ['enter', 'Name', 'human', 'QueryRoot', 'Human', null], - ['leave', 'Name', 'human', 'QueryRoot', 'Human', null], - ['enter', 'Argument', null, 'QueryRoot', 'Human', 'ID'], - ['enter', 'Name', 'id', 'QueryRoot', 'Human', 'ID'], - ['leave', 'Name', 'id', 'QueryRoot', 'Human', 'ID'], - ['enter', 'IntValue', null, 'QueryRoot', 'Human', 'ID'], - ['leave', 'IntValue', null, 'QueryRoot', 'Human', 'ID'], - ['leave', 'Argument', null, 'QueryRoot', 'Human', 'ID'], - ['enter', 'SelectionSet', null, 'Human', 'Human', null], - ['enter', 'Field', null, 'Human', 'String', null], - ['enter', 'Name', 'name', 'Human', 'String', null], - ['leave', 'Name', 'name', 'Human', 'String', null], - ['leave', 'Field', null, 'Human', 'String', null], - ['enter', 'Field', null, 'Human', '[Pet]', null], - ['enter', 'Name', 'pets', 'Human', '[Pet]', null], - ['leave', 'Name', 'pets', 'Human', '[Pet]', null], - ['enter', 'SelectionSet', null, 'Pet', '[Pet]', null], - ['enter', 'Field', null, 'Pet', 'String!', null], - ['enter', 'Name', '__typename', 'Pet', 'String!', null], - ['leave', 'Name', '__typename', 'Pet', 'String!', null], - ['leave', 'Field', null, 'Pet', 'String!', null], - ['leave', 'SelectionSet', null, 'Pet', '[Pet]', null], - ['leave', 'Field', null, 'Human', '[Pet]', null], - ['leave', 'SelectionSet', null, 'Human', 'Human', null], - ['leave', 'Field', null, 'QueryRoot', 'Human', null], - ['enter', 'Field', null, 'QueryRoot', 'Alien', null], - ['enter', 'Name', 'alien', 'QueryRoot', 'Alien', null], - ['leave', 'Name', 'alien', 'QueryRoot', 'Alien', null], - ['enter', 'SelectionSet', null, 'Alien', 'Alien', null], - ['enter', 'Field', null, 'Alien', 'String!', null], - ['enter', 'Name', '__typename', 'Alien', 'String!', null], - ['leave', 'Name', '__typename', 'Alien', 'String!', null], - ['leave', 'Field', null, 'Alien', 'String!', null], - ['leave', 'SelectionSet', null, 'Alien', 'Alien', null], - ['leave', 'Field', null, 'QueryRoot', 'Alien', null], - ['leave', 'SelectionSet', null, 'QueryRoot', 'QueryRoot', null], - ['leave', 'OperationDefinition', null, null, 'QueryRoot', null], - ['leave', 'Document', null, null, null, null], - ]); - }); - - it('supports traversals of input values', () => { - const schema = buildSchema(` - input ComplexInput { - stringListField: [String] - } - `); - const ast = parseValue('{ stringListField: ["foo"] }'); - const complexInputType = schema.getType('ComplexInput'); - invariant(complexInputType != null); - - const typeInfo = new TypeInfo(schema, complexInputType); - - const visited: Array = []; - visit( - ast, - visitWithTypeInfo(typeInfo, { - enter(node) { - const type = typeInfo.getInputType(); - visited.push([ - 'enter', - node.kind, - node.kind === 'Name' ? node.value : null, - String(type), - ]); - }, - leave(node) { - const type = typeInfo.getInputType(); - visited.push([ - 'leave', - node.kind, - node.kind === 'Name' ? node.value : null, - String(type), - ]); - }, - }), - ); - - expect(visited).to.deep.equal([ - ['enter', 'ObjectValue', null, 'ComplexInput'], - ['enter', 'ObjectField', null, '[String]'], - ['enter', 'Name', 'stringListField', '[String]'], - ['leave', 'Name', 'stringListField', '[String]'], - ['enter', 'ListValue', null, 'String'], - ['enter', 'StringValue', null, 'String'], - ['leave', 'StringValue', null, 'String'], - ['leave', 'ListValue', null, 'String'], - ['leave', 'ObjectField', null, '[String]'], - ['leave', 'ObjectValue', null, 'ComplexInput'], - ]); - }); - - it('supports traversals of selection sets', () => { - const humanType = testSchema.getType('Human'); - invariant(humanType != null); - - const typeInfo = new TypeInfo(testSchema, humanType); - - const ast = parse('{ name, pets { name } }'); - const operationNode = ast.definitions[0]; - invariant(operationNode.kind === 'OperationDefinition'); - - const visited: Array = []; - visit( - operationNode.selectionSet, - visitWithTypeInfo(typeInfo, { - enter(node) { - const parentType = typeInfo.getParentType(); - const type = typeInfo.getType(); - visited.push([ - 'enter', - node.kind, - node.kind === 'Name' ? node.value : null, - String(parentType), - String(type), - ]); - }, - leave(node) { - const parentType = typeInfo.getParentType(); - const type = typeInfo.getType(); - visited.push([ - 'leave', - node.kind, - node.kind === 'Name' ? node.value : null, - String(parentType), - String(type), - ]); - }, - }), - ); - - expect(visited).to.deep.equal([ - ['enter', 'SelectionSet', null, 'Human', 'Human'], - ['enter', 'Field', null, 'Human', 'String'], - ['enter', 'Name', 'name', 'Human', 'String'], - ['leave', 'Name', 'name', 'Human', 'String'], - ['leave', 'Field', null, 'Human', 'String'], - ['enter', 'Field', null, 'Human', '[Pet]'], - ['enter', 'Name', 'pets', 'Human', '[Pet]'], - ['leave', 'Name', 'pets', 'Human', '[Pet]'], - ['enter', 'SelectionSet', null, 'Pet', '[Pet]'], - ['enter', 'Field', null, 'Pet', 'String'], - ['enter', 'Name', 'name', 'Pet', 'String'], - ['leave', 'Name', 'name', 'Pet', 'String'], - ['leave', 'Field', null, 'Pet', 'String'], - ['leave', 'SelectionSet', null, 'Pet', '[Pet]'], - ['leave', 'Field', null, 'Human', '[Pet]'], - ['leave', 'SelectionSet', null, 'Human', 'Human'], - ]); - }); -}); diff --git a/src/utilities/__tests__/astFromValue-test.ts b/src/utilities/__tests__/astFromValue-test.ts deleted file mode 100644 index b8f2361bd7..0000000000 --- a/src/utilities/__tests__/astFromValue-test.ts +++ /dev/null @@ -1,379 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLList, - GraphQLNonNull, - GraphQLScalarType, -} from '../../type/definition'; -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLID, - GraphQLInt, - GraphQLString, -} from '../../type/scalars'; - -import { astFromValue } from '../astFromValue'; - -describe('astFromValue', () => { - it('converts boolean values to ASTs', () => { - expect(astFromValue(true, GraphQLBoolean)).to.deep.equal({ - kind: 'BooleanValue', - value: true, - }); - - expect(astFromValue(false, GraphQLBoolean)).to.deep.equal({ - kind: 'BooleanValue', - value: false, - }); - - expect(astFromValue(undefined, GraphQLBoolean)).to.deep.equal(null); - - expect(astFromValue(null, GraphQLBoolean)).to.deep.equal({ - kind: 'NullValue', - }); - - expect(astFromValue(0, GraphQLBoolean)).to.deep.equal({ - kind: 'BooleanValue', - value: false, - }); - - expect(astFromValue(1, GraphQLBoolean)).to.deep.equal({ - kind: 'BooleanValue', - value: true, - }); - - const NonNullBoolean = new GraphQLNonNull(GraphQLBoolean); - expect(astFromValue(0, NonNullBoolean)).to.deep.equal({ - kind: 'BooleanValue', - value: false, - }); - }); - - it('converts Int values to Int ASTs', () => { - expect(astFromValue(-1, GraphQLInt)).to.deep.equal({ - kind: 'IntValue', - value: '-1', - }); - - expect(astFromValue(123.0, GraphQLInt)).to.deep.equal({ - kind: 'IntValue', - value: '123', - }); - - expect(astFromValue(1e4, GraphQLInt)).to.deep.equal({ - kind: 'IntValue', - value: '10000', - }); - - // GraphQL spec does not allow coercing non-integer values to Int to avoid - // accidental data loss. - expect(() => astFromValue(123.5, GraphQLInt)).to.throw( - 'Int cannot represent non-integer value: 123.5', - ); - - // Note: outside the bounds of 32bit signed int. - expect(() => astFromValue(1e40, GraphQLInt)).to.throw( - 'Int cannot represent non 32-bit signed integer value: 1e+40', - ); - - expect(() => astFromValue(NaN, GraphQLInt)).to.throw( - 'Int cannot represent non-integer value: NaN', - ); - }); - - it('converts Float values to Int/Float ASTs', () => { - expect(astFromValue(-1, GraphQLFloat)).to.deep.equal({ - kind: 'IntValue', - value: '-1', - }); - - expect(astFromValue(123.0, GraphQLFloat)).to.deep.equal({ - kind: 'IntValue', - value: '123', - }); - - expect(astFromValue(123.5, GraphQLFloat)).to.deep.equal({ - kind: 'FloatValue', - value: '123.5', - }); - - expect(astFromValue(1e4, GraphQLFloat)).to.deep.equal({ - kind: 'IntValue', - value: '10000', - }); - - expect(astFromValue(1e40, GraphQLFloat)).to.deep.equal({ - kind: 'FloatValue', - value: '1e+40', - }); - }); - - it('converts String values to String ASTs', () => { - expect(astFromValue('hello', GraphQLString)).to.deep.equal({ - kind: 'StringValue', - value: 'hello', - }); - - expect(astFromValue('VALUE', GraphQLString)).to.deep.equal({ - kind: 'StringValue', - value: 'VALUE', - }); - - expect(astFromValue('VA\nLUE', GraphQLString)).to.deep.equal({ - kind: 'StringValue', - value: 'VA\nLUE', - }); - - expect(astFromValue(123, GraphQLString)).to.deep.equal({ - kind: 'StringValue', - value: '123', - }); - - expect(astFromValue(false, GraphQLString)).to.deep.equal({ - kind: 'StringValue', - value: 'false', - }); - - expect(astFromValue(null, GraphQLString)).to.deep.equal({ - kind: 'NullValue', - }); - - expect(astFromValue(undefined, GraphQLString)).to.deep.equal(null); - }); - - it('converts ID values to Int/String ASTs', () => { - expect(astFromValue('hello', GraphQLID)).to.deep.equal({ - kind: 'StringValue', - value: 'hello', - }); - - expect(astFromValue('VALUE', GraphQLID)).to.deep.equal({ - kind: 'StringValue', - value: 'VALUE', - }); - - // Note: EnumValues cannot contain non-identifier characters - expect(astFromValue('VA\nLUE', GraphQLID)).to.deep.equal({ - kind: 'StringValue', - value: 'VA\nLUE', - }); - - // Note: IntValues are used when possible. - expect(astFromValue(-1, GraphQLID)).to.deep.equal({ - kind: 'IntValue', - value: '-1', - }); - - expect(astFromValue(123, GraphQLID)).to.deep.equal({ - kind: 'IntValue', - value: '123', - }); - - expect(astFromValue('123', GraphQLID)).to.deep.equal({ - kind: 'IntValue', - value: '123', - }); - - expect(astFromValue('01', GraphQLID)).to.deep.equal({ - kind: 'StringValue', - value: '01', - }); - - expect(() => astFromValue(false, GraphQLID)).to.throw( - 'ID cannot represent value: false', - ); - - expect(astFromValue(null, GraphQLID)).to.deep.equal({ kind: 'NullValue' }); - - expect(astFromValue(undefined, GraphQLID)).to.deep.equal(null); - }); - - it('converts using serialize from a custom scalar type', () => { - const passthroughScalar = new GraphQLScalarType({ - name: 'PassthroughScalar', - serialize(value) { - return value; - }, - }); - - expect(astFromValue('value', passthroughScalar)).to.deep.equal({ - kind: 'StringValue', - value: 'value', - }); - - expect(() => astFromValue(NaN, passthroughScalar)).to.throw( - 'Cannot convert value to AST: NaN.', - ); - expect(() => astFromValue(Infinity, passthroughScalar)).to.throw( - 'Cannot convert value to AST: Infinity.', - ); - - const returnNullScalar = new GraphQLScalarType({ - name: 'ReturnNullScalar', - serialize() { - return null; - }, - }); - - expect(astFromValue('value', returnNullScalar)).to.equal(null); - - class SomeClass {} - - const returnCustomClassScalar = new GraphQLScalarType({ - name: 'ReturnCustomClassScalar', - serialize() { - return new SomeClass(); - }, - }); - - expect(() => astFromValue('value', returnCustomClassScalar)).to.throw( - 'Cannot convert value to AST: {}.', - ); - }); - - it('does not converts NonNull values to NullValue', () => { - const NonNullBoolean = new GraphQLNonNull(GraphQLBoolean); - expect(astFromValue(null, NonNullBoolean)).to.deep.equal(null); - }); - - const complexValue = { someArbitrary: 'complexValue' }; - - const myEnum = new GraphQLEnumType({ - name: 'MyEnum', - values: { - HELLO: {}, - GOODBYE: {}, - COMPLEX: { value: complexValue }, - }, - }); - - it('converts string values to Enum ASTs if possible', () => { - expect(astFromValue('HELLO', myEnum)).to.deep.equal({ - kind: 'EnumValue', - value: 'HELLO', - }); - - expect(astFromValue(complexValue, myEnum)).to.deep.equal({ - kind: 'EnumValue', - value: 'COMPLEX', - }); - - // Note: case sensitive - expect(() => astFromValue('hello', myEnum)).to.throw( - 'Enum "MyEnum" cannot represent value: "hello"', - ); - - // Note: Not a valid enum value - expect(() => astFromValue('UNKNOWN_VALUE', myEnum)).to.throw( - 'Enum "MyEnum" cannot represent value: "UNKNOWN_VALUE"', - ); - }); - - it('converts array values to List ASTs', () => { - expect( - astFromValue(['FOO', 'BAR'], new GraphQLList(GraphQLString)), - ).to.deep.equal({ - kind: 'ListValue', - values: [ - { kind: 'StringValue', value: 'FOO' }, - { kind: 'StringValue', value: 'BAR' }, - ], - }); - - expect( - astFromValue(['HELLO', 'GOODBYE'], new GraphQLList(myEnum)), - ).to.deep.equal({ - kind: 'ListValue', - values: [ - { kind: 'EnumValue', value: 'HELLO' }, - { kind: 'EnumValue', value: 'GOODBYE' }, - ], - }); - - function* listGenerator() { - yield 1; - yield 2; - yield 3; - } - - expect( - astFromValue(listGenerator(), new GraphQLList(GraphQLInt)), - ).to.deep.equal({ - kind: 'ListValue', - values: [ - { kind: 'IntValue', value: '1' }, - { kind: 'IntValue', value: '2' }, - { kind: 'IntValue', value: '3' }, - ], - }); - }); - - it('converts list singletons', () => { - expect(astFromValue('FOO', new GraphQLList(GraphQLString))).to.deep.equal({ - kind: 'StringValue', - value: 'FOO', - }); - }); - - it('skip invalid list items', () => { - const ast = astFromValue( - ['FOO', null, 'BAR'], - new GraphQLList(new GraphQLNonNull(GraphQLString)), - ); - - expect(ast).to.deep.equal({ - kind: 'ListValue', - values: [ - { kind: 'StringValue', value: 'FOO' }, - { kind: 'StringValue', value: 'BAR' }, - ], - }); - }); - - const inputObj = new GraphQLInputObjectType({ - name: 'MyInputObj', - fields: { - foo: { type: GraphQLFloat }, - bar: { type: myEnum }, - }, - }); - - it('converts input objects', () => { - expect(astFromValue({ foo: 3, bar: 'HELLO' }, inputObj)).to.deep.equal({ - kind: 'ObjectValue', - fields: [ - { - kind: 'ObjectField', - name: { kind: 'Name', value: 'foo' }, - value: { kind: 'IntValue', value: '3' }, - }, - { - kind: 'ObjectField', - name: { kind: 'Name', value: 'bar' }, - value: { kind: 'EnumValue', value: 'HELLO' }, - }, - ], - }); - }); - - it('converts input objects with explicit nulls', () => { - expect(astFromValue({ foo: null }, inputObj)).to.deep.equal({ - kind: 'ObjectValue', - fields: [ - { - kind: 'ObjectField', - name: { kind: 'Name', value: 'foo' }, - value: { kind: 'NullValue' }, - }, - ], - }); - }); - - it('does not converts non-object values as input objects', () => { - expect(astFromValue(5, inputObj)).to.equal(null); - }); -}); diff --git a/src/utilities/__tests__/buildASTSchema-test.ts b/src/utilities/__tests__/buildASTSchema-test.ts deleted file mode 100644 index 29280474ec..0000000000 --- a/src/utilities/__tests__/buildASTSchema-test.ts +++ /dev/null @@ -1,1113 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { invariant } from '../../jsutils/invariant'; -import type { Maybe } from '../../jsutils/Maybe'; - -import type { ASTNode } from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import { parse } from '../../language/parser'; -import { print } from '../../language/printer'; - -import { - assertEnumType, - assertInputObjectType, - assertInterfaceType, - assertObjectType, - assertScalarType, - assertUnionType, -} from '../../type/definition'; -import { - assertDirective, - GraphQLDeprecatedDirective, - GraphQLIncludeDirective, - GraphQLOneOfDirective, - GraphQLSkipDirective, - GraphQLSpecifiedByDirective, -} from '../../type/directives'; -import { __EnumValue, __Schema } from '../../type/introspection'; -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLID, - GraphQLInt, - GraphQLString, -} from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; -import { validateSchema } from '../../type/validate'; - -import { graphqlSync } from '../../graphql'; - -import { buildASTSchema, buildSchema } from '../buildASTSchema'; -import { printSchema, printType } from '../printSchema'; - -/** - * This function does a full cycle of going from a string with the contents of - * the SDL, parsed in a schema AST, materializing that schema AST into an - * in-memory GraphQLSchema, and then finally printing that object into the SDL - */ -function cycleSDL(sdl: string): string { - return printSchema(buildSchema(sdl)); -} - -function expectASTNode(obj: Maybe<{ readonly astNode: Maybe }>) { - invariant(obj?.astNode != null); - return expect(print(obj.astNode)); -} - -function expectExtensionASTNodes(obj: { - readonly extensionASTNodes: ReadonlyArray; -}) { - return expect(obj.extensionASTNodes.map(print).join('\n\n')); -} - -describe('Schema Builder', () => { - it('can use built schema for limited execution', () => { - const schema = buildASTSchema( - parse(` - type Query { - str: String - } - `), - ); - - const result = graphqlSync({ - schema, - source: '{ str }', - rootValue: { str: 123 }, - }); - expect(result.data).to.deep.equal({ str: '123' }); - }); - - it('can build a schema directly from the source', () => { - const schema = buildSchema(` - type Query { - add(x: Int, y: Int): Int - } - `); - - const source = '{ add(x: 34, y: 55) }'; - const rootValue = { - add: ({ x, y }: { x: number; y: number }) => x + y, - }; - expect(graphqlSync({ schema, source, rootValue })).to.deep.equal({ - data: { add: 89 }, - }); - }); - - it('Ignores non-type system definitions', () => { - const sdl = ` - type Query { - str: String - } - - fragment SomeFragment on Query { - str - } - `; - expect(() => buildSchema(sdl)).to.not.throw(); - }); - - it('Match order of default types and directives', () => { - const schema = new GraphQLSchema({}); - const sdlSchema = buildASTSchema({ - kind: Kind.DOCUMENT, - definitions: [], - }); - - expect(sdlSchema.getDirectives()).to.deep.equal(schema.getDirectives()); - - expect(sdlSchema.getTypeMap()).to.deep.equal(schema.getTypeMap()); - expect(Object.keys(sdlSchema.getTypeMap())).to.deep.equal( - Object.keys(schema.getTypeMap()), - ); - }); - - it('Empty type', () => { - const sdl = dedent` - type EmptyType - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple type', () => { - const sdl = dedent` - type Query { - str: String - int: Int - float: Float - id: ID - bool: Boolean - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - - const schema = buildSchema(sdl); - // Built-ins are used - expect(schema.getType('Int')).to.equal(GraphQLInt); - expect(schema.getType('Float')).to.equal(GraphQLFloat); - expect(schema.getType('String')).to.equal(GraphQLString); - expect(schema.getType('Boolean')).to.equal(GraphQLBoolean); - expect(schema.getType('ID')).to.equal(GraphQLID); - }); - - it('include standard type only if it is used', () => { - const schema = buildSchema('type Query'); - - // String and Boolean are always included through introspection types - expect(schema.getType('Int')).to.equal(undefined); - expect(schema.getType('Float')).to.equal(undefined); - expect(schema.getType('ID')).to.equal(undefined); - }); - - it('With directives', () => { - const sdl = dedent` - directive @foo(arg: Int) on FIELD - - directive @repeatableFoo(arg: Int) repeatable on FIELD - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Supports descriptions', () => { - const sdl = dedent` - """Do you agree that this is the most creative schema ever?""" - schema { - query: Query - } - - """This is a directive""" - directive @foo( - """It has an argument""" - arg: Int - ) on FIELD - - """Who knows what inside this scalar?""" - scalar MysteryScalar - - """This is a input object type""" - input FooInput { - """It has a field""" - field: Int - } - - """This is a interface type""" - interface Energy { - """It also has a field""" - str: String - } - - """There is nothing inside!""" - union BlackHole - - """With an enum""" - enum Color { - RED - - """Not a creative color""" - GREEN - BLUE - } - - """What a great type""" - type Query { - """And a field to boot""" - str: String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Maintains @include, @skip & @specifiedBy', () => { - const schema = buildSchema('type Query'); - - expect(schema.getDirectives()).to.have.lengthOf(5); - expect(schema.getDirective('skip')).to.equal(GraphQLSkipDirective); - expect(schema.getDirective('include')).to.equal(GraphQLIncludeDirective); - expect(schema.getDirective('deprecated')).to.equal( - GraphQLDeprecatedDirective, - ); - expect(schema.getDirective('specifiedBy')).to.equal( - GraphQLSpecifiedByDirective, - ); - expect(schema.getDirective('oneOf')).to.equal(GraphQLOneOfDirective); - }); - - it('Overriding directives excludes specified', () => { - const schema = buildSchema(` - directive @skip on FIELD - directive @include on FIELD - directive @deprecated on FIELD_DEFINITION - directive @specifiedBy on FIELD_DEFINITION - directive @oneOf on OBJECT - `); - - expect(schema.getDirectives()).to.have.lengthOf(5); - expect(schema.getDirective('skip')).to.not.equal(GraphQLSkipDirective); - expect(schema.getDirective('include')).to.not.equal( - GraphQLIncludeDirective, - ); - expect(schema.getDirective('deprecated')).to.not.equal( - GraphQLDeprecatedDirective, - ); - expect(schema.getDirective('specifiedBy')).to.not.equal( - GraphQLSpecifiedByDirective, - ); - expect(schema.getDirective('oneOf')).to.not.equal(GraphQLOneOfDirective); - }); - - it('Adding directives maintains @include, @skip, @deprecated, @specifiedBy, and @oneOf', () => { - const schema = buildSchema(` - directive @foo(arg: Int) on FIELD - `); - - expect(schema.getDirectives()).to.have.lengthOf(6); - expect(schema.getDirective('skip')).to.not.equal(undefined); - expect(schema.getDirective('include')).to.not.equal(undefined); - expect(schema.getDirective('deprecated')).to.not.equal(undefined); - expect(schema.getDirective('specifiedBy')).to.not.equal(undefined); - expect(schema.getDirective('oneOf')).to.not.equal(undefined); - }); - - it('Type modifiers', () => { - const sdl = dedent` - type Query { - nonNullStr: String! - listOfStrings: [String] - listOfNonNullStrings: [String!] - nonNullListOfStrings: [String]! - nonNullListOfNonNullStrings: [String!]! - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Recursive type', () => { - const sdl = dedent` - type Query { - str: String - recurse: Query - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Two types circular', () => { - const sdl = dedent` - type TypeOne { - str: String - typeTwo: TypeTwo - } - - type TypeTwo { - str: String - typeOne: TypeOne - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Single argument field', () => { - const sdl = dedent` - type Query { - str(int: Int): String - floatToStr(float: Float): String - idToStr(id: ID): String - booleanToStr(bool: Boolean): String - strToStr(bool: String): String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple type with multiple arguments', () => { - const sdl = dedent` - type Query { - str(int: Int, bool: Boolean): String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Empty interface', () => { - const sdl = dedent` - interface EmptyInterface - `; - - const definition = parse(sdl).definitions[0]; - expect( - definition.kind === 'InterfaceTypeDefinition' && definition.interfaces, - ).to.deep.equal([], 'The interfaces property must be an empty array.'); - - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple type with interface', () => { - const sdl = dedent` - type Query implements WorldInterface { - str: String - } - - interface WorldInterface { - str: String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple interface hierarchy', () => { - const sdl = dedent` - schema { - query: Child - } - - interface Child implements Parent { - str: String - } - - type Hello implements Parent & Child { - str: String - } - - interface Parent { - str: String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Empty enum', () => { - const sdl = dedent` - enum EmptyEnum - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple output enum', () => { - const sdl = dedent` - enum Hello { - WORLD - } - - type Query { - hello: Hello - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple input enum', () => { - const sdl = dedent` - enum Hello { - WORLD - } - - type Query { - str(hello: Hello): String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Multiple value enum', () => { - const sdl = dedent` - enum Hello { - WO - RLD - } - - type Query { - hello: Hello - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Empty union', () => { - const sdl = dedent` - union EmptyUnion - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple Union', () => { - const sdl = dedent` - union Hello = World - - type Query { - hello: Hello - } - - type World { - str: String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Multiple Union', () => { - const sdl = dedent` - union Hello = WorldOne | WorldTwo - - type Query { - hello: Hello - } - - type WorldOne { - str: String - } - - type WorldTwo { - str: String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Can build recursive Union', () => { - const schema = buildSchema(` - union Hello = Hello - - type Query { - hello: Hello - } - `); - const errors = validateSchema(schema); - expect(errors).to.have.lengthOf.above(0); - }); - - it('Custom Scalar', () => { - const sdl = dedent` - scalar CustomScalar - - type Query { - customScalar: CustomScalar - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Empty Input Object', () => { - const sdl = dedent` - input EmptyInputObject - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple Input Object', () => { - const sdl = dedent` - input Input { - int: Int - } - - type Query { - field(in: Input): String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple argument field with default', () => { - const sdl = dedent` - type Query { - str(int: Int = 2): String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Custom scalar argument field with default', () => { - const sdl = dedent` - scalar CustomScalar - - type Query { - str(int: CustomScalar = 2): String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple type with mutation', () => { - const sdl = dedent` - schema { - query: HelloScalars - mutation: Mutation - } - - type HelloScalars { - str: String - int: Int - bool: Boolean - } - - type Mutation { - addHelloScalars(str: String, int: Int, bool: Boolean): HelloScalars - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Simple type with subscription', () => { - const sdl = dedent` - schema { - query: HelloScalars - subscription: Subscription - } - - type HelloScalars { - str: String - int: Int - bool: Boolean - } - - type Subscription { - subscribeHelloScalars(str: String, int: Int, bool: Boolean): HelloScalars - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Unreferenced type implementing referenced interface', () => { - const sdl = dedent` - type Concrete implements Interface { - key: String - } - - interface Interface { - key: String - } - - type Query { - interface: Interface - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Unreferenced interface implementing referenced interface', () => { - const sdl = dedent` - interface Child implements Parent { - key: String - } - - interface Parent { - key: String - } - - type Query { - interfaceField: Parent - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Unreferenced type implementing referenced union', () => { - const sdl = dedent` - type Concrete { - key: String - } - - type Query { - union: Union - } - - union Union = Concrete - `; - expect(cycleSDL(sdl)).to.equal(sdl); - }); - - it('Supports @deprecated', () => { - const sdl = dedent` - enum MyEnum { - VALUE - OLD_VALUE @deprecated - OTHER_VALUE @deprecated(reason: "Terrible reasons") - } - - input MyInput { - oldInput: String @deprecated - otherInput: String @deprecated(reason: "Use newInput") - newInput: String - } - - type Query { - field1: String @deprecated - field2: Int @deprecated(reason: "Because I said so") - enum: MyEnum - field3(oldArg: String @deprecated, arg: String): String - field4(oldArg: String @deprecated(reason: "Why not?"), arg: String): String - field5(arg: MyInput): String - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - - const schema = buildSchema(sdl); - - const myEnum = assertEnumType(schema.getType('MyEnum')); - - const value = myEnum.getValue('VALUE'); - expect(value).to.include({ deprecationReason: undefined }); - - const oldValue = myEnum.getValue('OLD_VALUE'); - expect(oldValue).to.include({ - deprecationReason: 'No longer supported', - }); - - const otherValue = myEnum.getValue('OTHER_VALUE'); - expect(otherValue).to.include({ - deprecationReason: 'Terrible reasons', - }); - - const rootFields = assertObjectType(schema.getType('Query')).getFields(); - expect(rootFields.field1).to.include({ - deprecationReason: 'No longer supported', - }); - expect(rootFields.field2).to.include({ - deprecationReason: 'Because I said so', - }); - - const inputFields = assertInputObjectType( - schema.getType('MyInput'), - ).getFields(); - - const newInput = inputFields.newInput; - expect(newInput).to.include({ - deprecationReason: undefined, - }); - - const oldInput = inputFields.oldInput; - expect(oldInput).to.include({ - deprecationReason: 'No longer supported', - }); - - const otherInput = inputFields.otherInput; - expect(otherInput).to.include({ - deprecationReason: 'Use newInput', - }); - - const field3OldArg = rootFields.field3.args[0]; - expect(field3OldArg).to.include({ - deprecationReason: 'No longer supported', - }); - - const field4OldArg = rootFields.field4.args[0]; - expect(field4OldArg).to.include({ - deprecationReason: 'Why not?', - }); - }); - - it('Supports @specifiedBy', () => { - const sdl = dedent` - scalar Foo @specifiedBy(url: "https://example.com/foo_spec") - - type Query { - foo: Foo @deprecated - } - `; - expect(cycleSDL(sdl)).to.equal(sdl); - - const schema = buildSchema(sdl); - - expect(schema.getType('Foo')).to.include({ - specifiedByURL: 'https://example.com/foo_spec', - }); - }); - - it('Correctly extend scalar type', () => { - const schema = buildSchema(` - scalar SomeScalar - extend scalar SomeScalar @foo - extend scalar SomeScalar @bar - - directive @foo on SCALAR - directive @bar on SCALAR - `); - - const someScalar = assertScalarType(schema.getType('SomeScalar')); - expect(printType(someScalar)).to.equal(dedent` - scalar SomeScalar - `); - - expectASTNode(someScalar).to.equal('scalar SomeScalar'); - expectExtensionASTNodes(someScalar).to.equal(dedent` - extend scalar SomeScalar @foo - - extend scalar SomeScalar @bar - `); - }); - - it('Correctly extend object type', () => { - const schema = buildSchema(` - type SomeObject implements Foo { - first: String - } - - extend type SomeObject implements Bar { - second: Int - } - - extend type SomeObject implements Baz { - third: Float - } - - interface Foo - interface Bar - interface Baz - `); - - const someObject = assertObjectType(schema.getType('SomeObject')); - expect(printType(someObject)).to.equal(dedent` - type SomeObject implements Foo & Bar & Baz { - first: String - second: Int - third: Float - } - `); - - expectASTNode(someObject).to.equal(dedent` - type SomeObject implements Foo { - first: String - } - `); - expectExtensionASTNodes(someObject).to.equal(dedent` - extend type SomeObject implements Bar { - second: Int - } - - extend type SomeObject implements Baz { - third: Float - } - `); - }); - - it('Correctly extend interface type', () => { - const schema = buildSchema(dedent` - interface SomeInterface { - first: String - } - - extend interface SomeInterface { - second: Int - } - - extend interface SomeInterface { - third: Float - } - `); - - const someInterface = assertInterfaceType(schema.getType('SomeInterface')); - expect(printType(someInterface)).to.equal(dedent` - interface SomeInterface { - first: String - second: Int - third: Float - } - `); - - expectASTNode(someInterface).to.equal(dedent` - interface SomeInterface { - first: String - } - `); - expectExtensionASTNodes(someInterface).to.equal(dedent` - extend interface SomeInterface { - second: Int - } - - extend interface SomeInterface { - third: Float - } - `); - }); - - it('Correctly extend union type', () => { - const schema = buildSchema(` - union SomeUnion = FirstType - extend union SomeUnion = SecondType - extend union SomeUnion = ThirdType - - type FirstType - type SecondType - type ThirdType - `); - - const someUnion = assertUnionType(schema.getType('SomeUnion')); - expect(printType(someUnion)).to.equal(dedent` - union SomeUnion = FirstType | SecondType | ThirdType - `); - - expectASTNode(someUnion).to.equal('union SomeUnion = FirstType'); - expectExtensionASTNodes(someUnion).to.equal(dedent` - extend union SomeUnion = SecondType - - extend union SomeUnion = ThirdType - `); - }); - - it('Correctly extend enum type', () => { - const schema = buildSchema(dedent` - enum SomeEnum { - FIRST - } - - extend enum SomeEnum { - SECOND - } - - extend enum SomeEnum { - THIRD - } - `); - - const someEnum = assertEnumType(schema.getType('SomeEnum')); - expect(printType(someEnum)).to.equal(dedent` - enum SomeEnum { - FIRST - SECOND - THIRD - } - `); - - expectASTNode(someEnum).to.equal(dedent` - enum SomeEnum { - FIRST - } - `); - expectExtensionASTNodes(someEnum).to.equal(dedent` - extend enum SomeEnum { - SECOND - } - - extend enum SomeEnum { - THIRD - } - `); - }); - - it('Correctly extend input object type', () => { - const schema = buildSchema(dedent` - input SomeInput { - first: String - } - - extend input SomeInput { - second: Int - } - - extend input SomeInput { - third: Float - } - `); - - const someInput = assertInputObjectType(schema.getType('SomeInput')); - expect(printType(someInput)).to.equal(dedent` - input SomeInput { - first: String - second: Int - third: Float - } - `); - - expectASTNode(someInput).to.equal(dedent` - input SomeInput { - first: String - } - `); - expectExtensionASTNodes(someInput).to.equal(dedent` - extend input SomeInput { - second: Int - } - - extend input SomeInput { - third: Float - } - `); - }); - - it('Correctly assign AST nodes', () => { - const sdl = dedent` - schema { - query: Query - } - - type Query { - testField(testArg: TestInput): TestUnion - } - - input TestInput { - testInputField: TestEnum - } - - enum TestEnum { - TEST_VALUE - } - - union TestUnion = TestType - - interface TestInterface { - interfaceField: String - } - - type TestType implements TestInterface { - interfaceField: String - } - - scalar TestScalar - - directive @test(arg: TestScalar) on FIELD - `; - const ast = parse(sdl, { noLocation: true }); - - const schema = buildASTSchema(ast); - const query = assertObjectType(schema.getType('Query')); - const testInput = assertInputObjectType(schema.getType('TestInput')); - const testEnum = assertEnumType(schema.getType('TestEnum')); - const testUnion = assertUnionType(schema.getType('TestUnion')); - const testInterface = assertInterfaceType(schema.getType('TestInterface')); - const testType = assertObjectType(schema.getType('TestType')); - const testScalar = assertScalarType(schema.getType('TestScalar')); - const testDirective = assertDirective(schema.getDirective('test')); - - expect([ - schema.astNode, - query.astNode, - testInput.astNode, - testEnum.astNode, - testUnion.astNode, - testInterface.astNode, - testType.astNode, - testScalar.astNode, - testDirective.astNode, - ]).to.be.deep.equal(ast.definitions); - - const testField = query.getFields().testField; - expectASTNode(testField).to.equal( - 'testField(testArg: TestInput): TestUnion', - ); - expectASTNode(testField.args[0]).to.equal('testArg: TestInput'); - expectASTNode(testInput.getFields().testInputField).to.equal( - 'testInputField: TestEnum', - ); - - expectASTNode(testEnum.getValue('TEST_VALUE')).to.equal('TEST_VALUE'); - - expectASTNode(testInterface.getFields().interfaceField).to.equal( - 'interfaceField: String', - ); - expectASTNode(testType.getFields().interfaceField).to.equal( - 'interfaceField: String', - ); - expectASTNode(testDirective.args[0]).to.equal('arg: TestScalar'); - }); - - it('Root operation types with custom names', () => { - const schema = buildSchema(` - schema { - query: SomeQuery - mutation: SomeMutation - subscription: SomeSubscription - } - type SomeQuery - type SomeMutation - type SomeSubscription - `); - - expect(schema.getQueryType()).to.include({ name: 'SomeQuery' }); - expect(schema.getMutationType()).to.include({ name: 'SomeMutation' }); - expect(schema.getSubscriptionType()).to.include({ - name: 'SomeSubscription', - }); - }); - - it('Default root operation type names', () => { - const schema = buildSchema(` - type Query - type Mutation - type Subscription - `); - - expect(schema.getQueryType()).to.include({ name: 'Query' }); - expect(schema.getMutationType()).to.include({ name: 'Mutation' }); - expect(schema.getSubscriptionType()).to.include({ name: 'Subscription' }); - }); - - it('can build invalid schema', () => { - // Invalid schema, because it is missing query root type - const schema = buildSchema('type Mutation'); - const errors = validateSchema(schema); - expect(errors).to.have.lengthOf.above(0); - }); - - it('Do not override standard types', () => { - // NOTE: not sure it's desired behavior to just silently ignore override - // attempts so just documenting it here. - - const schema = buildSchema(` - scalar ID - - scalar __Schema - `); - - expect(schema.getType('ID')).to.equal(GraphQLID); - expect(schema.getType('__Schema')).to.equal(__Schema); - }); - - it('Allows to reference introspection types', () => { - const schema = buildSchema(` - type Query { - introspectionField: __EnumValue - } - `); - - const queryType = assertObjectType(schema.getType('Query')); - expect(queryType.getFields()).to.have.nested.property( - 'introspectionField.type', - __EnumValue, - ); - expect(schema.getType('__EnumValue')).to.equal(__EnumValue); - }); - - it('Rejects invalid SDL', () => { - const sdl = ` - type Query { - foo: String @unknown - } - `; - expect(() => buildSchema(sdl)).to.throw('Unknown directive "@unknown".'); - }); - - it('Allows to disable SDL validation', () => { - const sdl = ` - type Query { - foo: String @unknown - } - `; - buildSchema(sdl, { assumeValid: true }); - buildSchema(sdl, { assumeValidSDL: true }); - }); - - it('Throws on unknown types', () => { - const sdl = ` - type Query { - unknown: UnknownType - } - `; - expect(() => buildSchema(sdl, { assumeValidSDL: true })).to.throw( - 'Unknown type: "UnknownType".', - ); - }); - - it('Rejects invalid AST', () => { - // @ts-expect-error (First parameter expected to be DocumentNode) - expect(() => buildASTSchema(null)).to.throw( - 'Must provide valid Document AST', - ); - - // @ts-expect-error - expect(() => buildASTSchema({})).to.throw( - 'Must provide valid Document AST', - ); - }); -}); diff --git a/src/utilities/__tests__/buildClientSchema-test.ts b/src/utilities/__tests__/buildClientSchema-test.ts deleted file mode 100644 index e8cf046921..0000000000 --- a/src/utilities/__tests__/buildClientSchema-test.ts +++ /dev/null @@ -1,986 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { invariant } from '../../jsutils/invariant'; - -import { - assertEnumType, - GraphQLEnumType, - GraphQLObjectType, -} from '../../type/definition'; -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLID, - GraphQLInt, - GraphQLString, -} from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { graphqlSync } from '../../graphql'; - -import { buildSchema } from '../buildASTSchema'; -import { buildClientSchema } from '../buildClientSchema'; -import { introspectionFromSchema } from '../introspectionFromSchema'; -import { printSchema } from '../printSchema'; - -/** - * This function does a full cycle of going from a string with the contents of - * the SDL, build in-memory GraphQLSchema from it, produce a client-side - * representation of the schema by using "buildClientSchema" and then - * returns that schema printed as SDL. - */ -function cycleIntrospection(sdlString: string): string { - const serverSchema = buildSchema(sdlString); - const initialIntrospection = introspectionFromSchema(serverSchema); - const clientSchema = buildClientSchema(initialIntrospection); - const secondIntrospection = introspectionFromSchema(clientSchema); - - /** - * If the client then runs the introspection query against the client-side - * schema, it should get a result identical to what was returned by the server - */ - expect(secondIntrospection).to.deep.equal(initialIntrospection); - return printSchema(clientSchema); -} - -describe('Type System: build schema from introspection', () => { - it('builds a simple schema', () => { - const sdl = dedent` - """Simple schema""" - schema { - query: Simple - } - - """This is a simple type""" - type Simple { - """This is a string field""" - string: String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema without the query type', () => { - const sdl = dedent` - type Query { - foo: String - } - `; - - const schema = buildSchema(sdl); - const introspection = introspectionFromSchema(schema); - - // @ts-expect-error - delete introspection.__schema.queryType; - - const clientSchema = buildClientSchema(introspection); - expect(clientSchema.getQueryType()).to.equal(null); - expect(printSchema(clientSchema)).to.equal(sdl); - }); - - it('builds a simple schema with all operation types', () => { - const sdl = dedent` - schema { - query: QueryType - mutation: MutationType - subscription: SubscriptionType - } - - """This is a simple mutation type""" - type MutationType { - """Set the string field""" - string: String - } - - """This is a simple query type""" - type QueryType { - """This is a string field""" - string: String - } - - """This is a simple subscription type""" - type SubscriptionType { - """This is a string field""" - string: String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('uses built-in scalars when possible', () => { - const sdl = dedent` - scalar CustomScalar - - type Query { - int: Int - float: Float - string: String - boolean: Boolean - id: ID - custom: CustomScalar - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - - const schema = buildSchema(sdl); - const introspection = introspectionFromSchema(schema); - const clientSchema = buildClientSchema(introspection); - - // Built-ins are used - expect(clientSchema.getType('Int')).to.equal(GraphQLInt); - expect(clientSchema.getType('Float')).to.equal(GraphQLFloat); - expect(clientSchema.getType('String')).to.equal(GraphQLString); - expect(clientSchema.getType('Boolean')).to.equal(GraphQLBoolean); - expect(clientSchema.getType('ID')).to.equal(GraphQLID); - - // Custom are built - const customScalar = schema.getType('CustomScalar'); - expect(clientSchema.getType('CustomScalar')).to.not.equal(customScalar); - }); - - it('includes standard types only if they are used', () => { - const schema = buildSchema(` - type Query { - foo: String - } - `); - const introspection = introspectionFromSchema(schema); - const clientSchema = buildClientSchema(introspection); - - expect(clientSchema.getType('Int')).to.equal(undefined); - expect(clientSchema.getType('Float')).to.equal(undefined); - expect(clientSchema.getType('ID')).to.equal(undefined); - }); - - it('builds a schema with a recursive type reference', () => { - const sdl = dedent` - schema { - query: Recur - } - - type Recur { - recur: Recur - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with a circular type reference', () => { - const sdl = dedent` - type Dog { - bestFriend: Human - } - - type Human { - bestFriend: Dog - } - - type Query { - dog: Dog - human: Human - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with an interface', () => { - const sdl = dedent` - type Dog implements Friendly { - bestFriend: Friendly - } - - interface Friendly { - """The best friend of this friendly thing""" - bestFriend: Friendly - } - - type Human implements Friendly { - bestFriend: Friendly - } - - type Query { - friendly: Friendly - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with an interface hierarchy', () => { - const sdl = dedent` - type Dog implements Friendly & Named { - bestFriend: Friendly - name: String - } - - interface Friendly implements Named { - """The best friend of this friendly thing""" - bestFriend: Friendly - name: String - } - - type Human implements Friendly & Named { - bestFriend: Friendly - name: String - } - - interface Named { - name: String - } - - type Query { - friendly: Friendly - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with an implicit interface', () => { - const sdl = dedent` - type Dog implements Friendly { - bestFriend: Friendly - } - - interface Friendly { - """The best friend of this friendly thing""" - bestFriend: Friendly - } - - type Query { - dog: Dog - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with a union', () => { - const sdl = dedent` - type Dog { - bestFriend: Friendly - } - - union Friendly = Dog | Human - - type Human { - bestFriend: Friendly - } - - type Query { - friendly: Friendly - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with complex field values', () => { - const sdl = dedent` - type Query { - string: String - listOfString: [String] - nonNullString: String! - nonNullListOfString: [String]! - nonNullListOfNonNullString: [String!]! - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with field arguments', () => { - const sdl = dedent` - type Query { - """A field with a single arg""" - one( - """This is an int arg""" - intArg: Int - ): String - - """A field with a two args""" - two( - """This is an list of int arg""" - listArg: [Int] - - """This is a required arg""" - requiredArg: Boolean! - ): String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with default value on custom scalar field', () => { - const sdl = dedent` - scalar CustomScalar - - type Query { - testField(testArg: CustomScalar = "default"): String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with an enum', () => { - const foodEnum = new GraphQLEnumType({ - name: 'Food', - description: 'Varieties of food stuffs', - values: { - VEGETABLES: { - description: 'Foods that are vegetables.', - value: 1, - }, - FRUITS: { - value: 2, - }, - OILS: { - value: 3, - deprecationReason: 'Too fatty', - }, - }, - }); - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'EnumFields', - fields: { - food: { - description: 'Repeats the arg you give it', - type: foodEnum, - args: { - kind: { - description: 'what kind of food?', - type: foodEnum, - }, - }, - }, - }, - }), - }); - - const introspection = introspectionFromSchema(schema); - const clientSchema = buildClientSchema(introspection); - - const secondIntrospection = introspectionFromSchema(clientSchema); - expect(secondIntrospection).to.deep.equal(introspection); - - // It's also an Enum type on the client. - const clientFoodEnum = assertEnumType(clientSchema.getType('Food')); - - // Client types do not get server-only values, so `value` mirrors `name`, - // rather than using the integers defined in the "server" schema. - expect(clientFoodEnum.getValues()).to.deep.equal([ - { - name: 'VEGETABLES', - description: 'Foods that are vegetables.', - value: 'VEGETABLES', - deprecationReason: null, - extensions: {}, - astNode: undefined, - }, - { - name: 'FRUITS', - description: null, - value: 'FRUITS', - deprecationReason: null, - extensions: {}, - astNode: undefined, - }, - { - name: 'OILS', - description: null, - value: 'OILS', - deprecationReason: 'Too fatty', - extensions: {}, - astNode: undefined, - }, - ]); - }); - - it('builds a schema with an input object', () => { - const sdl = dedent` - """An input address""" - input Address { - """What street is this address?""" - street: String! - - """The city the address is within?""" - city: String! - - """The country (blank will assume USA).""" - country: String = "USA" - } - - type Query { - """Get a geocode from an address""" - geocode( - """The address to lookup""" - address: Address - ): String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with field arguments with default values', () => { - const sdl = dedent` - input Geo { - lat: Float - lon: Float - } - - type Query { - defaultInt(intArg: Int = 30): String - defaultList(listArg: [Int] = [1, 2, 3]): String - defaultObject(objArg: Geo = {lat: 37.485, lon: -122.148}): String - defaultNull(intArg: Int = null): String - noDefault(intArg: Int): String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with custom directives', () => { - const sdl = dedent` - """This is a custom directive""" - directive @customDirective repeatable on FIELD - - type Query { - string: String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema without directives', () => { - const sdl = dedent` - type Query { - string: String - } - `; - - const schema = buildSchema(sdl); - const introspection = introspectionFromSchema(schema); - - // @ts-expect-error - delete introspection.__schema.directives; - - const clientSchema = buildClientSchema(introspection); - - expect(schema.getDirectives()).to.have.lengthOf.above(0); - expect(clientSchema.getDirectives()).to.deep.equal([]); - expect(printSchema(clientSchema)).to.equal(sdl); - }); - - it('builds a schema aware of deprecation', () => { - const sdl = dedent` - directive @someDirective( - """This is a shiny new argument""" - shinyArg: SomeInputObject - - """This was our design mistake :(""" - oldArg: String @deprecated(reason: "Use shinyArg") - ) on QUERY - - enum Color { - """So rosy""" - RED - - """So grassy""" - GREEN - - """So calming""" - BLUE - - """So sickening""" - MAUVE @deprecated(reason: "No longer in fashion") - } - - input SomeInputObject { - """Nothing special about it, just deprecated for some unknown reason""" - oldField: String @deprecated(reason: "Don't use it, use newField instead!") - - """Same field but with a new name""" - newField: String - } - - type Query { - """This is a shiny string field""" - shinyString: String - - """This is a deprecated string field""" - deprecatedString: String @deprecated(reason: "Use shinyString") - - """Color of a week""" - color: Color - - """Some random field""" - someField( - """This is a shiny new argument""" - shinyArg: SomeInputObject - - """This was our design mistake :(""" - oldArg: String @deprecated(reason: "Use shinyArg") - ): String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with empty deprecation reasons', () => { - const sdl = dedent` - directive @someDirective(someArg: SomeInputObject @deprecated(reason: "")) on QUERY - - type Query { - someField(someArg: SomeInputObject @deprecated(reason: "")): SomeEnum @deprecated(reason: "") - } - - input SomeInputObject { - someInputField: String @deprecated(reason: "") - } - - enum SomeEnum { - SOME_VALUE @deprecated(reason: "") - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with specifiedBy url', () => { - const sdl = dedent` - scalar Foo @specifiedBy(url: "https://example.com/foo_spec") - - type Query { - foo: Foo - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('builds a schema with @oneOf directive', () => { - const sdl = dedent` - type Query { - someField(someArg: SomeInputObject): String - } - - input SomeInputObject @oneOf { - someInputField1: String - someInputField2: String - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - - it('can use client schema for limited execution', () => { - const schema = buildSchema(` - scalar CustomScalar - - type Query { - foo(custom1: CustomScalar, custom2: CustomScalar): String - } - `); - - const introspection = introspectionFromSchema(schema); - const clientSchema = buildClientSchema(introspection); - - const result = graphqlSync({ - schema: clientSchema, - source: - 'query Limited($v: CustomScalar) { foo(custom1: 123, custom2: $v) }', - rootValue: { foo: 'bar', unused: 'value' }, - variableValues: { v: 'baz' }, - }); - - expect(result.data).to.deep.equal({ foo: 'bar' }); - }); - - it('can build invalid schema', () => { - const schema = buildSchema('type Query', { assumeValid: true }); - - const introspection = introspectionFromSchema(schema); - const clientSchema = buildClientSchema(introspection, { - assumeValid: true, - }); - - expect(clientSchema.toConfig().assumeValid).to.equal(true); - }); - - describe('throws when given invalid introspection', () => { - const dummySchema = buildSchema(` - type Query { - foo(bar: String): String - } - - interface SomeInterface { - foo: String - } - - union SomeUnion = Query - - enum SomeEnum { FOO } - - input SomeInputObject { - foo: String - } - - directive @SomeDirective on QUERY - `); - - it('throws when introspection is missing __schema property', () => { - // @ts-expect-error (First parameter expected to be introspection results) - expect(() => buildClientSchema(null)).to.throw( - 'Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: null.', - ); - - // @ts-expect-error - expect(() => buildClientSchema({})).to.throw( - 'Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: {}.', - ); - }); - - it('throws when referenced unknown type', () => { - const introspection = introspectionFromSchema(dummySchema); - - // @ts-expect-error - introspection.__schema.types = introspection.__schema.types.filter( - ({ name }) => name !== 'Query', - ); - - expect(() => buildClientSchema(introspection)).to.throw( - 'Invalid or incomplete schema, unknown type: Query. Ensure that a full introspection query is used in order to build a client schema.', - ); - }); - - it('throws when missing definition for one of the standard scalars', () => { - const schema = buildSchema(` - type Query { - foo: Float - } - `); - const introspection = introspectionFromSchema(schema); - - // @ts-expect-error - introspection.__schema.types = introspection.__schema.types.filter( - ({ name }) => name !== 'Float', - ); - - expect(() => buildClientSchema(introspection)).to.throw( - 'Invalid or incomplete schema, unknown type: Float. Ensure that a full introspection query is used in order to build a client schema.', - ); - }); - - it('throws when type reference is missing name', () => { - const introspection = introspectionFromSchema(dummySchema); - - expect(introspection).to.have.nested.property('__schema.queryType.name'); - - // @ts-expect-error - delete introspection.__schema.queryType.name; - - expect(() => buildClientSchema(introspection)).to.throw( - 'Unknown type reference: { kind: "OBJECT" }.', - ); - }); - - it('throws when missing kind', () => { - const introspection = introspectionFromSchema(dummySchema); - const queryTypeIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'Query', - ); - - invariant(queryTypeIntrospection?.kind === 'OBJECT'); - // @ts-expect-error - delete queryTypeIntrospection.kind; - - expect(() => buildClientSchema(introspection)).to.throw( - /Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: { name: "Query", .* }\./, - ); - }); - - it('throws when missing interfaces', () => { - const introspection = introspectionFromSchema(dummySchema); - const queryTypeIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'Query', - ); - - expect(queryTypeIntrospection).to.have.property('interfaces'); - - invariant(queryTypeIntrospection?.kind === 'OBJECT'); - // @ts-expect-error - delete queryTypeIntrospection.interfaces; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing interfaces: { kind: "OBJECT", name: "Query", .* }\./, - ); - }); - - it('Legacy support for interfaces with null as interfaces field', () => { - const introspection = introspectionFromSchema(dummySchema); - const someInterfaceIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'SomeInterface', - ); - - invariant(someInterfaceIntrospection?.kind === 'INTERFACE'); - // @ts-expect-error - someInterfaceIntrospection.interfaces = null; - - const clientSchema = buildClientSchema(introspection); - expect(printSchema(clientSchema)).to.equal(printSchema(dummySchema)); - }); - - it('throws when missing fields', () => { - const introspection = introspectionFromSchema(dummySchema); - const queryTypeIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'Query', - ); - - invariant(queryTypeIntrospection?.kind === 'OBJECT'); - // @ts-expect-error - delete queryTypeIntrospection.fields; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing fields: { kind: "OBJECT", name: "Query", .* }\./, - ); - }); - - it('throws when missing field args', () => { - const introspection = introspectionFromSchema(dummySchema); - const queryTypeIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'Query', - ); - - invariant(queryTypeIntrospection?.kind === 'OBJECT'); - // @ts-expect-error - delete queryTypeIntrospection.fields[0].args; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing field args: { name: "foo", .* }\./, - ); - }); - - it('throws when output type is used as an arg type', () => { - const introspection = introspectionFromSchema(dummySchema); - const queryTypeIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'Query', - ); - - invariant(queryTypeIntrospection?.kind === 'OBJECT'); - const argType = queryTypeIntrospection.fields[0].args[0].type; - invariant(argType.kind === 'SCALAR'); - - expect(argType).to.have.property('name', 'String'); - // @ts-expect-error - argType.name = 'SomeUnion'; - - expect(() => buildClientSchema(introspection)).to.throw( - 'Introspection must provide input type for arguments, but received: SomeUnion.', - ); - }); - - it('throws when input type is used as a field type', () => { - const introspection = introspectionFromSchema(dummySchema); - const queryTypeIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'Query', - ); - - invariant(queryTypeIntrospection?.kind === 'OBJECT'); - const fieldType = queryTypeIntrospection.fields[0].type; - invariant(fieldType.kind === 'SCALAR'); - - expect(fieldType).to.have.property('name', 'String'); - // @ts-expect-error - fieldType.name = 'SomeInputObject'; - - expect(() => buildClientSchema(introspection)).to.throw( - 'Introspection must provide output type for fields, but received: SomeInputObject.', - ); - }); - - it('throws when missing possibleTypes', () => { - const introspection = introspectionFromSchema(dummySchema); - const someUnionIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'SomeUnion', - ); - - invariant(someUnionIntrospection?.kind === 'UNION'); - // @ts-expect-error - delete someUnionIntrospection.possibleTypes; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing possibleTypes: { kind: "UNION", name: "SomeUnion",.* }\./, - ); - }); - - it('throws when missing enumValues', () => { - const introspection = introspectionFromSchema(dummySchema); - const someEnumIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'SomeEnum', - ); - - invariant(someEnumIntrospection?.kind === 'ENUM'); - // @ts-expect-error - delete someEnumIntrospection.enumValues; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing enumValues: { kind: "ENUM", name: "SomeEnum", .* }\./, - ); - }); - - it('throws when missing inputFields', () => { - const introspection = introspectionFromSchema(dummySchema); - const someInputObjectIntrospection = introspection.__schema.types.find( - ({ name }) => name === 'SomeInputObject', - ); - - invariant(someInputObjectIntrospection?.kind === 'INPUT_OBJECT'); - // @ts-expect-error - delete someInputObjectIntrospection.inputFields; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing inputFields: { kind: "INPUT_OBJECT", name: "SomeInputObject", .* }\./, - ); - }); - - it('throws when missing directive locations', () => { - const introspection = introspectionFromSchema(dummySchema); - - const someDirectiveIntrospection = introspection.__schema.directives[0]; - expect(someDirectiveIntrospection).to.deep.include({ - name: 'SomeDirective', - locations: ['QUERY'], - }); - - // @ts-expect-error - delete someDirectiveIntrospection.locations; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing directive locations: { name: "SomeDirective", .* }\./, - ); - }); - - it('throws when missing directive args', () => { - const introspection = introspectionFromSchema(dummySchema); - - const someDirectiveIntrospection = introspection.__schema.directives[0]; - expect(someDirectiveIntrospection).to.deep.include({ - name: 'SomeDirective', - args: [], - }); - - // @ts-expect-error - delete someDirectiveIntrospection.args; - - expect(() => buildClientSchema(introspection)).to.throw( - /Introspection result missing directive args: { name: "SomeDirective", .* }\./, - ); - }); - }); - - describe('very deep decorators are not supported', () => { - it('fails on very deep (> 8 levels) lists', () => { - const schema = buildSchema(` - type Query { - foo: [[[[[[[[[[String]]]]]]]]]] - } - `); - - const introspection = introspectionFromSchema(schema); - expect(() => buildClientSchema(introspection)).to.throw( - 'Decorated type deeper than introspection query.', - ); - }); - - it('fails on a very deep (> 8 levels) non-null', () => { - const schema = buildSchema(` - type Query { - foo: [[[[[String!]!]!]!]!] - } - `); - - const introspection = introspectionFromSchema(schema); - expect(() => buildClientSchema(introspection)).to.throw( - 'Decorated type deeper than introspection query.', - ); - }); - - it('succeeds on deep (<= 8 levels) types', () => { - // e.g., fully non-null 4D matrix - const sdl = dedent` - type Query { - foo: [[[[String!]!]!]!]! - } - `; - - expect(cycleIntrospection(sdl)).to.equal(sdl); - }); - }); - - describe('prevents infinite recursion on invalid introspection', () => { - it('recursive interfaces', () => { - const sdl = ` - type Query { - foo: Foo - } - - type Foo implements Foo { - foo: String - } - `; - const schema = buildSchema(sdl, { assumeValid: true }); - const introspection = introspectionFromSchema(schema); - - const fooIntrospection = introspection.__schema.types.find( - (type) => type.name === 'Foo', - ); - expect(fooIntrospection).to.deep.include({ - name: 'Foo', - interfaces: [{ kind: 'OBJECT', name: 'Foo', ofType: null }], - }); - - expect(() => buildClientSchema(introspection)).to.throw( - 'Expected Foo to be a GraphQL Interface type.', - ); - }); - - it('recursive union', () => { - const sdl = ` - type Query { - foo: Foo - } - - union Foo = Foo - `; - const schema = buildSchema(sdl, { assumeValid: true }); - const introspection = introspectionFromSchema(schema); - - const fooIntrospection = introspection.__schema.types.find( - (type) => type.name === 'Foo', - ); - expect(fooIntrospection).to.deep.include({ - name: 'Foo', - possibleTypes: [{ kind: 'UNION', name: 'Foo', ofType: null }], - }); - - expect(() => buildClientSchema(introspection)).to.throw( - 'Expected Foo to be a GraphQL Object type.', - ); - }); - }); -}); diff --git a/src/utilities/__tests__/coerceInputValue-test.ts b/src/utilities/__tests__/coerceInputValue-test.ts deleted file mode 100644 index 03afca6a6b..0000000000 --- a/src/utilities/__tests__/coerceInputValue-test.ts +++ /dev/null @@ -1,567 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import type { GraphQLInputType } from '../../type/definition'; -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLList, - GraphQLNonNull, - GraphQLScalarType, -} from '../../type/definition'; -import { GraphQLInt } from '../../type/scalars'; - -import { coerceInputValue } from '../coerceInputValue'; - -interface CoerceResult { - value: unknown; - errors: ReadonlyArray; -} - -interface CoerceError { - path: ReadonlyArray; - value: unknown; - error: string; -} - -function coerceValue( - inputValue: unknown, - type: GraphQLInputType, -): CoerceResult { - const errors: Array = []; - const value = coerceInputValue( - inputValue, - type, - (path, invalidValue, error) => { - errors.push({ path, value: invalidValue, error: error.message }); - }, - ); - - return { errors, value }; -} - -function expectValue(result: CoerceResult) { - expect(result.errors).to.deep.equal([]); - return expect(result.value); -} - -function expectErrors(result: CoerceResult) { - return expect(result.errors); -} - -describe('coerceInputValue', () => { - describe('for GraphQLNonNull', () => { - const TestNonNull = new GraphQLNonNull(GraphQLInt); - - it('returns no error for non-null value', () => { - const result = coerceValue(1, TestNonNull); - expectValue(result).to.equal(1); - }); - - it('returns an error for undefined value', () => { - const result = coerceValue(undefined, TestNonNull); - expectErrors(result).to.deep.equal([ - { - error: 'Expected non-nullable type "Int!" not to be null.', - path: [], - value: undefined, - }, - ]); - }); - - it('returns an error for null value', () => { - const result = coerceValue(null, TestNonNull); - expectErrors(result).to.deep.equal([ - { - error: 'Expected non-nullable type "Int!" not to be null.', - path: [], - value: null, - }, - ]); - }); - }); - - describe('for GraphQLScalar', () => { - const TestScalar = new GraphQLScalarType({ - name: 'TestScalar', - parseValue(input: any) { - if (input.error != null) { - throw new Error(input.error); - } - return input.value; - }, - }); - - it('returns no error for valid input', () => { - const result = coerceValue({ value: 1 }, TestScalar); - expectValue(result).to.equal(1); - }); - - it('returns no error for null result', () => { - const result = coerceValue({ value: null }, TestScalar); - expectValue(result).to.equal(null); - }); - - it('returns no error for NaN result', () => { - const result = coerceValue({ value: NaN }, TestScalar); - expectValue(result).to.satisfy(Number.isNaN); - }); - - it('returns an error for undefined result', () => { - const result = coerceValue({ value: undefined }, TestScalar); - expectErrors(result).to.deep.equal([ - { - error: 'Expected type "TestScalar".', - path: [], - value: { value: undefined }, - }, - ]); - }); - - it('returns an error for undefined result', () => { - const inputValue = { error: 'Some error message' }; - const result = coerceValue(inputValue, TestScalar); - expectErrors(result).to.deep.equal([ - { - error: 'Expected type "TestScalar". Some error message', - path: [], - value: { error: 'Some error message' }, - }, - ]); - }); - }); - - describe('for GraphQLEnum', () => { - const TestEnum = new GraphQLEnumType({ - name: 'TestEnum', - values: { - FOO: { value: 'InternalFoo' }, - BAR: { value: 123456789 }, - }, - }); - - it('returns no error for a known enum name', () => { - const fooResult = coerceValue('FOO', TestEnum); - expectValue(fooResult).to.equal('InternalFoo'); - - const barResult = coerceValue('BAR', TestEnum); - expectValue(barResult).to.equal(123456789); - }); - - it('returns an error for misspelled enum value', () => { - const result = coerceValue('foo', TestEnum); - expectErrors(result).to.deep.equal([ - { - error: - 'Value "foo" does not exist in "TestEnum" enum. Did you mean the enum value "FOO"?', - path: [], - value: 'foo', - }, - ]); - }); - - it('returns an error for incorrect value type', () => { - const result1 = coerceValue(123, TestEnum); - expectErrors(result1).to.deep.equal([ - { - error: 'Enum "TestEnum" cannot represent non-string value: 123.', - path: [], - value: 123, - }, - ]); - - const result2 = coerceValue({ field: 'value' }, TestEnum); - expectErrors(result2).to.deep.equal([ - { - error: - 'Enum "TestEnum" cannot represent non-string value: { field: "value" }.', - path: [], - value: { field: 'value' }, - }, - ]); - }); - }); - - describe('for GraphQLInputObject', () => { - const DeepObject = new GraphQLInputObjectType({ - name: 'DeepObject', - fields: { - foo: { type: new GraphQLNonNull(GraphQLInt) }, - bar: { type: GraphQLInt }, - }, - }); - const TestInputObject = new GraphQLInputObjectType({ - name: 'TestInputObject', - fields: { - foo: { type: new GraphQLNonNull(GraphQLInt) }, - bar: { type: GraphQLInt }, - deepObject: { type: DeepObject }, - }, - }); - - it('returns no error for a valid input', () => { - const result = coerceValue({ foo: 123 }, TestInputObject); - expectValue(result).to.deep.equal({ foo: 123 }); - }); - - it('returns an error for a non-object type', () => { - const result = coerceValue(123, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Expected type "TestInputObject" to be an object.', - path: [], - value: 123, - }, - ]); - }); - - it('returns an error for an invalid field', () => { - const result = coerceValue({ foo: NaN }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Int cannot represent non-integer value: NaN', - path: ['foo'], - value: NaN, - }, - ]); - }); - - it('returns multiple errors for multiple invalid fields', () => { - const result = coerceValue({ foo: 'abc', bar: 'def' }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Int cannot represent non-integer value: "abc"', - path: ['foo'], - value: 'abc', - }, - { - error: 'Int cannot represent non-integer value: "def"', - path: ['bar'], - value: 'def', - }, - ]); - }); - - it('returns error for a missing required field', () => { - const result = coerceValue({ bar: 123 }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Field "foo" of required type "Int!" was not provided.', - path: [], - value: { bar: 123 }, - }, - ]); - }); - - it('returns error for an unknown field', () => { - const result = coerceValue( - { foo: 123, unknownField: 123 }, - TestInputObject, - ); - expectErrors(result).to.deep.equal([ - { - error: - 'Field "unknownField" is not defined by type "TestInputObject".', - path: [], - value: { foo: 123, unknownField: 123 }, - }, - ]); - }); - - it('returns error for a misspelled field', () => { - const result = coerceValue({ foo: 123, bart: 123 }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: - 'Field "bart" is not defined by type "TestInputObject". Did you mean "bar"?', - path: [], - value: { foo: 123, bart: 123 }, - }, - ]); - }); - - it('returns an error for an array type', () => { - const result = coerceValue([{ foo: 1 }, { bar: 1 }], TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Expected type "TestInputObject" to be an object.', - path: [], - value: [{ foo: 1 }, { bar: 1 }], - }, - ]); - }); - - it('returns an error for an array type on a nested field', () => { - const result = coerceValue( - { foo: 1, deepObject: [1, 2, 3] }, - TestInputObject, - ); - expectErrors(result).to.deep.equal([ - { - error: 'Expected type "DeepObject" to be an object.', - path: ['deepObject'], - value: [1, 2, 3], - }, - ]); - }); - }); - - describe('for GraphQLInputObject that isOneOf', () => { - const TestInputObject = new GraphQLInputObjectType({ - name: 'TestInputObject', - fields: { - foo: { type: GraphQLInt }, - bar: { type: GraphQLInt }, - }, - isOneOf: true, - }); - - it('returns no error for a valid input', () => { - const result = coerceValue({ foo: 123 }, TestInputObject); - expectValue(result).to.deep.equal({ foo: 123 }); - }); - - it('returns an error if more than one field is specified', () => { - const result = coerceValue({ foo: 123, bar: null }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: - 'Exactly one key must be specified for OneOf type "TestInputObject".', - path: [], - value: { foo: 123, bar: null }, - }, - ]); - }); - - it('returns an error the one field is null', () => { - const result = coerceValue({ bar: null }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Field "bar" must be non-null.', - path: ['bar'], - value: null, - }, - ]); - }); - - it('returns an error for an invalid field', () => { - const result = coerceValue({ foo: NaN }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Int cannot represent non-integer value: NaN', - path: ['foo'], - value: NaN, - }, - ]); - }); - - it('returns multiple errors for multiple invalid fields', () => { - const result = coerceValue({ foo: 'abc', bar: 'def' }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: 'Int cannot represent non-integer value: "abc"', - path: ['foo'], - value: 'abc', - }, - { - error: 'Int cannot represent non-integer value: "def"', - path: ['bar'], - value: 'def', - }, - { - error: - 'Exactly one key must be specified for OneOf type "TestInputObject".', - path: [], - value: { foo: 'abc', bar: 'def' }, - }, - ]); - }); - - it('returns error for an unknown field', () => { - const result = coerceValue( - { foo: 123, unknownField: 123 }, - TestInputObject, - ); - expectErrors(result).to.deep.equal([ - { - error: - 'Field "unknownField" is not defined by type "TestInputObject".', - path: [], - value: { foo: 123, unknownField: 123 }, - }, - ]); - }); - - it('returns error for a misspelled field', () => { - const result = coerceValue({ bart: 123 }, TestInputObject); - expectErrors(result).to.deep.equal([ - { - error: - 'Field "bart" is not defined by type "TestInputObject". Did you mean "bar"?', - path: [], - value: { bart: 123 }, - }, - { - error: - 'Exactly one key must be specified for OneOf type "TestInputObject".', - path: [], - value: { bart: 123 }, - }, - ]); - }); - }); - - describe('for GraphQLInputObject with default value', () => { - const makeTestInputObject = (defaultValue: any) => - new GraphQLInputObjectType({ - name: 'TestInputObject', - fields: { - foo: { - type: new GraphQLScalarType({ name: 'TestScalar' }), - defaultValue, - }, - }, - }); - - it('returns no errors for valid input value', () => { - const result = coerceValue({ foo: 5 }, makeTestInputObject(7)); - expectValue(result).to.deep.equal({ foo: 5 }); - }); - - it('returns object with default value', () => { - const result = coerceValue({}, makeTestInputObject(7)); - expectValue(result).to.deep.equal({ foo: 7 }); - }); - - it('returns null as value', () => { - const result = coerceValue({}, makeTestInputObject(null)); - expectValue(result).to.deep.equal({ foo: null }); - }); - - it('returns NaN as value', () => { - const result = coerceValue({}, makeTestInputObject(NaN)); - expectValue(result).to.have.property('foo').that.satisfy(Number.isNaN); - }); - }); - - describe('for GraphQLList', () => { - const TestList = new GraphQLList(GraphQLInt); - - it('returns no error for a valid input', () => { - const result = coerceValue([1, 2, 3], TestList); - expectValue(result).to.deep.equal([1, 2, 3]); - }); - - it('returns no error for a valid iterable input', () => { - function* listGenerator() { - yield 1; - yield 2; - yield 3; - } - - const result = coerceValue(listGenerator(), TestList); - expectValue(result).to.deep.equal([1, 2, 3]); - }); - - it('returns an error for an invalid input', () => { - const result = coerceValue([1, 'b', true, 4], TestList); - expectErrors(result).to.deep.equal([ - { - error: 'Int cannot represent non-integer value: "b"', - path: [1], - value: 'b', - }, - { - error: 'Int cannot represent non-integer value: true', - path: [2], - value: true, - }, - ]); - }); - - it('returns a list for a non-list value', () => { - const result = coerceValue(42, TestList); - expectValue(result).to.deep.equal([42]); - }); - - it('returns a list for a non-list object value', () => { - const TestListOfObjects = new GraphQLList( - new GraphQLInputObjectType({ - name: 'TestObject', - fields: { - length: { type: GraphQLInt }, - }, - }), - ); - - const result = coerceValue({ length: 100500 }, TestListOfObjects); - expectValue(result).to.deep.equal([{ length: 100500 }]); - }); - - it('returns an error for a non-list invalid value', () => { - const result = coerceValue('INVALID', TestList); - expectErrors(result).to.deep.equal([ - { - error: 'Int cannot represent non-integer value: "INVALID"', - path: [], - value: 'INVALID', - }, - ]); - }); - - it('returns null for a null value', () => { - const result = coerceValue(null, TestList); - expectValue(result).to.deep.equal(null); - }); - }); - - describe('for nested GraphQLList', () => { - const TestNestedList = new GraphQLList(new GraphQLList(GraphQLInt)); - - it('returns no error for a valid input', () => { - const result = coerceValue([[1], [2, 3]], TestNestedList); - expectValue(result).to.deep.equal([[1], [2, 3]]); - }); - - it('returns a list for a non-list value', () => { - const result = coerceValue(42, TestNestedList); - expectValue(result).to.deep.equal([[42]]); - }); - - it('returns null for a null value', () => { - const result = coerceValue(null, TestNestedList); - expectValue(result).to.deep.equal(null); - }); - - it('returns nested lists for nested non-list values', () => { - const result = coerceValue([1, 2, 3], TestNestedList); - expectValue(result).to.deep.equal([[1], [2], [3]]); - }); - - it('returns nested null for nested null values', () => { - const result = coerceValue([42, [null], null], TestNestedList); - expectValue(result).to.deep.equal([[42], [null], null]); - }); - }); - - describe('with default onError', () => { - it('throw error without path', () => { - expect(() => - coerceInputValue(null, new GraphQLNonNull(GraphQLInt)), - ).to.throw( - 'Invalid value null: Expected non-nullable type "Int!" not to be null.', - ); - }); - - it('throw error with path', () => { - expect(() => - coerceInputValue( - [null], - new GraphQLList(new GraphQLNonNull(GraphQLInt)), - ), - ).to.throw( - 'Invalid value null at "value[0]": Expected non-nullable type "Int!" not to be null.', - ); - }); - }); -}); diff --git a/src/utilities/__tests__/concatAST-test.ts b/src/utilities/__tests__/concatAST-test.ts deleted file mode 100644 index 622abd6b38..0000000000 --- a/src/utilities/__tests__/concatAST-test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { parse } from '../../language/parser'; -import { print } from '../../language/printer'; -import { Source } from '../../language/source'; - -import { concatAST } from '../concatAST'; - -describe('concatAST', () => { - it('concatenates two ASTs together', () => { - const sourceA = new Source(` - { a, b, ...Frag } - `); - - const sourceB = new Source(` - fragment Frag on T { - c - } - `); - - const astA = parse(sourceA); - const astB = parse(sourceB); - const astC = concatAST([astA, astB]); - - expect(print(astC)).to.equal(dedent` - { - a - b - ...Frag - } - - fragment Frag on T { - c - } - `); - }); -}); diff --git a/src/utilities/__tests__/extendSchema-test.ts b/src/utilities/__tests__/extendSchema-test.ts deleted file mode 100644 index 86baf0e699..0000000000 --- a/src/utilities/__tests__/extendSchema-test.ts +++ /dev/null @@ -1,1322 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { invariant } from '../../jsutils/invariant'; -import type { Maybe } from '../../jsutils/Maybe'; - -import type { ASTNode } from '../../language/ast'; -import { parse } from '../../language/parser'; -import { print } from '../../language/printer'; - -import { - assertEnumType, - assertInputObjectType, - assertInterfaceType, - assertObjectType, - assertScalarType, - assertUnionType, -} from '../../type/definition'; -import { assertDirective } from '../../type/directives'; -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLID, - GraphQLInt, - GraphQLString, -} from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; -import { validateSchema } from '../../type/validate'; - -import { graphqlSync } from '../../graphql'; - -import { buildSchema } from '../buildASTSchema'; -import { concatAST } from '../concatAST'; -import { extendSchema } from '../extendSchema'; -import { printSchema } from '../printSchema'; - -function expectExtensionASTNodes(obj: { - readonly extensionASTNodes: ReadonlyArray; -}) { - return expect(obj.extensionASTNodes.map(print).join('\n\n')); -} - -function expectASTNode(obj: Maybe<{ readonly astNode: Maybe }>) { - invariant(obj?.astNode != null); - return expect(print(obj.astNode)); -} - -function expectSchemaChanges( - schema: GraphQLSchema, - extendedSchema: GraphQLSchema, -) { - const schemaDefinitions = parse(printSchema(schema)).definitions.map(print); - return expect( - parse(printSchema(extendedSchema)) - .definitions.map(print) - .filter((def) => !schemaDefinitions.includes(def)) - .join('\n\n'), - ); -} - -describe('extendSchema', () => { - it('returns the original schema when there are no type definitions', () => { - const schema = buildSchema('type Query'); - const extendedSchema = extendSchema(schema, parse('{ field }')); - expect(extendedSchema).to.equal(schema); - }); - - it('can be used for limited execution', () => { - const schema = buildSchema('type Query'); - const extendAST = parse(` - extend type Query { - newField: String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - const result = graphqlSync({ - schema: extendedSchema, - source: '{ newField }', - rootValue: { newField: 123 }, - }); - expect(result).to.deep.equal({ - data: { newField: '123' }, - }); - }); - - it('extends objects by adding new fields', () => { - const schema = buildSchema(` - type Query { - someObject: SomeObject - } - - type SomeObject implements AnotherInterface & SomeInterface { - self: SomeObject - tree: [SomeObject]! - """Old field description.""" - oldField: String - } - - interface SomeInterface { - self: SomeInterface - } - - interface AnotherInterface { - self: SomeObject - } - `); - const extensionSDL = dedent` - extend type SomeObject { - """New field description.""" - newField(arg: Boolean): String - } - `; - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - type SomeObject implements AnotherInterface & SomeInterface { - self: SomeObject - tree: [SomeObject]! - """Old field description.""" - oldField: String - """New field description.""" - newField(arg: Boolean): String - } - `); - }); - - it('extends objects with standard type fields', () => { - const schema = buildSchema('type Query'); - - // String and Boolean are always included through introspection types - expect(schema.getType('Int')).to.equal(undefined); - expect(schema.getType('Float')).to.equal(undefined); - expect(schema.getType('String')).to.equal(GraphQLString); - expect(schema.getType('Boolean')).to.equal(GraphQLBoolean); - expect(schema.getType('ID')).to.equal(undefined); - - const extendAST = parse(` - extend type Query { - bool: Boolean - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expect(extendedSchema.getType('Int')).to.equal(undefined); - expect(extendedSchema.getType('Float')).to.equal(undefined); - expect(extendedSchema.getType('String')).to.equal(GraphQLString); - expect(extendedSchema.getType('Boolean')).to.equal(GraphQLBoolean); - expect(extendedSchema.getType('ID')).to.equal(undefined); - - const extendTwiceAST = parse(` - extend type Query { - int: Int - float: Float - id: ID - } - `); - const extendedTwiceSchema = extendSchema(schema, extendTwiceAST); - - expect(validateSchema(extendedTwiceSchema)).to.deep.equal([]); - expect(extendedTwiceSchema.getType('Int')).to.equal(GraphQLInt); - expect(extendedTwiceSchema.getType('Float')).to.equal(GraphQLFloat); - expect(extendedTwiceSchema.getType('String')).to.equal(GraphQLString); - expect(extendedTwiceSchema.getType('Boolean')).to.equal(GraphQLBoolean); - expect(extendedTwiceSchema.getType('ID')).to.equal(GraphQLID); - }); - - it('extends enums by adding new values', () => { - const schema = buildSchema(` - type Query { - someEnum(arg: SomeEnum): SomeEnum - } - - directive @foo(arg: SomeEnum) on SCHEMA - - enum SomeEnum { - """Old value description.""" - OLD_VALUE - } - `); - const extendAST = parse(` - extend enum SomeEnum { - """New value description.""" - NEW_VALUE - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - enum SomeEnum { - """Old value description.""" - OLD_VALUE - """New value description.""" - NEW_VALUE - } - `); - }); - - it('extends unions by adding new types', () => { - const schema = buildSchema(` - type Query { - someUnion: SomeUnion - } - - union SomeUnion = Foo | Biz - - type Foo { foo: String } - type Biz { biz: String } - type Bar { bar: String } - `); - const extendAST = parse(` - extend union SomeUnion = Bar - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - union SomeUnion = Foo | Biz | Bar - `); - }); - - it('allows extension of union by adding itself', () => { - const schema = buildSchema(` - union SomeUnion - `); - const extendAST = parse(` - extend union SomeUnion = SomeUnion - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.have.lengthOf.above(0); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - union SomeUnion = SomeUnion - `); - }); - - it('extends inputs by adding new fields', () => { - const schema = buildSchema(` - type Query { - someInput(arg: SomeInput): String - } - - directive @foo(arg: SomeInput) on SCHEMA - - input SomeInput { - """Old field description.""" - oldField: String - } - `); - const extendAST = parse(` - extend input SomeInput { - """New field description.""" - newField: String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - input SomeInput { - """Old field description.""" - oldField: String - """New field description.""" - newField: String - } - `); - }); - - it('extends scalars by adding new directives', () => { - const schema = buildSchema(` - type Query { - someScalar(arg: SomeScalar): SomeScalar - } - - directive @foo(arg: SomeScalar) on SCALAR - - input FooInput { - foo: SomeScalar - } - - scalar SomeScalar - `); - const extensionSDL = dedent` - extend scalar SomeScalar @foo - `; - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - const someScalar = assertScalarType(extendedSchema.getType('SomeScalar')); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectExtensionASTNodes(someScalar).to.equal(extensionSDL); - }); - - it('extends scalars by adding specifiedBy directive', () => { - const schema = buildSchema(` - type Query { - foo: Foo - } - - scalar Foo - - directive @foo on SCALAR - `); - const extensionSDL = dedent` - extend scalar Foo @foo - - extend scalar Foo @specifiedBy(url: "https://example.com/foo_spec") - `; - - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - const foo = assertScalarType(extendedSchema.getType('Foo')); - - expect(foo.specifiedByURL).to.equal('https://example.com/foo_spec'); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectExtensionASTNodes(foo).to.equal(extensionSDL); - }); - - it('correctly assign AST nodes to new and extended types', () => { - const schema = buildSchema(` - type Query - - scalar SomeScalar - enum SomeEnum - union SomeUnion - input SomeInput - type SomeObject - interface SomeInterface - - directive @foo on SCALAR - `); - const firstExtensionAST = parse(` - extend type Query { - newField(testArg: TestInput): TestEnum - } - - extend scalar SomeScalar @foo - - extend enum SomeEnum { - NEW_VALUE - } - - extend union SomeUnion = SomeObject - - extend input SomeInput { - newField: String - } - - extend interface SomeInterface { - newField: String - } - - enum TestEnum { - TEST_VALUE - } - - input TestInput { - testInputField: TestEnum - } - `); - const extendedSchema = extendSchema(schema, firstExtensionAST); - - const secondExtensionAST = parse(` - extend type Query { - oneMoreNewField: TestUnion - } - - extend scalar SomeScalar @test - - extend enum SomeEnum { - ONE_MORE_NEW_VALUE - } - - extend union SomeUnion = TestType - - extend input SomeInput { - oneMoreNewField: String - } - - extend interface SomeInterface { - oneMoreNewField: String - } - - union TestUnion = TestType - - interface TestInterface { - interfaceField: String - } - - type TestType implements TestInterface { - interfaceField: String - } - - directive @test(arg: Int) repeatable on FIELD | SCALAR - `); - const extendedTwiceSchema = extendSchema( - extendedSchema, - secondExtensionAST, - ); - - const extendedInOneGoSchema = extendSchema( - schema, - concatAST([firstExtensionAST, secondExtensionAST]), - ); - expect(printSchema(extendedInOneGoSchema)).to.equal( - printSchema(extendedTwiceSchema), - ); - - const query = assertObjectType(extendedTwiceSchema.getType('Query')); - const someEnum = assertEnumType(extendedTwiceSchema.getType('SomeEnum')); - const someUnion = assertUnionType(extendedTwiceSchema.getType('SomeUnion')); - const someScalar = assertScalarType( - extendedTwiceSchema.getType('SomeScalar'), - ); - const someInput = assertInputObjectType( - extendedTwiceSchema.getType('SomeInput'), - ); - const someInterface = assertInterfaceType( - extendedTwiceSchema.getType('SomeInterface'), - ); - - const testInput = assertInputObjectType( - extendedTwiceSchema.getType('TestInput'), - ); - const testEnum = assertEnumType(extendedTwiceSchema.getType('TestEnum')); - const testUnion = assertUnionType(extendedTwiceSchema.getType('TestUnion')); - const testType = assertObjectType(extendedTwiceSchema.getType('TestType')); - const testInterface = assertInterfaceType( - extendedTwiceSchema.getType('TestInterface'), - ); - const testDirective = assertDirective( - extendedTwiceSchema.getDirective('test'), - ); - - expect(testType.extensionASTNodes).to.deep.equal([]); - expect(testEnum.extensionASTNodes).to.deep.equal([]); - expect(testUnion.extensionASTNodes).to.deep.equal([]); - expect(testInput.extensionASTNodes).to.deep.equal([]); - expect(testInterface.extensionASTNodes).to.deep.equal([]); - - expect([ - testInput.astNode, - testEnum.astNode, - testUnion.astNode, - testInterface.astNode, - testType.astNode, - testDirective.astNode, - ...query.extensionASTNodes, - ...someScalar.extensionASTNodes, - ...someEnum.extensionASTNodes, - ...someUnion.extensionASTNodes, - ...someInput.extensionASTNodes, - ...someInterface.extensionASTNodes, - ]).to.have.members([ - ...firstExtensionAST.definitions, - ...secondExtensionAST.definitions, - ]); - - const newField = query.getFields().newField; - expectASTNode(newField).to.equal('newField(testArg: TestInput): TestEnum'); - expectASTNode(newField.args[0]).to.equal('testArg: TestInput'); - expectASTNode(query.getFields().oneMoreNewField).to.equal( - 'oneMoreNewField: TestUnion', - ); - - expectASTNode(someEnum.getValue('NEW_VALUE')).to.equal('NEW_VALUE'); - expectASTNode(someEnum.getValue('ONE_MORE_NEW_VALUE')).to.equal( - 'ONE_MORE_NEW_VALUE', - ); - - expectASTNode(someInput.getFields().newField).to.equal('newField: String'); - expectASTNode(someInput.getFields().oneMoreNewField).to.equal( - 'oneMoreNewField: String', - ); - expectASTNode(someInterface.getFields().newField).to.equal( - 'newField: String', - ); - expectASTNode(someInterface.getFields().oneMoreNewField).to.equal( - 'oneMoreNewField: String', - ); - - expectASTNode(testInput.getFields().testInputField).to.equal( - 'testInputField: TestEnum', - ); - - expectASTNode(testEnum.getValue('TEST_VALUE')).to.equal('TEST_VALUE'); - - expectASTNode(testInterface.getFields().interfaceField).to.equal( - 'interfaceField: String', - ); - expectASTNode(testType.getFields().interfaceField).to.equal( - 'interfaceField: String', - ); - expectASTNode(testDirective.args[0]).to.equal('arg: Int'); - }); - - it('builds types with deprecated fields/values', () => { - const schema = new GraphQLSchema({}); - const extendAST = parse(` - type SomeObject { - deprecatedField: String @deprecated(reason: "not used anymore") - } - - enum SomeEnum { - DEPRECATED_VALUE @deprecated(reason: "do not use") - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - const someType = assertObjectType(extendedSchema.getType('SomeObject')); - expect(someType.getFields().deprecatedField).to.include({ - deprecationReason: 'not used anymore', - }); - - const someEnum = assertEnumType(extendedSchema.getType('SomeEnum')); - expect(someEnum.getValue('DEPRECATED_VALUE')).to.include({ - deprecationReason: 'do not use', - }); - }); - - it('extends objects with deprecated fields', () => { - const schema = buildSchema('type SomeObject'); - const extendAST = parse(` - extend type SomeObject { - deprecatedField: String @deprecated(reason: "not used anymore") - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - const someType = assertObjectType(extendedSchema.getType('SomeObject')); - expect(someType.getFields().deprecatedField).to.include({ - deprecationReason: 'not used anymore', - }); - }); - - it('extends enums with deprecated values', () => { - const schema = buildSchema('enum SomeEnum'); - const extendAST = parse(` - extend enum SomeEnum { - DEPRECATED_VALUE @deprecated(reason: "do not use") - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - const someEnum = assertEnumType(extendedSchema.getType('SomeEnum')); - expect(someEnum.getValue('DEPRECATED_VALUE')).to.include({ - deprecationReason: 'do not use', - }); - }); - - it('adds new unused types', () => { - const schema = buildSchema(` - type Query { - dummy: String - } - `); - const extensionSDL = dedent` - type DummyUnionMember { - someField: String - } - - enum UnusedEnum { - SOME_VALUE - } - - input UnusedInput { - someField: String - } - - interface UnusedInterface { - someField: String - } - - type UnusedObject { - someField: String - } - - union UnusedUnion = DummyUnionMember - `; - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(extensionSDL); - }); - - it('extends objects by adding new fields with arguments', () => { - const schema = buildSchema(` - type SomeObject - - type Query { - someObject: SomeObject - } - `); - const extendAST = parse(` - input NewInputObj { - field1: Int - field2: [Float] - field3: String! - } - - extend type SomeObject { - newField(arg1: String, arg2: NewInputObj!): String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - type SomeObject { - newField(arg1: String, arg2: NewInputObj!): String - } - - input NewInputObj { - field1: Int - field2: [Float] - field3: String! - } - `); - }); - - it('extends objects by adding new fields with existing types', () => { - const schema = buildSchema(` - type Query { - someObject: SomeObject - } - - type SomeObject - enum SomeEnum { VALUE } - `); - const extendAST = parse(` - extend type SomeObject { - newField(arg1: SomeEnum!): SomeEnum - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - type SomeObject { - newField(arg1: SomeEnum!): SomeEnum - } - `); - }); - - it('extends objects by adding implemented interfaces', () => { - const schema = buildSchema(` - type Query { - someObject: SomeObject - } - - type SomeObject { - foo: String - } - - interface SomeInterface { - foo: String - } - `); - const extendAST = parse(` - extend type SomeObject implements SomeInterface - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - type SomeObject implements SomeInterface { - foo: String - } - `); - }); - - it('extends objects by including new types', () => { - const schema = buildSchema(` - type Query { - someObject: SomeObject - } - - type SomeObject { - oldField: String - } - `); - const newTypesSDL = dedent` - enum NewEnum { - VALUE - } - - interface NewInterface { - baz: String - } - - type NewObject implements NewInterface { - baz: String - } - - scalar NewScalar - - union NewUnion = NewObject`; - const extendAST = parse(` - ${newTypesSDL} - extend type SomeObject { - newObject: NewObject - newInterface: NewInterface - newUnion: NewUnion - newScalar: NewScalar - newEnum: NewEnum - newTree: [SomeObject]! - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - type SomeObject { - oldField: String - newObject: NewObject - newInterface: NewInterface - newUnion: NewUnion - newScalar: NewScalar - newEnum: NewEnum - newTree: [SomeObject]! - } - - ${newTypesSDL} - `); - }); - - it('extends objects by adding implemented new interfaces', () => { - const schema = buildSchema(` - type Query { - someObject: SomeObject - } - - type SomeObject implements OldInterface { - oldField: String - } - - interface OldInterface { - oldField: String - } - `); - const extendAST = parse(` - extend type SomeObject implements NewInterface { - newField: String - } - - interface NewInterface { - newField: String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - type SomeObject implements OldInterface & NewInterface { - oldField: String - newField: String - } - - interface NewInterface { - newField: String - } - `); - }); - - it('extends different types multiple times', () => { - const schema = buildSchema(` - type Query { - someScalar: SomeScalar - someObject(someInput: SomeInput): SomeObject - someInterface: SomeInterface - someEnum: SomeEnum - someUnion: SomeUnion - } - - scalar SomeScalar - - type SomeObject implements SomeInterface { - oldField: String - } - - interface SomeInterface { - oldField: String - } - - enum SomeEnum { - OLD_VALUE - } - - union SomeUnion = SomeObject - - input SomeInput { - oldField: String - } - `); - const newTypesSDL = dedent` - scalar NewScalar - - scalar AnotherNewScalar - - type NewObject { - foo: String - } - - type AnotherNewObject { - foo: String - } - - interface NewInterface { - newField: String - } - - interface AnotherNewInterface { - anotherNewField: String - } - `; - const schemaWithNewTypes = extendSchema(schema, parse(newTypesSDL)); - expectSchemaChanges(schema, schemaWithNewTypes).to.equal(newTypesSDL); - - const extendAST = parse(` - extend scalar SomeScalar @specifiedBy(url: "http://example.com/foo_spec") - - extend type SomeObject implements NewInterface { - newField: String - } - - extend type SomeObject implements AnotherNewInterface { - anotherNewField: String - } - - extend enum SomeEnum { - NEW_VALUE - } - - extend enum SomeEnum { - ANOTHER_NEW_VALUE - } - - extend union SomeUnion = NewObject - - extend union SomeUnion = AnotherNewObject - - extend input SomeInput { - newField: String - } - - extend input SomeInput { - anotherNewField: String - } - `); - const extendedSchema = extendSchema(schemaWithNewTypes, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - scalar SomeScalar @specifiedBy(url: "http://example.com/foo_spec") - - type SomeObject implements SomeInterface & NewInterface & AnotherNewInterface { - oldField: String - newField: String - anotherNewField: String - } - - enum SomeEnum { - OLD_VALUE - NEW_VALUE - ANOTHER_NEW_VALUE - } - - union SomeUnion = SomeObject | NewObject | AnotherNewObject - - input SomeInput { - oldField: String - newField: String - anotherNewField: String - } - - ${newTypesSDL} - `); - }); - - it('extends interfaces by adding new fields', () => { - const schema = buildSchema(` - interface SomeInterface { - oldField: String - } - - interface AnotherInterface implements SomeInterface { - oldField: String - } - - type SomeObject implements SomeInterface & AnotherInterface { - oldField: String - } - - type Query { - someInterface: SomeInterface - } - `); - const extendAST = parse(` - extend interface SomeInterface { - newField: String - } - - extend interface AnotherInterface { - newField: String - } - - extend type SomeObject { - newField: String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - interface SomeInterface { - oldField: String - newField: String - } - - interface AnotherInterface implements SomeInterface { - oldField: String - newField: String - } - - type SomeObject implements SomeInterface & AnotherInterface { - oldField: String - newField: String - } - `); - }); - - it('extends interfaces by adding new implemented interfaces', () => { - const schema = buildSchema(` - interface SomeInterface { - oldField: String - } - - interface AnotherInterface implements SomeInterface { - oldField: String - } - - type SomeObject implements SomeInterface & AnotherInterface { - oldField: String - } - - type Query { - someInterface: SomeInterface - } - `); - const extendAST = parse(` - interface NewInterface { - newField: String - } - - extend interface AnotherInterface implements NewInterface { - newField: String - } - - extend type SomeObject implements NewInterface { - newField: String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - interface AnotherInterface implements SomeInterface & NewInterface { - oldField: String - newField: String - } - - type SomeObject implements SomeInterface & AnotherInterface & NewInterface { - oldField: String - newField: String - } - - interface NewInterface { - newField: String - } - `); - }); - - it('allows extension of interface with missing Object fields', () => { - const schema = buildSchema(` - type Query { - someInterface: SomeInterface - } - - type SomeObject implements SomeInterface { - oldField: SomeInterface - } - - interface SomeInterface { - oldField: SomeInterface - } - `); - const extendAST = parse(` - extend interface SomeInterface { - newField: String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.have.lengthOf.above(0); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - interface SomeInterface { - oldField: SomeInterface - newField: String - } - `); - }); - - it('extends interfaces multiple times', () => { - const schema = buildSchema(` - type Query { - someInterface: SomeInterface - } - - interface SomeInterface { - some: SomeInterface - } - `); - - const extendAST = parse(` - extend interface SomeInterface { - newFieldA: Int - } - - extend interface SomeInterface { - newFieldB(test: Boolean): String - } - `); - const extendedSchema = extendSchema(schema, extendAST); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(dedent` - interface SomeInterface { - some: SomeInterface - newFieldA: Int - newFieldB(test: Boolean): String - } - `); - }); - - it('may extend mutations and subscriptions', () => { - const mutationSchema = buildSchema(` - type Query { - queryField: String - } - - type Mutation { - mutationField: String - } - - type Subscription { - subscriptionField: String - } - `); - const ast = parse(` - extend type Query { - newQueryField: Int - } - - extend type Mutation { - newMutationField: Int - } - - extend type Subscription { - newSubscriptionField: Int - } - `); - const originalPrint = printSchema(mutationSchema); - const extendedSchema = extendSchema(mutationSchema, ast); - expect(extendedSchema).to.not.equal(mutationSchema); - expect(printSchema(mutationSchema)).to.equal(originalPrint); - expect(printSchema(extendedSchema)).to.equal(dedent` - type Query { - queryField: String - newQueryField: Int - } - - type Mutation { - mutationField: String - newMutationField: Int - } - - type Subscription { - subscriptionField: String - newSubscriptionField: Int - } - `); - }); - - it('may extend directives with new directive', () => { - const schema = buildSchema(` - type Query { - foo: String - } - `); - const extensionSDL = dedent` - """New directive.""" - directive @new(enable: Boolean!, tag: String) repeatable on QUERY | FIELD - `; - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - - expect(validateSchema(extendedSchema)).to.deep.equal([]); - expectSchemaChanges(schema, extendedSchema).to.equal(extensionSDL); - }); - - it('Rejects invalid SDL', () => { - const schema = new GraphQLSchema({}); - const extendAST = parse('extend schema @unknown'); - - expect(() => extendSchema(schema, extendAST)).to.throw( - 'Unknown directive "@unknown".', - ); - }); - - it('Allows to disable SDL validation', () => { - const schema = new GraphQLSchema({}); - const extendAST = parse('extend schema @unknown'); - - extendSchema(schema, extendAST, { assumeValid: true }); - extendSchema(schema, extendAST, { assumeValidSDL: true }); - }); - - it('Throws on unknown types', () => { - const schema = new GraphQLSchema({}); - const ast = parse(` - type Query { - unknown: UnknownType - } - `); - expect(() => extendSchema(schema, ast, { assumeValidSDL: true })).to.throw( - 'Unknown type: "UnknownType".', - ); - }); - - it('Rejects invalid AST', () => { - const schema = new GraphQLSchema({}); - - // @ts-expect-error (Second argument expects DocumentNode) - expect(() => extendSchema(schema, null)).to.throw( - 'Must provide valid Document AST', - ); - - // @ts-expect-error - expect(() => extendSchema(schema, {})).to.throw( - 'Must provide valid Document AST', - ); - }); - - it('does not allow replacing a default directive', () => { - const schema = new GraphQLSchema({}); - const extendAST = parse(` - directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD - `); - - expect(() => extendSchema(schema, extendAST)).to.throw( - 'Directive "@include" already exists in the schema. It cannot be redefined.', - ); - }); - - it('does not allow replacing an existing enum value', () => { - const schema = buildSchema(` - enum SomeEnum { - ONE - } - `); - const extendAST = parse(` - extend enum SomeEnum { - ONE - } - `); - - expect(() => extendSchema(schema, extendAST)).to.throw( - 'Enum value "SomeEnum.ONE" already exists in the schema. It cannot also be defined in this type extension.', - ); - }); - - describe('can add additional root operation types', () => { - it('does not automatically include common root type names', () => { - const schema = new GraphQLSchema({}); - const extendedSchema = extendSchema(schema, parse('type Mutation')); - - expect(extendedSchema.getType('Mutation')).to.not.equal(undefined); - expect(extendedSchema.getMutationType()).to.equal(undefined); - }); - - it('adds schema definition missing in the original schema', () => { - const schema = buildSchema(` - directive @foo on SCHEMA - type Foo - `); - expect(schema.getQueryType()).to.equal(undefined); - - const extensionSDL = dedent` - schema @foo { - query: Foo - } - `; - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - - const queryType = extendedSchema.getQueryType(); - expect(queryType).to.include({ name: 'Foo' }); - expectASTNode(extendedSchema).to.equal(extensionSDL); - }); - - it('adds new root types via schema extension', () => { - const schema = buildSchema(` - type Query - type MutationRoot - `); - const extensionSDL = dedent` - extend schema { - mutation: MutationRoot - } - `; - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - - const mutationType = extendedSchema.getMutationType(); - expect(mutationType).to.include({ name: 'MutationRoot' }); - expectExtensionASTNodes(extendedSchema).to.equal(extensionSDL); - }); - - it('adds directive via schema extension', () => { - const schema = buildSchema(` - type Query - - directive @foo on SCHEMA - `); - const extensionSDL = dedent` - extend schema @foo - `; - const extendedSchema = extendSchema(schema, parse(extensionSDL)); - - expectExtensionASTNodes(extendedSchema).to.equal(extensionSDL); - }); - - it('adds multiple new root types via schema extension', () => { - const schema = buildSchema('type Query'); - const extendAST = parse(` - extend schema { - mutation: Mutation - subscription: Subscription - } - - type Mutation - type Subscription - `); - const extendedSchema = extendSchema(schema, extendAST); - - const mutationType = extendedSchema.getMutationType(); - expect(mutationType).to.include({ name: 'Mutation' }); - - const subscriptionType = extendedSchema.getSubscriptionType(); - expect(subscriptionType).to.include({ name: 'Subscription' }); - }); - - it('applies multiple schema extensions', () => { - const schema = buildSchema('type Query'); - const extendAST = parse(` - extend schema { - mutation: Mutation - } - type Mutation - - extend schema { - subscription: Subscription - } - type Subscription - `); - const extendedSchema = extendSchema(schema, extendAST); - - const mutationType = extendedSchema.getMutationType(); - expect(mutationType).to.include({ name: 'Mutation' }); - - const subscriptionType = extendedSchema.getSubscriptionType(); - expect(subscriptionType).to.include({ name: 'Subscription' }); - }); - - it('schema extension AST are available from schema object', () => { - const schema = buildSchema(` - type Query - - directive @foo on SCHEMA - `); - - const extendAST = parse(` - extend schema { - mutation: Mutation - } - type Mutation - - extend schema { - subscription: Subscription - } - type Subscription - `); - const extendedSchema = extendSchema(schema, extendAST); - - const secondExtendAST = parse('extend schema @foo'); - const extendedTwiceSchema = extendSchema(extendedSchema, secondExtendAST); - - expectExtensionASTNodes(extendedTwiceSchema).to.equal(dedent` - extend schema { - mutation: Mutation - } - - extend schema { - subscription: Subscription - } - - extend schema @foo - `); - }); - }); -}); diff --git a/src/utilities/__tests__/findBreakingChanges-test.ts b/src/utilities/__tests__/findBreakingChanges-test.ts deleted file mode 100644 index ba526deb48..0000000000 --- a/src/utilities/__tests__/findBreakingChanges-test.ts +++ /dev/null @@ -1,1232 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { - GraphQLDeprecatedDirective, - GraphQLIncludeDirective, - GraphQLOneOfDirective, - GraphQLSkipDirective, - GraphQLSpecifiedByDirective, -} from '../../type/directives'; -import { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../buildASTSchema'; -import { - BreakingChangeType, - DangerousChangeType, - findBreakingChanges, - findDangerousChanges, -} from '../findBreakingChanges'; - -describe('findBreakingChanges', () => { - it('should detect if a type was removed or not', () => { - const oldSchema = buildSchema(` - type Type1 - type Type2 - `); - - const newSchema = buildSchema(` - type Type2 - `); - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.TYPE_REMOVED, - description: 'Type1 was removed.', - }, - ]); - expect(findBreakingChanges(oldSchema, oldSchema)).to.deep.equal([]); - }); - - it('should detect if a standard scalar was removed', () => { - const oldSchema = buildSchema(` - type Query { - foo: Float - } - `); - - const newSchema = buildSchema(` - type Query { - foo: String - } - `); - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.TYPE_REMOVED, - description: - 'Standard scalar Float was removed because it is not referenced anymore.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Query.foo changed type from Float to String.', - }, - ]); - expect(findBreakingChanges(oldSchema, oldSchema)).to.deep.equal([]); - }); - - it('should detect if a type changed its type', () => { - const oldSchema = buildSchema(` - scalar TypeWasScalarBecomesEnum - interface TypeWasInterfaceBecomesUnion - type TypeWasObjectBecomesInputObject - `); - - const newSchema = buildSchema(` - enum TypeWasScalarBecomesEnum - union TypeWasInterfaceBecomesUnion - input TypeWasObjectBecomesInputObject - `); - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.TYPE_CHANGED_KIND, - description: - 'TypeWasScalarBecomesEnum changed from a Scalar type to an Enum type.', - }, - { - type: BreakingChangeType.TYPE_CHANGED_KIND, - description: - 'TypeWasInterfaceBecomesUnion changed from an Interface type to a Union type.', - }, - { - type: BreakingChangeType.TYPE_CHANGED_KIND, - description: - 'TypeWasObjectBecomesInputObject changed from an Object type to an Input type.', - }, - ]); - }); - - it('should detect if a field on a type was deleted or changed type', () => { - const oldSchema = buildSchema(` - type TypeA - type TypeB - - interface Type1 { - field1: TypeA - field2: String - field3: String - field4: TypeA - field6: String - field7: [String] - field8: Int - field9: Int! - field10: [Int]! - field11: Int - field12: [Int] - field13: [Int!] - field14: [Int] - field15: [[Int]] - field16: Int! - field17: [Int] - field18: [[Int!]!] - } - `); - - const newSchema = buildSchema(` - type TypeA - type TypeB - - interface Type1 { - field1: TypeA - field3: Boolean - field4: TypeB - field5: String - field6: [String] - field7: String - field8: Int! - field9: Int - field10: [Int] - field11: [Int]! - field12: [Int!] - field13: [Int] - field14: [[Int]] - field15: [Int] - field16: [Int]! - field17: [Int]! - field18: [[Int!]] - } - `); - - const changes = findBreakingChanges(oldSchema, newSchema); - expect(changes).to.deep.equal([ - { - type: BreakingChangeType.FIELD_REMOVED, - description: 'Type1.field2 was removed.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field3 changed type from String to Boolean.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field4 changed type from TypeA to TypeB.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field6 changed type from String to [String].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field7 changed type from [String] to String.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field9 changed type from Int! to Int.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field10 changed type from [Int]! to [Int].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field11 changed type from Int to [Int]!.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field13 changed type from [Int!] to [Int].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field14 changed type from [Int] to [[Int]].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field15 changed type from [[Int]] to [Int].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field16 changed type from Int! to [Int]!.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'Type1.field18 changed type from [[Int!]!] to [[Int!]].', - }, - ]); - }); - - it('should detect if fields on input types changed kind or were removed', () => { - const oldSchema = buildSchema(` - input InputType1 { - field1: String - field2: Boolean - field3: [String] - field4: String! - field5: String - field6: [Int] - field7: [Int]! - field8: Int - field9: [Int] - field10: [Int!] - field11: [Int] - field12: [[Int]] - field13: Int! - field14: [[Int]!] - field15: [[Int]!] - } - `); - - const newSchema = buildSchema(` - input InputType1 { - field1: Int - field3: String - field4: String - field5: String! - field6: [Int]! - field7: [Int] - field8: [Int]! - field9: [Int!] - field10: [Int] - field11: [[Int]] - field12: [Int] - field13: [Int]! - field14: [[Int]] - field15: [[Int!]!] - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.FIELD_REMOVED, - description: 'InputType1.field2 was removed.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field1 changed type from String to Int.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field3 changed type from [String] to String.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field5 changed type from String to String!.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field6 changed type from [Int] to [Int]!.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field8 changed type from Int to [Int]!.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field9 changed type from [Int] to [Int!].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field11 changed type from [Int] to [[Int]].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field12 changed type from [[Int]] to [Int].', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: 'InputType1.field13 changed type from Int! to [Int]!.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: - 'InputType1.field15 changed type from [[Int]!] to [[Int!]!].', - }, - ]); - }); - - it('should detect if a required field is added to an input type', () => { - const oldSchema = buildSchema(` - input InputType1 { - field1: String - } - `); - - const newSchema = buildSchema(` - input InputType1 { - field1: String - requiredField: Int! - optionalField1: Boolean - optionalField2: Boolean! = false - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, - description: - 'A required field requiredField on input type InputType1 was added.', - }, - ]); - }); - - it('should detect if a type was removed from a union type', () => { - const oldSchema = buildSchema(` - type Type1 - type Type2 - type Type3 - - union UnionType1 = Type1 | Type2 - `); - const newSchema = buildSchema(` - type Type1 - type Type2 - type Type3 - - union UnionType1 = Type1 | Type3 - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, - description: 'Type2 was removed from union type UnionType1.', - }, - ]); - }); - - it('should detect if a value was removed from an enum type', () => { - const oldSchema = buildSchema(` - enum EnumType1 { - VALUE0 - VALUE1 - VALUE2 - } - `); - - const newSchema = buildSchema(` - enum EnumType1 { - VALUE0 - VALUE2 - VALUE3 - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, - description: 'VALUE1 was removed from enum type EnumType1.', - }, - ]); - }); - - it('should detect if a field argument was removed', () => { - const oldSchema = buildSchema(` - interface Interface1 { - field1(arg1: Boolean, objectArg: String): String - } - - type Type1 { - field1(name: String): String - } - `); - - const newSchema = buildSchema(` - interface Interface1 { - field1: String - } - - type Type1 { - field1: String - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.ARG_REMOVED, - description: 'Interface1.field1 arg arg1 was removed.', - }, - { - type: BreakingChangeType.ARG_REMOVED, - description: 'Interface1.field1 arg objectArg was removed.', - }, - { - type: BreakingChangeType.ARG_REMOVED, - description: 'Type1.field1 arg name was removed.', - }, - ]); - }); - - it('should detect if a field argument has changed type', () => { - const oldSchema = buildSchema(` - type Type1 { - field1( - arg1: String - arg2: String - arg3: [String] - arg4: String - arg5: String! - arg6: String! - arg7: [Int]! - arg8: Int - arg9: [Int] - arg10: [Int!] - arg11: [Int] - arg12: [[Int]] - arg13: Int! - arg14: [[Int]!] - arg15: [[Int]!] - ): String - } - `); - - const newSchema = buildSchema(` - type Type1 { - field1( - arg1: Int - arg2: [String] - arg3: String - arg4: String! - arg5: Int - arg6: Int! - arg7: [Int] - arg8: [Int]! - arg9: [Int!] - arg10: [Int] - arg11: [[Int]] - arg12: [Int] - arg13: [Int]! - arg14: [[Int]] - arg15: [[Int!]!] - ): String - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg1 has changed type from String to Int.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg2 has changed type from String to [String].', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg3 has changed type from [String] to String.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg4 has changed type from String to String!.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg5 has changed type from String! to Int.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg6 has changed type from String! to Int!.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg8 has changed type from Int to [Int]!.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg9 has changed type from [Int] to [Int!].', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg11 has changed type from [Int] to [[Int]].', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg12 has changed type from [[Int]] to [Int].', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg13 has changed type from Int! to [Int]!.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'Type1.field1 arg arg15 has changed type from [[Int]!] to [[Int!]!].', - }, - ]); - }); - - it('should detect if a required field argument was added', () => { - const oldSchema = buildSchema(` - type Type1 { - field1(arg1: String): String - } - `); - - const newSchema = buildSchema(` - type Type1 { - field1( - arg1: String, - newRequiredArg: String! - newOptionalArg1: Int - newOptionalArg2: Int! = 0 - ): String - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.REQUIRED_ARG_ADDED, - description: 'A required arg newRequiredArg on Type1.field1 was added.', - }, - ]); - }); - - it('should not flag args with the same type signature as breaking', () => { - const oldSchema = buildSchema(` - input InputType1 { - field1: String - } - - type Type1 { - field1(arg1: Int!, arg2: InputType1): Int - } - `); - - const newSchema = buildSchema(` - input InputType1 { - field1: String - } - - type Type1 { - field1(arg1: Int!, arg2: InputType1): Int - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([]); - }); - - it('should consider args that move away from NonNull as non-breaking', () => { - const oldSchema = buildSchema(` - type Type1 { - field1(name: String!): String - } - `); - - const newSchema = buildSchema(` - type Type1 { - field1(name: String): String - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([]); - }); - - it('should detect interfaces removed from types', () => { - const oldSchema = buildSchema(` - interface Interface1 - - type Type1 implements Interface1 - `); - - const newSchema = buildSchema(` - interface Interface1 - - type Type1 - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, - description: 'Type1 no longer implements interface Interface1.', - }, - ]); - }); - - it('should detect interfaces removed from interfaces', () => { - const oldSchema = buildSchema(` - interface Interface1 - - interface Interface2 implements Interface1 - `); - - const newSchema = buildSchema(` - interface Interface1 - - interface Interface2 - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, - description: 'Interface2 no longer implements interface Interface1.', - }, - ]); - }); - - it('should ignore changes in order of interfaces', () => { - const oldSchema = buildSchema(` - interface FirstInterface - interface SecondInterface - - type Type1 implements FirstInterface & SecondInterface - `); - - const newSchema = buildSchema(` - interface FirstInterface - interface SecondInterface - - type Type1 implements SecondInterface & FirstInterface - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([]); - }); - - it('should detect all breaking changes', () => { - const oldSchema = buildSchema(` - directive @DirectiveThatIsRemoved on FIELD_DEFINITION - - directive @DirectiveThatRemovesArg(arg1: String) on FIELD_DEFINITION - - directive @NonNullDirectiveAdded on FIELD_DEFINITION - - directive @DirectiveThatWasRepeatable repeatable on FIELD_DEFINITION - - directive @DirectiveName on FIELD_DEFINITION | QUERY - - type ArgThatChanges { - field1(id: Float): String - } - - enum EnumTypeThatLosesAValue { - VALUE0 - VALUE1 - VALUE2 - } - - interface Interface1 - type TypeThatLooseInterface1 implements Interface1 - - type TypeInUnion1 - type TypeInUnion2 - union UnionTypeThatLosesAType = TypeInUnion1 | TypeInUnion2 - - type TypeThatChangesType - - type TypeThatGetsRemoved - - interface TypeThatHasBreakingFieldChanges { - field1: String - field2: String - } - `); - - const newSchema = buildSchema(` - directive @DirectiveThatRemovesArg on FIELD_DEFINITION - - directive @NonNullDirectiveAdded(arg1: Boolean!) on FIELD_DEFINITION - - directive @DirectiveThatWasRepeatable on FIELD_DEFINITION - - directive @DirectiveName on FIELD_DEFINITION - - type ArgThatChanges { - field1(id: String): String - } - - enum EnumTypeThatLosesAValue { - VALUE1 - VALUE2 - } - - interface Interface1 - type TypeThatLooseInterface1 - - type TypeInUnion1 - type TypeInUnion2 - union UnionTypeThatLosesAType = TypeInUnion1 - - interface TypeThatChangesType - - interface TypeThatHasBreakingFieldChanges { - field2: Boolean - } - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.TYPE_REMOVED, - description: - 'Standard scalar Float was removed because it is not referenced anymore.', - }, - { - type: BreakingChangeType.TYPE_REMOVED, - description: 'TypeThatGetsRemoved was removed.', - }, - { - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - 'ArgThatChanges.field1 arg id has changed type from Float to String.', - }, - { - type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, - description: - 'VALUE0 was removed from enum type EnumTypeThatLosesAValue.', - }, - { - type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, - description: - 'TypeThatLooseInterface1 no longer implements interface Interface1.', - }, - { - type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, - description: - 'TypeInUnion2 was removed from union type UnionTypeThatLosesAType.', - }, - { - type: BreakingChangeType.TYPE_CHANGED_KIND, - description: - 'TypeThatChangesType changed from an Object type to an Interface type.', - }, - { - type: BreakingChangeType.FIELD_REMOVED, - description: 'TypeThatHasBreakingFieldChanges.field1 was removed.', - }, - { - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: - 'TypeThatHasBreakingFieldChanges.field2 changed type from String to Boolean.', - }, - { - type: BreakingChangeType.DIRECTIVE_REMOVED, - description: 'DirectiveThatIsRemoved was removed.', - }, - { - type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, - description: 'arg1 was removed from DirectiveThatRemovesArg.', - }, - { - type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, - description: - 'A required arg arg1 on directive NonNullDirectiveAdded was added.', - }, - { - type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, - description: - 'Repeatable flag was removed from DirectiveThatWasRepeatable.', - }, - { - type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, - description: 'QUERY was removed from DirectiveName.', - }, - ]); - }); - - it('should detect if a directive was explicitly removed', () => { - const oldSchema = buildSchema(` - directive @DirectiveThatIsRemoved on FIELD_DEFINITION - directive @DirectiveThatStays on FIELD_DEFINITION - `); - - const newSchema = buildSchema(` - directive @DirectiveThatStays on FIELD_DEFINITION - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.DIRECTIVE_REMOVED, - description: 'DirectiveThatIsRemoved was removed.', - }, - ]); - }); - - it('should detect if a directive was implicitly removed', () => { - const oldSchema = new GraphQLSchema({}); - - const newSchema = new GraphQLSchema({ - directives: [ - GraphQLSkipDirective, - GraphQLIncludeDirective, - GraphQLSpecifiedByDirective, - GraphQLOneOfDirective, - ], - }); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.DIRECTIVE_REMOVED, - description: `${GraphQLDeprecatedDirective.name} was removed.`, - }, - ]); - }); - - it('should detect if a directive argument was removed', () => { - const oldSchema = buildSchema(` - directive @DirectiveWithArg(arg1: String) on FIELD_DEFINITION - `); - - const newSchema = buildSchema(` - directive @DirectiveWithArg on FIELD_DEFINITION - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, - description: 'arg1 was removed from DirectiveWithArg.', - }, - ]); - }); - - it('should detect if an optional directive argument was added', () => { - const oldSchema = buildSchema(` - directive @DirectiveName on FIELD_DEFINITION - `); - - const newSchema = buildSchema(` - directive @DirectiveName( - newRequiredArg: String! - newOptionalArg1: Int - newOptionalArg2: Int! = 0 - ) on FIELD_DEFINITION - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, - description: - 'A required arg newRequiredArg on directive DirectiveName was added.', - }, - ]); - }); - - it('should detect removal of repeatable flag', () => { - const oldSchema = buildSchema(` - directive @DirectiveName repeatable on OBJECT - `); - - const newSchema = buildSchema(` - directive @DirectiveName on OBJECT - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, - description: 'Repeatable flag was removed from DirectiveName.', - }, - ]); - }); - - it('should detect locations removed from a directive', () => { - const oldSchema = buildSchema(` - directive @DirectiveName on FIELD_DEFINITION | QUERY - `); - - const newSchema = buildSchema(` - directive @DirectiveName on FIELD_DEFINITION - `); - - expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, - description: 'QUERY was removed from DirectiveName.', - }, - ]); - }); -}); - -describe('findDangerousChanges', () => { - it('should detect if a defaultValue changed on an argument', () => { - const oldSDL = ` - input Input1 { - innerInputArray: [Input2] - } - - input Input2 { - arrayField: [Int] - } - - type Type1 { - field1( - withDefaultValue: String = "TO BE DELETED" - stringArg: String = "test" - emptyArray: [Int!] = [] - valueArray: [[String]] = [["a", "b"], ["c"]] - complexObject: Input1 = { - innerInputArray: [{ arrayField: [1, 2, 3] }] - } - ): String - } - `; - - const oldSchema = buildSchema(oldSDL); - const copyOfOldSchema = buildSchema(oldSDL); - expect(findDangerousChanges(oldSchema, copyOfOldSchema)).to.deep.equal([]); - - const newSchema = buildSchema(` - input Input1 { - innerInputArray: [Input2] - } - - input Input2 { - arrayField: [Int] - } - - type Type1 { - field1( - withDefaultValue: String - stringArg: String = "Test" - emptyArray: [Int!] = [7] - valueArray: [[String]] = [["b", "a"], ["d"]] - complexObject: Input1 = { - innerInputArray: [{ arrayField: [3, 2, 1] }] - } - ): String - } - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: - 'Type1.field1 arg withDefaultValue defaultValue was removed.', - }, - { - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: - 'Type1.field1 arg stringArg has changed defaultValue from "test" to "Test".', - }, - { - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: - 'Type1.field1 arg emptyArray has changed defaultValue from [] to [7].', - }, - { - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: - 'Type1.field1 arg valueArray has changed defaultValue from [["a", "b"], ["c"]] to [["b", "a"], ["d"]].', - }, - { - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: - 'Type1.field1 arg complexObject has changed defaultValue from {innerInputArray: [{arrayField: [1, 2, 3]}]} to {innerInputArray: [{arrayField: [3, 2, 1]}]}.', - }, - ]); - }); - - it('should ignore changes in field order of defaultValue', () => { - const oldSchema = buildSchema(` - input Input1 { - a: String - b: String - c: String - } - - type Type1 { - field1( - arg1: Input1 = { a: "a", b: "b", c: "c" } - ): String - } - `); - - const newSchema = buildSchema(` - input Input1 { - a: String - b: String - c: String - } - - type Type1 { - field1( - arg1: Input1 = { c: "c", b: "b", a: "a" } - ): String - } - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([]); - }); - - it('should ignore changes in field definitions order', () => { - const oldSchema = buildSchema(` - input Input1 { - a: String - b: String - c: String - } - - type Type1 { - field1( - arg1: Input1 = { a: "a", b: "b", c: "c" } - ): String - } - `); - - const newSchema = buildSchema(` - input Input1 { - c: String - b: String - a: String - } - - type Type1 { - field1( - arg1: Input1 = { a: "a", b: "b", c: "c" } - ): String - } - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([]); - }); - - it('should detect if a value was added to an enum type', () => { - const oldSchema = buildSchema(` - enum EnumType1 { - VALUE0 - VALUE1 - } - `); - - const newSchema = buildSchema(` - enum EnumType1 { - VALUE0 - VALUE1 - VALUE2 - } - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.VALUE_ADDED_TO_ENUM, - description: 'VALUE2 was added to enum type EnumType1.', - }, - ]); - }); - - it('should detect interfaces added to types', () => { - const oldSchema = buildSchema(` - interface OldInterface - interface NewInterface - - type Type1 implements OldInterface - `); - - const newSchema = buildSchema(` - interface OldInterface - interface NewInterface - - type Type1 implements OldInterface & NewInterface - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, - description: 'NewInterface added to interfaces implemented by Type1.', - }, - ]); - }); - - it('should detect interfaces added to interfaces', () => { - const oldSchema = buildSchema(` - interface OldInterface - interface NewInterface - - interface Interface1 implements OldInterface - `); - - const newSchema = buildSchema(` - interface OldInterface - interface NewInterface - - interface Interface1 implements OldInterface & NewInterface - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, - description: - 'NewInterface added to interfaces implemented by Interface1.', - }, - ]); - }); - - it('should detect if a type was added to a union type', () => { - const oldSchema = buildSchema(` - type Type1 - type Type2 - - union UnionType1 = Type1 - `); - - const newSchema = buildSchema(` - type Type1 - type Type2 - - union UnionType1 = Type1 | Type2 - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.TYPE_ADDED_TO_UNION, - description: 'Type2 was added to union type UnionType1.', - }, - ]); - }); - - it('should detect if an optional field was added to an input', () => { - const oldSchema = buildSchema(` - input InputType1 { - field1: String - } - `); - - const newSchema = buildSchema(` - input InputType1 { - field1: String - field2: Int - } - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, - description: - 'An optional field field2 on input type InputType1 was added.', - }, - ]); - }); - - it('should find all dangerous changes', () => { - const oldSchema = buildSchema(` - enum EnumType1 { - VALUE0 - VALUE1 - } - - type Type1 { - field1(argThatChangesDefaultValue: String = "test"): String - } - - interface Interface1 - type TypeThatGainsInterface1 - - type TypeInUnion1 - union UnionTypeThatGainsAType = TypeInUnion1 - `); - - const newSchema = buildSchema(` - enum EnumType1 { - VALUE0 - VALUE1 - VALUE2 - } - - type Type1 { - field1(argThatChangesDefaultValue: String = "Test"): String - } - - interface Interface1 - type TypeThatGainsInterface1 implements Interface1 - - type TypeInUnion1 - type TypeInUnion2 - union UnionTypeThatGainsAType = TypeInUnion1 | TypeInUnion2 - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.VALUE_ADDED_TO_ENUM, - description: 'VALUE2 was added to enum type EnumType1.', - }, - { - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: - 'Type1.field1 arg argThatChangesDefaultValue has changed defaultValue from "test" to "Test".', - }, - { - type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, - description: - 'Interface1 added to interfaces implemented by TypeThatGainsInterface1.', - }, - { - type: DangerousChangeType.TYPE_ADDED_TO_UNION, - description: - 'TypeInUnion2 was added to union type UnionTypeThatGainsAType.', - }, - ]); - }); - - it('should detect if an optional field argument was added', () => { - const oldSchema = buildSchema(` - type Type1 { - field1(arg1: String): String - } - `); - - const newSchema = buildSchema(` - type Type1 { - field1(arg1: String, arg2: String): String - } - `); - - expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([ - { - type: DangerousChangeType.OPTIONAL_ARG_ADDED, - description: 'An optional arg arg2 on Type1.field1 was added.', - }, - ]); - }); -}); diff --git a/src/utilities/__tests__/getIntrospectionQuery-test.ts b/src/utilities/__tests__/getIntrospectionQuery-test.ts deleted file mode 100644 index 86d1c549db..0000000000 --- a/src/utilities/__tests__/getIntrospectionQuery-test.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import { validate } from '../../validation/validate'; - -import { buildSchema } from '../buildASTSchema'; -import type { IntrospectionOptions } from '../getIntrospectionQuery'; -import { getIntrospectionQuery } from '../getIntrospectionQuery'; - -const dummySchema = buildSchema(` - type Query { - dummy: String - } -`); - -function expectIntrospectionQuery(options?: IntrospectionOptions) { - const query = getIntrospectionQuery(options); - - const validationErrors = validate(dummySchema, parse(query)); - expect(validationErrors).to.deep.equal([]); - - return { - toMatch(name: string, times: number = 1): void { - const pattern = toRegExp(name); - - expect(query).to.match(pattern); - expect(query.match(pattern)).to.have.lengthOf(times); - }, - toNotMatch(name: string): void { - expect(query).to.not.match(toRegExp(name)); - }, - }; - - function toRegExp(name: string): RegExp { - return new RegExp('\\b' + name + '\\b', 'g'); - } -} - -describe('getIntrospectionQuery', () => { - it('skip all "description" fields', () => { - expectIntrospectionQuery().toMatch('description', 5); - - expectIntrospectionQuery({ descriptions: true }).toMatch('description', 5); - - expectIntrospectionQuery({ descriptions: false }).toNotMatch('description'); - }); - - it('include "isRepeatable" field on directives', () => { - expectIntrospectionQuery().toNotMatch('isRepeatable'); - - expectIntrospectionQuery({ directiveIsRepeatable: true }).toMatch( - 'isRepeatable', - ); - - expectIntrospectionQuery({ directiveIsRepeatable: false }).toNotMatch( - 'isRepeatable', - ); - }); - - it('include "description" field on schema', () => { - expectIntrospectionQuery().toMatch('description', 5); - - expectIntrospectionQuery({ schemaDescription: false }).toMatch( - 'description', - 5, - ); - expectIntrospectionQuery({ schemaDescription: true }).toMatch( - 'description', - 6, - ); - - expectIntrospectionQuery({ - descriptions: false, - schemaDescription: true, - }).toNotMatch('description'); - }); - - it('include "specifiedBy" field', () => { - expectIntrospectionQuery().toNotMatch('specifiedByURL'); - - expectIntrospectionQuery({ specifiedByUrl: true }).toMatch( - 'specifiedByURL', - ); - - expectIntrospectionQuery({ specifiedByUrl: false }).toNotMatch( - 'specifiedByURL', - ); - }); - - it('include "isDeprecated" field on input values', () => { - expectIntrospectionQuery().toMatch('isDeprecated', 2); - - expectIntrospectionQuery({ inputValueDeprecation: true }).toMatch( - 'isDeprecated', - 3, - ); - - expectIntrospectionQuery({ inputValueDeprecation: false }).toMatch( - 'isDeprecated', - 2, - ); - }); - - it('include "deprecationReason" field on input values', () => { - expectIntrospectionQuery().toMatch('deprecationReason', 2); - - expectIntrospectionQuery({ inputValueDeprecation: true }).toMatch( - 'deprecationReason', - 3, - ); - - expectIntrospectionQuery({ inputValueDeprecation: false }).toMatch( - 'deprecationReason', - 2, - ); - }); - - it('include "isOneOf" field on input objects', () => { - expectIntrospectionQuery().toNotMatch('isOneOf'); - - expectIntrospectionQuery({ oneOf: true }).toMatch('isOneOf', 1); - - expectIntrospectionQuery({ oneOf: false }).toNotMatch('isOneOf'); - }); - - it('include deprecated input field and args', () => { - expectIntrospectionQuery().toMatch('includeDeprecated: true', 2); - - expectIntrospectionQuery({ inputValueDeprecation: true }).toMatch( - 'includeDeprecated: true', - 5, - ); - - expectIntrospectionQuery({ inputValueDeprecation: false }).toMatch( - 'includeDeprecated: true', - 2, - ); - }); -}); diff --git a/src/utilities/__tests__/getOperationAST-test.ts b/src/utilities/__tests__/getOperationAST-test.ts deleted file mode 100644 index 029dd7706e..0000000000 --- a/src/utilities/__tests__/getOperationAST-test.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import { getOperationAST } from '../getOperationAST'; - -describe('getOperationAST', () => { - it('Gets an operation from a simple document', () => { - const doc = parse('{ field }'); - expect(getOperationAST(doc)).to.equal(doc.definitions[0]); - }); - - it('Gets an operation from a document with named op (mutation)', () => { - const doc = parse('mutation Test { field }'); - expect(getOperationAST(doc)).to.equal(doc.definitions[0]); - }); - - it('Gets an operation from a document with named op (subscription)', () => { - const doc = parse('subscription Test { field }'); - expect(getOperationAST(doc)).to.equal(doc.definitions[0]); - }); - - it('Does not get missing operation', () => { - const doc = parse('type Foo { field: String }'); - expect(getOperationAST(doc)).to.equal(null); - }); - - it('Does not get ambiguous unnamed operation', () => { - const doc = parse(` - { field } - mutation Test { field } - subscription TestSub { field } - `); - expect(getOperationAST(doc)).to.equal(null); - }); - - it('Does not get ambiguous named operation', () => { - const doc = parse(` - query TestQ { field } - mutation TestM { field } - subscription TestS { field } - `); - expect(getOperationAST(doc)).to.equal(null); - }); - - it('Does not get misnamed operation', () => { - const doc = parse(` - { field } - - query TestQ { field } - mutation TestM { field } - subscription TestS { field } - `); - expect(getOperationAST(doc, 'Unknown')).to.equal(null); - }); - - it('Gets named operation', () => { - const doc = parse(` - query TestQ { field } - mutation TestM { field } - subscription TestS { field } - `); - expect(getOperationAST(doc, 'TestQ')).to.equal(doc.definitions[0]); - expect(getOperationAST(doc, 'TestM')).to.equal(doc.definitions[1]); - expect(getOperationAST(doc, 'TestS')).to.equal(doc.definitions[2]); - }); -}); diff --git a/src/utilities/__tests__/getOperationRootType-test.ts b/src/utilities/__tests__/getOperationRootType-test.ts deleted file mode 100644 index ce683a5a12..0000000000 --- a/src/utilities/__tests__/getOperationRootType-test.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { invariant } from '../../jsutils/invariant'; - -import type { DocumentNode, OperationDefinitionNode } from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import { parse } from '../../language/parser'; - -import { GraphQLObjectType } from '../../type/definition'; -import { GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { getOperationRootType } from '../getOperationRootType'; - -const queryType = new GraphQLObjectType({ - name: 'FooQuery', - fields: () => ({ - field: { type: GraphQLString }, - }), -}); - -const mutationType = new GraphQLObjectType({ - name: 'FooMutation', - fields: () => ({ - field: { type: GraphQLString }, - }), -}); - -const subscriptionType = new GraphQLObjectType({ - name: 'FooSubscription', - fields: () => ({ - field: { type: GraphQLString }, - }), -}); - -function getOperationNode(doc: DocumentNode): OperationDefinitionNode { - const operationNode = doc.definitions[0]; - invariant(operationNode.kind === Kind.OPERATION_DEFINITION); - return operationNode; -} - -describe('Deprecated - getOperationRootType', () => { - it('Gets a Query type for an unnamed OperationDefinitionNode', () => { - const testSchema = new GraphQLSchema({ - query: queryType, - }); - const doc = parse('{ field }'); - const operationNode = getOperationNode(doc); - expect(getOperationRootType(testSchema, operationNode)).to.equal(queryType); - }); - - it('Gets a Query type for an named OperationDefinitionNode', () => { - const testSchema = new GraphQLSchema({ - query: queryType, - }); - - const doc = parse('query Q { field }'); - const operationNode = getOperationNode(doc); - expect(getOperationRootType(testSchema, operationNode)).to.equal(queryType); - }); - - it('Gets a type for OperationTypeDefinitionNodes', () => { - const testSchema = new GraphQLSchema({ - query: queryType, - mutation: mutationType, - subscription: subscriptionType, - }); - - const doc = parse(` - schema { - query: FooQuery - mutation: FooMutation - subscription: FooSubscription - } - `); - - const schemaNode = doc.definitions[0]; - invariant(schemaNode.kind === Kind.SCHEMA_DEFINITION); - const [queryNode, mutationNode, subscriptionNode] = - schemaNode.operationTypes; - - expect(getOperationRootType(testSchema, queryNode)).to.equal(queryType); - expect(getOperationRootType(testSchema, mutationNode)).to.equal( - mutationType, - ); - expect(getOperationRootType(testSchema, subscriptionNode)).to.equal( - subscriptionType, - ); - }); - - it('Gets a Mutation type for an OperationDefinitionNode', () => { - const testSchema = new GraphQLSchema({ - mutation: mutationType, - }); - - const doc = parse('mutation { field }'); - const operationNode = getOperationNode(doc); - expect(getOperationRootType(testSchema, operationNode)).to.equal( - mutationType, - ); - }); - - it('Gets a Subscription type for an OperationDefinitionNode', () => { - const testSchema = new GraphQLSchema({ - subscription: subscriptionType, - }); - - const doc = parse('subscription { field }'); - const operationNode = getOperationNode(doc); - expect(getOperationRootType(testSchema, operationNode)).to.equal( - subscriptionType, - ); - }); - - it('Throws when query type not defined in schema', () => { - const testSchema = new GraphQLSchema({}); - - const doc = parse('query { field }'); - const operationNode = getOperationNode(doc); - expect(() => getOperationRootType(testSchema, operationNode)).to.throw( - 'Schema does not define the required query root type.', - ); - }); - - it('Throws when mutation type not defined in schema', () => { - const testSchema = new GraphQLSchema({}); - - const doc = parse('mutation { field }'); - const operationNode = getOperationNode(doc); - expect(() => getOperationRootType(testSchema, operationNode)).to.throw( - 'Schema is not configured for mutations.', - ); - }); - - it('Throws when subscription type not defined in schema', () => { - const testSchema = new GraphQLSchema({}); - - const doc = parse('subscription { field }'); - const operationNode = getOperationNode(doc); - expect(() => getOperationRootType(testSchema, operationNode)).to.throw( - 'Schema is not configured for subscriptions.', - ); - }); - - it('Throws when operation not a valid operation kind', () => { - const testSchema = new GraphQLSchema({}); - const doc = parse('{ field }'); - const operationNode: OperationDefinitionNode = { - ...getOperationNode(doc), - // @ts-expect-error - operation: 'non_existent_operation', - }; - - expect(() => getOperationRootType(testSchema, operationNode)).to.throw( - 'Can only have query, mutation and subscription operations.', - ); - }); -}); diff --git a/src/utilities/__tests__/introspectionFromSchema-test.ts b/src/utilities/__tests__/introspectionFromSchema-test.ts deleted file mode 100644 index 2ba66348d3..0000000000 --- a/src/utilities/__tests__/introspectionFromSchema-test.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { GraphQLObjectType } from '../../type/definition'; -import { GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { buildClientSchema } from '../buildClientSchema'; -import type { IntrospectionQuery } from '../getIntrospectionQuery'; -import { introspectionFromSchema } from '../introspectionFromSchema'; -import { printSchema } from '../printSchema'; - -function introspectionToSDL(introspection: IntrospectionQuery): string { - return printSchema(buildClientSchema(introspection)); -} - -describe('introspectionFromSchema', () => { - const schema = new GraphQLSchema({ - description: 'This is a simple schema', - query: new GraphQLObjectType({ - name: 'Simple', - description: 'This is a simple type', - fields: { - string: { - type: GraphQLString, - description: 'This is a string field', - }, - }, - }), - }); - - it('converts a simple schema', () => { - const introspection = introspectionFromSchema(schema); - - expect(introspectionToSDL(introspection)).to.deep.equal(dedent` - """This is a simple schema""" - schema { - query: Simple - } - - """This is a simple type""" - type Simple { - """This is a string field""" - string: String - } - `); - }); - - it('converts a simple schema without descriptions', () => { - const introspection = introspectionFromSchema(schema, { - descriptions: false, - }); - - expect(introspectionToSDL(introspection)).to.deep.equal(dedent` - schema { - query: Simple - } - - type Simple { - string: String - } - `); - }); -}); diff --git a/src/utilities/__tests__/lexicographicSortSchema-test.ts b/src/utilities/__tests__/lexicographicSortSchema-test.ts deleted file mode 100644 index bce12e3ac5..0000000000 --- a/src/utilities/__tests__/lexicographicSortSchema-test.ts +++ /dev/null @@ -1,359 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { buildSchema } from '../buildASTSchema'; -import { lexicographicSortSchema } from '../lexicographicSortSchema'; -import { printSchema } from '../printSchema'; - -function sortSDL(sdl: string): string { - const schema = buildSchema(sdl); - return printSchema(lexicographicSortSchema(schema)); -} - -describe('lexicographicSortSchema', () => { - it('sort fields', () => { - const sorted = sortSDL(` - input Bar { - barB: String! - barA: String - barC: [String] - } - - interface FooInterface { - fooB: String! - fooA: String - fooC: [String] - } - - type FooType implements FooInterface { - fooC: [String] - fooA: String - fooB: String! - } - - type Query { - dummy(arg: Bar): FooType - } - `); - - expect(sorted).to.equal(dedent` - input Bar { - barA: String - barB: String! - barC: [String] - } - - interface FooInterface { - fooA: String - fooB: String! - fooC: [String] - } - - type FooType implements FooInterface { - fooA: String - fooB: String! - fooC: [String] - } - - type Query { - dummy(arg: Bar): FooType - } - `); - }); - - it('sort implemented interfaces', () => { - const sorted = sortSDL(` - interface FooA { - dummy: String - } - - interface FooB { - dummy: String - } - - interface FooC implements FooB & FooA { - dummy: String - } - - type Query implements FooB & FooA & FooC { - dummy: String - } - `); - - expect(sorted).to.equal(dedent` - interface FooA { - dummy: String - } - - interface FooB { - dummy: String - } - - interface FooC implements FooA & FooB { - dummy: String - } - - type Query implements FooA & FooB & FooC { - dummy: String - } - `); - }); - - it('sort types in union', () => { - const sorted = sortSDL(` - type FooA { - dummy: String - } - - type FooB { - dummy: String - } - - type FooC { - dummy: String - } - - union FooUnion = FooB | FooA | FooC - - type Query { - dummy: FooUnion - } - `); - - expect(sorted).to.equal(dedent` - type FooA { - dummy: String - } - - type FooB { - dummy: String - } - - type FooC { - dummy: String - } - - union FooUnion = FooA | FooB | FooC - - type Query { - dummy: FooUnion - } - `); - }); - - it('sort enum values', () => { - const sorted = sortSDL(` - enum Foo { - B - C - A - } - - type Query { - dummy: Foo - } - `); - - expect(sorted).to.equal(dedent` - enum Foo { - A - B - C - } - - type Query { - dummy: Foo - } - `); - }); - - it('sort field arguments', () => { - const sorted = sortSDL(` - type Query { - dummy(argB: Int!, argA: String, argC: [Float]): ID - } - `); - - expect(sorted).to.equal(dedent` - type Query { - dummy(argA: String, argB: Int!, argC: [Float]): ID - } - `); - }); - - it('sort types', () => { - const sorted = sortSDL(` - type Query { - dummy(arg1: FooF, arg2: FooA, arg3: FooG): FooD - } - - type FooC implements FooE { - dummy: String - } - - enum FooG { - enumValue - } - - scalar FooA - - input FooF { - dummy: String - } - - union FooD = FooC | FooB - - interface FooE { - dummy: String - } - - type FooB { - dummy: String - } - `); - - expect(sorted).to.equal(dedent` - scalar FooA - - type FooB { - dummy: String - } - - type FooC implements FooE { - dummy: String - } - - union FooD = FooB | FooC - - interface FooE { - dummy: String - } - - input FooF { - dummy: String - } - - enum FooG { - enumValue - } - - type Query { - dummy(arg1: FooF, arg2: FooA, arg3: FooG): FooD - } - `); - }); - - it('sort directive arguments', () => { - const sorted = sortSDL(` - directive @test(argC: Float, argA: String, argB: Int) on FIELD - - type Query { - dummy: String - } - `); - - expect(sorted).to.equal(dedent` - directive @test(argA: String, argB: Int, argC: Float) on FIELD - - type Query { - dummy: String - } - `); - }); - - it('sort directive locations', () => { - const sorted = sortSDL(` - directive @test(argC: Float, argA: String, argB: Int) on UNION | FIELD | ENUM - - type Query { - dummy: String - } - `); - - expect(sorted).to.equal(dedent` - directive @test(argA: String, argB: Int, argC: Float) on ENUM | FIELD | UNION - - type Query { - dummy: String - } - `); - }); - - it('sort directives', () => { - const sorted = sortSDL(` - directive @fooC on FIELD - - directive @fooB on UNION - - directive @fooA on ENUM - - type Query { - dummy: String - } - `); - - expect(sorted).to.equal(dedent` - directive @fooA on ENUM - - directive @fooB on UNION - - directive @fooC on FIELD - - type Query { - dummy: String - } - `); - }); - - it('sort recursive types', () => { - const sorted = sortSDL(` - interface FooC { - fooB: FooB - fooA: FooA - fooC: FooC - } - - type FooB implements FooC { - fooB: FooB - fooA: FooA - } - - type FooA implements FooC { - fooB: FooB - fooA: FooA - } - - type Query { - fooC: FooC - fooB: FooB - fooA: FooA - } - `); - - expect(sorted).to.equal(dedent` - type FooA implements FooC { - fooA: FooA - fooB: FooB - } - - type FooB implements FooC { - fooA: FooA - fooB: FooB - } - - interface FooC { - fooA: FooA - fooB: FooB - fooC: FooC - } - - type Query { - fooA: FooA - fooB: FooB - fooC: FooC - } - `); - }); -}); diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts deleted file mode 100644 index 37af4a60f7..0000000000 --- a/src/utilities/__tests__/printSchema-test.ts +++ /dev/null @@ -1,889 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent, dedentString } from '../../__testUtils__/dedent'; - -import { DirectiveLocation } from '../../language/directiveLocation'; - -import type { GraphQLFieldConfig } from '../../type/definition'; -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, -} from '../../type/definition'; -import { GraphQLDirective } from '../../type/directives'; -import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../buildASTSchema'; -import { printIntrospectionSchema, printSchema } from '../printSchema'; - -function expectPrintedSchema(schema: GraphQLSchema) { - const schemaText = printSchema(schema); - // keep printSchema and buildSchema in sync - expect(printSchema(buildSchema(schemaText))).to.equal(schemaText); - return expect(schemaText); -} - -function buildSingleFieldSchema( - fieldConfig: GraphQLFieldConfig, -) { - const Query = new GraphQLObjectType({ - name: 'Query', - fields: { singleField: fieldConfig }, - }); - return new GraphQLSchema({ query: Query }); -} - -describe('Type System Printer', () => { - it('Prints String Field', () => { - const schema = buildSingleFieldSchema({ type: GraphQLString }); - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField: String - } - `); - }); - - it('Prints [String] Field', () => { - const schema = buildSingleFieldSchema({ - type: new GraphQLList(GraphQLString), - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField: [String] - } - `); - }); - - it('Prints String! Field', () => { - const schema = buildSingleFieldSchema({ - type: new GraphQLNonNull(GraphQLString), - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField: String! - } - `); - }); - - it('Prints [String]! Field', () => { - const schema = buildSingleFieldSchema({ - type: new GraphQLNonNull(new GraphQLList(GraphQLString)), - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField: [String]! - } - `); - }); - - it('Prints [String!] Field', () => { - const schema = buildSingleFieldSchema({ - type: new GraphQLList(new GraphQLNonNull(GraphQLString)), - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField: [String!] - } - `); - }); - - it('Prints [String!]! Field', () => { - const schema = buildSingleFieldSchema({ - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(GraphQLString)), - ), - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField: [String!]! - } - `); - }); - - it('Print Object Field', () => { - const FooType = new GraphQLObjectType({ - name: 'Foo', - fields: { str: { type: GraphQLString } }, - }); - const schema = new GraphQLSchema({ types: [FooType] }); - - expectPrintedSchema(schema).to.equal(dedent` - type Foo { - str: String - } - `); - }); - - it('Prints String Field With Int Arg', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { argOne: { type: GraphQLInt } }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int): String - } - `); - }); - - it('Prints String Field With Int Arg With Default', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { argOne: { type: GraphQLInt, defaultValue: 2 } }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int = 2): String - } - `); - }); - - it('Prints String Field With String Arg With Default', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { argOne: { type: GraphQLString, defaultValue: 'tes\t de\fault' } }, - }); - - expectPrintedSchema(schema).to.equal( - dedentString(String.raw` - type Query { - singleField(argOne: String = "tes\t de\fault"): String - } - `), - ); - }); - - it('Prints String Field With Int Arg With Default Null', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { argOne: { type: GraphQLInt, defaultValue: null } }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int = null): String - } - `); - }); - - it('Prints String Field With Int! Arg', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { argOne: { type: new GraphQLNonNull(GraphQLInt) } }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int!): String - } - `); - }); - - it('Prints String Field With Multiple Args', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { - argOne: { type: GraphQLInt }, - argTwo: { type: GraphQLString }, - }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int, argTwo: String): String - } - `); - }); - - it('Prints String Field With Multiple Args, First is Default', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { - argOne: { type: GraphQLInt, defaultValue: 1 }, - argTwo: { type: GraphQLString }, - argThree: { type: GraphQLBoolean }, - }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int = 1, argTwo: String, argThree: Boolean): String - } - `); - }); - - it('Prints String Field With Multiple Args, Second is Default', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { - argOne: { type: GraphQLInt }, - argTwo: { type: GraphQLString, defaultValue: 'foo' }, - argThree: { type: GraphQLBoolean }, - }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int, argTwo: String = "foo", argThree: Boolean): String - } - `); - }); - - it('Prints String Field With Multiple Args, Last is Default', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - args: { - argOne: { type: GraphQLInt }, - argTwo: { type: GraphQLString }, - argThree: { type: GraphQLBoolean, defaultValue: false }, - }, - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - singleField(argOne: Int, argTwo: String, argThree: Boolean = false): String - } - `); - }); - - it('Prints schema with description', () => { - const schema = new GraphQLSchema({ - description: 'Schema description.', - query: new GraphQLObjectType({ name: 'Query', fields: {} }), - }); - - expectPrintedSchema(schema).to.equal(dedent` - """Schema description.""" - schema { - query: Query - } - - type Query - `); - }); - - it('Omits schema of common names', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ name: 'Query', fields: {} }), - mutation: new GraphQLObjectType({ name: 'Mutation', fields: {} }), - subscription: new GraphQLObjectType({ name: 'Subscription', fields: {} }), - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query - - type Mutation - - type Subscription - `); - }); - - it('Prints custom query root types', () => { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ name: 'CustomType', fields: {} }), - }); - - expectPrintedSchema(schema).to.equal(dedent` - schema { - query: CustomType - } - - type CustomType - `); - }); - - it('Prints custom mutation root types', () => { - const schema = new GraphQLSchema({ - mutation: new GraphQLObjectType({ name: 'CustomType', fields: {} }), - }); - - expectPrintedSchema(schema).to.equal(dedent` - schema { - mutation: CustomType - } - - type CustomType - `); - }); - - it('Prints custom subscription root types', () => { - const schema = new GraphQLSchema({ - subscription: new GraphQLObjectType({ name: 'CustomType', fields: {} }), - }); - - expectPrintedSchema(schema).to.equal(dedent` - schema { - subscription: CustomType - } - - type CustomType - `); - }); - - it('Print Interface', () => { - const FooType = new GraphQLInterfaceType({ - name: 'Foo', - fields: { str: { type: GraphQLString } }, - }); - - const BarType = new GraphQLObjectType({ - name: 'Bar', - fields: { str: { type: GraphQLString } }, - interfaces: [FooType], - }); - - const schema = new GraphQLSchema({ types: [BarType] }); - expectPrintedSchema(schema).to.equal(dedent` - type Bar implements Foo { - str: String - } - - interface Foo { - str: String - } - `); - }); - - it('Print Multiple Interface', () => { - const FooType = new GraphQLInterfaceType({ - name: 'Foo', - fields: { str: { type: GraphQLString } }, - }); - - const BazType = new GraphQLInterfaceType({ - name: 'Baz', - fields: { int: { type: GraphQLInt } }, - }); - - const BarType = new GraphQLObjectType({ - name: 'Bar', - fields: { - str: { type: GraphQLString }, - int: { type: GraphQLInt }, - }, - interfaces: [FooType, BazType], - }); - - const schema = new GraphQLSchema({ types: [BarType] }); - expectPrintedSchema(schema).to.equal(dedent` - type Bar implements Foo & Baz { - str: String - int: Int - } - - interface Foo { - str: String - } - - interface Baz { - int: Int - } - `); - }); - - it('Print Hierarchical Interface', () => { - const FooType = new GraphQLInterfaceType({ - name: 'Foo', - fields: { str: { type: GraphQLString } }, - }); - - const BazType = new GraphQLInterfaceType({ - name: 'Baz', - interfaces: [FooType], - fields: { - int: { type: GraphQLInt }, - str: { type: GraphQLString }, - }, - }); - - const BarType = new GraphQLObjectType({ - name: 'Bar', - fields: { - str: { type: GraphQLString }, - int: { type: GraphQLInt }, - }, - interfaces: [FooType, BazType], - }); - - const Query = new GraphQLObjectType({ - name: 'Query', - fields: { bar: { type: BarType } }, - }); - - const schema = new GraphQLSchema({ query: Query, types: [BarType] }); - expectPrintedSchema(schema).to.equal(dedent` - type Bar implements Foo & Baz { - str: String - int: Int - } - - interface Foo { - str: String - } - - interface Baz implements Foo { - int: Int - str: String - } - - type Query { - bar: Bar - } - `); - }); - - it('Print Unions', () => { - const FooType = new GraphQLObjectType({ - name: 'Foo', - fields: { - bool: { type: GraphQLBoolean }, - }, - }); - - const BarType = new GraphQLObjectType({ - name: 'Bar', - fields: { - str: { type: GraphQLString }, - }, - }); - - const SingleUnion = new GraphQLUnionType({ - name: 'SingleUnion', - types: [FooType], - }); - - const MultipleUnion = new GraphQLUnionType({ - name: 'MultipleUnion', - types: [FooType, BarType], - }); - - const schema = new GraphQLSchema({ types: [SingleUnion, MultipleUnion] }); - expectPrintedSchema(schema).to.equal(dedent` - union SingleUnion = Foo - - type Foo { - bool: Boolean - } - - union MultipleUnion = Foo | Bar - - type Bar { - str: String - } - `); - }); - - it('Print Input Type', () => { - const InputType = new GraphQLInputObjectType({ - name: 'InputType', - fields: { - int: { type: GraphQLInt }, - }, - }); - - const schema = new GraphQLSchema({ types: [InputType] }); - expectPrintedSchema(schema).to.equal(dedent` - input InputType { - int: Int - } - `); - }); - - it('Print Input Type with @oneOf directive', () => { - const InputType = new GraphQLInputObjectType({ - name: 'InputType', - isOneOf: true, - fields: { - int: { type: GraphQLInt }, - }, - }); - - const schema = new GraphQLSchema({ types: [InputType] }); - expectPrintedSchema(schema).to.equal(dedent` - input InputType @oneOf { - int: Int - } - `); - }); - - it('Custom Scalar', () => { - const OddType = new GraphQLScalarType({ name: 'Odd' }); - - const schema = new GraphQLSchema({ types: [OddType] }); - expectPrintedSchema(schema).to.equal(dedent` - scalar Odd - `); - }); - - it('Custom Scalar with specifiedByURL', () => { - const FooType = new GraphQLScalarType({ - name: 'Foo', - specifiedByURL: 'https://example.com/foo_spec', - }); - - const schema = new GraphQLSchema({ types: [FooType] }); - expectPrintedSchema(schema).to.equal(dedent` - scalar Foo @specifiedBy(url: "https://example.com/foo_spec") - `); - }); - - it('Enum', () => { - const RGBType = new GraphQLEnumType({ - name: 'RGB', - values: { - RED: {}, - GREEN: {}, - BLUE: {}, - }, - }); - - const schema = new GraphQLSchema({ types: [RGBType] }); - expectPrintedSchema(schema).to.equal(dedent` - enum RGB { - RED - GREEN - BLUE - } - `); - }); - - it('Prints empty types', () => { - const schema = new GraphQLSchema({ - types: [ - new GraphQLEnumType({ name: 'SomeEnum', values: {} }), - new GraphQLInputObjectType({ name: 'SomeInputObject', fields: {} }), - new GraphQLInterfaceType({ name: 'SomeInterface', fields: {} }), - new GraphQLObjectType({ name: 'SomeObject', fields: {} }), - new GraphQLUnionType({ name: 'SomeUnion', types: [] }), - ], - }); - - expectPrintedSchema(schema).to.equal(dedent` - enum SomeEnum - - input SomeInputObject - - interface SomeInterface - - type SomeObject - - union SomeUnion - `); - }); - - it('Prints custom directives', () => { - const SimpleDirective = new GraphQLDirective({ - name: 'simpleDirective', - locations: [DirectiveLocation.FIELD], - }); - const ComplexDirective = new GraphQLDirective({ - name: 'complexDirective', - description: 'Complex Directive', - args: { - stringArg: { type: GraphQLString }, - intArg: { type: GraphQLInt, defaultValue: -1 }, - }, - isRepeatable: true, - locations: [DirectiveLocation.FIELD, DirectiveLocation.QUERY], - }); - - const schema = new GraphQLSchema({ - directives: [SimpleDirective, ComplexDirective], - }); - expectPrintedSchema(schema).to.equal(dedent` - directive @simpleDirective on FIELD - - """Complex Directive""" - directive @complexDirective(stringArg: String, intArg: Int = -1) repeatable on FIELD | QUERY - `); - }); - - it('Prints an empty description', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - description: '', - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - """""" - singleField: String - } - `); - }); - - it('Prints an description with only whitespace', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - description: ' ', - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - " " - singleField: String - } - `); - }); - - it('One-line prints a short description', () => { - const schema = buildSingleFieldSchema({ - type: GraphQLString, - description: 'This field is awesome', - }); - - expectPrintedSchema(schema).to.equal(dedent` - type Query { - """This field is awesome""" - singleField: String - } - `); - }); - - it('Print Introspection Schema', () => { - const schema = new GraphQLSchema({}); - const output = printIntrospectionSchema(schema); - - expect(output).to.equal(dedent` - """ - Directs the executor to include this field or fragment only when the \`if\` argument is true. - """ - directive @include( - """Included when true.""" - if: Boolean! - ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - - """ - Directs the executor to skip this field or fragment when the \`if\` argument is true. - """ - directive @skip( - """Skipped when true.""" - if: Boolean! - ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - - """Marks an element of a GraphQL schema as no longer supported.""" - directive @deprecated( - """ - Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/). - """ - reason: String = "No longer supported" - ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE - - """Exposes a URL that specifies the behavior of this scalar.""" - directive @specifiedBy( - """The URL that specifies the behavior of this scalar.""" - url: String! - ) on SCALAR - - """ - Indicates exactly one field must be supplied and this field must not be \`null\`. - """ - directive @oneOf on INPUT_OBJECT - - """ - A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations. - """ - type __Schema { - description: String - - """A list of all types supported by this server.""" - types: [__Type!]! - - """The type that query operations will be rooted at.""" - queryType: __Type! - - """ - If this server supports mutation, the type that mutation operations will be rooted at. - """ - mutationType: __Type - - """ - If this server support subscription, the type that subscription operations will be rooted at. - """ - subscriptionType: __Type - - """A list of all directives supported by this server.""" - directives: [__Directive!]! - } - - """ - The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \`__TypeKind\` enum. - - Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional \`specifiedByURL\`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. - """ - type __Type { - kind: __TypeKind! - name: String - description: String - specifiedByURL: String - fields(includeDeprecated: Boolean = false): [__Field!] - interfaces: [__Type!] - possibleTypes: [__Type!] - enumValues(includeDeprecated: Boolean = false): [__EnumValue!] - inputFields(includeDeprecated: Boolean = false): [__InputValue!] - ofType: __Type - isOneOf: Boolean - } - - """An enum describing what kind of type a given \`__Type\` is.""" - enum __TypeKind { - """Indicates this type is a scalar.""" - SCALAR - - """ - Indicates this type is an object. \`fields\` and \`interfaces\` are valid fields. - """ - OBJECT - - """ - Indicates this type is an interface. \`fields\`, \`interfaces\`, and \`possibleTypes\` are valid fields. - """ - INTERFACE - - """Indicates this type is a union. \`possibleTypes\` is a valid field.""" - UNION - - """Indicates this type is an enum. \`enumValues\` is a valid field.""" - ENUM - - """ - Indicates this type is an input object. \`inputFields\` is a valid field. - """ - INPUT_OBJECT - - """Indicates this type is a list. \`ofType\` is a valid field.""" - LIST - - """Indicates this type is a non-null. \`ofType\` is a valid field.""" - NON_NULL - } - - """ - Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type. - """ - type __Field { - name: String! - description: String - args(includeDeprecated: Boolean = false): [__InputValue!]! - type: __Type! - isDeprecated: Boolean! - deprecationReason: String - } - - """ - Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value. - """ - type __InputValue { - name: String! - description: String - type: __Type! - - """ - A GraphQL-formatted string representing the default value for this input value. - """ - defaultValue: String - isDeprecated: Boolean! - deprecationReason: String - } - - """ - One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string. - """ - type __EnumValue { - name: String! - description: String - isDeprecated: Boolean! - deprecationReason: String - } - - """ - A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document. - - In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor. - """ - type __Directive { - name: String! - description: String - isRepeatable: Boolean! - locations: [__DirectiveLocation!]! - args(includeDeprecated: Boolean = false): [__InputValue!]! - } - - """ - A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies. - """ - enum __DirectiveLocation { - """Location adjacent to a query operation.""" - QUERY - - """Location adjacent to a mutation operation.""" - MUTATION - - """Location adjacent to a subscription operation.""" - SUBSCRIPTION - - """Location adjacent to a field.""" - FIELD - - """Location adjacent to a fragment definition.""" - FRAGMENT_DEFINITION - - """Location adjacent to a fragment spread.""" - FRAGMENT_SPREAD - - """Location adjacent to an inline fragment.""" - INLINE_FRAGMENT - - """Location adjacent to a variable definition.""" - VARIABLE_DEFINITION - - """Location adjacent to a schema definition.""" - SCHEMA - - """Location adjacent to a scalar definition.""" - SCALAR - - """Location adjacent to an object type definition.""" - OBJECT - - """Location adjacent to a field definition.""" - FIELD_DEFINITION - - """Location adjacent to an argument definition.""" - ARGUMENT_DEFINITION - - """Location adjacent to an interface definition.""" - INTERFACE - - """Location adjacent to a union definition.""" - UNION - - """Location adjacent to an enum definition.""" - ENUM - - """Location adjacent to an enum value definition.""" - ENUM_VALUE - - """Location adjacent to an input object type definition.""" - INPUT_OBJECT - - """Location adjacent to an input object field definition.""" - INPUT_FIELD_DEFINITION - } - `); - }); -}); diff --git a/src/utilities/__tests__/separateOperations-test.ts b/src/utilities/__tests__/separateOperations-test.ts deleted file mode 100644 index 2f14bae9ac..0000000000 --- a/src/utilities/__tests__/separateOperations-test.ts +++ /dev/null @@ -1,258 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; - -import { mapValue } from '../../jsutils/mapValue'; - -import { parse } from '../../language/parser'; -import { print } from '../../language/printer'; - -import { separateOperations } from '../separateOperations'; - -describe('separateOperations', () => { - it('separates one AST into multiple, maintaining document order', () => { - const ast = parse(` - { - ...Y - ...X - } - - query One { - foo - bar - ...A - ...X - } - - fragment A on T { - field - ...B - } - - fragment X on T { - fieldX - } - - query Two { - ...A - ...Y - baz - } - - fragment Y on T { - fieldY - } - - fragment B on T { - something - } - `); - - const separatedASTs = mapValue(separateOperations(ast), print); - expect(separatedASTs).to.deep.equal({ - '': dedent` - { - ...Y - ...X - } - - fragment X on T { - fieldX - } - - fragment Y on T { - fieldY - } - `, - One: dedent` - query One { - foo - bar - ...A - ...X - } - - fragment A on T { - field - ...B - } - - fragment X on T { - fieldX - } - - fragment B on T { - something - } - `, - Two: dedent` - fragment A on T { - field - ...B - } - - query Two { - ...A - ...Y - baz - } - - fragment Y on T { - fieldY - } - - fragment B on T { - something - } - `, - }); - }); - - it('survives circular dependencies', () => { - const ast = parse(` - query One { - ...A - } - - fragment A on T { - ...B - } - - fragment B on T { - ...A - } - - query Two { - ...B - } - `); - - const separatedASTs = mapValue(separateOperations(ast), print); - expect(separatedASTs).to.deep.equal({ - One: dedent` - query One { - ...A - } - - fragment A on T { - ...B - } - - fragment B on T { - ...A - } - `, - Two: dedent` - fragment A on T { - ...B - } - - fragment B on T { - ...A - } - - query Two { - ...B - } - `, - }); - }); - - it('distinguish query and fragment names', () => { - const ast = parse(` - { - ...NameClash - } - - fragment NameClash on T { - oneField - } - - query NameClash { - ...ShouldBeSkippedInFirstQuery - } - - fragment ShouldBeSkippedInFirstQuery on T { - twoField - } - `); - - const separatedASTs = mapValue(separateOperations(ast), print); - expect(separatedASTs).to.deep.equal({ - '': dedent` - { - ...NameClash - } - - fragment NameClash on T { - oneField - } - `, - NameClash: dedent` - query NameClash { - ...ShouldBeSkippedInFirstQuery - } - - fragment ShouldBeSkippedInFirstQuery on T { - twoField - } - `, - }); - }); - - it('ignores type definitions', () => { - const ast = parse(` - query Foo { - ...Bar - } - - fragment Bar on T { - baz - } - - scalar Foo - type Bar - `); - - const separatedASTs = mapValue(separateOperations(ast), print); - expect(separatedASTs).to.deep.equal({ - Foo: dedent` - query Foo { - ...Bar - } - - fragment Bar on T { - baz - } - `, - }); - }); - - it('handles unknown fragments', () => { - const ast = parse(` - { - ...Unknown - ...Known - } - - fragment Known on T { - someField - } - `); - - const separatedASTs = mapValue(separateOperations(ast), print); - expect(separatedASTs).to.deep.equal({ - '': dedent` - { - ...Unknown - ...Known - } - - fragment Known on T { - someField - } - `, - }); - }); -}); diff --git a/src/utilities/__tests__/sortValueNode-test.ts b/src/utilities/__tests__/sortValueNode-test.ts deleted file mode 100644 index 5bda137d14..0000000000 --- a/src/utilities/__tests__/sortValueNode-test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parseValue } from '../../language/parser'; -import { print } from '../../language/printer'; - -import { sortValueNode } from '../sortValueNode'; - -describe('sortValueNode', () => { - function expectSortedValue(source: string) { - return expect(print(sortValueNode(parseValue(source)))); - } - - it('do not change non-object values', () => { - expectSortedValue('1').to.equal('1'); - expectSortedValue('3.14').to.equal('3.14'); - expectSortedValue('null').to.equal('null'); - expectSortedValue('true').to.equal('true'); - expectSortedValue('false').to.equal('false'); - expectSortedValue('"cba"').to.equal('"cba"'); - expectSortedValue('"""cba"""').to.equal('"""cba"""'); - expectSortedValue('[1, 3.14, null, false, "cba"]').to.equal( - '[1, 3.14, null, false, "cba"]', - ); - expectSortedValue('[[1, 3.14, null, false, "cba"]]').to.equal( - '[[1, 3.14, null, false, "cba"]]', - ); - }); - - it('sort input object fields', () => { - expectSortedValue('{ b: 2, a: 1 }').to.equal('{a: 1, b: 2}'); - expectSortedValue('{ a: { c: 3, b: 2 } }').to.equal('{a: {b: 2, c: 3}}'); - expectSortedValue('[{ b: 2, a: 1 }, { d: 4, c: 3}]').to.equal( - '[{a: 1, b: 2}, {c: 3, d: 4}]', - ); - expectSortedValue( - '{ b: { g: 7, f: 6 }, c: 3 , a: { d: 4, e: 5 } }', - ).to.equal('{a: {d: 4, e: 5}, b: {f: 6, g: 7}, c: 3}'); - }); -}); diff --git a/src/utilities/__tests__/stripIgnoredCharacters-fuzz.ts b/src/utilities/__tests__/stripIgnoredCharacters-fuzz.ts deleted file mode 100644 index 29a22ed838..0000000000 --- a/src/utilities/__tests__/stripIgnoredCharacters-fuzz.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { genFuzzStrings } from '../../__testUtils__/genFuzzStrings'; -import { inspectStr } from '../../__testUtils__/inspectStr'; - -import { invariant } from '../../jsutils/invariant'; - -import { Lexer } from '../../language/lexer'; -import { Source } from '../../language/source'; - -import { stripIgnoredCharacters } from '../stripIgnoredCharacters'; - -function lexValue(str: string) { - const lexer = new Lexer(new Source(str)); - const value = lexer.advance().value; - - invariant(lexer.advance().kind === '', 'Expected EOF'); - return value; -} - -describe('stripIgnoredCharacters', () => { - it('strips ignored characters inside random block strings', () => { - // Testing with length >7 is taking exponentially more time. However it is - // highly recommended to test with increased limit if you make any change. - for (const fuzzStr of genFuzzStrings({ - allowedChars: ['\n', '\t', ' ', '"', 'a', '\\'], - maxLength: 7, - })) { - const testStr = '"""' + fuzzStr + '"""'; - - let testValue; - try { - testValue = lexValue(testStr); - } catch (e) { - continue; // skip invalid values - } - - const strippedValue = lexValue(stripIgnoredCharacters(testStr)); - - invariant( - testValue === strippedValue, - dedent` - Expected lexValue(stripIgnoredCharacters(${inspectStr(testStr)})) - to equal ${inspectStr(testValue)} - but got ${inspectStr(strippedValue)} - `, - ); - } - }).timeout(20000); -}); diff --git a/src/utilities/__tests__/stripIgnoredCharacters-test.ts b/src/utilities/__tests__/stripIgnoredCharacters-test.ts deleted file mode 100644 index 4115742f5c..0000000000 --- a/src/utilities/__tests__/stripIgnoredCharacters-test.ts +++ /dev/null @@ -1,446 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { dedent } from '../../__testUtils__/dedent'; -import { inspectStr } from '../../__testUtils__/inspectStr'; -import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery'; -import { kitchenSinkSDL } from '../../__testUtils__/kitchenSinkSDL'; - -import { invariant } from '../../jsutils/invariant'; -import type { Maybe } from '../../jsutils/Maybe'; - -import { Lexer } from '../../language/lexer'; -import { parse } from '../../language/parser'; -import { Source } from '../../language/source'; - -import { stripIgnoredCharacters } from '../stripIgnoredCharacters'; - -const ignoredTokens = [ - // UnicodeBOM :: - '\uFEFF', // Byte Order Mark (U+FEFF) - - // WhiteSpace :: - '\t', // Horizontal Tab (U+0009) - ' ', // Space (U+0020) - - // LineTerminator :: - '\n', // "New Line (U+000A)" - '\r', // "Carriage Return (U+000D)" [ lookahead ! "New Line (U+000A)" ] - '\r\n', // "Carriage Return (U+000D)" "New Line (U+000A)" - - // Comment :: - '# "Comment" string\n', // `#` CommentChar* - - // Comma :: - ',', // , -]; - -const punctuatorTokens = [ - '!', - '$', - '(', - ')', - '...', - ':', - '=', - '@', - '[', - ']', - '{', - '|', - '}', -]; - -const nonPunctuatorTokens = [ - 'name_token', // Name - '1', // IntValue - '3.14', // FloatValue - '"some string value"', // StringValue - '"""block\nstring\nvalue"""', // StringValue(BlockString) -]; - -function lexValue(str: string): Maybe { - const lexer = new Lexer(new Source(str)); - const value = lexer.advance().value; - - invariant(lexer.advance().kind === '', 'Expected EOF'); - return value; -} - -function expectStripped(docString: string) { - return { - toEqual(expected: string): void { - const stripped = stripIgnoredCharacters(docString); - - invariant( - stripped === expected, - dedent` - Expected stripIgnoredCharacters(${inspectStr(docString)}) - to equal ${inspectStr(expected)} - but got ${inspectStr(stripped)} - `, - ); - - const strippedTwice = stripIgnoredCharacters(stripped); - - invariant( - stripped === strippedTwice, - dedent` - Expected stripIgnoredCharacters(${inspectStr(stripped)}) - to equal ${inspectStr(stripped)} - but got ${inspectStr(strippedTwice)} - `, - ); - }, - toStayTheSame(): void { - this.toEqual(docString); - }, - }; -} - -describe('stripIgnoredCharacters', () => { - it('strips ignored characters from GraphQL query document', () => { - const query = dedent` - query SomeQuery($foo: String!, $bar: String) { - someField(foo: $foo, bar: $bar) { - a - b { - c - d - } - } - } - `; - - expect(stripIgnoredCharacters(query)).to.equal( - 'query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}', - ); - }); - - it('accepts Source object', () => { - expect(stripIgnoredCharacters(new Source('{ a }'))).to.equal('{a}'); - }); - - it('strips ignored characters from GraphQL SDL document', () => { - const sdl = dedent` - """ - Type description - """ - type Foo { - """ - Field description - """ - bar: String - } - `; - - expect(stripIgnoredCharacters(sdl)).to.equal( - '"""Type description""" type Foo{"""Field description""" bar:String}', - ); - }); - - it('report document with invalid token', () => { - let caughtError; - - try { - stripIgnoredCharacters('{ foo(arg: "\n"'); - } catch (e) { - caughtError = e; - } - - expect(String(caughtError)).to.equal(dedent` - Syntax Error: Unterminated string. - - GraphQL request:1:13 - 1 | { foo(arg: " - | ^ - 2 | " - `); - }); - - it('strips non-parsable document', () => { - expectStripped('{ foo(arg: "str"').toEqual('{foo(arg:"str"'); - }); - - it('strips documents with only ignored characters', () => { - expectStripped('\n').toEqual(''); - expectStripped(',').toEqual(''); - expectStripped(',,').toEqual(''); - expectStripped('#comment\n, \n').toEqual(''); - - for (const ignored of ignoredTokens) { - expectStripped(ignored).toEqual(''); - - for (const anotherIgnored of ignoredTokens) { - expectStripped(ignored + anotherIgnored).toEqual(''); - } - } - - expectStripped(ignoredTokens.join('')).toEqual(''); - }); - - it('strips leading and trailing ignored tokens', () => { - expectStripped('\n1').toEqual('1'); - expectStripped(',1').toEqual('1'); - expectStripped(',,1').toEqual('1'); - expectStripped('#comment\n, \n1').toEqual('1'); - - expectStripped('1\n').toEqual('1'); - expectStripped('1,').toEqual('1'); - expectStripped('1,,').toEqual('1'); - expectStripped('1#comment\n, \n').toEqual('1'); - - for (const token of [...punctuatorTokens, ...nonPunctuatorTokens]) { - for (const ignored of ignoredTokens) { - expectStripped(ignored + token).toEqual(token); - expectStripped(token + ignored).toEqual(token); - - for (const anotherIgnored of ignoredTokens) { - expectStripped(token + ignored + ignored).toEqual(token); - expectStripped(ignored + anotherIgnored + token).toEqual(token); - } - } - - expectStripped(ignoredTokens.join('') + token).toEqual(token); - expectStripped(token + ignoredTokens.join('')).toEqual(token); - } - }); - - it('strips ignored tokens between punctuator tokens', () => { - expectStripped('[,)').toEqual('[)'); - expectStripped('[\r)').toEqual('[)'); - expectStripped('[\r\r)').toEqual('[)'); - expectStripped('[\r,)').toEqual('[)'); - expectStripped('[,\n)').toEqual('[)'); - - for (const left of punctuatorTokens) { - for (const right of punctuatorTokens) { - for (const ignored of ignoredTokens) { - expectStripped(left + ignored + right).toEqual(left + right); - - for (const anotherIgnored of ignoredTokens) { - expectStripped(left + ignored + anotherIgnored + right).toEqual( - left + right, - ); - } - } - - expectStripped(left + ignoredTokens.join('') + right).toEqual( - left + right, - ); - } - } - }); - - it('strips ignored tokens between punctuator and non-punctuator tokens', () => { - expectStripped('[,1').toEqual('[1'); - expectStripped('[\r1').toEqual('[1'); - expectStripped('[\r\r1').toEqual('[1'); - expectStripped('[\r,1').toEqual('[1'); - expectStripped('[,\n1').toEqual('[1'); - - for (const nonPunctuator of nonPunctuatorTokens) { - for (const punctuator of punctuatorTokens) { - for (const ignored of ignoredTokens) { - expectStripped(punctuator + ignored + nonPunctuator).toEqual( - punctuator + nonPunctuator, - ); - - for (const anotherIgnored of ignoredTokens) { - expectStripped( - punctuator + ignored + anotherIgnored + nonPunctuator, - ).toEqual(punctuator + nonPunctuator); - } - } - - expectStripped( - punctuator + ignoredTokens.join('') + nonPunctuator, - ).toEqual(punctuator + nonPunctuator); - } - } - }); - - it('strips ignored tokens between non-punctuator and punctuator tokens', () => { - expectStripped('1,[').toEqual('1['); - expectStripped('1\r[').toEqual('1['); - expectStripped('1\r\r[').toEqual('1['); - expectStripped('1\r,[').toEqual('1['); - expectStripped('1,\n[').toEqual('1['); - - for (const nonPunctuator of nonPunctuatorTokens) { - for (const punctuator of punctuatorTokens) { - // Special case for that is handled in the below test - if (punctuator === '...') { - continue; - } - - for (const ignored of ignoredTokens) { - expectStripped(nonPunctuator + ignored + punctuator).toEqual( - nonPunctuator + punctuator, - ); - - for (const anotherIgnored of ignoredTokens) { - expectStripped( - nonPunctuator + ignored + anotherIgnored + punctuator, - ).toEqual(nonPunctuator + punctuator); - } - } - - expectStripped( - nonPunctuator + ignoredTokens.join('') + punctuator, - ).toEqual(nonPunctuator + punctuator); - } - } - }); - - it('replace ignored tokens between non-punctuator tokens and spread with space', () => { - expectStripped('a ...').toEqual('a ...'); - expectStripped('1 ...').toEqual('1 ...'); - expectStripped('1 ... ...').toEqual('1 ......'); - - for (const nonPunctuator of nonPunctuatorTokens) { - for (const ignored of ignoredTokens) { - expectStripped(nonPunctuator + ignored + '...').toEqual( - nonPunctuator + ' ...', - ); - - for (const anotherIgnored of ignoredTokens) { - expectStripped( - nonPunctuator + ignored + anotherIgnored + ' ...', - ).toEqual(nonPunctuator + ' ...'); - } - } - - expectStripped(nonPunctuator + ignoredTokens.join('') + '...').toEqual( - nonPunctuator + ' ...', - ); - } - }); - - it('replace ignored tokens between non-punctuator tokens with space', () => { - expectStripped('1 2').toStayTheSame(); - expectStripped('"" ""').toStayTheSame(); - expectStripped('a b').toStayTheSame(); - - expectStripped('a,1').toEqual('a 1'); - expectStripped('a,,1').toEqual('a 1'); - expectStripped('a 1').toEqual('a 1'); - expectStripped('a \t 1').toEqual('a 1'); - - for (const left of nonPunctuatorTokens) { - for (const right of nonPunctuatorTokens) { - for (const ignored of ignoredTokens) { - expectStripped(left + ignored + right).toEqual(left + ' ' + right); - - for (const anotherIgnored of ignoredTokens) { - expectStripped(left + ignored + anotherIgnored + right).toEqual( - left + ' ' + right, - ); - } - } - - expectStripped(left + ignoredTokens.join('') + right).toEqual( - left + ' ' + right, - ); - } - } - }); - - it('does not strip ignored tokens embedded in the string', () => { - expectStripped('" "').toStayTheSame(); - expectStripped('","').toStayTheSame(); - expectStripped('",,"').toStayTheSame(); - expectStripped('",|"').toStayTheSame(); - - for (const ignored of ignoredTokens) { - expectStripped(JSON.stringify(ignored)).toStayTheSame(); - - for (const anotherIgnored of ignoredTokens) { - expectStripped( - JSON.stringify(ignored + anotherIgnored), - ).toStayTheSame(); - } - } - - expectStripped(JSON.stringify(ignoredTokens.join(''))).toStayTheSame(); - }); - - it('does not strip ignored tokens embedded in the block string', () => { - expectStripped('""","""').toStayTheSame(); - expectStripped('""",,"""').toStayTheSame(); - expectStripped('""",|"""').toStayTheSame(); - - const ignoredTokensWithoutFormatting = ignoredTokens.filter( - (token) => !['\n', '\r', '\r\n', '\t', ' '].includes(token), - ); - for (const ignored of ignoredTokensWithoutFormatting) { - expectStripped('"""|' + ignored + '|"""').toStayTheSame(); - - for (const anotherIgnored of ignoredTokensWithoutFormatting) { - expectStripped( - '"""|' + ignored + anotherIgnored + '|"""', - ).toStayTheSame(); - } - } - - expectStripped( - '"""|' + ignoredTokensWithoutFormatting.join('') + '|"""', - ).toStayTheSame(); - }); - - it('strips ignored characters inside block strings', () => { - function expectStrippedString(blockStr: string) { - const originalValue = lexValue(blockStr); - const strippedValue = lexValue(stripIgnoredCharacters(blockStr)); - - invariant( - originalValue === strippedValue, - dedent` - Expected lexValue(stripIgnoredCharacters(${inspectStr(blockStr)})) - to equal ${inspectStr(originalValue)} - but got ${inspectStr(strippedValue)} - `, - ); - return expectStripped(blockStr); - } - - expectStrippedString('""""""').toStayTheSame(); - expectStrippedString('""" """').toEqual('""""""'); - - expectStrippedString('"""a"""').toStayTheSame(); - expectStrippedString('""" a"""').toEqual('""" a"""'); - expectStrippedString('""" a """').toEqual('""" a """'); - - expectStrippedString('"""\n"""').toEqual('""""""'); - expectStrippedString('"""a\nb"""').toEqual('"""a\nb"""'); - expectStrippedString('"""a\rb"""').toEqual('"""a\nb"""'); - expectStrippedString('"""a\r\nb"""').toEqual('"""a\nb"""'); - expectStrippedString('"""a\r\n\nb"""').toEqual('"""a\n\nb"""'); - - expectStrippedString('"""\\\n"""').toStayTheSame(); - expectStrippedString('""""\n"""').toStayTheSame(); - expectStrippedString('"""\\"""\n"""').toEqual('"""\\""""""'); - - expectStrippedString('"""\na\n b"""').toStayTheSame(); - expectStrippedString('"""\n a\n b"""').toEqual('"""a\nb"""'); - expectStrippedString('"""\na\n b\nc"""').toEqual('"""a\n b\nc"""'); - }); - - it('strips kitchen sink query but maintains the exact same AST', () => { - const strippedQuery = stripIgnoredCharacters(kitchenSinkQuery); - expect(stripIgnoredCharacters(strippedQuery)).to.equal(strippedQuery); - - const queryAST = parse(kitchenSinkQuery, { noLocation: true }); - const strippedAST = parse(strippedQuery, { noLocation: true }); - expect(strippedAST).to.deep.equal(queryAST); - }); - - it('strips kitchen sink SDL but maintains the exact same AST', () => { - const strippedSDL = stripIgnoredCharacters(kitchenSinkSDL); - expect(stripIgnoredCharacters(strippedSDL)).to.equal(strippedSDL); - - const sdlAST = parse(kitchenSinkSDL, { noLocation: true }); - const strippedAST = parse(strippedSDL, { noLocation: true }); - expect(strippedAST).to.deep.equal(sdlAST); - }); -}); diff --git a/src/utilities/__tests__/typeComparators-test.ts b/src/utilities/__tests__/typeComparators-test.ts deleted file mode 100644 index f2709bf740..0000000000 --- a/src/utilities/__tests__/typeComparators-test.ts +++ /dev/null @@ -1,160 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import type { GraphQLFieldConfigMap } from '../../type/definition'; -import { - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLUnionType, -} from '../../type/definition'; -import { GraphQLFloat, GraphQLInt, GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { isEqualType, isTypeSubTypeOf } from '../typeComparators'; - -describe('typeComparators', () => { - describe('isEqualType', () => { - it('same reference are equal', () => { - expect(isEqualType(GraphQLString, GraphQLString)).to.equal(true); - }); - - it('int and float are not equal', () => { - expect(isEqualType(GraphQLInt, GraphQLFloat)).to.equal(false); - }); - - it('lists of same type are equal', () => { - expect( - isEqualType(new GraphQLList(GraphQLInt), new GraphQLList(GraphQLInt)), - ).to.equal(true); - }); - - it('lists is not equal to item', () => { - expect(isEqualType(new GraphQLList(GraphQLInt), GraphQLInt)).to.equal( - false, - ); - }); - - it('non-null of same type are equal', () => { - expect( - isEqualType( - new GraphQLNonNull(GraphQLInt), - new GraphQLNonNull(GraphQLInt), - ), - ).to.equal(true); - }); - - it('non-null is not equal to nullable', () => { - expect(isEqualType(new GraphQLNonNull(GraphQLInt), GraphQLInt)).to.equal( - false, - ); - }); - }); - - describe('isTypeSubTypeOf', () => { - function testSchema(fields: GraphQLFieldConfigMap) { - return new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields, - }), - }); - } - - it('same reference is subtype', () => { - const schema = testSchema({ field: { type: GraphQLString } }); - expect(isTypeSubTypeOf(schema, GraphQLString, GraphQLString)).to.equal( - true, - ); - }); - - it('int is not subtype of float', () => { - const schema = testSchema({ field: { type: GraphQLString } }); - expect(isTypeSubTypeOf(schema, GraphQLInt, GraphQLFloat)).to.equal(false); - }); - - it('non-null is subtype of nullable', () => { - const schema = testSchema({ field: { type: GraphQLString } }); - expect( - isTypeSubTypeOf(schema, new GraphQLNonNull(GraphQLInt), GraphQLInt), - ).to.equal(true); - }); - - it('nullable is not subtype of non-null', () => { - const schema = testSchema({ field: { type: GraphQLString } }); - expect( - isTypeSubTypeOf(schema, GraphQLInt, new GraphQLNonNull(GraphQLInt)), - ).to.equal(false); - }); - - it('item is not subtype of list', () => { - const schema = testSchema({ field: { type: GraphQLString } }); - expect( - isTypeSubTypeOf(schema, GraphQLInt, new GraphQLList(GraphQLInt)), - ).to.equal(false); - }); - - it('list is not subtype of item', () => { - const schema = testSchema({ field: { type: GraphQLString } }); - expect( - isTypeSubTypeOf(schema, new GraphQLList(GraphQLInt), GraphQLInt), - ).to.equal(false); - }); - - it('member is subtype of union', () => { - const member = new GraphQLObjectType({ - name: 'Object', - fields: { - field: { type: GraphQLString }, - }, - }); - const union = new GraphQLUnionType({ name: 'Union', types: [member] }); - const schema = testSchema({ field: { type: union } }); - expect(isTypeSubTypeOf(schema, member, union)).to.equal(true); - }); - - it('implementing object is subtype of interface', () => { - const iface = new GraphQLInterfaceType({ - name: 'Interface', - fields: { - field: { type: GraphQLString }, - }, - }); - const impl = new GraphQLObjectType({ - name: 'Object', - interfaces: [iface], - fields: { - field: { type: GraphQLString }, - }, - }); - const schema = testSchema({ field: { type: impl } }); - expect(isTypeSubTypeOf(schema, impl, iface)).to.equal(true); - }); - - it('implementing interface is subtype of interface', () => { - const iface = new GraphQLInterfaceType({ - name: 'Interface', - fields: { - field: { type: GraphQLString }, - }, - }); - const iface2 = new GraphQLInterfaceType({ - name: 'Interface2', - interfaces: [iface], - fields: { - field: { type: GraphQLString }, - }, - }); - const impl = new GraphQLObjectType({ - name: 'Object', - interfaces: [iface2, iface], - fields: { - field: { type: GraphQLString }, - }, - }); - const schema = testSchema({ field: { type: impl } }); - expect(isTypeSubTypeOf(schema, iface2, iface)).to.equal(true); - }); - }); -}); diff --git a/src/utilities/__tests__/valueFromAST-test.ts b/src/utilities/__tests__/valueFromAST-test.ts deleted file mode 100644 index 05924f3c56..0000000000 --- a/src/utilities/__tests__/valueFromAST-test.ts +++ /dev/null @@ -1,289 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { identityFunc } from '../../jsutils/identityFunc'; -import { invariant } from '../../jsutils/invariant'; -import type { ObjMap } from '../../jsutils/ObjMap'; - -import { parseValue } from '../../language/parser'; - -import type { GraphQLInputType } from '../../type/definition'; -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLList, - GraphQLNonNull, - GraphQLScalarType, -} from '../../type/definition'; -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLID, - GraphQLInt, - GraphQLString, -} from '../../type/scalars'; - -import { valueFromAST } from '../valueFromAST'; - -describe('valueFromAST', () => { - function expectValueFrom( - valueText: string, - type: GraphQLInputType, - variables?: ObjMap, - ) { - const ast = parseValue(valueText); - const value = valueFromAST(ast, type, variables); - return expect(value); - } - - it('rejects empty input', () => { - expect(valueFromAST(null, GraphQLBoolean)).to.deep.equal(undefined); - }); - - it('converts according to input coercion rules', () => { - expectValueFrom('true', GraphQLBoolean).to.equal(true); - expectValueFrom('false', GraphQLBoolean).to.equal(false); - expectValueFrom('123', GraphQLInt).to.equal(123); - expectValueFrom('123', GraphQLFloat).to.equal(123); - expectValueFrom('123.456', GraphQLFloat).to.equal(123.456); - expectValueFrom('"abc123"', GraphQLString).to.equal('abc123'); - expectValueFrom('123456', GraphQLID).to.equal('123456'); - expectValueFrom('"123456"', GraphQLID).to.equal('123456'); - }); - - it('does not convert when input coercion rules reject a value', () => { - expectValueFrom('123', GraphQLBoolean).to.equal(undefined); - expectValueFrom('123.456', GraphQLInt).to.equal(undefined); - expectValueFrom('true', GraphQLInt).to.equal(undefined); - expectValueFrom('"123"', GraphQLInt).to.equal(undefined); - expectValueFrom('"123"', GraphQLFloat).to.equal(undefined); - expectValueFrom('123', GraphQLString).to.equal(undefined); - expectValueFrom('true', GraphQLString).to.equal(undefined); - expectValueFrom('123.456', GraphQLString).to.equal(undefined); - }); - - it('convert using parseLiteral from a custom scalar type', () => { - const passthroughScalar = new GraphQLScalarType({ - name: 'PassthroughScalar', - parseLiteral(node) { - invariant(node.kind === 'StringValue'); - return node.value; - }, - parseValue: identityFunc, - }); - - expectValueFrom('"value"', passthroughScalar).to.equal('value'); - - const throwScalar = new GraphQLScalarType({ - name: 'ThrowScalar', - parseLiteral() { - throw new Error('Test'); - }, - parseValue: identityFunc, - }); - - expectValueFrom('value', throwScalar).to.equal(undefined); - - const returnUndefinedScalar = new GraphQLScalarType({ - name: 'ReturnUndefinedScalar', - parseLiteral() { - return undefined; - }, - parseValue: identityFunc, - }); - - expectValueFrom('value', returnUndefinedScalar).to.equal(undefined); - }); - - it('converts enum values according to input coercion rules', () => { - const testEnum = new GraphQLEnumType({ - name: 'TestColor', - values: { - RED: { value: 1 }, - GREEN: { value: 2 }, - BLUE: { value: 3 }, - NULL: { value: null }, - NAN: { value: NaN }, - NO_CUSTOM_VALUE: { value: undefined }, - }, - }); - - expectValueFrom('RED', testEnum).to.equal(1); - expectValueFrom('BLUE', testEnum).to.equal(3); - expectValueFrom('3', testEnum).to.equal(undefined); - expectValueFrom('"BLUE"', testEnum).to.equal(undefined); - expectValueFrom('null', testEnum).to.equal(null); - expectValueFrom('NULL', testEnum).to.equal(null); - expectValueFrom('NULL', new GraphQLNonNull(testEnum)).to.equal(null); - expectValueFrom('NAN', testEnum).to.deep.equal(NaN); - expectValueFrom('NO_CUSTOM_VALUE', testEnum).to.equal('NO_CUSTOM_VALUE'); - }); - - // Boolean! - const nonNullBool = new GraphQLNonNull(GraphQLBoolean); - // [Boolean] - const listOfBool = new GraphQLList(GraphQLBoolean); - // [Boolean!] - const listOfNonNullBool = new GraphQLList(nonNullBool); - // [Boolean]! - const nonNullListOfBool = new GraphQLNonNull(listOfBool); - // [Boolean!]! - const nonNullListOfNonNullBool = new GraphQLNonNull(listOfNonNullBool); - - it('coerces to null unless non-null', () => { - expectValueFrom('null', GraphQLBoolean).to.equal(null); - expectValueFrom('null', nonNullBool).to.equal(undefined); - }); - - it('coerces lists of values', () => { - expectValueFrom('true', listOfBool).to.deep.equal([true]); - expectValueFrom('123', listOfBool).to.equal(undefined); - expectValueFrom('null', listOfBool).to.equal(null); - expectValueFrom('[true, false]', listOfBool).to.deep.equal([true, false]); - expectValueFrom('[true, 123]', listOfBool).to.equal(undefined); - expectValueFrom('[true, null]', listOfBool).to.deep.equal([true, null]); - expectValueFrom('{ true: true }', listOfBool).to.equal(undefined); - }); - - it('coerces non-null lists of values', () => { - expectValueFrom('true', nonNullListOfBool).to.deep.equal([true]); - expectValueFrom('123', nonNullListOfBool).to.equal(undefined); - expectValueFrom('null', nonNullListOfBool).to.equal(undefined); - expectValueFrom('[true, false]', nonNullListOfBool).to.deep.equal([ - true, - false, - ]); - expectValueFrom('[true, 123]', nonNullListOfBool).to.equal(undefined); - expectValueFrom('[true, null]', nonNullListOfBool).to.deep.equal([ - true, - null, - ]); - }); - - it('coerces lists of non-null values', () => { - expectValueFrom('true', listOfNonNullBool).to.deep.equal([true]); - expectValueFrom('123', listOfNonNullBool).to.equal(undefined); - expectValueFrom('null', listOfNonNullBool).to.equal(null); - expectValueFrom('[true, false]', listOfNonNullBool).to.deep.equal([ - true, - false, - ]); - expectValueFrom('[true, 123]', listOfNonNullBool).to.equal(undefined); - expectValueFrom('[true, null]', listOfNonNullBool).to.equal(undefined); - }); - - it('coerces non-null lists of non-null values', () => { - expectValueFrom('true', nonNullListOfNonNullBool).to.deep.equal([true]); - expectValueFrom('123', nonNullListOfNonNullBool).to.equal(undefined); - expectValueFrom('null', nonNullListOfNonNullBool).to.equal(undefined); - expectValueFrom('[true, false]', nonNullListOfNonNullBool).to.deep.equal([ - true, - false, - ]); - expectValueFrom('[true, 123]', nonNullListOfNonNullBool).to.equal( - undefined, - ); - expectValueFrom('[true, null]', nonNullListOfNonNullBool).to.equal( - undefined, - ); - }); - - const testInputObj = new GraphQLInputObjectType({ - name: 'TestInput', - fields: { - int: { type: GraphQLInt, defaultValue: 42 }, - bool: { type: GraphQLBoolean }, - requiredBool: { type: nonNullBool }, - }, - }); - const testOneOfInputObj = new GraphQLInputObjectType({ - name: 'TestOneOfInput', - fields: { - a: { type: GraphQLString }, - b: { type: GraphQLString }, - }, - isOneOf: true, - }); - - it('coerces input objects according to input coercion rules', () => { - expectValueFrom('null', testInputObj).to.equal(null); - expectValueFrom('123', testInputObj).to.equal(undefined); - expectValueFrom('[]', testInputObj).to.equal(undefined); - expectValueFrom( - '{ int: 123, requiredBool: false }', - testInputObj, - ).to.deep.equal({ - int: 123, - requiredBool: false, - }); - expectValueFrom( - '{ bool: true, requiredBool: false }', - testInputObj, - ).to.deep.equal({ - int: 42, - bool: true, - requiredBool: false, - }); - expectValueFrom('{ int: true, requiredBool: true }', testInputObj).to.equal( - undefined, - ); - expectValueFrom('{ requiredBool: null }', testInputObj).to.equal(undefined); - expectValueFrom('{ bool: true }', testInputObj).to.equal(undefined); - expectValueFrom('{ a: "abc" }', testOneOfInputObj).to.deep.equal({ - a: 'abc', - }); - expectValueFrom('{ b: "def" }', testOneOfInputObj).to.deep.equal({ - b: 'def', - }); - expectValueFrom('{ a: "abc", b: null }', testOneOfInputObj).to.deep.equal( - undefined, - ); - expectValueFrom('{ a: null }', testOneOfInputObj).to.equal(undefined); - expectValueFrom('{ a: 1 }', testOneOfInputObj).to.equal(undefined); - expectValueFrom('{ a: "abc", b: "def" }', testOneOfInputObj).to.equal( - undefined, - ); - expectValueFrom('{}', testOneOfInputObj).to.equal(undefined); - expectValueFrom('{ c: "abc" }', testOneOfInputObj).to.equal(undefined); - }); - - it('accepts variable values assuming already coerced', () => { - expectValueFrom('$var', GraphQLBoolean, {}).to.equal(undefined); - expectValueFrom('$var', GraphQLBoolean, { var: true }).to.equal(true); - expectValueFrom('$var', GraphQLBoolean, { var: null }).to.equal(null); - expectValueFrom('$var', nonNullBool, { var: null }).to.equal(undefined); - }); - - it('asserts variables are provided as items in lists', () => { - expectValueFrom('[ $foo ]', listOfBool, {}).to.deep.equal([null]); - expectValueFrom('[ $foo ]', listOfNonNullBool, {}).to.equal(undefined); - expectValueFrom('[ $foo ]', listOfNonNullBool, { - foo: true, - }).to.deep.equal([true]); - // Note: variables are expected to have already been coerced, so we - // do not expect the singleton wrapping behavior for variables. - expectValueFrom('$foo', listOfNonNullBool, { foo: true }).to.equal(true); - expectValueFrom('$foo', listOfNonNullBool, { foo: [true] }).to.deep.equal([ - true, - ]); - }); - - it('omits input object fields for unprovided variables', () => { - expectValueFrom( - '{ int: $foo, bool: $foo, requiredBool: true }', - testInputObj, - {}, - ).to.deep.equal({ int: 42, requiredBool: true }); - - expectValueFrom('{ requiredBool: $foo }', testInputObj, {}).to.equal( - undefined, - ); - - expectValueFrom('{ requiredBool: $foo }', testInputObj, { - foo: true, - }).to.deep.equal({ - int: 42, - requiredBool: true, - }); - }); -}); diff --git a/src/utilities/__tests__/valueFromASTUntyped-test.ts b/src/utilities/__tests__/valueFromASTUntyped-test.ts deleted file mode 100644 index 9ad004c42e..0000000000 --- a/src/utilities/__tests__/valueFromASTUntyped-test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import type { Maybe } from '../../jsutils/Maybe'; -import type { ObjMap } from '../../jsutils/ObjMap'; - -import { parseValue } from '../../language/parser'; - -import { valueFromASTUntyped } from '../valueFromASTUntyped'; - -describe('valueFromASTUntyped', () => { - function expectValueFrom( - valueText: string, - variables?: Maybe>, - ) { - const ast = parseValue(valueText); - const value = valueFromASTUntyped(ast, variables); - return expect(value); - } - - it('parses simple values', () => { - expectValueFrom('null').to.equal(null); - expectValueFrom('true').to.equal(true); - expectValueFrom('false').to.equal(false); - expectValueFrom('123').to.equal(123); - expectValueFrom('123.456').to.equal(123.456); - expectValueFrom('"abc123"').to.equal('abc123'); - }); - - it('parses lists of values', () => { - expectValueFrom('[true, false]').to.deep.equal([true, false]); - expectValueFrom('[true, 123.45]').to.deep.equal([true, 123.45]); - expectValueFrom('[true, null]').to.deep.equal([true, null]); - expectValueFrom('[true, ["foo", 1.2]]').to.deep.equal([true, ['foo', 1.2]]); - }); - - it('parses input objects', () => { - expectValueFrom('{ int: 123, bool: false }').to.deep.equal({ - int: 123, - bool: false, - }); - expectValueFrom('{ foo: [ { bar: "baz"} ] }').to.deep.equal({ - foo: [{ bar: 'baz' }], - }); - }); - - it('parses enum values as plain strings', () => { - expectValueFrom('TEST_ENUM_VALUE').to.equal('TEST_ENUM_VALUE'); - expectValueFrom('[TEST_ENUM_VALUE]').to.deep.equal(['TEST_ENUM_VALUE']); - }); - - it('parses variables', () => { - expectValueFrom('$testVariable', { testVariable: 'foo' }).to.equal('foo'); - expectValueFrom('[$testVariable]', { testVariable: 'foo' }).to.deep.equal([ - 'foo', - ]); - expectValueFrom('{a:[$testVariable]}', { - testVariable: 'foo', - }).to.deep.equal({ a: ['foo'] }); - expectValueFrom('$testVariable', { testVariable: null }).to.equal(null); - expectValueFrom('$testVariable', { testVariable: NaN }).to.satisfy( - Number.isNaN, - ); - expectValueFrom('$testVariable', {}).to.equal(undefined); - expectValueFrom('$testVariable', null).to.equal(undefined); - }); -}); diff --git a/src/utilities/assertValidName.ts b/src/utilities/assertValidName.ts deleted file mode 100644 index 3e66461ae6..0000000000 --- a/src/utilities/assertValidName.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; - -import { GraphQLError } from '../error/GraphQLError'; - -import { assertName } from '../type/assertName'; - -/* c8 ignore start */ -/** - * Upholds the spec rules about naming. - * @deprecated Please use `assertName` instead. Will be removed in v17 - */ -export function assertValidName(name: string): string { - const error = isValidNameError(name); - if (error) { - throw error; - } - return name; -} - -/** - * Returns an Error if a name is invalid. - * @deprecated Please use `assertName` instead. Will be removed in v17 - */ -export function isValidNameError(name: string): GraphQLError | undefined { - devAssert(typeof name === 'string', 'Expected name to be a string.'); - - if (name.startsWith('__')) { - return new GraphQLError( - `Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`, - ); - } - - try { - assertName(name); - } catch (error) { - return error; - } -} -/* c8 ignore stop */ diff --git a/src/utilities/astFromValue.ts b/src/utilities/astFromValue.ts deleted file mode 100644 index 1a880449c8..0000000000 --- a/src/utilities/astFromValue.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import { isIterableObject } from '../jsutils/isIterableObject'; -import { isObjectLike } from '../jsutils/isObjectLike'; -import type { Maybe } from '../jsutils/Maybe'; - -import type { ObjectFieldNode, ValueNode } from '../language/ast'; -import { Kind } from '../language/kinds'; - -import type { GraphQLInputType } from '../type/definition'; -import { - isEnumType, - isInputObjectType, - isLeafType, - isListType, - isNonNullType, -} from '../type/definition'; -import { GraphQLID } from '../type/scalars'; - -/** - * Produces a GraphQL Value AST given a JavaScript object. - * Function will match JavaScript/JSON values to GraphQL AST schema format - * by using suggested GraphQLInputType. For example: - * - * astFromValue("value", GraphQLString) - * - * A GraphQL type must be provided, which will be used to interpret different - * JavaScript values. - * - * | JSON Value | GraphQL Value | - * | ------------- | -------------------- | - * | Object | Input Object | - * | Array | List | - * | Boolean | Boolean | - * | String | String / Enum Value | - * | Number | Int / Float | - * | Unknown | Enum Value | - * | null | NullValue | - * - */ -export function astFromValue( - value: unknown, - type: GraphQLInputType, -): Maybe { - if (isNonNullType(type)) { - const astValue = astFromValue(value, type.ofType); - if (astValue?.kind === Kind.NULL) { - return null; - } - return astValue; - } - - // only explicit null, not undefined, NaN - if (value === null) { - return { kind: Kind.NULL }; - } - - // undefined - if (value === undefined) { - return null; - } - - // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but - // the value is not an array, convert the value using the list's item type. - if (isListType(type)) { - const itemType = type.ofType; - if (isIterableObject(value)) { - const valuesNodes = []; - for (const item of value) { - const itemNode = astFromValue(item, itemType); - if (itemNode != null) { - valuesNodes.push(itemNode); - } - } - return { kind: Kind.LIST, values: valuesNodes }; - } - return astFromValue(value, itemType); - } - - // Populate the fields of the input object by creating ASTs from each value - // in the JavaScript object according to the fields in the input type. - if (isInputObjectType(type)) { - if (!isObjectLike(value)) { - return null; - } - const fieldNodes: Array = []; - for (const field of Object.values(type.getFields())) { - const fieldValue = astFromValue(value[field.name], field.type); - if (fieldValue) { - fieldNodes.push({ - kind: Kind.OBJECT_FIELD, - name: { kind: Kind.NAME, value: field.name }, - value: fieldValue, - }); - } - } - return { kind: Kind.OBJECT, fields: fieldNodes }; - } - - if (isLeafType(type)) { - // Since value is an internally represented value, it must be serialized - // to an externally represented value before converting into an AST. - const serialized = type.serialize(value); - if (serialized == null) { - return null; - } - - // Others serialize based on their corresponding JavaScript scalar types. - if (typeof serialized === 'boolean') { - return { kind: Kind.BOOLEAN, value: serialized }; - } - - // JavaScript numbers can be Int or Float values. - if (typeof serialized === 'number' && Number.isFinite(serialized)) { - const stringNum = String(serialized); - return integerStringRegExp.test(stringNum) - ? { kind: Kind.INT, value: stringNum } - : { kind: Kind.FLOAT, value: stringNum }; - } - - if (typeof serialized === 'string') { - // Enum types use Enum literals. - if (isEnumType(type)) { - return { kind: Kind.ENUM, value: serialized }; - } - - // ID types can use Int literals. - if (type === GraphQLID && integerStringRegExp.test(serialized)) { - return { kind: Kind.INT, value: serialized }; - } - - return { - kind: Kind.STRING, - value: serialized, - }; - } - - throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}.`); - } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - invariant(false, 'Unexpected input type: ' + inspect(type)); -} - -/** - * IntValue: - * - NegativeSign? 0 - * - NegativeSign? NonZeroDigit ( Digit+ )? - */ -const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; diff --git a/src/utilities/buildASTSchema.ts b/src/utilities/buildASTSchema.ts deleted file mode 100644 index eeff08e6ed..0000000000 --- a/src/utilities/buildASTSchema.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; - -import type { DocumentNode } from '../language/ast'; -import { Kind } from '../language/kinds'; -import type { ParseOptions } from '../language/parser'; -import { parse } from '../language/parser'; -import type { Source } from '../language/source'; - -import { specifiedDirectives } from '../type/directives'; -import type { GraphQLSchemaValidationOptions } from '../type/schema'; -import { GraphQLSchema } from '../type/schema'; - -import { assertValidSDL } from '../validation/validate'; - -import { extendSchemaImpl } from './extendSchema'; - -export interface BuildSchemaOptions extends GraphQLSchemaValidationOptions { - /** - * Set to true to assume the SDL is valid. - * - * Default: false - */ - assumeValidSDL?: boolean; -} - -/** - * This takes the ast of a schema document produced by the parse function in - * src/language/parser.js. - * - * If no schema definition is provided, then it will look for types named Query, - * Mutation and Subscription. - * - * Given that AST it constructs a GraphQLSchema. The resulting schema - * has no resolve methods, so execution will use default resolvers. - */ -export function buildASTSchema( - documentAST: DocumentNode, - options?: BuildSchemaOptions, -): GraphQLSchema { - devAssert( - documentAST != null && documentAST.kind === Kind.DOCUMENT, - 'Must provide valid Document AST.', - ); - - if (options?.assumeValid !== true && options?.assumeValidSDL !== true) { - assertValidSDL(documentAST); - } - - const emptySchemaConfig = { - description: undefined, - types: [], - directives: [], - extensions: Object.create(null), - extensionASTNodes: [], - assumeValid: false, - }; - const config = extendSchemaImpl(emptySchemaConfig, documentAST, options); - - if (config.astNode == null) { - for (const type of config.types) { - switch (type.name) { - // Note: While this could make early assertions to get the correctly - // typed values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - case 'Query': - // @ts-expect-error validated in `validateSchema` - config.query = type; - break; - case 'Mutation': - // @ts-expect-error validated in `validateSchema` - config.mutation = type; - break; - case 'Subscription': - // @ts-expect-error validated in `validateSchema` - config.subscription = type; - break; - } - } - } - - const directives = [ - ...config.directives, - // If specified directives were not explicitly declared, add them. - ...specifiedDirectives.filter((stdDirective) => - config.directives.every( - (directive) => directive.name !== stdDirective.name, - ), - ), - ]; - - return new GraphQLSchema({ ...config, directives }); -} - -/** - * A helper function to build a GraphQLSchema directly from a source - * document. - */ -export function buildSchema( - source: string | Source, - options?: BuildSchemaOptions & ParseOptions, -): GraphQLSchema { - const document = parse(source, { - noLocation: options?.noLocation, - allowLegacyFragmentVariables: options?.allowLegacyFragmentVariables, - }); - - return buildASTSchema(document, { - assumeValidSDL: options?.assumeValidSDL, - assumeValid: options?.assumeValid, - }); -} diff --git a/src/utilities/buildClientSchema.ts b/src/utilities/buildClientSchema.ts deleted file mode 100644 index 83f6abada8..0000000000 --- a/src/utilities/buildClientSchema.ts +++ /dev/null @@ -1,407 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; -import { isObjectLike } from '../jsutils/isObjectLike'; -import { keyValMap } from '../jsutils/keyValMap'; - -import { parseValue } from '../language/parser'; - -import type { - GraphQLFieldConfig, - GraphQLFieldConfigMap, - GraphQLNamedType, - GraphQLType, -} from '../type/definition'; -import { - assertInterfaceType, - assertNullableType, - assertObjectType, - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, - isInputType, - isOutputType, -} from '../type/definition'; -import { GraphQLDirective } from '../type/directives'; -import { introspectionTypes, TypeKind } from '../type/introspection'; -import { specifiedScalarTypes } from '../type/scalars'; -import type { GraphQLSchemaValidationOptions } from '../type/schema'; -import { GraphQLSchema } from '../type/schema'; - -import type { - IntrospectionDirective, - IntrospectionEnumType, - IntrospectionField, - IntrospectionInputObjectType, - IntrospectionInputValue, - IntrospectionInterfaceType, - IntrospectionNamedTypeRef, - IntrospectionObjectType, - IntrospectionQuery, - IntrospectionScalarType, - IntrospectionType, - IntrospectionTypeRef, - IntrospectionUnionType, -} from './getIntrospectionQuery'; -import { valueFromAST } from './valueFromAST'; - -/** - * Build a GraphQLSchema for use by client tools. - * - * Given the result of a client running the introspection query, creates and - * returns a GraphQLSchema instance which can be then used with all graphql-js - * tools, but cannot be used to execute a query, as introspection does not - * represent the "resolver", "parse" or "serialize" functions or any other - * server-internal mechanisms. - * - * This function expects a complete introspection result. Don't forget to check - * the "errors" field of a server response before calling this function. - */ -export function buildClientSchema( - introspection: IntrospectionQuery, - options?: GraphQLSchemaValidationOptions, -): GraphQLSchema { - devAssert( - isObjectLike(introspection) && isObjectLike(introspection.__schema), - `Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${inspect( - introspection, - )}.`, - ); - - // Get the schema from the introspection result. - const schemaIntrospection = introspection.__schema; - - // Iterate through all types, getting the type definition for each. - const typeMap = keyValMap( - schemaIntrospection.types, - (typeIntrospection) => typeIntrospection.name, - (typeIntrospection) => buildType(typeIntrospection), - ); - - // Include standard types only if they are used. - for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) { - if (typeMap[stdType.name]) { - typeMap[stdType.name] = stdType; - } - } - - // Get the root Query, Mutation, and Subscription types. - const queryType = schemaIntrospection.queryType - ? getObjectType(schemaIntrospection.queryType) - : null; - - const mutationType = schemaIntrospection.mutationType - ? getObjectType(schemaIntrospection.mutationType) - : null; - - const subscriptionType = schemaIntrospection.subscriptionType - ? getObjectType(schemaIntrospection.subscriptionType) - : null; - - // Get the directives supported by Introspection, assuming empty-set if - // directives were not queried for. - const directives = schemaIntrospection.directives - ? schemaIntrospection.directives.map(buildDirective) - : []; - - // Then produce and return a Schema with these types. - return new GraphQLSchema({ - description: schemaIntrospection.description, - query: queryType, - mutation: mutationType, - subscription: subscriptionType, - types: Object.values(typeMap), - directives, - assumeValid: options?.assumeValid, - }); - - // Given a type reference in introspection, return the GraphQLType instance. - // preferring cached instances before building new instances. - function getType(typeRef: IntrospectionTypeRef): GraphQLType { - if (typeRef.kind === TypeKind.LIST) { - const itemRef = typeRef.ofType; - if (!itemRef) { - throw new Error('Decorated type deeper than introspection query.'); - } - return new GraphQLList(getType(itemRef)); - } - if (typeRef.kind === TypeKind.NON_NULL) { - const nullableRef = typeRef.ofType; - if (!nullableRef) { - throw new Error('Decorated type deeper than introspection query.'); - } - const nullableType = getType(nullableRef); - return new GraphQLNonNull(assertNullableType(nullableType)); - } - return getNamedType(typeRef); - } - - function getNamedType(typeRef: IntrospectionNamedTypeRef): GraphQLNamedType { - const typeName = typeRef.name; - if (!typeName) { - throw new Error(`Unknown type reference: ${inspect(typeRef)}.`); - } - - const type = typeMap[typeName]; - if (!type) { - throw new Error( - `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`, - ); - } - - return type; - } - - function getObjectType( - typeRef: IntrospectionNamedTypeRef, - ): GraphQLObjectType { - return assertObjectType(getNamedType(typeRef)); - } - - function getInterfaceType( - typeRef: IntrospectionNamedTypeRef, - ): GraphQLInterfaceType { - return assertInterfaceType(getNamedType(typeRef)); - } - - // Given a type's introspection result, construct the correct - // GraphQLType instance. - function buildType(type: IntrospectionType): GraphQLNamedType { - // eslint-disable-next-line @typescript-eslint/prefer-optional-chain - if (type != null && type.name != null && type.kind != null) { - // FIXME: Properly type IntrospectionType, it's a breaking change so fix in v17 - // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check - switch (type.kind) { - case TypeKind.SCALAR: - return buildScalarDef(type); - case TypeKind.OBJECT: - return buildObjectDef(type); - case TypeKind.INTERFACE: - return buildInterfaceDef(type); - case TypeKind.UNION: - return buildUnionDef(type); - case TypeKind.ENUM: - return buildEnumDef(type); - case TypeKind.INPUT_OBJECT: - return buildInputObjectDef(type); - } - } - const typeStr = inspect(type); - throw new Error( - `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${typeStr}.`, - ); - } - - function buildScalarDef( - scalarIntrospection: IntrospectionScalarType, - ): GraphQLScalarType { - return new GraphQLScalarType({ - name: scalarIntrospection.name, - description: scalarIntrospection.description, - specifiedByURL: scalarIntrospection.specifiedByURL, - }); - } - - function buildImplementationsList( - implementingIntrospection: - | IntrospectionObjectType - | IntrospectionInterfaceType, - ): Array { - // TODO: Temporary workaround until GraphQL ecosystem will fully support - // 'interfaces' on interface types. - if ( - implementingIntrospection.interfaces === null && - implementingIntrospection.kind === TypeKind.INTERFACE - ) { - return []; - } - - if (!implementingIntrospection.interfaces) { - const implementingIntrospectionStr = inspect(implementingIntrospection); - throw new Error( - `Introspection result missing interfaces: ${implementingIntrospectionStr}.`, - ); - } - - return implementingIntrospection.interfaces.map(getInterfaceType); - } - - function buildObjectDef( - objectIntrospection: IntrospectionObjectType, - ): GraphQLObjectType { - return new GraphQLObjectType({ - name: objectIntrospection.name, - description: objectIntrospection.description, - interfaces: () => buildImplementationsList(objectIntrospection), - fields: () => buildFieldDefMap(objectIntrospection), - }); - } - - function buildInterfaceDef( - interfaceIntrospection: IntrospectionInterfaceType, - ): GraphQLInterfaceType { - return new GraphQLInterfaceType({ - name: interfaceIntrospection.name, - description: interfaceIntrospection.description, - interfaces: () => buildImplementationsList(interfaceIntrospection), - fields: () => buildFieldDefMap(interfaceIntrospection), - }); - } - - function buildUnionDef( - unionIntrospection: IntrospectionUnionType, - ): GraphQLUnionType { - if (!unionIntrospection.possibleTypes) { - const unionIntrospectionStr = inspect(unionIntrospection); - throw new Error( - `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`, - ); - } - return new GraphQLUnionType({ - name: unionIntrospection.name, - description: unionIntrospection.description, - types: () => unionIntrospection.possibleTypes.map(getObjectType), - }); - } - - function buildEnumDef( - enumIntrospection: IntrospectionEnumType, - ): GraphQLEnumType { - if (!enumIntrospection.enumValues) { - const enumIntrospectionStr = inspect(enumIntrospection); - throw new Error( - `Introspection result missing enumValues: ${enumIntrospectionStr}.`, - ); - } - return new GraphQLEnumType({ - name: enumIntrospection.name, - description: enumIntrospection.description, - values: keyValMap( - enumIntrospection.enumValues, - (valueIntrospection) => valueIntrospection.name, - (valueIntrospection) => ({ - description: valueIntrospection.description, - deprecationReason: valueIntrospection.deprecationReason, - }), - ), - }); - } - - function buildInputObjectDef( - inputObjectIntrospection: IntrospectionInputObjectType, - ): GraphQLInputObjectType { - if (!inputObjectIntrospection.inputFields) { - const inputObjectIntrospectionStr = inspect(inputObjectIntrospection); - throw new Error( - `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`, - ); - } - return new GraphQLInputObjectType({ - name: inputObjectIntrospection.name, - description: inputObjectIntrospection.description, - fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields), - isOneOf: inputObjectIntrospection.isOneOf, - }); - } - - function buildFieldDefMap( - typeIntrospection: IntrospectionObjectType | IntrospectionInterfaceType, - ): GraphQLFieldConfigMap { - if (!typeIntrospection.fields) { - throw new Error( - `Introspection result missing fields: ${inspect(typeIntrospection)}.`, - ); - } - - return keyValMap( - typeIntrospection.fields, - (fieldIntrospection) => fieldIntrospection.name, - buildField, - ); - } - - function buildField( - fieldIntrospection: IntrospectionField, - ): GraphQLFieldConfig { - const type = getType(fieldIntrospection.type); - if (!isOutputType(type)) { - const typeStr = inspect(type); - throw new Error( - `Introspection must provide output type for fields, but received: ${typeStr}.`, - ); - } - - if (!fieldIntrospection.args) { - const fieldIntrospectionStr = inspect(fieldIntrospection); - throw new Error( - `Introspection result missing field args: ${fieldIntrospectionStr}.`, - ); - } - - return { - description: fieldIntrospection.description, - deprecationReason: fieldIntrospection.deprecationReason, - type, - args: buildInputValueDefMap(fieldIntrospection.args), - }; - } - - function buildInputValueDefMap( - inputValueIntrospections: ReadonlyArray, - ) { - return keyValMap( - inputValueIntrospections, - (inputValue) => inputValue.name, - buildInputValue, - ); - } - - function buildInputValue(inputValueIntrospection: IntrospectionInputValue) { - const type = getType(inputValueIntrospection.type); - if (!isInputType(type)) { - const typeStr = inspect(type); - throw new Error( - `Introspection must provide input type for arguments, but received: ${typeStr}.`, - ); - } - - const defaultValue = - inputValueIntrospection.defaultValue != null - ? valueFromAST(parseValue(inputValueIntrospection.defaultValue), type) - : undefined; - return { - description: inputValueIntrospection.description, - type, - defaultValue, - deprecationReason: inputValueIntrospection.deprecationReason, - }; - } - - function buildDirective( - directiveIntrospection: IntrospectionDirective, - ): GraphQLDirective { - if (!directiveIntrospection.args) { - const directiveIntrospectionStr = inspect(directiveIntrospection); - throw new Error( - `Introspection result missing directive args: ${directiveIntrospectionStr}.`, - ); - } - if (!directiveIntrospection.locations) { - const directiveIntrospectionStr = inspect(directiveIntrospection); - throw new Error( - `Introspection result missing directive locations: ${directiveIntrospectionStr}.`, - ); - } - return new GraphQLDirective({ - name: directiveIntrospection.name, - description: directiveIntrospection.description, - isRepeatable: directiveIntrospection.isRepeatable, - locations: directiveIntrospection.locations.slice(), - args: buildInputValueDefMap(directiveIntrospection.args), - }); - } -} diff --git a/src/utilities/coerceInputValue.ts b/src/utilities/coerceInputValue.ts deleted file mode 100644 index 5263e925ee..0000000000 --- a/src/utilities/coerceInputValue.ts +++ /dev/null @@ -1,206 +0,0 @@ -import { didYouMean } from '../jsutils/didYouMean'; -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import { isIterableObject } from '../jsutils/isIterableObject'; -import { isObjectLike } from '../jsutils/isObjectLike'; -import type { Path } from '../jsutils/Path'; -import { addPath, pathToArray } from '../jsutils/Path'; -import { printPathArray } from '../jsutils/printPathArray'; -import { suggestionList } from '../jsutils/suggestionList'; - -import { GraphQLError } from '../error/GraphQLError'; - -import type { GraphQLInputType } from '../type/definition'; -import { - isInputObjectType, - isLeafType, - isListType, - isNonNullType, -} from '../type/definition'; - -type OnErrorCB = ( - path: ReadonlyArray, - invalidValue: unknown, - error: GraphQLError, -) => void; - -/** - * Coerces a JavaScript value given a GraphQL Input Type. - */ -export function coerceInputValue( - inputValue: unknown, - type: GraphQLInputType, - onError: OnErrorCB = defaultOnError, -): unknown { - return coerceInputValueImpl(inputValue, type, onError, undefined); -} - -function defaultOnError( - path: ReadonlyArray, - invalidValue: unknown, - error: GraphQLError, -): void { - let errorPrefix = 'Invalid value ' + inspect(invalidValue); - if (path.length > 0) { - errorPrefix += ` at "value${printPathArray(path)}"`; - } - error.message = errorPrefix + ': ' + error.message; - throw error; -} - -function coerceInputValueImpl( - inputValue: unknown, - type: GraphQLInputType, - onError: OnErrorCB, - path: Path | undefined, -): unknown { - if (isNonNullType(type)) { - if (inputValue != null) { - return coerceInputValueImpl(inputValue, type.ofType, onError, path); - } - onError( - pathToArray(path), - inputValue, - new GraphQLError( - `Expected non-nullable type "${inspect(type)}" not to be null.`, - ), - ); - return; - } - - if (inputValue == null) { - // Explicitly return the value null. - return null; - } - - if (isListType(type)) { - const itemType = type.ofType; - if (isIterableObject(inputValue)) { - return Array.from(inputValue, (itemValue, index) => { - const itemPath = addPath(path, index, undefined); - return coerceInputValueImpl(itemValue, itemType, onError, itemPath); - }); - } - // Lists accept a non-list value as a list of one. - return [coerceInputValueImpl(inputValue, itemType, onError, path)]; - } - - if (isInputObjectType(type)) { - if (!isObjectLike(inputValue) || Array.isArray(inputValue)) { - onError( - pathToArray(path), - inputValue, - new GraphQLError(`Expected type "${type.name}" to be an object.`), - ); - return; - } - - const coercedValue: any = {}; - const fieldDefs = type.getFields(); - - for (const field of Object.values(fieldDefs)) { - const fieldValue = inputValue[field.name]; - - if (fieldValue === undefined) { - if (field.defaultValue !== undefined) { - coercedValue[field.name] = field.defaultValue; - } else if (isNonNullType(field.type)) { - const typeStr = inspect(field.type); - onError( - pathToArray(path), - inputValue, - new GraphQLError( - `Field "${field.name}" of required type "${typeStr}" was not provided.`, - ), - ); - } - continue; - } - - coercedValue[field.name] = coerceInputValueImpl( - fieldValue, - field.type, - onError, - addPath(path, field.name, type.name), - ); - } - - // Ensure every provided field is defined. - for (const fieldName of Object.keys(inputValue)) { - if (!fieldDefs[fieldName]) { - const suggestions = suggestionList( - fieldName, - Object.keys(type.getFields()), - ); - onError( - pathToArray(path), - inputValue, - new GraphQLError( - `Field "${fieldName}" is not defined by type "${type.name}".` + - didYouMean(suggestions), - ), - ); - } - } - - if (type.isOneOf) { - const keys = Object.keys(coercedValue); - if (keys.length !== 1) { - onError( - pathToArray(path), - inputValue, - new GraphQLError( - `Exactly one key must be specified for OneOf type "${type.name}".`, - ), - ); - } - - const key = keys[0]; - const value = coercedValue[key]; - if (value === null) { - onError( - pathToArray(path).concat(key), - value, - new GraphQLError(`Field "${key}" must be non-null.`), - ); - } - } - - return coercedValue; - } - - if (isLeafType(type)) { - let parseResult; - - // Scalars and Enums determine if a input value is valid via parseValue(), - // which can throw to indicate failure. If it throws, maintain a reference - // to the original error. - try { - parseResult = type.parseValue(inputValue); - } catch (error) { - if (error instanceof GraphQLError) { - onError(pathToArray(path), inputValue, error); - } else { - onError( - pathToArray(path), - inputValue, - new GraphQLError(`Expected type "${type.name}". ` + error.message, { - originalError: error, - }), - ); - } - return; - } - if (parseResult === undefined) { - onError( - pathToArray(path), - inputValue, - new GraphQLError(`Expected type "${type.name}".`), - ); - } - return parseResult; - } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - invariant(false, 'Unexpected input type: ' + inspect(type)); -} diff --git a/src/utilities/concatAST.ts b/src/utilities/concatAST.ts deleted file mode 100644 index 33062f610e..0000000000 --- a/src/utilities/concatAST.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { DefinitionNode, DocumentNode } from '../language/ast'; -import { Kind } from '../language/kinds'; - -/** - * Provided a collection of ASTs, presumably each from different files, - * concatenate the ASTs together into batched AST, useful for validating many - * GraphQL source files which together represent one conceptual application. - */ -export function concatAST( - documents: ReadonlyArray, -): DocumentNode { - const definitions: Array = []; - for (const doc of documents) { - definitions.push(...doc.definitions); - } - return { kind: Kind.DOCUMENT, definitions }; -} diff --git a/src/utilities/extendSchema.ts b/src/utilities/extendSchema.ts deleted file mode 100644 index d53752d919..0000000000 --- a/src/utilities/extendSchema.ts +++ /dev/null @@ -1,693 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import { keyMap } from '../jsutils/keyMap'; -import { mapValue } from '../jsutils/mapValue'; -import type { Maybe } from '../jsutils/Maybe'; - -import type { - DirectiveDefinitionNode, - DocumentNode, - EnumTypeDefinitionNode, - EnumTypeExtensionNode, - EnumValueDefinitionNode, - FieldDefinitionNode, - InputObjectTypeDefinitionNode, - InputObjectTypeExtensionNode, - InputValueDefinitionNode, - InterfaceTypeDefinitionNode, - InterfaceTypeExtensionNode, - NamedTypeNode, - ObjectTypeDefinitionNode, - ObjectTypeExtensionNode, - ScalarTypeDefinitionNode, - ScalarTypeExtensionNode, - SchemaDefinitionNode, - SchemaExtensionNode, - TypeDefinitionNode, - TypeNode, - UnionTypeDefinitionNode, - UnionTypeExtensionNode, -} from '../language/ast'; -import { Kind } from '../language/kinds'; -import { - isTypeDefinitionNode, - isTypeExtensionNode, -} from '../language/predicates'; - -import type { - GraphQLArgumentConfig, - GraphQLEnumValueConfigMap, - GraphQLFieldConfig, - GraphQLFieldConfigArgumentMap, - GraphQLFieldConfigMap, - GraphQLInputFieldConfigMap, - GraphQLNamedType, - GraphQLType, -} from '../type/definition'; -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, - isEnumType, - isInputObjectType, - isInterfaceType, - isListType, - isNonNullType, - isObjectType, - isScalarType, - isUnionType, -} from '../type/definition'; -import { - GraphQLDeprecatedDirective, - GraphQLDirective, - GraphQLOneOfDirective, - GraphQLSpecifiedByDirective, -} from '../type/directives'; -import { introspectionTypes, isIntrospectionType } from '../type/introspection'; -import { isSpecifiedScalarType, specifiedScalarTypes } from '../type/scalars'; -import type { - GraphQLSchemaNormalizedConfig, - GraphQLSchemaValidationOptions, -} from '../type/schema'; -import { assertSchema, GraphQLSchema } from '../type/schema'; - -import { assertValidSDLExtension } from '../validation/validate'; - -import { getDirectiveValues } from '../execution/values'; - -import { valueFromAST } from './valueFromAST'; - -interface Options extends GraphQLSchemaValidationOptions { - /** - * Set to true to assume the SDL is valid. - * - * Default: false - */ - assumeValidSDL?: boolean; -} - -/** - * Produces a new schema given an existing schema and a document which may - * contain GraphQL type extensions and definitions. The original schema will - * remain unaltered. - * - * Because a schema represents a graph of references, a schema cannot be - * extended without effectively making an entire copy. We do not know until it's - * too late if subgraphs remain unchanged. - * - * This algorithm copies the provided schema, applying extensions while - * producing the copy. The original schema remains unaltered. - */ -export function extendSchema( - schema: GraphQLSchema, - documentAST: DocumentNode, - options?: Options, -): GraphQLSchema { - assertSchema(schema); - - devAssert( - documentAST != null && documentAST.kind === Kind.DOCUMENT, - 'Must provide valid Document AST.', - ); - - if (options?.assumeValid !== true && options?.assumeValidSDL !== true) { - assertValidSDLExtension(documentAST, schema); - } - - const schemaConfig = schema.toConfig(); - const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options); - return schemaConfig === extendedConfig - ? schema - : new GraphQLSchema(extendedConfig); -} - -/** - * @internal - */ -export function extendSchemaImpl( - schemaConfig: GraphQLSchemaNormalizedConfig, - documentAST: DocumentNode, - options?: Options, -): GraphQLSchemaNormalizedConfig { - // Collect the type definitions and extensions found in the document. - const typeDefs: Array = []; - const typeExtensionsMap = Object.create(null); - - // New directives and types are separate because a directives and types can - // have the same name. For example, a type named "skip". - const directiveDefs: Array = []; - - let schemaDef: Maybe; - // Schema extensions are collected which may add additional operation types. - const schemaExtensions: Array = []; - - for (const def of documentAST.definitions) { - if (def.kind === Kind.SCHEMA_DEFINITION) { - schemaDef = def; - } else if (def.kind === Kind.SCHEMA_EXTENSION) { - schemaExtensions.push(def); - } else if (isTypeDefinitionNode(def)) { - typeDefs.push(def); - } else if (isTypeExtensionNode(def)) { - const extendedTypeName = def.name.value; - const existingTypeExtensions = typeExtensionsMap[extendedTypeName]; - typeExtensionsMap[extendedTypeName] = existingTypeExtensions - ? existingTypeExtensions.concat([def]) - : [def]; - } else if (def.kind === Kind.DIRECTIVE_DEFINITION) { - directiveDefs.push(def); - } - } - - // If this document contains no new types, extensions, or directives then - // return the same unmodified GraphQLSchema instance. - if ( - Object.keys(typeExtensionsMap).length === 0 && - typeDefs.length === 0 && - directiveDefs.length === 0 && - schemaExtensions.length === 0 && - schemaDef == null - ) { - return schemaConfig; - } - - const typeMap = Object.create(null); - for (const existingType of schemaConfig.types) { - typeMap[existingType.name] = extendNamedType(existingType); - } - - for (const typeNode of typeDefs) { - const name = typeNode.name.value; - typeMap[name] = stdTypeMap[name] ?? buildType(typeNode); - } - - const operationTypes = { - // Get the extended root operation types. - query: schemaConfig.query && replaceNamedType(schemaConfig.query), - mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation), - subscription: - schemaConfig.subscription && replaceNamedType(schemaConfig.subscription), - // Then, incorporate schema definition and all schema extensions. - ...(schemaDef && getOperationTypes([schemaDef])), - ...getOperationTypes(schemaExtensions), - }; - - // Then produce and return a Schema config with these types. - return { - description: schemaDef?.description?.value, - ...operationTypes, - types: Object.values(typeMap), - directives: [ - ...schemaConfig.directives.map(replaceDirective), - ...directiveDefs.map(buildDirective), - ], - extensions: Object.create(null), - astNode: schemaDef ?? schemaConfig.astNode, - extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions), - assumeValid: options?.assumeValid ?? false, - }; - - // Below are functions used for producing this schema that have closed over - // this scope and have access to the schema, cache, and newly defined types. - - function replaceType(type: T): T { - if (isListType(type)) { - // @ts-expect-error - return new GraphQLList(replaceType(type.ofType)); - } - if (isNonNullType(type)) { - // @ts-expect-error - return new GraphQLNonNull(replaceType(type.ofType)); - } - // @ts-expect-error FIXME - return replaceNamedType(type); - } - - function replaceNamedType(type: T): T { - // Note: While this could make early assertions to get the correctly - // typed values, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - return typeMap[type.name]; - } - - function replaceDirective(directive: GraphQLDirective): GraphQLDirective { - const config = directive.toConfig(); - return new GraphQLDirective({ - ...config, - args: mapValue(config.args, extendArg), - }); - } - - function extendNamedType(type: GraphQLNamedType): GraphQLNamedType { - if (isIntrospectionType(type) || isSpecifiedScalarType(type)) { - // Builtin types are not extended. - return type; - } - if (isScalarType(type)) { - return extendScalarType(type); - } - if (isObjectType(type)) { - return extendObjectType(type); - } - if (isInterfaceType(type)) { - return extendInterfaceType(type); - } - if (isUnionType(type)) { - return extendUnionType(type); - } - if (isEnumType(type)) { - return extendEnumType(type); - } - if (isInputObjectType(type)) { - return extendInputObjectType(type); - } - /* c8 ignore next 3 */ - // Not reachable, all possible type definition nodes have been considered. - invariant(false, 'Unexpected type: ' + inspect(type)); - } - - function extendInputObjectType( - type: GraphQLInputObjectType, - ): GraphQLInputObjectType { - const config = type.toConfig(); - const extensions = typeExtensionsMap[config.name] ?? []; - - return new GraphQLInputObjectType({ - ...config, - fields: () => ({ - ...mapValue(config.fields, (field) => ({ - ...field, - type: replaceType(field.type), - })), - ...buildInputFieldMap(extensions), - }), - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } - - function extendEnumType(type: GraphQLEnumType): GraphQLEnumType { - const config = type.toConfig(); - const extensions = typeExtensionsMap[type.name] ?? []; - - return new GraphQLEnumType({ - ...config, - values: { - ...config.values, - ...buildEnumValueMap(extensions), - }, - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } - - function extendScalarType(type: GraphQLScalarType): GraphQLScalarType { - const config = type.toConfig(); - const extensions = typeExtensionsMap[config.name] ?? []; - - let specifiedByURL = config.specifiedByURL; - for (const extensionNode of extensions) { - specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL; - } - - return new GraphQLScalarType({ - ...config, - specifiedByURL, - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } - - function extendObjectType(type: GraphQLObjectType): GraphQLObjectType { - const config = type.toConfig(); - const extensions = typeExtensionsMap[config.name] ?? []; - - return new GraphQLObjectType({ - ...config, - interfaces: () => [ - ...type.getInterfaces().map(replaceNamedType), - ...buildInterfaces(extensions), - ], - fields: () => ({ - ...mapValue(config.fields, extendField), - ...buildFieldMap(extensions), - }), - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } - - function extendInterfaceType( - type: GraphQLInterfaceType, - ): GraphQLInterfaceType { - const config = type.toConfig(); - const extensions = typeExtensionsMap[config.name] ?? []; - - return new GraphQLInterfaceType({ - ...config, - interfaces: () => [ - ...type.getInterfaces().map(replaceNamedType), - ...buildInterfaces(extensions), - ], - fields: () => ({ - ...mapValue(config.fields, extendField), - ...buildFieldMap(extensions), - }), - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } - - function extendUnionType(type: GraphQLUnionType): GraphQLUnionType { - const config = type.toConfig(); - const extensions = typeExtensionsMap[config.name] ?? []; - - return new GraphQLUnionType({ - ...config, - types: () => [ - ...type.getTypes().map(replaceNamedType), - ...buildUnionTypes(extensions), - ], - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } - - function extendField( - field: GraphQLFieldConfig, - ): GraphQLFieldConfig { - return { - ...field, - type: replaceType(field.type), - args: field.args && mapValue(field.args, extendArg), - }; - } - - function extendArg(arg: GraphQLArgumentConfig) { - return { - ...arg, - type: replaceType(arg.type), - }; - } - - function getOperationTypes( - nodes: ReadonlyArray, - ): { - query?: Maybe; - mutation?: Maybe; - subscription?: Maybe; - } { - const opTypes = {}; - for (const node of nodes) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const operationTypesNodes = - /* c8 ignore next */ node.operationTypes ?? []; - - for (const operationType of operationTypesNodes) { - // Note: While this could make early assertions to get the correctly - // typed values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - // @ts-expect-error - opTypes[operationType.operation] = getNamedType(operationType.type); - } - } - - return opTypes; - } - - function getNamedType(node: NamedTypeNode): GraphQLNamedType { - const name = node.name.value; - const type = stdTypeMap[name] ?? typeMap[name]; - - if (type === undefined) { - throw new Error(`Unknown type: "${name}".`); - } - return type; - } - - function getWrappedType(node: TypeNode): GraphQLType { - if (node.kind === Kind.LIST_TYPE) { - return new GraphQLList(getWrappedType(node.type)); - } - if (node.kind === Kind.NON_NULL_TYPE) { - return new GraphQLNonNull(getWrappedType(node.type)); - } - return getNamedType(node); - } - - function buildDirective(node: DirectiveDefinitionNode): GraphQLDirective { - return new GraphQLDirective({ - name: node.name.value, - description: node.description?.value, - // @ts-expect-error - locations: node.locations.map(({ value }) => value), - isRepeatable: node.repeatable, - args: buildArgumentMap(node.arguments), - astNode: node, - }); - } - - function buildFieldMap( - nodes: ReadonlyArray< - | InterfaceTypeDefinitionNode - | InterfaceTypeExtensionNode - | ObjectTypeDefinitionNode - | ObjectTypeExtensionNode - >, - ): GraphQLFieldConfigMap { - const fieldConfigMap = Object.create(null); - for (const node of nodes) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const nodeFields = /* c8 ignore next */ node.fields ?? []; - - for (const field of nodeFields) { - fieldConfigMap[field.name.value] = { - // Note: While this could make assertions to get the correctly typed - // value, that would throw immediately while type system validation - // with validateSchema() will produce more actionable results. - type: getWrappedType(field.type), - description: field.description?.value, - args: buildArgumentMap(field.arguments), - deprecationReason: getDeprecationReason(field), - astNode: field, - }; - } - } - return fieldConfigMap; - } - - function buildArgumentMap( - args: Maybe>, - ): GraphQLFieldConfigArgumentMap { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const argsNodes = /* c8 ignore next */ args ?? []; - - const argConfigMap = Object.create(null); - for (const arg of argsNodes) { - // Note: While this could make assertions to get the correctly typed - // value, that would throw immediately while type system validation - // with validateSchema() will produce more actionable results. - const type: any = getWrappedType(arg.type); - - argConfigMap[arg.name.value] = { - type, - description: arg.description?.value, - defaultValue: valueFromAST(arg.defaultValue, type), - deprecationReason: getDeprecationReason(arg), - astNode: arg, - }; - } - return argConfigMap; - } - - function buildInputFieldMap( - nodes: ReadonlyArray< - InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode - >, - ): GraphQLInputFieldConfigMap { - const inputFieldMap = Object.create(null); - for (const node of nodes) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const fieldsNodes = /* c8 ignore next */ node.fields ?? []; - - for (const field of fieldsNodes) { - // Note: While this could make assertions to get the correctly typed - // value, that would throw immediately while type system validation - // with validateSchema() will produce more actionable results. - const type: any = getWrappedType(field.type); - - inputFieldMap[field.name.value] = { - type, - description: field.description?.value, - defaultValue: valueFromAST(field.defaultValue, type), - deprecationReason: getDeprecationReason(field), - astNode: field, - }; - } - } - return inputFieldMap; - } - - function buildEnumValueMap( - nodes: ReadonlyArray, - ): GraphQLEnumValueConfigMap { - const enumValueMap = Object.create(null); - for (const node of nodes) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const valuesNodes = /* c8 ignore next */ node.values ?? []; - - for (const value of valuesNodes) { - enumValueMap[value.name.value] = { - description: value.description?.value, - deprecationReason: getDeprecationReason(value), - astNode: value, - }; - } - } - return enumValueMap; - } - - function buildInterfaces( - nodes: ReadonlyArray< - | InterfaceTypeDefinitionNode - | InterfaceTypeExtensionNode - | ObjectTypeDefinitionNode - | ObjectTypeExtensionNode - >, - ): Array { - // Note: While this could make assertions to get the correctly typed - // values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - // @ts-expect-error - return nodes.flatMap( - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - (node) => /* c8 ignore next */ node.interfaces?.map(getNamedType) ?? [], - ); - } - - function buildUnionTypes( - nodes: ReadonlyArray, - ): Array { - // Note: While this could make assertions to get the correctly typed - // values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - // @ts-expect-error - return nodes.flatMap( - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - (node) => /* c8 ignore next */ node.types?.map(getNamedType) ?? [], - ); - } - - function buildType(astNode: TypeDefinitionNode): GraphQLNamedType { - const name = astNode.name.value; - const extensionASTNodes = typeExtensionsMap[name] ?? []; - - switch (astNode.kind) { - case Kind.OBJECT_TYPE_DEFINITION: { - const allNodes = [astNode, ...extensionASTNodes]; - - return new GraphQLObjectType({ - name, - description: astNode.description?.value, - interfaces: () => buildInterfaces(allNodes), - fields: () => buildFieldMap(allNodes), - astNode, - extensionASTNodes, - }); - } - case Kind.INTERFACE_TYPE_DEFINITION: { - const allNodes = [astNode, ...extensionASTNodes]; - - return new GraphQLInterfaceType({ - name, - description: astNode.description?.value, - interfaces: () => buildInterfaces(allNodes), - fields: () => buildFieldMap(allNodes), - astNode, - extensionASTNodes, - }); - } - case Kind.ENUM_TYPE_DEFINITION: { - const allNodes = [astNode, ...extensionASTNodes]; - - return new GraphQLEnumType({ - name, - description: astNode.description?.value, - values: buildEnumValueMap(allNodes), - astNode, - extensionASTNodes, - }); - } - case Kind.UNION_TYPE_DEFINITION: { - const allNodes = [astNode, ...extensionASTNodes]; - - return new GraphQLUnionType({ - name, - description: astNode.description?.value, - types: () => buildUnionTypes(allNodes), - astNode, - extensionASTNodes, - }); - } - case Kind.SCALAR_TYPE_DEFINITION: { - return new GraphQLScalarType({ - name, - description: astNode.description?.value, - specifiedByURL: getSpecifiedByURL(astNode), - astNode, - extensionASTNodes, - }); - } - case Kind.INPUT_OBJECT_TYPE_DEFINITION: { - const allNodes = [astNode, ...extensionASTNodes]; - - return new GraphQLInputObjectType({ - name, - description: astNode.description?.value, - fields: () => buildInputFieldMap(allNodes), - astNode, - extensionASTNodes, - isOneOf: isOneOf(astNode), - }); - } - } - } -} - -const stdTypeMap = keyMap( - [...specifiedScalarTypes, ...introspectionTypes], - (type) => type.name, -); - -/** - * Given a field or enum value node, returns the string value for the - * deprecation reason. - */ -function getDeprecationReason( - node: - | EnumValueDefinitionNode - | FieldDefinitionNode - | InputValueDefinitionNode, -): Maybe { - const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node); - // @ts-expect-error validated by `getDirectiveValues` - return deprecated?.reason; -} - -/** - * Given a scalar node, returns the string value for the specifiedByURL. - */ -function getSpecifiedByURL( - node: ScalarTypeDefinitionNode | ScalarTypeExtensionNode, -): Maybe { - const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node); - // @ts-expect-error validated by `getDirectiveValues` - return specifiedBy?.url; -} - -/** - * Given an input object node, returns if the node should be OneOf. - */ -function isOneOf(node: InputObjectTypeDefinitionNode): boolean { - return Boolean(getDirectiveValues(GraphQLOneOfDirective, node)); -} diff --git a/src/utilities/findBreakingChanges.ts b/src/utilities/findBreakingChanges.ts deleted file mode 100644 index 2489af9d62..0000000000 --- a/src/utilities/findBreakingChanges.ts +++ /dev/null @@ -1,574 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import { keyMap } from '../jsutils/keyMap'; - -import { print } from '../language/printer'; - -import type { - GraphQLEnumType, - GraphQLField, - GraphQLInputObjectType, - GraphQLInputType, - GraphQLInterfaceType, - GraphQLNamedType, - GraphQLObjectType, - GraphQLType, - GraphQLUnionType, -} from '../type/definition'; -import { - isEnumType, - isInputObjectType, - isInterfaceType, - isListType, - isNamedType, - isNonNullType, - isObjectType, - isRequiredArgument, - isRequiredInputField, - isScalarType, - isUnionType, -} from '../type/definition'; -import { isSpecifiedScalarType } from '../type/scalars'; -import type { GraphQLSchema } from '../type/schema'; - -import { astFromValue } from './astFromValue'; -import { sortValueNode } from './sortValueNode'; - -enum BreakingChangeType { - TYPE_REMOVED = 'TYPE_REMOVED', - TYPE_CHANGED_KIND = 'TYPE_CHANGED_KIND', - TYPE_REMOVED_FROM_UNION = 'TYPE_REMOVED_FROM_UNION', - VALUE_REMOVED_FROM_ENUM = 'VALUE_REMOVED_FROM_ENUM', - REQUIRED_INPUT_FIELD_ADDED = 'REQUIRED_INPUT_FIELD_ADDED', - IMPLEMENTED_INTERFACE_REMOVED = 'IMPLEMENTED_INTERFACE_REMOVED', - FIELD_REMOVED = 'FIELD_REMOVED', - FIELD_CHANGED_KIND = 'FIELD_CHANGED_KIND', - REQUIRED_ARG_ADDED = 'REQUIRED_ARG_ADDED', - ARG_REMOVED = 'ARG_REMOVED', - ARG_CHANGED_KIND = 'ARG_CHANGED_KIND', - DIRECTIVE_REMOVED = 'DIRECTIVE_REMOVED', - DIRECTIVE_ARG_REMOVED = 'DIRECTIVE_ARG_REMOVED', - REQUIRED_DIRECTIVE_ARG_ADDED = 'REQUIRED_DIRECTIVE_ARG_ADDED', - DIRECTIVE_REPEATABLE_REMOVED = 'DIRECTIVE_REPEATABLE_REMOVED', - DIRECTIVE_LOCATION_REMOVED = 'DIRECTIVE_LOCATION_REMOVED', -} -export { BreakingChangeType }; - -enum DangerousChangeType { - VALUE_ADDED_TO_ENUM = 'VALUE_ADDED_TO_ENUM', - TYPE_ADDED_TO_UNION = 'TYPE_ADDED_TO_UNION', - OPTIONAL_INPUT_FIELD_ADDED = 'OPTIONAL_INPUT_FIELD_ADDED', - OPTIONAL_ARG_ADDED = 'OPTIONAL_ARG_ADDED', - IMPLEMENTED_INTERFACE_ADDED = 'IMPLEMENTED_INTERFACE_ADDED', - ARG_DEFAULT_VALUE_CHANGE = 'ARG_DEFAULT_VALUE_CHANGE', -} -export { DangerousChangeType }; - -export interface BreakingChange { - type: BreakingChangeType; - description: string; -} - -export interface DangerousChange { - type: DangerousChangeType; - description: string; -} - -/** - * Given two schemas, returns an Array containing descriptions of all the types - * of breaking changes covered by the other functions down below. - */ -export function findBreakingChanges( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array { - // @ts-expect-error - return findSchemaChanges(oldSchema, newSchema).filter( - (change) => change.type in BreakingChangeType, - ); -} - -/** - * Given two schemas, returns an Array containing descriptions of all the types - * of potentially dangerous changes covered by the other functions down below. - */ -export function findDangerousChanges( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array { - // @ts-expect-error - return findSchemaChanges(oldSchema, newSchema).filter( - (change) => change.type in DangerousChangeType, - ); -} - -function findSchemaChanges( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array { - return [ - ...findTypeChanges(oldSchema, newSchema), - ...findDirectiveChanges(oldSchema, newSchema), - ]; -} - -function findDirectiveChanges( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array { - const schemaChanges = []; - - const directivesDiff = diff( - oldSchema.getDirectives(), - newSchema.getDirectives(), - ); - - for (const oldDirective of directivesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_REMOVED, - description: `${oldDirective.name} was removed.`, - }); - } - - for (const [oldDirective, newDirective] of directivesDiff.persisted) { - const argsDiff = diff(oldDirective.args, newDirective.args); - - for (const newArg of argsDiff.added) { - if (isRequiredArgument(newArg)) { - schemaChanges.push({ - type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, - description: `A required arg ${newArg.name} on directive ${oldDirective.name} was added.`, - }); - } - } - - for (const oldArg of argsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, - description: `${oldArg.name} was removed from ${oldDirective.name}.`, - }); - } - - if (oldDirective.isRepeatable && !newDirective.isRepeatable) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, - description: `Repeatable flag was removed from ${oldDirective.name}.`, - }); - } - - for (const location of oldDirective.locations) { - if (!newDirective.locations.includes(location)) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, - description: `${location} was removed from ${oldDirective.name}.`, - }); - } - } - } - - return schemaChanges; -} - -function findTypeChanges( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array { - const schemaChanges = []; - - const typesDiff = diff( - Object.values(oldSchema.getTypeMap()), - Object.values(newSchema.getTypeMap()), - ); - - for (const oldType of typesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.TYPE_REMOVED, - description: isSpecifiedScalarType(oldType) - ? `Standard scalar ${oldType.name} was removed because it is not referenced anymore.` - : `${oldType.name} was removed.`, - }); - } - - for (const [oldType, newType] of typesDiff.persisted) { - if (isEnumType(oldType) && isEnumType(newType)) { - schemaChanges.push(...findEnumTypeChanges(oldType, newType)); - } else if (isUnionType(oldType) && isUnionType(newType)) { - schemaChanges.push(...findUnionTypeChanges(oldType, newType)); - } else if (isInputObjectType(oldType) && isInputObjectType(newType)) { - schemaChanges.push(...findInputObjectTypeChanges(oldType, newType)); - } else if (isObjectType(oldType) && isObjectType(newType)) { - schemaChanges.push( - ...findFieldChanges(oldType, newType), - ...findImplementedInterfacesChanges(oldType, newType), - ); - } else if (isInterfaceType(oldType) && isInterfaceType(newType)) { - schemaChanges.push( - ...findFieldChanges(oldType, newType), - ...findImplementedInterfacesChanges(oldType, newType), - ); - } else if (oldType.constructor !== newType.constructor) { - schemaChanges.push({ - type: BreakingChangeType.TYPE_CHANGED_KIND, - description: - `${oldType.name} changed from ` + - `${typeKindName(oldType)} to ${typeKindName(newType)}.`, - }); - } - } - - return schemaChanges; -} - -function findInputObjectTypeChanges( - oldType: GraphQLInputObjectType, - newType: GraphQLInputObjectType, -): Array { - const schemaChanges = []; - const fieldsDiff = diff( - Object.values(oldType.getFields()), - Object.values(newType.getFields()), - ); - - for (const newField of fieldsDiff.added) { - if (isRequiredInputField(newField)) { - schemaChanges.push({ - type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, - description: `A required field ${newField.name} on input type ${oldType.name} was added.`, - }); - } else { - schemaChanges.push({ - type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, - description: `An optional field ${newField.name} on input type ${oldType.name} was added.`, - }); - } - } - - for (const oldField of fieldsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_REMOVED, - description: `${oldType.name}.${oldField.name} was removed.`, - }); - } - - for (const [oldField, newField] of fieldsDiff.persisted) { - const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( - oldField.type, - newField.type, - ); - if (!isSafe) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: - `${oldType.name}.${oldField.name} changed type from ` + - `${String(oldField.type)} to ${String(newField.type)}.`, - }); - } - } - - return schemaChanges; -} - -function findUnionTypeChanges( - oldType: GraphQLUnionType, - newType: GraphQLUnionType, -): Array { - const schemaChanges = []; - const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes()); - - for (const newPossibleType of possibleTypesDiff.added) { - schemaChanges.push({ - type: DangerousChangeType.TYPE_ADDED_TO_UNION, - description: `${newPossibleType.name} was added to union type ${oldType.name}.`, - }); - } - - for (const oldPossibleType of possibleTypesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, - description: `${oldPossibleType.name} was removed from union type ${oldType.name}.`, - }); - } - - return schemaChanges; -} - -function findEnumTypeChanges( - oldType: GraphQLEnumType, - newType: GraphQLEnumType, -): Array { - const schemaChanges = []; - const valuesDiff = diff(oldType.getValues(), newType.getValues()); - - for (const newValue of valuesDiff.added) { - schemaChanges.push({ - type: DangerousChangeType.VALUE_ADDED_TO_ENUM, - description: `${newValue.name} was added to enum type ${oldType.name}.`, - }); - } - - for (const oldValue of valuesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, - description: `${oldValue.name} was removed from enum type ${oldType.name}.`, - }); - } - - return schemaChanges; -} - -function findImplementedInterfacesChanges( - oldType: GraphQLObjectType | GraphQLInterfaceType, - newType: GraphQLObjectType | GraphQLInterfaceType, -): Array { - const schemaChanges = []; - const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces()); - - for (const newInterface of interfacesDiff.added) { - schemaChanges.push({ - type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, - description: `${newInterface.name} added to interfaces implemented by ${oldType.name}.`, - }); - } - - for (const oldInterface of interfacesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, - description: `${oldType.name} no longer implements interface ${oldInterface.name}.`, - }); - } - - return schemaChanges; -} - -function findFieldChanges( - oldType: GraphQLObjectType | GraphQLInterfaceType, - newType: GraphQLObjectType | GraphQLInterfaceType, -): Array { - const schemaChanges = []; - const fieldsDiff = diff( - Object.values(oldType.getFields()), - Object.values(newType.getFields()), - ); - - for (const oldField of fieldsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_REMOVED, - description: `${oldType.name}.${oldField.name} was removed.`, - }); - } - - for (const [oldField, newField] of fieldsDiff.persisted) { - schemaChanges.push(...findArgChanges(oldType, oldField, newField)); - - const isSafe = isChangeSafeForObjectOrInterfaceField( - oldField.type, - newField.type, - ); - if (!isSafe) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: - `${oldType.name}.${oldField.name} changed type from ` + - `${String(oldField.type)} to ${String(newField.type)}.`, - }); - } - } - - return schemaChanges; -} - -function findArgChanges( - oldType: GraphQLObjectType | GraphQLInterfaceType, - oldField: GraphQLField, - newField: GraphQLField, -): Array { - const schemaChanges = []; - const argsDiff = diff(oldField.args, newField.args); - - for (const oldArg of argsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.ARG_REMOVED, - description: `${oldType.name}.${oldField.name} arg ${oldArg.name} was removed.`, - }); - } - - for (const [oldArg, newArg] of argsDiff.persisted) { - const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( - oldArg.type, - newArg.type, - ); - if (!isSafe) { - schemaChanges.push({ - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed type from ` + - `${String(oldArg.type)} to ${String(newArg.type)}.`, - }); - } else if (oldArg.defaultValue !== undefined) { - if (newArg.defaultValue === undefined) { - schemaChanges.push({ - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: `${oldType.name}.${oldField.name} arg ${oldArg.name} defaultValue was removed.`, - }); - } else { - // Since we looking only for client's observable changes we should - // compare default values in the same representation as they are - // represented inside introspection. - const oldValueStr = stringifyValue(oldArg.defaultValue, oldArg.type); - const newValueStr = stringifyValue(newArg.defaultValue, newArg.type); - - if (oldValueStr !== newValueStr) { - schemaChanges.push({ - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed defaultValue from ${oldValueStr} to ${newValueStr}.`, - }); - } - } - } - } - - for (const newArg of argsDiff.added) { - if (isRequiredArgument(newArg)) { - schemaChanges.push({ - type: BreakingChangeType.REQUIRED_ARG_ADDED, - description: `A required arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, - }); - } else { - schemaChanges.push({ - type: DangerousChangeType.OPTIONAL_ARG_ADDED, - description: `An optional arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, - }); - } - } - - return schemaChanges; -} - -function isChangeSafeForObjectOrInterfaceField( - oldType: GraphQLType, - newType: GraphQLType, -): boolean { - if (isListType(oldType)) { - return ( - // if they're both lists, make sure the underlying types are compatible - (isListType(newType) && - isChangeSafeForObjectOrInterfaceField( - oldType.ofType, - newType.ofType, - )) || - // moving from nullable to non-null of the same underlying type is safe - (isNonNullType(newType) && - isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) - ); - } - - if (isNonNullType(oldType)) { - // if they're both non-null, make sure the underlying types are compatible - return ( - isNonNullType(newType) && - isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType) - ); - } - - return ( - // if they're both named types, see if their names are equivalent - (isNamedType(newType) && oldType.name === newType.name) || - // moving from nullable to non-null of the same underlying type is safe - (isNonNullType(newType) && - isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) - ); -} - -function isChangeSafeForInputObjectFieldOrFieldArg( - oldType: GraphQLType, - newType: GraphQLType, -): boolean { - if (isListType(oldType)) { - // if they're both lists, make sure the underlying types are compatible - return ( - isListType(newType) && - isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType) - ); - } - - if (isNonNullType(oldType)) { - return ( - // if they're both non-null, make sure the underlying types are - // compatible - (isNonNullType(newType) && - isChangeSafeForInputObjectFieldOrFieldArg( - oldType.ofType, - newType.ofType, - )) || - // moving from non-null to nullable of the same underlying type is safe - (!isNonNullType(newType) && - isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType)) - ); - } - - // if they're both named types, see if their names are equivalent - return isNamedType(newType) && oldType.name === newType.name; -} - -function typeKindName(type: GraphQLNamedType): string { - if (isScalarType(type)) { - return 'a Scalar type'; - } - if (isObjectType(type)) { - return 'an Object type'; - } - if (isInterfaceType(type)) { - return 'an Interface type'; - } - if (isUnionType(type)) { - return 'a Union type'; - } - if (isEnumType(type)) { - return 'an Enum type'; - } - if (isInputObjectType(type)) { - return 'an Input type'; - } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - invariant(false, 'Unexpected type: ' + inspect(type)); -} - -function stringifyValue(value: unknown, type: GraphQLInputType): string { - const ast = astFromValue(value, type); - invariant(ast != null); - return print(sortValueNode(ast)); -} - -function diff( - oldArray: ReadonlyArray, - newArray: ReadonlyArray, -): { - added: ReadonlyArray; - removed: ReadonlyArray; - persisted: ReadonlyArray<[T, T]>; -} { - const added: Array = []; - const removed: Array = []; - const persisted: Array<[T, T]> = []; - - const oldMap = keyMap(oldArray, ({ name }) => name); - const newMap = keyMap(newArray, ({ name }) => name); - - for (const oldItem of oldArray) { - const newItem = newMap[oldItem.name]; - if (newItem === undefined) { - removed.push(oldItem); - } else { - persisted.push([oldItem, newItem]); - } - } - - for (const newItem of newArray) { - if (oldMap[newItem.name] === undefined) { - added.push(newItem); - } - } - - return { added, persisted, removed }; -} diff --git a/src/utilities/getIntrospectionQuery.ts b/src/utilities/getIntrospectionQuery.ts deleted file mode 100644 index 373b474ed5..0000000000 --- a/src/utilities/getIntrospectionQuery.ts +++ /dev/null @@ -1,349 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; - -import type { DirectiveLocation } from '../language/directiveLocation'; - -export interface IntrospectionOptions { - /** - * Whether to include descriptions in the introspection result. - * Default: true - */ - descriptions?: boolean; - - /** - * Whether to include `specifiedByURL` in the introspection result. - * Default: false - */ - specifiedByUrl?: boolean; - - /** - * Whether to include `isRepeatable` flag on directives. - * Default: false - */ - directiveIsRepeatable?: boolean; - - /** - * Whether to include `description` field on schema. - * Default: false - */ - schemaDescription?: boolean; - - /** - * Whether target GraphQL server support deprecation of input values. - * Default: false - */ - inputValueDeprecation?: boolean; - - /** - * Whether target GraphQL server supports `@oneOf` input objects. - * Default: false - */ - oneOf?: boolean; -} - -/** - * Produce the GraphQL query recommended for a full schema introspection. - * Accepts optional IntrospectionOptions. - */ -export function getIntrospectionQuery(options?: IntrospectionOptions): string { - const optionsWithDefault = { - descriptions: true, - specifiedByUrl: false, - directiveIsRepeatable: false, - schemaDescription: false, - inputValueDeprecation: false, - oneOf: false, - ...options, - }; - - const descriptions = optionsWithDefault.descriptions ? 'description' : ''; - const specifiedByUrl = optionsWithDefault.specifiedByUrl - ? 'specifiedByURL' - : ''; - const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable - ? 'isRepeatable' - : ''; - const schemaDescription = optionsWithDefault.schemaDescription - ? descriptions - : ''; - - function inputDeprecation(str: string) { - return optionsWithDefault.inputValueDeprecation ? str : ''; - } - const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : ''; - - return ` - query IntrospectionQuery { - __schema { - ${schemaDescription} - queryType { name kind } - mutationType { name kind } - subscriptionType { name kind } - types { - ...FullType - } - directives { - name - ${descriptions} - ${directiveIsRepeatable} - locations - args${inputDeprecation('(includeDeprecated: true)')} { - ...InputValue - } - } - } - } - - fragment FullType on __Type { - kind - name - ${descriptions} - ${specifiedByUrl} - ${oneOf} - fields(includeDeprecated: true) { - name - ${descriptions} - args${inputDeprecation('(includeDeprecated: true)')} { - ...InputValue - } - type { - ...TypeRef - } - isDeprecated - deprecationReason - } - inputFields${inputDeprecation('(includeDeprecated: true)')} { - ...InputValue - } - interfaces { - ...TypeRef - } - enumValues(includeDeprecated: true) { - name - ${descriptions} - isDeprecated - deprecationReason - } - possibleTypes { - ...TypeRef - } - } - - fragment InputValue on __InputValue { - name - ${descriptions} - type { ...TypeRef } - defaultValue - ${inputDeprecation('isDeprecated')} - ${inputDeprecation('deprecationReason')} - } - - fragment TypeRef on __Type { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - } - } - } - } - } - } - } - } - } - } - `; -} - -export interface IntrospectionQuery { - readonly __schema: IntrospectionSchema; -} - -export interface IntrospectionSchema { - readonly description?: Maybe; - readonly queryType: IntrospectionNamedTypeRef; - readonly mutationType: Maybe< - IntrospectionNamedTypeRef - >; - readonly subscriptionType: Maybe< - IntrospectionNamedTypeRef - >; - readonly types: ReadonlyArray; - readonly directives: ReadonlyArray; -} - -export type IntrospectionType = - | IntrospectionScalarType - | IntrospectionObjectType - | IntrospectionInterfaceType - | IntrospectionUnionType - | IntrospectionEnumType - | IntrospectionInputObjectType; - -export type IntrospectionOutputType = - | IntrospectionScalarType - | IntrospectionObjectType - | IntrospectionInterfaceType - | IntrospectionUnionType - | IntrospectionEnumType; - -export type IntrospectionInputType = - | IntrospectionScalarType - | IntrospectionEnumType - | IntrospectionInputObjectType; - -export interface IntrospectionScalarType { - readonly kind: 'SCALAR'; - readonly name: string; - readonly description?: Maybe; - readonly specifiedByURL?: Maybe; -} - -export interface IntrospectionObjectType { - readonly kind: 'OBJECT'; - readonly name: string; - readonly description?: Maybe; - readonly fields: ReadonlyArray; - readonly interfaces: ReadonlyArray< - IntrospectionNamedTypeRef - >; -} - -export interface IntrospectionInterfaceType { - readonly kind: 'INTERFACE'; - readonly name: string; - readonly description?: Maybe; - readonly fields: ReadonlyArray; - readonly interfaces: ReadonlyArray< - IntrospectionNamedTypeRef - >; - readonly possibleTypes: ReadonlyArray< - IntrospectionNamedTypeRef - >; -} - -export interface IntrospectionUnionType { - readonly kind: 'UNION'; - readonly name: string; - readonly description?: Maybe; - readonly possibleTypes: ReadonlyArray< - IntrospectionNamedTypeRef - >; -} - -export interface IntrospectionEnumType { - readonly kind: 'ENUM'; - readonly name: string; - readonly description?: Maybe; - readonly enumValues: ReadonlyArray; -} - -export interface IntrospectionInputObjectType { - readonly kind: 'INPUT_OBJECT'; - readonly name: string; - readonly description?: Maybe; - readonly inputFields: ReadonlyArray; - readonly isOneOf: boolean; -} - -export interface IntrospectionListTypeRef< - T extends IntrospectionTypeRef = IntrospectionTypeRef, -> { - readonly kind: 'LIST'; - readonly ofType: T; -} - -export interface IntrospectionNonNullTypeRef< - T extends IntrospectionTypeRef = IntrospectionTypeRef, -> { - readonly kind: 'NON_NULL'; - readonly ofType: T; -} - -export type IntrospectionTypeRef = - | IntrospectionNamedTypeRef - | IntrospectionListTypeRef - | IntrospectionNonNullTypeRef< - IntrospectionNamedTypeRef | IntrospectionListTypeRef - >; - -export type IntrospectionOutputTypeRef = - | IntrospectionNamedTypeRef - | IntrospectionListTypeRef - | IntrospectionNonNullTypeRef< - | IntrospectionNamedTypeRef - | IntrospectionListTypeRef - >; - -export type IntrospectionInputTypeRef = - | IntrospectionNamedTypeRef - | IntrospectionListTypeRef - | IntrospectionNonNullTypeRef< - | IntrospectionNamedTypeRef - | IntrospectionListTypeRef - >; - -export interface IntrospectionNamedTypeRef< - T extends IntrospectionType = IntrospectionType, -> { - readonly kind: T['kind']; - readonly name: string; -} - -export interface IntrospectionField { - readonly name: string; - readonly description?: Maybe; - readonly args: ReadonlyArray; - readonly type: IntrospectionOutputTypeRef; - readonly isDeprecated: boolean; - readonly deprecationReason: Maybe; -} - -export interface IntrospectionInputValue { - readonly name: string; - readonly description?: Maybe; - readonly type: IntrospectionInputTypeRef; - readonly defaultValue: Maybe; - readonly isDeprecated?: boolean; - readonly deprecationReason?: Maybe; -} - -export interface IntrospectionEnumValue { - readonly name: string; - readonly description?: Maybe; - readonly isDeprecated: boolean; - readonly deprecationReason: Maybe; -} - -export interface IntrospectionDirective { - readonly name: string; - readonly description?: Maybe; - readonly isRepeatable?: boolean; - readonly locations: ReadonlyArray; - readonly args: ReadonlyArray; -} diff --git a/src/utilities/getOperationAST.ts b/src/utilities/getOperationAST.ts deleted file mode 100644 index 8decf943f6..0000000000 --- a/src/utilities/getOperationAST.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; - -import type { DocumentNode, OperationDefinitionNode } from '../language/ast'; -import { Kind } from '../language/kinds'; - -/** - * Returns an operation AST given a document AST and optionally an operation - * name. If a name is not provided, an operation is only returned if only one is - * provided in the document. - */ -export function getOperationAST( - documentAST: DocumentNode, - operationName?: Maybe, -): Maybe { - let operation = null; - for (const definition of documentAST.definitions) { - if (definition.kind === Kind.OPERATION_DEFINITION) { - if (operationName == null) { - // If no operation name was provided, only return an Operation if there - // is one defined in the document. Upon encountering the second, return - // null. - if (operation) { - return null; - } - operation = definition; - } else if (definition.name?.value === operationName) { - return definition; - } - } - } - return operation; -} diff --git a/src/utilities/getOperationRootType.ts b/src/utilities/getOperationRootType.ts deleted file mode 100644 index db20a793a8..0000000000 --- a/src/utilities/getOperationRootType.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { GraphQLError } from '../error/GraphQLError'; - -import type { - OperationDefinitionNode, - OperationTypeDefinitionNode, -} from '../language/ast'; - -import type { GraphQLObjectType } from '../type/definition'; -import type { GraphQLSchema } from '../type/schema'; - -/** - * Extracts the root type of the operation from the schema. - * - * @deprecated Please use `GraphQLSchema.getRootType` instead. Will be removed in v17 - */ -export function getOperationRootType( - schema: GraphQLSchema, - operation: OperationDefinitionNode | OperationTypeDefinitionNode, -): GraphQLObjectType { - if (operation.operation === 'query') { - const queryType = schema.getQueryType(); - if (!queryType) { - throw new GraphQLError( - 'Schema does not define the required query root type.', - { nodes: operation }, - ); - } - return queryType; - } - - if (operation.operation === 'mutation') { - const mutationType = schema.getMutationType(); - if (!mutationType) { - throw new GraphQLError('Schema is not configured for mutations.', { - nodes: operation, - }); - } - return mutationType; - } - - if (operation.operation === 'subscription') { - const subscriptionType = schema.getSubscriptionType(); - if (!subscriptionType) { - throw new GraphQLError('Schema is not configured for subscriptions.', { - nodes: operation, - }); - } - return subscriptionType; - } - - throw new GraphQLError( - 'Can only have query, mutation and subscription operations.', - { nodes: operation }, - ); -} diff --git a/src/utilities/index.ts b/src/utilities/index.ts deleted file mode 100644 index 452b975233..0000000000 --- a/src/utilities/index.ts +++ /dev/null @@ -1,105 +0,0 @@ -// Produce the GraphQL query recommended for a full schema introspection. -export { getIntrospectionQuery } from './getIntrospectionQuery'; - -export type { - IntrospectionOptions, - IntrospectionQuery, - IntrospectionSchema, - IntrospectionType, - IntrospectionInputType, - IntrospectionOutputType, - IntrospectionScalarType, - IntrospectionObjectType, - IntrospectionInterfaceType, - IntrospectionUnionType, - IntrospectionEnumType, - IntrospectionInputObjectType, - IntrospectionTypeRef, - IntrospectionInputTypeRef, - IntrospectionOutputTypeRef, - IntrospectionNamedTypeRef, - IntrospectionListTypeRef, - IntrospectionNonNullTypeRef, - IntrospectionField, - IntrospectionInputValue, - IntrospectionEnumValue, - IntrospectionDirective, -} from './getIntrospectionQuery'; - -// Gets the target Operation from a Document. -export { getOperationAST } from './getOperationAST'; - -// Gets the Type for the target Operation AST. -export { getOperationRootType } from './getOperationRootType'; - -// Convert a GraphQLSchema to an IntrospectionQuery. -export { introspectionFromSchema } from './introspectionFromSchema'; - -// Build a GraphQLSchema from an introspection result. -export { buildClientSchema } from './buildClientSchema'; - -// Build a GraphQLSchema from GraphQL Schema language. -export { buildASTSchema, buildSchema } from './buildASTSchema'; -export type { BuildSchemaOptions } from './buildASTSchema'; - -// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. -export { extendSchema } from './extendSchema'; - -// Sort a GraphQLSchema. -export { lexicographicSortSchema } from './lexicographicSortSchema'; - -// Print a GraphQLSchema to GraphQL Schema language. -export { - printSchema, - printType, - printIntrospectionSchema, -} from './printSchema'; - -// Create a GraphQLType from a GraphQL language AST. -export { typeFromAST } from './typeFromAST'; - -// Create a JavaScript value from a GraphQL language AST with a type. -export { valueFromAST } from './valueFromAST'; - -// Create a JavaScript value from a GraphQL language AST without a type. -export { valueFromASTUntyped } from './valueFromASTUntyped'; - -// Create a GraphQL language AST from a JavaScript value. -export { astFromValue } from './astFromValue'; - -// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. -export { TypeInfo, visitWithTypeInfo } from './TypeInfo'; - -// Coerces a JavaScript value to a GraphQL type, or produces errors. -export { coerceInputValue } from './coerceInputValue'; - -// Concatenates multiple AST together. -export { concatAST } from './concatAST'; - -// Separates an AST into an AST per Operation. -export { separateOperations } from './separateOperations'; - -// Strips characters that are not significant to the validity or execution of a GraphQL document. -export { stripIgnoredCharacters } from './stripIgnoredCharacters'; - -// Comparators for types -export { - isEqualType, - isTypeSubTypeOf, - doTypesOverlap, -} from './typeComparators'; - -// Asserts that a string is a valid GraphQL name -export { assertValidName, isValidNameError } from './assertValidName'; - -// Compares two GraphQLSchemas and detects breaking changes. -export { - BreakingChangeType, - DangerousChangeType, - findBreakingChanges, - findDangerousChanges, -} from './findBreakingChanges'; -export type { BreakingChange, DangerousChange } from './findBreakingChanges'; - -// Wrapper type that contains DocumentNode and types that can be deduced from it. -export type { TypedQueryDocumentNode } from './typedQueryDocumentNode'; diff --git a/src/utilities/introspectionFromSchema.ts b/src/utilities/introspectionFromSchema.ts deleted file mode 100644 index 5f58248363..0000000000 --- a/src/utilities/introspectionFromSchema.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { invariant } from '../jsutils/invariant'; - -import { parse } from '../language/parser'; - -import type { GraphQLSchema } from '../type/schema'; - -import { executeSync } from '../execution/execute'; - -import type { - IntrospectionOptions, - IntrospectionQuery, -} from './getIntrospectionQuery'; -import { getIntrospectionQuery } from './getIntrospectionQuery'; - -/** - * Build an IntrospectionQuery from a GraphQLSchema - * - * IntrospectionQuery is useful for utilities that care about type and field - * relationships, but do not need to traverse through those relationships. - * - * This is the inverse of buildClientSchema. The primary use case is outside - * of the server context, for instance when doing schema comparisons. - */ -export function introspectionFromSchema( - schema: GraphQLSchema, - options?: IntrospectionOptions, -): IntrospectionQuery { - const optionsWithDefaults = { - specifiedByUrl: true, - directiveIsRepeatable: true, - schemaDescription: true, - inputValueDeprecation: true, - oneOf: true, - ...options, - }; - - const document = parse(getIntrospectionQuery(optionsWithDefaults)); - const result = executeSync({ schema, document }); - invariant(!result.errors && result.data); - return result.data as any; -} diff --git a/src/utilities/lexicographicSortSchema.ts b/src/utilities/lexicographicSortSchema.ts deleted file mode 100644 index 26b6908c9f..0000000000 --- a/src/utilities/lexicographicSortSchema.ts +++ /dev/null @@ -1,190 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import { keyValMap } from '../jsutils/keyValMap'; -import type { Maybe } from '../jsutils/Maybe'; -import { naturalCompare } from '../jsutils/naturalCompare'; -import type { ObjMap } from '../jsutils/ObjMap'; - -import type { - GraphQLFieldConfigArgumentMap, - GraphQLFieldConfigMap, - GraphQLInputFieldConfigMap, - GraphQLNamedType, - GraphQLType, -} from '../type/definition'; -import { - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLUnionType, - isEnumType, - isInputObjectType, - isInterfaceType, - isListType, - isNonNullType, - isObjectType, - isScalarType, - isUnionType, -} from '../type/definition'; -import { GraphQLDirective } from '../type/directives'; -import { isIntrospectionType } from '../type/introspection'; -import { GraphQLSchema } from '../type/schema'; - -/** - * Sort GraphQLSchema. - * - * This function returns a sorted copy of the given GraphQLSchema. - */ -export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema { - const schemaConfig = schema.toConfig(); - const typeMap = keyValMap( - sortByName(schemaConfig.types), - (type) => type.name, - sortNamedType, - ); - - return new GraphQLSchema({ - ...schemaConfig, - types: Object.values(typeMap), - directives: sortByName(schemaConfig.directives).map(sortDirective), - query: replaceMaybeType(schemaConfig.query), - mutation: replaceMaybeType(schemaConfig.mutation), - subscription: replaceMaybeType(schemaConfig.subscription), - }); - - function replaceType(type: T): T { - if (isListType(type)) { - // @ts-expect-error - return new GraphQLList(replaceType(type.ofType)); - } else if (isNonNullType(type)) { - // @ts-expect-error - return new GraphQLNonNull(replaceType(type.ofType)); - } - // @ts-expect-error FIXME: TS Conversion - return replaceNamedType(type); - } - - function replaceNamedType(type: T): T { - return typeMap[type.name] as T; - } - - function replaceMaybeType( - maybeType: Maybe, - ): Maybe { - return maybeType && replaceNamedType(maybeType); - } - - function sortDirective(directive: GraphQLDirective) { - const config = directive.toConfig(); - return new GraphQLDirective({ - ...config, - locations: sortBy(config.locations, (x) => x), - args: sortArgs(config.args), - }); - } - - function sortArgs(args: GraphQLFieldConfigArgumentMap) { - return sortObjMap(args, (arg) => ({ - ...arg, - type: replaceType(arg.type), - })); - } - - function sortFields(fieldsMap: GraphQLFieldConfigMap) { - return sortObjMap(fieldsMap, (field) => ({ - ...field, - type: replaceType(field.type), - args: field.args && sortArgs(field.args), - })); - } - - function sortInputFields(fieldsMap: GraphQLInputFieldConfigMap) { - return sortObjMap(fieldsMap, (field) => ({ - ...field, - type: replaceType(field.type), - })); - } - - function sortTypes( - array: ReadonlyArray, - ): Array { - return sortByName(array).map(replaceNamedType); - } - - function sortNamedType(type: GraphQLNamedType): GraphQLNamedType { - if (isScalarType(type) || isIntrospectionType(type)) { - return type; - } - if (isObjectType(type)) { - const config = type.toConfig(); - return new GraphQLObjectType({ - ...config, - interfaces: () => sortTypes(config.interfaces), - fields: () => sortFields(config.fields), - }); - } - if (isInterfaceType(type)) { - const config = type.toConfig(); - return new GraphQLInterfaceType({ - ...config, - interfaces: () => sortTypes(config.interfaces), - fields: () => sortFields(config.fields), - }); - } - if (isUnionType(type)) { - const config = type.toConfig(); - return new GraphQLUnionType({ - ...config, - types: () => sortTypes(config.types), - }); - } - if (isEnumType(type)) { - const config = type.toConfig(); - return new GraphQLEnumType({ - ...config, - values: sortObjMap(config.values, (value) => value), - }); - } - if (isInputObjectType(type)) { - const config = type.toConfig(); - return new GraphQLInputObjectType({ - ...config, - fields: () => sortInputFields(config.fields), - }); - } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - invariant(false, 'Unexpected type: ' + inspect(type)); - } -} - -function sortObjMap( - map: ObjMap, - sortValueFn: (value: T) => R, -): ObjMap { - const sortedMap = Object.create(null); - for (const key of Object.keys(map).sort(naturalCompare)) { - sortedMap[key] = sortValueFn(map[key]); - } - return sortedMap; -} - -function sortByName( - array: ReadonlyArray, -): Array { - return sortBy(array, (obj) => obj.name); -} - -function sortBy( - array: ReadonlyArray, - mapToKey: (item: T) => string, -): Array { - return array.slice().sort((obj1, obj2) => { - const key1 = mapToKey(obj1); - const key2 = mapToKey(obj2); - return naturalCompare(key1, key2); - }); -} diff --git a/src/utilities/printSchema.ts b/src/utilities/printSchema.ts deleted file mode 100644 index edac6262c5..0000000000 --- a/src/utilities/printSchema.ts +++ /dev/null @@ -1,331 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import type { Maybe } from '../jsutils/Maybe'; - -import { isPrintableAsBlockString } from '../language/blockString'; -import { Kind } from '../language/kinds'; -import { print } from '../language/printer'; - -import type { - GraphQLArgument, - GraphQLEnumType, - GraphQLInputField, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLNamedType, - GraphQLObjectType, - GraphQLScalarType, - GraphQLUnionType, -} from '../type/definition'; -import { - isEnumType, - isInputObjectType, - isInterfaceType, - isObjectType, - isScalarType, - isUnionType, -} from '../type/definition'; -import type { GraphQLDirective } from '../type/directives'; -import { - DEFAULT_DEPRECATION_REASON, - isSpecifiedDirective, -} from '../type/directives'; -import { isIntrospectionType } from '../type/introspection'; -import { isSpecifiedScalarType } from '../type/scalars'; -import type { GraphQLSchema } from '../type/schema'; - -import { astFromValue } from './astFromValue'; - -export function printSchema(schema: GraphQLSchema): string { - return printFilteredSchema( - schema, - (n) => !isSpecifiedDirective(n), - isDefinedType, - ); -} - -export function printIntrospectionSchema(schema: GraphQLSchema): string { - return printFilteredSchema(schema, isSpecifiedDirective, isIntrospectionType); -} - -function isDefinedType(type: GraphQLNamedType): boolean { - return !isSpecifiedScalarType(type) && !isIntrospectionType(type); -} - -function printFilteredSchema( - schema: GraphQLSchema, - directiveFilter: (type: GraphQLDirective) => boolean, - typeFilter: (type: GraphQLNamedType) => boolean, -): string { - const directives = schema.getDirectives().filter(directiveFilter); - const types = Object.values(schema.getTypeMap()).filter(typeFilter); - - return [ - printSchemaDefinition(schema), - ...directives.map((directive) => printDirective(directive)), - ...types.map((type) => printType(type)), - ] - .filter(Boolean) - .join('\n\n'); -} - -function printSchemaDefinition(schema: GraphQLSchema): Maybe { - if (schema.description == null && isSchemaOfCommonNames(schema)) { - return; - } - - const operationTypes = []; - - const queryType = schema.getQueryType(); - if (queryType) { - operationTypes.push(` query: ${queryType.name}`); - } - - const mutationType = schema.getMutationType(); - if (mutationType) { - operationTypes.push(` mutation: ${mutationType.name}`); - } - - const subscriptionType = schema.getSubscriptionType(); - if (subscriptionType) { - operationTypes.push(` subscription: ${subscriptionType.name}`); - } - - return printDescription(schema) + `schema {\n${operationTypes.join('\n')}\n}`; -} - -/** - * GraphQL schema define root types for each type of operation. These types are - * the same as any other type and can be named in any manner, however there is - * a common naming convention: - * - * ```graphql - * schema { - * query: Query - * mutation: Mutation - * subscription: Subscription - * } - * ``` - * - * When using this naming convention, the schema description can be omitted. - */ -function isSchemaOfCommonNames(schema: GraphQLSchema): boolean { - const queryType = schema.getQueryType(); - if (queryType && queryType.name !== 'Query') { - return false; - } - - const mutationType = schema.getMutationType(); - if (mutationType && mutationType.name !== 'Mutation') { - return false; - } - - const subscriptionType = schema.getSubscriptionType(); - if (subscriptionType && subscriptionType.name !== 'Subscription') { - return false; - } - - return true; -} - -export function printType(type: GraphQLNamedType): string { - if (isScalarType(type)) { - return printScalar(type); - } - if (isObjectType(type)) { - return printObject(type); - } - if (isInterfaceType(type)) { - return printInterface(type); - } - if (isUnionType(type)) { - return printUnion(type); - } - if (isEnumType(type)) { - return printEnum(type); - } - if (isInputObjectType(type)) { - return printInputObject(type); - } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - invariant(false, 'Unexpected type: ' + inspect(type)); -} - -function printScalar(type: GraphQLScalarType): string { - return ( - printDescription(type) + `scalar ${type.name}` + printSpecifiedByURL(type) - ); -} - -function printImplementedInterfaces( - type: GraphQLObjectType | GraphQLInterfaceType, -): string { - const interfaces = type.getInterfaces(); - return interfaces.length - ? ' implements ' + interfaces.map((i) => i.name).join(' & ') - : ''; -} - -function printObject(type: GraphQLObjectType): string { - return ( - printDescription(type) + - `type ${type.name}` + - printImplementedInterfaces(type) + - printFields(type) - ); -} - -function printInterface(type: GraphQLInterfaceType): string { - return ( - printDescription(type) + - `interface ${type.name}` + - printImplementedInterfaces(type) + - printFields(type) - ); -} - -function printUnion(type: GraphQLUnionType): string { - const types = type.getTypes(); - const possibleTypes = types.length ? ' = ' + types.join(' | ') : ''; - return printDescription(type) + 'union ' + type.name + possibleTypes; -} - -function printEnum(type: GraphQLEnumType): string { - const values = type - .getValues() - .map( - (value, i) => - printDescription(value, ' ', !i) + - ' ' + - value.name + - printDeprecated(value.deprecationReason), - ); - - return printDescription(type) + `enum ${type.name}` + printBlock(values); -} - -function printInputObject(type: GraphQLInputObjectType): string { - const fields = Object.values(type.getFields()).map( - (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f), - ); - return ( - printDescription(type) + - `input ${type.name}` + - (type.isOneOf ? ' @oneOf' : '') + - printBlock(fields) - ); -} - -function printFields(type: GraphQLObjectType | GraphQLInterfaceType): string { - const fields = Object.values(type.getFields()).map( - (f, i) => - printDescription(f, ' ', !i) + - ' ' + - f.name + - printArgs(f.args, ' ') + - ': ' + - String(f.type) + - printDeprecated(f.deprecationReason), - ); - return printBlock(fields); -} - -function printBlock(items: ReadonlyArray): string { - return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : ''; -} - -function printArgs( - args: ReadonlyArray, - indentation: string = '', -): string { - if (args.length === 0) { - return ''; - } - - // If every arg does not have a description, print them on one line. - if (args.every((arg) => !arg.description)) { - return '(' + args.map(printInputValue).join(', ') + ')'; - } - - return ( - '(\n' + - args - .map( - (arg, i) => - printDescription(arg, ' ' + indentation, !i) + - ' ' + - indentation + - printInputValue(arg), - ) - .join('\n') + - '\n' + - indentation + - ')' - ); -} - -function printInputValue(arg: GraphQLInputField): string { - const defaultAST = astFromValue(arg.defaultValue, arg.type); - let argDecl = arg.name + ': ' + String(arg.type); - if (defaultAST) { - argDecl += ` = ${print(defaultAST)}`; - } - return argDecl + printDeprecated(arg.deprecationReason); -} - -function printDirective(directive: GraphQLDirective): string { - return ( - printDescription(directive) + - 'directive @' + - directive.name + - printArgs(directive.args) + - (directive.isRepeatable ? ' repeatable' : '') + - ' on ' + - directive.locations.join(' | ') - ); -} - -function printDeprecated(reason: Maybe): string { - if (reason == null) { - return ''; - } - if (reason !== DEFAULT_DEPRECATION_REASON) { - const astValue = print({ kind: Kind.STRING, value: reason }); - return ` @deprecated(reason: ${astValue})`; - } - return ' @deprecated'; -} - -function printSpecifiedByURL(scalar: GraphQLScalarType): string { - if (scalar.specifiedByURL == null) { - return ''; - } - const astValue = print({ - kind: Kind.STRING, - value: scalar.specifiedByURL, - }); - return ` @specifiedBy(url: ${astValue})`; -} - -function printDescription( - def: { readonly description: Maybe }, - indentation: string = '', - firstInBlock: boolean = true, -): string { - const { description } = def; - if (description == null) { - return ''; - } - - const blockString = print({ - kind: Kind.STRING, - value: description, - block: isPrintableAsBlockString(description), - }); - - const prefix = - indentation && !firstInBlock ? '\n' + indentation : indentation; - - return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n'; -} diff --git a/src/utilities/separateOperations.ts b/src/utilities/separateOperations.ts deleted file mode 100644 index 84a8b774f9..0000000000 --- a/src/utilities/separateOperations.ts +++ /dev/null @@ -1,98 +0,0 @@ -import type { ObjMap } from '../jsutils/ObjMap'; - -import type { - DocumentNode, - OperationDefinitionNode, - SelectionSetNode, -} from '../language/ast'; -import { Kind } from '../language/kinds'; -import { visit } from '../language/visitor'; - -/** - * separateOperations accepts a single AST document which may contain many - * operations and fragments and returns a collection of AST documents each of - * which contains a single operation as well the fragment definitions it - * refers to. - */ -export function separateOperations( - documentAST: DocumentNode, -): ObjMap { - const operations: Array = []; - const depGraph: DepGraph = Object.create(null); - - // Populate metadata and build a dependency graph. - for (const definitionNode of documentAST.definitions) { - switch (definitionNode.kind) { - case Kind.OPERATION_DEFINITION: - operations.push(definitionNode); - break; - case Kind.FRAGMENT_DEFINITION: - depGraph[definitionNode.name.value] = collectDependencies( - definitionNode.selectionSet, - ); - break; - default: - // ignore non-executable definitions - } - } - - // For each operation, produce a new synthesized AST which includes only what - // is necessary for completing that operation. - const separatedDocumentASTs = Object.create(null); - for (const operation of operations) { - const dependencies = new Set(); - - for (const fragmentName of collectDependencies(operation.selectionSet)) { - collectTransitiveDependencies(dependencies, depGraph, fragmentName); - } - - // Provides the empty string for anonymous operations. - const operationName = operation.name ? operation.name.value : ''; - - // The list of definition nodes to be included for this operation, sorted - // to retain the same order as the original document. - separatedDocumentASTs[operationName] = { - kind: Kind.DOCUMENT, - definitions: documentAST.definitions.filter( - (node) => - node === operation || - (node.kind === Kind.FRAGMENT_DEFINITION && - dependencies.has(node.name.value)), - ), - }; - } - - return separatedDocumentASTs; -} - -type DepGraph = ObjMap>; - -// From a dependency graph, collects a list of transitive dependencies by -// recursing through a dependency graph. -function collectTransitiveDependencies( - collected: Set, - depGraph: DepGraph, - fromName: string, -): void { - if (!collected.has(fromName)) { - collected.add(fromName); - - const immediateDeps = depGraph[fromName]; - if (immediateDeps !== undefined) { - for (const toName of immediateDeps) { - collectTransitiveDependencies(collected, depGraph, toName); - } - } - } -} - -function collectDependencies(selectionSet: SelectionSetNode): Array { - const dependencies: Array = []; - - visit(selectionSet, { - FragmentSpread(node) { - dependencies.push(node.name.value); - }, - }); - return dependencies; -} diff --git a/src/utilities/sortValueNode.ts b/src/utilities/sortValueNode.ts deleted file mode 100644 index 6050c9a907..0000000000 --- a/src/utilities/sortValueNode.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { naturalCompare } from '../jsutils/naturalCompare'; - -import type { ObjectFieldNode, ValueNode } from '../language/ast'; -import { Kind } from '../language/kinds'; - -/** - * Sort ValueNode. - * - * This function returns a sorted copy of the given ValueNode. - * - * @internal - */ -export function sortValueNode(valueNode: ValueNode): ValueNode { - switch (valueNode.kind) { - case Kind.OBJECT: - return { - ...valueNode, - fields: sortFields(valueNode.fields), - }; - case Kind.LIST: - return { - ...valueNode, - values: valueNode.values.map(sortValueNode), - }; - case Kind.INT: - case Kind.FLOAT: - case Kind.STRING: - case Kind.BOOLEAN: - case Kind.NULL: - case Kind.ENUM: - case Kind.VARIABLE: - return valueNode; - } -} - -function sortFields( - fields: ReadonlyArray, -): Array { - return fields - .map((fieldNode) => ({ - ...fieldNode, - value: sortValueNode(fieldNode.value), - })) - .sort((fieldA, fieldB) => - naturalCompare(fieldA.name.value, fieldB.name.value), - ); -} diff --git a/src/utilities/stripIgnoredCharacters.ts b/src/utilities/stripIgnoredCharacters.ts deleted file mode 100644 index 5eb5c9800c..0000000000 --- a/src/utilities/stripIgnoredCharacters.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { printBlockString } from '../language/blockString'; -import { isPunctuatorTokenKind, Lexer } from '../language/lexer'; -import { isSource, Source } from '../language/source'; -import { TokenKind } from '../language/tokenKind'; - -/** - * Strips characters that are not significant to the validity or execution - * of a GraphQL document: - * - UnicodeBOM - * - WhiteSpace - * - LineTerminator - * - Comment - * - Comma - * - BlockString indentation - * - * Note: It is required to have a delimiter character between neighboring - * non-punctuator tokens and this function always uses single space as delimiter. - * - * It is guaranteed that both input and output documents if parsed would result - * in the exact same AST except for nodes location. - * - * Warning: It is guaranteed that this function will always produce stable results. - * However, it's not guaranteed that it will stay the same between different - * releases due to bugfixes or changes in the GraphQL specification. - * - * Query example: - * - * ```graphql - * query SomeQuery($foo: String!, $bar: String) { - * someField(foo: $foo, bar: $bar) { - * a - * b { - * c - * d - * } - * } - * } - * ``` - * - * Becomes: - * - * ```graphql - * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} - * ``` - * - * SDL example: - * - * ```graphql - * """ - * Type description - * """ - * type Foo { - * """ - * Field description - * """ - * bar: String - * } - * ``` - * - * Becomes: - * - * ```graphql - * """Type description""" type Foo{"""Field description""" bar:String} - * ``` - */ -export function stripIgnoredCharacters(source: string | Source): string { - const sourceObj = isSource(source) ? source : new Source(source); - - const body = sourceObj.body; - const lexer = new Lexer(sourceObj); - let strippedBody = ''; - - let wasLastAddedTokenNonPunctuator = false; - while (lexer.advance().kind !== TokenKind.EOF) { - const currentToken = lexer.token; - const tokenKind = currentToken.kind; - - /** - * Every two non-punctuator tokens should have space between them. - * Also prevent case of non-punctuator token following by spread resulting - * in invalid token (e.g. `1...` is invalid Float token). - */ - const isNonPunctuator = !isPunctuatorTokenKind(currentToken.kind); - if (wasLastAddedTokenNonPunctuator) { - if (isNonPunctuator || currentToken.kind === TokenKind.SPREAD) { - strippedBody += ' '; - } - } - - const tokenBody = body.slice(currentToken.start, currentToken.end); - if (tokenKind === TokenKind.BLOCK_STRING) { - strippedBody += printBlockString(currentToken.value, { minimize: true }); - } else { - strippedBody += tokenBody; - } - - wasLastAddedTokenNonPunctuator = isNonPunctuator; - } - - return strippedBody; -} diff --git a/src/utilities/typeComparators.ts b/src/utilities/typeComparators.ts deleted file mode 100644 index 287be40bfe..0000000000 --- a/src/utilities/typeComparators.ts +++ /dev/null @@ -1,119 +0,0 @@ -import type { GraphQLCompositeType, GraphQLType } from '../type/definition'; -import { - isAbstractType, - isInterfaceType, - isListType, - isNonNullType, - isObjectType, -} from '../type/definition'; -import type { GraphQLSchema } from '../type/schema'; - -/** - * Provided two types, return true if the types are equal (invariant). - */ -export function isEqualType(typeA: GraphQLType, typeB: GraphQLType): boolean { - // Equivalent types are equal. - if (typeA === typeB) { - return true; - } - - // If either type is non-null, the other must also be non-null. - if (isNonNullType(typeA) && isNonNullType(typeB)) { - return isEqualType(typeA.ofType, typeB.ofType); - } - - // If either type is a list, the other must also be a list. - if (isListType(typeA) && isListType(typeB)) { - return isEqualType(typeA.ofType, typeB.ofType); - } - - // Otherwise the types are not equal. - return false; -} - -/** - * Provided a type and a super type, return true if the first type is either - * equal or a subset of the second super type (covariant). - */ -export function isTypeSubTypeOf( - schema: GraphQLSchema, - maybeSubType: GraphQLType, - superType: GraphQLType, -): boolean { - // Equivalent type is a valid subtype - if (maybeSubType === superType) { - return true; - } - - // If superType is non-null, maybeSubType must also be non-null. - if (isNonNullType(superType)) { - if (isNonNullType(maybeSubType)) { - return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); - } - return false; - } - if (isNonNullType(maybeSubType)) { - // If superType is nullable, maybeSubType may be non-null or nullable. - return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); - } - - // If superType type is a list, maybeSubType type must also be a list. - if (isListType(superType)) { - if (isListType(maybeSubType)) { - return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); - } - return false; - } - if (isListType(maybeSubType)) { - // If superType is not a list, maybeSubType must also be not a list. - return false; - } - - // If superType type is an abstract type, check if it is super type of maybeSubType. - // Otherwise, the child type is not a valid subtype of the parent type. - return ( - isAbstractType(superType) && - (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) && - schema.isSubType(superType, maybeSubType) - ); -} - -/** - * Provided two composite types, determine if they "overlap". Two composite - * types overlap when the Sets of possible concrete types for each intersect. - * - * This is often used to determine if a fragment of a given type could possibly - * be visited in a context of another type. - * - * This function is commutative. - */ -export function doTypesOverlap( - schema: GraphQLSchema, - typeA: GraphQLCompositeType, - typeB: GraphQLCompositeType, -): boolean { - // Equivalent types overlap - if (typeA === typeB) { - return true; - } - - if (isAbstractType(typeA)) { - if (isAbstractType(typeB)) { - // If both types are abstract, then determine if there is any intersection - // between possible concrete types of each. - return schema - .getPossibleTypes(typeA) - .some((type) => schema.isSubType(typeB, type)); - } - // Determine if the latter type is a possible concrete type of the former. - return schema.isSubType(typeA, typeB); - } - - if (isAbstractType(typeB)) { - // Determine if the former type is a possible concrete type of the latter. - return schema.isSubType(typeB, typeA); - } - - // Otherwise the types do not overlap. - return false; -} diff --git a/src/utilities/typeFromAST.ts b/src/utilities/typeFromAST.ts deleted file mode 100644 index 7510df1046..0000000000 --- a/src/utilities/typeFromAST.ts +++ /dev/null @@ -1,52 +0,0 @@ -import type { - ListTypeNode, - NamedTypeNode, - NonNullTypeNode, - TypeNode, -} from '../language/ast'; -import { Kind } from '../language/kinds'; - -import type { GraphQLNamedType, GraphQLType } from '../type/definition'; -import { GraphQLList, GraphQLNonNull } from '../type/definition'; -import type { GraphQLSchema } from '../type/schema'; - -/** - * Given a Schema and an AST node describing a type, return a GraphQLType - * definition which applies to that type. For example, if provided the parsed - * AST node for `[User]`, a GraphQLList instance will be returned, containing - * the type called "User" found in the schema. If a type called "User" is not - * found in the schema, then undefined will be returned. - */ -export function typeFromAST( - schema: GraphQLSchema, - typeNode: NamedTypeNode, -): GraphQLNamedType | undefined; -export function typeFromAST( - schema: GraphQLSchema, - typeNode: ListTypeNode, -): GraphQLList | undefined; -export function typeFromAST( - schema: GraphQLSchema, - typeNode: NonNullTypeNode, -): GraphQLNonNull | undefined; -export function typeFromAST( - schema: GraphQLSchema, - typeNode: TypeNode, -): GraphQLType | undefined; -export function typeFromAST( - schema: GraphQLSchema, - typeNode: TypeNode, -): GraphQLType | undefined { - switch (typeNode.kind) { - case Kind.LIST_TYPE: { - const innerType = typeFromAST(schema, typeNode.type); - return innerType && new GraphQLList(innerType); - } - case Kind.NON_NULL_TYPE: { - const innerType = typeFromAST(schema, typeNode.type); - return innerType && new GraphQLNonNull(innerType); - } - case Kind.NAMED_TYPE: - return schema.getType(typeNode.name.value); - } -} diff --git a/src/utilities/typedQueryDocumentNode.ts b/src/utilities/typedQueryDocumentNode.ts deleted file mode 100644 index 1bd5cf0825..0000000000 --- a/src/utilities/typedQueryDocumentNode.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { DocumentNode, ExecutableDefinitionNode } from '../language/ast'; -/** - * Wrapper type that contains DocumentNode and types that can be deduced from it. - */ -export interface TypedQueryDocumentNode< - TResponseData = { [key: string]: any }, - TRequestVariables = { [key: string]: any }, -> extends DocumentNode { - readonly definitions: ReadonlyArray; - // FIXME: remove once TS implements proper way to enforce nominal typing - /** - * This type is used to ensure that the variables you pass in to the query are assignable to Variables - * and that the Result is assignable to whatever you pass your result to. The method is never actually - * implemented, but the type is valid because we list it as optional - */ - __ensureTypesOfVariablesAndResultMatching?: ( - variables: TRequestVariables, - ) => TResponseData; -} diff --git a/src/utilities/valueFromAST.ts b/src/utilities/valueFromAST.ts deleted file mode 100644 index 2e6cc1c613..0000000000 --- a/src/utilities/valueFromAST.ts +++ /dev/null @@ -1,173 +0,0 @@ -import { inspect } from '../jsutils/inspect'; -import { invariant } from '../jsutils/invariant'; -import { keyMap } from '../jsutils/keyMap'; -import type { Maybe } from '../jsutils/Maybe'; -import type { ObjMap } from '../jsutils/ObjMap'; - -import type { ValueNode } from '../language/ast'; -import { Kind } from '../language/kinds'; - -import type { GraphQLInputType } from '../type/definition'; -import { - isInputObjectType, - isLeafType, - isListType, - isNonNullType, -} from '../type/definition'; - -/** - * Produces a JavaScript value given a GraphQL Value AST. - * - * A GraphQL type must be provided, which will be used to interpret different - * GraphQL Value literals. - * - * Returns `undefined` when the value could not be validly coerced according to - * the provided type. - * - * | GraphQL Value | JSON Value | - * | -------------------- | ------------- | - * | Input Object | Object | - * | List | Array | - * | Boolean | Boolean | - * | String | String | - * | Int / Float | Number | - * | Enum Value | Unknown | - * | NullValue | null | - * - */ -export function valueFromAST( - valueNode: Maybe, - type: GraphQLInputType, - variables?: Maybe>, -): unknown { - if (!valueNode) { - // When there is no node, then there is also no value. - // Importantly, this is different from returning the value null. - return; - } - - if (valueNode.kind === Kind.VARIABLE) { - const variableName = valueNode.name.value; - if (variables == null || variables[variableName] === undefined) { - // No valid return value. - return; - } - const variableValue = variables[variableName]; - if (variableValue === null && isNonNullType(type)) { - return; // Invalid: intentionally return no value. - } - // Note: This does no further checking that this variable is correct. - // This assumes that this query has been validated and the variable - // usage here is of the correct type. - return variableValue; - } - - if (isNonNullType(type)) { - if (valueNode.kind === Kind.NULL) { - return; // Invalid: intentionally return no value. - } - return valueFromAST(valueNode, type.ofType, variables); - } - - if (valueNode.kind === Kind.NULL) { - // This is explicitly returning the value null. - return null; - } - - if (isListType(type)) { - const itemType = type.ofType; - if (valueNode.kind === Kind.LIST) { - const coercedValues = []; - for (const itemNode of valueNode.values) { - if (isMissingVariable(itemNode, variables)) { - // If an array contains a missing variable, it is either coerced to - // null or if the item type is non-null, it considered invalid. - if (isNonNullType(itemType)) { - return; // Invalid: intentionally return no value. - } - coercedValues.push(null); - } else { - const itemValue = valueFromAST(itemNode, itemType, variables); - if (itemValue === undefined) { - return; // Invalid: intentionally return no value. - } - coercedValues.push(itemValue); - } - } - return coercedValues; - } - const coercedValue = valueFromAST(valueNode, itemType, variables); - if (coercedValue === undefined) { - return; // Invalid: intentionally return no value. - } - return [coercedValue]; - } - - if (isInputObjectType(type)) { - if (valueNode.kind !== Kind.OBJECT) { - return; // Invalid: intentionally return no value. - } - const coercedObj = Object.create(null); - const fieldNodes = keyMap(valueNode.fields, (field) => field.name.value); - for (const field of Object.values(type.getFields())) { - const fieldNode = fieldNodes[field.name]; - if (!fieldNode || isMissingVariable(fieldNode.value, variables)) { - if (field.defaultValue !== undefined) { - coercedObj[field.name] = field.defaultValue; - } else if (isNonNullType(field.type)) { - return; // Invalid: intentionally return no value. - } - continue; - } - const fieldValue = valueFromAST(fieldNode.value, field.type, variables); - if (fieldValue === undefined) { - return; // Invalid: intentionally return no value. - } - coercedObj[field.name] = fieldValue; - } - - if (type.isOneOf) { - const keys = Object.keys(coercedObj); - if (keys.length !== 1) { - return; // Invalid: not exactly one key, intentionally return no value. - } - - if (coercedObj[keys[0]] === null) { - return; // Invalid: value not non-null, intentionally return no value. - } - } - - return coercedObj; - } - - if (isLeafType(type)) { - // Scalars and Enums fulfill parsing a literal value via parseLiteral(). - // Invalid values represent a failure to parse correctly, in which case - // no value is returned. - let result; - try { - result = type.parseLiteral(valueNode, variables); - } catch (_error) { - return; // Invalid: intentionally return no value. - } - if (result === undefined) { - return; // Invalid: intentionally return no value. - } - return result; - } - /* c8 ignore next 3 */ - // Not reachable, all possible input types have been considered. - invariant(false, 'Unexpected input type: ' + inspect(type)); -} - -// Returns true if the provided valueNode is a variable which is not defined -// in the set of variables. -function isMissingVariable( - valueNode: ValueNode, - variables: Maybe>, -): boolean { - return ( - valueNode.kind === Kind.VARIABLE && - (variables == null || variables[valueNode.name.value] === undefined) - ); -} diff --git a/src/utilities/valueFromASTUntyped.ts b/src/utilities/valueFromASTUntyped.ts deleted file mode 100644 index 05540da3a4..0000000000 --- a/src/utilities/valueFromASTUntyped.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { keyValMap } from '../jsutils/keyValMap'; -import type { Maybe } from '../jsutils/Maybe'; -import type { ObjMap } from '../jsutils/ObjMap'; - -import type { ValueNode } from '../language/ast'; -import { Kind } from '../language/kinds'; - -/** - * Produces a JavaScript value given a GraphQL Value AST. - * - * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value - * will reflect the provided GraphQL value AST. - * - * | GraphQL Value | JavaScript Value | - * | -------------------- | ---------------- | - * | Input Object | Object | - * | List | Array | - * | Boolean | Boolean | - * | String / Enum | String | - * | Int / Float | Number | - * | Null | null | - * - */ -export function valueFromASTUntyped( - valueNode: ValueNode, - variables?: Maybe>, -): unknown { - switch (valueNode.kind) { - case Kind.NULL: - return null; - case Kind.INT: - return parseInt(valueNode.value, 10); - case Kind.FLOAT: - return parseFloat(valueNode.value); - case Kind.STRING: - case Kind.ENUM: - case Kind.BOOLEAN: - return valueNode.value; - case Kind.LIST: - return valueNode.values.map((node) => - valueFromASTUntyped(node, variables), - ); - case Kind.OBJECT: - return keyValMap( - valueNode.fields, - (field) => field.name.value, - (field) => valueFromASTUntyped(field.value, variables), - ); - case Kind.VARIABLE: - return variables?.[valueNode.name.value]; - } -} diff --git a/src/validation/README.md b/src/validation/README.md deleted file mode 100644 index 8a4a1c85f0..0000000000 --- a/src/validation/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## GraphQL Validation - -The `graphql/validation` module fulfills the Validation phase of fulfilling a -GraphQL result. - -```js -import { validate } from 'graphql/validation'; // ES6 -var GraphQLValidator = require('graphql/validation'); // CommonJS -``` diff --git a/src/validation/ValidationContext.ts b/src/validation/ValidationContext.ts deleted file mode 100644 index 7884031c9d..0000000000 --- a/src/validation/ValidationContext.ts +++ /dev/null @@ -1,271 +0,0 @@ -import type { Maybe } from '../jsutils/Maybe'; -import type { ObjMap } from '../jsutils/ObjMap'; - -import type { GraphQLError } from '../error/GraphQLError'; - -import type { - DocumentNode, - FragmentDefinitionNode, - FragmentSpreadNode, - OperationDefinitionNode, - SelectionSetNode, - VariableNode, -} from '../language/ast'; -import { Kind } from '../language/kinds'; -import type { ASTVisitor } from '../language/visitor'; -import { visit } from '../language/visitor'; - -import type { - GraphQLArgument, - GraphQLCompositeType, - GraphQLEnumValue, - GraphQLField, - GraphQLInputType, - GraphQLOutputType, -} from '../type/definition'; -import type { GraphQLDirective } from '../type/directives'; -import type { GraphQLSchema } from '../type/schema'; - -import { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo'; - -type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode; -interface VariableUsage { - readonly node: VariableNode; - readonly type: Maybe; - readonly defaultValue: Maybe; - readonly parentType: Maybe; -} - -/** - * An instance of this class is passed as the "this" context to all validators, - * allowing access to commonly useful contextual information from within a - * validation rule. - */ -export class ASTValidationContext { - private _ast: DocumentNode; - private _onError: (error: GraphQLError) => void; - private _fragments: ObjMap | undefined; - private _fragmentSpreads: Map>; - private _recursivelyReferencedFragments: Map< - OperationDefinitionNode, - Array - >; - - constructor(ast: DocumentNode, onError: (error: GraphQLError) => void) { - this._ast = ast; - this._fragments = undefined; - this._fragmentSpreads = new Map(); - this._recursivelyReferencedFragments = new Map(); - this._onError = onError; - } - - get [Symbol.toStringTag]() { - return 'ASTValidationContext'; - } - - reportError(error: GraphQLError): void { - this._onError(error); - } - - getDocument(): DocumentNode { - return this._ast; - } - - getFragment(name: string): Maybe { - let fragments: ObjMap; - if (this._fragments) { - fragments = this._fragments; - } else { - fragments = Object.create(null); - for (const defNode of this.getDocument().definitions) { - if (defNode.kind === Kind.FRAGMENT_DEFINITION) { - fragments[defNode.name.value] = defNode; - } - } - this._fragments = fragments; - } - return fragments[name]; - } - - getFragmentSpreads( - node: SelectionSetNode, - ): ReadonlyArray { - let spreads = this._fragmentSpreads.get(node); - if (!spreads) { - spreads = []; - const setsToVisit: Array = [node]; - let set: SelectionSetNode | undefined; - while ((set = setsToVisit.pop())) { - for (const selection of set.selections) { - if (selection.kind === Kind.FRAGMENT_SPREAD) { - spreads.push(selection); - } else if (selection.selectionSet) { - setsToVisit.push(selection.selectionSet); - } - } - } - this._fragmentSpreads.set(node, spreads); - } - return spreads; - } - - getRecursivelyReferencedFragments( - operation: OperationDefinitionNode, - ): ReadonlyArray { - let fragments = this._recursivelyReferencedFragments.get(operation); - if (!fragments) { - fragments = []; - const collectedNames = Object.create(null); - const nodesToVisit: Array = [operation.selectionSet]; - let node: SelectionSetNode | undefined; - while ((node = nodesToVisit.pop())) { - for (const spread of this.getFragmentSpreads(node)) { - const fragName = spread.name.value; - if (collectedNames[fragName] !== true) { - collectedNames[fragName] = true; - const fragment = this.getFragment(fragName); - if (fragment) { - fragments.push(fragment); - nodesToVisit.push(fragment.selectionSet); - } - } - } - } - this._recursivelyReferencedFragments.set(operation, fragments); - } - return fragments; - } -} - -export type ASTValidationRule = (context: ASTValidationContext) => ASTVisitor; - -export class SDLValidationContext extends ASTValidationContext { - private _schema: Maybe; - - constructor( - ast: DocumentNode, - schema: Maybe, - onError: (error: GraphQLError) => void, - ) { - super(ast, onError); - this._schema = schema; - } - - get [Symbol.toStringTag]() { - return 'SDLValidationContext'; - } - - getSchema(): Maybe { - return this._schema; - } -} - -export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor; - -export class ValidationContext extends ASTValidationContext { - private _schema: GraphQLSchema; - private _typeInfo: TypeInfo; - private _variableUsages: Map< - NodeWithSelectionSet, - ReadonlyArray - >; - - private _recursiveVariableUsages: Map< - OperationDefinitionNode, - ReadonlyArray - >; - - constructor( - schema: GraphQLSchema, - ast: DocumentNode, - typeInfo: TypeInfo, - onError: (error: GraphQLError) => void, - ) { - super(ast, onError); - this._schema = schema; - this._typeInfo = typeInfo; - this._variableUsages = new Map(); - this._recursiveVariableUsages = new Map(); - } - - get [Symbol.toStringTag]() { - return 'ValidationContext'; - } - - getSchema(): GraphQLSchema { - return this._schema; - } - - getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray { - let usages = this._variableUsages.get(node); - if (!usages) { - const newUsages: Array = []; - const typeInfo = new TypeInfo(this._schema); - visit( - node, - visitWithTypeInfo(typeInfo, { - VariableDefinition: () => false, - Variable(variable) { - newUsages.push({ - node: variable, - type: typeInfo.getInputType(), - defaultValue: typeInfo.getDefaultValue(), - parentType: typeInfo.getParentInputType(), - }); - }, - }), - ); - usages = newUsages; - this._variableUsages.set(node, usages); - } - return usages; - } - - getRecursiveVariableUsages( - operation: OperationDefinitionNode, - ): ReadonlyArray { - let usages = this._recursiveVariableUsages.get(operation); - if (!usages) { - usages = this.getVariableUsages(operation); - for (const frag of this.getRecursivelyReferencedFragments(operation)) { - usages = usages.concat(this.getVariableUsages(frag)); - } - this._recursiveVariableUsages.set(operation, usages); - } - return usages; - } - - getType(): Maybe { - return this._typeInfo.getType(); - } - - getParentType(): Maybe { - return this._typeInfo.getParentType(); - } - - getInputType(): Maybe { - return this._typeInfo.getInputType(); - } - - getParentInputType(): Maybe { - return this._typeInfo.getParentInputType(); - } - - getFieldDef(): Maybe> { - return this._typeInfo.getFieldDef(); - } - - getDirective(): Maybe { - return this._typeInfo.getDirective(); - } - - getArgument(): Maybe { - return this._typeInfo.getArgument(); - } - - getEnumValue(): Maybe { - return this._typeInfo.getEnumValue(); - } -} - -export type ValidationRule = (context: ValidationContext) => ASTVisitor; diff --git a/src/validation/__tests__/ExecutableDefinitionsRule-test.ts b/src/validation/__tests__/ExecutableDefinitionsRule-test.ts deleted file mode 100644 index ec3a1afe25..0000000000 --- a/src/validation/__tests__/ExecutableDefinitionsRule-test.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { describe, it } from 'mocha'; - -import { ExecutableDefinitionsRule } from '../rules/ExecutableDefinitionsRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(ExecutableDefinitionsRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Executable definitions', () => { - it('with only operation', () => { - expectValid(` - query Foo { - dog { - name - } - } - `); - }); - - it('with operation and fragment', () => { - expectValid(` - query Foo { - dog { - name - ...Frag - } - } - - fragment Frag on Dog { - name - } - `); - }); - - it('with type definition', () => { - expectErrors(` - query Foo { - dog { - name - } - } - - type Cow { - name: String - } - - extend type Dog { - color: String - } - `).toDeepEqual([ - { - message: 'The "Cow" definition is not executable.', - locations: [{ line: 8, column: 7 }], - }, - { - message: 'The "Dog" definition is not executable.', - locations: [{ line: 12, column: 7 }], - }, - ]); - }); - - it('with schema definition', () => { - expectErrors(` - schema { - query: Query - } - - type Query { - test: String - } - - extend schema @directive - `).toDeepEqual([ - { - message: 'The schema definition is not executable.', - locations: [{ line: 2, column: 7 }], - }, - { - message: 'The "Query" definition is not executable.', - locations: [{ line: 6, column: 7 }], - }, - { - message: 'The schema definition is not executable.', - locations: [{ line: 10, column: 7 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/FieldsOnCorrectTypeRule-test.ts b/src/validation/__tests__/FieldsOnCorrectTypeRule-test.ts deleted file mode 100644 index 70473fa685..0000000000 --- a/src/validation/__tests__/FieldsOnCorrectTypeRule-test.ts +++ /dev/null @@ -1,447 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { FieldsOnCorrectTypeRule } from '../rules/FieldsOnCorrectTypeRule'; -import { validate } from '../validate'; - -import { expectValidationErrorsWithSchema } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrorsWithSchema( - testSchema, - FieldsOnCorrectTypeRule, - queryStr, - ); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -const testSchema = buildSchema(` - interface Pet { - name: String - } - - type Dog implements Pet { - name: String - nickname: String - barkVolume: Int - } - - type Cat implements Pet { - name: String - nickname: String - meowVolume: Int - } - - union CatOrDog = Cat | Dog - - type Human { - name: String - pets: [Pet] - } - - type Query { - human: Human - } -`); - -describe('Validate: Fields on correct type', () => { - it('Object field selection', () => { - expectValid(` - fragment objectFieldSelection on Dog { - __typename - name - } - `); - }); - - it('Aliased object field selection', () => { - expectValid(` - fragment aliasedObjectFieldSelection on Dog { - tn : __typename - otherName : name - } - `); - }); - - it('Interface field selection', () => { - expectValid(` - fragment interfaceFieldSelection on Pet { - __typename - name - } - `); - }); - - it('Aliased interface field selection', () => { - expectValid(` - fragment interfaceFieldSelection on Pet { - otherName : name - } - `); - }); - - it('Lying alias selection', () => { - expectValid(` - fragment lyingAliasSelection on Dog { - name : nickname - } - `); - }); - - it('Ignores fields on unknown type', () => { - expectValid(` - fragment unknownSelection on UnknownType { - unknownField - } - `); - }); - - it('reports errors when type is known again', () => { - expectErrors(` - fragment typeKnownAgain on Pet { - unknown_pet_field { - ... on Cat { - unknown_cat_field - } - } - } - `).toDeepEqual([ - { - message: 'Cannot query field "unknown_pet_field" on type "Pet".', - locations: [{ line: 3, column: 9 }], - }, - { - message: 'Cannot query field "unknown_cat_field" on type "Cat".', - locations: [{ line: 5, column: 13 }], - }, - ]); - }); - - it('Field not defined on fragment', () => { - expectErrors(` - fragment fieldNotDefined on Dog { - meowVolume - } - `).toDeepEqual([ - { - message: - 'Cannot query field "meowVolume" on type "Dog". Did you mean "barkVolume"?', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('Ignores deeply unknown field', () => { - expectErrors(` - fragment deepFieldNotDefined on Dog { - unknown_field { - deeper_unknown_field - } - } - `).toDeepEqual([ - { - message: 'Cannot query field "unknown_field" on type "Dog".', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('Sub-field not defined', () => { - expectErrors(` - fragment subFieldNotDefined on Human { - pets { - unknown_field - } - } - `).toDeepEqual([ - { - message: 'Cannot query field "unknown_field" on type "Pet".', - locations: [{ line: 4, column: 11 }], - }, - ]); - }); - - it('Field not defined on inline fragment', () => { - expectErrors(` - fragment fieldNotDefined on Pet { - ... on Dog { - meowVolume - } - } - `).toDeepEqual([ - { - message: - 'Cannot query field "meowVolume" on type "Dog". Did you mean "barkVolume"?', - locations: [{ line: 4, column: 11 }], - }, - ]); - }); - - it('Aliased field target not defined', () => { - expectErrors(` - fragment aliasedFieldTargetNotDefined on Dog { - volume : mooVolume - } - `).toDeepEqual([ - { - message: - 'Cannot query field "mooVolume" on type "Dog". Did you mean "barkVolume"?', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('Aliased lying field target not defined', () => { - expectErrors(` - fragment aliasedLyingFieldTargetNotDefined on Dog { - barkVolume : kawVolume - } - `).toDeepEqual([ - { - message: - 'Cannot query field "kawVolume" on type "Dog". Did you mean "barkVolume"?', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('Not defined on interface', () => { - expectErrors(` - fragment notDefinedOnInterface on Pet { - tailLength - } - `).toDeepEqual([ - { - message: 'Cannot query field "tailLength" on type "Pet".', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('Defined on implementors but not on interface', () => { - expectErrors(` - fragment definedOnImplementorsButNotInterface on Pet { - nickname - } - `).toDeepEqual([ - { - message: - 'Cannot query field "nickname" on type "Pet". Did you mean to use an inline fragment on "Cat" or "Dog"?', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('Meta field selection on union', () => { - expectValid(` - fragment directFieldSelectionOnUnion on CatOrDog { - __typename - } - `); - }); - - it('Direct field selection on union', () => { - expectErrors(` - fragment directFieldSelectionOnUnion on CatOrDog { - directField - } - `).toDeepEqual([ - { - message: 'Cannot query field "directField" on type "CatOrDog".', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('Defined on implementors queried on union', () => { - expectErrors(` - fragment definedOnImplementorsQueriedOnUnion on CatOrDog { - name - } - `).toDeepEqual([ - { - message: - 'Cannot query field "name" on type "CatOrDog". Did you mean to use an inline fragment on "Pet", "Cat", or "Dog"?', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('valid field in inline fragment', () => { - expectValid(` - fragment objectFieldSelection on Pet { - ... on Dog { - name - } - ... { - name - } - } - `); - }); - - describe('Fields on correct type error message', () => { - function expectErrorMessage(schema: GraphQLSchema, queryStr: string) { - const errors = validate(schema, parse(queryStr), [ - FieldsOnCorrectTypeRule, - ]); - expect(errors.length).to.equal(1); - return expect(errors[0].message); - } - - it('Works with no suggestions', () => { - const schema = buildSchema(` - type T { - fieldWithVeryLongNameThatWillNeverBeSuggested: String - } - type Query { t: T } - `); - - expectErrorMessage(schema, '{ t { f } }').to.equal( - 'Cannot query field "f" on type "T".', - ); - }); - - it('Works with no small numbers of type suggestions', () => { - const schema = buildSchema(` - union T = A | B - type Query { t: T } - - type A { f: String } - type B { f: String } - `); - - expectErrorMessage(schema, '{ t { f } }').to.equal( - 'Cannot query field "f" on type "T". Did you mean to use an inline fragment on "A" or "B"?', - ); - }); - - it('Works with no small numbers of field suggestions', () => { - const schema = buildSchema(` - type T { - y: String - z: String - } - type Query { t: T } - `); - - expectErrorMessage(schema, '{ t { f } }').to.equal( - 'Cannot query field "f" on type "T". Did you mean "y" or "z"?', - ); - }); - - it('Only shows one set of suggestions at a time, preferring types', () => { - const schema = buildSchema(` - interface T { - y: String - z: String - } - type Query { t: T } - - type A implements T { - f: String - y: String - z: String - } - type B implements T { - f: String - y: String - z: String - } - `); - - expectErrorMessage(schema, '{ t { f } }').to.equal( - 'Cannot query field "f" on type "T". Did you mean to use an inline fragment on "A" or "B"?', - ); - }); - - it('Sort type suggestions based on inheritance order', () => { - const interfaceSchema = buildSchema(` - interface T { bar: String } - type Query { t: T } - - interface Z implements T { - foo: String - bar: String - } - - interface Y implements Z & T { - foo: String - bar: String - } - - type X implements Y & Z & T { - foo: String - bar: String - } - `); - - expectErrorMessage(interfaceSchema, '{ t { foo } }').to.equal( - 'Cannot query field "foo" on type "T". Did you mean to use an inline fragment on "Z", "Y", or "X"?', - ); - - const unionSchema = buildSchema(` - interface Animal { name: String } - interface Mammal implements Animal { name: String } - - interface Canine implements Animal & Mammal { name: String } - type Dog implements Animal & Mammal & Canine { name: String } - - interface Feline implements Animal & Mammal { name: String } - type Cat implements Animal & Mammal & Feline { name: String } - - union CatOrDog = Cat | Dog - type Query { catOrDog: CatOrDog } - `); - - expectErrorMessage(unionSchema, '{ catOrDog { name } }').to.equal( - 'Cannot query field "name" on type "CatOrDog". Did you mean to use an inline fragment on "Animal", "Mammal", "Canine", "Dog", or "Feline"?', - ); - }); - - it('Limits lots of type suggestions', () => { - const schema = buildSchema(` - union T = A | B | C | D | E | F - type Query { t: T } - - type A { f: String } - type B { f: String } - type C { f: String } - type D { f: String } - type E { f: String } - type F { f: String } - `); - - expectErrorMessage(schema, '{ t { f } }').to.equal( - 'Cannot query field "f" on type "T". Did you mean to use an inline fragment on "A", "B", "C", "D", or "E"?', - ); - }); - - it('Limits lots of field suggestions', () => { - const schema = buildSchema(` - type T { - u: String - v: String - w: String - x: String - y: String - z: String - } - type Query { t: T } - `); - - expectErrorMessage(schema, '{ t { f } }').to.equal( - 'Cannot query field "f" on type "T". Did you mean "u", "v", "w", "x", or "y"?', - ); - }); - }); -}); diff --git a/src/validation/__tests__/FragmentsOnCompositeTypesRule-test.ts b/src/validation/__tests__/FragmentsOnCompositeTypesRule-test.ts deleted file mode 100644 index dc1ed40796..0000000000 --- a/src/validation/__tests__/FragmentsOnCompositeTypesRule-test.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { describe, it } from 'mocha'; - -import { FragmentsOnCompositeTypesRule } from '../rules/FragmentsOnCompositeTypesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(FragmentsOnCompositeTypesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Fragments on composite types', () => { - it('object is valid fragment type', () => { - expectValid(` - fragment validFragment on Dog { - barks - } - `); - }); - - it('interface is valid fragment type', () => { - expectValid(` - fragment validFragment on Pet { - name - } - `); - }); - - it('object is valid inline fragment type', () => { - expectValid(` - fragment validFragment on Pet { - ... on Dog { - barks - } - } - `); - }); - - it('interface is valid inline fragment type', () => { - expectValid(` - fragment validFragment on Mammal { - ... on Canine { - name - } - } - `); - }); - - it('inline fragment without type is valid', () => { - expectValid(` - fragment validFragment on Pet { - ... { - name - } - } - `); - }); - - it('union is valid fragment type', () => { - expectValid(` - fragment validFragment on CatOrDog { - __typename - } - `); - }); - - it('scalar is invalid fragment type', () => { - expectErrors(` - fragment scalarFragment on Boolean { - bad - } - `).toDeepEqual([ - { - message: - 'Fragment "scalarFragment" cannot condition on non composite type "Boolean".', - locations: [{ line: 2, column: 34 }], - }, - ]); - }); - - it('enum is invalid fragment type', () => { - expectErrors(` - fragment scalarFragment on FurColor { - bad - } - `).toDeepEqual([ - { - message: - 'Fragment "scalarFragment" cannot condition on non composite type "FurColor".', - locations: [{ line: 2, column: 34 }], - }, - ]); - }); - - it('input object is invalid fragment type', () => { - expectErrors(` - fragment inputFragment on ComplexInput { - stringField - } - `).toDeepEqual([ - { - message: - 'Fragment "inputFragment" cannot condition on non composite type "ComplexInput".', - locations: [{ line: 2, column: 33 }], - }, - ]); - }); - - it('scalar is invalid inline fragment type', () => { - expectErrors(` - fragment invalidFragment on Pet { - ... on String { - barks - } - } - `).toDeepEqual([ - { - message: 'Fragment cannot condition on non composite type "String".', - locations: [{ line: 3, column: 16 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/KnownArgumentNamesRule-test.ts b/src/validation/__tests__/KnownArgumentNamesRule-test.ts deleted file mode 100644 index 4ce5fd190f..0000000000 --- a/src/validation/__tests__/KnownArgumentNamesRule-test.ts +++ /dev/null @@ -1,329 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { - KnownArgumentNamesOnDirectivesRule, - KnownArgumentNamesRule, -} from '../rules/KnownArgumentNamesRule'; - -import { expectSDLValidationErrors, expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(KnownArgumentNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors( - schema, - KnownArgumentNamesOnDirectivesRule, - sdlStr, - ); -} - -function expectValidSDL(sdlStr: string) { - expectSDLErrors(sdlStr).toDeepEqual([]); -} - -describe('Validate: Known argument names', () => { - it('single arg is known', () => { - expectValid(` - fragment argOnRequiredArg on Dog { - doesKnowCommand(dogCommand: SIT) - } - `); - }); - - it('multiple args are known', () => { - expectValid(` - fragment multipleArgs on ComplicatedArgs { - multipleReqs(req1: 1, req2: 2) - } - `); - }); - - it('ignores args of unknown fields', () => { - expectValid(` - fragment argOnUnknownField on Dog { - unknownField(unknownArg: SIT) - } - `); - }); - - it('multiple args in reverse order are known', () => { - expectValid(` - fragment multipleArgsReverseOrder on ComplicatedArgs { - multipleReqs(req2: 2, req1: 1) - } - `); - }); - - it('no args on optional arg', () => { - expectValid(` - fragment noArgOnOptionalArg on Dog { - isHouseTrained - } - `); - }); - - it('args are known deeply', () => { - expectValid(` - { - dog { - doesKnowCommand(dogCommand: SIT) - } - human { - pet { - ... on Dog { - doesKnowCommand(dogCommand: SIT) - } - } - } - } - `); - }); - - it('directive args are known', () => { - expectValid(` - { - dog @skip(if: true) - } - `); - }); - - it('field args are invalid', () => { - expectErrors(` - { - dog @skip(unless: true) - } - `).toDeepEqual([ - { - message: 'Unknown argument "unless" on directive "@skip".', - locations: [{ line: 3, column: 19 }], - }, - ]); - }); - - it('directive without args is valid', () => { - expectValid(` - { - dog @onField - } - `); - }); - - it('arg passed to directive without arg is reported', () => { - expectErrors(` - { - dog @onField(if: true) - } - `).toDeepEqual([ - { - message: 'Unknown argument "if" on directive "@onField".', - locations: [{ line: 3, column: 22 }], - }, - ]); - }); - - it('misspelled directive args are reported', () => { - expectErrors(` - { - dog @skip(iff: true) - } - `).toDeepEqual([ - { - message: - 'Unknown argument "iff" on directive "@skip". Did you mean "if"?', - locations: [{ line: 3, column: 19 }], - }, - ]); - }); - - it('invalid arg name', () => { - expectErrors(` - fragment invalidArgName on Dog { - doesKnowCommand(unknown: true) - } - `).toDeepEqual([ - { - message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".', - locations: [{ line: 3, column: 25 }], - }, - ]); - }); - - it('misspelled arg name is reported', () => { - expectErrors(` - fragment invalidArgName on Dog { - doesKnowCommand(DogCommand: true) - } - `).toDeepEqual([ - { - message: - 'Unknown argument "DogCommand" on field "Dog.doesKnowCommand". Did you mean "dogCommand"?', - locations: [{ line: 3, column: 25 }], - }, - ]); - }); - - it('unknown args amongst known args', () => { - expectErrors(` - fragment oneGoodArgOneInvalidArg on Dog { - doesKnowCommand(whoKnows: 1, dogCommand: SIT, unknown: true) - } - `).toDeepEqual([ - { - message: 'Unknown argument "whoKnows" on field "Dog.doesKnowCommand".', - locations: [{ line: 3, column: 25 }], - }, - { - message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".', - locations: [{ line: 3, column: 55 }], - }, - ]); - }); - - it('unknown args deeply', () => { - expectErrors(` - { - dog { - doesKnowCommand(unknown: true) - } - human { - pet { - ... on Dog { - doesKnowCommand(unknown: true) - } - } - } - } - `).toDeepEqual([ - { - message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".', - locations: [{ line: 4, column: 27 }], - }, - { - message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".', - locations: [{ line: 9, column: 31 }], - }, - ]); - }); - - describe('within SDL', () => { - it('known arg on directive defined inside SDL', () => { - expectValidSDL(` - type Query { - foo: String @test(arg: "") - } - - directive @test(arg: String) on FIELD_DEFINITION - `); - }); - - it('unknown arg on directive defined inside SDL', () => { - expectSDLErrors(` - type Query { - foo: String @test(unknown: "") - } - - directive @test(arg: String) on FIELD_DEFINITION - `).toDeepEqual([ - { - message: 'Unknown argument "unknown" on directive "@test".', - locations: [{ line: 3, column: 29 }], - }, - ]); - }); - - it('misspelled arg name is reported on directive defined inside SDL', () => { - expectSDLErrors(` - type Query { - foo: String @test(agr: "") - } - - directive @test(arg: String) on FIELD_DEFINITION - `).toDeepEqual([ - { - message: - 'Unknown argument "agr" on directive "@test". Did you mean "arg"?', - locations: [{ line: 3, column: 29 }], - }, - ]); - }); - - it('unknown arg on standard directive', () => { - expectSDLErrors(` - type Query { - foo: String @deprecated(unknown: "") - } - `).toDeepEqual([ - { - message: 'Unknown argument "unknown" on directive "@deprecated".', - locations: [{ line: 3, column: 35 }], - }, - ]); - }); - - it('unknown arg on overridden standard directive', () => { - expectSDLErrors(` - type Query { - foo: String @deprecated(reason: "") - } - directive @deprecated(arg: String) on FIELD - `).toDeepEqual([ - { - message: 'Unknown argument "reason" on directive "@deprecated".', - locations: [{ line: 3, column: 35 }], - }, - ]); - }); - - it('unknown arg on directive defined in schema extension', () => { - const schema = buildSchema(` - type Query { - foo: String - } - `); - expectSDLErrors( - ` - directive @test(arg: String) on OBJECT - - extend type Query @test(unknown: "") - `, - schema, - ).toDeepEqual([ - { - message: 'Unknown argument "unknown" on directive "@test".', - locations: [{ line: 4, column: 36 }], - }, - ]); - }); - - it('unknown arg on directive used in schema extension', () => { - const schema = buildSchema(` - directive @test(arg: String) on OBJECT - - type Query { - foo: String - } - `); - expectSDLErrors( - ` - extend type Query @test(unknown: "") - `, - schema, - ).toDeepEqual([ - { - message: 'Unknown argument "unknown" on directive "@test".', - locations: [{ line: 2, column: 35 }], - }, - ]); - }); - }); -}); diff --git a/src/validation/__tests__/KnownDirectivesRule-test.ts b/src/validation/__tests__/KnownDirectivesRule-test.ts deleted file mode 100644 index 4cb6e225c1..0000000000 --- a/src/validation/__tests__/KnownDirectivesRule-test.ts +++ /dev/null @@ -1,452 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { KnownDirectivesRule } from '../rules/KnownDirectivesRule'; - -import { - expectSDLValidationErrors, - expectValidationErrorsWithSchema, -} from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrorsWithSchema( - schemaWithDirectives, - KnownDirectivesRule, - queryStr, - ); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, KnownDirectivesRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -const schemaWithDirectives = buildSchema(` - type Query { - dummy: String - } - - directive @onQuery on QUERY - directive @onMutation on MUTATION - directive @onSubscription on SUBSCRIPTION - directive @onField on FIELD - directive @onFragmentDefinition on FRAGMENT_DEFINITION - directive @onFragmentSpread on FRAGMENT_SPREAD - directive @onInlineFragment on INLINE_FRAGMENT - directive @onVariableDefinition on VARIABLE_DEFINITION -`); - -const schemaWithSDLDirectives = buildSchema(` - directive @onSchema on SCHEMA - directive @onScalar on SCALAR - directive @onObject on OBJECT - directive @onFieldDefinition on FIELD_DEFINITION - directive @onArgumentDefinition on ARGUMENT_DEFINITION - directive @onInterface on INTERFACE - directive @onUnion on UNION - directive @onEnum on ENUM - directive @onEnumValue on ENUM_VALUE - directive @onInputObject on INPUT_OBJECT - directive @onInputFieldDefinition on INPUT_FIELD_DEFINITION -`); - -describe('Validate: Known directives', () => { - it('with no directives', () => { - expectValid(` - query Foo { - name - ...Frag - } - - fragment Frag on Dog { - name - } - `); - }); - - it('with standard directives', () => { - expectValid(` - { - human @skip(if: false) { - name - pets { - ... on Dog @include(if: true) { - name - } - } - } - } - `); - }); - - it('with unknown directive', () => { - expectErrors(` - { - human @unknown(directive: "value") { - name - } - } - `).toDeepEqual([ - { - message: 'Unknown directive "@unknown".', - locations: [{ line: 3, column: 15 }], - }, - ]); - }); - - it('with many unknown directives', () => { - expectErrors(` - { - __typename @unknown - human @unknown { - name - pets @unknown { - name - } - } - } - `).toDeepEqual([ - { - message: 'Unknown directive "@unknown".', - locations: [{ line: 3, column: 20 }], - }, - { - message: 'Unknown directive "@unknown".', - locations: [{ line: 4, column: 15 }], - }, - { - message: 'Unknown directive "@unknown".', - locations: [{ line: 6, column: 16 }], - }, - ]); - }); - - it('with well placed directives', () => { - expectValid(` - query ($var: Boolean @onVariableDefinition) @onQuery { - human @onField { - ...Frag @onFragmentSpread - ... @onInlineFragment { - name @onField - } - } - } - - mutation @onMutation { - someField @onField - } - - subscription @onSubscription { - someField @onField - } - - fragment Frag on Human @onFragmentDefinition { - name @onField - } - `); - }); - - it('with misplaced directives', () => { - expectErrors(` - query ($var: Boolean @onQuery) @onMutation { - human @onQuery { - ...Frag @onQuery - ... @onQuery { - name @onQuery - } - } - } - - mutation @onQuery { - someField @onQuery - } - - subscription @onQuery { - someField @onQuery - } - - fragment Frag on Human @onQuery { - name @onQuery - } - `).toDeepEqual([ - { - message: 'Directive "@onQuery" may not be used on VARIABLE_DEFINITION.', - locations: [{ line: 2, column: 28 }], - }, - { - message: 'Directive "@onMutation" may not be used on QUERY.', - locations: [{ line: 2, column: 38 }], - }, - { - message: 'Directive "@onQuery" may not be used on FIELD.', - locations: [{ line: 3, column: 15 }], - }, - { - message: 'Directive "@onQuery" may not be used on FRAGMENT_SPREAD.', - locations: [{ line: 4, column: 19 }], - }, - { - message: 'Directive "@onQuery" may not be used on INLINE_FRAGMENT.', - locations: [{ line: 5, column: 15 }], - }, - { - message: 'Directive "@onQuery" may not be used on FIELD.', - locations: [{ line: 6, column: 18 }], - }, - { - message: 'Directive "@onQuery" may not be used on MUTATION.', - locations: [{ line: 11, column: 16 }], - }, - { - message: 'Directive "@onQuery" may not be used on FIELD.', - locations: [{ column: 19, line: 12 }], - }, - { - message: 'Directive "@onQuery" may not be used on SUBSCRIPTION.', - locations: [{ column: 20, line: 15 }], - }, - { - message: 'Directive "@onQuery" may not be used on FIELD.', - locations: [{ column: 19, line: 16 }], - }, - { - message: 'Directive "@onQuery" may not be used on FRAGMENT_DEFINITION.', - locations: [{ column: 30, line: 19 }], - }, - { - message: 'Directive "@onQuery" may not be used on FIELD.', - locations: [{ column: 14, line: 20 }], - }, - ]); - }); - - describe('within SDL', () => { - it('with directive defined inside SDL', () => { - expectValidSDL(` - type Query { - foo: String @test - } - - directive @test on FIELD_DEFINITION - `); - }); - - it('with standard directive', () => { - expectValidSDL(` - type Query { - foo: String @deprecated - } - `); - }); - - it('with overridden standard directive', () => { - expectValidSDL(` - schema @deprecated { - query: Query - } - directive @deprecated on SCHEMA - `); - }); - - it('with directive defined in schema extension', () => { - const schema = buildSchema(` - type Query { - foo: String - } - `); - expectValidSDL( - ` - directive @test on OBJECT - - extend type Query @test - `, - schema, - ); - }); - - it('with directive used in schema extension', () => { - const schema = buildSchema(` - directive @test on OBJECT - - type Query { - foo: String - } - `); - expectValidSDL( - ` - extend type Query @test - `, - schema, - ); - }); - - it('with unknown directive in schema extension', () => { - const schema = buildSchema(` - type Query { - foo: String - } - `); - expectSDLErrors( - ` - extend type Query @unknown - `, - schema, - ).toDeepEqual([ - { - message: 'Unknown directive "@unknown".', - locations: [{ line: 2, column: 29 }], - }, - ]); - }); - - it('with well placed directives', () => { - expectValidSDL( - ` - type MyObj implements MyInterface @onObject { - myField(myArg: Int @onArgumentDefinition): String @onFieldDefinition - } - - extend type MyObj @onObject - - scalar MyScalar @onScalar - - extend scalar MyScalar @onScalar - - interface MyInterface @onInterface { - myField(myArg: Int @onArgumentDefinition): String @onFieldDefinition - } - - extend interface MyInterface @onInterface - - union MyUnion @onUnion = MyObj | Other - - extend union MyUnion @onUnion - - enum MyEnum @onEnum { - MY_VALUE @onEnumValue - } - - extend enum MyEnum @onEnum - - input MyInput @onInputObject { - myField: Int @onInputFieldDefinition - } - - extend input MyInput @onInputObject - - schema @onSchema { - query: MyQuery - } - - extend schema @onSchema - `, - schemaWithSDLDirectives, - ); - }); - - it('with misplaced directives', () => { - expectSDLErrors( - ` - type MyObj implements MyInterface @onInterface { - myField(myArg: Int @onInputFieldDefinition): String @onInputFieldDefinition - } - - scalar MyScalar @onEnum - - interface MyInterface @onObject { - myField(myArg: Int @onInputFieldDefinition): String @onInputFieldDefinition - } - - union MyUnion @onEnumValue = MyObj | Other - - enum MyEnum @onScalar { - MY_VALUE @onUnion - } - - input MyInput @onEnum { - myField: Int @onArgumentDefinition - } - - schema @onObject { - query: MyQuery - } - - extend schema @onObject - `, - schemaWithSDLDirectives, - ).toDeepEqual([ - { - message: 'Directive "@onInterface" may not be used on OBJECT.', - locations: [{ line: 2, column: 45 }], - }, - { - message: - 'Directive "@onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.', - locations: [{ line: 3, column: 32 }], - }, - { - message: - 'Directive "@onInputFieldDefinition" may not be used on FIELD_DEFINITION.', - locations: [{ line: 3, column: 65 }], - }, - { - message: 'Directive "@onEnum" may not be used on SCALAR.', - locations: [{ line: 6, column: 27 }], - }, - { - message: 'Directive "@onObject" may not be used on INTERFACE.', - locations: [{ line: 8, column: 33 }], - }, - { - message: - 'Directive "@onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.', - locations: [{ line: 9, column: 32 }], - }, - { - message: - 'Directive "@onInputFieldDefinition" may not be used on FIELD_DEFINITION.', - locations: [{ line: 9, column: 65 }], - }, - { - message: 'Directive "@onEnumValue" may not be used on UNION.', - locations: [{ line: 12, column: 25 }], - }, - { - message: 'Directive "@onScalar" may not be used on ENUM.', - locations: [{ line: 14, column: 23 }], - }, - { - message: 'Directive "@onUnion" may not be used on ENUM_VALUE.', - locations: [{ line: 15, column: 22 }], - }, - { - message: 'Directive "@onEnum" may not be used on INPUT_OBJECT.', - locations: [{ line: 18, column: 25 }], - }, - { - message: - 'Directive "@onArgumentDefinition" may not be used on INPUT_FIELD_DEFINITION.', - locations: [{ line: 19, column: 26 }], - }, - { - message: 'Directive "@onObject" may not be used on SCHEMA.', - locations: [{ line: 22, column: 18 }], - }, - { - message: 'Directive "@onObject" may not be used on SCHEMA.', - locations: [{ line: 26, column: 25 }], - }, - ]); - }); - }); -}); diff --git a/src/validation/__tests__/KnownFragmentNamesRule-test.ts b/src/validation/__tests__/KnownFragmentNamesRule-test.ts deleted file mode 100644 index c425767806..0000000000 --- a/src/validation/__tests__/KnownFragmentNamesRule-test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { describe, it } from 'mocha'; - -import { KnownFragmentNamesRule } from '../rules/KnownFragmentNamesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(KnownFragmentNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Known fragment names', () => { - it('known fragment names are valid', () => { - expectValid(` - { - human(id: 4) { - ...HumanFields1 - ... on Human { - ...HumanFields2 - } - ... { - name - } - } - } - fragment HumanFields1 on Human { - name - ...HumanFields3 - } - fragment HumanFields2 on Human { - name - } - fragment HumanFields3 on Human { - name - } - `); - }); - - it('unknown fragment names are invalid', () => { - expectErrors(` - { - human(id: 4) { - ...UnknownFragment1 - ... on Human { - ...UnknownFragment2 - } - } - } - fragment HumanFields on Human { - name - ...UnknownFragment3 - } - `).toDeepEqual([ - { - message: 'Unknown fragment "UnknownFragment1".', - locations: [{ line: 4, column: 14 }], - }, - { - message: 'Unknown fragment "UnknownFragment2".', - locations: [{ line: 6, column: 16 }], - }, - { - message: 'Unknown fragment "UnknownFragment3".', - locations: [{ line: 12, column: 12 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/KnownTypeNamesRule-test.ts b/src/validation/__tests__/KnownTypeNamesRule-test.ts deleted file mode 100644 index 34f0ca71e5..0000000000 --- a/src/validation/__tests__/KnownTypeNamesRule-test.ts +++ /dev/null @@ -1,362 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { KnownTypeNamesRule } from '../rules/KnownTypeNamesRule'; - -import { - expectSDLValidationErrors, - expectValidationErrors, - expectValidationErrorsWithSchema, -} from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(KnownTypeNamesRule, queryStr); -} - -function expectErrorsWithSchema(schema: GraphQLSchema, queryStr: string) { - return expectValidationErrorsWithSchema(schema, KnownTypeNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, KnownTypeNamesRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Known type names', () => { - it('known type names are valid', () => { - expectValid(` - query Foo( - $var: String - $required: [Int!]! - $introspectionType: __EnumValue - ) { - user(id: 4) { - pets { ... on Pet { name }, ...PetFields, ... { name } } - } - } - - fragment PetFields on Pet { - name - } - `); - }); - - it('unknown type names are invalid', () => { - expectErrors(` - query Foo($var: [JumbledUpLetters!]!) { - user(id: 4) { - name - pets { ... on Badger { name }, ...PetFields } - } - } - fragment PetFields on Peat { - name - } - `).toDeepEqual([ - { - message: 'Unknown type "JumbledUpLetters".', - locations: [{ line: 2, column: 24 }], - }, - { - message: 'Unknown type "Badger".', - locations: [{ line: 5, column: 25 }], - }, - { - message: 'Unknown type "Peat". Did you mean "Pet" or "Cat"?', - locations: [{ line: 8, column: 29 }], - }, - ]); - }); - - it('references to standard scalars that are missing in schema', () => { - const schema = buildSchema('type Query { foo: String }'); - const query = ` - query ($id: ID, $float: Float, $int: Int) { - __typename - } - `; - expectErrorsWithSchema(schema, query).toDeepEqual([ - { - message: 'Unknown type "ID".', - locations: [{ line: 2, column: 19 }], - }, - { - message: 'Unknown type "Float".', - locations: [{ line: 2, column: 31 }], - }, - { - message: 'Unknown type "Int".', - locations: [{ line: 2, column: 44 }], - }, - ]); - }); - - describe('within SDL', () => { - it('use standard types', () => { - expectValidSDL(` - type Query { - string: String - int: Int - float: Float - boolean: Boolean - id: ID - introspectionType: __EnumValue - } - `); - }); - - it('reference types defined inside the same document', () => { - expectValidSDL(` - union SomeUnion = SomeObject | AnotherObject - - type SomeObject implements SomeInterface { - someScalar(arg: SomeInputObject): SomeScalar - } - - type AnotherObject { - foo(arg: SomeInputObject): String - } - - type SomeInterface { - someScalar(arg: SomeInputObject): SomeScalar - } - - input SomeInputObject { - someScalar: SomeScalar - } - - scalar SomeScalar - - type RootQuery { - someInterface: SomeInterface - someUnion: SomeUnion - someScalar: SomeScalar - someObject: SomeObject - } - - schema { - query: RootQuery - } - `); - }); - - it('unknown type references', () => { - expectSDLErrors(` - type A - type B - - type SomeObject implements C { - e(d: D): E - } - - union SomeUnion = F | G - - interface SomeInterface { - i(h: H): I - } - - input SomeInput { - j: J - } - - directive @SomeDirective(k: K) on QUERY - - schema { - query: L - mutation: M - subscription: N - } - `).toDeepEqual([ - { - message: 'Unknown type "C". Did you mean "A" or "B"?', - locations: [{ line: 5, column: 36 }], - }, - { - message: 'Unknown type "D". Did you mean "A", "B", or "ID"?', - locations: [{ line: 6, column: 16 }], - }, - { - message: 'Unknown type "E". Did you mean "A" or "B"?', - locations: [{ line: 6, column: 20 }], - }, - { - message: 'Unknown type "F". Did you mean "A" or "B"?', - locations: [{ line: 9, column: 27 }], - }, - { - message: 'Unknown type "G". Did you mean "A" or "B"?', - locations: [{ line: 9, column: 31 }], - }, - { - message: 'Unknown type "H". Did you mean "A" or "B"?', - locations: [{ line: 12, column: 16 }], - }, - { - message: 'Unknown type "I". Did you mean "A", "B", or "ID"?', - locations: [{ line: 12, column: 20 }], - }, - { - message: 'Unknown type "J". Did you mean "A" or "B"?', - locations: [{ line: 16, column: 14 }], - }, - { - message: 'Unknown type "K". Did you mean "A" or "B"?', - locations: [{ line: 19, column: 37 }], - }, - { - message: 'Unknown type "L". Did you mean "A" or "B"?', - locations: [{ line: 22, column: 18 }], - }, - { - message: 'Unknown type "M". Did you mean "A" or "B"?', - locations: [{ line: 23, column: 21 }], - }, - { - message: 'Unknown type "N". Did you mean "A" or "B"?', - locations: [{ line: 24, column: 25 }], - }, - ]); - }); - - it('does not consider non-type definitions', () => { - expectSDLErrors(` - query Foo { __typename } - fragment Foo on Query { __typename } - directive @Foo on QUERY - - type Query { - foo: Foo - } - `).toDeepEqual([ - { - message: 'Unknown type "Foo".', - locations: [{ line: 7, column: 16 }], - }, - ]); - }); - - it('reference standard types inside extension document', () => { - const schema = buildSchema('type Foo'); - const sdl = ` - type SomeType { - string: String - int: Int - float: Float - boolean: Boolean - id: ID - introspectionType: __EnumValue - } - `; - - expectValidSDL(sdl, schema); - }); - - it('reference types inside extension document', () => { - const schema = buildSchema('type Foo'); - const sdl = ` - type QueryRoot { - foo: Foo - bar: Bar - } - - scalar Bar - - schema { - query: QueryRoot - } - `; - - expectValidSDL(sdl, schema); - }); - - it('unknown type references inside extension document', () => { - const schema = buildSchema('type A'); - const sdl = ` - type B - - type SomeObject implements C { - e(d: D): E - } - - union SomeUnion = F | G - - interface SomeInterface { - i(h: H): I - } - - input SomeInput { - j: J - } - - directive @SomeDirective(k: K) on QUERY - - schema { - query: L - mutation: M - subscription: N - } - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: 'Unknown type "C". Did you mean "A" or "B"?', - locations: [{ line: 4, column: 36 }], - }, - { - message: 'Unknown type "D". Did you mean "A", "B", or "ID"?', - locations: [{ line: 5, column: 16 }], - }, - { - message: 'Unknown type "E". Did you mean "A" or "B"?', - locations: [{ line: 5, column: 20 }], - }, - { - message: 'Unknown type "F". Did you mean "A" or "B"?', - locations: [{ line: 8, column: 27 }], - }, - { - message: 'Unknown type "G". Did you mean "A" or "B"?', - locations: [{ line: 8, column: 31 }], - }, - { - message: 'Unknown type "H". Did you mean "A" or "B"?', - locations: [{ line: 11, column: 16 }], - }, - { - message: 'Unknown type "I". Did you mean "A", "B", or "ID"?', - locations: [{ line: 11, column: 20 }], - }, - { - message: 'Unknown type "J". Did you mean "A" or "B"?', - locations: [{ line: 15, column: 14 }], - }, - { - message: 'Unknown type "K". Did you mean "A" or "B"?', - locations: [{ line: 18, column: 37 }], - }, - { - message: 'Unknown type "L". Did you mean "A" or "B"?', - locations: [{ line: 21, column: 18 }], - }, - { - message: 'Unknown type "M". Did you mean "A" or "B"?', - locations: [{ line: 22, column: 21 }], - }, - { - message: 'Unknown type "N". Did you mean "A" or "B"?', - locations: [{ line: 23, column: 25 }], - }, - ]); - }); - }); -}); diff --git a/src/validation/__tests__/LoneAnonymousOperationRule-test.ts b/src/validation/__tests__/LoneAnonymousOperationRule-test.ts deleted file mode 100644 index a50ef1bdf0..0000000000 --- a/src/validation/__tests__/LoneAnonymousOperationRule-test.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { describe, it } from 'mocha'; - -import { LoneAnonymousOperationRule } from '../rules/LoneAnonymousOperationRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(LoneAnonymousOperationRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Anonymous operation must be alone', () => { - it('no operations', () => { - expectValid(` - fragment fragA on Type { - field - } - `); - }); - - it('one anon operation', () => { - expectValid(` - { - field - } - `); - }); - - it('multiple named operations', () => { - expectValid(` - query Foo { - field - } - - query Bar { - field - } - `); - }); - - it('anon operation with fragment', () => { - expectValid(` - { - ...Foo - } - fragment Foo on Type { - field - } - `); - }); - - it('multiple anon operations', () => { - expectErrors(` - { - fieldA - } - { - fieldB - } - `).toDeepEqual([ - { - message: 'This anonymous operation must be the only defined operation.', - locations: [{ line: 2, column: 7 }], - }, - { - message: 'This anonymous operation must be the only defined operation.', - locations: [{ line: 5, column: 7 }], - }, - ]); - }); - - it('anon operation with a mutation', () => { - expectErrors(` - { - fieldA - } - mutation Foo { - fieldB - } - `).toDeepEqual([ - { - message: 'This anonymous operation must be the only defined operation.', - locations: [{ line: 2, column: 7 }], - }, - ]); - }); - - it('anon operation with a subscription', () => { - expectErrors(` - { - fieldA - } - subscription Foo { - fieldB - } - `).toDeepEqual([ - { - message: 'This anonymous operation must be the only defined operation.', - locations: [{ line: 2, column: 7 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/LoneSchemaDefinitionRule-test.ts b/src/validation/__tests__/LoneSchemaDefinitionRule-test.ts deleted file mode 100644 index 3f2ea895af..0000000000 --- a/src/validation/__tests__/LoneSchemaDefinitionRule-test.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { LoneSchemaDefinitionRule } from '../rules/LoneSchemaDefinitionRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, LoneSchemaDefinitionRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Schema definition should be alone', () => { - it('no schema', () => { - expectValidSDL(` - type Query { - foo: String - } - `); - }); - - it('one schema definition', () => { - expectValidSDL(` - schema { - query: Foo - } - - type Foo { - foo: String - } - `); - }); - - it('multiple schema definitions', () => { - expectSDLErrors(` - schema { - query: Foo - } - - type Foo { - foo: String - } - - schema { - mutation: Foo - } - - schema { - subscription: Foo - } - `).toDeepEqual([ - { - message: 'Must provide only one schema definition.', - locations: [{ line: 10, column: 7 }], - }, - { - message: 'Must provide only one schema definition.', - locations: [{ line: 14, column: 7 }], - }, - ]); - }); - - it('define schema in schema extension', () => { - const schema = buildSchema(` - type Foo { - foo: String - } - `); - - expectSDLErrors( - ` - schema { - query: Foo - } - `, - schema, - ).toDeepEqual([]); - }); - - it('redefine schema in schema extension', () => { - const schema = buildSchema(` - schema { - query: Foo - } - - type Foo { - foo: String - } - `); - - expectSDLErrors( - ` - schema { - mutation: Foo - } - `, - schema, - ).toDeepEqual([ - { - message: 'Cannot define a new schema within a schema extension.', - locations: [{ line: 2, column: 9 }], - }, - ]); - }); - - it('redefine implicit schema in schema extension', () => { - const schema = buildSchema(` - type Query { - fooField: Foo - } - - type Foo { - foo: String - } - `); - - expectSDLErrors( - ` - schema { - mutation: Foo - } - `, - schema, - ).toDeepEqual([ - { - message: 'Cannot define a new schema within a schema extension.', - locations: [{ line: 2, column: 9 }], - }, - ]); - }); - - it('extend schema in schema extension', () => { - const schema = buildSchema(` - type Query { - fooField: Foo - } - - type Foo { - foo: String - } - `); - - expectValidSDL( - ` - extend schema { - mutation: Foo - } - `, - schema, - ); - }); -}); diff --git a/src/validation/__tests__/MaxIntrospectionDepthRule-test.ts b/src/validation/__tests__/MaxIntrospectionDepthRule-test.ts deleted file mode 100644 index d6609941d4..0000000000 --- a/src/validation/__tests__/MaxIntrospectionDepthRule-test.ts +++ /dev/null @@ -1,554 +0,0 @@ -import { describe, it } from 'mocha'; - -import { getIntrospectionQuery } from '../../utilities/getIntrospectionQuery'; - -import { MaxIntrospectionDepthRule } from '../rules/MaxIntrospectionDepthRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(MaxIntrospectionDepthRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Max introspection nodes rule', () => { - it('default introspection query', () => { - expectValid(getIntrospectionQuery()); - }); - - it('all options introspection query', () => { - expectValid( - getIntrospectionQuery({ - descriptions: true, - specifiedByUrl: true, - directiveIsRepeatable: true, - schemaDescription: true, - inputValueDeprecation: true, - }), - ); - }); - - it('3 flat fields introspection query', () => { - expectValid(` - { - __type(name: "Query") { - trueFields: fields(includeDeprecated: true) { - name - } - falseFields: fields(includeDeprecated: false) { - name - } - omittedFields: fields { - name - } - } - } - `); - }); - - it('3 fields deep introspection query from __schema', () => { - expectErrors(` - { - __schema { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 interfaces deep introspection query from __schema', () => { - expectErrors(` - { - __schema { - types { - interfaces { - interfaces { - interfaces { - name - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 possibleTypes deep introspection query from __schema', () => { - expectErrors(` - { - __schema { - types { - possibleTypes { - possibleTypes { - possibleTypes { - name - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 inputFields deep introspection query from __schema', () => { - expectErrors(` - { - __schema { - types { - inputFields { - type { - inputFields { - type { - inputFields { - type { - name - } - } - } - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 fields deep introspection query from multiple __schema', () => { - expectErrors(` - { - one: __schema { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - two: __schema { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - three: __schema { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - { - locations: [ - { - column: 7, - line: 18, - }, - ], - message: 'Maximum introspection depth exceeded', - }, - { - locations: [ - { - column: 7, - line: 33, - }, - ], - message: 'Maximum introspection depth exceeded', - }, - ]); - }); - - it('3 fields deep introspection query from __type', () => { - expectErrors(` - { - __type(name: "Query") { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 fields deep introspection query from multiple __type', () => { - expectErrors(` - { - one: __type(name: "Query") { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - two: __type(name: "Query") { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - three: __type(name: "Query") { - types { - fields { - type { - fields { - type { - fields { - name - } - } - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - { - locations: [ - { - column: 7, - line: 18, - }, - ], - message: 'Maximum introspection depth exceeded', - }, - { - locations: [ - { - column: 7, - line: 33, - }, - ], - message: 'Maximum introspection depth exceeded', - }, - ]); - }); - - it('1 fields deep with 3 fields introspection query', () => { - expectValid(` - { - __schema { - types { - fields { - type { - oneFields: fields { - name - } - twoFields: fields { - name - } - threeFields: fields { - name - } - } - } - } - } - } - `); - }); - - it('3 fields deep from varying parents introspection query', () => { - expectErrors(` - { - __schema { - types { - fields { - type { - fields { - type { - ofType { - fields { - name - } - } - } - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 fields deep introspection query with inline fragments', () => { - expectErrors(` - query test { - __schema { - types { - ... on __Type { - fields { - type { - ... on __Type { - ofType { - fields { - type { - ... on __Type { - fields { - name - } - } - } - } - } - } - } - } - } - } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 fields deep introspection query with fragments', () => { - expectErrors(` - query test { - __schema { - types { - ...One - } - } - } - - fragment One on __Type { - fields { - type { - ...Two - } - } - } - - fragment Two on __Type { - fields { - type { - ...Three - } - } - } - - fragment Three on __Type { - fields { - name - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 7, - line: 3, - }, - ], - }, - ]); - }); - - it('3 fields deep inside inline fragment on query', () => { - expectErrors(` - { - ... { - __schema { types { fields { type { fields { type { fields { name } } } } } } } - } - } - `).toDeepEqual([ - { - message: 'Maximum introspection depth exceeded', - locations: [ - { - column: 9, - line: 4, - }, - ], - }, - ]); - }); - - it('opts out if fragment is missing', () => { - expectValid(` - query test { - __schema { - types { - ...Missing - } - } - } - `); - }); - - it("doesn't infinitely recurse on fragment cycle", () => { - expectValid(` - query test { - __schema { - types { - ...Cycle - } - } - } - fragment Cycle on __Type { - ...Cycle - } - `); - }); -}); diff --git a/src/validation/__tests__/NoDeprecatedCustomRule-test.ts b/src/validation/__tests__/NoDeprecatedCustomRule-test.ts deleted file mode 100644 index 512edb27dd..0000000000 --- a/src/validation/__tests__/NoDeprecatedCustomRule-test.ts +++ /dev/null @@ -1,272 +0,0 @@ -import { describe, it } from 'mocha'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { NoDeprecatedCustomRule } from '../rules/custom/NoDeprecatedCustomRule'; - -import { expectValidationErrorsWithSchema } from './harness'; - -function buildAssertion(sdlStr: string) { - const schema = buildSchema(sdlStr); - return { expectErrors, expectValid }; - - function expectErrors(queryStr: string) { - return expectValidationErrorsWithSchema( - schema, - NoDeprecatedCustomRule, - queryStr, - ); - } - - function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); - } -} - -describe('Validate: no deprecated', () => { - describe('no deprecated fields', () => { - const { expectValid, expectErrors } = buildAssertion(` - type Query { - normalField: String - deprecatedField: String @deprecated(reason: "Some field reason.") - } - `); - - it('ignores fields that are not deprecated', () => { - expectValid(` - { - normalField - } - `); - }); - - it('ignores unknown fields', () => { - expectValid(` - { - unknownField - } - - fragment UnknownFragment on UnknownType { - deprecatedField - } - `); - }); - - it('reports error when a deprecated field is selected', () => { - const message = - 'The field Query.deprecatedField is deprecated. Some field reason.'; - - expectErrors(` - { - deprecatedField - } - - fragment QueryFragment on Query { - deprecatedField - } - `).toDeepEqual([ - { message, locations: [{ line: 3, column: 11 }] }, - { message, locations: [{ line: 7, column: 11 }] }, - ]); - }); - }); - - describe('no deprecated arguments on fields', () => { - const { expectValid, expectErrors } = buildAssertion(` - type Query { - someField( - normalArg: String, - deprecatedArg: String @deprecated(reason: "Some arg reason."), - ): String - } - `); - - it('ignores arguments that are not deprecated', () => { - expectValid(` - { - normalField(normalArg: "") - } - `); - }); - - it('ignores unknown arguments', () => { - expectValid(` - { - someField(unknownArg: "") - unknownField(deprecatedArg: "") - } - `); - }); - - it('reports error when a deprecated argument is used', () => { - expectErrors(` - { - someField(deprecatedArg: "") - } - `).toDeepEqual([ - { - message: - 'Field "Query.someField" argument "deprecatedArg" is deprecated. Some arg reason.', - locations: [{ line: 3, column: 21 }], - }, - ]); - }); - }); - - describe('no deprecated arguments on directives', () => { - const { expectValid, expectErrors } = buildAssertion(` - type Query { - someField: String - } - - directive @someDirective( - normalArg: String, - deprecatedArg: String @deprecated(reason: "Some arg reason."), - ) on FIELD - `); - - it('ignores arguments that are not deprecated', () => { - expectValid(` - { - someField @someDirective(normalArg: "") - } - `); - }); - - it('ignores unknown arguments', () => { - expectValid(` - { - someField @someDirective(unknownArg: "") - someField @unknownDirective(deprecatedArg: "") - } - `); - }); - - it('reports error when a deprecated argument is used', () => { - expectErrors(` - { - someField @someDirective(deprecatedArg: "") - } - `).toDeepEqual([ - { - message: - 'Directive "@someDirective" argument "deprecatedArg" is deprecated. Some arg reason.', - locations: [{ line: 3, column: 36 }], - }, - ]); - }); - }); - - describe('no deprecated input fields', () => { - const { expectValid, expectErrors } = buildAssertion(` - input InputType { - normalField: String - deprecatedField: String @deprecated(reason: "Some input field reason.") - } - - type Query { - someField(someArg: InputType): String - } - - directive @someDirective(someArg: InputType) on FIELD - `); - - it('ignores input fields that are not deprecated', () => { - expectValid(` - { - someField( - someArg: { normalField: "" } - ) @someDirective(someArg: { normalField: "" }) - } - `); - }); - - it('ignores unknown input fields', () => { - expectValid(` - { - someField( - someArg: { unknownField: "" } - ) - - someField( - unknownArg: { unknownField: "" } - ) - - unknownField( - unknownArg: { unknownField: "" } - ) - } - `); - }); - - it('reports error when a deprecated input field is used', () => { - const message = - 'The input field InputType.deprecatedField is deprecated. Some input field reason.'; - - expectErrors(` - { - someField( - someArg: { deprecatedField: "" } - ) @someDirective(someArg: { deprecatedField: "" }) - } - `).toDeepEqual([ - { message, locations: [{ line: 4, column: 24 }] }, - { message, locations: [{ line: 5, column: 39 }] }, - ]); - }); - }); - - describe('no deprecated enum values', () => { - const { expectValid, expectErrors } = buildAssertion(` - enum EnumType { - NORMAL_VALUE - DEPRECATED_VALUE @deprecated(reason: "Some enum reason.") - } - - type Query { - someField(enumArg: EnumType): String - } - `); - - it('ignores enum values that are not deprecated', () => { - expectValid(` - { - normalField(enumArg: NORMAL_VALUE) - } - `); - }); - - it('ignores unknown enum values', () => { - expectValid(` - query ( - $unknownValue: EnumType = UNKNOWN_VALUE - $unknownType: UnknownType = UNKNOWN_VALUE - ) { - someField(enumArg: UNKNOWN_VALUE) - someField(unknownArg: UNKNOWN_VALUE) - unknownField(unknownArg: UNKNOWN_VALUE) - } - - fragment SomeFragment on Query { - someField(enumArg: UNKNOWN_VALUE) - } - `); - }); - - it('reports error when a deprecated enum value is used', () => { - const message = - 'The enum value "EnumType.DEPRECATED_VALUE" is deprecated. Some enum reason.'; - - expectErrors(` - query ( - $variable: EnumType = DEPRECATED_VALUE - ) { - someField(enumArg: DEPRECATED_VALUE) - } - `).toDeepEqual([ - { message, locations: [{ line: 3, column: 33 }] }, - { message, locations: [{ line: 5, column: 30 }] }, - ]); - }); - }); -}); diff --git a/src/validation/__tests__/NoFragmentCyclesRule-test.ts b/src/validation/__tests__/NoFragmentCyclesRule-test.ts deleted file mode 100644 index 08ac4cb4a9..0000000000 --- a/src/validation/__tests__/NoFragmentCyclesRule-test.ts +++ /dev/null @@ -1,260 +0,0 @@ -import { describe, it } from 'mocha'; - -import { NoFragmentCyclesRule } from '../rules/NoFragmentCyclesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(NoFragmentCyclesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: No circular fragment spreads', () => { - it('single reference is valid', () => { - expectValid(` - fragment fragA on Dog { ...fragB } - fragment fragB on Dog { name } - `); - }); - - it('spreading twice is not circular', () => { - expectValid(` - fragment fragA on Dog { ...fragB, ...fragB } - fragment fragB on Dog { name } - `); - }); - - it('spreading twice indirectly is not circular', () => { - expectValid(` - fragment fragA on Dog { ...fragB, ...fragC } - fragment fragB on Dog { ...fragC } - fragment fragC on Dog { name } - `); - }); - - it('double spread within abstract types', () => { - expectValid(` - fragment nameFragment on Pet { - ... on Dog { name } - ... on Cat { name } - } - - fragment spreadsInAnon on Pet { - ... on Dog { ...nameFragment } - ... on Cat { ...nameFragment } - } - `); - }); - - it('does not false positive on unknown fragment', () => { - expectValid(` - fragment nameFragment on Pet { - ...UnknownFragment - } - `); - }); - - it('spreading recursively within field fails', () => { - expectErrors(` - fragment fragA on Human { relatives { ...fragA } }, - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragA" within itself.', - locations: [{ line: 2, column: 45 }], - }, - ]); - }); - - it('no spreading itself directly', () => { - expectErrors(` - fragment fragA on Dog { ...fragA } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragA" within itself.', - locations: [{ line: 2, column: 31 }], - }, - ]); - }); - - it('no spreading itself directly within inline fragment', () => { - expectErrors(` - fragment fragA on Pet { - ... on Dog { - ...fragA - } - } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragA" within itself.', - locations: [{ line: 4, column: 11 }], - }, - ]); - }); - - it('no spreading itself indirectly', () => { - expectErrors(` - fragment fragA on Dog { ...fragB } - fragment fragB on Dog { ...fragA } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragA" within itself via "fragB".', - locations: [ - { line: 2, column: 31 }, - { line: 3, column: 31 }, - ], - }, - ]); - }); - - it('no spreading itself indirectly reports opposite order', () => { - expectErrors(` - fragment fragB on Dog { ...fragA } - fragment fragA on Dog { ...fragB } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragB" within itself via "fragA".', - locations: [ - { line: 2, column: 31 }, - { line: 3, column: 31 }, - ], - }, - ]); - }); - - it('no spreading itself indirectly within inline fragment', () => { - expectErrors(` - fragment fragA on Pet { - ... on Dog { - ...fragB - } - } - fragment fragB on Pet { - ... on Dog { - ...fragA - } - } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragA" within itself via "fragB".', - locations: [ - { line: 4, column: 11 }, - { line: 9, column: 11 }, - ], - }, - ]); - }); - - it('no spreading itself deeply', () => { - expectErrors(` - fragment fragA on Dog { ...fragB } - fragment fragB on Dog { ...fragC } - fragment fragC on Dog { ...fragO } - fragment fragX on Dog { ...fragY } - fragment fragY on Dog { ...fragZ } - fragment fragZ on Dog { ...fragO } - fragment fragO on Dog { ...fragP } - fragment fragP on Dog { ...fragA, ...fragX } - `).toDeepEqual([ - { - message: - 'Cannot spread fragment "fragA" within itself via "fragB", "fragC", "fragO", "fragP".', - locations: [ - { line: 2, column: 31 }, - { line: 3, column: 31 }, - { line: 4, column: 31 }, - { line: 8, column: 31 }, - { line: 9, column: 31 }, - ], - }, - { - message: - 'Cannot spread fragment "fragO" within itself via "fragP", "fragX", "fragY", "fragZ".', - locations: [ - { line: 8, column: 31 }, - { line: 9, column: 41 }, - { line: 5, column: 31 }, - { line: 6, column: 31 }, - { line: 7, column: 31 }, - ], - }, - ]); - }); - - it('no spreading itself deeply two paths', () => { - expectErrors(` - fragment fragA on Dog { ...fragB, ...fragC } - fragment fragB on Dog { ...fragA } - fragment fragC on Dog { ...fragA } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragA" within itself via "fragB".', - locations: [ - { line: 2, column: 31 }, - { line: 3, column: 31 }, - ], - }, - { - message: 'Cannot spread fragment "fragA" within itself via "fragC".', - locations: [ - { line: 2, column: 41 }, - { line: 4, column: 31 }, - ], - }, - ]); - }); - - it('no spreading itself deeply two paths -- alt traverse order', () => { - expectErrors(` - fragment fragA on Dog { ...fragC } - fragment fragB on Dog { ...fragC } - fragment fragC on Dog { ...fragA, ...fragB } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragA" within itself via "fragC".', - locations: [ - { line: 2, column: 31 }, - { line: 4, column: 31 }, - ], - }, - { - message: 'Cannot spread fragment "fragC" within itself via "fragB".', - locations: [ - { line: 4, column: 41 }, - { line: 3, column: 31 }, - ], - }, - ]); - }); - - it('no spreading itself deeply and immediately', () => { - expectErrors(` - fragment fragA on Dog { ...fragB } - fragment fragB on Dog { ...fragB, ...fragC } - fragment fragC on Dog { ...fragA, ...fragB } - `).toDeepEqual([ - { - message: 'Cannot spread fragment "fragB" within itself.', - locations: [{ line: 3, column: 31 }], - }, - { - message: - 'Cannot spread fragment "fragA" within itself via "fragB", "fragC".', - locations: [ - { line: 2, column: 31 }, - { line: 3, column: 41 }, - { line: 4, column: 31 }, - ], - }, - { - message: 'Cannot spread fragment "fragB" within itself via "fragC".', - locations: [ - { line: 3, column: 41 }, - { line: 4, column: 41 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/NoSchemaIntrospectionCustomRule-test.ts b/src/validation/__tests__/NoSchemaIntrospectionCustomRule-test.ts deleted file mode 100644 index cd681a7e68..0000000000 --- a/src/validation/__tests__/NoSchemaIntrospectionCustomRule-test.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { describe, it } from 'mocha'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { NoSchemaIntrospectionCustomRule } from '../rules/custom/NoSchemaIntrospectionCustomRule'; - -import { expectValidationErrorsWithSchema } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrorsWithSchema( - schema, - NoSchemaIntrospectionCustomRule, - queryStr, - ); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -const schema = buildSchema(` - type Query { - someQuery: SomeType - } - - type SomeType { - someField: String - introspectionField: __EnumValue - } -`); - -describe('Validate: Prohibit introspection queries', () => { - it('ignores valid fields including __typename', () => { - expectValid(` - { - someQuery { - __typename - someField - } - } - `); - }); - - it('ignores fields not in the schema', () => { - expectValid(` - { - __introspect - } - `); - }); - - it('reports error when a field with an introspection type is requested', () => { - expectErrors(` - { - __schema { - queryType { - name - } - } - } - `).toDeepEqual([ - { - message: - 'GraphQL introspection has been disabled, but the requested query contained the field "__schema".', - locations: [{ line: 3, column: 9 }], - }, - { - message: - 'GraphQL introspection has been disabled, but the requested query contained the field "queryType".', - locations: [{ line: 4, column: 11 }], - }, - ]); - }); - - it('reports error when a field with an introspection type is requested and aliased', () => { - expectErrors(` - { - s: __schema { - queryType { - name - } - } - } - `).toDeepEqual([ - { - message: - 'GraphQL introspection has been disabled, but the requested query contained the field "__schema".', - locations: [{ line: 3, column: 9 }], - }, - { - message: - 'GraphQL introspection has been disabled, but the requested query contained the field "queryType".', - locations: [{ line: 4, column: 11 }], - }, - ]); - }); - - it('reports error when using a fragment with a field with an introspection type', () => { - expectErrors(` - { - ...QueryFragment - } - - fragment QueryFragment on Query { - __schema { - queryType { - name - } - } - } - `).toDeepEqual([ - { - message: - 'GraphQL introspection has been disabled, but the requested query contained the field "__schema".', - locations: [{ line: 7, column: 9 }], - }, - { - message: - 'GraphQL introspection has been disabled, but the requested query contained the field "queryType".', - locations: [{ line: 8, column: 11 }], - }, - ]); - }); - - it('reports error for non-standard introspection fields', () => { - expectErrors(` - { - someQuery { - introspectionField - } - } - `).toDeepEqual([ - { - message: - 'GraphQL introspection has been disabled, but the requested query contained the field "introspectionField".', - locations: [{ line: 4, column: 11 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/NoUndefinedVariablesRule-test.ts b/src/validation/__tests__/NoUndefinedVariablesRule-test.ts deleted file mode 100644 index e027d4a49b..0000000000 --- a/src/validation/__tests__/NoUndefinedVariablesRule-test.ts +++ /dev/null @@ -1,407 +0,0 @@ -import { describe, it } from 'mocha'; - -import { NoUndefinedVariablesRule } from '../rules/NoUndefinedVariablesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(NoUndefinedVariablesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: No undefined variables', () => { - it('all variables defined', () => { - expectValid(` - query Foo($a: String, $b: String, $c: String) { - field(a: $a, b: $b, c: $c) - } - `); - }); - - it('all variables deeply defined', () => { - expectValid(` - query Foo($a: String, $b: String, $c: String) { - field(a: $a) { - field(b: $b) { - field(c: $c) - } - } - } - `); - }); - - it('all variables deeply in inline fragments defined', () => { - expectValid(` - query Foo($a: String, $b: String, $c: String) { - ... on Type { - field(a: $a) { - field(b: $b) { - ... on Type { - field(c: $c) - } - } - } - } - } - `); - }); - - it('all variables in fragments deeply defined', () => { - expectValid(` - query Foo($a: String, $b: String, $c: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) { - ...FragB - } - } - fragment FragB on Type { - field(b: $b) { - ...FragC - } - } - fragment FragC on Type { - field(c: $c) - } - `); - }); - - it('variable within single fragment defined in multiple operations', () => { - expectValid(` - query Foo($a: String) { - ...FragA - } - query Bar($a: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) - } - `); - }); - - it('variable within fragments defined in operations', () => { - expectValid(` - query Foo($a: String) { - ...FragA - } - query Bar($b: String) { - ...FragB - } - fragment FragA on Type { - field(a: $a) - } - fragment FragB on Type { - field(b: $b) - } - `); - }); - - it('variable within recursive fragment defined', () => { - expectValid(` - query Foo($a: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) { - ...FragA - } - } - `); - }); - - it('variable not defined', () => { - expectErrors(` - query Foo($a: String, $b: String, $c: String) { - field(a: $a, b: $b, c: $c, d: $d) - } - `).toDeepEqual([ - { - message: 'Variable "$d" is not defined by operation "Foo".', - locations: [ - { line: 3, column: 39 }, - { line: 2, column: 7 }, - ], - }, - ]); - }); - - it('variable not defined by un-named query', () => { - expectErrors(` - { - field(a: $a) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is not defined.', - locations: [ - { line: 3, column: 18 }, - { line: 2, column: 7 }, - ], - }, - ]); - }); - - it('multiple variables not defined', () => { - expectErrors(` - query Foo($b: String) { - field(a: $a, b: $b, c: $c) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is not defined by operation "Foo".', - locations: [ - { line: 3, column: 18 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$c" is not defined by operation "Foo".', - locations: [ - { line: 3, column: 32 }, - { line: 2, column: 7 }, - ], - }, - ]); - }); - - it('variable in fragment not defined by un-named query', () => { - expectErrors(` - { - ...FragA - } - fragment FragA on Type { - field(a: $a) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is not defined.', - locations: [ - { line: 6, column: 18 }, - { line: 2, column: 7 }, - ], - }, - ]); - }); - - it('variable in fragment not defined by operation', () => { - expectErrors(` - query Foo($a: String, $b: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) { - ...FragB - } - } - fragment FragB on Type { - field(b: $b) { - ...FragC - } - } - fragment FragC on Type { - field(c: $c) - } - `).toDeepEqual([ - { - message: 'Variable "$c" is not defined by operation "Foo".', - locations: [ - { line: 16, column: 18 }, - { line: 2, column: 7 }, - ], - }, - ]); - }); - - it('multiple variables in fragments not defined', () => { - expectErrors(` - query Foo($b: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) { - ...FragB - } - } - fragment FragB on Type { - field(b: $b) { - ...FragC - } - } - fragment FragC on Type { - field(c: $c) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is not defined by operation "Foo".', - locations: [ - { line: 6, column: 18 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$c" is not defined by operation "Foo".', - locations: [ - { line: 16, column: 18 }, - { line: 2, column: 7 }, - ], - }, - ]); - }); - - it('single variable in fragment not defined by multiple operations', () => { - expectErrors(` - query Foo($a: String) { - ...FragAB - } - query Bar($a: String) { - ...FragAB - } - fragment FragAB on Type { - field(a: $a, b: $b) - } - `).toDeepEqual([ - { - message: 'Variable "$b" is not defined by operation "Foo".', - locations: [ - { line: 9, column: 25 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$b" is not defined by operation "Bar".', - locations: [ - { line: 9, column: 25 }, - { line: 5, column: 7 }, - ], - }, - ]); - }); - - it('variables in fragment not defined by multiple operations', () => { - expectErrors(` - query Foo($b: String) { - ...FragAB - } - query Bar($a: String) { - ...FragAB - } - fragment FragAB on Type { - field(a: $a, b: $b) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is not defined by operation "Foo".', - locations: [ - { line: 9, column: 18 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$b" is not defined by operation "Bar".', - locations: [ - { line: 9, column: 25 }, - { line: 5, column: 7 }, - ], - }, - ]); - }); - - it('variable in fragment used by other operation', () => { - expectErrors(` - query Foo($b: String) { - ...FragA - } - query Bar($a: String) { - ...FragB - } - fragment FragA on Type { - field(a: $a) - } - fragment FragB on Type { - field(b: $b) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is not defined by operation "Foo".', - locations: [ - { line: 9, column: 18 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$b" is not defined by operation "Bar".', - locations: [ - { line: 12, column: 18 }, - { line: 5, column: 7 }, - ], - }, - ]); - }); - - it('multiple undefined variables produce multiple errors', () => { - expectErrors(` - query Foo($b: String) { - ...FragAB - } - query Bar($a: String) { - ...FragAB - } - fragment FragAB on Type { - field1(a: $a, b: $b) - ...FragC - field3(a: $a, b: $b) - } - fragment FragC on Type { - field2(c: $c) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is not defined by operation "Foo".', - locations: [ - { line: 9, column: 19 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$a" is not defined by operation "Foo".', - locations: [ - { line: 11, column: 19 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$c" is not defined by operation "Foo".', - locations: [ - { line: 14, column: 19 }, - { line: 2, column: 7 }, - ], - }, - { - message: 'Variable "$b" is not defined by operation "Bar".', - locations: [ - { line: 9, column: 26 }, - { line: 5, column: 7 }, - ], - }, - { - message: 'Variable "$b" is not defined by operation "Bar".', - locations: [ - { line: 11, column: 26 }, - { line: 5, column: 7 }, - ], - }, - { - message: 'Variable "$c" is not defined by operation "Bar".', - locations: [ - { line: 14, column: 19 }, - { line: 5, column: 7 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/NoUnusedFragmentsRule-test.ts b/src/validation/__tests__/NoUnusedFragmentsRule-test.ts deleted file mode 100644 index abeee19e9f..0000000000 --- a/src/validation/__tests__/NoUnusedFragmentsRule-test.ts +++ /dev/null @@ -1,163 +0,0 @@ -import { describe, it } from 'mocha'; - -import { NoUnusedFragmentsRule } from '../rules/NoUnusedFragmentsRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(NoUnusedFragmentsRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: No unused fragments', () => { - it('all fragment names are used', () => { - expectValid(` - { - human(id: 4) { - ...HumanFields1 - ... on Human { - ...HumanFields2 - } - } - } - fragment HumanFields1 on Human { - name - ...HumanFields3 - } - fragment HumanFields2 on Human { - name - } - fragment HumanFields3 on Human { - name - } - `); - }); - - it('all fragment names are used by multiple operations', () => { - expectValid(` - query Foo { - human(id: 4) { - ...HumanFields1 - } - } - query Bar { - human(id: 4) { - ...HumanFields2 - } - } - fragment HumanFields1 on Human { - name - ...HumanFields3 - } - fragment HumanFields2 on Human { - name - } - fragment HumanFields3 on Human { - name - } - `); - }); - - it('contains unknown fragments', () => { - expectErrors(` - query Foo { - human(id: 4) { - ...HumanFields1 - } - } - query Bar { - human(id: 4) { - ...HumanFields2 - } - } - fragment HumanFields1 on Human { - name - ...HumanFields3 - } - fragment HumanFields2 on Human { - name - } - fragment HumanFields3 on Human { - name - } - fragment Unused1 on Human { - name - } - fragment Unused2 on Human { - name - } - `).toDeepEqual([ - { - message: 'Fragment "Unused1" is never used.', - locations: [{ line: 22, column: 7 }], - }, - { - message: 'Fragment "Unused2" is never used.', - locations: [{ line: 25, column: 7 }], - }, - ]); - }); - - it('contains unknown fragments with ref cycle', () => { - expectErrors(` - query Foo { - human(id: 4) { - ...HumanFields1 - } - } - query Bar { - human(id: 4) { - ...HumanFields2 - } - } - fragment HumanFields1 on Human { - name - ...HumanFields3 - } - fragment HumanFields2 on Human { - name - } - fragment HumanFields3 on Human { - name - } - fragment Unused1 on Human { - name - ...Unused2 - } - fragment Unused2 on Human { - name - ...Unused1 - } - `).toDeepEqual([ - { - message: 'Fragment "Unused1" is never used.', - locations: [{ line: 22, column: 7 }], - }, - { - message: 'Fragment "Unused2" is never used.', - locations: [{ line: 26, column: 7 }], - }, - ]); - }); - - it('contains unknown and undef fragments', () => { - expectErrors(` - query Foo { - human(id: 4) { - ...bar - } - } - fragment foo on Human { - name - } - `).toDeepEqual([ - { - message: 'Fragment "foo" is never used.', - locations: [{ line: 7, column: 7 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/NoUnusedVariablesRule-test.ts b/src/validation/__tests__/NoUnusedVariablesRule-test.ts deleted file mode 100644 index 6be63cd23d..0000000000 --- a/src/validation/__tests__/NoUnusedVariablesRule-test.ts +++ /dev/null @@ -1,233 +0,0 @@ -import { describe, it } from 'mocha'; - -import { NoUnusedVariablesRule } from '../rules/NoUnusedVariablesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(NoUnusedVariablesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: No unused variables', () => { - it('uses all variables', () => { - expectValid(` - query ($a: String, $b: String, $c: String) { - field(a: $a, b: $b, c: $c) - } - `); - }); - - it('uses all variables deeply', () => { - expectValid(` - query Foo($a: String, $b: String, $c: String) { - field(a: $a) { - field(b: $b) { - field(c: $c) - } - } - } - `); - }); - - it('uses all variables deeply in inline fragments', () => { - expectValid(` - query Foo($a: String, $b: String, $c: String) { - ... on Type { - field(a: $a) { - field(b: $b) { - ... on Type { - field(c: $c) - } - } - } - } - } - `); - }); - - it('uses all variables in fragments', () => { - expectValid(` - query Foo($a: String, $b: String, $c: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) { - ...FragB - } - } - fragment FragB on Type { - field(b: $b) { - ...FragC - } - } - fragment FragC on Type { - field(c: $c) - } - `); - }); - - it('variable used by fragment in multiple operations', () => { - expectValid(` - query Foo($a: String) { - ...FragA - } - query Bar($b: String) { - ...FragB - } - fragment FragA on Type { - field(a: $a) - } - fragment FragB on Type { - field(b: $b) - } - `); - }); - - it('variable used by recursive fragment', () => { - expectValid(` - query Foo($a: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) { - ...FragA - } - } - `); - }); - - it('variable not used', () => { - expectErrors(` - query ($a: String, $b: String, $c: String) { - field(a: $a, b: $b) - } - `).toDeepEqual([ - { - message: 'Variable "$c" is never used.', - locations: [{ line: 2, column: 38 }], - }, - ]); - }); - - it('multiple variables not used', () => { - expectErrors(` - query Foo($a: String, $b: String, $c: String) { - field(b: $b) - } - `).toDeepEqual([ - { - message: 'Variable "$a" is never used in operation "Foo".', - locations: [{ line: 2, column: 17 }], - }, - { - message: 'Variable "$c" is never used in operation "Foo".', - locations: [{ line: 2, column: 41 }], - }, - ]); - }); - - it('variable not used in fragments', () => { - expectErrors(` - query Foo($a: String, $b: String, $c: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) { - ...FragB - } - } - fragment FragB on Type { - field(b: $b) { - ...FragC - } - } - fragment FragC on Type { - field - } - `).toDeepEqual([ - { - message: 'Variable "$c" is never used in operation "Foo".', - locations: [{ line: 2, column: 41 }], - }, - ]); - }); - - it('multiple variables not used in fragments', () => { - expectErrors(` - query Foo($a: String, $b: String, $c: String) { - ...FragA - } - fragment FragA on Type { - field { - ...FragB - } - } - fragment FragB on Type { - field(b: $b) { - ...FragC - } - } - fragment FragC on Type { - field - } - `).toDeepEqual([ - { - message: 'Variable "$a" is never used in operation "Foo".', - locations: [{ line: 2, column: 17 }], - }, - { - message: 'Variable "$c" is never used in operation "Foo".', - locations: [{ line: 2, column: 41 }], - }, - ]); - }); - - it('variable not used by unreferenced fragment', () => { - expectErrors(` - query Foo($b: String) { - ...FragA - } - fragment FragA on Type { - field(a: $a) - } - fragment FragB on Type { - field(b: $b) - } - `).toDeepEqual([ - { - message: 'Variable "$b" is never used in operation "Foo".', - locations: [{ line: 2, column: 17 }], - }, - ]); - }); - - it('variable not used by fragment used by other operation', () => { - expectErrors(` - query Foo($b: String) { - ...FragA - } - query Bar($a: String) { - ...FragB - } - fragment FragA on Type { - field(a: $a) - } - fragment FragB on Type { - field(b: $b) - } - `).toDeepEqual([ - { - message: 'Variable "$b" is never used in operation "Foo".', - locations: [{ line: 2, column: 17 }], - }, - { - message: 'Variable "$a" is never used in operation "Bar".', - locations: [{ line: 5, column: 17 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.ts b/src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.ts deleted file mode 100644 index 7418c3e4e8..0000000000 --- a/src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.ts +++ /dev/null @@ -1,1195 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { OverlappingFieldsCanBeMergedRule } from '../rules/OverlappingFieldsCanBeMergedRule'; - -import { - expectValidationErrors, - expectValidationErrorsWithSchema, -} from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(OverlappingFieldsCanBeMergedRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -function expectErrorsWithSchema(schema: GraphQLSchema, queryStr: string) { - return expectValidationErrorsWithSchema( - schema, - OverlappingFieldsCanBeMergedRule, - queryStr, - ); -} - -function expectValidWithSchema(schema: GraphQLSchema, queryStr: string) { - expectErrorsWithSchema(schema, queryStr).toDeepEqual([]); -} - -describe('Validate: Overlapping fields can be merged', () => { - it('unique fields', () => { - expectValid(` - fragment uniqueFields on Dog { - name - nickname - } - `); - }); - - it('identical fields', () => { - expectValid(` - fragment mergeIdenticalFields on Dog { - name - name - } - `); - }); - - it('identical fields with identical args', () => { - expectValid(` - fragment mergeIdenticalFieldsWithIdenticalArgs on Dog { - doesKnowCommand(dogCommand: SIT) - doesKnowCommand(dogCommand: SIT) - } - `); - }); - - it('identical fields with identical directives', () => { - expectValid(` - fragment mergeSameFieldsWithSameDirectives on Dog { - name @include(if: true) - name @include(if: true) - } - `); - }); - - it('different args with different aliases', () => { - expectValid(` - fragment differentArgsWithDifferentAliases on Dog { - knowsSit: doesKnowCommand(dogCommand: SIT) - knowsDown: doesKnowCommand(dogCommand: DOWN) - } - `); - }); - - it('different directives with different aliases', () => { - expectValid(` - fragment differentDirectivesWithDifferentAliases on Dog { - nameIfTrue: name @include(if: true) - nameIfFalse: name @include(if: false) - } - `); - }); - - it('different skip/include directives accepted', () => { - // Note: Differing skip/include directives don't create an ambiguous return - // value and are acceptable in conditions where differing runtime values - // may have the same desired effect of including or skipping a field. - expectValid(` - fragment differentDirectivesWithDifferentAliases on Dog { - name @include(if: true) - name @include(if: false) - } - `); - }); - - it('Same aliases with different field targets', () => { - expectErrors(` - fragment sameAliasesWithDifferentFieldTargets on Dog { - fido: name - fido: nickname - } - `).toDeepEqual([ - { - message: - 'Fields "fido" conflict because "name" and "nickname" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('Same aliases allowed on non-overlapping fields', () => { - // This is valid since no object can be both a "Dog" and a "Cat", thus - // these fields can never overlap. - expectValid(` - fragment sameAliasesWithDifferentFieldTargets on Pet { - ... on Dog { - name - } - ... on Cat { - name: nickname - } - } - `); - }); - - it('Alias masking direct field access', () => { - expectErrors(` - fragment aliasMaskingDirectFieldAccess on Dog { - name: nickname - name - } - `).toDeepEqual([ - { - message: - 'Fields "name" conflict because "nickname" and "name" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('different args, second adds an argument', () => { - expectErrors(` - fragment conflictingArgs on Dog { - doesKnowCommand - doesKnowCommand(dogCommand: HEEL) - } - `).toDeepEqual([ - { - message: - 'Fields "doesKnowCommand" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('different args, second missing an argument', () => { - expectErrors(` - fragment conflictingArgs on Dog { - doesKnowCommand(dogCommand: SIT) - doesKnowCommand - } - `).toDeepEqual([ - { - message: - 'Fields "doesKnowCommand" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('conflicting arg values', () => { - expectErrors(` - fragment conflictingArgs on Dog { - doesKnowCommand(dogCommand: SIT) - doesKnowCommand(dogCommand: HEEL) - } - `).toDeepEqual([ - { - message: - 'Fields "doesKnowCommand" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('conflicting arg names', () => { - expectErrors(` - fragment conflictingArgs on Dog { - isAtLocation(x: 0) - isAtLocation(y: 0) - } - `).toDeepEqual([ - { - message: - 'Fields "isAtLocation" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 9 }, - ], - }, - ]); - }); - - it('allows different args where no conflict is possible', () => { - // This is valid since no object can be both a "Dog" and a "Cat", thus - // these fields can never overlap. - expectValid(` - fragment conflictingArgs on Pet { - ... on Dog { - name(surname: true) - } - ... on Cat { - name - } - } - `); - }); - - it('allows different order of args', () => { - const schema = buildSchema(` - type Query { - someField(a: String, b: String): String - } - `); - - // This is valid since arguments are unordered, see: - // https://spec.graphql.org/draft/#sec-Language.Arguments.Arguments-are-unordered - expectValidWithSchema( - schema, - ` - { - someField(a: null, b: null) - someField(b: null, a: null) - } - `, - ); - }); - - it('allows different order of input object fields in arg values', () => { - const schema = buildSchema(` - input SomeInput { - a: String - b: String - } - - type Query { - someField(arg: SomeInput): String - } - `); - - // This is valid since input object fields are unordered, see: - // https://spec.graphql.org/draft/#sec-Input-Object-Values.Input-object-fields-are-unordered - expectValidWithSchema( - schema, - ` - { - someField(arg: { a: null, b: null }) - someField(arg: { b: null, a: null }) - } - `, - ); - }); - - it('encounters conflict in fragments', () => { - expectErrors(` - { - ...A - ...B - } - fragment A on Type { - x: a - } - fragment B on Type { - x: b - } - `).toDeepEqual([ - { - message: - 'Fields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 7, column: 9 }, - { line: 10, column: 9 }, - ], - }, - ]); - }); - - it('reports each conflict once', () => { - expectErrors(` - { - f1 { - ...A - ...B - } - f2 { - ...B - ...A - } - f3 { - ...A - ...B - x: c - } - } - fragment A on Type { - x: a - } - fragment B on Type { - x: b - } - `).toDeepEqual([ - { - message: - 'Fields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 18, column: 9 }, - { line: 21, column: 9 }, - ], - }, - { - message: - 'Fields "x" conflict because "c" and "a" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 14, column: 11 }, - { line: 18, column: 9 }, - ], - }, - { - message: - 'Fields "x" conflict because "c" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 14, column: 11 }, - { line: 21, column: 9 }, - ], - }, - ]); - }); - - it('deep conflict', () => { - expectErrors(` - { - field { - x: a - }, - field { - x: b - } - } - `).toDeepEqual([ - { - message: - 'Fields "field" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 11 }, - { line: 6, column: 9 }, - { line: 7, column: 11 }, - ], - }, - ]); - }); - - it('deep conflict with multiple issues', () => { - expectErrors(` - { - field { - x: a - y: c - }, - field { - x: b - y: d - } - } - `).toDeepEqual([ - { - message: - 'Fields "field" conflict because subfields "x" conflict because "a" and "b" are different fields and subfields "y" conflict because "c" and "d" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 11 }, - { line: 5, column: 11 }, - { line: 7, column: 9 }, - { line: 8, column: 11 }, - { line: 9, column: 11 }, - ], - }, - ]); - }); - - it('very deep conflict', () => { - expectErrors(` - { - field { - deepField { - x: a - } - }, - field { - deepField { - x: b - } - } - } - `).toDeepEqual([ - { - message: - 'Fields "field" conflict because subfields "deepField" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 4, column: 11 }, - { line: 5, column: 13 }, - { line: 8, column: 9 }, - { line: 9, column: 11 }, - { line: 10, column: 13 }, - ], - }, - ]); - }); - - it('reports deep conflict to nearest common ancestor', () => { - expectErrors(` - { - field { - deepField { - x: a - } - deepField { - x: b - } - }, - field { - deepField { - y - } - } - } - `).toDeepEqual([ - { - message: - 'Fields "deepField" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 4, column: 11 }, - { line: 5, column: 13 }, - { line: 7, column: 11 }, - { line: 8, column: 13 }, - ], - }, - ]); - }); - - it('reports deep conflict to nearest common ancestor in fragments', () => { - expectErrors(` - { - field { - ...F - } - field { - ...F - } - } - fragment F on T { - deepField { - deeperField { - x: a - } - deeperField { - x: b - } - }, - deepField { - deeperField { - y - } - } - } - `).toDeepEqual([ - { - message: - 'Fields "deeperField" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 12, column: 11 }, - { line: 13, column: 13 }, - { line: 15, column: 11 }, - { line: 16, column: 13 }, - ], - }, - ]); - }); - - it('reports deep conflict in nested fragments', () => { - expectErrors(` - { - field { - ...F - } - field { - ...I - } - } - fragment F on T { - x: a - ...G - } - fragment G on T { - y: c - } - fragment I on T { - y: d - ...J - } - fragment J on T { - x: b - } - `).toDeepEqual([ - { - message: - 'Fields "field" conflict because subfields "x" conflict because "a" and "b" are different fields and subfields "y" conflict because "c" and "d" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 11, column: 9 }, - { line: 15, column: 9 }, - { line: 6, column: 9 }, - { line: 22, column: 9 }, - { line: 18, column: 9 }, - ], - }, - ]); - }); - - it('reports deep conflict after nested fragments', () => { - expectErrors(` - fragment F on T { - ...G - } - fragment G on T { - ...H - } - fragment H on T { - x: a - } - { - x: b - ...F - } - `).toDeepEqual([ - { - message: - 'Fields "x" conflict because "b" and "a" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 12, column: 9 }, - { line: 9, column: 9 }, - ], - }, - ]); - }); - - it('ignores unknown fragments', () => { - expectValid(` - { - field - ...Unknown - ...Known - } - - fragment Known on T { - field - ...OtherUnknown - } - `); - }); - - describe('return types must be unambiguous', () => { - const schema = buildSchema(` - interface SomeBox { - deepBox: SomeBox - unrelatedField: String - } - - type StringBox implements SomeBox { - scalar: String - deepBox: StringBox - unrelatedField: String - listStringBox: [StringBox] - stringBox: StringBox - intBox: IntBox - } - - type IntBox implements SomeBox { - scalar: Int - deepBox: IntBox - unrelatedField: String - listStringBox: [StringBox] - stringBox: StringBox - intBox: IntBox - } - - interface NonNullStringBox1 { - scalar: String! - } - - type NonNullStringBox1Impl implements SomeBox & NonNullStringBox1 { - scalar: String! - unrelatedField: String - deepBox: SomeBox - } - - interface NonNullStringBox2 { - scalar: String! - } - - type NonNullStringBox2Impl implements SomeBox & NonNullStringBox2 { - scalar: String! - unrelatedField: String - deepBox: SomeBox - } - - type Connection { - edges: [Edge] - } - - type Edge { - node: Node - } - - type Node { - id: ID - name: String - } - - type Query { - someBox: SomeBox - connection: Connection - } - `); - - it('conflicting return types which potentially overlap', () => { - // This is invalid since an object could potentially be both the Object - // type IntBox and the interface type NonNullStringBox1. While that - // condition does not exist in the current schema, the schema could - // expand in the future to allow this. Thus it is invalid. - expectErrorsWithSchema( - schema, - ` - { - someBox { - ...on IntBox { - scalar - } - ...on NonNullStringBox1 { - scalar - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "scalar" conflict because they return conflicting types "Int" and "String!". Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 5, column: 17 }, - { line: 8, column: 17 }, - ], - }, - ]); - }); - - it('compatible return shapes on different return types', () => { - // In this case `deepBox` returns `SomeBox` in the first usage, and - // `StringBox` in the second usage. These return types are not the same! - // however this is valid because the return *shapes* are compatible. - expectValidWithSchema( - schema, - ` - { - someBox { - ... on SomeBox { - deepBox { - unrelatedField - } - } - ... on StringBox { - deepBox { - unrelatedField - } - } - } - } - `, - ); - }); - - it('disallows differing return types despite no overlap', () => { - expectErrorsWithSchema( - schema, - ` - { - someBox { - ... on IntBox { - scalar - } - ... on StringBox { - scalar - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "scalar" conflict because they return conflicting types "Int" and "String". Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 5, column: 17 }, - { line: 8, column: 17 }, - ], - }, - ]); - }); - - it('reports correctly when a non-exclusive follows an exclusive', () => { - expectErrorsWithSchema( - schema, - ` - { - someBox { - ... on IntBox { - deepBox { - ...X - } - } - } - someBox { - ... on StringBox { - deepBox { - ...Y - } - } - } - memoed: someBox { - ... on IntBox { - deepBox { - ...X - } - } - } - memoed: someBox { - ... on StringBox { - deepBox { - ...Y - } - } - } - other: someBox { - ...X - } - other: someBox { - ...Y - } - } - fragment X on SomeBox { - scalar - } - fragment Y on SomeBox { - scalar: unrelatedField - } - `, - ).toDeepEqual([ - { - message: - 'Fields "other" conflict because subfields "scalar" conflict because "scalar" and "unrelatedField" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 31, column: 13 }, - { line: 39, column: 13 }, - { line: 34, column: 13 }, - { line: 42, column: 13 }, - ], - }, - ]); - }); - - it('disallows differing return type nullability despite no overlap', () => { - expectErrorsWithSchema( - schema, - ` - { - someBox { - ... on NonNullStringBox1 { - scalar - } - ... on StringBox { - scalar - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "scalar" conflict because they return conflicting types "String!" and "String". Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 5, column: 17 }, - { line: 8, column: 17 }, - ], - }, - ]); - }); - - it('disallows differing return type list despite no overlap', () => { - expectErrorsWithSchema( - schema, - ` - { - someBox { - ... on IntBox { - box: listStringBox { - scalar - } - } - ... on StringBox { - box: stringBox { - scalar - } - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "box" conflict because they return conflicting types "[StringBox]" and "StringBox". Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 5, column: 17 }, - { line: 10, column: 17 }, - ], - }, - ]); - - expectErrorsWithSchema( - schema, - ` - { - someBox { - ... on IntBox { - box: stringBox { - scalar - } - } - ... on StringBox { - box: listStringBox { - scalar - } - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "box" conflict because they return conflicting types "StringBox" and "[StringBox]". Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 5, column: 17 }, - { line: 10, column: 17 }, - ], - }, - ]); - }); - - it('disallows differing subfields', () => { - expectErrorsWithSchema( - schema, - ` - { - someBox { - ... on IntBox { - box: stringBox { - val: scalar - val: unrelatedField - } - } - ... on StringBox { - box: stringBox { - val: scalar - } - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "val" conflict because "scalar" and "unrelatedField" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 6, column: 19 }, - { line: 7, column: 19 }, - ], - }, - ]); - }); - - it('disallows differing deep return types despite no overlap', () => { - expectErrorsWithSchema( - schema, - ` - { - someBox { - ... on IntBox { - box: stringBox { - scalar - } - } - ... on StringBox { - box: intBox { - scalar - } - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "box" conflict because subfields "scalar" conflict because they return conflicting types "String" and "Int". Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 5, column: 17 }, - { line: 6, column: 19 }, - { line: 10, column: 17 }, - { line: 11, column: 19 }, - ], - }, - ]); - }); - - it('allows non-conflicting overlapping types', () => { - expectValidWithSchema( - schema, - ` - { - someBox { - ... on IntBox { - scalar: unrelatedField - } - ... on StringBox { - scalar - } - } - } - `, - ); - }); - - it('same wrapped scalar return types', () => { - expectValidWithSchema( - schema, - ` - { - someBox { - ...on NonNullStringBox1 { - scalar - } - ...on NonNullStringBox2 { - scalar - } - } - } - `, - ); - }); - - it('allows inline fragments without type condition', () => { - expectValidWithSchema( - schema, - ` - { - a - ... { - a - } - } - `, - ); - }); - - it('compares deep types including list', () => { - expectErrorsWithSchema( - schema, - ` - { - connection { - ...edgeID - edges { - node { - id: name - } - } - } - } - - fragment edgeID on Connection { - edges { - node { - id - } - } - } - `, - ).toDeepEqual([ - { - message: - 'Fields "edges" conflict because subfields "node" conflict because subfields "id" conflict because "name" and "id" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 5, column: 15 }, - { line: 6, column: 17 }, - { line: 7, column: 19 }, - { line: 14, column: 13 }, - { line: 15, column: 15 }, - { line: 16, column: 17 }, - ], - }, - ]); - }); - - it('ignores unknown types', () => { - expectValidWithSchema( - schema, - ` - { - someBox { - ...on UnknownType { - scalar - } - ...on NonNullStringBox2 { - scalar - } - } - } - `, - ); - }); - - it('works for field names that are JS keywords', () => { - const schemaWithKeywords = buildSchema(` - type Foo { - constructor: String - } - - type Query { - foo: Foo - } - `); - - expectValidWithSchema( - schemaWithKeywords, - ` - { - foo { - constructor - } - } - `, - ); - }); - }); - - it('does not infinite loop on recursive fragment', () => { - expectValid(` - { - ...fragA - } - - fragment fragA on Human { name, relatives { name, ...fragA } } - `); - }); - - it('does not infinite loop on immediately recursive fragment', () => { - expectValid(` - { - ...fragA - } - - fragment fragA on Human { name, ...fragA } - `); - }); - - it('does not infinite loop on recursive fragment with a field named after fragment', () => { - expectValid(` - { - ...fragA - fragA - } - - fragment fragA on Query { ...fragA } - `); - }); - - it('finds invalid cases even with field named after fragment', () => { - expectErrors(` - { - fragA - ...fragA - } - - fragment fragA on Type { - fragA: b - } - `).toDeepEqual([ - { - message: - 'Fields "fragA" conflict because "fragA" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 3, column: 9 }, - { line: 8, column: 9 }, - ], - }, - ]); - }); - - it('does not infinite loop on transitively recursive fragment', () => { - expectValid(` - { - ...fragA - fragB - } - - fragment fragA on Human { name, ...fragB } - fragment fragB on Human { name, ...fragC } - fragment fragC on Human { name, ...fragA } - `); - }); - - it('finds invalid case even with immediately recursive fragment', () => { - expectErrors(` - fragment sameAliasesWithDifferentFieldTargets on Dog { - ...sameAliasesWithDifferentFieldTargets - fido: name - fido: nickname - } - `).toDeepEqual([ - { - message: - 'Fields "fido" conflict because "name" and "nickname" are different fields. Use different aliases on the fields to fetch both if this was intentional.', - locations: [ - { line: 4, column: 9 }, - { line: 5, column: 9 }, - ], - }, - ]); - }); - - it('does not infinite loop on recursive fragments separated by fields', () => { - expectValid(` - { - ...fragA - ...fragB - } - - fragment fragA on T { - x { - ...fragA - x { - ...fragA - } - } - } - - fragment fragB on T { - x { - ...fragB - x { - ...fragB - } - } - } - `); - }); -}); diff --git a/src/validation/__tests__/PossibleFragmentSpreadsRule-test.ts b/src/validation/__tests__/PossibleFragmentSpreadsRule-test.ts deleted file mode 100644 index 3e52f234b5..0000000000 --- a/src/validation/__tests__/PossibleFragmentSpreadsRule-test.ts +++ /dev/null @@ -1,303 +0,0 @@ -import { describe, it } from 'mocha'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { PossibleFragmentSpreadsRule } from '../rules/PossibleFragmentSpreadsRule'; - -import { expectValidationErrorsWithSchema } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrorsWithSchema( - testSchema, - PossibleFragmentSpreadsRule, - queryStr, - ); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -const testSchema = buildSchema(` - interface Being { - name: String - } - - interface Pet implements Being { - name: String - } - - type Dog implements Being & Pet { - name: String - barkVolume: Int - } - - type Cat implements Being & Pet { - name: String - meowVolume: Int - } - - union CatOrDog = Cat | Dog - - interface Intelligent { - iq: Int - } - - type Human implements Being & Intelligent { - name: String - pets: [Pet] - iq: Int - } - - type Alien implements Being & Intelligent { - name: String - iq: Int - } - - union DogOrHuman = Dog | Human - - union HumanOrAlien = Human | Alien - - type Query { - catOrDog: CatOrDog - dogOrHuman: DogOrHuman - humanOrAlien: HumanOrAlien - } -`); - -describe('Validate: Possible fragment spreads', () => { - it('of the same object', () => { - expectValid(` - fragment objectWithinObject on Dog { ...dogFragment } - fragment dogFragment on Dog { barkVolume } - `); - }); - - it('of the same object with inline fragment', () => { - expectValid(` - fragment objectWithinObjectAnon on Dog { ... on Dog { barkVolume } } - `); - }); - - it('object into an implemented interface', () => { - expectValid(` - fragment objectWithinInterface on Pet { ...dogFragment } - fragment dogFragment on Dog { barkVolume } - `); - }); - - it('object into containing union', () => { - expectValid(` - fragment objectWithinUnion on CatOrDog { ...dogFragment } - fragment dogFragment on Dog { barkVolume } - `); - }); - - it('union into contained object', () => { - expectValid(` - fragment unionWithinObject on Dog { ...catOrDogFragment } - fragment catOrDogFragment on CatOrDog { __typename } - `); - }); - - it('union into overlapping interface', () => { - expectValid(` - fragment unionWithinInterface on Pet { ...catOrDogFragment } - fragment catOrDogFragment on CatOrDog { __typename } - `); - }); - - it('union into overlapping union', () => { - expectValid(` - fragment unionWithinUnion on DogOrHuman { ...catOrDogFragment } - fragment catOrDogFragment on CatOrDog { __typename } - `); - }); - - it('interface into implemented object', () => { - expectValid(` - fragment interfaceWithinObject on Dog { ...petFragment } - fragment petFragment on Pet { name } - `); - }); - - it('interface into overlapping interface', () => { - expectValid(` - fragment interfaceWithinInterface on Pet { ...beingFragment } - fragment beingFragment on Being { name } - `); - }); - - it('interface into overlapping interface in inline fragment', () => { - expectValid(` - fragment interfaceWithinInterface on Pet { ... on Being { name } } - `); - }); - - it('interface into overlapping union', () => { - expectValid(` - fragment interfaceWithinUnion on CatOrDog { ...petFragment } - fragment petFragment on Pet { name } - `); - }); - - it('ignores incorrect type (caught by FragmentsOnCompositeTypesRule)', () => { - expectValid(` - fragment petFragment on Pet { ...badInADifferentWay } - fragment badInADifferentWay on String { name } - `); - }); - - it('ignores unknown fragments (caught by KnownFragmentNamesRule)', () => { - expectValid(` - fragment petFragment on Pet { ...UnknownFragment } - `); - }); - - it('different object into object', () => { - expectErrors(` - fragment invalidObjectWithinObject on Cat { ...dogFragment } - fragment dogFragment on Dog { barkVolume } - `).toDeepEqual([ - { - message: - 'Fragment "dogFragment" cannot be spread here as objects of type "Cat" can never be of type "Dog".', - locations: [{ line: 2, column: 51 }], - }, - ]); - }); - - it('different object into object in inline fragment', () => { - expectErrors(` - fragment invalidObjectWithinObjectAnon on Cat { - ... on Dog { barkVolume } - } - `).toDeepEqual([ - { - message: - 'Fragment cannot be spread here as objects of type "Cat" can never be of type "Dog".', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('object into not implementing interface', () => { - expectErrors(` - fragment invalidObjectWithinInterface on Pet { ...humanFragment } - fragment humanFragment on Human { pets { name } } - `).toDeepEqual([ - { - message: - 'Fragment "humanFragment" cannot be spread here as objects of type "Pet" can never be of type "Human".', - locations: [{ line: 2, column: 54 }], - }, - ]); - }); - - it('object into not containing union', () => { - expectErrors(` - fragment invalidObjectWithinUnion on CatOrDog { ...humanFragment } - fragment humanFragment on Human { pets { name } } - `).toDeepEqual([ - { - message: - 'Fragment "humanFragment" cannot be spread here as objects of type "CatOrDog" can never be of type "Human".', - locations: [{ line: 2, column: 55 }], - }, - ]); - }); - - it('union into not contained object', () => { - expectErrors(` - fragment invalidUnionWithinObject on Human { ...catOrDogFragment } - fragment catOrDogFragment on CatOrDog { __typename } - `).toDeepEqual([ - { - message: - 'Fragment "catOrDogFragment" cannot be spread here as objects of type "Human" can never be of type "CatOrDog".', - locations: [{ line: 2, column: 52 }], - }, - ]); - }); - - it('union into non overlapping interface', () => { - expectErrors(` - fragment invalidUnionWithinInterface on Pet { ...humanOrAlienFragment } - fragment humanOrAlienFragment on HumanOrAlien { __typename } - `).toDeepEqual([ - { - message: - 'Fragment "humanOrAlienFragment" cannot be spread here as objects of type "Pet" can never be of type "HumanOrAlien".', - locations: [{ line: 2, column: 53 }], - }, - ]); - }); - - it('union into non overlapping union', () => { - expectErrors(` - fragment invalidUnionWithinUnion on CatOrDog { ...humanOrAlienFragment } - fragment humanOrAlienFragment on HumanOrAlien { __typename } - `).toDeepEqual([ - { - message: - 'Fragment "humanOrAlienFragment" cannot be spread here as objects of type "CatOrDog" can never be of type "HumanOrAlien".', - locations: [{ line: 2, column: 54 }], - }, - ]); - }); - - it('interface into non implementing object', () => { - expectErrors(` - fragment invalidInterfaceWithinObject on Cat { ...intelligentFragment } - fragment intelligentFragment on Intelligent { iq } - `).toDeepEqual([ - { - message: - 'Fragment "intelligentFragment" cannot be spread here as objects of type "Cat" can never be of type "Intelligent".', - locations: [{ line: 2, column: 54 }], - }, - ]); - }); - - it('interface into non overlapping interface', () => { - expectErrors(` - fragment invalidInterfaceWithinInterface on Pet { - ...intelligentFragment - } - fragment intelligentFragment on Intelligent { iq } - `).toDeepEqual([ - { - message: - 'Fragment "intelligentFragment" cannot be spread here as objects of type "Pet" can never be of type "Intelligent".', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('interface into non overlapping interface in inline fragment', () => { - expectErrors(` - fragment invalidInterfaceWithinInterfaceAnon on Pet { - ...on Intelligent { iq } - } - `).toDeepEqual([ - { - message: - 'Fragment cannot be spread here as objects of type "Pet" can never be of type "Intelligent".', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('interface into non overlapping union', () => { - expectErrors(` - fragment invalidInterfaceWithinUnion on HumanOrAlien { ...petFragment } - fragment petFragment on Pet { name } - `).toDeepEqual([ - { - message: - 'Fragment "petFragment" cannot be spread here as objects of type "HumanOrAlien" can never be of type "Pet".', - locations: [{ line: 2, column: 62 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/PossibleTypeExtensionsRule-test.ts b/src/validation/__tests__/PossibleTypeExtensionsRule-test.ts deleted file mode 100644 index e29c097bdb..0000000000 --- a/src/validation/__tests__/PossibleTypeExtensionsRule-test.ts +++ /dev/null @@ -1,271 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { PossibleTypeExtensionsRule } from '../rules/PossibleTypeExtensionsRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, PossibleTypeExtensionsRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Possible type extensions', () => { - it('no extensions', () => { - expectValidSDL(` - scalar FooScalar - type FooObject - interface FooInterface - union FooUnion - enum FooEnum - input FooInputObject - `); - }); - - it('one extension per type', () => { - expectValidSDL(` - scalar FooScalar - type FooObject - interface FooInterface - union FooUnion - enum FooEnum - input FooInputObject - - extend scalar FooScalar @dummy - extend type FooObject @dummy - extend interface FooInterface @dummy - extend union FooUnion @dummy - extend enum FooEnum @dummy - extend input FooInputObject @dummy - `); - }); - - it('many extensions per type', () => { - expectValidSDL(` - scalar FooScalar - type FooObject - interface FooInterface - union FooUnion - enum FooEnum - input FooInputObject - - extend scalar FooScalar @dummy - extend type FooObject @dummy - extend interface FooInterface @dummy - extend union FooUnion @dummy - extend enum FooEnum @dummy - extend input FooInputObject @dummy - - extend scalar FooScalar @dummy - extend type FooObject @dummy - extend interface FooInterface @dummy - extend union FooUnion @dummy - extend enum FooEnum @dummy - extend input FooInputObject @dummy - `); - }); - - it('extending unknown type', () => { - const message = - 'Cannot extend type "Unknown" because it is not defined. Did you mean "Known"?'; - - expectSDLErrors(` - type Known - - extend scalar Unknown @dummy - extend type Unknown @dummy - extend interface Unknown @dummy - extend union Unknown @dummy - extend enum Unknown @dummy - extend input Unknown @dummy - `).toDeepEqual([ - { message, locations: [{ line: 4, column: 21 }] }, - { message, locations: [{ line: 5, column: 19 }] }, - { message, locations: [{ line: 6, column: 24 }] }, - { message, locations: [{ line: 7, column: 20 }] }, - { message, locations: [{ line: 8, column: 19 }] }, - { message, locations: [{ line: 9, column: 20 }] }, - ]); - }); - - it('does not consider non-type definitions', () => { - const message = 'Cannot extend type "Foo" because it is not defined.'; - - expectSDLErrors(` - query Foo { __typename } - fragment Foo on Query { __typename } - directive @Foo on SCHEMA - - extend scalar Foo @dummy - extend type Foo @dummy - extend interface Foo @dummy - extend union Foo @dummy - extend enum Foo @dummy - extend input Foo @dummy - `).toDeepEqual([ - { message, locations: [{ line: 6, column: 21 }] }, - { message, locations: [{ line: 7, column: 19 }] }, - { message, locations: [{ line: 8, column: 24 }] }, - { message, locations: [{ line: 9, column: 20 }] }, - { message, locations: [{ line: 10, column: 19 }] }, - { message, locations: [{ line: 11, column: 20 }] }, - ]); - }); - - it('extending with different kinds', () => { - expectSDLErrors(` - scalar FooScalar - type FooObject - interface FooInterface - union FooUnion - enum FooEnum - input FooInputObject - - extend type FooScalar @dummy - extend interface FooObject @dummy - extend union FooInterface @dummy - extend enum FooUnion @dummy - extend input FooEnum @dummy - extend scalar FooInputObject @dummy - `).toDeepEqual([ - { - message: 'Cannot extend non-object type "FooScalar".', - locations: [ - { line: 2, column: 7 }, - { line: 9, column: 7 }, - ], - }, - { - message: 'Cannot extend non-interface type "FooObject".', - locations: [ - { line: 3, column: 7 }, - { line: 10, column: 7 }, - ], - }, - { - message: 'Cannot extend non-union type "FooInterface".', - locations: [ - { line: 4, column: 7 }, - { line: 11, column: 7 }, - ], - }, - { - message: 'Cannot extend non-enum type "FooUnion".', - locations: [ - { line: 5, column: 7 }, - { line: 12, column: 7 }, - ], - }, - { - message: 'Cannot extend non-input object type "FooEnum".', - locations: [ - { line: 6, column: 7 }, - { line: 13, column: 7 }, - ], - }, - { - message: 'Cannot extend non-scalar type "FooInputObject".', - locations: [ - { line: 7, column: 7 }, - { line: 14, column: 7 }, - ], - }, - ]); - }); - - it('extending types within existing schema', () => { - const schema = buildSchema(` - scalar FooScalar - type FooObject - interface FooInterface - union FooUnion - enum FooEnum - input FooInputObject - `); - const sdl = ` - extend scalar FooScalar @dummy - extend type FooObject @dummy - extend interface FooInterface @dummy - extend union FooUnion @dummy - extend enum FooEnum @dummy - extend input FooInputObject @dummy - `; - - expectValidSDL(sdl, schema); - }); - - it('extending unknown types within existing schema', () => { - const schema = buildSchema('type Known'); - const sdl = ` - extend scalar Unknown @dummy - extend type Unknown @dummy - extend interface Unknown @dummy - extend union Unknown @dummy - extend enum Unknown @dummy - extend input Unknown @dummy - `; - - const message = - 'Cannot extend type "Unknown" because it is not defined. Did you mean "Known"?'; - expectSDLErrors(sdl, schema).toDeepEqual([ - { message, locations: [{ line: 2, column: 21 }] }, - { message, locations: [{ line: 3, column: 19 }] }, - { message, locations: [{ line: 4, column: 24 }] }, - { message, locations: [{ line: 5, column: 20 }] }, - { message, locations: [{ line: 6, column: 19 }] }, - { message, locations: [{ line: 7, column: 20 }] }, - ]); - }); - - it('extending types with different kinds within existing schema', () => { - const schema = buildSchema(` - scalar FooScalar - type FooObject - interface FooInterface - union FooUnion - enum FooEnum - input FooInputObject - `); - const sdl = ` - extend type FooScalar @dummy - extend interface FooObject @dummy - extend union FooInterface @dummy - extend enum FooUnion @dummy - extend input FooEnum @dummy - extend scalar FooInputObject @dummy - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: 'Cannot extend non-object type "FooScalar".', - locations: [{ line: 2, column: 7 }], - }, - { - message: 'Cannot extend non-interface type "FooObject".', - locations: [{ line: 3, column: 7 }], - }, - { - message: 'Cannot extend non-union type "FooInterface".', - locations: [{ line: 4, column: 7 }], - }, - { - message: 'Cannot extend non-enum type "FooUnion".', - locations: [{ line: 5, column: 7 }], - }, - { - message: 'Cannot extend non-input object type "FooEnum".', - locations: [{ line: 6, column: 7 }], - }, - { - message: 'Cannot extend non-scalar type "FooInputObject".', - locations: [{ line: 7, column: 7 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/ProvidedRequiredArgumentsRule-test.ts b/src/validation/__tests__/ProvidedRequiredArgumentsRule-test.ts deleted file mode 100644 index 23a272572c..0000000000 --- a/src/validation/__tests__/ProvidedRequiredArgumentsRule-test.ts +++ /dev/null @@ -1,356 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { - ProvidedRequiredArgumentsOnDirectivesRule, - ProvidedRequiredArgumentsRule, -} from '../rules/ProvidedRequiredArgumentsRule'; - -import { expectSDLValidationErrors, expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(ProvidedRequiredArgumentsRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors( - schema, - ProvidedRequiredArgumentsOnDirectivesRule, - sdlStr, - ); -} - -function expectValidSDL(sdlStr: string) { - expectSDLErrors(sdlStr).toDeepEqual([]); -} - -describe('Validate: Provided required arguments', () => { - it('ignores unknown arguments', () => { - expectValid(` - { - dog { - isHouseTrained(unknownArgument: true) - } - } - `); - }); - - describe('Valid non-nullable value', () => { - it('Arg on optional arg', () => { - expectValid(` - { - dog { - isHouseTrained(atOtherHomes: true) - } - } - `); - }); - - it('No Arg on optional arg', () => { - expectValid(` - { - dog { - isHouseTrained - } - } - `); - }); - - it('No arg on non-null field with default', () => { - expectValid(` - { - complicatedArgs { - nonNullFieldWithDefault - } - } - `); - }); - - it('Multiple args', () => { - expectValid(` - { - complicatedArgs { - multipleReqs(req1: 1, req2: 2) - } - } - `); - }); - - it('Multiple args reverse order', () => { - expectValid(` - { - complicatedArgs { - multipleReqs(req2: 2, req1: 1) - } - } - `); - }); - - it('No args on multiple optional', () => { - expectValid(` - { - complicatedArgs { - multipleOpts - } - } - `); - }); - - it('One arg on multiple optional', () => { - expectValid(` - { - complicatedArgs { - multipleOpts(opt1: 1) - } - } - `); - }); - - it('Second arg on multiple optional', () => { - expectValid(` - { - complicatedArgs { - multipleOpts(opt2: 1) - } - } - `); - }); - - it('Multiple required args on mixedList', () => { - expectValid(` - { - complicatedArgs { - multipleOptAndReq(req1: 3, req2: 4) - } - } - `); - }); - - it('Multiple required and one optional arg on mixedList', () => { - expectValid(` - { - complicatedArgs { - multipleOptAndReq(req1: 3, req2: 4, opt1: 5) - } - } - `); - }); - - it('All required and optional args on mixedList', () => { - expectValid(` - { - complicatedArgs { - multipleOptAndReq(req1: 3, req2: 4, opt1: 5, opt2: 6) - } - } - `); - }); - }); - - describe('Invalid non-nullable value', () => { - it('Missing one non-nullable argument', () => { - expectErrors(` - { - complicatedArgs { - multipleReqs(req2: 2) - } - } - `).toDeepEqual([ - { - message: - 'Field "multipleReqs" argument "req1" of type "Int!" is required, but it was not provided.', - locations: [{ line: 4, column: 13 }], - }, - ]); - }); - - it('Missing multiple non-nullable arguments', () => { - expectErrors(` - { - complicatedArgs { - multipleReqs - } - } - `).toDeepEqual([ - { - message: - 'Field "multipleReqs" argument "req1" of type "Int!" is required, but it was not provided.', - locations: [{ line: 4, column: 13 }], - }, - { - message: - 'Field "multipleReqs" argument "req2" of type "Int!" is required, but it was not provided.', - locations: [{ line: 4, column: 13 }], - }, - ]); - }); - - it('Incorrect value and missing argument', () => { - expectErrors(` - { - complicatedArgs { - multipleReqs(req1: "one") - } - } - `).toDeepEqual([ - { - message: - 'Field "multipleReqs" argument "req2" of type "Int!" is required, but it was not provided.', - locations: [{ line: 4, column: 13 }], - }, - ]); - }); - }); - - describe('Directive arguments', () => { - it('ignores unknown directives', () => { - expectValid(` - { - dog @unknown - } - `); - }); - - it('with directives of valid types', () => { - expectValid(` - { - dog @include(if: true) { - name - } - human @skip(if: false) { - name - } - } - `); - }); - - it('with directive with missing types', () => { - expectErrors(` - { - dog @include { - name @skip - } - } - `).toDeepEqual([ - { - message: - 'Directive "@include" argument "if" of type "Boolean!" is required, but it was not provided.', - locations: [{ line: 3, column: 15 }], - }, - { - message: - 'Directive "@skip" argument "if" of type "Boolean!" is required, but it was not provided.', - locations: [{ line: 4, column: 18 }], - }, - ]); - }); - }); - - describe('within SDL', () => { - it('Missing optional args on directive defined inside SDL', () => { - expectValidSDL(` - type Query { - foo: String @test - } - - directive @test(arg1: String, arg2: String! = "") on FIELD_DEFINITION - `); - }); - - it('Missing arg on directive defined inside SDL', () => { - expectSDLErrors(` - type Query { - foo: String @test - } - - directive @test(arg: String!) on FIELD_DEFINITION - `).toDeepEqual([ - { - message: - 'Directive "@test" argument "arg" of type "String!" is required, but it was not provided.', - locations: [{ line: 3, column: 23 }], - }, - ]); - }); - - it('Missing arg on standard directive', () => { - expectSDLErrors(` - type Query { - foo: String @include - } - `).toDeepEqual([ - { - message: - 'Directive "@include" argument "if" of type "Boolean!" is required, but it was not provided.', - locations: [{ line: 3, column: 23 }], - }, - ]); - }); - - it('Missing arg on overridden standard directive', () => { - expectSDLErrors(` - type Query { - foo: String @deprecated - } - directive @deprecated(reason: String!) on FIELD - `).toDeepEqual([ - { - message: - 'Directive "@deprecated" argument "reason" of type "String!" is required, but it was not provided.', - locations: [{ line: 3, column: 23 }], - }, - ]); - }); - - it('Missing arg on directive defined in schema extension', () => { - const schema = buildSchema(` - type Query { - foo: String - } - `); - expectSDLErrors( - ` - directive @test(arg: String!) on OBJECT - - extend type Query @test - `, - schema, - ).toDeepEqual([ - { - message: - 'Directive "@test" argument "arg" of type "String!" is required, but it was not provided.', - locations: [{ line: 4, column: 30 }], - }, - ]); - }); - - it('Missing arg on directive used in schema extension', () => { - const schema = buildSchema(` - directive @test(arg: String!) on OBJECT - - type Query { - foo: String - } - `); - expectSDLErrors( - ` - extend type Query @test - `, - schema, - ).toDeepEqual([ - { - message: - 'Directive "@test" argument "arg" of type "String!" is required, but it was not provided.', - locations: [{ line: 2, column: 29 }], - }, - ]); - }); - }); -}); diff --git a/src/validation/__tests__/ScalarLeafsRule-test.ts b/src/validation/__tests__/ScalarLeafsRule-test.ts deleted file mode 100644 index 0f0d8e18cb..0000000000 --- a/src/validation/__tests__/ScalarLeafsRule-test.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import type { DocumentNode } from '../../language/ast'; -import { OperationTypeNode } from '../../language/ast'; -import { Kind } from '../../language/kinds'; - -import { ScalarLeafsRule } from '../rules/ScalarLeafsRule'; -import { validate } from '../validate'; - -import { expectValidationErrors, testSchema } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(ScalarLeafsRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Scalar leafs', () => { - it('valid scalar selection', () => { - expectValid(` - fragment scalarSelection on Dog { - barks - } - `); - }); - - it('object type missing selection', () => { - expectErrors(` - query directQueryOnObjectWithoutSubFields { - human - } - `).toDeepEqual([ - { - message: - 'Field "human" of type "Human" must have a selection of subfields. Did you mean "human { ... }"?', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('interface type missing selection', () => { - expectErrors(` - { - human { pets } - } - `).toDeepEqual([ - { - message: - 'Field "pets" of type "[Pet]" must have a selection of subfields. Did you mean "pets { ... }"?', - locations: [{ line: 3, column: 17 }], - }, - ]); - }); - - it('valid scalar selection with args', () => { - expectValid(` - fragment scalarSelectionWithArgs on Dog { - doesKnowCommand(dogCommand: SIT) - } - `); - }); - - it('scalar selection not allowed on Boolean', () => { - expectErrors(` - fragment scalarSelectionsNotAllowedOnBoolean on Dog { - barks { sinceWhen } - } - `).toDeepEqual([ - { - message: - 'Field "barks" must not have a selection since type "Boolean" has no subfields.', - locations: [{ line: 3, column: 15 }], - }, - ]); - }); - - it('scalar selection not allowed on Enum', () => { - expectErrors(` - fragment scalarSelectionsNotAllowedOnEnum on Cat { - furColor { inHexDec } - } - `).toDeepEqual([ - { - message: - 'Field "furColor" must not have a selection since type "FurColor" has no subfields.', - locations: [{ line: 3, column: 18 }], - }, - ]); - }); - - it('scalar selection not allowed with args', () => { - expectErrors(` - fragment scalarSelectionsNotAllowedWithArgs on Dog { - doesKnowCommand(dogCommand: SIT) { sinceWhen } - } - `).toDeepEqual([ - { - message: - 'Field "doesKnowCommand" must not have a selection since type "Boolean" has no subfields.', - locations: [{ line: 3, column: 42 }], - }, - ]); - }); - - it('Scalar selection not allowed with directives', () => { - expectErrors(` - fragment scalarSelectionsNotAllowedWithDirectives on Dog { - name @include(if: true) { isAlsoHumanName } - } - `).toDeepEqual([ - { - message: - 'Field "name" must not have a selection since type "String" has no subfields.', - locations: [{ line: 3, column: 33 }], - }, - ]); - }); - - it('Scalar selection not allowed with directives and args', () => { - expectErrors(` - fragment scalarSelectionsNotAllowedWithDirectivesAndArgs on Dog { - doesKnowCommand(dogCommand: SIT) @include(if: true) { sinceWhen } - } - `).toDeepEqual([ - { - message: - 'Field "doesKnowCommand" must not have a selection since type "Boolean" has no subfields.', - locations: [{ line: 3, column: 61 }], - }, - ]); - }); - - it('object type having only one selection', () => { - const doc: DocumentNode = { - kind: Kind.DOCUMENT, - definitions: [ - { - kind: Kind.OPERATION_DEFINITION, - operation: OperationTypeNode.QUERY, - selectionSet: { - kind: Kind.SELECTION_SET, - selections: [ - { - kind: Kind.FIELD, - name: { kind: Kind.NAME, value: 'human' }, - selectionSet: { kind: Kind.SELECTION_SET, selections: [] }, - }, - ], - }, - }, - ], - }; - - // We can't leverage expectErrors since it doesn't support passing in the - // documentNode directly. We have to do this because this is technically - // an invalid document. - const errors = validate(testSchema, doc, [ScalarLeafsRule]); - expectJSON(errors).toDeepEqual([ - { - message: - 'Field "human" of type "Human" must have at least one field selected.', - }, - ]); - }); -}); diff --git a/src/validation/__tests__/SingleFieldSubscriptionsRule-test.ts b/src/validation/__tests__/SingleFieldSubscriptionsRule-test.ts deleted file mode 100644 index e0d3789299..0000000000 --- a/src/validation/__tests__/SingleFieldSubscriptionsRule-test.ts +++ /dev/null @@ -1,306 +0,0 @@ -import { describe, it } from 'mocha'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { SingleFieldSubscriptionsRule } from '../rules/SingleFieldSubscriptionsRule'; - -import { expectValidationErrorsWithSchema } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrorsWithSchema( - schema, - SingleFieldSubscriptionsRule, - queryStr, - ); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -const schema = buildSchema(` - type Message { - body: String - sender: String - } - - type SubscriptionRoot { - importantEmails: [String] - notImportantEmails: [String] - moreImportantEmails: [String] - spamEmails: [String] - deletedEmails: [String] - newMessage: Message - } - - type QueryRoot { - dummy: String - } - - schema { - query: QueryRoot - subscription: SubscriptionRoot - } -`); - -describe('Validate: Subscriptions with single field', () => { - it('valid subscription', () => { - expectValid(` - subscription ImportantEmails { - importantEmails - } - `); - }); - - it('valid subscription with fragment', () => { - // From https://spec.graphql.org/draft/#example-13061 - expectValid(` - subscription sub { - ...newMessageFields - } - - fragment newMessageFields on SubscriptionRoot { - newMessage { - body - sender - } - } - `); - }); - - it('valid subscription with fragment and field', () => { - // From https://spec.graphql.org/draft/#example-13061 - expectValid(` - subscription sub { - newMessage { - body - } - ...newMessageFields - } - - fragment newMessageFields on SubscriptionRoot { - newMessage { - body - sender - } - } - `); - }); - - it('fails with more than one root field', () => { - expectErrors(` - subscription ImportantEmails { - importantEmails - notImportantEmails - } - `).toDeepEqual([ - { - message: - 'Subscription "ImportantEmails" must select only one top level field.', - locations: [{ line: 4, column: 9 }], - }, - ]); - }); - - it('fails with more than one root field including introspection', () => { - expectErrors(` - subscription ImportantEmails { - importantEmails - __typename - } - `).toDeepEqual([ - { - message: - 'Subscription "ImportantEmails" must select only one top level field.', - locations: [{ line: 4, column: 9 }], - }, - { - message: - 'Subscription "ImportantEmails" must not select an introspection top level field.', - locations: [{ line: 4, column: 9 }], - }, - ]); - }); - - it('fails with more than one root field including aliased introspection via fragment', () => { - expectErrors(` - subscription ImportantEmails { - importantEmails - ...Introspection - } - fragment Introspection on SubscriptionRoot { - typename: __typename - } - `).toDeepEqual([ - { - message: - 'Subscription "ImportantEmails" must select only one top level field.', - locations: [{ line: 7, column: 9 }], - }, - { - message: - 'Subscription "ImportantEmails" must not select an introspection top level field.', - locations: [{ line: 7, column: 9 }], - }, - ]); - }); - - it('fails with many more than one root field', () => { - expectErrors(` - subscription ImportantEmails { - importantEmails - notImportantEmails - spamEmails - } - `).toDeepEqual([ - { - message: - 'Subscription "ImportantEmails" must select only one top level field.', - locations: [ - { line: 4, column: 9 }, - { line: 5, column: 9 }, - ], - }, - ]); - }); - - it('fails with many more than one root field via fragments', () => { - expectErrors(` - subscription ImportantEmails { - importantEmails - ... { - more: moreImportantEmails - } - ...NotImportantEmails - } - fragment NotImportantEmails on SubscriptionRoot { - notImportantEmails - deleted: deletedEmails - ...SpamEmails - } - fragment SpamEmails on SubscriptionRoot { - spamEmails - } - `).toDeepEqual([ - { - message: - 'Subscription "ImportantEmails" must select only one top level field.', - locations: [ - { line: 5, column: 11 }, - { line: 10, column: 9 }, - { line: 11, column: 9 }, - { line: 15, column: 9 }, - ], - }, - ]); - }); - - it('does not infinite loop on recursive fragments', () => { - expectErrors(` - subscription NoInfiniteLoop { - ...A - } - fragment A on SubscriptionRoot { - ...A - } - `).toDeepEqual([]); - }); - - it('fails with many more than one root field via fragments (anonymous)', () => { - expectErrors(` - subscription { - importantEmails - ... { - more: moreImportantEmails - ...NotImportantEmails - } - ...NotImportantEmails - } - fragment NotImportantEmails on SubscriptionRoot { - notImportantEmails - deleted: deletedEmails - ... { - ... { - archivedEmails - } - } - ...SpamEmails - } - fragment SpamEmails on SubscriptionRoot { - spamEmails - ...NonExistentFragment - } - `).toDeepEqual([ - { - message: 'Anonymous Subscription must select only one top level field.', - locations: [ - { line: 5, column: 11 }, - { line: 11, column: 9 }, - { line: 12, column: 9 }, - { line: 15, column: 13 }, - { line: 21, column: 9 }, - ], - }, - ]); - }); - - it('fails with more than one root field in anonymous subscriptions', () => { - expectErrors(` - subscription { - importantEmails - notImportantEmails - } - `).toDeepEqual([ - { - message: 'Anonymous Subscription must select only one top level field.', - locations: [{ line: 4, column: 9 }], - }, - ]); - }); - - it('fails with introspection field', () => { - expectErrors(` - subscription ImportantEmails { - __typename - } - `).toDeepEqual([ - { - message: - 'Subscription "ImportantEmails" must not select an introspection top level field.', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('fails with introspection field in anonymous subscription', () => { - expectErrors(` - subscription { - __typename - } - `).toDeepEqual([ - { - message: - 'Anonymous Subscription must not select an introspection top level field.', - locations: [{ line: 3, column: 9 }], - }, - ]); - }); - - it('skips if not subscription type', () => { - const emptySchema = buildSchema(` - type Query { - dummy: String - } - `); - - expectValidationErrorsWithSchema( - emptySchema, - SingleFieldSubscriptionsRule, - ` - subscription { - __typename - } - `, - ).toDeepEqual([]); - }); -}); diff --git a/src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts b/src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts deleted file mode 100644 index cf63202b52..0000000000 --- a/src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { describe, it } from 'mocha'; - -import { UniqueArgumentDefinitionNamesRule } from '../rules/UniqueArgumentDefinitionNamesRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string) { - return expectSDLValidationErrors( - undefined, - UniqueArgumentDefinitionNamesRule, - sdlStr, - ); -} - -function expectValidSDL(sdlStr: string) { - expectSDLErrors(sdlStr).toDeepEqual([]); -} - -describe('Validate: Unique argument definition names', () => { - it('no args', () => { - expectValidSDL(` - type SomeObject { - someField: String - } - - interface SomeInterface { - someField: String - } - - directive @someDirective on QUERY - `); - }); - - it('one argument', () => { - expectValidSDL(` - type SomeObject { - someField(foo: String): String - } - - interface SomeInterface { - someField(foo: String): String - } - - extend type SomeObject { - anotherField(foo: String): String - } - - extend interface SomeInterface { - anotherField(foo: String): String - } - - directive @someDirective(foo: String) on QUERY - `); - }); - - it('multiple arguments', () => { - expectValidSDL(` - type SomeObject { - someField( - foo: String - bar: String - ): String - } - - interface SomeInterface { - someField( - foo: String - bar: String - ): String - } - - extend type SomeObject { - anotherField( - foo: String - bar: String - ): String - } - - extend interface SomeInterface { - anotherField( - foo: String - bar: String - ): String - } - - directive @someDirective( - foo: String - bar: String - ) on QUERY - `); - }); - - it('duplicating arguments', () => { - expectSDLErrors(` - type SomeObject { - someField( - foo: String - bar: String - foo: String - ): String - } - - interface SomeInterface { - someField( - foo: String - bar: String - foo: String - ): String - } - - extend type SomeObject { - anotherField( - foo: String - bar: String - bar: String - ): String - } - - extend interface SomeInterface { - anotherField( - bar: String - foo: String - foo: String - ): String - } - - directive @someDirective( - foo: String - bar: String - foo: String - ) on QUERY - `).toDeepEqual([ - { - message: - 'Argument "SomeObject.someField(foo:)" can only be defined once.', - locations: [ - { line: 4, column: 11 }, - { line: 6, column: 11 }, - ], - }, - { - message: - 'Argument "SomeInterface.someField(foo:)" can only be defined once.', - locations: [ - { line: 12, column: 11 }, - { line: 14, column: 11 }, - ], - }, - { - message: - 'Argument "SomeObject.anotherField(bar:)" can only be defined once.', - locations: [ - { line: 21, column: 11 }, - { line: 22, column: 11 }, - ], - }, - { - message: - 'Argument "SomeInterface.anotherField(foo:)" can only be defined once.', - locations: [ - { line: 29, column: 11 }, - { line: 30, column: 11 }, - ], - }, - { - message: 'Argument "@someDirective(foo:)" can only be defined once.', - locations: [ - { line: 35, column: 9 }, - { line: 37, column: 9 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueArgumentNamesRule-test.ts b/src/validation/__tests__/UniqueArgumentNamesRule-test.ts deleted file mode 100644 index f5709e321a..0000000000 --- a/src/validation/__tests__/UniqueArgumentNamesRule-test.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { describe, it } from 'mocha'; - -import { UniqueArgumentNamesRule } from '../rules/UniqueArgumentNamesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(UniqueArgumentNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Unique argument names', () => { - it('no arguments on field', () => { - expectValid(` - { - field - } - `); - }); - - it('no arguments on directive', () => { - expectValid(` - { - field @directive - } - `); - }); - - it('argument on field', () => { - expectValid(` - { - field(arg: "value") - } - `); - }); - - it('argument on directive', () => { - expectValid(` - { - field @directive(arg: "value") - } - `); - }); - - it('same argument on two fields', () => { - expectValid(` - { - one: field(arg: "value") - two: field(arg: "value") - } - `); - }); - - it('same argument on field and directive', () => { - expectValid(` - { - field(arg: "value") @directive(arg: "value") - } - `); - }); - - it('same argument on two directives', () => { - expectValid(` - { - field @directive1(arg: "value") @directive2(arg: "value") - } - `); - }); - - it('multiple field arguments', () => { - expectValid(` - { - field(arg1: "value", arg2: "value", arg3: "value") - } - `); - }); - - it('multiple directive arguments', () => { - expectValid(` - { - field @directive(arg1: "value", arg2: "value", arg3: "value") - } - `); - }); - - it('duplicate field arguments', () => { - expectErrors(` - { - field(arg1: "value", arg1: "value") - } - `).toDeepEqual([ - { - message: 'There can be only one argument named "arg1".', - locations: [ - { line: 3, column: 15 }, - { line: 3, column: 30 }, - ], - }, - ]); - }); - - it('many duplicate field arguments', () => { - expectErrors(` - { - field(arg1: "value", arg1: "value", arg1: "value") - } - `).toDeepEqual([ - { - message: 'There can be only one argument named "arg1".', - locations: [ - { line: 3, column: 15 }, - { line: 3, column: 30 }, - { line: 3, column: 45 }, - ], - }, - ]); - }); - - it('duplicate directive arguments', () => { - expectErrors(` - { - field @directive(arg1: "value", arg1: "value") - } - `).toDeepEqual([ - { - message: 'There can be only one argument named "arg1".', - locations: [ - { line: 3, column: 26 }, - { line: 3, column: 41 }, - ], - }, - ]); - }); - - it('many duplicate directive arguments', () => { - expectErrors(` - { - field @directive(arg1: "value", arg1: "value", arg1: "value") - } - `).toDeepEqual([ - { - message: 'There can be only one argument named "arg1".', - locations: [ - { line: 3, column: 26 }, - { line: 3, column: 41 }, - { line: 3, column: 56 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueDirectiveNamesRule-test.ts b/src/validation/__tests__/UniqueDirectiveNamesRule-test.ts deleted file mode 100644 index a632af286a..0000000000 --- a/src/validation/__tests__/UniqueDirectiveNamesRule-test.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { UniqueDirectiveNamesRule } from '../rules/UniqueDirectiveNamesRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, UniqueDirectiveNamesRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Unique directive names', () => { - it('no directive', () => { - expectValidSDL(` - type Foo - `); - }); - - it('one directive', () => { - expectValidSDL(` - directive @foo on SCHEMA - `); - }); - - it('many directives', () => { - expectValidSDL(` - directive @foo on SCHEMA - directive @bar on SCHEMA - directive @baz on SCHEMA - `); - }); - - it('directive and non-directive definitions named the same', () => { - expectValidSDL(` - query foo { __typename } - fragment foo on foo { __typename } - type foo - - directive @foo on SCHEMA - `); - }); - - it('directives named the same', () => { - expectSDLErrors(` - directive @foo on SCHEMA - - directive @foo on SCHEMA - `).toDeepEqual([ - { - message: 'There can be only one directive named "@foo".', - locations: [ - { line: 2, column: 18 }, - { line: 4, column: 18 }, - ], - }, - ]); - }); - - it('adding new directive to existing schema', () => { - const schema = buildSchema('directive @foo on SCHEMA'); - - expectValidSDL('directive @bar on SCHEMA', schema); - }); - - it('adding new directive with standard name to existing schema', () => { - const schema = buildSchema('type foo'); - - expectSDLErrors('directive @skip on SCHEMA', schema).toDeepEqual([ - { - message: - 'Directive "@skip" already exists in the schema. It cannot be redefined.', - locations: [{ line: 1, column: 12 }], - }, - ]); - }); - - it('adding new directive to existing schema with same-named type', () => { - const schema = buildSchema('type foo'); - - expectValidSDL('directive @foo on SCHEMA', schema); - }); - - it('adding conflicting directives to existing schema', () => { - const schema = buildSchema('directive @foo on SCHEMA'); - - expectSDLErrors('directive @foo on SCHEMA', schema).toDeepEqual([ - { - message: - 'Directive "@foo" already exists in the schema. It cannot be redefined.', - locations: [{ line: 1, column: 12 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueDirectivesPerLocationRule-test.ts b/src/validation/__tests__/UniqueDirectivesPerLocationRule-test.ts deleted file mode 100644 index d57a3df684..0000000000 --- a/src/validation/__tests__/UniqueDirectivesPerLocationRule-test.ts +++ /dev/null @@ -1,394 +0,0 @@ -import { describe, it } from 'mocha'; - -import { parse } from '../../language/parser'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { extendSchema } from '../../utilities/extendSchema'; - -import { UniqueDirectivesPerLocationRule } from '../rules/UniqueDirectivesPerLocationRule'; - -import { - expectSDLValidationErrors, - expectValidationErrorsWithSchema, - testSchema, -} from './harness'; - -const extensionSDL = ` - directive @directive on FIELD | FRAGMENT_DEFINITION - directive @directiveA on FIELD | FRAGMENT_DEFINITION - directive @directiveB on FIELD | FRAGMENT_DEFINITION - directive @repeatable repeatable on FIELD | FRAGMENT_DEFINITION -`; -const schemaWithDirectives = extendSchema(testSchema, parse(extensionSDL)); - -function expectErrors(queryStr: string) { - return expectValidationErrorsWithSchema( - schemaWithDirectives, - UniqueDirectivesPerLocationRule, - queryStr, - ); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors( - schema, - UniqueDirectivesPerLocationRule, - sdlStr, - ); -} - -describe('Validate: Directives Are Unique Per Location', () => { - it('no directives', () => { - expectValid(` - fragment Test on Type { - field - } - `); - }); - - it('unique directives in different locations', () => { - expectValid(` - fragment Test on Type @directiveA { - field @directiveB - } - `); - }); - - it('unique directives in same locations', () => { - expectValid(` - fragment Test on Type @directiveA @directiveB { - field @directiveA @directiveB - } - `); - }); - - it('same directives in different locations', () => { - expectValid(` - fragment Test on Type @directiveA { - field @directiveA - } - `); - }); - - it('same directives in similar locations', () => { - expectValid(` - fragment Test on Type { - field @directive - field @directive - } - `); - }); - - it('repeatable directives in same location', () => { - expectValid(` - fragment Test on Type @repeatable @repeatable { - field @repeatable @repeatable - } - `); - }); - - it('unknown directives must be ignored', () => { - expectValid(` - type Test @unknown @unknown { - field: String! @unknown @unknown - } - - extend type Test @unknown { - anotherField: String! - } - `); - }); - - it('duplicate directives in one location', () => { - expectErrors(` - fragment Test on Type { - field @directive @directive - } - `).toDeepEqual([ - { - message: - 'The directive "@directive" can only be used once at this location.', - locations: [ - { line: 3, column: 15 }, - { line: 3, column: 26 }, - ], - }, - ]); - }); - - it('many duplicate directives in one location', () => { - expectErrors(` - fragment Test on Type { - field @directive @directive @directive - } - `).toDeepEqual([ - { - message: - 'The directive "@directive" can only be used once at this location.', - locations: [ - { line: 3, column: 15 }, - { line: 3, column: 26 }, - ], - }, - { - message: - 'The directive "@directive" can only be used once at this location.', - locations: [ - { line: 3, column: 15 }, - { line: 3, column: 37 }, - ], - }, - ]); - }); - - it('different duplicate directives in one location', () => { - expectErrors(` - fragment Test on Type { - field @directiveA @directiveB @directiveA @directiveB - } - `).toDeepEqual([ - { - message: - 'The directive "@directiveA" can only be used once at this location.', - locations: [ - { line: 3, column: 15 }, - { line: 3, column: 39 }, - ], - }, - { - message: - 'The directive "@directiveB" can only be used once at this location.', - locations: [ - { line: 3, column: 27 }, - { line: 3, column: 51 }, - ], - }, - ]); - }); - - it('duplicate directives in many locations', () => { - expectErrors(` - fragment Test on Type @directive @directive { - field @directive @directive - } - `).toDeepEqual([ - { - message: - 'The directive "@directive" can only be used once at this location.', - locations: [ - { line: 2, column: 29 }, - { line: 2, column: 40 }, - ], - }, - { - message: - 'The directive "@directive" can only be used once at this location.', - locations: [ - { line: 3, column: 15 }, - { line: 3, column: 26 }, - ], - }, - ]); - }); - - it('duplicate directives on SDL definitions', () => { - expectSDLErrors(` - directive @nonRepeatable on - SCHEMA | SCALAR | OBJECT | INTERFACE | UNION | INPUT_OBJECT - - schema @nonRepeatable @nonRepeatable { query: Dummy } - - scalar TestScalar @nonRepeatable @nonRepeatable - type TestObject @nonRepeatable @nonRepeatable - interface TestInterface @nonRepeatable @nonRepeatable - union TestUnion @nonRepeatable @nonRepeatable - input TestInput @nonRepeatable @nonRepeatable - `).toDeepEqual([ - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 5, column: 14 }, - { line: 5, column: 29 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 7, column: 25 }, - { line: 7, column: 40 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 8, column: 23 }, - { line: 8, column: 38 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 9, column: 31 }, - { line: 9, column: 46 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 10, column: 23 }, - { line: 10, column: 38 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 11, column: 23 }, - { line: 11, column: 38 }, - ], - }, - ]); - }); - - it('duplicate directives on SDL extensions', () => { - expectSDLErrors(` - directive @nonRepeatable on - SCHEMA | SCALAR | OBJECT | INTERFACE | UNION | INPUT_OBJECT - - extend schema @nonRepeatable @nonRepeatable - - extend scalar TestScalar @nonRepeatable @nonRepeatable - extend type TestObject @nonRepeatable @nonRepeatable - extend interface TestInterface @nonRepeatable @nonRepeatable - extend union TestUnion @nonRepeatable @nonRepeatable - extend input TestInput @nonRepeatable @nonRepeatable - `).toDeepEqual([ - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 5, column: 21 }, - { line: 5, column: 36 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 7, column: 32 }, - { line: 7, column: 47 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 8, column: 30 }, - { line: 8, column: 45 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 9, column: 38 }, - { line: 9, column: 53 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 10, column: 30 }, - { line: 10, column: 45 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 11, column: 30 }, - { line: 11, column: 45 }, - ], - }, - ]); - }); - - it('duplicate directives between SDL definitions and extensions', () => { - expectSDLErrors(` - directive @nonRepeatable on SCHEMA - - schema @nonRepeatable { query: Dummy } - extend schema @nonRepeatable - `).toDeepEqual([ - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 4, column: 14 }, - { line: 5, column: 21 }, - ], - }, - ]); - - expectSDLErrors(` - directive @nonRepeatable on SCALAR - - scalar TestScalar @nonRepeatable - extend scalar TestScalar @nonRepeatable - scalar TestScalar @nonRepeatable - `).toDeepEqual([ - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 4, column: 25 }, - { line: 5, column: 32 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 4, column: 25 }, - { line: 6, column: 25 }, - ], - }, - ]); - - expectSDLErrors(` - directive @nonRepeatable on OBJECT - - extend type TestObject @nonRepeatable - type TestObject @nonRepeatable - extend type TestObject @nonRepeatable - `).toDeepEqual([ - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 4, column: 30 }, - { line: 5, column: 23 }, - ], - }, - { - message: - 'The directive "@nonRepeatable" can only be used once at this location.', - locations: [ - { line: 4, column: 30 }, - { line: 6, column: 30 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueEnumValueNamesRule-test.ts b/src/validation/__tests__/UniqueEnumValueNamesRule-test.ts deleted file mode 100644 index 17a71a6e90..0000000000 --- a/src/validation/__tests__/UniqueEnumValueNamesRule-test.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { UniqueEnumValueNamesRule } from '../rules/UniqueEnumValueNamesRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, UniqueEnumValueNamesRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Unique enum value names', () => { - it('no values', () => { - expectValidSDL(` - enum SomeEnum - `); - }); - - it('one value', () => { - expectValidSDL(` - enum SomeEnum { - FOO - } - `); - }); - - it('multiple values', () => { - expectValidSDL(` - enum SomeEnum { - FOO - BAR - } - `); - }); - - it('duplicate values inside the same enum definition', () => { - expectSDLErrors(` - enum SomeEnum { - FOO - BAR - FOO - } - `).toDeepEqual([ - { - message: 'Enum value "SomeEnum.FOO" can only be defined once.', - locations: [ - { line: 3, column: 9 }, - { line: 5, column: 9 }, - ], - }, - ]); - }); - - it('extend enum with new value', () => { - expectValidSDL(` - enum SomeEnum { - FOO - } - extend enum SomeEnum { - BAR - } - extend enum SomeEnum { - BAZ - } - `); - }); - - it('extend enum with duplicate value', () => { - expectSDLErrors(` - extend enum SomeEnum { - FOO - } - enum SomeEnum { - FOO - } - `).toDeepEqual([ - { - message: 'Enum value "SomeEnum.FOO" can only be defined once.', - locations: [ - { line: 3, column: 9 }, - { line: 6, column: 9 }, - ], - }, - ]); - }); - - it('duplicate value inside extension', () => { - expectSDLErrors(` - enum SomeEnum - extend enum SomeEnum { - FOO - BAR - FOO - } - `).toDeepEqual([ - { - message: 'Enum value "SomeEnum.FOO" can only be defined once.', - locations: [ - { line: 4, column: 9 }, - { line: 6, column: 9 }, - ], - }, - ]); - }); - - it('duplicate value inside different extensions', () => { - expectSDLErrors(` - enum SomeEnum - extend enum SomeEnum { - FOO - } - extend enum SomeEnum { - FOO - } - `).toDeepEqual([ - { - message: 'Enum value "SomeEnum.FOO" can only be defined once.', - locations: [ - { line: 4, column: 9 }, - { line: 7, column: 9 }, - ], - }, - ]); - }); - - it('adding new value to the type inside existing schema', () => { - const schema = buildSchema('enum SomeEnum'); - const sdl = ` - extend enum SomeEnum { - FOO - } - `; - - expectValidSDL(sdl, schema); - }); - - it('adding conflicting value to existing schema twice', () => { - const schema = buildSchema(` - enum SomeEnum { - FOO - } - `); - const sdl = ` - extend enum SomeEnum { - FOO - } - extend enum SomeEnum { - FOO - } - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: - 'Enum value "SomeEnum.FOO" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 3, column: 9 }], - }, - { - message: - 'Enum value "SomeEnum.FOO" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 6, column: 9 }], - }, - ]); - }); - - it('adding enum values to existing schema twice', () => { - const schema = buildSchema('enum SomeEnum'); - const sdl = ` - extend enum SomeEnum { - FOO - } - extend enum SomeEnum { - FOO - } - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: 'Enum value "SomeEnum.FOO" can only be defined once.', - locations: [ - { line: 3, column: 9 }, - { line: 6, column: 9 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueFieldDefinitionNamesRule-test.ts b/src/validation/__tests__/UniqueFieldDefinitionNamesRule-test.ts deleted file mode 100644 index 441e85d31a..0000000000 --- a/src/validation/__tests__/UniqueFieldDefinitionNamesRule-test.ts +++ /dev/null @@ -1,435 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { UniqueFieldDefinitionNamesRule } from '../rules/UniqueFieldDefinitionNamesRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors( - schema, - UniqueFieldDefinitionNamesRule, - sdlStr, - ); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Unique field definition names', () => { - it('no fields', () => { - expectValidSDL(` - type SomeObject - interface SomeInterface - input SomeInputObject - `); - }); - - it('one field', () => { - expectValidSDL(` - type SomeObject { - foo: String - } - - interface SomeInterface { - foo: String - } - - input SomeInputObject { - foo: String - } - `); - }); - - it('multiple fields', () => { - expectValidSDL(` - type SomeObject { - foo: String - bar: String - } - - interface SomeInterface { - foo: String - bar: String - } - - input SomeInputObject { - foo: String - bar: String - } - `); - }); - - it('duplicate fields inside the same type definition', () => { - expectSDLErrors(` - type SomeObject { - foo: String - bar: String - foo: String - } - - interface SomeInterface { - foo: String - bar: String - foo: String - } - - input SomeInputObject { - foo: String - bar: String - foo: String - } - `).toDeepEqual([ - { - message: 'Field "SomeObject.foo" can only be defined once.', - locations: [ - { line: 3, column: 9 }, - { line: 5, column: 9 }, - ], - }, - { - message: 'Field "SomeInterface.foo" can only be defined once.', - locations: [ - { line: 9, column: 9 }, - { line: 11, column: 9 }, - ], - }, - { - message: 'Field "SomeInputObject.foo" can only be defined once.', - locations: [ - { line: 15, column: 9 }, - { line: 17, column: 9 }, - ], - }, - ]); - }); - - it('extend type with new field', () => { - expectValidSDL(` - type SomeObject { - foo: String - } - extend type SomeObject { - bar: String - } - extend type SomeObject { - baz: String - } - - interface SomeInterface { - foo: String - } - extend interface SomeInterface { - bar: String - } - extend interface SomeInterface { - baz: String - } - - input SomeInputObject { - foo: String - } - extend input SomeInputObject { - bar: String - } - extend input SomeInputObject { - baz: String - } - `); - }); - - it('extend type with duplicate field', () => { - expectSDLErrors(` - extend type SomeObject { - foo: String - } - type SomeObject { - foo: String - } - - extend interface SomeInterface { - foo: String - } - interface SomeInterface { - foo: String - } - - extend input SomeInputObject { - foo: String - } - input SomeInputObject { - foo: String - } - `).toDeepEqual([ - { - message: 'Field "SomeObject.foo" can only be defined once.', - locations: [ - { line: 3, column: 9 }, - { line: 6, column: 9 }, - ], - }, - { - message: 'Field "SomeInterface.foo" can only be defined once.', - locations: [ - { line: 10, column: 9 }, - { line: 13, column: 9 }, - ], - }, - { - message: 'Field "SomeInputObject.foo" can only be defined once.', - locations: [ - { line: 17, column: 9 }, - { line: 20, column: 9 }, - ], - }, - ]); - }); - - it('duplicate field inside extension', () => { - expectSDLErrors(` - type SomeObject - extend type SomeObject { - foo: String - bar: String - foo: String - } - - interface SomeInterface - extend interface SomeInterface { - foo: String - bar: String - foo: String - } - - input SomeInputObject - extend input SomeInputObject { - foo: String - bar: String - foo: String - } - `).toDeepEqual([ - { - message: 'Field "SomeObject.foo" can only be defined once.', - locations: [ - { line: 4, column: 9 }, - { line: 6, column: 9 }, - ], - }, - { - message: 'Field "SomeInterface.foo" can only be defined once.', - locations: [ - { line: 11, column: 9 }, - { line: 13, column: 9 }, - ], - }, - { - message: 'Field "SomeInputObject.foo" can only be defined once.', - locations: [ - { line: 18, column: 9 }, - { line: 20, column: 9 }, - ], - }, - ]); - }); - - it('duplicate field inside different extensions', () => { - expectSDLErrors(` - type SomeObject - extend type SomeObject { - foo: String - } - extend type SomeObject { - foo: String - } - - interface SomeInterface - extend interface SomeInterface { - foo: String - } - extend interface SomeInterface { - foo: String - } - - input SomeInputObject - extend input SomeInputObject { - foo: String - } - extend input SomeInputObject { - foo: String - } - `).toDeepEqual([ - { - message: 'Field "SomeObject.foo" can only be defined once.', - locations: [ - { line: 4, column: 9 }, - { line: 7, column: 9 }, - ], - }, - { - message: 'Field "SomeInterface.foo" can only be defined once.', - locations: [ - { line: 12, column: 9 }, - { line: 15, column: 9 }, - ], - }, - { - message: 'Field "SomeInputObject.foo" can only be defined once.', - locations: [ - { line: 20, column: 9 }, - { line: 23, column: 9 }, - ], - }, - ]); - }); - - it('adding new field to the type inside existing schema', () => { - const schema = buildSchema(` - type SomeObject - interface SomeInterface - input SomeInputObject - `); - const sdl = ` - extend type SomeObject { - foo: String - } - - extend interface SomeInterface { - foo: String - } - - extend input SomeInputObject { - foo: String - } - `; - - expectValidSDL(sdl, schema); - }); - - it('adding conflicting fields to existing schema twice', () => { - const schema = buildSchema(` - type SomeObject { - foo: String - } - - interface SomeInterface { - foo: String - } - - input SomeInputObject { - foo: String - } - `); - const sdl = ` - extend type SomeObject { - foo: String - } - extend interface SomeInterface { - foo: String - } - extend input SomeInputObject { - foo: String - } - - extend type SomeObject { - foo: String - } - extend interface SomeInterface { - foo: String - } - extend input SomeInputObject { - foo: String - } - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: - 'Field "SomeObject.foo" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 3, column: 9 }], - }, - { - message: - 'Field "SomeInterface.foo" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 6, column: 9 }], - }, - { - message: - 'Field "SomeInputObject.foo" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 9, column: 9 }], - }, - { - message: - 'Field "SomeObject.foo" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 13, column: 9 }], - }, - { - message: - 'Field "SomeInterface.foo" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 16, column: 9 }], - }, - { - message: - 'Field "SomeInputObject.foo" already exists in the schema. It cannot also be defined in this type extension.', - locations: [{ line: 19, column: 9 }], - }, - ]); - }); - - it('adding fields to existing schema twice', () => { - const schema = buildSchema(` - type SomeObject - interface SomeInterface - input SomeInputObject - `); - const sdl = ` - extend type SomeObject { - foo: String - } - extend type SomeObject { - foo: String - } - - extend interface SomeInterface { - foo: String - } - extend interface SomeInterface { - foo: String - } - - extend input SomeInputObject { - foo: String - } - extend input SomeInputObject { - foo: String - } - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: 'Field "SomeObject.foo" can only be defined once.', - locations: [ - { line: 3, column: 9 }, - { line: 6, column: 9 }, - ], - }, - { - message: 'Field "SomeInterface.foo" can only be defined once.', - locations: [ - { line: 10, column: 9 }, - { line: 13, column: 9 }, - ], - }, - { - message: 'Field "SomeInputObject.foo" can only be defined once.', - locations: [ - { line: 17, column: 9 }, - { line: 20, column: 9 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueFragmentNamesRule-test.ts b/src/validation/__tests__/UniqueFragmentNamesRule-test.ts deleted file mode 100644 index 2a693a6781..0000000000 --- a/src/validation/__tests__/UniqueFragmentNamesRule-test.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { describe, it } from 'mocha'; - -import { UniqueFragmentNamesRule } from '../rules/UniqueFragmentNamesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(UniqueFragmentNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Unique fragment names', () => { - it('no fragments', () => { - expectValid(` - { - field - } - `); - }); - - it('one fragment', () => { - expectValid(` - { - ...fragA - } - - fragment fragA on Type { - field - } - `); - }); - - it('many fragments', () => { - expectValid(` - { - ...fragA - ...fragB - ...fragC - } - fragment fragA on Type { - fieldA - } - fragment fragB on Type { - fieldB - } - fragment fragC on Type { - fieldC - } - `); - }); - - it('inline fragments are always unique', () => { - expectValid(` - { - ...on Type { - fieldA - } - ...on Type { - fieldB - } - } - `); - }); - - it('fragment and operation named the same', () => { - expectValid(` - query Foo { - ...Foo - } - fragment Foo on Type { - field - } - `); - }); - - it('fragments named the same', () => { - expectErrors(` - { - ...fragA - } - fragment fragA on Type { - fieldA - } - fragment fragA on Type { - fieldB - } - `).toDeepEqual([ - { - message: 'There can be only one fragment named "fragA".', - locations: [ - { line: 5, column: 16 }, - { line: 8, column: 16 }, - ], - }, - ]); - }); - - it('fragments named the same without being referenced', () => { - expectErrors(` - fragment fragA on Type { - fieldA - } - fragment fragA on Type { - fieldB - } - `).toDeepEqual([ - { - message: 'There can be only one fragment named "fragA".', - locations: [ - { line: 2, column: 16 }, - { line: 5, column: 16 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueInputFieldNamesRule-test.ts b/src/validation/__tests__/UniqueInputFieldNamesRule-test.ts deleted file mode 100644 index 33e4a2db01..0000000000 --- a/src/validation/__tests__/UniqueInputFieldNamesRule-test.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { describe, it } from 'mocha'; - -import { UniqueInputFieldNamesRule } from '../rules/UniqueInputFieldNamesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(UniqueInputFieldNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Unique input field names', () => { - it('input object with fields', () => { - expectValid(` - { - field(arg: { f: true }) - } - `); - }); - - it('same input object within two args', () => { - expectValid(` - { - field(arg1: { f: true }, arg2: { f: true }) - } - `); - }); - - it('multiple input object fields', () => { - expectValid(` - { - field(arg: { f1: "value", f2: "value", f3: "value" }) - } - `); - }); - - it('allows for nested input objects with similar fields', () => { - expectValid(` - { - field(arg: { - deep: { - deep: { - id: 1 - } - id: 1 - } - id: 1 - }) - } - `); - }); - - it('duplicate input object fields', () => { - expectErrors(` - { - field(arg: { f1: "value", f1: "value" }) - } - `).toDeepEqual([ - { - message: 'There can be only one input field named "f1".', - locations: [ - { line: 3, column: 22 }, - { line: 3, column: 35 }, - ], - }, - ]); - }); - - it('many duplicate input object fields', () => { - expectErrors(` - { - field(arg: { f1: "value", f1: "value", f1: "value" }) - } - `).toDeepEqual([ - { - message: 'There can be only one input field named "f1".', - locations: [ - { line: 3, column: 22 }, - { line: 3, column: 35 }, - ], - }, - { - message: 'There can be only one input field named "f1".', - locations: [ - { line: 3, column: 22 }, - { line: 3, column: 48 }, - ], - }, - ]); - }); - - it('nested duplicate input object fields', () => { - expectErrors(` - { - field(arg: { f1: {f2: "value", f2: "value" }}) - } - `).toDeepEqual([ - { - message: 'There can be only one input field named "f2".', - locations: [ - { line: 3, column: 27 }, - { line: 3, column: 40 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueOperationNamesRule-test.ts b/src/validation/__tests__/UniqueOperationNamesRule-test.ts deleted file mode 100644 index f84abda63e..0000000000 --- a/src/validation/__tests__/UniqueOperationNamesRule-test.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { describe, it } from 'mocha'; - -import { UniqueOperationNamesRule } from '../rules/UniqueOperationNamesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(UniqueOperationNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Unique operation names', () => { - it('no operations', () => { - expectValid(` - fragment fragA on Type { - field - } - `); - }); - - it('one anon operation', () => { - expectValid(` - { - field - } - `); - }); - - it('one named operation', () => { - expectValid(` - query Foo { - field - } - `); - }); - - it('multiple operations', () => { - expectValid(` - query Foo { - field - } - - query Bar { - field - } - `); - }); - - it('multiple operations of different types', () => { - expectValid(` - query Foo { - field - } - - mutation Bar { - field - } - - subscription Baz { - field - } - `); - }); - - it('fragment and operation named the same', () => { - expectValid(` - query Foo { - ...Foo - } - fragment Foo on Type { - field - } - `); - }); - - it('multiple operations of same name', () => { - expectErrors(` - query Foo { - fieldA - } - query Foo { - fieldB - } - `).toDeepEqual([ - { - message: 'There can be only one operation named "Foo".', - locations: [ - { line: 2, column: 13 }, - { line: 5, column: 13 }, - ], - }, - ]); - }); - - it('multiple ops of same name of different types (mutation)', () => { - expectErrors(` - query Foo { - fieldA - } - mutation Foo { - fieldB - } - `).toDeepEqual([ - { - message: 'There can be only one operation named "Foo".', - locations: [ - { line: 2, column: 13 }, - { line: 5, column: 16 }, - ], - }, - ]); - }); - - it('multiple ops of same name of different types (subscription)', () => { - expectErrors(` - query Foo { - fieldA - } - subscription Foo { - fieldB - } - `).toDeepEqual([ - { - message: 'There can be only one operation named "Foo".', - locations: [ - { line: 2, column: 13 }, - { line: 5, column: 20 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueOperationTypesRule-test.ts b/src/validation/__tests__/UniqueOperationTypesRule-test.ts deleted file mode 100644 index 61e819b022..0000000000 --- a/src/validation/__tests__/UniqueOperationTypesRule-test.ts +++ /dev/null @@ -1,384 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { UniqueOperationTypesRule } from '../rules/UniqueOperationTypesRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, UniqueOperationTypesRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Unique operation types', () => { - it('no schema definition', () => { - expectValidSDL(` - type Foo - `); - }); - - it('schema definition with all types', () => { - expectValidSDL(` - type Foo - - schema { - query: Foo - mutation: Foo - subscription: Foo - } - `); - }); - - it('schema definition with single extension', () => { - expectValidSDL(` - type Foo - - schema { query: Foo } - - extend schema { - mutation: Foo - subscription: Foo - } - `); - }); - - it('schema definition with separate extensions', () => { - expectValidSDL(` - type Foo - - schema { query: Foo } - extend schema { mutation: Foo } - extend schema { subscription: Foo } - `); - }); - - it('extend schema before definition', () => { - expectValidSDL(` - type Foo - - extend schema { mutation: Foo } - extend schema { subscription: Foo } - - schema { query: Foo } - `); - }); - - it('duplicate operation types inside single schema definition', () => { - expectSDLErrors(` - type Foo - - schema { - query: Foo - mutation: Foo - subscription: Foo - - query: Foo - mutation: Foo - subscription: Foo - } - `).toDeepEqual([ - { - message: 'There can be only one query type in schema.', - locations: [ - { line: 5, column: 9 }, - { line: 9, column: 9 }, - ], - }, - { - message: 'There can be only one mutation type in schema.', - locations: [ - { line: 6, column: 9 }, - { line: 10, column: 9 }, - ], - }, - { - message: 'There can be only one subscription type in schema.', - locations: [ - { line: 7, column: 9 }, - { line: 11, column: 9 }, - ], - }, - ]); - }); - - it('duplicate operation types inside schema extension', () => { - expectSDLErrors(` - type Foo - - schema { - query: Foo - mutation: Foo - subscription: Foo - } - - extend schema { - query: Foo - mutation: Foo - subscription: Foo - } - `).toDeepEqual([ - { - message: 'There can be only one query type in schema.', - locations: [ - { line: 5, column: 9 }, - { line: 11, column: 9 }, - ], - }, - { - message: 'There can be only one mutation type in schema.', - locations: [ - { line: 6, column: 9 }, - { line: 12, column: 9 }, - ], - }, - { - message: 'There can be only one subscription type in schema.', - locations: [ - { line: 7, column: 9 }, - { line: 13, column: 9 }, - ], - }, - ]); - }); - - it('duplicate operation types inside schema extension twice', () => { - expectSDLErrors(` - type Foo - - schema { - query: Foo - mutation: Foo - subscription: Foo - } - - extend schema { - query: Foo - mutation: Foo - subscription: Foo - } - - extend schema { - query: Foo - mutation: Foo - subscription: Foo - } - `).toDeepEqual([ - { - message: 'There can be only one query type in schema.', - locations: [ - { line: 5, column: 9 }, - { line: 11, column: 9 }, - ], - }, - { - message: 'There can be only one mutation type in schema.', - locations: [ - { line: 6, column: 9 }, - { line: 12, column: 9 }, - ], - }, - { - message: 'There can be only one subscription type in schema.', - locations: [ - { line: 7, column: 9 }, - { line: 13, column: 9 }, - ], - }, - { - message: 'There can be only one query type in schema.', - locations: [ - { line: 5, column: 9 }, - { line: 17, column: 9 }, - ], - }, - { - message: 'There can be only one mutation type in schema.', - locations: [ - { line: 6, column: 9 }, - { line: 18, column: 9 }, - ], - }, - { - message: 'There can be only one subscription type in schema.', - locations: [ - { line: 7, column: 9 }, - { line: 19, column: 9 }, - ], - }, - ]); - }); - - it('duplicate operation types inside second schema extension', () => { - expectSDLErrors(` - type Foo - - schema { - query: Foo - } - - extend schema { - mutation: Foo - subscription: Foo - } - - extend schema { - query: Foo - mutation: Foo - subscription: Foo - } - `).toDeepEqual([ - { - message: 'There can be only one query type in schema.', - locations: [ - { line: 5, column: 9 }, - { line: 14, column: 9 }, - ], - }, - { - message: 'There can be only one mutation type in schema.', - locations: [ - { line: 9, column: 9 }, - { line: 15, column: 9 }, - ], - }, - { - message: 'There can be only one subscription type in schema.', - locations: [ - { line: 10, column: 9 }, - { line: 16, column: 9 }, - ], - }, - ]); - }); - - it('define schema inside extension SDL', () => { - const schema = buildSchema('type Foo'); - const sdl = ` - schema { - query: Foo - mutation: Foo - subscription: Foo - } - `; - - expectValidSDL(sdl, schema); - }); - - it('define and extend schema inside extension SDL', () => { - const schema = buildSchema('type Foo'); - const sdl = ` - schema { query: Foo } - extend schema { mutation: Foo } - extend schema { subscription: Foo } - `; - - expectValidSDL(sdl, schema); - }); - - it('adding new operation types to existing schema', () => { - const schema = buildSchema('type Query'); - const sdl = ` - extend schema { mutation: Foo } - extend schema { subscription: Foo } - `; - - expectValidSDL(sdl, schema); - }); - - it('adding conflicting operation types to existing schema', () => { - const schema = buildSchema(` - type Query - type Mutation - type Subscription - - type Foo - `); - - const sdl = ` - extend schema { - query: Foo - mutation: Foo - subscription: Foo - } - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: - 'Type for query already defined in the schema. It cannot be redefined.', - locations: [{ line: 3, column: 9 }], - }, - { - message: - 'Type for mutation already defined in the schema. It cannot be redefined.', - locations: [{ line: 4, column: 9 }], - }, - { - message: - 'Type for subscription already defined in the schema. It cannot be redefined.', - locations: [{ line: 5, column: 9 }], - }, - ]); - }); - - it('adding conflicting operation types to existing schema twice', () => { - const schema = buildSchema(` - type Query - type Mutation - type Subscription - `); - - const sdl = ` - extend schema { - query: Foo - mutation: Foo - subscription: Foo - } - - extend schema { - query: Foo - mutation: Foo - subscription: Foo - } - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: - 'Type for query already defined in the schema. It cannot be redefined.', - locations: [{ line: 3, column: 9 }], - }, - { - message: - 'Type for mutation already defined in the schema. It cannot be redefined.', - locations: [{ line: 4, column: 9 }], - }, - { - message: - 'Type for subscription already defined in the schema. It cannot be redefined.', - locations: [{ line: 5, column: 9 }], - }, - { - message: - 'Type for query already defined in the schema. It cannot be redefined.', - locations: [{ line: 9, column: 9 }], - }, - { - message: - 'Type for mutation already defined in the schema. It cannot be redefined.', - locations: [{ line: 10, column: 9 }], - }, - { - message: - 'Type for subscription already defined in the schema. It cannot be redefined.', - locations: [{ line: 11, column: 9 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueTypeNamesRule-test.ts b/src/validation/__tests__/UniqueTypeNamesRule-test.ts deleted file mode 100644 index 5478467dec..0000000000 --- a/src/validation/__tests__/UniqueTypeNamesRule-test.ts +++ /dev/null @@ -1,162 +0,0 @@ -import { describe, it } from 'mocha'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { UniqueTypeNamesRule } from '../rules/UniqueTypeNamesRule'; - -import { expectSDLValidationErrors } from './harness'; - -function expectSDLErrors(sdlStr: string, schema?: GraphQLSchema) { - return expectSDLValidationErrors(schema, UniqueTypeNamesRule, sdlStr); -} - -function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) { - expectSDLErrors(sdlStr, schema).toDeepEqual([]); -} - -describe('Validate: Unique type names', () => { - it('no types', () => { - expectValidSDL(` - directive @test on SCHEMA - `); - }); - - it('one type', () => { - expectValidSDL(` - type Foo - `); - }); - - it('many types', () => { - expectValidSDL(` - type Foo - type Bar - type Baz - `); - }); - - it('type and non-type definitions named the same', () => { - expectValidSDL(` - query Foo { __typename } - fragment Foo on Query { __typename } - directive @Foo on SCHEMA - - type Foo - `); - }); - - it('types named the same', () => { - expectSDLErrors(` - type Foo - - scalar Foo - type Foo - interface Foo - union Foo - enum Foo - input Foo - `).toDeepEqual([ - { - message: 'There can be only one type named "Foo".', - locations: [ - { line: 2, column: 12 }, - { line: 4, column: 14 }, - ], - }, - { - message: 'There can be only one type named "Foo".', - locations: [ - { line: 2, column: 12 }, - { line: 5, column: 12 }, - ], - }, - { - message: 'There can be only one type named "Foo".', - locations: [ - { line: 2, column: 12 }, - { line: 6, column: 17 }, - ], - }, - { - message: 'There can be only one type named "Foo".', - locations: [ - { line: 2, column: 12 }, - { line: 7, column: 13 }, - ], - }, - { - message: 'There can be only one type named "Foo".', - locations: [ - { line: 2, column: 12 }, - { line: 8, column: 12 }, - ], - }, - { - message: 'There can be only one type named "Foo".', - locations: [ - { line: 2, column: 12 }, - { line: 9, column: 13 }, - ], - }, - ]); - }); - - it('adding new type to existing schema', () => { - const schema = buildSchema('type Foo'); - - expectValidSDL('type Bar', schema); - }); - - it('adding new type to existing schema with same-named directive', () => { - const schema = buildSchema('directive @Foo on SCHEMA'); - - expectValidSDL('type Foo', schema); - }); - - it('adding conflicting types to existing schema', () => { - const schema = buildSchema('type Foo'); - const sdl = ` - scalar Foo - type Foo - interface Foo - union Foo - enum Foo - input Foo - `; - - expectSDLErrors(sdl, schema).toDeepEqual([ - { - message: - 'Type "Foo" already exists in the schema. It cannot also be defined in this type definition.', - locations: [{ line: 2, column: 14 }], - }, - { - message: - 'Type "Foo" already exists in the schema. It cannot also be defined in this type definition.', - locations: [{ line: 3, column: 12 }], - }, - { - message: - 'Type "Foo" already exists in the schema. It cannot also be defined in this type definition.', - locations: [{ line: 4, column: 17 }], - }, - { - message: - 'Type "Foo" already exists in the schema. It cannot also be defined in this type definition.', - locations: [{ line: 5, column: 13 }], - }, - { - message: - 'Type "Foo" already exists in the schema. It cannot also be defined in this type definition.', - locations: [{ line: 6, column: 12 }], - }, - { - message: - 'Type "Foo" already exists in the schema. It cannot also be defined in this type definition.', - locations: [{ line: 7, column: 13 }], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/UniqueVariableNamesRule-test.ts b/src/validation/__tests__/UniqueVariableNamesRule-test.ts deleted file mode 100644 index 9d51b62170..0000000000 --- a/src/validation/__tests__/UniqueVariableNamesRule-test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { describe, it } from 'mocha'; - -import { UniqueVariableNamesRule } from '../rules/UniqueVariableNamesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(UniqueVariableNamesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Unique variable names', () => { - it('unique variable names', () => { - expectValid(` - query A($x: Int, $y: String) { __typename } - query B($x: String, $y: Int) { __typename } - `); - }); - - it('duplicate variable names', () => { - expectErrors(` - query A($x: Int, $x: Int, $x: String) { __typename } - query B($x: String, $x: Int) { __typename } - query C($x: Int, $x: Int) { __typename } - `).toDeepEqual([ - { - message: 'There can be only one variable named "$x".', - locations: [ - { line: 2, column: 16 }, - { line: 2, column: 25 }, - { line: 2, column: 34 }, - ], - }, - { - message: 'There can be only one variable named "$x".', - locations: [ - { line: 3, column: 16 }, - { line: 3, column: 28 }, - ], - }, - { - message: 'There can be only one variable named "$x".', - locations: [ - { line: 4, column: 16 }, - { line: 4, column: 25 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/ValidationContext-test.ts b/src/validation/__tests__/ValidationContext-test.ts deleted file mode 100644 index 159aa30549..0000000000 --- a/src/validation/__tests__/ValidationContext-test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { identityFunc } from '../../jsutils/identityFunc'; - -import { parse } from '../../language/parser'; - -import { GraphQLSchema } from '../../type/schema'; - -import { TypeInfo } from '../../utilities/TypeInfo'; - -import { - ASTValidationContext, - SDLValidationContext, - ValidationContext, -} from '../ValidationContext'; - -describe('ValidationContext', () => { - it('can be Object.toStringified', () => { - const schema = new GraphQLSchema({}); - const typeInfo = new TypeInfo(schema); - const ast = parse('{ foo }'); - const onError = identityFunc; - - const astContext = new ASTValidationContext(ast, onError); - expect(Object.prototype.toString.call(astContext)).to.equal( - '[object ASTValidationContext]', - ); - - const sdlContext = new SDLValidationContext(ast, schema, onError); - expect(Object.prototype.toString.call(sdlContext)).to.equal( - '[object SDLValidationContext]', - ); - - const context = new ValidationContext(schema, ast, typeInfo, onError); - expect(Object.prototype.toString.call(context)).to.equal( - '[object ValidationContext]', - ); - }); -}); diff --git a/src/validation/__tests__/ValuesOfCorrectTypeRule-test.ts b/src/validation/__tests__/ValuesOfCorrectTypeRule-test.ts deleted file mode 100644 index 3610fa648b..0000000000 --- a/src/validation/__tests__/ValuesOfCorrectTypeRule-test.ts +++ /dev/null @@ -1,1287 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { inspect } from '../../jsutils/inspect'; - -import { parse } from '../../language/parser'; - -import { GraphQLObjectType, GraphQLScalarType } from '../../type/definition'; -import { GraphQLString } from '../../type/scalars'; -import { GraphQLSchema } from '../../type/schema'; - -import { ValuesOfCorrectTypeRule } from '../rules/ValuesOfCorrectTypeRule'; -import { validate } from '../validate'; - -import { - expectValidationErrors, - expectValidationErrorsWithSchema, -} from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(ValuesOfCorrectTypeRule, queryStr); -} - -function expectErrorsWithSchema(schema: GraphQLSchema, queryStr: string) { - return expectValidationErrorsWithSchema( - schema, - ValuesOfCorrectTypeRule, - queryStr, - ); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -function expectValidWithSchema(schema: GraphQLSchema, queryStr: string) { - expectErrorsWithSchema(schema, queryStr).toDeepEqual([]); -} - -describe('Validate: Values of correct type', () => { - describe('Valid values', () => { - it('Good int value', () => { - expectValid(` - { - complicatedArgs { - intArgField(intArg: 2) - } - } - `); - }); - - it('Good negative int value', () => { - expectValid(` - { - complicatedArgs { - intArgField(intArg: -2) - } - } - `); - }); - - it('Good boolean value', () => { - expectValid(` - { - complicatedArgs { - booleanArgField(booleanArg: true) - } - } - `); - }); - - it('Good string value', () => { - expectValid(` - { - complicatedArgs { - stringArgField(stringArg: "foo") - } - } - `); - }); - - it('Good float value', () => { - expectValid(` - { - complicatedArgs { - floatArgField(floatArg: 1.1) - } - } - `); - }); - - it('Good negative float value', () => { - expectValid(` - { - complicatedArgs { - floatArgField(floatArg: -1.1) - } - } - `); - }); - - it('Int into Float', () => { - expectValid(` - { - complicatedArgs { - floatArgField(floatArg: 1) - } - } - `); - }); - - it('Int into ID', () => { - expectValid(` - { - complicatedArgs { - idArgField(idArg: 1) - } - } - `); - }); - - it('String into ID', () => { - expectValid(` - { - complicatedArgs { - idArgField(idArg: "someIdString") - } - } - `); - }); - - it('Good enum value', () => { - expectValid(` - { - dog { - doesKnowCommand(dogCommand: SIT) - } - } - `); - }); - - it('Enum with undefined value', () => { - expectValid(` - { - complicatedArgs { - enumArgField(enumArg: UNKNOWN) - } - } - `); - }); - - it('Enum with null value', () => { - expectValid(` - { - complicatedArgs { - enumArgField(enumArg: NO_FUR) - } - } - `); - }); - - it('null into nullable type', () => { - expectValid(` - { - complicatedArgs { - intArgField(intArg: null) - } - } - `); - - expectValid(` - { - dog(a: null, b: null, c:{ requiredField: true, intField: null }) { - name - } - } - `); - }); - }); - - describe('Invalid String values', () => { - it('Int into String', () => { - expectErrors(` - { - complicatedArgs { - stringArgField(stringArg: 1) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: 1', - locations: [{ line: 4, column: 39 }], - }, - ]); - }); - - it('Float into String', () => { - expectErrors(` - { - complicatedArgs { - stringArgField(stringArg: 1.0) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: 1.0', - locations: [{ line: 4, column: 39 }], - }, - ]); - }); - - it('Boolean into String', () => { - expectErrors(` - { - complicatedArgs { - stringArgField(stringArg: true) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: true', - locations: [{ line: 4, column: 39 }], - }, - ]); - }); - - it('Unquoted String into String', () => { - expectErrors(` - { - complicatedArgs { - stringArgField(stringArg: BAR) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: BAR', - locations: [{ line: 4, column: 39 }], - }, - ]); - }); - }); - - describe('Invalid Int values', () => { - it('String into Int', () => { - expectErrors(` - { - complicatedArgs { - intArgField(intArg: "3") - } - } - `).toDeepEqual([ - { - message: 'Int cannot represent non-integer value: "3"', - locations: [{ line: 4, column: 33 }], - }, - ]); - }); - - it('Big Int into Int', () => { - expectErrors(` - { - complicatedArgs { - intArgField(intArg: 829384293849283498239482938) - } - } - `).toDeepEqual([ - { - message: - 'Int cannot represent non 32-bit signed integer value: 829384293849283498239482938', - locations: [{ line: 4, column: 33 }], - }, - ]); - }); - - it('Unquoted String into Int', () => { - expectErrors(` - { - complicatedArgs { - intArgField(intArg: FOO) - } - } - `).toDeepEqual([ - { - message: 'Int cannot represent non-integer value: FOO', - locations: [{ line: 4, column: 33 }], - }, - ]); - }); - - it('Simple Float into Int', () => { - expectErrors(` - { - complicatedArgs { - intArgField(intArg: 3.0) - } - } - `).toDeepEqual([ - { - message: 'Int cannot represent non-integer value: 3.0', - locations: [{ line: 4, column: 33 }], - }, - ]); - }); - - it('Float into Int', () => { - expectErrors(` - { - complicatedArgs { - intArgField(intArg: 3.333) - } - } - `).toDeepEqual([ - { - message: 'Int cannot represent non-integer value: 3.333', - locations: [{ line: 4, column: 33 }], - }, - ]); - }); - }); - - describe('Invalid Float values', () => { - it('String into Float', () => { - expectErrors(` - { - complicatedArgs { - floatArgField(floatArg: "3.333") - } - } - `).toDeepEqual([ - { - message: 'Float cannot represent non numeric value: "3.333"', - locations: [{ line: 4, column: 37 }], - }, - ]); - }); - - it('Boolean into Float', () => { - expectErrors(` - { - complicatedArgs { - floatArgField(floatArg: true) - } - } - `).toDeepEqual([ - { - message: 'Float cannot represent non numeric value: true', - locations: [{ line: 4, column: 37 }], - }, - ]); - }); - - it('Unquoted into Float', () => { - expectErrors(` - { - complicatedArgs { - floatArgField(floatArg: FOO) - } - } - `).toDeepEqual([ - { - message: 'Float cannot represent non numeric value: FOO', - locations: [{ line: 4, column: 37 }], - }, - ]); - }); - }); - - describe('Invalid Boolean value', () => { - it('Int into Boolean', () => { - expectErrors(` - { - complicatedArgs { - booleanArgField(booleanArg: 2) - } - } - `).toDeepEqual([ - { - message: 'Boolean cannot represent a non boolean value: 2', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('Float into Boolean', () => { - expectErrors(` - { - complicatedArgs { - booleanArgField(booleanArg: 1.0) - } - } - `).toDeepEqual([ - { - message: 'Boolean cannot represent a non boolean value: 1.0', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('String into Boolean', () => { - expectErrors(` - { - complicatedArgs { - booleanArgField(booleanArg: "true") - } - } - `).toDeepEqual([ - { - message: 'Boolean cannot represent a non boolean value: "true"', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('Unquoted into Boolean', () => { - expectErrors(` - { - complicatedArgs { - booleanArgField(booleanArg: TRUE) - } - } - `).toDeepEqual([ - { - message: 'Boolean cannot represent a non boolean value: TRUE', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - }); - - describe('Invalid ID value', () => { - it('Float into ID', () => { - expectErrors(` - { - complicatedArgs { - idArgField(idArg: 1.0) - } - } - `).toDeepEqual([ - { - message: - 'ID cannot represent a non-string and non-integer value: 1.0', - locations: [{ line: 4, column: 31 }], - }, - ]); - }); - - it('Boolean into ID', () => { - expectErrors(` - { - complicatedArgs { - idArgField(idArg: true) - } - } - `).toDeepEqual([ - { - message: - 'ID cannot represent a non-string and non-integer value: true', - locations: [{ line: 4, column: 31 }], - }, - ]); - }); - - it('Unquoted into ID', () => { - expectErrors(` - { - complicatedArgs { - idArgField(idArg: SOMETHING) - } - } - `).toDeepEqual([ - { - message: - 'ID cannot represent a non-string and non-integer value: SOMETHING', - locations: [{ line: 4, column: 31 }], - }, - ]); - }); - }); - - describe('Invalid Enum value', () => { - it('Int into Enum', () => { - expectErrors(` - { - dog { - doesKnowCommand(dogCommand: 2) - } - } - `).toDeepEqual([ - { - message: 'Enum "DogCommand" cannot represent non-enum value: 2.', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('Float into Enum', () => { - expectErrors(` - { - dog { - doesKnowCommand(dogCommand: 1.0) - } - } - `).toDeepEqual([ - { - message: 'Enum "DogCommand" cannot represent non-enum value: 1.0.', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('String into Enum', () => { - expectErrors(` - { - dog { - doesKnowCommand(dogCommand: "SIT") - } - } - `).toDeepEqual([ - { - message: - 'Enum "DogCommand" cannot represent non-enum value: "SIT". Did you mean the enum value "SIT"?', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('Boolean into Enum', () => { - expectErrors(` - { - dog { - doesKnowCommand(dogCommand: true) - } - } - `).toDeepEqual([ - { - message: 'Enum "DogCommand" cannot represent non-enum value: true.', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('Unknown Enum Value into Enum', () => { - expectErrors(` - { - dog { - doesKnowCommand(dogCommand: JUGGLE) - } - } - `).toDeepEqual([ - { - message: 'Value "JUGGLE" does not exist in "DogCommand" enum.', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('Different case Enum Value into Enum', () => { - expectErrors(` - { - dog { - doesKnowCommand(dogCommand: sit) - } - } - `).toDeepEqual([ - { - message: - 'Value "sit" does not exist in "DogCommand" enum. Did you mean the enum value "SIT"?', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - }); - - describe('Valid List value', () => { - it('Good list value', () => { - expectValid(` - { - complicatedArgs { - stringListArgField(stringListArg: ["one", null, "two"]) - } - } - `); - }); - - it('Empty list value', () => { - expectValid(` - { - complicatedArgs { - stringListArgField(stringListArg: []) - } - } - `); - }); - - it('Null value', () => { - expectValid(` - { - complicatedArgs { - stringListArgField(stringListArg: null) - } - } - `); - }); - - it('Single value into List', () => { - expectValid(` - { - complicatedArgs { - stringListArgField(stringListArg: "one") - } - } - `); - }); - }); - - describe('Invalid List value', () => { - it('Incorrect item type', () => { - expectErrors(` - { - complicatedArgs { - stringListArgField(stringListArg: ["one", 2]) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: 2', - locations: [{ line: 4, column: 55 }], - }, - ]); - }); - - it('Single value of incorrect type', () => { - expectErrors(` - { - complicatedArgs { - stringListArgField(stringListArg: 1) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: 1', - locations: [{ line: 4, column: 47 }], - }, - ]); - }); - }); - - describe('Valid non-nullable value', () => { - it('Arg on optional arg', () => { - expectValid(` - { - dog { - isHouseTrained(atOtherHomes: true) - } - } - `); - }); - - it('No Arg on optional arg', () => { - expectValid(` - { - dog { - isHouseTrained - } - } - `); - }); - - it('Multiple args', () => { - expectValid(` - { - complicatedArgs { - multipleReqs(req1: 1, req2: 2) - } - } - `); - }); - - it('Multiple args reverse order', () => { - expectValid(` - { - complicatedArgs { - multipleReqs(req2: 2, req1: 1) - } - } - `); - }); - - it('No args on multiple optional', () => { - expectValid(` - { - complicatedArgs { - multipleOpts - } - } - `); - }); - - it('One arg on multiple optional', () => { - expectValid(` - { - complicatedArgs { - multipleOpts(opt1: 1) - } - } - `); - }); - - it('Second arg on multiple optional', () => { - expectValid(` - { - complicatedArgs { - multipleOpts(opt2: 1) - } - } - `); - }); - - it('Multiple required args on mixedList', () => { - expectValid(` - { - complicatedArgs { - multipleOptAndReq(req1: 3, req2: 4) - } - } - `); - }); - - it('Multiple required and one optional arg on mixedList', () => { - expectValid(` - { - complicatedArgs { - multipleOptAndReq(req1: 3, req2: 4, opt1: 5) - } - } - `); - }); - - it('All required and optional args on mixedList', () => { - expectValid(` - { - complicatedArgs { - multipleOptAndReq(req1: 3, req2: 4, opt1: 5, opt2: 6) - } - } - `); - }); - }); - - describe('Invalid non-nullable value', () => { - it('Incorrect value type', () => { - expectErrors(` - { - complicatedArgs { - multipleReqs(req2: "two", req1: "one") - } - } - `).toDeepEqual([ - { - message: 'Int cannot represent non-integer value: "two"', - locations: [{ line: 4, column: 32 }], - }, - { - message: 'Int cannot represent non-integer value: "one"', - locations: [{ line: 4, column: 45 }], - }, - ]); - }); - - it('Incorrect value and missing argument (ProvidedRequiredArgumentsRule)', () => { - expectErrors(` - { - complicatedArgs { - multipleReqs(req1: "one") - } - } - `).toDeepEqual([ - { - message: 'Int cannot represent non-integer value: "one"', - locations: [{ line: 4, column: 32 }], - }, - ]); - }); - - it('Null value', () => { - expectErrors(` - { - complicatedArgs { - multipleReqs(req1: null) - } - } - `).toDeepEqual([ - { - message: 'Expected value of type "Int!", found null.', - locations: [{ line: 4, column: 32 }], - }, - ]); - }); - }); - - describe('Valid input object value', () => { - it('Optional arg, despite required field in type', () => { - expectValid(` - { - complicatedArgs { - complexArgField - } - } - `); - }); - - it('Partial object, only required', () => { - expectValid(` - { - complicatedArgs { - complexArgField(complexArg: { requiredField: true }) - } - } - `); - }); - - it('Partial object, required field can be falsy', () => { - expectValid(` - { - complicatedArgs { - complexArgField(complexArg: { requiredField: false }) - } - } - `); - }); - - it('Partial object, including required', () => { - expectValid(` - { - complicatedArgs { - complexArgField(complexArg: { requiredField: true, intField: 4 }) - } - } - `); - }); - - it('Full object', () => { - expectValid(` - { - complicatedArgs { - complexArgField(complexArg: { - requiredField: true, - intField: 4, - stringField: "foo", - booleanField: false, - stringListField: ["one", "two"] - }) - } - } - `); - }); - - it('Full object with fields in different order', () => { - expectValid(` - { - complicatedArgs { - complexArgField(complexArg: { - stringListField: ["one", "two"], - booleanField: false, - requiredField: true, - stringField: "foo", - intField: 4, - }) - } - } - `); - }); - }); - - describe('Valid oneOf input object value', () => { - it('Exactly one field', () => { - expectValid(` - { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: "abc" }) - } - } - `); - }); - - it('Exactly one non-nullable variable', () => { - expectValid(` - query ($string: String!) { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: $string }) - } - } - `); - }); - }); - - describe('Invalid input object value', () => { - it('Partial object, missing required', () => { - expectErrors(` - { - complicatedArgs { - complexArgField(complexArg: { intField: 4 }) - } - } - `).toDeepEqual([ - { - message: - 'Field "ComplexInput.requiredField" of required type "Boolean!" was not provided.', - locations: [{ line: 4, column: 41 }], - }, - ]); - }); - - it('Partial object, invalid field type', () => { - expectErrors(` - { - complicatedArgs { - complexArgField(complexArg: { - stringListField: ["one", 2], - requiredField: true, - }) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: 2', - locations: [{ line: 5, column: 40 }], - }, - ]); - }); - - it('Partial object, null to non-null field', () => { - expectErrors(` - { - complicatedArgs { - complexArgField(complexArg: { - requiredField: true, - nonNullField: null, - }) - } - } - `).toDeepEqual([ - { - message: 'Expected value of type "Boolean!", found null.', - locations: [{ line: 6, column: 29 }], - }, - ]); - }); - - it('Partial object, unknown field arg', () => { - expectErrors(` - { - complicatedArgs { - complexArgField(complexArg: { - requiredField: true, - invalidField: "value" - }) - } - } - `).toDeepEqual([ - { - message: - 'Field "invalidField" is not defined by type "ComplexInput". Did you mean "intField"?', - locations: [{ line: 6, column: 15 }], - }, - ]); - }); - - it('reports original error for custom scalar which throws', () => { - const customScalar = new GraphQLScalarType({ - name: 'Invalid', - parseValue(value) { - throw new Error( - `Invalid scalar is always invalid: ${inspect(value)}`, - ); - }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - invalidArg: { - type: GraphQLString, - args: { arg: { type: customScalar } }, - }, - }, - }), - }); - - const doc = parse('{ invalidArg(arg: 123) }'); - const errors = validate(schema, doc, [ValuesOfCorrectTypeRule]); - - expectJSON(errors).toDeepEqual([ - { - message: - 'Expected value of type "Invalid", found 123; Invalid scalar is always invalid: 123', - locations: [{ line: 1, column: 19 }], - }, - ]); - - expect(errors[0]).to.have.nested.property( - 'originalError.message', - 'Invalid scalar is always invalid: 123', - ); - }); - - it('reports error for custom scalar that returns undefined', () => { - const customScalar = new GraphQLScalarType({ - name: 'CustomScalar', - parseValue() { - return undefined; - }, - }); - - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - invalidArg: { - type: GraphQLString, - args: { arg: { type: customScalar } }, - }, - }, - }), - }); - - expectErrorsWithSchema(schema, '{ invalidArg(arg: 123) }').toDeepEqual([ - { - message: 'Expected value of type "CustomScalar", found 123.', - locations: [{ line: 1, column: 19 }], - }, - ]); - }); - - it('allows custom scalar to accept complex literals', () => { - const customScalar = new GraphQLScalarType({ name: 'Any' }); - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - anyArg: { - type: GraphQLString, - args: { arg: { type: customScalar } }, - }, - }, - }), - }); - - expectValidWithSchema( - schema, - ` - { - test1: anyArg(arg: 123) - test2: anyArg(arg: "abc") - test3: anyArg(arg: [123, "abc"]) - test4: anyArg(arg: {deep: [123, "abc"]}) - } - `, - ); - }); - }); - - describe('Invalid oneOf input object value', () => { - it('Invalid field type', () => { - expectErrors(` - { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: 2 }) - } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: 2', - locations: [{ line: 4, column: 52 }], - }, - ]); - }); - - it('Exactly one null field', () => { - expectErrors(` - { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: null }) - } - } - `).toDeepEqual([ - { - message: 'Field "OneOfInput.stringField" must be non-null.', - locations: [{ line: 4, column: 37 }], - }, - ]); - }); - - it('Exactly one nullable variable', () => { - expectErrors(` - query ($string: String) { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: $string }) - } - } - `).toDeepEqual([ - { - message: - 'Variable "string" must be non-nullable to be used for OneOf Input Object "OneOfInput".', - locations: [{ line: 4, column: 37 }], - }, - ]); - }); - - it('More than one field', () => { - expectErrors(` - { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: "abc", intField: 123 }) - } - } - `).toDeepEqual([ - { - message: - 'OneOf Input Object "OneOfInput" must specify exactly one key.', - locations: [{ line: 4, column: 37 }], - }, - ]); - }); - }); - - describe('Directive arguments', () => { - it('with directives of valid types', () => { - expectValid(` - { - dog @include(if: true) { - name - } - human @skip(if: false) { - name - } - } - `); - }); - - it('with directive with incorrect types', () => { - expectErrors(` - { - dog @include(if: "yes") { - name @skip(if: ENUM) - } - } - `).toDeepEqual([ - { - message: 'Boolean cannot represent a non boolean value: "yes"', - locations: [{ line: 3, column: 28 }], - }, - { - message: 'Boolean cannot represent a non boolean value: ENUM', - locations: [{ line: 4, column: 28 }], - }, - ]); - }); - }); - - describe('Variable default values', () => { - it('variables with valid default values', () => { - expectValid(` - query WithDefaultValues( - $a: Int = 1, - $b: String = "ok", - $c: ComplexInput = { requiredField: true, intField: 3 } - $d: Int! = 123 - ) { - dog { name } - } - `); - }); - - it('variables with valid default null values', () => { - expectValid(` - query WithDefaultValues( - $a: Int = null, - $b: String = null, - $c: ComplexInput = { requiredField: true, intField: null } - ) { - dog { name } - } - `); - }); - - it('variables with invalid default null values', () => { - expectErrors(` - query WithDefaultValues( - $a: Int! = null, - $b: String! = null, - $c: ComplexInput = { requiredField: null, intField: null } - ) { - dog { name } - } - `).toDeepEqual([ - { - message: 'Expected value of type "Int!", found null.', - locations: [{ line: 3, column: 22 }], - }, - { - message: 'Expected value of type "String!", found null.', - locations: [{ line: 4, column: 25 }], - }, - { - message: 'Expected value of type "Boolean!", found null.', - locations: [{ line: 5, column: 47 }], - }, - ]); - }); - - it('variables with invalid default values', () => { - expectErrors(` - query InvalidDefaultValues( - $a: Int = "one", - $b: String = 4, - $c: ComplexInput = "NotVeryComplex" - ) { - dog { name } - } - `).toDeepEqual([ - { - message: 'Int cannot represent non-integer value: "one"', - locations: [{ line: 3, column: 21 }], - }, - { - message: 'String cannot represent a non string value: 4', - locations: [{ line: 4, column: 24 }], - }, - { - message: - 'Expected value of type "ComplexInput", found "NotVeryComplex".', - locations: [{ line: 5, column: 30 }], - }, - ]); - }); - - it('variables with complex invalid default values', () => { - expectErrors(` - query WithDefaultValues( - $a: ComplexInput = { requiredField: 123, intField: "abc" } - ) { - dog { name } - } - `).toDeepEqual([ - { - message: 'Boolean cannot represent a non boolean value: 123', - locations: [{ line: 3, column: 47 }], - }, - { - message: 'Int cannot represent non-integer value: "abc"', - locations: [{ line: 3, column: 62 }], - }, - ]); - }); - - it('complex variables missing required field', () => { - expectErrors(` - query MissingRequiredField($a: ComplexInput = {intField: 3}) { - dog { name } - } - `).toDeepEqual([ - { - message: - 'Field "ComplexInput.requiredField" of required type "Boolean!" was not provided.', - locations: [{ line: 2, column: 55 }], - }, - ]); - }); - - it('list variables with invalid item', () => { - expectErrors(` - query InvalidItem($a: [String] = ["one", 2]) { - dog { name } - } - `).toDeepEqual([ - { - message: 'String cannot represent a non string value: 2', - locations: [{ line: 2, column: 50 }], - }, - ]); - }); - }); -}); diff --git a/src/validation/__tests__/VariablesAreInputTypesRule-test.ts b/src/validation/__tests__/VariablesAreInputTypesRule-test.ts deleted file mode 100644 index 7b754fd76f..0000000000 --- a/src/validation/__tests__/VariablesAreInputTypesRule-test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { describe, it } from 'mocha'; - -import { VariablesAreInputTypesRule } from '../rules/VariablesAreInputTypesRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(VariablesAreInputTypesRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Variables are input types', () => { - it('unknown types are ignored', () => { - expectValid(` - query Foo($a: Unknown, $b: [[Unknown!]]!) { - field(a: $a, b: $b) - } - `); - }); - - it('input types are valid', () => { - expectValid(` - query Foo($a: String, $b: [Boolean!]!, $c: ComplexInput) { - field(a: $a, b: $b, c: $c) - } - `); - }); - - it('output types are invalid', () => { - expectErrors(` - query Foo($a: Dog, $b: [[CatOrDog!]]!, $c: Pet) { - field(a: $a, b: $b, c: $c) - } - `).toDeepEqual([ - { - locations: [{ line: 2, column: 21 }], - message: 'Variable "$a" cannot be non-input type "Dog".', - }, - { - locations: [{ line: 2, column: 30 }], - message: 'Variable "$b" cannot be non-input type "[[CatOrDog!]]!".', - }, - { - locations: [{ line: 2, column: 50 }], - message: 'Variable "$c" cannot be non-input type "Pet".', - }, - ]); - }); -}); diff --git a/src/validation/__tests__/VariablesInAllowedPositionRule-test.ts b/src/validation/__tests__/VariablesInAllowedPositionRule-test.ts deleted file mode 100644 index 6fc3d59c39..0000000000 --- a/src/validation/__tests__/VariablesInAllowedPositionRule-test.ts +++ /dev/null @@ -1,391 +0,0 @@ -import { describe, it } from 'mocha'; - -import { VariablesInAllowedPositionRule } from '../rules/VariablesInAllowedPositionRule'; - -import { expectValidationErrors } from './harness'; - -function expectErrors(queryStr: string) { - return expectValidationErrors(VariablesInAllowedPositionRule, queryStr); -} - -function expectValid(queryStr: string) { - expectErrors(queryStr).toDeepEqual([]); -} - -describe('Validate: Variables are in allowed positions', () => { - it('Boolean => Boolean', () => { - expectValid(` - query Query($booleanArg: Boolean) - { - complicatedArgs { - booleanArgField(booleanArg: $booleanArg) - } - } - `); - }); - - it('Boolean => Boolean within fragment', () => { - expectValid(` - fragment booleanArgFrag on ComplicatedArgs { - booleanArgField(booleanArg: $booleanArg) - } - query Query($booleanArg: Boolean) - { - complicatedArgs { - ...booleanArgFrag - } - } - `); - - expectValid(` - query Query($booleanArg: Boolean) - { - complicatedArgs { - ...booleanArgFrag - } - } - fragment booleanArgFrag on ComplicatedArgs { - booleanArgField(booleanArg: $booleanArg) - } - `); - }); - - it('Boolean! => Boolean', () => { - expectValid(` - query Query($nonNullBooleanArg: Boolean!) - { - complicatedArgs { - booleanArgField(booleanArg: $nonNullBooleanArg) - } - } - `); - }); - - it('Boolean! => Boolean within fragment', () => { - expectValid(` - fragment booleanArgFrag on ComplicatedArgs { - booleanArgField(booleanArg: $nonNullBooleanArg) - } - - query Query($nonNullBooleanArg: Boolean!) - { - complicatedArgs { - ...booleanArgFrag - } - } - `); - }); - - it('[String] => [String]', () => { - expectValid(` - query Query($stringListVar: [String]) - { - complicatedArgs { - stringListArgField(stringListArg: $stringListVar) - } - } - `); - }); - - it('[String!] => [String]', () => { - expectValid(` - query Query($stringListVar: [String!]) - { - complicatedArgs { - stringListArgField(stringListArg: $stringListVar) - } - } - `); - }); - - it('String => [String] in item position', () => { - expectValid(` - query Query($stringVar: String) - { - complicatedArgs { - stringListArgField(stringListArg: [$stringVar]) - } - } - `); - }); - - it('String! => [String] in item position', () => { - expectValid(` - query Query($stringVar: String!) - { - complicatedArgs { - stringListArgField(stringListArg: [$stringVar]) - } - } - `); - }); - - it('ComplexInput => ComplexInput', () => { - expectValid(` - query Query($complexVar: ComplexInput) - { - complicatedArgs { - complexArgField(complexArg: $complexVar) - } - } - `); - }); - - it('ComplexInput => ComplexInput in field position', () => { - expectValid(` - query Query($boolVar: Boolean = false) - { - complicatedArgs { - complexArgField(complexArg: {requiredArg: $boolVar}) - } - } - `); - }); - - it('Boolean! => Boolean! in directive', () => { - expectValid(` - query Query($boolVar: Boolean!) - { - dog @include(if: $boolVar) - } - `); - }); - - it('Int => Int!', () => { - expectErrors(` - query Query($intArg: Int) { - complicatedArgs { - nonNullIntArgField(nonNullIntArg: $intArg) - } - } - `).toDeepEqual([ - { - message: - 'Variable "$intArg" of type "Int" used in position expecting type "Int!".', - locations: [ - { line: 2, column: 19 }, - { line: 4, column: 45 }, - ], - }, - ]); - }); - - it('Int => Int! within fragment', () => { - expectErrors(` - fragment nonNullIntArgFieldFrag on ComplicatedArgs { - nonNullIntArgField(nonNullIntArg: $intArg) - } - - query Query($intArg: Int) { - complicatedArgs { - ...nonNullIntArgFieldFrag - } - } - `).toDeepEqual([ - { - message: - 'Variable "$intArg" of type "Int" used in position expecting type "Int!".', - locations: [ - { line: 6, column: 19 }, - { line: 3, column: 43 }, - ], - }, - ]); - }); - - it('Int => Int! within nested fragment', () => { - expectErrors(` - fragment outerFrag on ComplicatedArgs { - ...nonNullIntArgFieldFrag - } - - fragment nonNullIntArgFieldFrag on ComplicatedArgs { - nonNullIntArgField(nonNullIntArg: $intArg) - } - - query Query($intArg: Int) { - complicatedArgs { - ...outerFrag - } - } - `).toDeepEqual([ - { - message: - 'Variable "$intArg" of type "Int" used in position expecting type "Int!".', - locations: [ - { line: 10, column: 19 }, - { line: 7, column: 43 }, - ], - }, - ]); - }); - - it('String over Boolean', () => { - expectErrors(` - query Query($stringVar: String) { - complicatedArgs { - booleanArgField(booleanArg: $stringVar) - } - } - `).toDeepEqual([ - { - message: - 'Variable "$stringVar" of type "String" used in position expecting type "Boolean".', - locations: [ - { line: 2, column: 19 }, - { line: 4, column: 39 }, - ], - }, - ]); - }); - - it('String => [String]', () => { - expectErrors(` - query Query($stringVar: String) { - complicatedArgs { - stringListArgField(stringListArg: $stringVar) - } - } - `).toDeepEqual([ - { - message: - 'Variable "$stringVar" of type "String" used in position expecting type "[String]".', - locations: [ - { line: 2, column: 19 }, - { line: 4, column: 45 }, - ], - }, - ]); - }); - - it('Boolean => Boolean! in directive', () => { - expectErrors(` - query Query($boolVar: Boolean) { - dog @include(if: $boolVar) - } - `).toDeepEqual([ - { - message: - 'Variable "$boolVar" of type "Boolean" used in position expecting type "Boolean!".', - locations: [ - { line: 2, column: 19 }, - { line: 3, column: 26 }, - ], - }, - ]); - }); - - it('String => Boolean! in directive', () => { - expectErrors(` - query Query($stringVar: String) { - dog @include(if: $stringVar) - } - `).toDeepEqual([ - { - message: - 'Variable "$stringVar" of type "String" used in position expecting type "Boolean!".', - locations: [ - { line: 2, column: 19 }, - { line: 3, column: 26 }, - ], - }, - ]); - }); - - it('[String] => [String!]', () => { - expectErrors(` - query Query($stringListVar: [String]) - { - complicatedArgs { - stringListNonNullArgField(stringListNonNullArg: $stringListVar) - } - } - `).toDeepEqual([ - { - message: - 'Variable "$stringListVar" of type "[String]" used in position expecting type "[String!]".', - locations: [ - { line: 2, column: 19 }, - { line: 5, column: 59 }, - ], - }, - ]); - }); - - describe('Allows optional (nullable) variables with default values', () => { - it('Int => Int! fails when variable provides null default value', () => { - expectErrors(` - query Query($intVar: Int = null) { - complicatedArgs { - nonNullIntArgField(nonNullIntArg: $intVar) - } - } - `).toDeepEqual([ - { - message: - 'Variable "$intVar" of type "Int" used in position expecting type "Int!".', - locations: [ - { line: 2, column: 21 }, - { line: 4, column: 47 }, - ], - }, - ]); - }); - - it('Int => Int! when variable provides non-null default value', () => { - expectValid(` - query Query($intVar: Int = 1) { - complicatedArgs { - nonNullIntArgField(nonNullIntArg: $intVar) - } - }`); - }); - - it('Int => Int! when optional argument provides default value', () => { - expectValid(` - query Query($intVar: Int) { - complicatedArgs { - nonNullFieldWithDefault(nonNullIntArg: $intVar) - } - }`); - }); - - it('Boolean => Boolean! in directive with default value with option', () => { - expectValid(` - query Query($boolVar: Boolean = false) { - dog @include(if: $boolVar) - }`); - }); - }); -}); - -describe('Validates OneOf Input Objects', () => { - it('Allows exactly one non-nullable variable', () => { - expectValid(` - query ($string: String!) { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: $string }) - } - } - `); - }); - - it('Forbids one nullable variable', () => { - expectErrors(` - query ($string: String) { - complicatedArgs { - oneOfArgField(oneOfArg: { stringField: $string }) - } - } - `).toDeepEqual([ - { - message: - 'Variable "$string" is of type "String" but must be non-nullable to be used for OneOf Input Object "OneOfInput".', - locations: [ - { line: 2, column: 14 }, - { line: 4, column: 50 }, - ], - }, - ]); - }); -}); diff --git a/src/validation/__tests__/harness.ts b/src/validation/__tests__/harness.ts deleted file mode 100644 index ea4840341c..0000000000 --- a/src/validation/__tests__/harness.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import type { Maybe } from '../../jsutils/Maybe'; - -import { parse } from '../../language/parser'; - -import type { GraphQLSchema } from '../../type/schema'; - -import { buildSchema } from '../../utilities/buildASTSchema'; - -import { validate, validateSDL } from '../validate'; -import type { SDLValidationRule, ValidationRule } from '../ValidationContext'; - -export const testSchema: GraphQLSchema = buildSchema(` - interface Mammal { - mother: Mammal - father: Mammal - } - - interface Pet { - name(surname: Boolean): String - } - - interface Canine implements Mammal { - name(surname: Boolean): String - mother: Canine - father: Canine - } - - enum DogCommand { - SIT - HEEL - DOWN - } - - type Dog implements Pet & Mammal & Canine { - name(surname: Boolean): String - nickname: String - barkVolume: Int - barks: Boolean - doesKnowCommand(dogCommand: DogCommand): Boolean - isHouseTrained(atOtherHomes: Boolean = true): Boolean - isAtLocation(x: Int, y: Int): Boolean - mother: Dog - father: Dog - } - - type Cat implements Pet { - name(surname: Boolean): String - nickname: String - meows: Boolean - meowsVolume: Int - furColor: FurColor - } - - union CatOrDog = Cat | Dog - - type Human { - name(surname: Boolean): String - pets: [Pet] - relatives: [Human] - } - - enum FurColor { - BROWN - BLACK - TAN - SPOTTED - NO_FUR - UNKNOWN - } - - input ComplexInput { - requiredField: Boolean! - nonNullField: Boolean! = false - intField: Int - stringField: String - booleanField: Boolean - stringListField: [String] - } - - input OneOfInput @oneOf { - stringField: String - intField: Int - } - - type ComplicatedArgs { - # TODO List - # TODO Coercion - # TODO NotNulls - intArgField(intArg: Int): String - nonNullIntArgField(nonNullIntArg: Int!): String - stringArgField(stringArg: String): String - booleanArgField(booleanArg: Boolean): String - enumArgField(enumArg: FurColor): String - floatArgField(floatArg: Float): String - idArgField(idArg: ID): String - stringListArgField(stringListArg: [String]): String - stringListNonNullArgField(stringListNonNullArg: [String!]): String - complexArgField(complexArg: ComplexInput): String - oneOfArgField(oneOfArg: OneOfInput): String - multipleReqs(req1: Int!, req2: Int!): String - nonNullFieldWithDefault(arg: Int! = 0): String - multipleOpts(opt1: Int = 0, opt2: Int = 0): String - multipleOptAndReq(req1: Int!, req2: Int!, opt1: Int = 0, opt2: Int = 0): String - } - - type QueryRoot { - human(id: ID): Human - dog: Dog - cat: Cat - pet: Pet - catOrDog: CatOrDog - complicatedArgs: ComplicatedArgs - } - - schema { - query: QueryRoot - } - - directive @onField on FIELD -`); - -export function expectValidationErrorsWithSchema( - schema: GraphQLSchema, - rule: ValidationRule, - queryStr: string, -): any { - const doc = parse(queryStr); - const errors = validate(schema, doc, [rule]); - return expectJSON(errors); -} - -export function expectValidationErrors( - rule: ValidationRule, - queryStr: string, -): any { - return expectValidationErrorsWithSchema(testSchema, rule, queryStr); -} - -export function expectSDLValidationErrors( - schema: Maybe, - rule: SDLValidationRule, - sdlStr: string, -): any { - const doc = parse(sdlStr); - const errors = validateSDL(doc, schema, [rule]); - return expectJSON(errors); -} diff --git a/src/validation/__tests__/validation-test.ts b/src/validation/__tests__/validation-test.ts deleted file mode 100644 index 2d49f9335b..0000000000 --- a/src/validation/__tests__/validation-test.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { expectJSON } from '../../__testUtils__/expectJSON'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { DirectiveNode } from '../../language/ast'; -import { parse } from '../../language/parser'; - -import { buildSchema } from '../../utilities/buildASTSchema'; -import { TypeInfo } from '../../utilities/TypeInfo'; - -import { validate } from '../validate'; -import type { ValidationContext } from '../ValidationContext'; - -import { testSchema } from './harness'; - -describe('Validate: Supports full validation', () => { - it('rejects invalid documents', () => { - // @ts-expect-error (expects a DocumentNode as a second parameter) - expect(() => validate(testSchema, null)).to.throw('Must provide document.'); - }); - - it('validates queries', () => { - const doc = parse(` - query { - human { - pets { - ... on Cat { - meowsVolume - } - ... on Dog { - barkVolume - } - } - } - } - `); - - const errors = validate(testSchema, doc); - expectJSON(errors).toDeepEqual([]); - }); - - it('detects unknown fields', () => { - const doc = parse(` - { - unknown - } - `); - - const errors = validate(testSchema, doc); - expectJSON(errors).toDeepEqual([ - { - locations: [{ line: 3, column: 9 }], - message: 'Cannot query field "unknown" on type "QueryRoot".', - }, - ]); - }); - - it('Deprecated: validates using a custom TypeInfo', () => { - // This TypeInfo will never return a valid field. - const typeInfo = new TypeInfo(testSchema, null, () => null); - - const doc = parse(` - query { - human { - pets { - ... on Cat { - meowsVolume - } - ... on Dog { - barkVolume - } - } - } - } - `); - - const errors = validate(testSchema, doc, undefined, undefined, typeInfo); - const errorMessages = errors.map((error) => error.message); - - expect(errorMessages).to.deep.equal([ - 'Cannot query field "human" on type "QueryRoot". Did you mean "human"?', - 'Cannot query field "meowsVolume" on type "Cat". Did you mean "meowsVolume"?', - 'Cannot query field "barkVolume" on type "Dog". Did you mean "barkVolume"?', - ]); - }); - - it('validates using a custom rule', () => { - const schema = buildSchema(` - directive @custom(arg: String) on FIELD - - type Query { - foo: String - } - `); - - const doc = parse(` - query { - name @custom - } - `); - - function customRule(context: ValidationContext) { - return { - Directive(node: DirectiveNode) { - const directiveDef = context.getDirective(); - const error = new GraphQLError( - 'Reporting directive: ' + String(directiveDef), - { nodes: node }, - ); - context.reportError(error); - }, - }; - } - - const errors = validate(schema, doc, [customRule]); - expectJSON(errors).toDeepEqual([ - { - message: 'Reporting directive: @custom', - locations: [{ line: 3, column: 14 }], - }, - ]); - }); -}); - -describe('Validate: Limit maximum number of validation errors', () => { - const query = ` - { - firstUnknownField - secondUnknownField - thirdUnknownField - } - `; - const doc = parse(query, { noLocation: true }); - - function validateDocument(options: { maxErrors?: number }) { - return validate(testSchema, doc, undefined, options); - } - - function invalidFieldError(fieldName: string) { - return { - message: `Cannot query field "${fieldName}" on type "QueryRoot".`, - }; - } - - it('when maxErrors is equal to number of errors', () => { - const errors = validateDocument({ maxErrors: 3 }); - expectJSON(errors).toDeepEqual([ - invalidFieldError('firstUnknownField'), - invalidFieldError('secondUnknownField'), - invalidFieldError('thirdUnknownField'), - ]); - }); - - it('when maxErrors is less than number of errors', () => { - const errors = validateDocument({ maxErrors: 2 }); - expectJSON(errors).toDeepEqual([ - invalidFieldError('firstUnknownField'), - invalidFieldError('secondUnknownField'), - { - message: - 'Too many validation errors, error limit reached. Validation aborted.', - }, - ]); - }); - - it('passthrough exceptions from rules', () => { - function customRule() { - return { - Field() { - throw new Error('Error from custom rule!'); - }, - }; - } - expect(() => - validate(testSchema, doc, [customRule], { maxErrors: 1 }), - ).to.throw(/^Error from custom rule!$/); - }); -}); diff --git a/src/validation/index.ts b/src/validation/index.ts deleted file mode 100644 index 587479e351..0000000000 --- a/src/validation/index.ts +++ /dev/null @@ -1,101 +0,0 @@ -export { validate } from './validate'; - -export { ValidationContext } from './ValidationContext'; -export type { ValidationRule } from './ValidationContext'; - -// All validation rules in the GraphQL Specification. -export { specifiedRules, recommendedRules } from './specifiedRules'; - -// Spec Section: "Executable Definitions" -export { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule'; - -// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" -export { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule'; - -// Spec Section: "Fragments on Composite Types" -export { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule'; - -// Spec Section: "Argument Names" -export { KnownArgumentNamesRule } from './rules/KnownArgumentNamesRule'; - -// Spec Section: "Directives Are Defined" -export { KnownDirectivesRule } from './rules/KnownDirectivesRule'; - -// Spec Section: "Fragment spread target defined" -export { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule'; - -// Spec Section: "Fragment Spread Type Existence" -export { KnownTypeNamesRule } from './rules/KnownTypeNamesRule'; - -// Spec Section: "Lone Anonymous Operation" -export { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule'; - -// Spec Section: "Fragments must not form cycles" -export { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule'; - -// Spec Section: "All Variable Used Defined" -export { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule'; - -// Spec Section: "Fragments must be used" -export { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule'; - -// Spec Section: "All Variables Used" -export { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule'; - -// Spec Section: "Field Selection Merging" -export { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule'; - -// Spec Section: "Fragment spread is possible" -export { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule'; - -// Spec Section: "Argument Optionality" -export { ProvidedRequiredArgumentsRule } from './rules/ProvidedRequiredArgumentsRule'; - -// Spec Section: "Leaf Field Selections" -export { ScalarLeafsRule } from './rules/ScalarLeafsRule'; - -// Spec Section: "Subscriptions with Single Root Field" -export { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule'; - -// Spec Section: "Argument Uniqueness" -export { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule'; - -// Spec Section: "Directives Are Unique Per Location" -export { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule'; - -// Spec Section: "Fragment Name Uniqueness" -export { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule'; - -// Spec Section: "Input Object Field Uniqueness" -export { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule'; - -// Spec Section: "Operation Name Uniqueness" -export { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule'; - -// Spec Section: "Variable Uniqueness" -export { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule'; - -// Spec Section: "Values Type Correctness" -export { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule'; - -// Spec Section: "Variables are Input Types" -export { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule'; - -// Spec Section: "All Variable Usages Are Allowed" -export { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule'; - -export { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule'; - -// SDL-specific validation rules -export { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule'; -export { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule'; -export { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule'; -export { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule'; -export { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule'; -export { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule'; -export { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule'; -export { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule'; - -// Optional rules not defined by the GraphQL Specification -export { NoDeprecatedCustomRule } from './rules/custom/NoDeprecatedCustomRule'; -export { NoSchemaIntrospectionCustomRule } from './rules/custom/NoSchemaIntrospectionCustomRule'; diff --git a/src/validation/rules/ExecutableDefinitionsRule.ts b/src/validation/rules/ExecutableDefinitionsRule.ts deleted file mode 100644 index 8f82a6797b..0000000000 --- a/src/validation/rules/ExecutableDefinitionsRule.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import { Kind } from '../../language/kinds'; -import { isExecutableDefinitionNode } from '../../language/predicates'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * Executable definitions - * - * A GraphQL document is only valid for execution if all definitions are either - * operation or fragment definitions. - * - * See https://spec.graphql.org/draft/#sec-Executable-Definitions - */ -export function ExecutableDefinitionsRule( - context: ASTValidationContext, -): ASTVisitor { - return { - Document(node) { - for (const definition of node.definitions) { - if (!isExecutableDefinitionNode(definition)) { - const defName = - definition.kind === Kind.SCHEMA_DEFINITION || - definition.kind === Kind.SCHEMA_EXTENSION - ? 'schema' - : '"' + definition.name.value + '"'; - context.reportError( - new GraphQLError(`The ${defName} definition is not executable.`, { - nodes: definition, - }), - ); - } - } - return false; - }, - }; -} diff --git a/src/validation/rules/FieldsOnCorrectTypeRule.ts b/src/validation/rules/FieldsOnCorrectTypeRule.ts deleted file mode 100644 index 9182f9c4a1..0000000000 --- a/src/validation/rules/FieldsOnCorrectTypeRule.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { didYouMean } from '../../jsutils/didYouMean'; -import { naturalCompare } from '../../jsutils/naturalCompare'; -import { suggestionList } from '../../jsutils/suggestionList'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { FieldNode } from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { - GraphQLInterfaceType, - GraphQLObjectType, - GraphQLOutputType, -} from '../../type/definition'; -import { - isAbstractType, - isInterfaceType, - isObjectType, -} from '../../type/definition'; -import type { GraphQLSchema } from '../../type/schema'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Fields on correct type - * - * A GraphQL document is only valid if all fields selected are defined by the - * parent type, or are an allowed meta field such as __typename. - * - * See https://spec.graphql.org/draft/#sec-Field-Selections - */ -export function FieldsOnCorrectTypeRule( - context: ValidationContext, -): ASTVisitor { - return { - Field(node: FieldNode) { - const type = context.getParentType(); - if (type) { - const fieldDef = context.getFieldDef(); - if (!fieldDef) { - // This field doesn't exist, lets look for suggestions. - const schema = context.getSchema(); - const fieldName = node.name.value; - - // First determine if there are any suggested types to condition on. - let suggestion = didYouMean( - 'to use an inline fragment on', - getSuggestedTypeNames(schema, type, fieldName), - ); - - // If there are no suggested types, then perhaps this was a typo? - if (suggestion === '') { - suggestion = didYouMean(getSuggestedFieldNames(type, fieldName)); - } - - // Report an error, including helpful suggestions. - context.reportError( - new GraphQLError( - `Cannot query field "${fieldName}" on type "${type.name}".` + - suggestion, - { nodes: node }, - ), - ); - } - } - }, - }; -} - -/** - * Go through all of the implementations of type, as well as the interfaces that - * they implement. If any of those types include the provided field, suggest them, - * sorted by how often the type is referenced. - */ -function getSuggestedTypeNames( - schema: GraphQLSchema, - type: GraphQLOutputType, - fieldName: string, -): Array { - if (!isAbstractType(type)) { - // Must be an Object type, which does not have possible fields. - return []; - } - - const suggestedTypes: Set = - new Set(); - const usageCount = Object.create(null); - for (const possibleType of schema.getPossibleTypes(type)) { - if (!possibleType.getFields()[fieldName]) { - continue; - } - - // This object type defines this field. - suggestedTypes.add(possibleType); - usageCount[possibleType.name] = 1; - - for (const possibleInterface of possibleType.getInterfaces()) { - if (!possibleInterface.getFields()[fieldName]) { - continue; - } - - // This interface type defines this field. - suggestedTypes.add(possibleInterface); - usageCount[possibleInterface.name] = - (usageCount[possibleInterface.name] ?? 0) + 1; - } - } - - return [...suggestedTypes] - .sort((typeA, typeB) => { - // Suggest both interface and object types based on how common they are. - const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; - if (usageCountDiff !== 0) { - return usageCountDiff; - } - - // Suggest super types first followed by subtypes - if (isInterfaceType(typeA) && schema.isSubType(typeA, typeB)) { - return -1; - } - if (isInterfaceType(typeB) && schema.isSubType(typeB, typeA)) { - return 1; - } - - return naturalCompare(typeA.name, typeB.name); - }) - .map((x) => x.name); -} - -/** - * For the field name provided, determine if there are any similar field names - * that may be the result of a typo. - */ -function getSuggestedFieldNames( - type: GraphQLOutputType, - fieldName: string, -): Array { - if (isObjectType(type) || isInterfaceType(type)) { - const possibleFieldNames = Object.keys(type.getFields()); - return suggestionList(fieldName, possibleFieldNames); - } - // Otherwise, must be a Union type, which does not define fields. - return []; -} diff --git a/src/validation/rules/FragmentsOnCompositeTypesRule.ts b/src/validation/rules/FragmentsOnCompositeTypesRule.ts deleted file mode 100644 index fb71f63836..0000000000 --- a/src/validation/rules/FragmentsOnCompositeTypesRule.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import { print } from '../../language/printer'; -import type { ASTVisitor } from '../../language/visitor'; - -import { isCompositeType } from '../../type/definition'; - -import { typeFromAST } from '../../utilities/typeFromAST'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Fragments on composite type - * - * Fragments use a type condition to determine if they apply, since fragments - * can only be spread into a composite type (object, interface, or union), the - * type condition must also be a composite type. - * - * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types - */ -export function FragmentsOnCompositeTypesRule( - context: ValidationContext, -): ASTVisitor { - return { - InlineFragment(node) { - const typeCondition = node.typeCondition; - if (typeCondition) { - const type = typeFromAST(context.getSchema(), typeCondition); - if (type && !isCompositeType(type)) { - const typeStr = print(typeCondition); - context.reportError( - new GraphQLError( - `Fragment cannot condition on non composite type "${typeStr}".`, - { nodes: typeCondition }, - ), - ); - } - } - }, - FragmentDefinition(node) { - const type = typeFromAST(context.getSchema(), node.typeCondition); - if (type && !isCompositeType(type)) { - const typeStr = print(node.typeCondition); - context.reportError( - new GraphQLError( - `Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, - { nodes: node.typeCondition }, - ), - ); - } - }, - }; -} diff --git a/src/validation/rules/KnownArgumentNamesRule.ts b/src/validation/rules/KnownArgumentNamesRule.ts deleted file mode 100644 index 332b21c1ca..0000000000 --- a/src/validation/rules/KnownArgumentNamesRule.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { didYouMean } from '../../jsutils/didYouMean'; -import { suggestionList } from '../../jsutils/suggestionList'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import { Kind } from '../../language/kinds'; -import type { ASTVisitor } from '../../language/visitor'; - -import { specifiedDirectives } from '../../type/directives'; - -import type { - SDLValidationContext, - ValidationContext, -} from '../ValidationContext'; - -/** - * Known argument names - * - * A GraphQL field is only valid if all supplied arguments are defined by - * that field. - * - * See https://spec.graphql.org/draft/#sec-Argument-Names - * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations - */ -export function KnownArgumentNamesRule(context: ValidationContext): ASTVisitor { - return { - // eslint-disable-next-line new-cap - ...KnownArgumentNamesOnDirectivesRule(context), - Argument(argNode) { - const argDef = context.getArgument(); - const fieldDef = context.getFieldDef(); - const parentType = context.getParentType(); - - if (!argDef && fieldDef && parentType) { - const argName = argNode.name.value; - const knownArgsNames = fieldDef.args.map((arg) => arg.name); - const suggestions = suggestionList(argName, knownArgsNames); - context.reportError( - new GraphQLError( - `Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` + - didYouMean(suggestions), - { nodes: argNode }, - ), - ); - } - }, - }; -} - -/** - * @internal - */ -export function KnownArgumentNamesOnDirectivesRule( - context: ValidationContext | SDLValidationContext, -): ASTVisitor { - const directiveArgs = Object.create(null); - - const schema = context.getSchema(); - const definedDirectives = schema - ? schema.getDirectives() - : specifiedDirectives; - for (const directive of definedDirectives) { - directiveArgs[directive.name] = directive.args.map((arg) => arg.name); - } - - const astDefinitions = context.getDocument().definitions; - for (const def of astDefinitions) { - if (def.kind === Kind.DIRECTIVE_DEFINITION) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const argsNodes = def.arguments ?? []; - - directiveArgs[def.name.value] = argsNodes.map((arg) => arg.name.value); - } - } - - return { - Directive(directiveNode) { - const directiveName = directiveNode.name.value; - const knownArgs = directiveArgs[directiveName]; - - if (directiveNode.arguments && knownArgs) { - for (const argNode of directiveNode.arguments) { - const argName = argNode.name.value; - if (!knownArgs.includes(argName)) { - const suggestions = suggestionList(argName, knownArgs); - context.reportError( - new GraphQLError( - `Unknown argument "${argName}" on directive "@${directiveName}".` + - didYouMean(suggestions), - { nodes: argNode }, - ), - ); - } - } - } - - return false; - }, - }; -} diff --git a/src/validation/rules/KnownDirectivesRule.ts b/src/validation/rules/KnownDirectivesRule.ts deleted file mode 100644 index f24dbe7d28..0000000000 --- a/src/validation/rules/KnownDirectivesRule.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { inspect } from '../../jsutils/inspect'; -import { invariant } from '../../jsutils/invariant'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTNode } from '../../language/ast'; -import { OperationTypeNode } from '../../language/ast'; -import { DirectiveLocation } from '../../language/directiveLocation'; -import { Kind } from '../../language/kinds'; -import type { ASTVisitor } from '../../language/visitor'; - -import { specifiedDirectives } from '../../type/directives'; - -import type { - SDLValidationContext, - ValidationContext, -} from '../ValidationContext'; - -/** - * Known directives - * - * A GraphQL document is only valid if all `@directives` are known by the - * schema and legally positioned. - * - * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined - */ -export function KnownDirectivesRule( - context: ValidationContext | SDLValidationContext, -): ASTVisitor { - const locationsMap = Object.create(null); - - const schema = context.getSchema(); - const definedDirectives = schema - ? schema.getDirectives() - : specifiedDirectives; - for (const directive of definedDirectives) { - locationsMap[directive.name] = directive.locations; - } - - const astDefinitions = context.getDocument().definitions; - for (const def of astDefinitions) { - if (def.kind === Kind.DIRECTIVE_DEFINITION) { - locationsMap[def.name.value] = def.locations.map((name) => name.value); - } - } - - return { - Directive(node, _key, _parent, _path, ancestors) { - const name = node.name.value; - const locations = locationsMap[name]; - - if (!locations) { - context.reportError( - new GraphQLError(`Unknown directive "@${name}".`, { nodes: node }), - ); - return; - } - - const candidateLocation = getDirectiveLocationForASTPath(ancestors); - if (candidateLocation && !locations.includes(candidateLocation)) { - context.reportError( - new GraphQLError( - `Directive "@${name}" may not be used on ${candidateLocation}.`, - { nodes: node }, - ), - ); - } - }, - }; -} - -function getDirectiveLocationForASTPath( - ancestors: ReadonlyArray>, -): DirectiveLocation | undefined { - const appliedTo = ancestors[ancestors.length - 1]; - invariant('kind' in appliedTo); - - switch (appliedTo.kind) { - case Kind.OPERATION_DEFINITION: - return getDirectiveLocationForOperation(appliedTo.operation); - case Kind.FIELD: - return DirectiveLocation.FIELD; - case Kind.FRAGMENT_SPREAD: - return DirectiveLocation.FRAGMENT_SPREAD; - case Kind.INLINE_FRAGMENT: - return DirectiveLocation.INLINE_FRAGMENT; - case Kind.FRAGMENT_DEFINITION: - return DirectiveLocation.FRAGMENT_DEFINITION; - case Kind.VARIABLE_DEFINITION: - return DirectiveLocation.VARIABLE_DEFINITION; - case Kind.SCHEMA_DEFINITION: - case Kind.SCHEMA_EXTENSION: - return DirectiveLocation.SCHEMA; - case Kind.SCALAR_TYPE_DEFINITION: - case Kind.SCALAR_TYPE_EXTENSION: - return DirectiveLocation.SCALAR; - case Kind.OBJECT_TYPE_DEFINITION: - case Kind.OBJECT_TYPE_EXTENSION: - return DirectiveLocation.OBJECT; - case Kind.FIELD_DEFINITION: - return DirectiveLocation.FIELD_DEFINITION; - case Kind.INTERFACE_TYPE_DEFINITION: - case Kind.INTERFACE_TYPE_EXTENSION: - return DirectiveLocation.INTERFACE; - case Kind.UNION_TYPE_DEFINITION: - case Kind.UNION_TYPE_EXTENSION: - return DirectiveLocation.UNION; - case Kind.ENUM_TYPE_DEFINITION: - case Kind.ENUM_TYPE_EXTENSION: - return DirectiveLocation.ENUM; - case Kind.ENUM_VALUE_DEFINITION: - return DirectiveLocation.ENUM_VALUE; - case Kind.INPUT_OBJECT_TYPE_DEFINITION: - case Kind.INPUT_OBJECT_TYPE_EXTENSION: - return DirectiveLocation.INPUT_OBJECT; - case Kind.INPUT_VALUE_DEFINITION: { - const parentNode = ancestors[ancestors.length - 3]; - invariant('kind' in parentNode); - return parentNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION - ? DirectiveLocation.INPUT_FIELD_DEFINITION - : DirectiveLocation.ARGUMENT_DEFINITION; - } - // Not reachable, all possible types have been considered. - /* c8 ignore next */ - default: - invariant(false, 'Unexpected kind: ' + inspect(appliedTo.kind)); - } -} - -function getDirectiveLocationForOperation( - operation: OperationTypeNode, -): DirectiveLocation { - switch (operation) { - case OperationTypeNode.QUERY: - return DirectiveLocation.QUERY; - case OperationTypeNode.MUTATION: - return DirectiveLocation.MUTATION; - case OperationTypeNode.SUBSCRIPTION: - return DirectiveLocation.SUBSCRIPTION; - } -} diff --git a/src/validation/rules/KnownFragmentNamesRule.ts b/src/validation/rules/KnownFragmentNamesRule.ts deleted file mode 100644 index c37403f752..0000000000 --- a/src/validation/rules/KnownFragmentNamesRule.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Known fragment names - * - * A GraphQL document is only valid if all `...Fragment` fragment spreads refer - * to fragments defined in the same document. - * - * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined - */ -export function KnownFragmentNamesRule(context: ValidationContext): ASTVisitor { - return { - FragmentSpread(node) { - const fragmentName = node.name.value; - const fragment = context.getFragment(fragmentName); - if (!fragment) { - context.reportError( - new GraphQLError(`Unknown fragment "${fragmentName}".`, { - nodes: node.name, - }), - ); - } - }, - }; -} diff --git a/src/validation/rules/KnownTypeNamesRule.ts b/src/validation/rules/KnownTypeNamesRule.ts deleted file mode 100644 index fadc080c35..0000000000 --- a/src/validation/rules/KnownTypeNamesRule.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { didYouMean } from '../../jsutils/didYouMean'; -import { suggestionList } from '../../jsutils/suggestionList'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTNode } from '../../language/ast'; -import { - isTypeDefinitionNode, - isTypeSystemDefinitionNode, - isTypeSystemExtensionNode, -} from '../../language/predicates'; -import type { ASTVisitor } from '../../language/visitor'; - -import { introspectionTypes } from '../../type/introspection'; -import { specifiedScalarTypes } from '../../type/scalars'; - -import type { - SDLValidationContext, - ValidationContext, -} from '../ValidationContext'; - -/** - * Known type names - * - * A GraphQL document is only valid if referenced types (specifically - * variable definitions and fragment conditions) are defined by the type schema. - * - * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence - */ -export function KnownTypeNamesRule( - context: ValidationContext | SDLValidationContext, -): ASTVisitor { - const schema = context.getSchema(); - const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null); - - const definedTypes = Object.create(null); - for (const def of context.getDocument().definitions) { - if (isTypeDefinitionNode(def)) { - definedTypes[def.name.value] = true; - } - } - - const typeNames = [ - ...Object.keys(existingTypesMap), - ...Object.keys(definedTypes), - ]; - - return { - NamedType(node, _1, parent, _2, ancestors) { - const typeName = node.name.value; - if (!existingTypesMap[typeName] && !definedTypes[typeName]) { - const definitionNode = ancestors[2] ?? parent; - const isSDL = definitionNode != null && isSDLNode(definitionNode); - if (isSDL && standardTypeNames.includes(typeName)) { - return; - } - - const suggestedTypes = suggestionList( - typeName, - isSDL ? standardTypeNames.concat(typeNames) : typeNames, - ); - context.reportError( - new GraphQLError( - `Unknown type "${typeName}".` + didYouMean(suggestedTypes), - { nodes: node }, - ), - ); - } - }, - }; -} - -const standardTypeNames = [...specifiedScalarTypes, ...introspectionTypes].map( - (type) => type.name, -); - -function isSDLNode(value: ASTNode | ReadonlyArray): boolean { - return ( - 'kind' in value && - (isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value)) - ); -} diff --git a/src/validation/rules/LoneAnonymousOperationRule.ts b/src/validation/rules/LoneAnonymousOperationRule.ts deleted file mode 100644 index 291a494c76..0000000000 --- a/src/validation/rules/LoneAnonymousOperationRule.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import { Kind } from '../../language/kinds'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * Lone anonymous operation - * - * A GraphQL document is only valid if when it contains an anonymous operation - * (the query short-hand) that it contains only that one operation definition. - * - * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation - */ -export function LoneAnonymousOperationRule( - context: ASTValidationContext, -): ASTVisitor { - let operationCount = 0; - return { - Document(node) { - operationCount = node.definitions.filter( - (definition) => definition.kind === Kind.OPERATION_DEFINITION, - ).length; - }, - OperationDefinition(node) { - if (!node.name && operationCount > 1) { - context.reportError( - new GraphQLError( - 'This anonymous operation must be the only defined operation.', - { nodes: node }, - ), - ); - } - }, - }; -} diff --git a/src/validation/rules/LoneSchemaDefinitionRule.ts b/src/validation/rules/LoneSchemaDefinitionRule.ts deleted file mode 100644 index 4eeb8cdcba..0000000000 --- a/src/validation/rules/LoneSchemaDefinitionRule.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Lone Schema definition - * - * A GraphQL document is only valid if it contains only one schema definition. - */ -export function LoneSchemaDefinitionRule( - context: SDLValidationContext, -): ASTVisitor { - const oldSchema = context.getSchema(); - const alreadyDefined = - oldSchema?.astNode ?? - oldSchema?.getQueryType() ?? - oldSchema?.getMutationType() ?? - oldSchema?.getSubscriptionType(); - - let schemaDefinitionsCount = 0; - return { - SchemaDefinition(node) { - if (alreadyDefined) { - context.reportError( - new GraphQLError( - 'Cannot define a new schema within a schema extension.', - { nodes: node }, - ), - ); - return; - } - - if (schemaDefinitionsCount > 0) { - context.reportError( - new GraphQLError('Must provide only one schema definition.', { - nodes: node, - }), - ); - } - ++schemaDefinitionsCount; - }, - }; -} diff --git a/src/validation/rules/MaxIntrospectionDepthRule.ts b/src/validation/rules/MaxIntrospectionDepthRule.ts deleted file mode 100644 index 0c2dbd3879..0000000000 --- a/src/validation/rules/MaxIntrospectionDepthRule.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTNode } from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -const MAX_LISTS_DEPTH = 3; - -export function MaxIntrospectionDepthRule( - context: ASTValidationContext, -): ASTVisitor { - /** - * Counts the depth of list fields in "__Type" recursively and - * returns `true` if the limit has been reached. - */ - function checkDepth( - node: ASTNode, - visitedFragments: { - [fragmentName: string]: true | undefined; - } = Object.create(null), - depth: number = 0, - ): boolean { - if (node.kind === Kind.FRAGMENT_SPREAD) { - const fragmentName = node.name.value; - if (visitedFragments[fragmentName] === true) { - // Fragment cycles are handled by `NoFragmentCyclesRule`. - return false; - } - const fragment = context.getFragment(fragmentName); - if (!fragment) { - // Missing fragments checks are handled by `KnownFragmentNamesRule`. - return false; - } - - // Rather than following an immutable programming pattern which has - // significant memory and garbage collection overhead, we've opted to - // take a mutable approach for efficiency's sake. Importantly visiting a - // fragment twice is fine, so long as you don't do one visit inside the - // other. - try { - visitedFragments[fragmentName] = true; - return checkDepth(fragment, visitedFragments, depth); - } finally { - visitedFragments[fragmentName] = undefined; - } - } - - if ( - node.kind === Kind.FIELD && - // check all introspection lists - (node.name.value === 'fields' || - node.name.value === 'interfaces' || - node.name.value === 'possibleTypes' || - node.name.value === 'inputFields') - ) { - // eslint-disable-next-line no-param-reassign - depth++; - if (depth >= MAX_LISTS_DEPTH) { - return true; - } - } - - // handles fields and inline fragments - if ('selectionSet' in node && node.selectionSet) { - for (const child of node.selectionSet.selections) { - if (checkDepth(child, visitedFragments, depth)) { - return true; - } - } - } - - return false; - } - - return { - Field(node) { - if (node.name.value === '__schema' || node.name.value === '__type') { - if (checkDepth(node)) { - context.reportError( - new GraphQLError('Maximum introspection depth exceeded', { - nodes: [node], - }), - ); - return false; - } - } - }, - }; -} diff --git a/src/validation/rules/NoFragmentCyclesRule.ts b/src/validation/rules/NoFragmentCyclesRule.ts deleted file mode 100644 index 448b1cf496..0000000000 --- a/src/validation/rules/NoFragmentCyclesRule.ts +++ /dev/null @@ -1,90 +0,0 @@ -import type { ObjMap } from '../../jsutils/ObjMap'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - FragmentDefinitionNode, - FragmentSpreadNode, -} from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * No fragment cycles - * - * The graph of fragment spreads must not form any cycles including spreading itself. - * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. - * - * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles - */ -export function NoFragmentCyclesRule( - context: ASTValidationContext, -): ASTVisitor { - // Tracks already visited fragments to maintain O(N) and to ensure that cycles - // are not redundantly reported. - const visitedFrags: ObjMap = Object.create(null); - - // Array of AST nodes used to produce meaningful errors - const spreadPath: Array = []; - - // Position in the spread path - const spreadPathIndexByName: ObjMap = Object.create(null); - - return { - OperationDefinition: () => false, - FragmentDefinition(node) { - detectCycleRecursive(node); - return false; - }, - }; - - // This does a straight-forward DFS to find cycles. - // It does not terminate when a cycle was found but continues to explore - // the graph to find all possible cycles. - function detectCycleRecursive(fragment: FragmentDefinitionNode): void { - if (visitedFrags[fragment.name.value]) { - return; - } - - const fragmentName = fragment.name.value; - visitedFrags[fragmentName] = true; - - const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); - if (spreadNodes.length === 0) { - return; - } - - spreadPathIndexByName[fragmentName] = spreadPath.length; - - for (const spreadNode of spreadNodes) { - const spreadName = spreadNode.name.value; - const cycleIndex = spreadPathIndexByName[spreadName]; - - spreadPath.push(spreadNode); - if (cycleIndex === undefined) { - const spreadFragment = context.getFragment(spreadName); - if (spreadFragment) { - detectCycleRecursive(spreadFragment); - } - } else { - const cyclePath = spreadPath.slice(cycleIndex); - const viaPath = cyclePath - .slice(0, -1) - .map((s) => '"' + s.name.value + '"') - .join(', '); - - context.reportError( - new GraphQLError( - `Cannot spread fragment "${spreadName}" within itself` + - (viaPath !== '' ? ` via ${viaPath}.` : '.'), - { nodes: cyclePath }, - ), - ); - } - spreadPath.pop(); - } - - spreadPathIndexByName[fragmentName] = undefined; - } -} diff --git a/src/validation/rules/NoUndefinedVariablesRule.ts b/src/validation/rules/NoUndefinedVariablesRule.ts deleted file mode 100644 index 3d499b5dcc..0000000000 --- a/src/validation/rules/NoUndefinedVariablesRule.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * No undefined variables - * - * A GraphQL operation is only valid if all variables encountered, both directly - * and via fragment spreads, are defined by that operation. - * - * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined - */ -export function NoUndefinedVariablesRule( - context: ValidationContext, -): ASTVisitor { - let variableNameDefined = Object.create(null); - - return { - OperationDefinition: { - enter() { - variableNameDefined = Object.create(null); - }, - leave(operation) { - const usages = context.getRecursiveVariableUsages(operation); - - for (const { node } of usages) { - const varName = node.name.value; - if (variableNameDefined[varName] !== true) { - context.reportError( - new GraphQLError( - operation.name - ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` - : `Variable "$${varName}" is not defined.`, - { nodes: [node, operation] }, - ), - ); - } - } - }, - }, - VariableDefinition(node) { - variableNameDefined[node.variable.name.value] = true; - }, - }; -} diff --git a/src/validation/rules/NoUnusedFragmentsRule.ts b/src/validation/rules/NoUnusedFragmentsRule.ts deleted file mode 100644 index aebf34535d..0000000000 --- a/src/validation/rules/NoUnusedFragmentsRule.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - FragmentDefinitionNode, - OperationDefinitionNode, -} from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * No unused fragments - * - * A GraphQL document is only valid if all fragment definitions are spread - * within operations, or spread within other fragments spread within operations. - * - * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used - */ -export function NoUnusedFragmentsRule( - context: ASTValidationContext, -): ASTVisitor { - const operationDefs: Array = []; - const fragmentDefs: Array = []; - - return { - OperationDefinition(node) { - operationDefs.push(node); - return false; - }, - FragmentDefinition(node) { - fragmentDefs.push(node); - return false; - }, - Document: { - leave() { - const fragmentNameUsed = Object.create(null); - for (const operation of operationDefs) { - for (const fragment of context.getRecursivelyReferencedFragments( - operation, - )) { - fragmentNameUsed[fragment.name.value] = true; - } - } - - for (const fragmentDef of fragmentDefs) { - const fragName = fragmentDef.name.value; - if (fragmentNameUsed[fragName] !== true) { - context.reportError( - new GraphQLError(`Fragment "${fragName}" is never used.`, { - nodes: fragmentDef, - }), - ); - } - } - }, - }, - }; -} diff --git a/src/validation/rules/NoUnusedVariablesRule.ts b/src/validation/rules/NoUnusedVariablesRule.ts deleted file mode 100644 index 5083af4f28..0000000000 --- a/src/validation/rules/NoUnusedVariablesRule.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { VariableDefinitionNode } from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * No unused variables - * - * A GraphQL operation is only valid if all variables defined by an operation - * are used, either directly or within a spread fragment. - * - * See https://spec.graphql.org/draft/#sec-All-Variables-Used - */ -export function NoUnusedVariablesRule(context: ValidationContext): ASTVisitor { - let variableDefs: Array = []; - - return { - OperationDefinition: { - enter() { - variableDefs = []; - }, - leave(operation) { - const variableNameUsed = Object.create(null); - const usages = context.getRecursiveVariableUsages(operation); - - for (const { node } of usages) { - variableNameUsed[node.name.value] = true; - } - - for (const variableDef of variableDefs) { - const variableName = variableDef.variable.name.value; - if (variableNameUsed[variableName] !== true) { - context.reportError( - new GraphQLError( - operation.name - ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` - : `Variable "$${variableName}" is never used.`, - { nodes: variableDef }, - ), - ); - } - } - }, - }, - VariableDefinition(def) { - variableDefs.push(def); - }, - }; -} diff --git a/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts b/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts deleted file mode 100644 index 8397a35b80..0000000000 --- a/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts +++ /dev/null @@ -1,900 +0,0 @@ -import { inspect } from '../../jsutils/inspect'; -import type { Maybe } from '../../jsutils/Maybe'; -import type { ObjMap } from '../../jsutils/ObjMap'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - DirectiveNode, - FieldNode, - FragmentDefinitionNode, - SelectionSetNode, - ValueNode, -} from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import { print } from '../../language/printer'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { - GraphQLField, - GraphQLNamedType, - GraphQLOutputType, -} from '../../type/definition'; -import { - getNamedType, - isInterfaceType, - isLeafType, - isListType, - isNonNullType, - isObjectType, -} from '../../type/definition'; - -import { sortValueNode } from '../../utilities/sortValueNode'; -import { typeFromAST } from '../../utilities/typeFromAST'; - -import type { ValidationContext } from '../ValidationContext'; - -function reasonMessage(reason: ConflictReasonMessage): string { - if (Array.isArray(reason)) { - return reason - .map( - ([responseName, subReason]) => - `subfields "${responseName}" conflict because ` + - reasonMessage(subReason), - ) - .join(' and '); - } - return reason; -} - -/** - * Overlapping fields can be merged - * - * A selection set is only valid if all fields (including spreading any - * fragments) either correspond to distinct response names or can be merged - * without ambiguity. - * - * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging - */ -export function OverlappingFieldsCanBeMergedRule( - context: ValidationContext, -): ASTVisitor { - // A memoization for when fields and a fragment or two fragments are compared - // "between" each other for conflicts. Comparisons made be made many times, - // so memoizing this can dramatically improve the performance of this validator. - const comparedFieldsAndFragmentPairs = new OrderedPairSet< - NodeAndDefCollection, - string - >(); - const comparedFragmentPairs = new PairSet(); - - // A cache for the "field map" and list of fragment names found in any given - // selection set. Selection sets may be asked for this information multiple - // times, so this improves the performance of this validator. - const cachedFieldsAndFragmentNames = new Map(); - - return { - SelectionSet(selectionSet) { - const conflicts = findConflictsWithinSelectionSet( - context, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - context.getParentType(), - selectionSet, - ); - for (const [[responseName, reason], fields1, fields2] of conflicts) { - const reasonMsg = reasonMessage(reason); - context.reportError( - new GraphQLError( - `Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, - { nodes: fields1.concat(fields2) }, - ), - ); - } - }, - }; -} - -type Conflict = [ConflictReason, Array, Array]; -// Field name and reason. -type ConflictReason = [string, ConflictReasonMessage]; -// Reason is a string, or a nested list of conflicts. -type ConflictReasonMessage = string | Array; -// Tuple defining a field node in a context. -type NodeAndDef = [ - Maybe, - FieldNode, - Maybe>, -]; -// Map of array of those. -type NodeAndDefCollection = ObjMap>; -type FragmentNames = Array; -type FieldsAndFragmentNames = readonly [NodeAndDefCollection, FragmentNames]; - -/** - * Algorithm: - * - * Conflicts occur when two fields exist in a query which will produce the same - * response name, but represent differing values, thus creating a conflict. - * The algorithm below finds all conflicts via making a series of comparisons - * between fields. In order to compare as few fields as possible, this makes - * a series of comparisons "within" sets of fields and "between" sets of fields. - * - * Given any selection set, a collection produces both a set of fields by - * also including all inline fragments, as well as a list of fragments - * referenced by fragment spreads. - * - * A) Each selection set represented in the document first compares "within" its - * collected set of fields, finding any conflicts between every pair of - * overlapping fields. - * Note: This is the *only time* that a the fields "within" a set are compared - * to each other. After this only fields "between" sets are compared. - * - * B) Also, if any fragment is referenced in a selection set, then a - * comparison is made "between" the original set of fields and the - * referenced fragment. - * - * C) Also, if multiple fragments are referenced, then comparisons - * are made "between" each referenced fragment. - * - * D) When comparing "between" a set of fields and a referenced fragment, first - * a comparison is made between each field in the original set of fields and - * each field in the the referenced set of fields. - * - * E) Also, if any fragment is referenced in the referenced selection set, - * then a comparison is made "between" the original set of fields and the - * referenced fragment (recursively referring to step D). - * - * F) When comparing "between" two fragments, first a comparison is made between - * each field in the first referenced set of fields and each field in the the - * second referenced set of fields. - * - * G) Also, any fragments referenced by the first must be compared to the - * second, and any fragments referenced by the second must be compared to the - * first (recursively referring to step F). - * - * H) When comparing two fields, if both have selection sets, then a comparison - * is made "between" both selection sets, first comparing the set of fields in - * the first selection set with the set of fields in the second. - * - * I) Also, if any fragment is referenced in either selection set, then a - * comparison is made "between" the other set of fields and the - * referenced fragment. - * - * J) Also, if two fragments are referenced in both selection sets, then a - * comparison is made "between" the two fragments. - * - */ - -// Find all conflicts found "within" a selection set, including those found -// via spreading in fragments. Called when visiting each SelectionSet in the -// GraphQL Document. -function findConflictsWithinSelectionSet( - context: ValidationContext, - cachedFieldsAndFragmentNames: Map, - comparedFieldsAndFragmentPairs: OrderedPairSet, - comparedFragmentPairs: PairSet, - parentType: Maybe, - selectionSet: SelectionSetNode, -): Array { - const conflicts: Array = []; - - const [fieldMap, fragmentNames] = getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - parentType, - selectionSet, - ); - - // (A) Find find all conflicts "within" the fields of this selection set. - // Note: this is the *only place* `collectConflictsWithin` is called. - collectConflictsWithin( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - fieldMap, - ); - - if (fragmentNames.length !== 0) { - // (B) Then collect conflicts between these fields and those represented by - // each spread fragment name found. - for (let i = 0; i < fragmentNames.length; i++) { - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - false, - fieldMap, - fragmentNames[i], - ); - // (C) Then compare this fragment with all other fragments found in this - // selection set to collect conflicts between fragments spread together. - // This compares each item in the list of fragment names to every other - // item in that same list (except for itself). - for (let j = i + 1; j < fragmentNames.length; j++) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - false, - fragmentNames[i], - fragmentNames[j], - ); - } - } - } - return conflicts; -} - -// Collect all conflicts found between a set of fields and a fragment reference -// including via spreading in any nested fragments. -function collectConflictsBetweenFieldsAndFragment( - context: ValidationContext, - conflicts: Array, - cachedFieldsAndFragmentNames: Map, - comparedFieldsAndFragmentPairs: OrderedPairSet, - comparedFragmentPairs: PairSet, - areMutuallyExclusive: boolean, - fieldMap: NodeAndDefCollection, - fragmentName: string, -): void { - // Memoize so the fields and fragments are not compared for conflicts more - // than once. - if ( - comparedFieldsAndFragmentPairs.has( - fieldMap, - fragmentName, - areMutuallyExclusive, - ) - ) { - return; - } - comparedFieldsAndFragmentPairs.add( - fieldMap, - fragmentName, - areMutuallyExclusive, - ); - - const fragment = context.getFragment(fragmentName); - if (!fragment) { - return; - } - - const [fieldMap2, referencedFragmentNames] = - getReferencedFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragment, - ); - - // Do not compare a fragment's fieldMap to itself. - if (fieldMap === fieldMap2) { - return; - } - - // (D) First collect any conflicts between the provided collection of fields - // and the collection of fields represented by the given fragment. - collectConflictsBetween( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap, - fieldMap2, - ); - - // (E) Then collect any conflicts between the provided collection of fields - // and any fragment names found in the given fragment. - for (const referencedFragmentName of referencedFragmentNames) { - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap, - referencedFragmentName, - ); - } -} - -// Collect all conflicts found between two fragments, including via spreading in -// any nested fragments. -function collectConflictsBetweenFragments( - context: ValidationContext, - conflicts: Array, - cachedFieldsAndFragmentNames: Map, - comparedFieldsAndFragmentPairs: OrderedPairSet, - comparedFragmentPairs: PairSet, - areMutuallyExclusive: boolean, - fragmentName1: string, - fragmentName2: string, -): void { - // No need to compare a fragment to itself. - if (fragmentName1 === fragmentName2) { - return; - } - - // Memoize so two fragments are not compared for conflicts more than once. - if ( - comparedFragmentPairs.has( - fragmentName1, - fragmentName2, - areMutuallyExclusive, - ) - ) { - return; - } - comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive); - - const fragment1 = context.getFragment(fragmentName1); - const fragment2 = context.getFragment(fragmentName2); - if (!fragment1 || !fragment2) { - return; - } - - const [fieldMap1, referencedFragmentNames1] = - getReferencedFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragment1, - ); - const [fieldMap2, referencedFragmentNames2] = - getReferencedFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragment2, - ); - - // (F) First, collect all conflicts between these two collections of fields - // (not including any nested fragments). - collectConflictsBetween( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap1, - fieldMap2, - ); - - // (G) Then collect conflicts between the first fragment and any nested - // fragments spread in the second fragment. - for (const referencedFragmentName2 of referencedFragmentNames2) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fragmentName1, - referencedFragmentName2, - ); - } - - // (G) Then collect conflicts between the second fragment and any nested - // fragments spread in the first fragment. - for (const referencedFragmentName1 of referencedFragmentNames1) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - referencedFragmentName1, - fragmentName2, - ); - } -} - -// Find all conflicts found between two selection sets, including those found -// via spreading in fragments. Called when determining if conflicts exist -// between the sub-fields of two overlapping fields. -function findConflictsBetweenSubSelectionSets( - context: ValidationContext, - cachedFieldsAndFragmentNames: Map, - comparedFieldsAndFragmentPairs: OrderedPairSet, - comparedFragmentPairs: PairSet, - areMutuallyExclusive: boolean, - parentType1: Maybe, - selectionSet1: SelectionSetNode, - parentType2: Maybe, - selectionSet2: SelectionSetNode, -): Array { - const conflicts: Array = []; - - const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - parentType1, - selectionSet1, - ); - const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - parentType2, - selectionSet2, - ); - - // (H) First, collect all conflicts between these two collections of field. - collectConflictsBetween( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap1, - fieldMap2, - ); - - // (I) Then collect conflicts between the first collection of fields and - // those referenced by each fragment name associated with the second. - for (const fragmentName2 of fragmentNames2) { - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap1, - fragmentName2, - ); - } - - // (I) Then collect conflicts between the second collection of fields and - // those referenced by each fragment name associated with the first. - for (const fragmentName1 of fragmentNames1) { - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap2, - fragmentName1, - ); - } - - // (J) Also collect conflicts between any fragment names by the first and - // fragment names by the second. This compares each item in the first set of - // names to each item in the second set of names. - for (const fragmentName1 of fragmentNames1) { - for (const fragmentName2 of fragmentNames2) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - fragmentName1, - fragmentName2, - ); - } - } - return conflicts; -} - -// Collect all Conflicts "within" one collection of fields. -function collectConflictsWithin( - context: ValidationContext, - conflicts: Array, - cachedFieldsAndFragmentNames: Map, - comparedFieldsAndFragmentPairs: OrderedPairSet, - comparedFragmentPairs: PairSet, - fieldMap: NodeAndDefCollection, -): void { - // A field map is a keyed collection, where each key represents a response - // name and the value at that key is a list of all fields which provide that - // response name. For every response name, if there are multiple fields, they - // must be compared to find a potential conflict. - for (const [responseName, fields] of Object.entries(fieldMap)) { - // This compares every field in the list to every other field in this list - // (except to itself). If the list only has one item, nothing needs to - // be compared. - if (fields.length > 1) { - for (let i = 0; i < fields.length; i++) { - for (let j = i + 1; j < fields.length; j++) { - const conflict = findConflict( - context, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - false, // within one collection is never mutually exclusive - responseName, - fields[i], - fields[j], - ); - if (conflict) { - conflicts.push(conflict); - } - } - } - } - } -} - -// Collect all Conflicts between two collections of fields. This is similar to, -// but different from the `collectConflictsWithin` function above. This check -// assumes that `collectConflictsWithin` has already been called on each -// provided collection of fields. This is true because this validator traverses -// each individual selection set. -function collectConflictsBetween( - context: ValidationContext, - conflicts: Array, - cachedFieldsAndFragmentNames: Map, - comparedFieldsAndFragmentPairs: OrderedPairSet, - comparedFragmentPairs: PairSet, - parentFieldsAreMutuallyExclusive: boolean, - fieldMap1: NodeAndDefCollection, - fieldMap2: NodeAndDefCollection, -): void { - // A field map is a keyed collection, where each key represents a response - // name and the value at that key is a list of all fields which provide that - // response name. For any response name which appears in both provided field - // maps, each field from the first field map must be compared to every field - // in the second field map to find potential conflicts. - for (const [responseName, fields1] of Object.entries(fieldMap1)) { - const fields2 = fieldMap2[responseName]; - if (fields2) { - for (const field1 of fields1) { - for (const field2 of fields2) { - const conflict = findConflict( - context, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - parentFieldsAreMutuallyExclusive, - responseName, - field1, - field2, - ); - if (conflict) { - conflicts.push(conflict); - } - } - } - } - } -} - -// Determines if there is a conflict between two particular fields, including -// comparing their sub-fields. -function findConflict( - context: ValidationContext, - cachedFieldsAndFragmentNames: Map, - comparedFieldsAndFragmentPairs: OrderedPairSet, - comparedFragmentPairs: PairSet, - parentFieldsAreMutuallyExclusive: boolean, - responseName: string, - field1: NodeAndDef, - field2: NodeAndDef, -): Maybe { - const [parentType1, node1, def1] = field1; - const [parentType2, node2, def2] = field2; - - // If it is known that two fields could not possibly apply at the same - // time, due to the parent types, then it is safe to permit them to diverge - // in aliased field or arguments used as they will not present any ambiguity - // by differing. - // It is known that two parent types could never overlap if they are - // different Object types. Interface or Union types might overlap - if not - // in the current state of the schema, then perhaps in some future version, - // thus may not safely diverge. - const areMutuallyExclusive = - parentFieldsAreMutuallyExclusive || - (parentType1 !== parentType2 && - isObjectType(parentType1) && - isObjectType(parentType2)); - - if (!areMutuallyExclusive) { - // Two aliases must refer to the same field. - const name1 = node1.name.value; - const name2 = node2.name.value; - if (name1 !== name2) { - return [ - [responseName, `"${name1}" and "${name2}" are different fields`], - [node1], - [node2], - ]; - } - - // Two field calls must have the same arguments. - if (!sameArguments(node1, node2)) { - return [ - [responseName, 'they have differing arguments'], - [node1], - [node2], - ]; - } - } - - // The return type for each field. - const type1 = def1?.type; - const type2 = def2?.type; - - if (type1 && type2 && doTypesConflict(type1, type2)) { - return [ - [ - responseName, - `they return conflicting types "${inspect(type1)}" and "${inspect( - type2, - )}"`, - ], - [node1], - [node2], - ]; - } - - // Collect and compare sub-fields. Use the same "visited fragment names" list - // for both collections so fields in a fragment reference are never - // compared to themselves. - const selectionSet1 = node1.selectionSet; - const selectionSet2 = node2.selectionSet; - if (selectionSet1 && selectionSet2) { - const conflicts = findConflictsBetweenSubSelectionSets( - context, - cachedFieldsAndFragmentNames, - comparedFieldsAndFragmentPairs, - comparedFragmentPairs, - areMutuallyExclusive, - getNamedType(type1), - selectionSet1, - getNamedType(type2), - selectionSet2, - ); - return subfieldConflicts(conflicts, responseName, node1, node2); - } -} - -function sameArguments( - node1: FieldNode | DirectiveNode, - node2: FieldNode | DirectiveNode, -): boolean { - const args1 = node1.arguments; - const args2 = node2.arguments; - - if (args1 === undefined || args1.length === 0) { - return args2 === undefined || args2.length === 0; - } - if (args2 === undefined || args2.length === 0) { - return false; - } - - /* c8 ignore next */ - if (args1.length !== args2.length) { - /* c8 ignore next */ - return false; - /* c8 ignore next */ - } - - const values2 = new Map(args2.map(({ name, value }) => [name.value, value])); - return args1.every((arg1) => { - const value1 = arg1.value; - const value2 = values2.get(arg1.name.value); - if (value2 === undefined) { - return false; - } - - return stringifyValue(value1) === stringifyValue(value2); - }); -} - -function stringifyValue(value: ValueNode): string | null { - return print(sortValueNode(value)); -} - -// Two types conflict if both types could not apply to a value simultaneously. -// Composite types are ignored as their individual field types will be compared -// later recursively. However List and Non-Null types must match. -function doTypesConflict( - type1: GraphQLOutputType, - type2: GraphQLOutputType, -): boolean { - if (isListType(type1)) { - return isListType(type2) - ? doTypesConflict(type1.ofType, type2.ofType) - : true; - } - if (isListType(type2)) { - return true; - } - if (isNonNullType(type1)) { - return isNonNullType(type2) - ? doTypesConflict(type1.ofType, type2.ofType) - : true; - } - if (isNonNullType(type2)) { - return true; - } - if (isLeafType(type1) || isLeafType(type2)) { - return type1 !== type2; - } - return false; -} - -// Given a selection set, return the collection of fields (a mapping of response -// name to field nodes and definitions) as well as a list of fragment names -// referenced via fragment spreads. -function getFieldsAndFragmentNames( - context: ValidationContext, - cachedFieldsAndFragmentNames: Map, - parentType: Maybe, - selectionSet: SelectionSetNode, -): FieldsAndFragmentNames { - const cached = cachedFieldsAndFragmentNames.get(selectionSet); - if (cached) { - return cached; - } - const nodeAndDefs: NodeAndDefCollection = Object.create(null); - const fragmentNames: ObjMap = Object.create(null); - _collectFieldsAndFragmentNames( - context, - parentType, - selectionSet, - nodeAndDefs, - fragmentNames, - ); - const result = [nodeAndDefs, Object.keys(fragmentNames)] as const; - cachedFieldsAndFragmentNames.set(selectionSet, result); - return result; -} - -// Given a reference to a fragment, return the represented collection of fields -// as well as a list of nested fragment names referenced via fragment spreads. -function getReferencedFieldsAndFragmentNames( - context: ValidationContext, - cachedFieldsAndFragmentNames: Map, - fragment: FragmentDefinitionNode, -) { - // Short-circuit building a type from the node if possible. - const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet); - if (cached) { - return cached; - } - - const fragmentType = typeFromAST(context.getSchema(), fragment.typeCondition); - return getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragmentType, - fragment.selectionSet, - ); -} - -function _collectFieldsAndFragmentNames( - context: ValidationContext, - parentType: Maybe, - selectionSet: SelectionSetNode, - nodeAndDefs: NodeAndDefCollection, - fragmentNames: ObjMap, -): void { - for (const selection of selectionSet.selections) { - switch (selection.kind) { - case Kind.FIELD: { - const fieldName = selection.name.value; - let fieldDef; - if (isObjectType(parentType) || isInterfaceType(parentType)) { - fieldDef = parentType.getFields()[fieldName]; - } - const responseName = selection.alias - ? selection.alias.value - : fieldName; - if (!nodeAndDefs[responseName]) { - nodeAndDefs[responseName] = []; - } - nodeAndDefs[responseName].push([parentType, selection, fieldDef]); - break; - } - case Kind.FRAGMENT_SPREAD: - fragmentNames[selection.name.value] = true; - break; - case Kind.INLINE_FRAGMENT: { - const typeCondition = selection.typeCondition; - const inlineFragmentType = typeCondition - ? typeFromAST(context.getSchema(), typeCondition) - : parentType; - _collectFieldsAndFragmentNames( - context, - inlineFragmentType, - selection.selectionSet, - nodeAndDefs, - fragmentNames, - ); - break; - } - } - } -} - -// Given a series of Conflicts which occurred between two sub-fields, generate -// a single Conflict. -function subfieldConflicts( - conflicts: ReadonlyArray, - responseName: string, - node1: FieldNode, - node2: FieldNode, -): Maybe { - if (conflicts.length > 0) { - return [ - [responseName, conflicts.map(([reason]) => reason)], - [node1, ...conflicts.map(([, fields1]) => fields1).flat()], - [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], - ]; - } -} - -/** - * A way to keep track of pairs of things where the ordering of the pair - * matters. - * - * Provides a third argument for has/set to allow flagging the pair as - * weakly or strongly present within the collection. - */ -class OrderedPairSet { - _data: Map>; - - constructor() { - this._data = new Map(); - } - - has(a: T, b: U, weaklyPresent: boolean): boolean { - const result = this._data.get(a)?.get(b); - if (result === undefined) { - return false; - } - - return weaklyPresent ? true : weaklyPresent === result; - } - - add(a: T, b: U, weaklyPresent: boolean): void { - const map = this._data.get(a); - if (map === undefined) { - this._data.set(a, new Map([[b, weaklyPresent]])); - } else { - map.set(b, weaklyPresent); - } - } -} - -/** - * A way to keep track of pairs of similar things when the ordering of the pair - * does not matter. - */ -class PairSet { - _orderedPairSet: OrderedPairSet; - - constructor() { - this._orderedPairSet = new OrderedPairSet(); - } - - has(a: T, b: T, weaklyPresent: boolean): boolean { - return a < b - ? this._orderedPairSet.has(a, b, weaklyPresent) - : this._orderedPairSet.has(b, a, weaklyPresent); - } - - add(a: T, b: T, weaklyPresent: boolean): void { - if (a < b) { - this._orderedPairSet.add(a, b, weaklyPresent); - } else { - this._orderedPairSet.add(b, a, weaklyPresent); - } - } -} diff --git a/src/validation/rules/PossibleFragmentSpreadsRule.ts b/src/validation/rules/PossibleFragmentSpreadsRule.ts deleted file mode 100644 index fe738e5559..0000000000 --- a/src/validation/rules/PossibleFragmentSpreadsRule.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { inspect } from '../../jsutils/inspect'; -import type { Maybe } from '../../jsutils/Maybe'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { GraphQLCompositeType } from '../../type/definition'; -import { isCompositeType } from '../../type/definition'; - -import { doTypesOverlap } from '../../utilities/typeComparators'; -import { typeFromAST } from '../../utilities/typeFromAST'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Possible fragment spread - * - * A fragment spread is only valid if the type condition could ever possibly - * be true: if there is a non-empty intersection of the possible parent types, - * and possible types which pass the type condition. - */ -export function PossibleFragmentSpreadsRule( - context: ValidationContext, -): ASTVisitor { - return { - InlineFragment(node) { - const fragType = context.getType(); - const parentType = context.getParentType(); - if ( - isCompositeType(fragType) && - isCompositeType(parentType) && - !doTypesOverlap(context.getSchema(), fragType, parentType) - ) { - const parentTypeStr = inspect(parentType); - const fragTypeStr = inspect(fragType); - context.reportError( - new GraphQLError( - `Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, - { nodes: node }, - ), - ); - } - }, - FragmentSpread(node) { - const fragName = node.name.value; - const fragType = getFragmentType(context, fragName); - const parentType = context.getParentType(); - if ( - fragType && - parentType && - !doTypesOverlap(context.getSchema(), fragType, parentType) - ) { - const parentTypeStr = inspect(parentType); - const fragTypeStr = inspect(fragType); - context.reportError( - new GraphQLError( - `Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, - { nodes: node }, - ), - ); - } - }, - }; -} - -function getFragmentType( - context: ValidationContext, - name: string, -): Maybe { - const frag = context.getFragment(name); - if (frag) { - const type = typeFromAST(context.getSchema(), frag.typeCondition); - if (isCompositeType(type)) { - return type; - } - } -} diff --git a/src/validation/rules/PossibleTypeExtensionsRule.ts b/src/validation/rules/PossibleTypeExtensionsRule.ts deleted file mode 100644 index 57d16b473f..0000000000 --- a/src/validation/rules/PossibleTypeExtensionsRule.ts +++ /dev/null @@ -1,143 +0,0 @@ -import { didYouMean } from '../../jsutils/didYouMean'; -import { inspect } from '../../jsutils/inspect'; -import { invariant } from '../../jsutils/invariant'; -import type { ObjMap } from '../../jsutils/ObjMap'; -import { suggestionList } from '../../jsutils/suggestionList'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { DefinitionNode, TypeExtensionNode } from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import { isTypeDefinitionNode } from '../../language/predicates'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { GraphQLNamedType } from '../../type/definition'; -import { - isEnumType, - isInputObjectType, - isInterfaceType, - isObjectType, - isScalarType, - isUnionType, -} from '../../type/definition'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Possible type extension - * - * A type extension is only valid if the type is defined and has the same kind. - */ -export function PossibleTypeExtensionsRule( - context: SDLValidationContext, -): ASTVisitor { - const schema = context.getSchema(); - const definedTypes: ObjMap = Object.create(null); - - for (const def of context.getDocument().definitions) { - if (isTypeDefinitionNode(def)) { - definedTypes[def.name.value] = def; - } - } - - return { - ScalarTypeExtension: checkExtension, - ObjectTypeExtension: checkExtension, - InterfaceTypeExtension: checkExtension, - UnionTypeExtension: checkExtension, - EnumTypeExtension: checkExtension, - InputObjectTypeExtension: checkExtension, - }; - - function checkExtension(node: TypeExtensionNode): void { - const typeName = node.name.value; - const defNode = definedTypes[typeName]; - const existingType = schema?.getType(typeName); - - let expectedKind: Kind | undefined; - if (defNode) { - expectedKind = defKindToExtKind[defNode.kind]; - } else if (existingType) { - expectedKind = typeToExtKind(existingType); - } - - if (expectedKind) { - if (expectedKind !== node.kind) { - const kindStr = extensionKindToTypeName(node.kind); - context.reportError( - new GraphQLError(`Cannot extend non-${kindStr} type "${typeName}".`, { - nodes: defNode ? [defNode, node] : node, - }), - ); - } - } else { - const allTypeNames = Object.keys({ - ...definedTypes, - ...schema?.getTypeMap(), - }); - - const suggestedTypes = suggestionList(typeName, allTypeNames); - context.reportError( - new GraphQLError( - `Cannot extend type "${typeName}" because it is not defined.` + - didYouMean(suggestedTypes), - { nodes: node.name }, - ), - ); - } - } -} - -const defKindToExtKind: ObjMap = { - [Kind.SCALAR_TYPE_DEFINITION]: Kind.SCALAR_TYPE_EXTENSION, - [Kind.OBJECT_TYPE_DEFINITION]: Kind.OBJECT_TYPE_EXTENSION, - [Kind.INTERFACE_TYPE_DEFINITION]: Kind.INTERFACE_TYPE_EXTENSION, - [Kind.UNION_TYPE_DEFINITION]: Kind.UNION_TYPE_EXTENSION, - [Kind.ENUM_TYPE_DEFINITION]: Kind.ENUM_TYPE_EXTENSION, - [Kind.INPUT_OBJECT_TYPE_DEFINITION]: Kind.INPUT_OBJECT_TYPE_EXTENSION, -}; - -function typeToExtKind(type: GraphQLNamedType): Kind { - if (isScalarType(type)) { - return Kind.SCALAR_TYPE_EXTENSION; - } - if (isObjectType(type)) { - return Kind.OBJECT_TYPE_EXTENSION; - } - if (isInterfaceType(type)) { - return Kind.INTERFACE_TYPE_EXTENSION; - } - if (isUnionType(type)) { - return Kind.UNION_TYPE_EXTENSION; - } - if (isEnumType(type)) { - return Kind.ENUM_TYPE_EXTENSION; - } - if (isInputObjectType(type)) { - return Kind.INPUT_OBJECT_TYPE_EXTENSION; - } - /* c8 ignore next 3 */ - // Not reachable. All possible types have been considered - invariant(false, 'Unexpected type: ' + inspect(type)); -} - -function extensionKindToTypeName(kind: Kind): string { - switch (kind) { - case Kind.SCALAR_TYPE_EXTENSION: - return 'scalar'; - case Kind.OBJECT_TYPE_EXTENSION: - return 'object'; - case Kind.INTERFACE_TYPE_EXTENSION: - return 'interface'; - case Kind.UNION_TYPE_EXTENSION: - return 'union'; - case Kind.ENUM_TYPE_EXTENSION: - return 'enum'; - case Kind.INPUT_OBJECT_TYPE_EXTENSION: - return 'input object'; - // Not reachable. All possible types have been considered - /* c8 ignore next */ - default: - invariant(false, 'Unexpected kind: ' + inspect(kind)); - } -} diff --git a/src/validation/rules/ProvidedRequiredArgumentsRule.ts b/src/validation/rules/ProvidedRequiredArgumentsRule.ts deleted file mode 100644 index b111dcee1b..0000000000 --- a/src/validation/rules/ProvidedRequiredArgumentsRule.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { inspect } from '../../jsutils/inspect'; -import { keyMap } from '../../jsutils/keyMap'; -import type { ObjMap } from '../../jsutils/ObjMap'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { InputValueDefinitionNode } from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import { print } from '../../language/printer'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { GraphQLArgument } from '../../type/definition'; -import { isRequiredArgument, isType } from '../../type/definition'; -import { specifiedDirectives } from '../../type/directives'; - -import type { - SDLValidationContext, - ValidationContext, -} from '../ValidationContext'; - -/** - * Provided required arguments - * - * A field or directive is only valid if all required (non-null without a - * default value) field arguments have been provided. - */ -export function ProvidedRequiredArgumentsRule( - context: ValidationContext, -): ASTVisitor { - return { - // eslint-disable-next-line new-cap - ...ProvidedRequiredArgumentsOnDirectivesRule(context), - Field: { - // Validate on leave to allow for deeper errors to appear first. - leave(fieldNode) { - const fieldDef = context.getFieldDef(); - if (!fieldDef) { - return false; - } - - const providedArgs = new Set( - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - fieldNode.arguments?.map((arg) => arg.name.value), - ); - for (const argDef of fieldDef.args) { - if (!providedArgs.has(argDef.name) && isRequiredArgument(argDef)) { - const argTypeStr = inspect(argDef.type); - context.reportError( - new GraphQLError( - `Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`, - { nodes: fieldNode }, - ), - ); - } - } - }, - }, - }; -} - -/** - * @internal - */ -export function ProvidedRequiredArgumentsOnDirectivesRule( - context: ValidationContext | SDLValidationContext, -): ASTVisitor { - const requiredArgsMap: ObjMap< - ObjMap - > = Object.create(null); - - const schema = context.getSchema(); - const definedDirectives = schema?.getDirectives() ?? specifiedDirectives; - for (const directive of definedDirectives) { - requiredArgsMap[directive.name] = keyMap( - directive.args.filter(isRequiredArgument), - (arg) => arg.name, - ); - } - - const astDefinitions = context.getDocument().definitions; - for (const def of astDefinitions) { - if (def.kind === Kind.DIRECTIVE_DEFINITION) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const argNodes = def.arguments ?? []; - - requiredArgsMap[def.name.value] = keyMap( - argNodes.filter(isRequiredArgumentNode), - (arg) => arg.name.value, - ); - } - } - - return { - Directive: { - // Validate on leave to allow for deeper errors to appear first. - leave(directiveNode) { - const directiveName = directiveNode.name.value; - const requiredArgs = requiredArgsMap[directiveName]; - if (requiredArgs) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const argNodes = directiveNode.arguments ?? []; - const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); - for (const [argName, argDef] of Object.entries(requiredArgs)) { - if (!argNodeMap.has(argName)) { - const argType = isType(argDef.type) - ? inspect(argDef.type) - : print(argDef.type); - context.reportError( - new GraphQLError( - `Directive "@${directiveName}" argument "${argName}" of type "${argType}" is required, but it was not provided.`, - { nodes: directiveNode }, - ), - ); - } - } - } - }, - }, - }; -} - -function isRequiredArgumentNode(arg: InputValueDefinitionNode): boolean { - return arg.type.kind === Kind.NON_NULL_TYPE && arg.defaultValue == null; -} diff --git a/src/validation/rules/ScalarLeafsRule.ts b/src/validation/rules/ScalarLeafsRule.ts deleted file mode 100644 index 966143c58b..0000000000 --- a/src/validation/rules/ScalarLeafsRule.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { inspect } from '../../jsutils/inspect'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { FieldNode } from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import { getNamedType, isLeafType } from '../../type/definition'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Scalar leafs - * - * A GraphQL document is valid only if all leaf fields (fields without - * sub selections) are of scalar or enum types. - */ -export function ScalarLeafsRule(context: ValidationContext): ASTVisitor { - return { - Field(node: FieldNode) { - const type = context.getType(); - const selectionSet = node.selectionSet; - if (type) { - if (isLeafType(getNamedType(type))) { - if (selectionSet) { - const fieldName = node.name.value; - const typeStr = inspect(type); - context.reportError( - new GraphQLError( - `Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, - { nodes: selectionSet }, - ), - ); - } - } else if (!selectionSet) { - const fieldName = node.name.value; - const typeStr = inspect(type); - context.reportError( - new GraphQLError( - `Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, - { nodes: node }, - ), - ); - } else if (selectionSet.selections.length === 0) { - const fieldName = node.name.value; - const typeStr = inspect(type); - context.reportError( - new GraphQLError( - `Field "${fieldName}" of type "${typeStr}" must have at least one field selected.`, - { nodes: node }, - ), - ); - } - } - }, - }; -} diff --git a/src/validation/rules/SingleFieldSubscriptionsRule.ts b/src/validation/rules/SingleFieldSubscriptionsRule.ts deleted file mode 100644 index 21cb1abaf6..0000000000 --- a/src/validation/rules/SingleFieldSubscriptionsRule.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type { ObjMap } from '../../jsutils/ObjMap'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - FragmentDefinitionNode, - OperationDefinitionNode, -} from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import type { ASTVisitor } from '../../language/visitor'; - -import { collectFields } from '../../execution/collectFields'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Subscriptions must only include a non-introspection field. - * - * A GraphQL subscription is valid only if it contains a single root field and - * that root field is not an introspection field. - * - * See https://spec.graphql.org/draft/#sec-Single-root-field - */ -export function SingleFieldSubscriptionsRule( - context: ValidationContext, -): ASTVisitor { - return { - OperationDefinition(node: OperationDefinitionNode) { - if (node.operation === 'subscription') { - const schema = context.getSchema(); - const subscriptionType = schema.getSubscriptionType(); - if (subscriptionType) { - const operationName = node.name ? node.name.value : null; - const variableValues: { - [variable: string]: any; - } = Object.create(null); - const document = context.getDocument(); - const fragments: ObjMap = Object.create(null); - for (const definition of document.definitions) { - if (definition.kind === Kind.FRAGMENT_DEFINITION) { - fragments[definition.name.value] = definition; - } - } - const fields = collectFields( - schema, - fragments, - variableValues, - subscriptionType, - node.selectionSet, - ); - if (fields.size > 1) { - const fieldSelectionLists = [...fields.values()]; - const extraFieldSelectionLists = fieldSelectionLists.slice(1); - const extraFieldSelections = extraFieldSelectionLists.flat(); - context.reportError( - new GraphQLError( - operationName != null - ? `Subscription "${operationName}" must select only one top level field.` - : 'Anonymous Subscription must select only one top level field.', - { nodes: extraFieldSelections }, - ), - ); - } - for (const fieldNodes of fields.values()) { - const field = fieldNodes[0]; - const fieldName = field.name.value; - if (fieldName.startsWith('__')) { - context.reportError( - new GraphQLError( - operationName != null - ? `Subscription "${operationName}" must not select an introspection top level field.` - : 'Anonymous Subscription must not select an introspection top level field.', - { nodes: fieldNodes }, - ), - ); - } - } - } - } - }, - }; -} diff --git a/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts b/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts deleted file mode 100644 index 2348276338..0000000000 --- a/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { groupBy } from '../../jsutils/groupBy'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - FieldDefinitionNode, - InputValueDefinitionNode, - NameNode, -} from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Unique argument definition names - * - * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. - * A GraphQL Directive is only valid if all its arguments are uniquely named. - */ -export function UniqueArgumentDefinitionNamesRule( - context: SDLValidationContext, -): ASTVisitor { - return { - DirectiveDefinition(directiveNode) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const argumentNodes = directiveNode.arguments ?? []; - - return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); - }, - InterfaceTypeDefinition: checkArgUniquenessPerField, - InterfaceTypeExtension: checkArgUniquenessPerField, - ObjectTypeDefinition: checkArgUniquenessPerField, - ObjectTypeExtension: checkArgUniquenessPerField, - }; - - function checkArgUniquenessPerField(typeNode: { - readonly name: NameNode; - readonly fields?: ReadonlyArray; - }) { - const typeName = typeNode.name.value; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const fieldNodes = typeNode.fields ?? []; - - for (const fieldDef of fieldNodes) { - const fieldName = fieldDef.name.value; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const argumentNodes = fieldDef.arguments ?? []; - - checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); - } - - return false; - } - - function checkArgUniqueness( - parentName: string, - argumentNodes: ReadonlyArray, - ) { - const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value); - - for (const [argName, argNodes] of seenArgs) { - if (argNodes.length > 1) { - context.reportError( - new GraphQLError( - `Argument "${parentName}(${argName}:)" can only be defined once.`, - { nodes: argNodes.map((node) => node.name) }, - ), - ); - } - } - - return false; - } -} diff --git a/src/validation/rules/UniqueArgumentNamesRule.ts b/src/validation/rules/UniqueArgumentNamesRule.ts deleted file mode 100644 index 19667efaa7..0000000000 --- a/src/validation/rules/UniqueArgumentNamesRule.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { groupBy } from '../../jsutils/groupBy'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ArgumentNode } from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * Unique argument names - * - * A GraphQL field or directive is only valid if all supplied arguments are - * uniquely named. - * - * See https://spec.graphql.org/draft/#sec-Argument-Names - */ -export function UniqueArgumentNamesRule( - context: ASTValidationContext, -): ASTVisitor { - return { - Field: checkArgUniqueness, - Directive: checkArgUniqueness, - }; - - function checkArgUniqueness(parentNode: { - arguments?: ReadonlyArray; - }) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const argumentNodes = parentNode.arguments ?? []; - - const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value); - - for (const [argName, argNodes] of seenArgs) { - if (argNodes.length > 1) { - context.reportError( - new GraphQLError( - `There can be only one argument named "${argName}".`, - { nodes: argNodes.map((node) => node.name) }, - ), - ); - } - } - } -} diff --git a/src/validation/rules/UniqueDirectiveNamesRule.ts b/src/validation/rules/UniqueDirectiveNamesRule.ts deleted file mode 100644 index ade517ddce..0000000000 --- a/src/validation/rules/UniqueDirectiveNamesRule.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Unique directive names - * - * A GraphQL document is only valid if all defined directives have unique names. - */ -export function UniqueDirectiveNamesRule( - context: SDLValidationContext, -): ASTVisitor { - const knownDirectiveNames = Object.create(null); - const schema = context.getSchema(); - - return { - DirectiveDefinition(node) { - const directiveName = node.name.value; - - if (schema?.getDirective(directiveName)) { - context.reportError( - new GraphQLError( - `Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, - { nodes: node.name }, - ), - ); - return; - } - - if (knownDirectiveNames[directiveName]) { - context.reportError( - new GraphQLError( - `There can be only one directive named "@${directiveName}".`, - { nodes: [knownDirectiveNames[directiveName], node.name] }, - ), - ); - } else { - knownDirectiveNames[directiveName] = node.name; - } - - return false; - }, - }; -} diff --git a/src/validation/rules/UniqueDirectivesPerLocationRule.ts b/src/validation/rules/UniqueDirectivesPerLocationRule.ts deleted file mode 100644 index a4fc54690a..0000000000 --- a/src/validation/rules/UniqueDirectivesPerLocationRule.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import { Kind } from '../../language/kinds'; -import { - isTypeDefinitionNode, - isTypeExtensionNode, -} from '../../language/predicates'; -import type { ASTVisitor } from '../../language/visitor'; - -import { specifiedDirectives } from '../../type/directives'; - -import type { - SDLValidationContext, - ValidationContext, -} from '../ValidationContext'; - -/** - * Unique directive names per location - * - * A GraphQL document is only valid if all non-repeatable directives at - * a given location are uniquely named. - * - * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location - */ -export function UniqueDirectivesPerLocationRule( - context: ValidationContext | SDLValidationContext, -): ASTVisitor { - const uniqueDirectiveMap = Object.create(null); - - const schema = context.getSchema(); - const definedDirectives = schema - ? schema.getDirectives() - : specifiedDirectives; - for (const directive of definedDirectives) { - uniqueDirectiveMap[directive.name] = !directive.isRepeatable; - } - - const astDefinitions = context.getDocument().definitions; - for (const def of astDefinitions) { - if (def.kind === Kind.DIRECTIVE_DEFINITION) { - uniqueDirectiveMap[def.name.value] = !def.repeatable; - } - } - - const schemaDirectives = Object.create(null); - const typeDirectivesMap = Object.create(null); - - return { - // Many different AST nodes may contain directives. Rather than listing - // them all, just listen for entering any node, and check to see if it - // defines any directives. - enter(node) { - if (!('directives' in node) || !node.directives) { - return; - } - - let seenDirectives; - if ( - node.kind === Kind.SCHEMA_DEFINITION || - node.kind === Kind.SCHEMA_EXTENSION - ) { - seenDirectives = schemaDirectives; - } else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) { - const typeName = node.name.value; - seenDirectives = typeDirectivesMap[typeName]; - if (seenDirectives === undefined) { - typeDirectivesMap[typeName] = seenDirectives = Object.create(null); - } - } else { - seenDirectives = Object.create(null); - } - - for (const directive of node.directives) { - const directiveName = directive.name.value; - - if (uniqueDirectiveMap[directiveName]) { - if (seenDirectives[directiveName]) { - context.reportError( - new GraphQLError( - `The directive "@${directiveName}" can only be used once at this location.`, - { nodes: [seenDirectives[directiveName], directive] }, - ), - ); - } else { - seenDirectives[directiveName] = directive; - } - } - } - }, - }; -} diff --git a/src/validation/rules/UniqueEnumValueNamesRule.ts b/src/validation/rules/UniqueEnumValueNamesRule.ts deleted file mode 100644 index 2bdf8749a2..0000000000 --- a/src/validation/rules/UniqueEnumValueNamesRule.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - EnumTypeDefinitionNode, - EnumTypeExtensionNode, -} from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import { isEnumType } from '../../type/definition'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Unique enum value names - * - * A GraphQL enum type is only valid if all its values are uniquely named. - */ -export function UniqueEnumValueNamesRule( - context: SDLValidationContext, -): ASTVisitor { - const schema = context.getSchema(); - const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); - const knownValueNames = Object.create(null); - - return { - EnumTypeDefinition: checkValueUniqueness, - EnumTypeExtension: checkValueUniqueness, - }; - - function checkValueUniqueness( - node: EnumTypeDefinitionNode | EnumTypeExtensionNode, - ) { - const typeName = node.name.value; - - if (!knownValueNames[typeName]) { - knownValueNames[typeName] = Object.create(null); - } - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const valueNodes = node.values ?? []; - const valueNames = knownValueNames[typeName]; - - for (const valueDef of valueNodes) { - const valueName = valueDef.name.value; - - const existingType = existingTypeMap[typeName]; - if (isEnumType(existingType) && existingType.getValue(valueName)) { - context.reportError( - new GraphQLError( - `Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, - { nodes: valueDef.name }, - ), - ); - } else if (valueNames[valueName]) { - context.reportError( - new GraphQLError( - `Enum value "${typeName}.${valueName}" can only be defined once.`, - { nodes: [valueNames[valueName], valueDef.name] }, - ), - ); - } else { - valueNames[valueName] = valueDef.name; - } - } - - return false; - } -} diff --git a/src/validation/rules/UniqueFieldDefinitionNamesRule.ts b/src/validation/rules/UniqueFieldDefinitionNamesRule.ts deleted file mode 100644 index 52f6527d64..0000000000 --- a/src/validation/rules/UniqueFieldDefinitionNamesRule.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - FieldDefinitionNode, - InputValueDefinitionNode, - NameNode, -} from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { GraphQLNamedType } from '../../type/definition'; -import { - isInputObjectType, - isInterfaceType, - isObjectType, -} from '../../type/definition'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Unique field definition names - * - * A GraphQL complex type is only valid if all its fields are uniquely named. - */ -export function UniqueFieldDefinitionNamesRule( - context: SDLValidationContext, -): ASTVisitor { - const schema = context.getSchema(); - const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); - const knownFieldNames = Object.create(null); - - return { - InputObjectTypeDefinition: checkFieldUniqueness, - InputObjectTypeExtension: checkFieldUniqueness, - InterfaceTypeDefinition: checkFieldUniqueness, - InterfaceTypeExtension: checkFieldUniqueness, - ObjectTypeDefinition: checkFieldUniqueness, - ObjectTypeExtension: checkFieldUniqueness, - }; - - function checkFieldUniqueness(node: { - readonly name: NameNode; - readonly fields?: ReadonlyArray< - InputValueDefinitionNode | FieldDefinitionNode - >; - }) { - const typeName = node.name.value; - - if (!knownFieldNames[typeName]) { - knownFieldNames[typeName] = Object.create(null); - } - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const fieldNodes = node.fields ?? []; - const fieldNames = knownFieldNames[typeName]; - - for (const fieldDef of fieldNodes) { - const fieldName = fieldDef.name.value; - - if (hasField(existingTypeMap[typeName], fieldName)) { - context.reportError( - new GraphQLError( - `Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, - { nodes: fieldDef.name }, - ), - ); - } else if (fieldNames[fieldName]) { - context.reportError( - new GraphQLError( - `Field "${typeName}.${fieldName}" can only be defined once.`, - { nodes: [fieldNames[fieldName], fieldDef.name] }, - ), - ); - } else { - fieldNames[fieldName] = fieldDef.name; - } - } - - return false; - } -} - -function hasField(type: GraphQLNamedType, fieldName: string): boolean { - if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) { - return type.getFields()[fieldName] != null; - } - return false; -} diff --git a/src/validation/rules/UniqueFragmentNamesRule.ts b/src/validation/rules/UniqueFragmentNamesRule.ts deleted file mode 100644 index 3b4311e9c8..0000000000 --- a/src/validation/rules/UniqueFragmentNamesRule.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * Unique fragment names - * - * A GraphQL document is only valid if all defined fragments have unique names. - * - * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness - */ -export function UniqueFragmentNamesRule( - context: ASTValidationContext, -): ASTVisitor { - const knownFragmentNames = Object.create(null); - return { - OperationDefinition: () => false, - FragmentDefinition(node) { - const fragmentName = node.name.value; - if (knownFragmentNames[fragmentName]) { - context.reportError( - new GraphQLError( - `There can be only one fragment named "${fragmentName}".`, - { nodes: [knownFragmentNames[fragmentName], node.name] }, - ), - ); - } else { - knownFragmentNames[fragmentName] = node.name; - } - return false; - }, - }; -} diff --git a/src/validation/rules/UniqueInputFieldNamesRule.ts b/src/validation/rules/UniqueInputFieldNamesRule.ts deleted file mode 100644 index c1916a73b3..0000000000 --- a/src/validation/rules/UniqueInputFieldNamesRule.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { invariant } from '../../jsutils/invariant'; -import type { ObjMap } from '../../jsutils/ObjMap'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { NameNode } from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * Unique input field names - * - * A GraphQL input object value is only valid if all supplied fields are - * uniquely named. - * - * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness - */ -export function UniqueInputFieldNamesRule( - context: ASTValidationContext, -): ASTVisitor { - const knownNameStack: Array> = []; - let knownNames: ObjMap = Object.create(null); - - return { - ObjectValue: { - enter() { - knownNameStack.push(knownNames); - knownNames = Object.create(null); - }, - leave() { - const prevKnownNames = knownNameStack.pop(); - invariant(prevKnownNames); - knownNames = prevKnownNames; - }, - }, - ObjectField(node) { - const fieldName = node.name.value; - if (knownNames[fieldName]) { - context.reportError( - new GraphQLError( - `There can be only one input field named "${fieldName}".`, - { nodes: [knownNames[fieldName], node.name] }, - ), - ); - } else { - knownNames[fieldName] = node.name; - } - }, - }; -} diff --git a/src/validation/rules/UniqueOperationNamesRule.ts b/src/validation/rules/UniqueOperationNamesRule.ts deleted file mode 100644 index 6df98be8c7..0000000000 --- a/src/validation/rules/UniqueOperationNamesRule.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * Unique operation names - * - * A GraphQL document is only valid if all defined operations have unique names. - * - * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness - */ -export function UniqueOperationNamesRule( - context: ASTValidationContext, -): ASTVisitor { - const knownOperationNames = Object.create(null); - return { - OperationDefinition(node) { - const operationName = node.name; - if (operationName) { - if (knownOperationNames[operationName.value]) { - context.reportError( - new GraphQLError( - `There can be only one operation named "${operationName.value}".`, - { - nodes: [ - knownOperationNames[operationName.value], - operationName, - ], - }, - ), - ); - } else { - knownOperationNames[operationName.value] = operationName; - } - } - return false; - }, - FragmentDefinition: () => false, - }; -} diff --git a/src/validation/rules/UniqueOperationTypesRule.ts b/src/validation/rules/UniqueOperationTypesRule.ts deleted file mode 100644 index f8ac6871ec..0000000000 --- a/src/validation/rules/UniqueOperationTypesRule.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - SchemaDefinitionNode, - SchemaExtensionNode, -} from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Unique operation types - * - * A GraphQL document is only valid if it has only one type per operation. - */ -export function UniqueOperationTypesRule( - context: SDLValidationContext, -): ASTVisitor { - const schema = context.getSchema(); - const definedOperationTypes = Object.create(null); - const existingOperationTypes = schema - ? { - query: schema.getQueryType(), - mutation: schema.getMutationType(), - subscription: schema.getSubscriptionType(), - } - : {}; - - return { - SchemaDefinition: checkOperationTypes, - SchemaExtension: checkOperationTypes, - }; - - function checkOperationTypes( - node: SchemaDefinitionNode | SchemaExtensionNode, - ) { - // See: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const operationTypesNodes = node.operationTypes ?? []; - - for (const operationType of operationTypesNodes) { - const operation = operationType.operation; - const alreadyDefinedOperationType = definedOperationTypes[operation]; - - if (existingOperationTypes[operation]) { - context.reportError( - new GraphQLError( - `Type for ${operation} already defined in the schema. It cannot be redefined.`, - { nodes: operationType }, - ), - ); - } else if (alreadyDefinedOperationType) { - context.reportError( - new GraphQLError( - `There can be only one ${operation} type in schema.`, - { nodes: [alreadyDefinedOperationType, operationType] }, - ), - ); - } else { - definedOperationTypes[operation] = operationType; - } - } - - return false; - } -} diff --git a/src/validation/rules/UniqueTypeNamesRule.ts b/src/validation/rules/UniqueTypeNamesRule.ts deleted file mode 100644 index a1f6588b11..0000000000 --- a/src/validation/rules/UniqueTypeNamesRule.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { TypeDefinitionNode } from '../../language/ast'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { SDLValidationContext } from '../ValidationContext'; - -/** - * Unique type names - * - * A GraphQL document is only valid if all defined types have unique names. - */ -export function UniqueTypeNamesRule(context: SDLValidationContext): ASTVisitor { - const knownTypeNames = Object.create(null); - const schema = context.getSchema(); - - return { - ScalarTypeDefinition: checkTypeName, - ObjectTypeDefinition: checkTypeName, - InterfaceTypeDefinition: checkTypeName, - UnionTypeDefinition: checkTypeName, - EnumTypeDefinition: checkTypeName, - InputObjectTypeDefinition: checkTypeName, - }; - - function checkTypeName(node: TypeDefinitionNode) { - const typeName = node.name.value; - - if (schema?.getType(typeName)) { - context.reportError( - new GraphQLError( - `Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, - { nodes: node.name }, - ), - ); - return; - } - - if (knownTypeNames[typeName]) { - context.reportError( - new GraphQLError(`There can be only one type named "${typeName}".`, { - nodes: [knownTypeNames[typeName], node.name], - }), - ); - } else { - knownTypeNames[typeName] = node.name; - } - - return false; - } -} diff --git a/src/validation/rules/UniqueVariableNamesRule.ts b/src/validation/rules/UniqueVariableNamesRule.ts deleted file mode 100644 index 3c9f76d885..0000000000 --- a/src/validation/rules/UniqueVariableNamesRule.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { groupBy } from '../../jsutils/groupBy'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ASTVisitor } from '../../language/visitor'; - -import type { ASTValidationContext } from '../ValidationContext'; - -/** - * Unique variable names - * - * A GraphQL operation is only valid if all its variables are uniquely named. - */ -export function UniqueVariableNamesRule( - context: ASTValidationContext, -): ASTVisitor { - return { - OperationDefinition(operationNode) { - // See: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - const variableDefinitions = operationNode.variableDefinitions ?? []; - - const seenVariableDefinitions = groupBy( - variableDefinitions, - (node) => node.variable.name.value, - ); - - for (const [variableName, variableNodes] of seenVariableDefinitions) { - if (variableNodes.length > 1) { - context.reportError( - new GraphQLError( - `There can be only one variable named "$${variableName}".`, - { nodes: variableNodes.map((node) => node.variable.name) }, - ), - ); - } - } - }, - }; -} diff --git a/src/validation/rules/ValuesOfCorrectTypeRule.ts b/src/validation/rules/ValuesOfCorrectTypeRule.ts deleted file mode 100644 index 3f284d7103..0000000000 --- a/src/validation/rules/ValuesOfCorrectTypeRule.ts +++ /dev/null @@ -1,230 +0,0 @@ -import { didYouMean } from '../../jsutils/didYouMean'; -import { inspect } from '../../jsutils/inspect'; -import { keyMap } from '../../jsutils/keyMap'; -import type { ObjMap } from '../../jsutils/ObjMap'; -import { suggestionList } from '../../jsutils/suggestionList'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { - ObjectFieldNode, - ObjectValueNode, - ValueNode, - VariableDefinitionNode, -} from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import { print } from '../../language/printer'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { GraphQLInputObjectType } from '../../type/definition'; -import { - getNamedType, - getNullableType, - isInputObjectType, - isLeafType, - isListType, - isNonNullType, - isRequiredInputField, -} from '../../type/definition'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Value literals of correct type - * - * A GraphQL document is only valid if all value literals are of the type - * expected at their position. - * - * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type - */ -export function ValuesOfCorrectTypeRule( - context: ValidationContext, -): ASTVisitor { - let variableDefinitions: { [key: string]: VariableDefinitionNode } = {}; - - return { - OperationDefinition: { - enter() { - variableDefinitions = {}; - }, - }, - VariableDefinition(definition) { - variableDefinitions[definition.variable.name.value] = definition; - }, - ListValue(node) { - // Note: TypeInfo will traverse into a list's item type, so look to the - // parent input type to check if it is a list. - const type = getNullableType(context.getParentInputType()); - if (!isListType(type)) { - isValidValueNode(context, node); - return false; // Don't traverse further. - } - }, - ObjectValue(node) { - const type = getNamedType(context.getInputType()); - if (!isInputObjectType(type)) { - isValidValueNode(context, node); - return false; // Don't traverse further. - } - // Ensure every required field exists. - const fieldNodeMap = keyMap(node.fields, (field) => field.name.value); - for (const fieldDef of Object.values(type.getFields())) { - const fieldNode = fieldNodeMap[fieldDef.name]; - if (!fieldNode && isRequiredInputField(fieldDef)) { - const typeStr = inspect(fieldDef.type); - context.reportError( - new GraphQLError( - `Field "${type.name}.${fieldDef.name}" of required type "${typeStr}" was not provided.`, - { nodes: node }, - ), - ); - } - } - - if (type.isOneOf) { - validateOneOfInputObject( - context, - node, - type, - fieldNodeMap, - variableDefinitions, - ); - } - }, - ObjectField(node) { - const parentType = getNamedType(context.getParentInputType()); - const fieldType = context.getInputType(); - if (!fieldType && isInputObjectType(parentType)) { - const suggestions = suggestionList( - node.name.value, - Object.keys(parentType.getFields()), - ); - context.reportError( - new GraphQLError( - `Field "${node.name.value}" is not defined by type "${parentType.name}".` + - didYouMean(suggestions), - { nodes: node }, - ), - ); - } - }, - NullValue(node) { - const type = context.getInputType(); - if (isNonNullType(type)) { - context.reportError( - new GraphQLError( - `Expected value of type "${inspect(type)}", found ${print(node)}.`, - { nodes: node }, - ), - ); - } - }, - EnumValue: (node) => isValidValueNode(context, node), - IntValue: (node) => isValidValueNode(context, node), - FloatValue: (node) => isValidValueNode(context, node), - StringValue: (node) => isValidValueNode(context, node), - BooleanValue: (node) => isValidValueNode(context, node), - }; -} - -/** - * Any value literal may be a valid representation of a Scalar, depending on - * that scalar type. - */ -function isValidValueNode(context: ValidationContext, node: ValueNode): void { - // Report any error at the full type expected by the location. - const locationType = context.getInputType(); - if (!locationType) { - return; - } - - const type = getNamedType(locationType); - - if (!isLeafType(type)) { - const typeStr = inspect(locationType); - context.reportError( - new GraphQLError( - `Expected value of type "${typeStr}", found ${print(node)}.`, - { nodes: node }, - ), - ); - return; - } - - // Scalars and Enums determine if a literal value is valid via parseLiteral(), - // which may throw or return an invalid value to indicate failure. - try { - const parseResult = type.parseLiteral(node, undefined /* variables */); - if (parseResult === undefined) { - const typeStr = inspect(locationType); - context.reportError( - new GraphQLError( - `Expected value of type "${typeStr}", found ${print(node)}.`, - { nodes: node }, - ), - ); - } - } catch (error) { - const typeStr = inspect(locationType); - if (error instanceof GraphQLError) { - context.reportError(error); - } else { - context.reportError( - new GraphQLError( - `Expected value of type "${typeStr}", found ${print(node)}; ` + - error.message, - { nodes: node, originalError: error }, - ), - ); - } - } -} - -function validateOneOfInputObject( - context: ValidationContext, - node: ObjectValueNode, - type: GraphQLInputObjectType, - fieldNodeMap: ObjMap, - variableDefinitions: { [key: string]: VariableDefinitionNode }, -): void { - const keys = Object.keys(fieldNodeMap); - const isNotExactlyOneField = keys.length !== 1; - - if (isNotExactlyOneField) { - context.reportError( - new GraphQLError( - `OneOf Input Object "${type.name}" must specify exactly one key.`, - { nodes: [node] }, - ), - ); - return; - } - - const value = fieldNodeMap[keys[0]]?.value; - const isNullLiteral = !value || value.kind === Kind.NULL; - const isVariable = value?.kind === Kind.VARIABLE; - - if (isNullLiteral) { - context.reportError( - new GraphQLError(`Field "${type.name}.${keys[0]}" must be non-null.`, { - nodes: [node], - }), - ); - return; - } - - if (isVariable) { - const variableName = value.name.value; - const definition = variableDefinitions[variableName]; - const isNullableVariable = definition.type.kind !== Kind.NON_NULL_TYPE; - - if (isNullableVariable) { - context.reportError( - new GraphQLError( - `Variable "${variableName}" must be non-nullable to be used for OneOf Input Object "${type.name}".`, - { nodes: [node] }, - ), - ); - } - } -} diff --git a/src/validation/rules/VariablesAreInputTypesRule.ts b/src/validation/rules/VariablesAreInputTypesRule.ts deleted file mode 100644 index 58d535ce81..0000000000 --- a/src/validation/rules/VariablesAreInputTypesRule.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { GraphQLError } from '../../error/GraphQLError'; - -import type { VariableDefinitionNode } from '../../language/ast'; -import { print } from '../../language/printer'; -import type { ASTVisitor } from '../../language/visitor'; - -import { isInputType } from '../../type/definition'; - -import { typeFromAST } from '../../utilities/typeFromAST'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Variables are input types - * - * A GraphQL operation is only valid if all the variables it defines are of - * input types (scalar, enum, or input object). - * - * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types - */ -export function VariablesAreInputTypesRule( - context: ValidationContext, -): ASTVisitor { - return { - VariableDefinition(node: VariableDefinitionNode) { - const type = typeFromAST(context.getSchema(), node.type); - - if (type !== undefined && !isInputType(type)) { - const variableName = node.variable.name.value; - const typeName = print(node.type); - - context.reportError( - new GraphQLError( - `Variable "$${variableName}" cannot be non-input type "${typeName}".`, - { nodes: node.type }, - ), - ); - } - }, - }; -} diff --git a/src/validation/rules/VariablesInAllowedPositionRule.ts b/src/validation/rules/VariablesInAllowedPositionRule.ts deleted file mode 100644 index 3f4cb51c27..0000000000 --- a/src/validation/rules/VariablesInAllowedPositionRule.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { inspect } from '../../jsutils/inspect'; -import type { Maybe } from '../../jsutils/Maybe'; - -import { GraphQLError } from '../../error/GraphQLError'; - -import type { ValueNode } from '../../language/ast'; -import { Kind } from '../../language/kinds'; -import type { ASTVisitor } from '../../language/visitor'; - -import type { GraphQLType } from '../../type/definition'; -import { - isInputObjectType, - isNonNullType, - isNullableType, -} from '../../type/definition'; -import type { GraphQLSchema } from '../../type/schema'; - -import { isTypeSubTypeOf } from '../../utilities/typeComparators'; -import { typeFromAST } from '../../utilities/typeFromAST'; - -import type { ValidationContext } from '../ValidationContext'; - -/** - * Variables in allowed position - * - * Variable usages must be compatible with the arguments they are passed to. - * - * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed - */ -export function VariablesInAllowedPositionRule( - context: ValidationContext, -): ASTVisitor { - let varDefMap = Object.create(null); - - return { - OperationDefinition: { - enter() { - varDefMap = Object.create(null); - }, - leave(operation) { - const usages = context.getRecursiveVariableUsages(operation); - - for (const { node, type, defaultValue, parentType } of usages) { - const varName = node.name.value; - const varDef = varDefMap[varName]; - if (varDef && type) { - // A var type is allowed if it is the same or more strict (e.g. is - // a subtype of) than the expected type. It can be more strict if - // the variable type is non-null when the expected type is nullable. - // If both are list types, the variable item type can be more strict - // than the expected item type (contravariant). - const schema = context.getSchema(); - const varType = typeFromAST(schema, varDef.type); - if ( - varType && - !allowedVariableUsage( - schema, - varType, - varDef.defaultValue, - type, - defaultValue, - ) - ) { - const varTypeStr = inspect(varType); - const typeStr = inspect(type); - context.reportError( - new GraphQLError( - `Variable "$${varName}" of type "${varTypeStr}" used in position expecting type "${typeStr}".`, - { nodes: [varDef, node] }, - ), - ); - } - - if ( - isInputObjectType(parentType) && - parentType.isOneOf && - isNullableType(varType) - ) { - context.reportError( - new GraphQLError( - `Variable "$${varName}" is of type "${varType}" but must be non-nullable to be used for OneOf Input Object "${parentType}".`, - { nodes: [varDef, node] }, - ), - ); - } - } - } - }, - }, - VariableDefinition(node) { - varDefMap[node.variable.name.value] = node; - }, - }; -} - -/** - * Returns true if the variable is allowed in the location it was found, - * which includes considering if default values exist for either the variable - * or the location at which it is located. - */ -function allowedVariableUsage( - schema: GraphQLSchema, - varType: GraphQLType, - varDefaultValue: Maybe, - locationType: GraphQLType, - locationDefaultValue: Maybe, -): boolean { - if (isNonNullType(locationType) && !isNonNullType(varType)) { - const hasNonNullVariableDefaultValue = - varDefaultValue != null && varDefaultValue.kind !== Kind.NULL; - const hasLocationDefaultValue = locationDefaultValue !== undefined; - if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { - return false; - } - const nullableLocationType = locationType.ofType; - return isTypeSubTypeOf(schema, varType, nullableLocationType); - } - return isTypeSubTypeOf(schema, varType, locationType); -} diff --git a/src/validation/rules/custom/NoDeprecatedCustomRule.ts b/src/validation/rules/custom/NoDeprecatedCustomRule.ts deleted file mode 100644 index e06ac2e789..0000000000 --- a/src/validation/rules/custom/NoDeprecatedCustomRule.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { invariant } from '../../../jsutils/invariant'; - -import { GraphQLError } from '../../../error/GraphQLError'; - -import type { ASTVisitor } from '../../../language/visitor'; - -import { getNamedType, isInputObjectType } from '../../../type/definition'; - -import type { ValidationContext } from '../../ValidationContext'; - -/** - * No deprecated - * - * A GraphQL document is only valid if all selected fields and all used enum values have not been - * deprecated. - * - * Note: This rule is optional and is not part of the Validation section of the GraphQL - * Specification. The main purpose of this rule is detection of deprecated usages and not - * necessarily to forbid their use when querying a service. - */ -export function NoDeprecatedCustomRule(context: ValidationContext): ASTVisitor { - return { - Field(node) { - const fieldDef = context.getFieldDef(); - const deprecationReason = fieldDef?.deprecationReason; - if (fieldDef && deprecationReason != null) { - const parentType = context.getParentType(); - invariant(parentType != null); - context.reportError( - new GraphQLError( - `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`, - { nodes: node }, - ), - ); - } - }, - Argument(node) { - const argDef = context.getArgument(); - const deprecationReason = argDef?.deprecationReason; - if (argDef && deprecationReason != null) { - const directiveDef = context.getDirective(); - if (directiveDef != null) { - context.reportError( - new GraphQLError( - `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, - { nodes: node }, - ), - ); - } else { - const parentType = context.getParentType(); - const fieldDef = context.getFieldDef(); - invariant(parentType != null && fieldDef != null); - context.reportError( - new GraphQLError( - `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, - { nodes: node }, - ), - ); - } - } - }, - ObjectField(node) { - const inputObjectDef = getNamedType(context.getParentInputType()); - if (isInputObjectType(inputObjectDef)) { - const inputFieldDef = inputObjectDef.getFields()[node.name.value]; - const deprecationReason = inputFieldDef?.deprecationReason; - if (deprecationReason != null) { - context.reportError( - new GraphQLError( - `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`, - { nodes: node }, - ), - ); - } - } - }, - EnumValue(node) { - const enumValueDef = context.getEnumValue(); - const deprecationReason = enumValueDef?.deprecationReason; - if (enumValueDef && deprecationReason != null) { - const enumTypeDef = getNamedType(context.getInputType()); - invariant(enumTypeDef != null); - context.reportError( - new GraphQLError( - `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`, - { nodes: node }, - ), - ); - } - }, - }; -} diff --git a/src/validation/rules/custom/NoSchemaIntrospectionCustomRule.ts b/src/validation/rules/custom/NoSchemaIntrospectionCustomRule.ts deleted file mode 100644 index 257d58d723..0000000000 --- a/src/validation/rules/custom/NoSchemaIntrospectionCustomRule.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { GraphQLError } from '../../../error/GraphQLError'; - -import type { FieldNode } from '../../../language/ast'; -import type { ASTVisitor } from '../../../language/visitor'; - -import { getNamedType } from '../../../type/definition'; -import { isIntrospectionType } from '../../../type/introspection'; - -import type { ValidationContext } from '../../ValidationContext'; - -/** - * Prohibit introspection queries - * - * A GraphQL document is only valid if all fields selected are not fields that - * return an introspection type. - * - * Note: This rule is optional and is not part of the Validation section of the - * GraphQL Specification. This rule effectively disables introspection, which - * does not reflect best practices and should only be done if absolutely necessary. - */ -export function NoSchemaIntrospectionCustomRule( - context: ValidationContext, -): ASTVisitor { - return { - Field(node: FieldNode) { - const type = getNamedType(context.getType()); - if (type && isIntrospectionType(type)) { - context.reportError( - new GraphQLError( - `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, - { nodes: node }, - ), - ); - } - }, - }; -} diff --git a/src/validation/specifiedRules.ts b/src/validation/specifiedRules.ts deleted file mode 100644 index c312c9839c..0000000000 --- a/src/validation/specifiedRules.ts +++ /dev/null @@ -1,134 +0,0 @@ -// Spec Section: "Executable Definitions" -import { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule'; -// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" -import { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule'; -// Spec Section: "Fragments on Composite Types" -import { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule'; -// Spec Section: "Argument Names" -import { - KnownArgumentNamesOnDirectivesRule, - KnownArgumentNamesRule, -} from './rules/KnownArgumentNamesRule'; -// Spec Section: "Directives Are Defined" -import { KnownDirectivesRule } from './rules/KnownDirectivesRule'; -// Spec Section: "Fragment spread target defined" -import { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule'; -// Spec Section: "Fragment Spread Type Existence" -import { KnownTypeNamesRule } from './rules/KnownTypeNamesRule'; -// Spec Section: "Lone Anonymous Operation" -import { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule'; -// SDL-specific validation rules -import { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule'; -// TODO: Spec Section -import { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule'; -// Spec Section: "Fragments must not form cycles" -import { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule'; -// Spec Section: "All Variable Used Defined" -import { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule'; -// Spec Section: "Fragments must be used" -import { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule'; -// Spec Section: "All Variables Used" -import { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule'; -// Spec Section: "Field Selection Merging" -import { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule'; -// Spec Section: "Fragment spread is possible" -import { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule'; -import { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule'; -// Spec Section: "Argument Optionality" -import { - ProvidedRequiredArgumentsOnDirectivesRule, - ProvidedRequiredArgumentsRule, -} from './rules/ProvidedRequiredArgumentsRule'; -// Spec Section: "Leaf Field Selections" -import { ScalarLeafsRule } from './rules/ScalarLeafsRule'; -// Spec Section: "Subscriptions with Single Root Field" -import { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule'; -import { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule'; -// Spec Section: "Argument Uniqueness" -import { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule'; -import { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule'; -// Spec Section: "Directives Are Unique Per Location" -import { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule'; -import { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule'; -import { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule'; -// Spec Section: "Fragment Name Uniqueness" -import { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule'; -// Spec Section: "Input Object Field Uniqueness" -import { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule'; -// Spec Section: "Operation Name Uniqueness" -import { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule'; -import { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule'; -import { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule'; -// Spec Section: "Variable Uniqueness" -import { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule'; -// Spec Section: "Value Type Correctness" -import { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule'; -// Spec Section: "Variables are Input Types" -import { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule'; -// Spec Section: "All Variable Usages Are Allowed" -import { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule'; -import type { SDLValidationRule, ValidationRule } from './ValidationContext'; - -/** - * Technically these aren't part of the spec but they are strongly encouraged - * validation rules. - */ -export const recommendedRules = Object.freeze([MaxIntrospectionDepthRule]); - -/** - * This set includes all validation rules defined by the GraphQL spec. - * - * The order of the rules in this list has been adjusted to lead to the - * most clear output when encountering multiple validation errors. - */ -export const specifiedRules: ReadonlyArray = Object.freeze([ - ExecutableDefinitionsRule, - UniqueOperationNamesRule, - LoneAnonymousOperationRule, - SingleFieldSubscriptionsRule, - KnownTypeNamesRule, - FragmentsOnCompositeTypesRule, - VariablesAreInputTypesRule, - ScalarLeafsRule, - FieldsOnCorrectTypeRule, - UniqueFragmentNamesRule, - KnownFragmentNamesRule, - NoUnusedFragmentsRule, - PossibleFragmentSpreadsRule, - NoFragmentCyclesRule, - UniqueVariableNamesRule, - NoUndefinedVariablesRule, - NoUnusedVariablesRule, - KnownDirectivesRule, - UniqueDirectivesPerLocationRule, - KnownArgumentNamesRule, - UniqueArgumentNamesRule, - ValuesOfCorrectTypeRule, - ProvidedRequiredArgumentsRule, - VariablesInAllowedPositionRule, - OverlappingFieldsCanBeMergedRule, - UniqueInputFieldNamesRule, - ...recommendedRules, -]); - -/** - * @internal - */ -export const specifiedSDLRules: ReadonlyArray = - Object.freeze([ - LoneSchemaDefinitionRule, - UniqueOperationTypesRule, - UniqueTypeNamesRule, - UniqueEnumValueNamesRule, - UniqueFieldDefinitionNamesRule, - UniqueArgumentDefinitionNamesRule, - UniqueDirectiveNamesRule, - KnownTypeNamesRule, - KnownDirectivesRule, - UniqueDirectivesPerLocationRule, - PossibleTypeExtensionsRule, - KnownArgumentNamesOnDirectivesRule, - UniqueArgumentNamesRule, - UniqueInputFieldNamesRule, - ProvidedRequiredArgumentsOnDirectivesRule, - ]); diff --git a/src/validation/validate.ts b/src/validation/validate.ts deleted file mode 100644 index 7259874240..0000000000 --- a/src/validation/validate.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { devAssert } from '../jsutils/devAssert'; -import type { Maybe } from '../jsutils/Maybe'; - -import { GraphQLError } from '../error/GraphQLError'; - -import type { DocumentNode } from '../language/ast'; -import { visit, visitInParallel } from '../language/visitor'; - -import type { GraphQLSchema } from '../type/schema'; -import { assertValidSchema } from '../type/validate'; - -import { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo'; - -import { specifiedRules, specifiedSDLRules } from './specifiedRules'; -import type { SDLValidationRule, ValidationRule } from './ValidationContext'; -import { SDLValidationContext, ValidationContext } from './ValidationContext'; - -/** - * Implements the "Validation" section of the spec. - * - * Validation runs synchronously, returning an array of encountered errors, or - * an empty array if no errors were encountered and the document is valid. - * - * A list of specific validation rules may be provided. If not provided, the - * default list of rules defined by the GraphQL specification will be used. - * - * Each validation rules is a function which returns a visitor - * (see the language/visitor API). Visitor methods are expected to return - * GraphQLErrors, or Arrays of GraphQLErrors when invalid. - * - * Validate will stop validation after a `maxErrors` limit has been reached. - * Attackers can send pathologically invalid queries to induce a DoS attack, - * so by default `maxErrors` set to 100 errors. - * - * Optionally a custom TypeInfo instance may be provided. If not provided, one - * will be created from the provided schema. - */ -export function validate( - schema: GraphQLSchema, - documentAST: DocumentNode, - rules: ReadonlyArray = specifiedRules, - options?: { maxErrors?: number }, - - /** @deprecated will be removed in 17.0.0 */ - typeInfo: TypeInfo = new TypeInfo(schema), -): ReadonlyArray { - const maxErrors = options?.maxErrors ?? 100; - - devAssert(documentAST, 'Must provide document.'); - // If the schema used for validation is invalid, throw an error. - assertValidSchema(schema); - - const abortObj = Object.freeze({}); - const errors: Array = []; - const context = new ValidationContext( - schema, - documentAST, - typeInfo, - (error) => { - if (errors.length >= maxErrors) { - errors.push( - new GraphQLError( - 'Too many validation errors, error limit reached. Validation aborted.', - ), - ); - // eslint-disable-next-line @typescript-eslint/no-throw-literal - throw abortObj; - } - errors.push(error); - }, - ); - - // This uses a specialized visitor which runs multiple visitors in parallel, - // while maintaining the visitor skip and break API. - const visitor = visitInParallel(rules.map((rule) => rule(context))); - - // Visit the whole document with each instance of all provided rules. - try { - visit(documentAST, visitWithTypeInfo(typeInfo, visitor)); - } catch (e) { - if (e !== abortObj) { - throw e; - } - } - return errors; -} - -/** - * @internal - */ -export function validateSDL( - documentAST: DocumentNode, - schemaToExtend?: Maybe, - rules: ReadonlyArray = specifiedSDLRules, -): ReadonlyArray { - const errors: Array = []; - const context = new SDLValidationContext( - documentAST, - schemaToExtend, - (error) => { - errors.push(error); - }, - ); - - const visitors = rules.map((rule) => rule(context)); - visit(documentAST, visitInParallel(visitors)); - return errors; -} - -/** - * Utility function which asserts a SDL document is valid by throwing an error - * if it is invalid. - * - * @internal - */ -export function assertValidSDL(documentAST: DocumentNode): void { - const errors = validateSDL(documentAST); - if (errors.length !== 0) { - throw new Error(errors.map((error) => error.message).join('\n\n')); - } -} - -/** - * Utility function which asserts a SDL document is valid by throwing an error - * if it is invalid. - * - * @internal - */ -export function assertValidSDLExtension( - documentAST: DocumentNode, - schema: GraphQLSchema, -): void { - const errors = validateSDL(documentAST, schema); - if (errors.length !== 0) { - throw new Error(errors.map((error) => error.message).join('\n\n')); - } -} diff --git a/src/version.ts b/src/version.ts deleted file mode 100644 index 0b4d797129..0000000000 --- a/src/version.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Note: This file is autogenerated using "resources/gen-version.js" script and -// automatically updated by "npm version" command. - -/** - * A string containing the version of the GraphQL.js library - */ -export const version = '16.11.0' as string; - -/** - * An object containing the components of the GraphQL.js version string - */ -export const versionInfo = Object.freeze({ - major: 16 as number, - minor: 11 as number, - patch: 0 as number, - preReleaseTag: null as string | null, -}); diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 8dfb0f4794..0000000000 --- a/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "include": ["src/**/*"], - "compilerOptions": { - "module": "commonjs", - "lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"], - "target": "es2019", - "strict": true, - "useUnknownInCatchVariables": false, - "noEmit": true, - "isolatedModules": true, - "importsNotUsedAsValues": "error", - "forceConsistentCasingInFileNames": true - } -} diff --git a/type/assertName.d.ts b/type/assertName.d.ts new file mode 100644 index 0000000000..1e21508c71 --- /dev/null +++ b/type/assertName.d.ts @@ -0,0 +1,10 @@ +/** + * Upholds the spec rules about naming. + */ +export declare function assertName(name: string): string; +/** + * Upholds the spec rules about naming enum values. + * + * @internal + */ +export declare function assertEnumValueName(name: string): string; diff --git a/type/assertName.js b/type/assertName.js new file mode 100644 index 0000000000..6308280e3c --- /dev/null +++ b/type/assertName.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.assertName = assertName; +exports.assertEnumValueName = assertEnumValueName; +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const characterClasses_js_1 = require("../language/characterClasses.js"); +/** + * Upholds the spec rules about naming. + */ +function assertName(name) { + if (name.length === 0) { + throw new GraphQLError_js_1.GraphQLError('Expected name to be a non-empty string.'); + } + for (let i = 1; i < name.length; ++i) { + if (!(0, characterClasses_js_1.isNameContinue)(name.charCodeAt(i))) { + throw new GraphQLError_js_1.GraphQLError(`Names must only contain [_a-zA-Z0-9] but "${name}" does not.`); + } + } + if (!(0, characterClasses_js_1.isNameStart)(name.charCodeAt(0))) { + throw new GraphQLError_js_1.GraphQLError(`Names must start with [_a-zA-Z] but "${name}" does not.`); + } + return name; +} +/** + * Upholds the spec rules about naming enum values. + * + * @internal + */ +function assertEnumValueName(name) { + if (name === 'true' || name === 'false' || name === 'null') { + throw new GraphQLError_js_1.GraphQLError(`Enum values cannot be named: ${name}`); + } + return assertName(name); +} +//# sourceMappingURL=assertName.js.map \ No newline at end of file diff --git a/type/assertName.js.map b/type/assertName.js.map new file mode 100644 index 0000000000..01e3ed839c --- /dev/null +++ b/type/assertName.js.map @@ -0,0 +1 @@ +{"version":3,"file":"assertName.js","sourceRoot":"","sources":["../../src/type/assertName.ts"],"names":[],"mappings":";;AAOA,gCAoBC;AAOD,kDAKC;AAvCD,8DAAwD;AAExD,yEAA8E;AAE9E;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,8BAAY,CAAC,yCAAyC,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,IAAA,oCAAc,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,8BAAY,CACpB,6CAA6C,IAAI,aAAa,CAC/D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,CAAC,IAAA,iCAAW,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,8BAAY,CACpB,wCAAwC,IAAI,aAAa,CAC1D,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3D,MAAM,IAAI,8BAAY,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { GraphQLError } from '../error/GraphQLError.js';\n\nimport { isNameContinue, isNameStart } from '../language/characterClasses.js';\n\n/**\n * Upholds the spec rules about naming.\n */\nexport function assertName(name: string): string {\n if (name.length === 0) {\n throw new GraphQLError('Expected name to be a non-empty string.');\n }\n\n for (let i = 1; i < name.length; ++i) {\n if (!isNameContinue(name.charCodeAt(i))) {\n throw new GraphQLError(\n `Names must only contain [_a-zA-Z0-9] but \"${name}\" does not.`,\n );\n }\n }\n\n if (!isNameStart(name.charCodeAt(0))) {\n throw new GraphQLError(\n `Names must start with [_a-zA-Z] but \"${name}\" does not.`,\n );\n }\n\n return name;\n}\n\n/**\n * Upholds the spec rules about naming enum values.\n *\n * @internal\n */\nexport function assertEnumValueName(name: string): string {\n if (name === 'true' || name === 'false' || name === 'null') {\n throw new GraphQLError(`Enum values cannot be named: ${name}`);\n }\n return assertName(name);\n}\n"]} \ No newline at end of file diff --git a/type/assertName.mjs b/type/assertName.mjs new file mode 100644 index 0000000000..ad0d77b907 --- /dev/null +++ b/type/assertName.mjs @@ -0,0 +1,31 @@ +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { isNameContinue, isNameStart } from "../language/characterClasses.mjs"; +/** + * Upholds the spec rules about naming. + */ +export function assertName(name) { + if (name.length === 0) { + throw new GraphQLError('Expected name to be a non-empty string.'); + } + for (let i = 1; i < name.length; ++i) { + if (!isNameContinue(name.charCodeAt(i))) { + throw new GraphQLError(`Names must only contain [_a-zA-Z0-9] but "${name}" does not.`); + } + } + if (!isNameStart(name.charCodeAt(0))) { + throw new GraphQLError(`Names must start with [_a-zA-Z] but "${name}" does not.`); + } + return name; +} +/** + * Upholds the spec rules about naming enum values. + * + * @internal + */ +export function assertEnumValueName(name) { + if (name === 'true' || name === 'false' || name === 'null') { + throw new GraphQLError(`Enum values cannot be named: ${name}`); + } + return assertName(name); +} +//# sourceMappingURL=assertName.js.map \ No newline at end of file diff --git a/type/assertName.mjs.map b/type/assertName.mjs.map new file mode 100644 index 0000000000..22ccf60183 --- /dev/null +++ b/type/assertName.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"assertName.js","sourceRoot":"","sources":["../../src/type/assertName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kCAAiC;AAExD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,yCAAwC;AAE9E;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,YAAY,CAAC,yCAAyC,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,YAAY,CACpB,6CAA6C,IAAI,aAAa,CAC/D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,YAAY,CACpB,wCAAwC,IAAI,aAAa,CAC1D,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3D,MAAM,IAAI,YAAY,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { GraphQLError } from '../error/GraphQLError.js';\n\nimport { isNameContinue, isNameStart } from '../language/characterClasses.js';\n\n/**\n * Upholds the spec rules about naming.\n */\nexport function assertName(name: string): string {\n if (name.length === 0) {\n throw new GraphQLError('Expected name to be a non-empty string.');\n }\n\n for (let i = 1; i < name.length; ++i) {\n if (!isNameContinue(name.charCodeAt(i))) {\n throw new GraphQLError(\n `Names must only contain [_a-zA-Z0-9] but \"${name}\" does not.`,\n );\n }\n }\n\n if (!isNameStart(name.charCodeAt(0))) {\n throw new GraphQLError(\n `Names must start with [_a-zA-Z] but \"${name}\" does not.`,\n );\n }\n\n return name;\n}\n\n/**\n * Upholds the spec rules about naming enum values.\n *\n * @internal\n */\nexport function assertEnumValueName(name: string): string {\n if (name === 'true' || name === 'false' || name === 'null') {\n throw new GraphQLError(`Enum values cannot be named: ${name}`);\n }\n return assertName(name);\n}\n"]} \ No newline at end of file diff --git a/type/definition.d.ts b/type/definition.d.ts new file mode 100644 index 0000000000..cb428f8071 --- /dev/null +++ b/type/definition.d.ts @@ -0,0 +1,891 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { Path } from '../jsutils/Path.js'; +import type { PromiseOrValue } from '../jsutils/PromiseOrValue.js'; +import type { ConstValueNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, EnumValueDefinitionNode, FieldDefinitionNode, FieldNode, FragmentDefinitionNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, OperationDefinitionNode, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, UnionTypeDefinitionNode, UnionTypeExtensionNode, ValueNode } from '../language/ast.js'; +import type { GraphQLVariableSignature } from '../execution/getVariableSignature.js'; +import type { VariableValues } from '../execution/values.js'; +import type { GraphQLDirective } from './directives.js'; +import type { GraphQLSchema } from './schema.js'; +/** + * These are all of the possible kinds of types. + */ +export type GraphQLType = GraphQLNamedType | GraphQLWrappingType; +export declare function isType(type: unknown): type is GraphQLType; +export declare function assertType(type: unknown): GraphQLType; +/** + * There are predicates for each GraphQL schema element. + */ +export declare function isScalarType(type: unknown): type is GraphQLScalarType; +export declare function assertScalarType(type: unknown): GraphQLScalarType; +export declare function isObjectType(type: unknown): type is GraphQLObjectType; +export declare function assertObjectType(type: unknown): GraphQLObjectType; +export declare function isField(field: unknown): field is GraphQLField; +export declare function assertField(field: unknown): GraphQLField; +export declare function isArgument(arg: unknown): arg is GraphQLArgument; +export declare function assertArgument(arg: unknown): GraphQLArgument; +export declare function isInterfaceType(type: unknown): type is GraphQLInterfaceType; +export declare function assertInterfaceType(type: unknown): GraphQLInterfaceType; +export declare function isUnionType(type: unknown): type is GraphQLUnionType; +export declare function assertUnionType(type: unknown): GraphQLUnionType; +export declare function isEnumType(type: unknown): type is GraphQLEnumType; +export declare function assertEnumType(type: unknown): GraphQLEnumType; +export declare function isEnumValue(value: unknown): value is GraphQLEnumValue; +export declare function assertEnumValue(value: unknown): GraphQLEnumValue; +export declare function isInputObjectType(type: unknown): type is GraphQLInputObjectType; +export declare function assertInputObjectType(type: unknown): GraphQLInputObjectType; +export declare function isInputField(field: unknown): field is GraphQLInputField; +export declare function assertInputField(field: unknown): GraphQLInputField; +export declare function isListType(type: GraphQLInputType): type is GraphQLList; +export declare function isListType(type: GraphQLOutputType): type is GraphQLList; +export declare function isListType(type: unknown): type is GraphQLList; +export declare function assertListType(type: unknown): GraphQLList; +export declare function isNonNullType(type: GraphQLInputType): type is GraphQLNonNull; +export declare function isNonNullType(type: GraphQLOutputType): type is GraphQLNonNull; +export declare function isNonNullType(type: unknown): type is GraphQLNonNull; +export declare function assertNonNullType(type: unknown): GraphQLNonNull; +/** + * These types may be used as input types for arguments and directives. + */ +export type GraphQLNullableInputType = GraphQLNamedInputType | GraphQLList; +export type GraphQLInputType = GraphQLNullableInputType | GraphQLNonNull; +export declare function isInputType(type: unknown): type is GraphQLInputType; +export declare function assertInputType(type: unknown): GraphQLInputType; +/** + * These types may be used as output types as the result of fields. + */ +export type GraphQLNullableOutputType = GraphQLNamedOutputType | GraphQLList; +export type GraphQLOutputType = GraphQLNullableOutputType | GraphQLNonNull; +export declare function isOutputType(type: unknown): type is GraphQLOutputType; +export declare function assertOutputType(type: unknown): GraphQLOutputType; +/** + * These types may describe types which may be leaf values. + */ +export type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType; +export declare function isLeafType(type: unknown): type is GraphQLLeafType; +export declare function assertLeafType(type: unknown): GraphQLLeafType; +/** + * These types may describe the parent context of a selection set. + */ +export type GraphQLCompositeType = GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType; +export declare function isCompositeType(type: unknown): type is GraphQLCompositeType; +export declare function assertCompositeType(type: unknown): GraphQLCompositeType; +/** + * These types may describe the parent context of a selection set. + */ +export type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType; +export declare function isAbstractType(type: unknown): type is GraphQLAbstractType; +export declare function assertAbstractType(type: unknown): GraphQLAbstractType; +/** + * List Type Wrapper + * + * A list is a wrapping type which points to another type. + * Lists are often created within the context of defining the fields of + * an object type. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * parents: { type: new GraphQLList(PersonType) }, + * children: { type: new GraphQLList(PersonType) }, + * }) + * }) + * ``` + */ +export declare class GraphQLList implements GraphQLSchemaElement { + readonly ofType: T; + constructor(ofType: T); + get [Symbol.toStringTag](): string; + toString(): string; + toJSON(): string; +} +/** + * Non-Null Type Wrapper + * + * A non-null is a wrapping type which points to another type. + * Non-null types enforce that their values are never null and can ensure + * an error is raised if this ever occurs during a request. It is useful for + * fields which you can make a strong guarantee on non-nullability, for example + * usually the id field of a database row will never be null. + * + * Example: + * + * ```ts + * const RowType = new GraphQLObjectType({ + * name: 'Row', + * fields: () => ({ + * id: { type: new GraphQLNonNull(GraphQLString) }, + * }) + * }) + * ``` + * Note: the enforcement of non-nullability occurs within the executor. + */ +export declare class GraphQLNonNull implements GraphQLSchemaElement { + readonly ofType: T; + constructor(ofType: T); + get [Symbol.toStringTag](): string; + toString(): string; + toJSON(): string; +} +/** + * These types wrap and modify other types + */ +export type GraphQLWrappingType = GraphQLList | GraphQLNonNull; +export declare function isWrappingType(type: unknown): type is GraphQLWrappingType; +export declare function assertWrappingType(type: unknown): GraphQLWrappingType; +/** + * These types can all accept null as a value. + */ +export type GraphQLNullableType = GraphQLNamedType | GraphQLList; +export declare function isNullableType(type: unknown): type is GraphQLNullableType; +export declare function assertNullableType(type: unknown): GraphQLNullableType; +export declare function getNullableType(type: undefined | null): void; +export declare function getNullableType(type: T | GraphQLNonNull): T; +export declare function getNullableType(type: Maybe): GraphQLNullableType | undefined; +/** + * These named types do not include modifiers like List or NonNull. + */ +export type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType; +export type GraphQLNamedInputType = GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType; +export type GraphQLNamedOutputType = GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType; +export declare function isNamedType(type: unknown): type is GraphQLNamedType; +export declare function assertNamedType(type: unknown): GraphQLNamedType; +export declare function getNamedType(type: undefined | null): void; +export declare function getNamedType(type: GraphQLInputType): GraphQLNamedInputType; +export declare function getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType; +export declare function getNamedType(type: GraphQLType): GraphQLNamedType; +export declare function getNamedType(type: Maybe): GraphQLNamedType | undefined; +/** + * An interface for all Schema Elements. + */ +export interface GraphQLSchemaElement { + toString: () => string; + toJSON: () => string; +} +/** + * Used while defining GraphQL types to allow for circular references in + * otherwise immutable type definitions. + */ +export type ThunkReadonlyArray = (() => ReadonlyArray) | ReadonlyArray; +export type ThunkObjMap = (() => ObjMap) | ObjMap; +export declare function resolveReadonlyArrayThunk(thunk: ThunkReadonlyArray): ReadonlyArray; +export declare function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLScalarTypeExtensions { + [attributeName: string | symbol]: unknown; +} +/** + * Scalar Type Definition + * + * The leaf values of any request and input values to arguments are + * Scalars (or Enums) and are defined with a name and a series of functions + * used to parse input from ast or variables and to ensure validity. + * + * If a type's coerceOutputValue function returns `null` or does not return a + * value (i.e. it returns `undefined`) then an error will be raised and a + * `null` value will be returned in the response. It is always better to + * validate. + * + * Example: + * + * ```ts + * function ensureOdd(value) { + * if (!Number.isFinite(value)) { + * throw new Error( + * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`, + * ); + * } + * + * if (value % 2 === 0) { + * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`); + * } + * } + * + * const OddType = new GraphQLScalarType({ + * name: 'Odd', + * coerceOutputValue(value) { + * return ensureOdd(value); + * }, + * coerceInputValue(value) { + * return ensureOdd(value); + * } + * valueToLiteral(value) { + * return parse(`${ensureOdd(value)`); + * } + * }); + * ``` + * + * Custom scalars behavior is defined via the following functions: + * + * - coerceOutputValue(value): Implements "Result Coercion". Given an internal value, + * produces an external value valid for this type. Returns undefined or + * throws an error to indicate invalid values. + * + * - coerceInputValue(value): Implements "Input Coercion" for values. Given an + * external value (for example, variable values), produces an internal value + * valid for this type. Returns undefined or throws an error to indicate + * invalid values. + * + * - coerceInputLiteral(ast): Implements "Input Coercion" for constant literals. + * Given an GraphQL literal (AST) (for example, an argument value), produces + * an internal value valid for this type. Returns undefined or throws an + * error to indicate invalid values. + * + * - valueToLiteral(value): Converts an external value to a GraphQL + * literal (AST). Returns undefined or throws an error to indicate + * invalid values. + * + * Deprecated, to be removed in v18: + * + * - serialize(value): Implements "Result Coercion". Renamed to + * `coerceOutputValue()`. + * + * - parseValue(value): Implements "Input Coercion" for values. Renamed to + * `coerceInputValue()`. + * + * - parseLiteral(ast): Implements "Input Coercion" for literals including + * non-specified replacement of variables embedded within complex scalars. + * Replaced by the combination of the `replaceVariables()` utility and the + * `coerceInputLiteral()` method. + * + */ +export declare class GraphQLScalarType implements GraphQLSchemaElement { + name: string; + description: Maybe; + specifiedByURL: Maybe; + /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */ + serialize: GraphQLScalarSerializer; + /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */ + parseValue: GraphQLScalarValueParser; + /** @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */ + parseLiteral: GraphQLScalarLiteralParser; + coerceOutputValue: GraphQLScalarOutputValueCoercer; + coerceInputValue: GraphQLScalarInputValueCoercer; + coerceInputLiteral: GraphQLScalarInputLiteralCoercer | undefined; + valueToLiteral: GraphQLScalarValueToLiteral | undefined; + extensions: Readonly; + astNode: Maybe; + extensionASTNodes: ReadonlyArray; + constructor(config: Readonly>); + get [Symbol.toStringTag](): string; + toConfig(): GraphQLScalarTypeNormalizedConfig; + toString(): string; + toJSON(): string; +} +export type GraphQLScalarSerializer = (outputValue: unknown) => TExternal; +export type GraphQLScalarOutputValueCoercer = (outputValue: unknown) => TExternal; +export type GraphQLScalarValueParser = (inputValue: unknown) => TInternal; +export type GraphQLScalarInputValueCoercer = (inputValue: unknown) => TInternal; +export type GraphQLScalarLiteralParser = (valueNode: ValueNode, variables: Maybe>) => Maybe; +export type GraphQLScalarInputLiteralCoercer = (valueNode: ConstValueNode) => Maybe; +export type GraphQLScalarValueToLiteral = (inputValue: unknown) => ConstValueNode | undefined; +export interface GraphQLScalarTypeConfig { + name: string; + description?: Maybe; + specifiedByURL?: Maybe; + /** Serializes an internal value to include in a response. */ + /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */ + serialize?: GraphQLScalarSerializer | undefined; + /** Parses an externally provided value to use as an input. */ + /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */ + parseValue?: GraphQLScalarValueParser | undefined; + /** Parses an externally provided literal value to use as an input. */ + /** @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */ + parseLiteral?: GraphQLScalarLiteralParser | undefined; + /** Coerces an internal value to include in a response. */ + coerceOutputValue?: GraphQLScalarOutputValueCoercer | undefined; + /** Coerces an externally provided value to use as an input. */ + coerceInputValue?: GraphQLScalarInputValueCoercer | undefined; + /** Coerces an externally provided const literal value to use as an input. */ + coerceInputLiteral?: GraphQLScalarInputLiteralCoercer | undefined; + /** Translates an externally provided value to a literal (AST). */ + valueToLiteral?: GraphQLScalarValueToLiteral | undefined; + extensions?: Maybe>; + astNode?: Maybe; + extensionASTNodes?: Maybe>; +} +export interface GraphQLScalarTypeNormalizedConfig extends GraphQLScalarTypeConfig { + serialize: GraphQLScalarSerializer; + parseValue: GraphQLScalarValueParser; + parseLiteral: GraphQLScalarLiteralParser; + coerceOutputValue: GraphQLScalarOutputValueCoercer; + coerceInputValue: GraphQLScalarInputValueCoercer; + coerceInputLiteral: GraphQLScalarInputLiteralCoercer | undefined; + extensions: Readonly; + extensionASTNodes: ReadonlyArray; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + * + * We've provided these template arguments because this is an open type and + * you may find them useful. + */ +export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> { + [attributeName: string | symbol]: unknown; +} +/** + * Object Type Definition + * + * Almost all of the GraphQL types you define will be object types. Object types + * have a name, but most importantly describe their fields. + * + * Example: + * + * ```ts + * const AddressType = new GraphQLObjectType({ + * name: 'Address', + * fields: { + * street: { type: GraphQLString }, + * number: { type: GraphQLInt }, + * formatted: { + * type: GraphQLString, + * resolve(obj) { + * return obj.number + ' ' + obj.street + * } + * } + * } + * }); + * ``` + * + * When two types need to refer to each other, or a type needs to refer to + * itself in a field, you can use a function expression (aka a closure or a + * thunk) to supply the fields lazily. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * name: { type: GraphQLString }, + * bestFriend: { type: PersonType }, + * }) + * }); + * ``` + */ +export declare class GraphQLObjectType implements GraphQLSchemaElement { + name: string; + description: Maybe; + isTypeOf: Maybe>; + extensions: Readonly>; + astNode: Maybe; + extensionASTNodes: ReadonlyArray; + private _fields; + private _interfaces; + constructor(config: Readonly>); + get [Symbol.toStringTag](): string; + getFields(): GraphQLFieldMap; + getInterfaces(): ReadonlyArray; + toConfig(): GraphQLObjectTypeNormalizedConfig; + toString(): string; + toJSON(): string; +} +export interface GraphQLObjectTypeConfig { + name: string; + description?: Maybe; + interfaces?: ThunkReadonlyArray | undefined; + fields: ThunkObjMap>; + isTypeOf?: Maybe>; + extensions?: Maybe>>; + astNode?: Maybe; + extensionASTNodes?: Maybe>; +} +export interface GraphQLObjectTypeNormalizedConfig extends GraphQLObjectTypeConfig { + interfaces: ReadonlyArray; + fields: GraphQLFieldNormalizedConfigMap; + extensions: Readonly>; + extensionASTNodes: ReadonlyArray; +} +export type GraphQLTypeResolver = (value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: GraphQLAbstractType) => PromiseOrValue; +export type GraphQLIsTypeOfFn = (source: TSource, context: TContext, info: GraphQLResolveInfo) => PromiseOrValue; +export type GraphQLFieldResolver = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo, abortSignal: AbortSignal | undefined) => TResult; +export interface GraphQLResolveInfo { + readonly fieldName: string; + readonly fieldNodes: ReadonlyArray; + readonly returnType: GraphQLOutputType; + readonly parentType: GraphQLObjectType; + readonly path: Path; + readonly schema: GraphQLSchema; + readonly fragments: ObjMap; + readonly rootValue: unknown; + readonly operation: OperationDefinitionNode; + readonly variableValues: VariableValues; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + * + * We've provided these template arguments because this is an open type and + * you may find them useful. + */ +export interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> { + [attributeName: string | symbol]: unknown; +} +export interface GraphQLFieldConfig { + description?: Maybe; + type: GraphQLOutputType; + args?: GraphQLFieldConfigArgumentMap | undefined; + resolve?: GraphQLFieldResolver | undefined; + subscribe?: GraphQLFieldResolver | undefined; + deprecationReason?: Maybe; + extensions?: Maybe>>; + astNode?: Maybe; +} +export interface GraphQLFieldNormalizedConfig extends GraphQLFieldConfig { + args: GraphQLFieldNormalizedConfigArgumentMap; + extensions: Readonly>; +} +export type GraphQLFieldConfigArgumentMap = ObjMap; +export type GraphQLFieldNormalizedConfigArgumentMap = ObjMap; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLArgumentExtensions { + [attributeName: string | symbol]: unknown; +} +export interface GraphQLArgumentConfig { + description?: Maybe; + type: GraphQLInputType; + /** @deprecated use default instead, defaultValue will be removed in v18 **/ + defaultValue?: unknown; + default?: GraphQLDefaultInput | undefined; + deprecationReason?: Maybe; + extensions?: Maybe>; + astNode?: Maybe; +} +export interface GraphQLArgumentNormalizedConfig extends GraphQLArgumentConfig { + default: GraphQLDefaultInput | undefined; + extensions: Readonly; +} +export type GraphQLFieldConfigMap = ObjMap>; +export type GraphQLFieldNormalizedConfigMap = ObjMap>; +export declare class GraphQLField implements GraphQLSchemaElement { + parentType: GraphQLObjectType | GraphQLInterfaceType | undefined; + name: string; + description: Maybe; + type: GraphQLOutputType; + args: ReadonlyArray; + resolve?: GraphQLFieldResolver | undefined; + subscribe?: GraphQLFieldResolver | undefined; + deprecationReason: Maybe; + extensions: Readonly>; + astNode: Maybe; + constructor(parentType: GraphQLObjectType | GraphQLInterfaceType | undefined, name: string, config: GraphQLFieldConfig); + get [Symbol.toStringTag](): string; + toConfig(): GraphQLFieldNormalizedConfig; + toString(): string; + toJSON(): string; +} +export declare class GraphQLArgument implements GraphQLSchemaElement { + parent: GraphQLField | GraphQLDirective; + name: string; + description: Maybe; + type: GraphQLInputType; + defaultValue: unknown; + default: GraphQLDefaultInput | undefined; + deprecationReason: Maybe; + extensions: Readonly; + astNode: Maybe; + constructor(parent: GraphQLField | GraphQLDirective, name: string, config: GraphQLArgumentConfig); + get [Symbol.toStringTag](): string; + toConfig(): GraphQLArgumentNormalizedConfig; + toString(): string; + toJSON(): string; +} +export declare function isRequiredArgument(arg: GraphQLArgument | GraphQLVariableSignature): boolean; +export type GraphQLFieldMap = ObjMap>; +export type GraphQLDefaultInput = { + value: unknown; + literal?: never; +} | { + literal: ConstValueNode; + value?: never; +}; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLInterfaceTypeExtensions { + [attributeName: string | symbol]: unknown; +} +/** + * Interface Type Definition + * + * When a field can return one of a heterogeneous set of types, a Interface type + * is used to describe what types are possible, what fields are in common across + * all types, as well as a function to determine which type is actually used + * when the field is resolved. + * + * Example: + * + * ```ts + * const EntityType = new GraphQLInterfaceType({ + * name: 'Entity', + * fields: { + * name: { type: GraphQLString } + * } + * }); + * ``` + */ +export declare class GraphQLInterfaceType implements GraphQLSchemaElement { + name: string; + description: Maybe; + resolveType: Maybe>; + extensions: Readonly; + astNode: Maybe; + extensionASTNodes: ReadonlyArray; + private _fields; + private _interfaces; + constructor(config: Readonly>); + get [Symbol.toStringTag](): string; + getFields(): GraphQLFieldMap; + getInterfaces(): ReadonlyArray; + toConfig(): GraphQLInterfaceTypeNormalizedConfig; + toString(): string; + toJSON(): string; +} +export interface GraphQLInterfaceTypeConfig { + name: string; + description?: Maybe; + interfaces?: ThunkReadonlyArray | undefined; + fields: ThunkObjMap>; + /** + * Optionally provide a custom type resolver function. If one is not provided, + * the default implementation will call `isTypeOf` on each implementing + * Object type. + */ + resolveType?: Maybe>; + extensions?: Maybe>; + astNode?: Maybe; + extensionASTNodes?: Maybe>; +} +export interface GraphQLInterfaceTypeNormalizedConfig extends GraphQLInterfaceTypeConfig { + interfaces: ReadonlyArray; + fields: GraphQLFieldNormalizedConfigMap; + extensions: Readonly; + extensionASTNodes: ReadonlyArray; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLUnionTypeExtensions { + [attributeName: string | symbol]: unknown; +} +/** + * Union Type Definition + * + * When a field can return one of a heterogeneous set of types, a Union type + * is used to describe what types are possible as well as providing a function + * to determine which type is actually used when the field is resolved. + * + * Example: + * + * ```ts + * const PetType = new GraphQLUnionType({ + * name: 'Pet', + * types: [ DogType, CatType ], + * resolveType(value) { + * if (value instanceof Dog) { + * return DogType; + * } + * if (value instanceof Cat) { + * return CatType; + * } + * } + * }); + * ``` + */ +export declare class GraphQLUnionType implements GraphQLSchemaElement { + name: string; + description: Maybe; + resolveType: Maybe>; + extensions: Readonly; + astNode: Maybe; + extensionASTNodes: ReadonlyArray; + private _types; + constructor(config: Readonly>); + get [Symbol.toStringTag](): string; + getTypes(): ReadonlyArray; + toConfig(): GraphQLUnionTypeNormalizedConfig; + toString(): string; + toJSON(): string; +} +export interface GraphQLUnionTypeConfig { + name: string; + description?: Maybe; + types: ThunkReadonlyArray; + /** + * Optionally provide a custom type resolver function. If one is not provided, + * the default implementation will call `isTypeOf` on each implementing + * Object type. + */ + resolveType?: Maybe>; + extensions?: Maybe>; + astNode?: Maybe; + extensionASTNodes?: Maybe>; +} +export interface GraphQLUnionTypeNormalizedConfig extends GraphQLUnionTypeConfig { + types: ReadonlyArray; + extensions: Readonly; + extensionASTNodes: ReadonlyArray; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLEnumTypeExtensions { + [attributeName: string | symbol]: unknown; +} +/** + * Enum Type Definition + * + * Some leaf values of requests and input values are Enums. GraphQL coerces + * Enum values as strings, however internally Enums can be represented by any + * kind of type, often integers. + * + * Example: + * + * ```ts + * const RGBType = new GraphQLEnumType({ + * name: 'RGB', + * values: { + * RED: { value: 0 }, + * GREEN: { value: 1 }, + * BLUE: { value: 2 } + * } + * }); + * ``` + * + * Note: If a value is not provided in a definition, the name of the enum value + * will be used as its internal value. + */ +export declare class GraphQLEnumType/* */ implements GraphQLSchemaElement { + name: string; + description: Maybe; + extensions: Readonly; + astNode: Maybe; + extensionASTNodes: ReadonlyArray; + private _values; + private _valueLookup; + private _nameLookup; + constructor(config: Readonly); + get [Symbol.toStringTag](): string; + getValues(): ReadonlyArray; + getValue(name: string): Maybe; + /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */ + serialize(outputValue: unknown): Maybe; + coerceOutputValue(outputValue: unknown): Maybe; + /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */ + parseValue(inputValue: unknown, hideSuggestions?: Maybe): Maybe; + coerceInputValue(inputValue: unknown, hideSuggestions?: Maybe): Maybe; + /** @deprecated use `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */ + parseLiteral(valueNode: ValueNode, _variables: Maybe>, hideSuggestions?: Maybe): Maybe; + coerceInputLiteral(valueNode: ConstValueNode, hideSuggestions?: Maybe): Maybe; + valueToLiteral(value: unknown): ConstValueNode | undefined; + toConfig(): GraphQLEnumTypeNormalizedConfig; + toString(): string; + toJSON(): string; +} +export interface GraphQLEnumTypeConfig { + name: string; + description?: Maybe; + values: ThunkObjMap; + extensions?: Maybe>; + astNode?: Maybe; + extensionASTNodes?: Maybe>; +} +export interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig { + values: GraphQLEnumValueNormalizedConfigMap; + extensions: Readonly; + extensionASTNodes: ReadonlyArray; +} +export type GraphQLEnumValueConfigMap = ObjMap; +export type GraphQLEnumValueNormalizedConfigMap = ObjMap; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLEnumValueExtensions { + [attributeName: string | symbol]: unknown; +} +export interface GraphQLEnumValueConfig { + description?: Maybe; + value?: any; + deprecationReason?: Maybe; + extensions?: Maybe>; + astNode?: Maybe; +} +export interface GraphQLEnumValueNormalizedConfig extends GraphQLEnumValueConfig { + extensions: Readonly; +} +export declare class GraphQLEnumValue implements GraphQLSchemaElement { + parentEnum: GraphQLEnumType; + name: string; + description: Maybe; + value: any; + deprecationReason: Maybe; + extensions: Readonly; + astNode: Maybe; + constructor(parentEnum: GraphQLEnumType, name: string, config: GraphQLEnumValueConfig); + get [Symbol.toStringTag](): string; + toConfig(): GraphQLEnumValueNormalizedConfig; + toString(): string; + toJSON(): string; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLInputObjectTypeExtensions { + [attributeName: string | symbol]: unknown; +} +/** + * Input Object Type Definition + * + * An input object defines a structured collection of fields which may be + * supplied to a field argument. + * + * Using `NonNull` will ensure that a value must be provided by the query + * + * Example: + * + * ```ts + * const GeoPoint = new GraphQLInputObjectType({ + * name: 'GeoPoint', + * fields: { + * lat: { type: new GraphQLNonNull(GraphQLFloat) }, + * lon: { type: new GraphQLNonNull(GraphQLFloat) }, + * alt: { type: GraphQLFloat, defaultValue: 0 }, + * } + * }); + * ``` + */ +export declare class GraphQLInputObjectType implements GraphQLSchemaElement { + name: string; + description: Maybe; + extensions: Readonly; + astNode: Maybe; + extensionASTNodes: ReadonlyArray; + isOneOf: boolean; + private _fields; + constructor(config: Readonly); + get [Symbol.toStringTag](): string; + getFields(): GraphQLInputFieldMap; + toConfig(): GraphQLInputObjectTypeNormalizedConfig; + toString(): string; + toJSON(): string; +} +export interface GraphQLInputObjectTypeConfig { + name: string; + description?: Maybe; + fields: ThunkObjMap; + extensions?: Maybe>; + astNode?: Maybe; + extensionASTNodes?: Maybe>; + isOneOf?: boolean; +} +export interface GraphQLInputObjectTypeNormalizedConfig extends GraphQLInputObjectTypeConfig { + fields: GraphQLInputFieldNormalizedConfigMap; + extensions: Readonly; + extensionASTNodes: ReadonlyArray; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLInputFieldExtensions { + [attributeName: string | symbol]: unknown; +} +export interface GraphQLInputFieldConfig { + description?: Maybe; + type: GraphQLInputType; + /** @deprecated use default instead, defaultValue will be removed in v18 **/ + defaultValue?: unknown; + default?: GraphQLDefaultInput | undefined; + deprecationReason?: Maybe; + extensions?: Maybe>; + astNode?: Maybe; +} +export type GraphQLInputFieldConfigMap = ObjMap; +export interface GraphQLInputFieldNormalizedConfig extends GraphQLInputFieldConfig { + default: GraphQLDefaultInput | undefined; + extensions: Readonly; +} +export type GraphQLInputFieldNormalizedConfigMap = ObjMap; +export declare class GraphQLInputField implements GraphQLSchemaElement { + parentType: GraphQLInputObjectType; + name: string; + description: Maybe; + type: GraphQLInputType; + defaultValue: unknown; + default: GraphQLDefaultInput | undefined; + deprecationReason: Maybe; + extensions: Readonly; + astNode: Maybe; + constructor(parentType: GraphQLInputObjectType, name: string, config: GraphQLInputFieldConfig); + get [Symbol.toStringTag](): string; + toConfig(): GraphQLInputFieldNormalizedConfig; + toString(): string; + toJSON(): string; +} +export declare function isRequiredInputField(field: GraphQLInputField): boolean; +export type GraphQLInputFieldMap = ObjMap; diff --git a/type/definition.js b/type/definition.js new file mode 100644 index 0000000000..2961a1c97d --- /dev/null +++ b/type/definition.js @@ -0,0 +1,1068 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GraphQLInputField = exports.GraphQLInputObjectType = exports.GraphQLEnumValue = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLArgument = exports.GraphQLField = exports.GraphQLObjectType = exports.GraphQLScalarType = exports.GraphQLNonNull = exports.GraphQLList = void 0; +exports.isType = isType; +exports.assertType = assertType; +exports.isScalarType = isScalarType; +exports.assertScalarType = assertScalarType; +exports.isObjectType = isObjectType; +exports.assertObjectType = assertObjectType; +exports.isField = isField; +exports.assertField = assertField; +exports.isArgument = isArgument; +exports.assertArgument = assertArgument; +exports.isInterfaceType = isInterfaceType; +exports.assertInterfaceType = assertInterfaceType; +exports.isUnionType = isUnionType; +exports.assertUnionType = assertUnionType; +exports.isEnumType = isEnumType; +exports.assertEnumType = assertEnumType; +exports.isEnumValue = isEnumValue; +exports.assertEnumValue = assertEnumValue; +exports.isInputObjectType = isInputObjectType; +exports.assertInputObjectType = assertInputObjectType; +exports.isInputField = isInputField; +exports.assertInputField = assertInputField; +exports.isListType = isListType; +exports.assertListType = assertListType; +exports.isNonNullType = isNonNullType; +exports.assertNonNullType = assertNonNullType; +exports.isInputType = isInputType; +exports.assertInputType = assertInputType; +exports.isOutputType = isOutputType; +exports.assertOutputType = assertOutputType; +exports.isLeafType = isLeafType; +exports.assertLeafType = assertLeafType; +exports.isCompositeType = isCompositeType; +exports.assertCompositeType = assertCompositeType; +exports.isAbstractType = isAbstractType; +exports.assertAbstractType = assertAbstractType; +exports.isWrappingType = isWrappingType; +exports.assertWrappingType = assertWrappingType; +exports.isNullableType = isNullableType; +exports.assertNullableType = assertNullableType; +exports.getNullableType = getNullableType; +exports.isNamedType = isNamedType; +exports.assertNamedType = assertNamedType; +exports.getNamedType = getNamedType; +exports.resolveReadonlyArrayThunk = resolveReadonlyArrayThunk; +exports.resolveObjMapThunk = resolveObjMapThunk; +exports.isRequiredArgument = isRequiredArgument; +exports.isRequiredInputField = isRequiredInputField; +const devAssert_js_1 = require("../jsutils/devAssert.js"); +const didYouMean_js_1 = require("../jsutils/didYouMean.js"); +const identityFunc_js_1 = require("../jsutils/identityFunc.js"); +const inspect_js_1 = require("../jsutils/inspect.js"); +const instanceOf_js_1 = require("../jsutils/instanceOf.js"); +const keyMap_js_1 = require("../jsutils/keyMap.js"); +const keyValMap_js_1 = require("../jsutils/keyValMap.js"); +const mapValue_js_1 = require("../jsutils/mapValue.js"); +const suggestionList_js_1 = require("../jsutils/suggestionList.js"); +const toObjMap_js_1 = require("../jsutils/toObjMap.js"); +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const kinds_js_1 = require("../language/kinds.js"); +const printer_js_1 = require("../language/printer.js"); +const valueFromASTUntyped_js_1 = require("../utilities/valueFromASTUntyped.js"); +const assertName_js_1 = require("./assertName.js"); +function isType(type) { + return (isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) || + isListType(type) || + isNonNullType(type)); +} +function assertType(type) { + if (!isType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL type.`); + } + return type; +} +/** + * There are predicates for each GraphQL schema element. + */ +function isScalarType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLScalarType); +} +function assertScalarType(type) { + if (!isScalarType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL Scalar type.`); + } + return type; +} +function isObjectType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLObjectType); +} +function assertObjectType(type) { + if (!isObjectType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL Object type.`); + } + return type; +} +function isField(field) { + return (0, instanceOf_js_1.instanceOf)(field, GraphQLField); +} +function assertField(field) { + if (!isField(field)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(field)} to be a GraphQL field.`); + } + return field; +} +function isArgument(arg) { + return (0, instanceOf_js_1.instanceOf)(arg, GraphQLArgument); +} +function assertArgument(arg) { + if (!isArgument(arg)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(arg)} to be a GraphQL argument.`); + } + return arg; +} +function isInterfaceType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLInterfaceType); +} +function assertInterfaceType(type) { + if (!isInterfaceType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL Interface type.`); + } + return type; +} +function isUnionType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLUnionType); +} +function assertUnionType(type) { + if (!isUnionType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL Union type.`); + } + return type; +} +function isEnumType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLEnumType); +} +function assertEnumType(type) { + if (!isEnumType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL Enum type.`); + } + return type; +} +function isEnumValue(value) { + return (0, instanceOf_js_1.instanceOf)(value, GraphQLEnumValue); +} +function assertEnumValue(value) { + if (!isEnumValue(value)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(value)} to be a GraphQL Enum value.`); + } + return value; +} +function isInputObjectType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLInputObjectType); +} +function assertInputObjectType(type) { + if (!isInputObjectType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL Input Object type.`); + } + return type; +} +function isInputField(field) { + return (0, instanceOf_js_1.instanceOf)(field, GraphQLInputField); +} +function assertInputField(field) { + if (!isInputField(field)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(field)} to be a GraphQL input field.`); + } + return field; +} +function isListType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLList); +} +function assertListType(type) { + if (!isListType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL List type.`); + } + return type; +} +function isNonNullType(type) { + return (0, instanceOf_js_1.instanceOf)(type, GraphQLNonNull); +} +function assertNonNullType(type) { + if (!isNonNullType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL Non-Null type.`); + } + return type; +} +function isInputType(type) { + return (isScalarType(type) || + isEnumType(type) || + isInputObjectType(type) || + (isWrappingType(type) && isInputType(type.ofType))); +} +function assertInputType(type) { + if (!isInputType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL input type.`); + } + return type; +} +function isOutputType(type) { + return (isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + (isWrappingType(type) && isOutputType(type.ofType))); +} +function assertOutputType(type) { + if (!isOutputType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL output type.`); + } + return type; +} +function isLeafType(type) { + return isScalarType(type) || isEnumType(type); +} +function assertLeafType(type) { + if (!isLeafType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL leaf type.`); + } + return type; +} +function isCompositeType(type) { + return isObjectType(type) || isInterfaceType(type) || isUnionType(type); +} +function assertCompositeType(type) { + if (!isCompositeType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL composite type.`); + } + return type; +} +function isAbstractType(type) { + return isInterfaceType(type) || isUnionType(type); +} +function assertAbstractType(type) { + if (!isAbstractType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL abstract type.`); + } + return type; +} +/** + * List Type Wrapper + * + * A list is a wrapping type which points to another type. + * Lists are often created within the context of defining the fields of + * an object type. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * parents: { type: new GraphQLList(PersonType) }, + * children: { type: new GraphQLList(PersonType) }, + * }) + * }) + * ``` + */ +class GraphQLList { + constructor(ofType) { + this.ofType = ofType; + } + get [Symbol.toStringTag]() { + return 'GraphQLList'; + } + toString() { + return '[' + String(this.ofType) + ']'; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLList = GraphQLList; +/** + * Non-Null Type Wrapper + * + * A non-null is a wrapping type which points to another type. + * Non-null types enforce that their values are never null and can ensure + * an error is raised if this ever occurs during a request. It is useful for + * fields which you can make a strong guarantee on non-nullability, for example + * usually the id field of a database row will never be null. + * + * Example: + * + * ```ts + * const RowType = new GraphQLObjectType({ + * name: 'Row', + * fields: () => ({ + * id: { type: new GraphQLNonNull(GraphQLString) }, + * }) + * }) + * ``` + * Note: the enforcement of non-nullability occurs within the executor. + */ +class GraphQLNonNull { + constructor(ofType) { + this.ofType = ofType; + } + get [Symbol.toStringTag]() { + return 'GraphQLNonNull'; + } + toString() { + return String(this.ofType) + '!'; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLNonNull = GraphQLNonNull; +function isWrappingType(type) { + return isListType(type) || isNonNullType(type); +} +function assertWrappingType(type) { + if (!isWrappingType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL wrapping type.`); + } + return type; +} +function isNullableType(type) { + return isType(type) && !isNonNullType(type); +} +function assertNullableType(type) { + if (!isNullableType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL nullable type.`); + } + return type; +} +function getNullableType(type) { + if (type) { + return isNonNullType(type) ? type.ofType : type; + } +} +function isNamedType(type) { + return (isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type)); +} +function assertNamedType(type) { + if (!isNamedType(type)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(type)} to be a GraphQL named type.`); + } + return type; +} +function getNamedType(type) { + if (type) { + let unwrappedType = type; + while (isWrappingType(unwrappedType)) { + unwrappedType = unwrappedType.ofType; + } + return unwrappedType; + } +} +function resolveReadonlyArrayThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +function resolveObjMapThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +/** + * Scalar Type Definition + * + * The leaf values of any request and input values to arguments are + * Scalars (or Enums) and are defined with a name and a series of functions + * used to parse input from ast or variables and to ensure validity. + * + * If a type's coerceOutputValue function returns `null` or does not return a + * value (i.e. it returns `undefined`) then an error will be raised and a + * `null` value will be returned in the response. It is always better to + * validate. + * + * Example: + * + * ```ts + * function ensureOdd(value) { + * if (!Number.isFinite(value)) { + * throw new Error( + * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`, + * ); + * } + * + * if (value % 2 === 0) { + * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`); + * } + * } + * + * const OddType = new GraphQLScalarType({ + * name: 'Odd', + * coerceOutputValue(value) { + * return ensureOdd(value); + * }, + * coerceInputValue(value) { + * return ensureOdd(value); + * } + * valueToLiteral(value) { + * return parse(`${ensureOdd(value)`); + * } + * }); + * ``` + * + * Custom scalars behavior is defined via the following functions: + * + * - coerceOutputValue(value): Implements "Result Coercion". Given an internal value, + * produces an external value valid for this type. Returns undefined or + * throws an error to indicate invalid values. + * + * - coerceInputValue(value): Implements "Input Coercion" for values. Given an + * external value (for example, variable values), produces an internal value + * valid for this type. Returns undefined or throws an error to indicate + * invalid values. + * + * - coerceInputLiteral(ast): Implements "Input Coercion" for constant literals. + * Given an GraphQL literal (AST) (for example, an argument value), produces + * an internal value valid for this type. Returns undefined or throws an + * error to indicate invalid values. + * + * - valueToLiteral(value): Converts an external value to a GraphQL + * literal (AST). Returns undefined or throws an error to indicate + * invalid values. + * + * Deprecated, to be removed in v18: + * + * - serialize(value): Implements "Result Coercion". Renamed to + * `coerceOutputValue()`. + * + * - parseValue(value): Implements "Input Coercion" for values. Renamed to + * `coerceInputValue()`. + * + * - parseLiteral(ast): Implements "Input Coercion" for literals including + * non-specified replacement of variables embedded within complex scalars. + * Replaced by the combination of the `replaceVariables()` utility and the + * `coerceInputLiteral()` method. + * + */ +class GraphQLScalarType { + constructor(config) { + this.name = (0, assertName_js_1.assertName)(config.name); + this.description = config.description; + this.specifiedByURL = config.specifiedByURL; + this.serialize = + config.serialize ?? + config.coerceOutputValue ?? + identityFunc_js_1.identityFunc; + this.parseValue = + config.parseValue ?? + config.coerceInputValue ?? + identityFunc_js_1.identityFunc; + this.parseLiteral = + config.parseLiteral ?? + ((node, variables) => this.coerceInputValue((0, valueFromASTUntyped_js_1.valueFromASTUntyped)(node, variables))); + this.coerceOutputValue = config.coerceOutputValue ?? this.serialize; + this.coerceInputValue = config.coerceInputValue ?? this.parseValue; + this.coerceInputLiteral = config.coerceInputLiteral; + this.valueToLiteral = config.valueToLiteral; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + if (config.parseLiteral) { + (typeof config.parseValue === 'function' && + typeof config.parseLiteral === 'function') || (0, devAssert_js_1.devAssert)(false, `${this.name} must provide both "parseValue" and "parseLiteral" functions.`); + } + if (config.coerceInputLiteral) { + (typeof config.coerceInputValue === 'function' && + typeof config.coerceInputLiteral === 'function') || (0, devAssert_js_1.devAssert)(false, `${this.name} must provide both "coerceInputValue" and "coerceInputLiteral" functions.`); + } + } + get [Symbol.toStringTag]() { + return 'GraphQLScalarType'; + } + toConfig() { + return { + name: this.name, + description: this.description, + specifiedByURL: this.specifiedByURL, + serialize: this.serialize, + parseValue: this.parseValue, + parseLiteral: this.parseLiteral, + coerceOutputValue: this.coerceOutputValue, + coerceInputValue: this.coerceInputValue, + coerceInputLiteral: this.coerceInputLiteral, + valueToLiteral: this.valueToLiteral, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLScalarType = GraphQLScalarType; +/** + * Object Type Definition + * + * Almost all of the GraphQL types you define will be object types. Object types + * have a name, but most importantly describe their fields. + * + * Example: + * + * ```ts + * const AddressType = new GraphQLObjectType({ + * name: 'Address', + * fields: { + * street: { type: GraphQLString }, + * number: { type: GraphQLInt }, + * formatted: { + * type: GraphQLString, + * resolve(obj) { + * return obj.number + ' ' + obj.street + * } + * } + * } + * }); + * ``` + * + * When two types need to refer to each other, or a type needs to refer to + * itself in a field, you can use a function expression (aka a closure or a + * thunk) to supply the fields lazily. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * name: { type: GraphQLString }, + * bestFriend: { type: PersonType }, + * }) + * }); + * ``` + */ +class GraphQLObjectType { + constructor(config) { + this.name = (0, assertName_js_1.assertName)(config.name); + this.description = config.description; + this.isTypeOf = config.isTypeOf; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._fields = (defineFieldMap).bind(undefined, this, config.fields); + this._interfaces = defineInterfaces.bind(undefined, config.interfaces); + } + get [Symbol.toStringTag]() { + return 'GraphQLObjectType'; + } + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + return this._fields; + } + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + return this._interfaces; + } + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: (0, mapValue_js_1.mapValue)(this.getFields(), (field) => field.toConfig()), + isTypeOf: this.isTypeOf, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLObjectType = GraphQLObjectType; +function defineInterfaces(interfaces) { + return resolveReadonlyArrayThunk(interfaces ?? []); +} +function defineFieldMap(parentType, fields) { + const fieldMap = resolveObjMapThunk(fields); + return (0, mapValue_js_1.mapValue)(fieldMap, (fieldConfig, fieldName) => new GraphQLField(parentType, fieldName, fieldConfig)); +} +class GraphQLField { + constructor(parentType, name, config) { + this.parentType = parentType; + this.name = (0, assertName_js_1.assertName)(name); + this.description = config.description; + this.type = config.type; + const argsConfig = config.args; + this.args = argsConfig + ? Object.entries(argsConfig).map(([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig)) + : []; + this.resolve = config.resolve; + this.subscribe = config.subscribe; + this.deprecationReason = config.deprecationReason; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLField'; + } + toConfig() { + return { + description: this.description, + type: this.type, + args: (0, keyValMap_js_1.keyValMap)(this.args, (arg) => arg.name, (arg) => arg.toConfig()), + resolve: this.resolve, + subscribe: this.subscribe, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parentType ?? ''}.${this.name}`; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLField = GraphQLField; +class GraphQLArgument { + constructor(parent, name, config) { + this.parent = parent; + this.name = (0, assertName_js_1.assertName)(name); + this.description = config.description; + this.type = config.type; + this.defaultValue = config.defaultValue; + this.default = config.default; + this.deprecationReason = config.deprecationReason; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLArgument'; + } + toConfig() { + return { + description: this.description, + type: this.type, + defaultValue: this.defaultValue, + default: this.default, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parent}(${this.name}:)`; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLArgument = GraphQLArgument; +function isRequiredArgument(arg) { + return (isNonNullType(arg.type) && + arg.default === undefined && + arg.defaultValue === undefined); +} +/** + * Interface Type Definition + * + * When a field can return one of a heterogeneous set of types, a Interface type + * is used to describe what types are possible, what fields are in common across + * all types, as well as a function to determine which type is actually used + * when the field is resolved. + * + * Example: + * + * ```ts + * const EntityType = new GraphQLInterfaceType({ + * name: 'Entity', + * fields: { + * name: { type: GraphQLString } + * } + * }); + * ``` + */ +class GraphQLInterfaceType { + constructor(config) { + this.name = (0, assertName_js_1.assertName)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._fields = (defineFieldMap).bind(undefined, this, config.fields); + this._interfaces = defineInterfaces.bind(undefined, config.interfaces); + } + get [Symbol.toStringTag]() { + return 'GraphQLInterfaceType'; + } + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + return this._fields; + } + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + return this._interfaces; + } + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: (0, mapValue_js_1.mapValue)(this.getFields(), (field) => field.toConfig()), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLInterfaceType = GraphQLInterfaceType; +/** + * Union Type Definition + * + * When a field can return one of a heterogeneous set of types, a Union type + * is used to describe what types are possible as well as providing a function + * to determine which type is actually used when the field is resolved. + * + * Example: + * + * ```ts + * const PetType = new GraphQLUnionType({ + * name: 'Pet', + * types: [ DogType, CatType ], + * resolveType(value) { + * if (value instanceof Dog) { + * return DogType; + * } + * if (value instanceof Cat) { + * return CatType; + * } + * } + * }); + * ``` + */ +class GraphQLUnionType { + constructor(config) { + this.name = (0, assertName_js_1.assertName)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._types = defineTypes.bind(undefined, config.types); + } + get [Symbol.toStringTag]() { + return 'GraphQLUnionType'; + } + getTypes() { + if (typeof this._types === 'function') { + this._types = this._types(); + } + return this._types; + } + toConfig() { + return { + name: this.name, + description: this.description, + types: this.getTypes(), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLUnionType = GraphQLUnionType; +function defineTypes(types) { + return resolveReadonlyArrayThunk(types); +} +/** + * Enum Type Definition + * + * Some leaf values of requests and input values are Enums. GraphQL coerces + * Enum values as strings, however internally Enums can be represented by any + * kind of type, often integers. + * + * Example: + * + * ```ts + * const RGBType = new GraphQLEnumType({ + * name: 'RGB', + * values: { + * RED: { value: 0 }, + * GREEN: { value: 1 }, + * BLUE: { value: 2 } + * } + * }); + * ``` + * + * Note: If a value is not provided in a definition, the name of the enum value + * will be used as its internal value. + */ +class GraphQLEnumType /* */ { + constructor(config) { + this.name = (0, assertName_js_1.assertName)(config.name); + this.description = config.description; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._values = + typeof config.values === 'function' + ? config.values + : Object.entries(config.values).map(([valueName, valueConfig]) => new GraphQLEnumValue(this, valueName, valueConfig)); + this._valueLookup = null; + this._nameLookup = null; + } + get [Symbol.toStringTag]() { + return 'GraphQLEnumType'; + } + getValues() { + if (typeof this._values === 'function') { + this._values = Object.entries(this._values()).map(([valueName, valueConfig]) => new GraphQLEnumValue(this, valueName, valueConfig)); + } + return this._values; + } + getValue(name) { + if (this._nameLookup === null) { + this._nameLookup = (0, keyMap_js_1.keyMap)(this.getValues(), (value) => value.name); + } + return this._nameLookup[name]; + } + /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */ + serialize(outputValue /* T */) { + return this.coerceOutputValue(outputValue); + } + coerceOutputValue(outputValue /* T */) { + if (this._valueLookup === null) { + this._valueLookup = new Map(this.getValues().map((enumValue) => [enumValue.value, enumValue])); + } + const enumValue = this._valueLookup.get(outputValue); + if (enumValue === undefined) { + throw new GraphQLError_js_1.GraphQLError(`Enum "${this.name}" cannot represent value: ${(0, inspect_js_1.inspect)(outputValue)}`); + } + return enumValue.name; + } + /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */ + parseValue(inputValue, hideSuggestions) { + return this.coerceInputValue(inputValue, hideSuggestions); + } + coerceInputValue(inputValue, hideSuggestions) { + if (typeof inputValue !== 'string') { + const valueStr = (0, inspect_js_1.inspect)(inputValue); + throw new GraphQLError_js_1.GraphQLError(`Enum "${this.name}" cannot represent non-string value: ${valueStr}.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr))); + } + const enumValue = this.getValue(inputValue); + if (enumValue == null) { + throw new GraphQLError_js_1.GraphQLError(`Value "${inputValue}" does not exist in "${this.name}" enum.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, inputValue))); + } + return enumValue.value; + } + /** @deprecated use `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */ + parseLiteral(valueNode, _variables, hideSuggestions) { + // Note: variables will be resolved to a value before calling this function. + return this.coerceInputLiteral(valueNode, hideSuggestions); + } + coerceInputLiteral(valueNode, hideSuggestions) { + if (valueNode.kind !== kinds_js_1.Kind.ENUM) { + const valueStr = (0, printer_js_1.print)(valueNode); + throw new GraphQLError_js_1.GraphQLError(`Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)), { nodes: valueNode }); + } + const enumValue = this.getValue(valueNode.value); + if (enumValue == null) { + const valueStr = (0, printer_js_1.print)(valueNode); + throw new GraphQLError_js_1.GraphQLError(`Value "${valueStr}" does not exist in "${this.name}" enum.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)), { nodes: valueNode }); + } + return enumValue.value; + } + valueToLiteral(value) { + if (typeof value === 'string' && this.getValue(value)) { + return { kind: kinds_js_1.Kind.ENUM, value }; + } + } + toConfig() { + return { + name: this.name, + description: this.description, + values: (0, keyValMap_js_1.keyValMap)(this.getValues(), (value) => value.name, (value) => value.toConfig()), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLEnumType = GraphQLEnumType; +function didYouMeanEnumValue(enumType, unknownValueStr) { + const allNames = enumType.getValues().map((value) => value.name); + const suggestedValues = (0, suggestionList_js_1.suggestionList)(unknownValueStr, allNames); + return (0, didYouMean_js_1.didYouMean)('the enum value', suggestedValues); +} +class GraphQLEnumValue { + constructor(parentEnum, name, config) { + this.parentEnum = parentEnum; + this.name = (0, assertName_js_1.assertEnumValueName)(name); + this.description = config.description; + this.value = config.value !== undefined ? config.value : name; + this.deprecationReason = config.deprecationReason; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLEnumValue'; + } + toConfig() { + return { + description: this.description, + value: this.value, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parentEnum.name}.${this.name}`; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLEnumValue = GraphQLEnumValue; +/** + * Input Object Type Definition + * + * An input object defines a structured collection of fields which may be + * supplied to a field argument. + * + * Using `NonNull` will ensure that a value must be provided by the query + * + * Example: + * + * ```ts + * const GeoPoint = new GraphQLInputObjectType({ + * name: 'GeoPoint', + * fields: { + * lat: { type: new GraphQLNonNull(GraphQLFloat) }, + * lon: { type: new GraphQLNonNull(GraphQLFloat) }, + * alt: { type: GraphQLFloat, defaultValue: 0 }, + * } + * }); + * ``` + */ +class GraphQLInputObjectType { + constructor(config) { + this.name = (0, assertName_js_1.assertName)(config.name); + this.description = config.description; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this.isOneOf = config.isOneOf ?? false; + this._fields = defineInputFieldMap.bind(undefined, this, config.fields); + } + get [Symbol.toStringTag]() { + return 'GraphQLInputObjectType'; + } + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + return this._fields; + } + toConfig() { + return { + name: this.name, + description: this.description, + fields: (0, mapValue_js_1.mapValue)(this.getFields(), (field) => field.toConfig()), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + isOneOf: this.isOneOf, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLInputObjectType = GraphQLInputObjectType; +function defineInputFieldMap(parentType, fields) { + const fieldMap = resolveObjMapThunk(fields); + return (0, mapValue_js_1.mapValue)(fieldMap, (fieldConfig, fieldName) => new GraphQLInputField(parentType, fieldName, fieldConfig)); +} +class GraphQLInputField { + constructor(parentType, name, config) { + (!('resolve' in config)) || (0, devAssert_js_1.devAssert)(false, `${parentType}.${name} field has a resolve property, but Input Types cannot define resolvers.`); + this.parentType = parentType; + this.name = (0, assertName_js_1.assertName)(name); + this.description = config.description; + this.type = config.type; + this.defaultValue = config.defaultValue; + this.default = config.default; + this.deprecationReason = config.deprecationReason; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLInputField'; + } + toConfig() { + return { + description: this.description, + type: this.type, + defaultValue: this.defaultValue, + default: this.default, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parentType}.${this.name}`; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLInputField = GraphQLInputField; +function isRequiredInputField(field) { + return (isNonNullType(field.type) && + field.defaultValue === undefined && + field.default === undefined); +} +//# sourceMappingURL=definition.js.map \ No newline at end of file diff --git a/type/definition.js.map b/type/definition.js.map new file mode 100644 index 0000000000..80925371b2 --- /dev/null +++ b/type/definition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/type/definition.ts"],"names":[],"mappings":";;;AA0DA,wBAWC;AAED,gCAKC;AAKD,oCAEC;AAED,4CAKC;AAED,oCAEC;AAED,4CAKC;AAED,0BAEC;AAED,kCAKC;AAED,gCAEC;AAED,wCAKC;AAED,0CAEC;AAED,kDAOC;AAED,kCAEC;AAED,0CAKC;AAED,gCAEC;AAED,wCAKC;AAED,kCAEC;AAED,0CAKC;AAED,8CAIC;AAED,sDAOC;AAED,oCAEC;AAED,4CAKC;AASD,gCAEC;AAED,wCAKC;AAWD,sCAIC;AAED,8CAOC;AAaD,kCAOC;AAED,0CAKC;AAaD,oCASC;AAED,4CAKC;AAOD,gCAEC;AAED,wCAKC;AAUD,0CAEC;AAED,kDAOC;AAOD,wCAEC;AAED,gDAKC;AA8FD,wCAEC;AAED,gDAKC;AAOD,wCAEC;AAED,gDAKC;AASD,0CAMC;AAm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,CAAC,IAAI,CAAC;QACzB,KAAK,CAAC,YAAY,KAAK,SAAS;QAChC,KAAK,CAAC,OAAO,KAAK,SAAS,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { didYouMean } from '../jsutils/didYouMean.js';\nimport { identityFunc } from '../jsutils/identityFunc.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\nimport { keyMap } from '../jsutils/keyMap.js';\nimport { keyValMap } from '../jsutils/keyValMap.js';\nimport { mapValue } from '../jsutils/mapValue.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport type { Path } from '../jsutils/Path.js';\nimport type { PromiseOrValue } from '../jsutils/PromiseOrValue.js';\nimport { suggestionList } from '../jsutils/suggestionList.js';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ConstValueNode,\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n EnumValueDefinitionNode,\n FieldDefinitionNode,\n FieldNode,\n FragmentDefinitionNode,\n InputObjectTypeDefinitionNode,\n InputObjectTypeExtensionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n OperationDefinitionNode,\n ScalarTypeDefinitionNode,\n ScalarTypeExtensionNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n ValueNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport type { GraphQLVariableSignature } from '../execution/getVariableSignature.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { valueFromASTUntyped } from '../utilities/valueFromASTUntyped.js';\n\nimport { assertEnumValueName, assertName } from './assertName.js';\nimport type { GraphQLDirective } from './directives.js';\nimport type { GraphQLSchema } from './schema.js';\n\n// Predicates & Assertions\n\n/**\n * These are all of the possible kinds of types.\n */\nexport type GraphQLType = GraphQLNamedType | GraphQLWrappingType;\n\nexport function isType(type: unknown): type is GraphQLType {\n return (\n isScalarType(type) ||\n isObjectType(type) ||\n isInterfaceType(type) ||\n isUnionType(type) ||\n isEnumType(type) ||\n isInputObjectType(type) ||\n isListType(type) ||\n isNonNullType(type)\n );\n}\n\nexport function assertType(type: unknown): GraphQLType {\n if (!isType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL type.`);\n }\n return type;\n}\n\n/**\n * There are predicates for each GraphQL schema element.\n */\nexport function isScalarType(type: unknown): type is GraphQLScalarType {\n return instanceOf(type, GraphQLScalarType);\n}\n\nexport function assertScalarType(type: unknown): GraphQLScalarType {\n if (!isScalarType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Scalar type.`);\n }\n return type;\n}\n\nexport function isObjectType(type: unknown): type is GraphQLObjectType {\n return instanceOf(type, GraphQLObjectType);\n}\n\nexport function assertObjectType(type: unknown): GraphQLObjectType {\n if (!isObjectType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Object type.`);\n }\n return type;\n}\n\nexport function isField(field: unknown): field is GraphQLField {\n return instanceOf(field, GraphQLField);\n}\n\nexport function assertField(field: unknown): GraphQLField {\n if (!isField(field)) {\n throw new Error(`Expected ${inspect(field)} to be a GraphQL field.`);\n }\n return field;\n}\n\nexport function isArgument(arg: unknown): arg is GraphQLArgument {\n return instanceOf(arg, GraphQLArgument);\n}\n\nexport function assertArgument(arg: unknown): GraphQLArgument {\n if (!isArgument(arg)) {\n throw new Error(`Expected ${inspect(arg)} to be a GraphQL argument.`);\n }\n return arg;\n}\n\nexport function isInterfaceType(type: unknown): type is GraphQLInterfaceType {\n return instanceOf(type, GraphQLInterfaceType);\n}\n\nexport function assertInterfaceType(type: unknown): GraphQLInterfaceType {\n if (!isInterfaceType(type)) {\n throw new Error(\n `Expected ${inspect(type)} to be a GraphQL Interface type.`,\n );\n }\n return type;\n}\n\nexport function isUnionType(type: unknown): type is GraphQLUnionType {\n return instanceOf(type, GraphQLUnionType);\n}\n\nexport function assertUnionType(type: unknown): GraphQLUnionType {\n if (!isUnionType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Union type.`);\n }\n return type;\n}\n\nexport function isEnumType(type: unknown): type is GraphQLEnumType {\n return instanceOf(type, GraphQLEnumType);\n}\n\nexport function assertEnumType(type: unknown): GraphQLEnumType {\n if (!isEnumType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Enum type.`);\n }\n return type;\n}\n\nexport function isEnumValue(value: unknown): value is GraphQLEnumValue {\n return instanceOf(value, GraphQLEnumValue);\n}\n\nexport function assertEnumValue(value: unknown): GraphQLEnumValue {\n if (!isEnumValue(value)) {\n throw new Error(`Expected ${inspect(value)} to be a GraphQL Enum value.`);\n }\n return value;\n}\n\nexport function isInputObjectType(\n type: unknown,\n): type is GraphQLInputObjectType {\n return instanceOf(type, GraphQLInputObjectType);\n}\n\nexport function assertInputObjectType(type: unknown): GraphQLInputObjectType {\n if (!isInputObjectType(type)) {\n throw new Error(\n `Expected ${inspect(type)} to be a GraphQL Input Object type.`,\n );\n }\n return type;\n}\n\nexport function isInputField(field: unknown): field is GraphQLInputField {\n return instanceOf(field, GraphQLInputField);\n}\n\nexport function assertInputField(field: unknown): GraphQLInputField {\n if (!isInputField(field)) {\n throw new Error(`Expected ${inspect(field)} to be a GraphQL input field.`);\n }\n return field;\n}\n\nexport function isListType(\n type: GraphQLInputType,\n): type is GraphQLList;\nexport function isListType(\n type: GraphQLOutputType,\n): type is GraphQLList;\nexport function isListType(type: unknown): type is GraphQLList;\nexport function isListType(type: unknown): type is GraphQLList {\n return instanceOf(type, GraphQLList);\n}\n\nexport function assertListType(type: unknown): GraphQLList {\n if (!isListType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL List type.`);\n }\n return type;\n}\n\nexport function isNonNullType(\n type: GraphQLInputType,\n): type is GraphQLNonNull;\nexport function isNonNullType(\n type: GraphQLOutputType,\n): type is GraphQLNonNull;\nexport function isNonNullType(\n type: unknown,\n): type is GraphQLNonNull;\nexport function isNonNullType(\n type: unknown,\n): type is GraphQLNonNull {\n return instanceOf(type, GraphQLNonNull);\n}\n\nexport function assertNonNullType(\n type: unknown,\n): GraphQLNonNull {\n if (!isNonNullType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Non-Null type.`);\n }\n return type;\n}\n\n/**\n * These types may be used as input types for arguments and directives.\n */\nexport type GraphQLNullableInputType =\n | GraphQLNamedInputType\n | GraphQLList;\n\nexport type GraphQLInputType =\n | GraphQLNullableInputType\n | GraphQLNonNull;\n\nexport function isInputType(type: unknown): type is GraphQLInputType {\n return (\n isScalarType(type) ||\n isEnumType(type) ||\n isInputObjectType(type) ||\n (isWrappingType(type) && isInputType(type.ofType))\n );\n}\n\nexport function assertInputType(type: unknown): GraphQLInputType {\n if (!isInputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL input type.`);\n }\n return type;\n}\n\n/**\n * These types may be used as output types as the result of fields.\n */\nexport type GraphQLNullableOutputType =\n | GraphQLNamedOutputType\n | GraphQLList;\n\nexport type GraphQLOutputType =\n | GraphQLNullableOutputType\n | GraphQLNonNull;\n\nexport function isOutputType(type: unknown): type is GraphQLOutputType {\n return (\n isScalarType(type) ||\n isObjectType(type) ||\n isInterfaceType(type) ||\n isUnionType(type) ||\n isEnumType(type) ||\n (isWrappingType(type) && isOutputType(type.ofType))\n );\n}\n\nexport function assertOutputType(type: unknown): GraphQLOutputType {\n if (!isOutputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL output type.`);\n }\n return type;\n}\n\n/**\n * These types may describe types which may be leaf values.\n */\nexport type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;\n\nexport function isLeafType(type: unknown): type is GraphQLLeafType {\n return isScalarType(type) || isEnumType(type);\n}\n\nexport function assertLeafType(type: unknown): GraphQLLeafType {\n if (!isLeafType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL leaf type.`);\n }\n return type;\n}\n\n/**\n * These types may describe the parent context of a selection set.\n */\nexport type GraphQLCompositeType =\n | GraphQLObjectType\n | GraphQLInterfaceType\n | GraphQLUnionType;\n\nexport function isCompositeType(type: unknown): type is GraphQLCompositeType {\n return isObjectType(type) || isInterfaceType(type) || isUnionType(type);\n}\n\nexport function assertCompositeType(type: unknown): GraphQLCompositeType {\n if (!isCompositeType(type)) {\n throw new Error(\n `Expected ${inspect(type)} to be a GraphQL composite type.`,\n );\n }\n return type;\n}\n\n/**\n * These types may describe the parent context of a selection set.\n */\nexport type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType;\n\nexport function isAbstractType(type: unknown): type is GraphQLAbstractType {\n return isInterfaceType(type) || isUnionType(type);\n}\n\nexport function assertAbstractType(type: unknown): GraphQLAbstractType {\n if (!isAbstractType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL abstract type.`);\n }\n return type;\n}\n\n/**\n * List Type Wrapper\n *\n * A list is a wrapping type which points to another type.\n * Lists are often created within the context of defining the fields of\n * an object type.\n *\n * Example:\n *\n * ```ts\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * parents: { type: new GraphQLList(PersonType) },\n * children: { type: new GraphQLList(PersonType) },\n * })\n * })\n * ```\n */\nexport class GraphQLList\n implements GraphQLSchemaElement\n{\n readonly ofType: T;\n\n constructor(ofType: T) {\n this.ofType = ofType;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLList';\n }\n\n toString(): string {\n return '[' + String(this.ofType) + ']';\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/**\n * Non-Null Type Wrapper\n *\n * A non-null is a wrapping type which points to another type.\n * Non-null types enforce that their values are never null and can ensure\n * an error is raised if this ever occurs during a request. It is useful for\n * fields which you can make a strong guarantee on non-nullability, for example\n * usually the id field of a database row will never be null.\n *\n * Example:\n *\n * ```ts\n * const RowType = new GraphQLObjectType({\n * name: 'Row',\n * fields: () => ({\n * id: { type: new GraphQLNonNull(GraphQLString) },\n * })\n * })\n * ```\n * Note: the enforcement of non-nullability occurs within the executor.\n */\nexport class GraphQLNonNull\n implements GraphQLSchemaElement\n{\n readonly ofType: T;\n\n constructor(ofType: T) {\n this.ofType = ofType;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLNonNull';\n }\n\n toString(): string {\n return String(this.ofType) + '!';\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/**\n * These types wrap and modify other types\n */\n\nexport type GraphQLWrappingType =\n | GraphQLList\n | GraphQLNonNull;\n\nexport function isWrappingType(type: unknown): type is GraphQLWrappingType {\n return isListType(type) || isNonNullType(type);\n}\n\nexport function assertWrappingType(type: unknown): GraphQLWrappingType {\n if (!isWrappingType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL wrapping type.`);\n }\n return type;\n}\n\n/**\n * These types can all accept null as a value.\n */\nexport type GraphQLNullableType = GraphQLNamedType | GraphQLList;\n\nexport function isNullableType(type: unknown): type is GraphQLNullableType {\n return isType(type) && !isNonNullType(type);\n}\n\nexport function assertNullableType(type: unknown): GraphQLNullableType {\n if (!isNullableType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL nullable type.`);\n }\n return type;\n}\n\nexport function getNullableType(type: undefined | null): void;\nexport function getNullableType(\n type: T | GraphQLNonNull,\n): T;\nexport function getNullableType(\n type: Maybe,\n): GraphQLNullableType | undefined;\nexport function getNullableType(\n type: Maybe,\n): GraphQLNullableType | undefined {\n if (type) {\n return isNonNullType(type) ? type.ofType : type;\n }\n}\n\n/**\n * These named types do not include modifiers like List or NonNull.\n */\nexport type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;\n\nexport type GraphQLNamedInputType =\n | GraphQLScalarType\n | GraphQLEnumType\n | GraphQLInputObjectType;\n\nexport type GraphQLNamedOutputType =\n | GraphQLScalarType\n | GraphQLObjectType\n | GraphQLInterfaceType\n | GraphQLUnionType\n | GraphQLEnumType;\n\nexport function isNamedType(type: unknown): type is GraphQLNamedType {\n return (\n isScalarType(type) ||\n isObjectType(type) ||\n isInterfaceType(type) ||\n isUnionType(type) ||\n isEnumType(type) ||\n isInputObjectType(type)\n );\n}\n\nexport function assertNamedType(type: unknown): GraphQLNamedType {\n if (!isNamedType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL named type.`);\n }\n return type;\n}\n\nexport function getNamedType(type: undefined | null): void;\nexport function getNamedType(type: GraphQLInputType): GraphQLNamedInputType;\nexport function getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType;\nexport function getNamedType(type: GraphQLType): GraphQLNamedType;\nexport function getNamedType(\n type: Maybe,\n): GraphQLNamedType | undefined;\nexport function getNamedType(\n type: Maybe,\n): GraphQLNamedType | undefined {\n if (type) {\n let unwrappedType = type;\n while (isWrappingType(unwrappedType)) {\n unwrappedType = unwrappedType.ofType;\n }\n return unwrappedType;\n }\n}\n\n/**\n * An interface for all Schema Elements.\n */\n\nexport interface GraphQLSchemaElement {\n toString: () => string;\n toJSON: () => string;\n}\n\n/**\n * Used while defining GraphQL types to allow for circular references in\n * otherwise immutable type definitions.\n */\nexport type ThunkReadonlyArray = (() => ReadonlyArray) | ReadonlyArray;\nexport type ThunkObjMap = (() => ObjMap) | ObjMap;\n\nexport function resolveReadonlyArrayThunk(\n thunk: ThunkReadonlyArray,\n): ReadonlyArray {\n return typeof thunk === 'function' ? thunk() : thunk;\n}\n\nexport function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap {\n return typeof thunk === 'function' ? thunk() : thunk;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLScalarTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Scalar Type Definition\n *\n * The leaf values of any request and input values to arguments are\n * Scalars (or Enums) and are defined with a name and a series of functions\n * used to parse input from ast or variables and to ensure validity.\n *\n * If a type's coerceOutputValue function returns `null` or does not return a\n * value (i.e. it returns `undefined`) then an error will be raised and a\n * `null` value will be returned in the response. It is always better to\n * validate.\n *\n * Example:\n *\n * ```ts\n * function ensureOdd(value) {\n * if (!Number.isFinite(value)) {\n * throw new Error(\n * `Scalar \"Odd\" cannot represent \"${value}\" since it is not a finite number.`,\n * );\n * }\n *\n * if (value % 2 === 0) {\n * throw new Error(`Scalar \"Odd\" cannot represent \"${value}\" since it is even.`);\n * }\n * }\n *\n * const OddType = new GraphQLScalarType({\n * name: 'Odd',\n * coerceOutputValue(value) {\n * return ensureOdd(value);\n * },\n * coerceInputValue(value) {\n * return ensureOdd(value);\n * }\n * valueToLiteral(value) {\n * return parse(`${ensureOdd(value)`);\n * }\n * });\n * ```\n *\n * Custom scalars behavior is defined via the following functions:\n *\n * - coerceOutputValue(value): Implements \"Result Coercion\". Given an internal value,\n * produces an external value valid for this type. Returns undefined or\n * throws an error to indicate invalid values.\n *\n * - coerceInputValue(value): Implements \"Input Coercion\" for values. Given an\n * external value (for example, variable values), produces an internal value\n * valid for this type. Returns undefined or throws an error to indicate\n * invalid values.\n *\n * - coerceInputLiteral(ast): Implements \"Input Coercion\" for constant literals.\n * Given an GraphQL literal (AST) (for example, an argument value), produces\n * an internal value valid for this type. Returns undefined or throws an\n * error to indicate invalid values.\n *\n * - valueToLiteral(value): Converts an external value to a GraphQL\n * literal (AST). Returns undefined or throws an error to indicate\n * invalid values.\n *\n * Deprecated, to be removed in v18:\n *\n * - serialize(value): Implements \"Result Coercion\". Renamed to\n * `coerceOutputValue()`.\n *\n * - parseValue(value): Implements \"Input Coercion\" for values. Renamed to\n * `coerceInputValue()`.\n *\n * - parseLiteral(ast): Implements \"Input Coercion\" for literals including\n * non-specified replacement of variables embedded within complex scalars.\n * Replaced by the combination of the `replaceVariables()` utility and the\n * `coerceInputLiteral()` method.\n *\n */\nexport class GraphQLScalarType\n implements GraphQLSchemaElement\n{\n name: string;\n description: Maybe;\n specifiedByURL: Maybe;\n /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */\n serialize: GraphQLScalarSerializer;\n /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */\n parseValue: GraphQLScalarValueParser;\n /** @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */\n parseLiteral: GraphQLScalarLiteralParser;\n coerceOutputValue: GraphQLScalarOutputValueCoercer;\n coerceInputValue: GraphQLScalarInputValueCoercer;\n coerceInputLiteral: GraphQLScalarInputLiteralCoercer | undefined;\n valueToLiteral: GraphQLScalarValueToLiteral | undefined;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.specifiedByURL = config.specifiedByURL;\n this.serialize =\n config.serialize ??\n config.coerceOutputValue ??\n (identityFunc as GraphQLScalarSerializer);\n this.parseValue =\n config.parseValue ??\n config.coerceInputValue ??\n (identityFunc as GraphQLScalarValueParser);\n this.parseLiteral =\n config.parseLiteral ??\n ((node, variables) =>\n this.coerceInputValue(valueFromASTUntyped(node, variables)));\n this.coerceOutputValue = config.coerceOutputValue ?? this.serialize;\n this.coerceInputValue = config.coerceInputValue ?? this.parseValue;\n this.coerceInputLiteral = config.coerceInputLiteral;\n this.valueToLiteral = config.valueToLiteral;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n if (config.parseLiteral) {\n devAssert(\n typeof config.parseValue === 'function' &&\n typeof config.parseLiteral === 'function',\n `${this.name} must provide both \"parseValue\" and \"parseLiteral\" functions.`,\n );\n }\n\n if (config.coerceInputLiteral) {\n devAssert(\n typeof config.coerceInputValue === 'function' &&\n typeof config.coerceInputLiteral === 'function',\n `${this.name} must provide both \"coerceInputValue\" and \"coerceInputLiteral\" functions.`,\n );\n }\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLScalarType';\n }\n\n toConfig(): GraphQLScalarTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n specifiedByURL: this.specifiedByURL,\n serialize: this.serialize,\n parseValue: this.parseValue,\n parseLiteral: this.parseLiteral,\n coerceOutputValue: this.coerceOutputValue,\n coerceInputValue: this.coerceInputValue,\n coerceInputLiteral: this.coerceInputLiteral,\n valueToLiteral: this.valueToLiteral,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/* @deprecated in favor of GraphQLScalarOutputValueCoercer, will be removed in v18 */\nexport type GraphQLScalarSerializer = (\n outputValue: unknown,\n) => TExternal;\n\nexport type GraphQLScalarOutputValueCoercer = (\n outputValue: unknown,\n) => TExternal;\n\n/* @deprecated in favor of GraphQLScalarInputValueCoercer, will be removed in v18 */\nexport type GraphQLScalarValueParser = (\n inputValue: unknown,\n) => TInternal;\n\nexport type GraphQLScalarInputValueCoercer = (\n inputValue: unknown,\n) => TInternal;\n\n/* @deprecated in favor of GraphQLScalarInputLiteralCoercer, will be removed in v18 */\nexport type GraphQLScalarLiteralParser = (\n valueNode: ValueNode,\n variables: Maybe>,\n) => Maybe;\n\nexport type GraphQLScalarInputLiteralCoercer = (\n valueNode: ConstValueNode,\n) => Maybe;\n\nexport type GraphQLScalarValueToLiteral = (\n inputValue: unknown,\n) => ConstValueNode | undefined;\n\nexport interface GraphQLScalarTypeConfig {\n name: string;\n description?: Maybe;\n specifiedByURL?: Maybe;\n /** Serializes an internal value to include in a response. */\n /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */\n serialize?: GraphQLScalarSerializer | undefined;\n /** Parses an externally provided value to use as an input. */\n /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */\n parseValue?: GraphQLScalarValueParser | undefined;\n /** Parses an externally provided literal value to use as an input. */\n /** @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */\n parseLiteral?: GraphQLScalarLiteralParser | undefined;\n /** Coerces an internal value to include in a response. */\n coerceOutputValue?: GraphQLScalarOutputValueCoercer | undefined;\n /** Coerces an externally provided value to use as an input. */\n coerceInputValue?: GraphQLScalarInputValueCoercer | undefined;\n /** Coerces an externally provided const literal value to use as an input. */\n coerceInputLiteral?: GraphQLScalarInputLiteralCoercer | undefined;\n /** Translates an externally provided value to a literal (AST). */\n valueToLiteral?: GraphQLScalarValueToLiteral | undefined;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLScalarTypeNormalizedConfig\n extends GraphQLScalarTypeConfig {\n serialize: GraphQLScalarSerializer;\n parseValue: GraphQLScalarValueParser;\n parseLiteral: GraphQLScalarLiteralParser;\n coerceOutputValue: GraphQLScalarOutputValueCoercer;\n coerceInputValue: GraphQLScalarInputValueCoercer;\n coerceInputLiteral: GraphQLScalarInputLiteralCoercer | undefined;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n *\n * We've provided these template arguments because this is an open type and\n * you may find them useful.\n */\nexport interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Object Type Definition\n *\n * Almost all of the GraphQL types you define will be object types. Object types\n * have a name, but most importantly describe their fields.\n *\n * Example:\n *\n * ```ts\n * const AddressType = new GraphQLObjectType({\n * name: 'Address',\n * fields: {\n * street: { type: GraphQLString },\n * number: { type: GraphQLInt },\n * formatted: {\n * type: GraphQLString,\n * resolve(obj) {\n * return obj.number + ' ' + obj.street\n * }\n * }\n * }\n * });\n * ```\n *\n * When two types need to refer to each other, or a type needs to refer to\n * itself in a field, you can use a function expression (aka a closure or a\n * thunk) to supply the fields lazily.\n *\n * Example:\n *\n * ```ts\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * name: { type: GraphQLString },\n * bestFriend: { type: PersonType },\n * })\n * });\n * ```\n */\nexport class GraphQLObjectType\n implements GraphQLSchemaElement\n{\n name: string;\n description: Maybe;\n isTypeOf: Maybe>;\n extensions: Readonly>;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _fields: ThunkObjMap>;\n private _interfaces: ThunkReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.isTypeOf = config.isTypeOf;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n this._fields = (defineFieldMap).bind(\n undefined,\n this,\n config.fields,\n );\n this._interfaces = defineInterfaces.bind(undefined, config.interfaces);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLObjectType';\n }\n\n getFields(): GraphQLFieldMap {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n return this._fields;\n }\n\n getInterfaces(): ReadonlyArray {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n return this._interfaces;\n }\n\n toConfig(): GraphQLObjectTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: mapValue(this.getFields(), (field) => field.toConfig()),\n isTypeOf: this.isTypeOf,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction defineInterfaces(\n interfaces: Maybe>,\n): ReadonlyArray {\n return resolveReadonlyArrayThunk(interfaces ?? []);\n}\n\nfunction defineFieldMap(\n parentType:\n | GraphQLObjectType\n | GraphQLInterfaceType,\n fields: ThunkObjMap>,\n): GraphQLFieldMap {\n const fieldMap = resolveObjMapThunk(fields);\n\n return mapValue(\n fieldMap,\n (fieldConfig, fieldName) =>\n new GraphQLField(parentType, fieldName, fieldConfig),\n );\n}\n\nexport interface GraphQLObjectTypeConfig {\n name: string;\n description?: Maybe;\n interfaces?: ThunkReadonlyArray | undefined;\n fields: ThunkObjMap>;\n isTypeOf?: Maybe>;\n extensions?: Maybe>>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLObjectTypeNormalizedConfig\n extends GraphQLObjectTypeConfig {\n interfaces: ReadonlyArray;\n fields: GraphQLFieldNormalizedConfigMap;\n extensions: Readonly>;\n extensionASTNodes: ReadonlyArray;\n}\n\nexport type GraphQLTypeResolver = (\n value: TSource,\n context: TContext,\n info: GraphQLResolveInfo,\n abstractType: GraphQLAbstractType,\n) => PromiseOrValue;\n\nexport type GraphQLIsTypeOfFn = (\n source: TSource,\n context: TContext,\n info: GraphQLResolveInfo,\n) => PromiseOrValue;\n\nexport type GraphQLFieldResolver<\n TSource,\n TContext,\n TArgs = any,\n TResult = unknown,\n> = (\n source: TSource,\n args: TArgs,\n context: TContext,\n info: GraphQLResolveInfo,\n abortSignal: AbortSignal | undefined,\n) => TResult;\n\nexport interface GraphQLResolveInfo {\n readonly fieldName: string;\n readonly fieldNodes: ReadonlyArray;\n readonly returnType: GraphQLOutputType;\n readonly parentType: GraphQLObjectType;\n readonly path: Path;\n readonly schema: GraphQLSchema;\n readonly fragments: ObjMap;\n readonly rootValue: unknown;\n readonly operation: OperationDefinitionNode;\n readonly variableValues: VariableValues;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n *\n * We've provided these template arguments because this is an open type and\n * you may find them useful.\n */\nexport interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLFieldConfig {\n description?: Maybe;\n type: GraphQLOutputType;\n args?: GraphQLFieldConfigArgumentMap | undefined;\n resolve?: GraphQLFieldResolver | undefined;\n subscribe?: GraphQLFieldResolver | undefined;\n deprecationReason?: Maybe;\n extensions?: Maybe<\n Readonly>\n >;\n astNode?: Maybe;\n}\n\nexport interface GraphQLFieldNormalizedConfig\n extends GraphQLFieldConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n extensions: Readonly>;\n}\n\nexport type GraphQLFieldConfigArgumentMap = ObjMap;\n\nexport type GraphQLFieldNormalizedConfigArgumentMap =\n ObjMap;\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLArgumentExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLArgumentConfig {\n description?: Maybe;\n type: GraphQLInputType;\n /** @deprecated use default instead, defaultValue will be removed in v18 **/\n defaultValue?: unknown;\n default?: GraphQLDefaultInput | undefined;\n deprecationReason?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport interface GraphQLArgumentNormalizedConfig extends GraphQLArgumentConfig {\n default: GraphQLDefaultInput | undefined;\n extensions: Readonly;\n}\n\nexport type GraphQLFieldConfigMap = ObjMap<\n GraphQLFieldConfig\n>;\n\nexport type GraphQLFieldNormalizedConfigMap = ObjMap<\n GraphQLFieldNormalizedConfig\n>;\n\nexport class GraphQLField\n implements GraphQLSchemaElement\n{\n parentType:\n | GraphQLObjectType\n | GraphQLInterfaceType\n | undefined;\n name: string;\n description: Maybe;\n type: GraphQLOutputType;\n args: ReadonlyArray;\n resolve?: GraphQLFieldResolver | undefined;\n subscribe?: GraphQLFieldResolver | undefined;\n deprecationReason: Maybe;\n extensions: Readonly>;\n astNode: Maybe;\n\n constructor(\n parentType:\n | GraphQLObjectType\n | GraphQLInterfaceType\n | undefined,\n name: string,\n config: GraphQLFieldConfig,\n ) {\n this.parentType = parentType;\n this.name = assertName(name);\n this.description = config.description;\n this.type = config.type;\n\n const argsConfig = config.args;\n this.args = argsConfig\n ? Object.entries(argsConfig).map(\n ([argName, argConfig]) =>\n new GraphQLArgument(this, argName, argConfig),\n )\n : [];\n\n this.resolve = config.resolve;\n this.subscribe = config.subscribe;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLField';\n }\n\n toConfig(): GraphQLFieldNormalizedConfig {\n return {\n description: this.description,\n type: this.type,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n resolve: this.resolve,\n subscribe: this.subscribe,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parentType ?? ''}.${this.name}`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport class GraphQLArgument implements GraphQLSchemaElement {\n parent: GraphQLField | GraphQLDirective;\n name: string;\n description: Maybe;\n type: GraphQLInputType;\n defaultValue: unknown;\n default: GraphQLDefaultInput | undefined;\n deprecationReason: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(\n parent: GraphQLField | GraphQLDirective,\n name: string,\n config: GraphQLArgumentConfig,\n ) {\n this.parent = parent;\n this.name = assertName(name);\n this.description = config.description;\n this.type = config.type;\n this.defaultValue = config.defaultValue;\n this.default = config.default;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLArgument';\n }\n\n toConfig(): GraphQLArgumentNormalizedConfig {\n return {\n description: this.description,\n type: this.type,\n defaultValue: this.defaultValue,\n default: this.default,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parent}(${this.name}:)`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport function isRequiredArgument(\n arg: GraphQLArgument | GraphQLVariableSignature,\n): boolean {\n return (\n isNonNullType(arg.type) &&\n arg.default === undefined &&\n arg.defaultValue === undefined\n );\n}\n\nexport type GraphQLFieldMap = ObjMap<\n GraphQLField\n>;\n\nexport type GraphQLDefaultInput =\n | { value: unknown; literal?: never }\n | { literal: ConstValueNode; value?: never };\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLInterfaceTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Interface Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Interface type\n * is used to describe what types are possible, what fields are in common across\n * all types, as well as a function to determine which type is actually used\n * when the field is resolved.\n *\n * Example:\n *\n * ```ts\n * const EntityType = new GraphQLInterfaceType({\n * name: 'Entity',\n * fields: {\n * name: { type: GraphQLString }\n * }\n * });\n * ```\n */\nexport class GraphQLInterfaceType\n implements GraphQLSchemaElement\n{\n name: string;\n description: Maybe;\n resolveType: Maybe>;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _fields: ThunkObjMap>;\n private _interfaces: ThunkReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n this._fields = (defineFieldMap).bind(\n undefined,\n this,\n config.fields,\n );\n this._interfaces = defineInterfaces.bind(undefined, config.interfaces);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInterfaceType';\n }\n\n getFields(): GraphQLFieldMap {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n return this._fields;\n }\n\n getInterfaces(): ReadonlyArray {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n return this._interfaces;\n }\n\n toConfig(): GraphQLInterfaceTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: mapValue(this.getFields(), (field) => field.toConfig()),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport interface GraphQLInterfaceTypeConfig {\n name: string;\n description?: Maybe;\n interfaces?: ThunkReadonlyArray | undefined;\n fields: ThunkObjMap>;\n /**\n * Optionally provide a custom type resolver function. If one is not provided,\n * the default implementation will call `isTypeOf` on each implementing\n * Object type.\n */\n resolveType?: Maybe>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLInterfaceTypeNormalizedConfig\n extends GraphQLInterfaceTypeConfig {\n interfaces: ReadonlyArray;\n fields: GraphQLFieldNormalizedConfigMap;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLUnionTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Union Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Union type\n * is used to describe what types are possible as well as providing a function\n * to determine which type is actually used when the field is resolved.\n *\n * Example:\n *\n * ```ts\n * const PetType = new GraphQLUnionType({\n * name: 'Pet',\n * types: [ DogType, CatType ],\n * resolveType(value) {\n * if (value instanceof Dog) {\n * return DogType;\n * }\n * if (value instanceof Cat) {\n * return CatType;\n * }\n * }\n * });\n * ```\n */\nexport class GraphQLUnionType implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n resolveType: Maybe>;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _types: ThunkReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._types = defineTypes.bind(undefined, config.types);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLUnionType';\n }\n\n getTypes(): ReadonlyArray {\n if (typeof this._types === 'function') {\n this._types = this._types();\n }\n return this._types;\n }\n\n toConfig(): GraphQLUnionTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n types: this.getTypes(),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction defineTypes(\n types: ThunkReadonlyArray,\n): ReadonlyArray {\n return resolveReadonlyArrayThunk(types);\n}\n\nexport interface GraphQLUnionTypeConfig {\n name: string;\n description?: Maybe;\n types: ThunkReadonlyArray;\n /**\n * Optionally provide a custom type resolver function. If one is not provided,\n * the default implementation will call `isTypeOf` on each implementing\n * Object type.\n */\n resolveType?: Maybe>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLUnionTypeNormalizedConfig\n extends GraphQLUnionTypeConfig {\n types: ReadonlyArray;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLEnumTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Enum Type Definition\n *\n * Some leaf values of requests and input values are Enums. GraphQL coerces\n * Enum values as strings, however internally Enums can be represented by any\n * kind of type, often integers.\n *\n * Example:\n *\n * ```ts\n * const RGBType = new GraphQLEnumType({\n * name: 'RGB',\n * values: {\n * RED: { value: 0 },\n * GREEN: { value: 1 },\n * BLUE: { value: 2 }\n * }\n * });\n * ```\n *\n * Note: If a value is not provided in a definition, the name of the enum value\n * will be used as its internal value.\n */\nexport class GraphQLEnumType /* */ implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _values:\n | ReadonlyArray */>\n | (() => GraphQLEnumValueConfigMap);\n\n private _valueLookup: ReadonlyMap | null;\n private _nameLookup: ObjMap | null;\n\n constructor(config: Readonly */>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._values =\n typeof config.values === 'function'\n ? config.values\n : Object.entries(config.values).map(\n ([valueName, valueConfig]) =>\n new GraphQLEnumValue(this, valueName, valueConfig),\n );\n this._valueLookup = null;\n this._nameLookup = null;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLEnumType';\n }\n\n getValues(): ReadonlyArray */> {\n if (typeof this._values === 'function') {\n this._values = Object.entries(this._values()).map(\n ([valueName, valueConfig]) =>\n new GraphQLEnumValue(this, valueName, valueConfig),\n );\n }\n return this._values;\n }\n\n getValue(name: string): Maybe {\n if (this._nameLookup === null) {\n this._nameLookup = keyMap(this.getValues(), (value) => value.name);\n }\n return this._nameLookup[name];\n }\n\n /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */\n serialize(outputValue: unknown /* T */): Maybe {\n return this.coerceOutputValue(outputValue);\n }\n\n coerceOutputValue(outputValue: unknown /* T */): Maybe {\n if (this._valueLookup === null) {\n this._valueLookup = new Map(\n this.getValues().map((enumValue) => [enumValue.value, enumValue]),\n );\n }\n const enumValue = this._valueLookup.get(outputValue);\n if (enumValue === undefined) {\n throw new GraphQLError(\n `Enum \"${this.name}\" cannot represent value: ${inspect(outputValue)}`,\n );\n }\n return enumValue.name;\n }\n\n /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */\n parseValue(\n inputValue: unknown,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n return this.coerceInputValue(inputValue, hideSuggestions);\n }\n\n coerceInputValue(\n inputValue: unknown,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n if (typeof inputValue !== 'string') {\n const valueStr = inspect(inputValue);\n throw new GraphQLError(\n `Enum \"${this.name}\" cannot represent non-string value: ${valueStr}.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)),\n );\n }\n\n const enumValue = this.getValue(inputValue);\n if (enumValue == null) {\n throw new GraphQLError(\n `Value \"${inputValue}\" does not exist in \"${this.name}\" enum.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, inputValue)),\n );\n }\n return enumValue.value;\n }\n\n /** @deprecated use `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */\n parseLiteral(\n valueNode: ValueNode,\n _variables: Maybe>,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n // Note: variables will be resolved to a value before calling this function.\n return this.coerceInputLiteral(\n valueNode as ConstValueNode,\n hideSuggestions,\n );\n }\n\n coerceInputLiteral(\n valueNode: ConstValueNode,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n if (valueNode.kind !== Kind.ENUM) {\n const valueStr = print(valueNode);\n throw new GraphQLError(\n `Enum \"${this.name}\" cannot represent non-enum value: ${valueStr}.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)),\n { nodes: valueNode },\n );\n }\n\n const enumValue = this.getValue(valueNode.value);\n if (enumValue == null) {\n const valueStr = print(valueNode);\n throw new GraphQLError(\n `Value \"${valueStr}\" does not exist in \"${this.name}\" enum.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)),\n { nodes: valueNode },\n );\n }\n return enumValue.value;\n }\n\n valueToLiteral(value: unknown): ConstValueNode | undefined {\n if (typeof value === 'string' && this.getValue(value)) {\n return { kind: Kind.ENUM, value };\n }\n }\n\n toConfig(): GraphQLEnumTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n values: keyValMap(\n this.getValues(),\n (value) => value.name,\n (value) => value.toConfig(),\n ),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction didYouMeanEnumValue(\n enumType: GraphQLEnumType,\n unknownValueStr: string,\n): string {\n const allNames = enumType.getValues().map((value) => value.name);\n const suggestedValues = suggestionList(unknownValueStr, allNames);\n\n return didYouMean('the enum value', suggestedValues);\n}\n\nexport interface GraphQLEnumTypeConfig {\n name: string;\n description?: Maybe;\n values: ThunkObjMap */>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig {\n values: GraphQLEnumValueNormalizedConfigMap;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\nexport type GraphQLEnumValueConfigMap /* */ =\n ObjMap */>;\n\nexport type GraphQLEnumValueNormalizedConfigMap /* */ =\n ObjMap */>;\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLEnumValueExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLEnumValueConfig {\n description?: Maybe;\n value?: any /* T */;\n deprecationReason?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport interface GraphQLEnumValueNormalizedConfig\n extends GraphQLEnumValueConfig {\n extensions: Readonly;\n}\n\nexport class GraphQLEnumValue implements GraphQLSchemaElement {\n parentEnum: GraphQLEnumType;\n name: string;\n description: Maybe;\n value: any /* T */;\n deprecationReason: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(\n parentEnum: GraphQLEnumType,\n name: string,\n config: GraphQLEnumValueConfig,\n ) {\n this.parentEnum = parentEnum;\n this.name = assertEnumValueName(name);\n this.description = config.description;\n this.value = config.value !== undefined ? config.value : name;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLEnumValue';\n }\n\n toConfig(): GraphQLEnumValueNormalizedConfig {\n return {\n description: this.description,\n value: this.value,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parentEnum.name}.${this.name}`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLInputObjectTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Input Object Type Definition\n *\n * An input object defines a structured collection of fields which may be\n * supplied to a field argument.\n *\n * Using `NonNull` will ensure that a value must be provided by the query\n *\n * Example:\n *\n * ```ts\n * const GeoPoint = new GraphQLInputObjectType({\n * name: 'GeoPoint',\n * fields: {\n * lat: { type: new GraphQLNonNull(GraphQLFloat) },\n * lon: { type: new GraphQLNonNull(GraphQLFloat) },\n * alt: { type: GraphQLFloat, defaultValue: 0 },\n * }\n * });\n * ```\n */\nexport class GraphQLInputObjectType implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n isOneOf: boolean;\n\n private _fields: ThunkObjMap;\n\n constructor(config: Readonly) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n this.isOneOf = config.isOneOf ?? false;\n\n this._fields = defineInputFieldMap.bind(undefined, this, config.fields);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInputObjectType';\n }\n\n getFields(): GraphQLInputFieldMap {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n return this._fields;\n }\n\n toConfig(): GraphQLInputObjectTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n fields: mapValue(this.getFields(), (field) => field.toConfig()),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n isOneOf: this.isOneOf,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction defineInputFieldMap(\n parentType: GraphQLInputObjectType,\n fields: ThunkObjMap,\n): GraphQLInputFieldMap {\n const fieldMap = resolveObjMapThunk(fields);\n return mapValue(\n fieldMap,\n (fieldConfig, fieldName) =>\n new GraphQLInputField(parentType, fieldName, fieldConfig),\n );\n}\n\nexport interface GraphQLInputObjectTypeConfig {\n name: string;\n description?: Maybe;\n fields: ThunkObjMap;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n isOneOf?: boolean;\n}\n\nexport interface GraphQLInputObjectTypeNormalizedConfig\n extends GraphQLInputObjectTypeConfig {\n fields: GraphQLInputFieldNormalizedConfigMap;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLInputFieldExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLInputFieldConfig {\n description?: Maybe;\n type: GraphQLInputType;\n /** @deprecated use default instead, defaultValue will be removed in v18 **/\n defaultValue?: unknown;\n default?: GraphQLDefaultInput | undefined;\n deprecationReason?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport type GraphQLInputFieldConfigMap = ObjMap;\n\nexport interface GraphQLInputFieldNormalizedConfig\n extends GraphQLInputFieldConfig {\n default: GraphQLDefaultInput | undefined;\n extensions: Readonly;\n}\n\nexport type GraphQLInputFieldNormalizedConfigMap =\n ObjMap;\n\nexport class GraphQLInputField implements GraphQLSchemaElement {\n parentType: GraphQLInputObjectType;\n name: string;\n description: Maybe;\n type: GraphQLInputType;\n defaultValue: unknown;\n default: GraphQLDefaultInput | undefined;\n deprecationReason: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(\n parentType: GraphQLInputObjectType,\n name: string,\n config: GraphQLInputFieldConfig,\n ) {\n devAssert(\n !('resolve' in config),\n `${parentType}.${name} field has a resolve property, but Input Types cannot define resolvers.`,\n );\n\n this.parentType = parentType;\n this.name = assertName(name);\n this.description = config.description;\n this.type = config.type;\n this.defaultValue = config.defaultValue;\n this.default = config.default;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInputField';\n }\n\n toConfig(): GraphQLInputFieldNormalizedConfig {\n return {\n description: this.description,\n type: this.type,\n defaultValue: this.defaultValue,\n default: this.default,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parentType}.${this.name}`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport function isRequiredInputField(field: GraphQLInputField): boolean {\n return (\n isNonNullType(field.type) &&\n field.defaultValue === undefined &&\n field.default === undefined\n );\n}\n\nexport type GraphQLInputFieldMap = ObjMap;\n"]} \ No newline at end of file diff --git a/type/definition.mjs b/type/definition.mjs new file mode 100644 index 0000000000..ea9e1e7393 --- /dev/null +++ b/type/definition.mjs @@ -0,0 +1,1005 @@ +import { devAssert } from "../jsutils/devAssert.mjs"; +import { didYouMean } from "../jsutils/didYouMean.mjs"; +import { identityFunc } from "../jsutils/identityFunc.mjs"; +import { inspect } from "../jsutils/inspect.mjs"; +import { instanceOf } from "../jsutils/instanceOf.mjs"; +import { keyMap } from "../jsutils/keyMap.mjs"; +import { keyValMap } from "../jsutils/keyValMap.mjs"; +import { mapValue } from "../jsutils/mapValue.mjs"; +import { suggestionList } from "../jsutils/suggestionList.mjs"; +import { toObjMapWithSymbols } from "../jsutils/toObjMap.mjs"; +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { print } from "../language/printer.mjs"; +import { valueFromASTUntyped } from "../utilities/valueFromASTUntyped.mjs"; +import { assertEnumValueName, assertName } from "./assertName.mjs"; +export function isType(type) { + return (isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) || + isListType(type) || + isNonNullType(type)); +} +export function assertType(type) { + if (!isType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL type.`); + } + return type; +} +/** + * There are predicates for each GraphQL schema element. + */ +export function isScalarType(type) { + return instanceOf(type, GraphQLScalarType); +} +export function assertScalarType(type) { + if (!isScalarType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL Scalar type.`); + } + return type; +} +export function isObjectType(type) { + return instanceOf(type, GraphQLObjectType); +} +export function assertObjectType(type) { + if (!isObjectType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL Object type.`); + } + return type; +} +export function isField(field) { + return instanceOf(field, GraphQLField); +} +export function assertField(field) { + if (!isField(field)) { + throw new Error(`Expected ${inspect(field)} to be a GraphQL field.`); + } + return field; +} +export function isArgument(arg) { + return instanceOf(arg, GraphQLArgument); +} +export function assertArgument(arg) { + if (!isArgument(arg)) { + throw new Error(`Expected ${inspect(arg)} to be a GraphQL argument.`); + } + return arg; +} +export function isInterfaceType(type) { + return instanceOf(type, GraphQLInterfaceType); +} +export function assertInterfaceType(type) { + if (!isInterfaceType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL Interface type.`); + } + return type; +} +export function isUnionType(type) { + return instanceOf(type, GraphQLUnionType); +} +export function assertUnionType(type) { + if (!isUnionType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL Union type.`); + } + return type; +} +export function isEnumType(type) { + return instanceOf(type, GraphQLEnumType); +} +export function assertEnumType(type) { + if (!isEnumType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL Enum type.`); + } + return type; +} +export function isEnumValue(value) { + return instanceOf(value, GraphQLEnumValue); +} +export function assertEnumValue(value) { + if (!isEnumValue(value)) { + throw new Error(`Expected ${inspect(value)} to be a GraphQL Enum value.`); + } + return value; +} +export function isInputObjectType(type) { + return instanceOf(type, GraphQLInputObjectType); +} +export function assertInputObjectType(type) { + if (!isInputObjectType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL Input Object type.`); + } + return type; +} +export function isInputField(field) { + return instanceOf(field, GraphQLInputField); +} +export function assertInputField(field) { + if (!isInputField(field)) { + throw new Error(`Expected ${inspect(field)} to be a GraphQL input field.`); + } + return field; +} +export function isListType(type) { + return instanceOf(type, GraphQLList); +} +export function assertListType(type) { + if (!isListType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL List type.`); + } + return type; +} +export function isNonNullType(type) { + return instanceOf(type, GraphQLNonNull); +} +export function assertNonNullType(type) { + if (!isNonNullType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL Non-Null type.`); + } + return type; +} +export function isInputType(type) { + return (isScalarType(type) || + isEnumType(type) || + isInputObjectType(type) || + (isWrappingType(type) && isInputType(type.ofType))); +} +export function assertInputType(type) { + if (!isInputType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL input type.`); + } + return type; +} +export function isOutputType(type) { + return (isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + (isWrappingType(type) && isOutputType(type.ofType))); +} +export function assertOutputType(type) { + if (!isOutputType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL output type.`); + } + return type; +} +export function isLeafType(type) { + return isScalarType(type) || isEnumType(type); +} +export function assertLeafType(type) { + if (!isLeafType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL leaf type.`); + } + return type; +} +export function isCompositeType(type) { + return isObjectType(type) || isInterfaceType(type) || isUnionType(type); +} +export function assertCompositeType(type) { + if (!isCompositeType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL composite type.`); + } + return type; +} +export function isAbstractType(type) { + return isInterfaceType(type) || isUnionType(type); +} +export function assertAbstractType(type) { + if (!isAbstractType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL abstract type.`); + } + return type; +} +/** + * List Type Wrapper + * + * A list is a wrapping type which points to another type. + * Lists are often created within the context of defining the fields of + * an object type. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * parents: { type: new GraphQLList(PersonType) }, + * children: { type: new GraphQLList(PersonType) }, + * }) + * }) + * ``` + */ +export class GraphQLList { + constructor(ofType) { + this.ofType = ofType; + } + get [Symbol.toStringTag]() { + return 'GraphQLList'; + } + toString() { + return '[' + String(this.ofType) + ']'; + } + toJSON() { + return this.toString(); + } +} +/** + * Non-Null Type Wrapper + * + * A non-null is a wrapping type which points to another type. + * Non-null types enforce that their values are never null and can ensure + * an error is raised if this ever occurs during a request. It is useful for + * fields which you can make a strong guarantee on non-nullability, for example + * usually the id field of a database row will never be null. + * + * Example: + * + * ```ts + * const RowType = new GraphQLObjectType({ + * name: 'Row', + * fields: () => ({ + * id: { type: new GraphQLNonNull(GraphQLString) }, + * }) + * }) + * ``` + * Note: the enforcement of non-nullability occurs within the executor. + */ +export class GraphQLNonNull { + constructor(ofType) { + this.ofType = ofType; + } + get [Symbol.toStringTag]() { + return 'GraphQLNonNull'; + } + toString() { + return String(this.ofType) + '!'; + } + toJSON() { + return this.toString(); + } +} +export function isWrappingType(type) { + return isListType(type) || isNonNullType(type); +} +export function assertWrappingType(type) { + if (!isWrappingType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL wrapping type.`); + } + return type; +} +export function isNullableType(type) { + return isType(type) && !isNonNullType(type); +} +export function assertNullableType(type) { + if (!isNullableType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL nullable type.`); + } + return type; +} +export function getNullableType(type) { + if (type) { + return isNonNullType(type) ? type.ofType : type; + } +} +export function isNamedType(type) { + return (isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type)); +} +export function assertNamedType(type) { + if (!isNamedType(type)) { + throw new Error(`Expected ${inspect(type)} to be a GraphQL named type.`); + } + return type; +} +export function getNamedType(type) { + if (type) { + let unwrappedType = type; + while (isWrappingType(unwrappedType)) { + unwrappedType = unwrappedType.ofType; + } + return unwrappedType; + } +} +export function resolveReadonlyArrayThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +export function resolveObjMapThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +/** + * Scalar Type Definition + * + * The leaf values of any request and input values to arguments are + * Scalars (or Enums) and are defined with a name and a series of functions + * used to parse input from ast or variables and to ensure validity. + * + * If a type's coerceOutputValue function returns `null` or does not return a + * value (i.e. it returns `undefined`) then an error will be raised and a + * `null` value will be returned in the response. It is always better to + * validate. + * + * Example: + * + * ```ts + * function ensureOdd(value) { + * if (!Number.isFinite(value)) { + * throw new Error( + * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`, + * ); + * } + * + * if (value % 2 === 0) { + * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`); + * } + * } + * + * const OddType = new GraphQLScalarType({ + * name: 'Odd', + * coerceOutputValue(value) { + * return ensureOdd(value); + * }, + * coerceInputValue(value) { + * return ensureOdd(value); + * } + * valueToLiteral(value) { + * return parse(`${ensureOdd(value)`); + * } + * }); + * ``` + * + * Custom scalars behavior is defined via the following functions: + * + * - coerceOutputValue(value): Implements "Result Coercion". Given an internal value, + * produces an external value valid for this type. Returns undefined or + * throws an error to indicate invalid values. + * + * - coerceInputValue(value): Implements "Input Coercion" for values. Given an + * external value (for example, variable values), produces an internal value + * valid for this type. Returns undefined or throws an error to indicate + * invalid values. + * + * - coerceInputLiteral(ast): Implements "Input Coercion" for constant literals. + * Given an GraphQL literal (AST) (for example, an argument value), produces + * an internal value valid for this type. Returns undefined or throws an + * error to indicate invalid values. + * + * - valueToLiteral(value): Converts an external value to a GraphQL + * literal (AST). Returns undefined or throws an error to indicate + * invalid values. + * + * Deprecated, to be removed in v18: + * + * - serialize(value): Implements "Result Coercion". Renamed to + * `coerceOutputValue()`. + * + * - parseValue(value): Implements "Input Coercion" for values. Renamed to + * `coerceInputValue()`. + * + * - parseLiteral(ast): Implements "Input Coercion" for literals including + * non-specified replacement of variables embedded within complex scalars. + * Replaced by the combination of the `replaceVariables()` utility and the + * `coerceInputLiteral()` method. + * + */ +export class GraphQLScalarType { + constructor(config) { + this.name = assertName(config.name); + this.description = config.description; + this.specifiedByURL = config.specifiedByURL; + this.serialize = + config.serialize ?? + config.coerceOutputValue ?? + identityFunc; + this.parseValue = + config.parseValue ?? + config.coerceInputValue ?? + identityFunc; + this.parseLiteral = + config.parseLiteral ?? + ((node, variables) => this.coerceInputValue(valueFromASTUntyped(node, variables))); + this.coerceOutputValue = config.coerceOutputValue ?? this.serialize; + this.coerceInputValue = config.coerceInputValue ?? this.parseValue; + this.coerceInputLiteral = config.coerceInputLiteral; + this.valueToLiteral = config.valueToLiteral; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + if (config.parseLiteral) { + (typeof config.parseValue === 'function' && + typeof config.parseLiteral === 'function') || devAssert(false, `${this.name} must provide both "parseValue" and "parseLiteral" functions.`); + } + if (config.coerceInputLiteral) { + (typeof config.coerceInputValue === 'function' && + typeof config.coerceInputLiteral === 'function') || devAssert(false, `${this.name} must provide both "coerceInputValue" and "coerceInputLiteral" functions.`); + } + } + get [Symbol.toStringTag]() { + return 'GraphQLScalarType'; + } + toConfig() { + return { + name: this.name, + description: this.description, + specifiedByURL: this.specifiedByURL, + serialize: this.serialize, + parseValue: this.parseValue, + parseLiteral: this.parseLiteral, + coerceOutputValue: this.coerceOutputValue, + coerceInputValue: this.coerceInputValue, + coerceInputLiteral: this.coerceInputLiteral, + valueToLiteral: this.valueToLiteral, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +/** + * Object Type Definition + * + * Almost all of the GraphQL types you define will be object types. Object types + * have a name, but most importantly describe their fields. + * + * Example: + * + * ```ts + * const AddressType = new GraphQLObjectType({ + * name: 'Address', + * fields: { + * street: { type: GraphQLString }, + * number: { type: GraphQLInt }, + * formatted: { + * type: GraphQLString, + * resolve(obj) { + * return obj.number + ' ' + obj.street + * } + * } + * } + * }); + * ``` + * + * When two types need to refer to each other, or a type needs to refer to + * itself in a field, you can use a function expression (aka a closure or a + * thunk) to supply the fields lazily. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * name: { type: GraphQLString }, + * bestFriend: { type: PersonType }, + * }) + * }); + * ``` + */ +export class GraphQLObjectType { + constructor(config) { + this.name = assertName(config.name); + this.description = config.description; + this.isTypeOf = config.isTypeOf; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._fields = (defineFieldMap).bind(undefined, this, config.fields); + this._interfaces = defineInterfaces.bind(undefined, config.interfaces); + } + get [Symbol.toStringTag]() { + return 'GraphQLObjectType'; + } + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + return this._fields; + } + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + return this._interfaces; + } + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: mapValue(this.getFields(), (field) => field.toConfig()), + isTypeOf: this.isTypeOf, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +function defineInterfaces(interfaces) { + return resolveReadonlyArrayThunk(interfaces ?? []); +} +function defineFieldMap(parentType, fields) { + const fieldMap = resolveObjMapThunk(fields); + return mapValue(fieldMap, (fieldConfig, fieldName) => new GraphQLField(parentType, fieldName, fieldConfig)); +} +export class GraphQLField { + constructor(parentType, name, config) { + this.parentType = parentType; + this.name = assertName(name); + this.description = config.description; + this.type = config.type; + const argsConfig = config.args; + this.args = argsConfig + ? Object.entries(argsConfig).map(([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig)) + : []; + this.resolve = config.resolve; + this.subscribe = config.subscribe; + this.deprecationReason = config.deprecationReason; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLField'; + } + toConfig() { + return { + description: this.description, + type: this.type, + args: keyValMap(this.args, (arg) => arg.name, (arg) => arg.toConfig()), + resolve: this.resolve, + subscribe: this.subscribe, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parentType ?? ''}.${this.name}`; + } + toJSON() { + return this.toString(); + } +} +export class GraphQLArgument { + constructor(parent, name, config) { + this.parent = parent; + this.name = assertName(name); + this.description = config.description; + this.type = config.type; + this.defaultValue = config.defaultValue; + this.default = config.default; + this.deprecationReason = config.deprecationReason; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLArgument'; + } + toConfig() { + return { + description: this.description, + type: this.type, + defaultValue: this.defaultValue, + default: this.default, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parent}(${this.name}:)`; + } + toJSON() { + return this.toString(); + } +} +export function isRequiredArgument(arg) { + return (isNonNullType(arg.type) && + arg.default === undefined && + arg.defaultValue === undefined); +} +/** + * Interface Type Definition + * + * When a field can return one of a heterogeneous set of types, a Interface type + * is used to describe what types are possible, what fields are in common across + * all types, as well as a function to determine which type is actually used + * when the field is resolved. + * + * Example: + * + * ```ts + * const EntityType = new GraphQLInterfaceType({ + * name: 'Entity', + * fields: { + * name: { type: GraphQLString } + * } + * }); + * ``` + */ +export class GraphQLInterfaceType { + constructor(config) { + this.name = assertName(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._fields = (defineFieldMap).bind(undefined, this, config.fields); + this._interfaces = defineInterfaces.bind(undefined, config.interfaces); + } + get [Symbol.toStringTag]() { + return 'GraphQLInterfaceType'; + } + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + return this._fields; + } + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + return this._interfaces; + } + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: mapValue(this.getFields(), (field) => field.toConfig()), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +/** + * Union Type Definition + * + * When a field can return one of a heterogeneous set of types, a Union type + * is used to describe what types are possible as well as providing a function + * to determine which type is actually used when the field is resolved. + * + * Example: + * + * ```ts + * const PetType = new GraphQLUnionType({ + * name: 'Pet', + * types: [ DogType, CatType ], + * resolveType(value) { + * if (value instanceof Dog) { + * return DogType; + * } + * if (value instanceof Cat) { + * return CatType; + * } + * } + * }); + * ``` + */ +export class GraphQLUnionType { + constructor(config) { + this.name = assertName(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._types = defineTypes.bind(undefined, config.types); + } + get [Symbol.toStringTag]() { + return 'GraphQLUnionType'; + } + getTypes() { + if (typeof this._types === 'function') { + this._types = this._types(); + } + return this._types; + } + toConfig() { + return { + name: this.name, + description: this.description, + types: this.getTypes(), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +function defineTypes(types) { + return resolveReadonlyArrayThunk(types); +} +/** + * Enum Type Definition + * + * Some leaf values of requests and input values are Enums. GraphQL coerces + * Enum values as strings, however internally Enums can be represented by any + * kind of type, often integers. + * + * Example: + * + * ```ts + * const RGBType = new GraphQLEnumType({ + * name: 'RGB', + * values: { + * RED: { value: 0 }, + * GREEN: { value: 1 }, + * BLUE: { value: 2 } + * } + * }); + * ``` + * + * Note: If a value is not provided in a definition, the name of the enum value + * will be used as its internal value. + */ +export class GraphQLEnumType /* */ { + constructor(config) { + this.name = assertName(config.name); + this.description = config.description; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._values = + typeof config.values === 'function' + ? config.values + : Object.entries(config.values).map(([valueName, valueConfig]) => new GraphQLEnumValue(this, valueName, valueConfig)); + this._valueLookup = null; + this._nameLookup = null; + } + get [Symbol.toStringTag]() { + return 'GraphQLEnumType'; + } + getValues() { + if (typeof this._values === 'function') { + this._values = Object.entries(this._values()).map(([valueName, valueConfig]) => new GraphQLEnumValue(this, valueName, valueConfig)); + } + return this._values; + } + getValue(name) { + if (this._nameLookup === null) { + this._nameLookup = keyMap(this.getValues(), (value) => value.name); + } + return this._nameLookup[name]; + } + /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */ + serialize(outputValue /* T */) { + return this.coerceOutputValue(outputValue); + } + coerceOutputValue(outputValue /* T */) { + if (this._valueLookup === null) { + this._valueLookup = new Map(this.getValues().map((enumValue) => [enumValue.value, enumValue])); + } + const enumValue = this._valueLookup.get(outputValue); + if (enumValue === undefined) { + throw new GraphQLError(`Enum "${this.name}" cannot represent value: ${inspect(outputValue)}`); + } + return enumValue.name; + } + /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */ + parseValue(inputValue, hideSuggestions) { + return this.coerceInputValue(inputValue, hideSuggestions); + } + coerceInputValue(inputValue, hideSuggestions) { + if (typeof inputValue !== 'string') { + const valueStr = inspect(inputValue); + throw new GraphQLError(`Enum "${this.name}" cannot represent non-string value: ${valueStr}.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr))); + } + const enumValue = this.getValue(inputValue); + if (enumValue == null) { + throw new GraphQLError(`Value "${inputValue}" does not exist in "${this.name}" enum.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, inputValue))); + } + return enumValue.value; + } + /** @deprecated use `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */ + parseLiteral(valueNode, _variables, hideSuggestions) { + // Note: variables will be resolved to a value before calling this function. + return this.coerceInputLiteral(valueNode, hideSuggestions); + } + coerceInputLiteral(valueNode, hideSuggestions) { + if (valueNode.kind !== Kind.ENUM) { + const valueStr = print(valueNode); + throw new GraphQLError(`Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)), { nodes: valueNode }); + } + const enumValue = this.getValue(valueNode.value); + if (enumValue == null) { + const valueStr = print(valueNode); + throw new GraphQLError(`Value "${valueStr}" does not exist in "${this.name}" enum.` + + (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)), { nodes: valueNode }); + } + return enumValue.value; + } + valueToLiteral(value) { + if (typeof value === 'string' && this.getValue(value)) { + return { kind: Kind.ENUM, value }; + } + } + toConfig() { + return { + name: this.name, + description: this.description, + values: keyValMap(this.getValues(), (value) => value.name, (value) => value.toConfig()), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +function didYouMeanEnumValue(enumType, unknownValueStr) { + const allNames = enumType.getValues().map((value) => value.name); + const suggestedValues = suggestionList(unknownValueStr, allNames); + return didYouMean('the enum value', suggestedValues); +} +export class GraphQLEnumValue { + constructor(parentEnum, name, config) { + this.parentEnum = parentEnum; + this.name = assertEnumValueName(name); + this.description = config.description; + this.value = config.value !== undefined ? config.value : name; + this.deprecationReason = config.deprecationReason; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLEnumValue'; + } + toConfig() { + return { + description: this.description, + value: this.value, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parentEnum.name}.${this.name}`; + } + toJSON() { + return this.toString(); + } +} +/** + * Input Object Type Definition + * + * An input object defines a structured collection of fields which may be + * supplied to a field argument. + * + * Using `NonNull` will ensure that a value must be provided by the query + * + * Example: + * + * ```ts + * const GeoPoint = new GraphQLInputObjectType({ + * name: 'GeoPoint', + * fields: { + * lat: { type: new GraphQLNonNull(GraphQLFloat) }, + * lon: { type: new GraphQLNonNull(GraphQLFloat) }, + * alt: { type: GraphQLFloat, defaultValue: 0 }, + * } + * }); + * ``` + */ +export class GraphQLInputObjectType { + constructor(config) { + this.name = assertName(config.name); + this.description = config.description; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this.isOneOf = config.isOneOf ?? false; + this._fields = defineInputFieldMap.bind(undefined, this, config.fields); + } + get [Symbol.toStringTag]() { + return 'GraphQLInputObjectType'; + } + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + return this._fields; + } + toConfig() { + return { + name: this.name, + description: this.description, + fields: mapValue(this.getFields(), (field) => field.toConfig()), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + isOneOf: this.isOneOf, + }; + } + toString() { + return this.name; + } + toJSON() { + return this.toString(); + } +} +function defineInputFieldMap(parentType, fields) { + const fieldMap = resolveObjMapThunk(fields); + return mapValue(fieldMap, (fieldConfig, fieldName) => new GraphQLInputField(parentType, fieldName, fieldConfig)); +} +export class GraphQLInputField { + constructor(parentType, name, config) { + (!('resolve' in config)) || devAssert(false, `${parentType}.${name} field has a resolve property, but Input Types cannot define resolvers.`); + this.parentType = parentType; + this.name = assertName(name); + this.description = config.description; + this.type = config.type; + this.defaultValue = config.defaultValue; + this.default = config.default; + this.deprecationReason = config.deprecationReason; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + } + get [Symbol.toStringTag]() { + return 'GraphQLInputField'; + } + toConfig() { + return { + description: this.description, + type: this.type, + defaultValue: this.defaultValue, + default: this.default, + deprecationReason: this.deprecationReason, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return `${this.parentType}.${this.name}`; + } + toJSON() { + return this.toString(); + } +} +export function isRequiredInputField(field) { + return (isNonNullType(field.type) && + field.defaultValue === undefined && + field.default === undefined); +} +//# sourceMappingURL=definition.js.map \ No newline at end of file diff --git a/type/definition.mjs.map b/type/definition.mjs.map new file mode 100644 index 0000000000..0a2114e77c --- /dev/null +++ b/type/definition.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/type/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,UAAU,EAAE,kCAAiC;AACtD,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EA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AAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAwB;IAC3D,OAAO,CACL,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;QACzB,KAAK,CAAC,YAAY,KAAK,SAAS;QAChC,KAAK,CAAC,OAAO,KAAK,SAAS,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { didYouMean } from '../jsutils/didYouMean.js';\nimport { identityFunc } from '../jsutils/identityFunc.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\nimport { keyMap } from '../jsutils/keyMap.js';\nimport { keyValMap } from '../jsutils/keyValMap.js';\nimport { mapValue } from '../jsutils/mapValue.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport type { Path } from '../jsutils/Path.js';\nimport type { PromiseOrValue } from '../jsutils/PromiseOrValue.js';\nimport { suggestionList } from '../jsutils/suggestionList.js';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ConstValueNode,\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n EnumValueDefinitionNode,\n FieldDefinitionNode,\n FieldNode,\n FragmentDefinitionNode,\n InputObjectTypeDefinitionNode,\n InputObjectTypeExtensionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n OperationDefinitionNode,\n ScalarTypeDefinitionNode,\n ScalarTypeExtensionNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n ValueNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport type { GraphQLVariableSignature } from '../execution/getVariableSignature.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { valueFromASTUntyped } from '../utilities/valueFromASTUntyped.js';\n\nimport { assertEnumValueName, assertName } from './assertName.js';\nimport type { GraphQLDirective } from './directives.js';\nimport type { GraphQLSchema } from './schema.js';\n\n// Predicates & Assertions\n\n/**\n * These are all of the possible kinds of types.\n */\nexport type GraphQLType = GraphQLNamedType | GraphQLWrappingType;\n\nexport function isType(type: unknown): type is GraphQLType {\n return (\n isScalarType(type) ||\n isObjectType(type) ||\n isInterfaceType(type) ||\n isUnionType(type) ||\n isEnumType(type) ||\n isInputObjectType(type) ||\n isListType(type) ||\n isNonNullType(type)\n );\n}\n\nexport function assertType(type: unknown): GraphQLType {\n if (!isType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL type.`);\n }\n return type;\n}\n\n/**\n * There are predicates for each GraphQL schema element.\n */\nexport function isScalarType(type: unknown): type is GraphQLScalarType {\n return instanceOf(type, GraphQLScalarType);\n}\n\nexport function assertScalarType(type: unknown): GraphQLScalarType {\n if (!isScalarType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Scalar type.`);\n }\n return type;\n}\n\nexport function isObjectType(type: unknown): type is GraphQLObjectType {\n return instanceOf(type, GraphQLObjectType);\n}\n\nexport function assertObjectType(type: unknown): GraphQLObjectType {\n if (!isObjectType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Object type.`);\n }\n return type;\n}\n\nexport function isField(field: unknown): field is GraphQLField {\n return instanceOf(field, GraphQLField);\n}\n\nexport function assertField(field: unknown): GraphQLField {\n if (!isField(field)) {\n throw new Error(`Expected ${inspect(field)} to be a GraphQL field.`);\n }\n return field;\n}\n\nexport function isArgument(arg: unknown): arg is GraphQLArgument {\n return instanceOf(arg, GraphQLArgument);\n}\n\nexport function assertArgument(arg: unknown): GraphQLArgument {\n if (!isArgument(arg)) {\n throw new Error(`Expected ${inspect(arg)} to be a GraphQL argument.`);\n }\n return arg;\n}\n\nexport function isInterfaceType(type: unknown): type is GraphQLInterfaceType {\n return instanceOf(type, GraphQLInterfaceType);\n}\n\nexport function assertInterfaceType(type: unknown): GraphQLInterfaceType {\n if (!isInterfaceType(type)) {\n throw new Error(\n `Expected ${inspect(type)} to be a GraphQL Interface type.`,\n );\n }\n return type;\n}\n\nexport function isUnionType(type: unknown): type is GraphQLUnionType {\n return instanceOf(type, GraphQLUnionType);\n}\n\nexport function assertUnionType(type: unknown): GraphQLUnionType {\n if (!isUnionType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Union type.`);\n }\n return type;\n}\n\nexport function isEnumType(type: unknown): type is GraphQLEnumType {\n return instanceOf(type, GraphQLEnumType);\n}\n\nexport function assertEnumType(type: unknown): GraphQLEnumType {\n if (!isEnumType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Enum type.`);\n }\n return type;\n}\n\nexport function isEnumValue(value: unknown): value is GraphQLEnumValue {\n return instanceOf(value, GraphQLEnumValue);\n}\n\nexport function assertEnumValue(value: unknown): GraphQLEnumValue {\n if (!isEnumValue(value)) {\n throw new Error(`Expected ${inspect(value)} to be a GraphQL Enum value.`);\n }\n return value;\n}\n\nexport function isInputObjectType(\n type: unknown,\n): type is GraphQLInputObjectType {\n return instanceOf(type, GraphQLInputObjectType);\n}\n\nexport function assertInputObjectType(type: unknown): GraphQLInputObjectType {\n if (!isInputObjectType(type)) {\n throw new Error(\n `Expected ${inspect(type)} to be a GraphQL Input Object type.`,\n );\n }\n return type;\n}\n\nexport function isInputField(field: unknown): field is GraphQLInputField {\n return instanceOf(field, GraphQLInputField);\n}\n\nexport function assertInputField(field: unknown): GraphQLInputField {\n if (!isInputField(field)) {\n throw new Error(`Expected ${inspect(field)} to be a GraphQL input field.`);\n }\n return field;\n}\n\nexport function isListType(\n type: GraphQLInputType,\n): type is GraphQLList;\nexport function isListType(\n type: GraphQLOutputType,\n): type is GraphQLList;\nexport function isListType(type: unknown): type is GraphQLList;\nexport function isListType(type: unknown): type is GraphQLList {\n return instanceOf(type, GraphQLList);\n}\n\nexport function assertListType(type: unknown): GraphQLList {\n if (!isListType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL List type.`);\n }\n return type;\n}\n\nexport function isNonNullType(\n type: GraphQLInputType,\n): type is GraphQLNonNull;\nexport function isNonNullType(\n type: GraphQLOutputType,\n): type is GraphQLNonNull;\nexport function isNonNullType(\n type: unknown,\n): type is GraphQLNonNull;\nexport function isNonNullType(\n type: unknown,\n): type is GraphQLNonNull {\n return instanceOf(type, GraphQLNonNull);\n}\n\nexport function assertNonNullType(\n type: unknown,\n): GraphQLNonNull {\n if (!isNonNullType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Non-Null type.`);\n }\n return type;\n}\n\n/**\n * These types may be used as input types for arguments and directives.\n */\nexport type GraphQLNullableInputType =\n | GraphQLNamedInputType\n | GraphQLList;\n\nexport type GraphQLInputType =\n | GraphQLNullableInputType\n | GraphQLNonNull;\n\nexport function isInputType(type: unknown): type is GraphQLInputType {\n return (\n isScalarType(type) ||\n isEnumType(type) ||\n isInputObjectType(type) ||\n (isWrappingType(type) && isInputType(type.ofType))\n );\n}\n\nexport function assertInputType(type: unknown): GraphQLInputType {\n if (!isInputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL input type.`);\n }\n return type;\n}\n\n/**\n * These types may be used as output types as the result of fields.\n */\nexport type GraphQLNullableOutputType =\n | GraphQLNamedOutputType\n | GraphQLList;\n\nexport type GraphQLOutputType =\n | GraphQLNullableOutputType\n | GraphQLNonNull;\n\nexport function isOutputType(type: unknown): type is GraphQLOutputType {\n return (\n isScalarType(type) ||\n isObjectType(type) ||\n isInterfaceType(type) ||\n isUnionType(type) ||\n isEnumType(type) ||\n (isWrappingType(type) && isOutputType(type.ofType))\n );\n}\n\nexport function assertOutputType(type: unknown): GraphQLOutputType {\n if (!isOutputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL output type.`);\n }\n return type;\n}\n\n/**\n * These types may describe types which may be leaf values.\n */\nexport type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;\n\nexport function isLeafType(type: unknown): type is GraphQLLeafType {\n return isScalarType(type) || isEnumType(type);\n}\n\nexport function assertLeafType(type: unknown): GraphQLLeafType {\n if (!isLeafType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL leaf type.`);\n }\n return type;\n}\n\n/**\n * These types may describe the parent context of a selection set.\n */\nexport type GraphQLCompositeType =\n | GraphQLObjectType\n | GraphQLInterfaceType\n | GraphQLUnionType;\n\nexport function isCompositeType(type: unknown): type is GraphQLCompositeType {\n return isObjectType(type) || isInterfaceType(type) || isUnionType(type);\n}\n\nexport function assertCompositeType(type: unknown): GraphQLCompositeType {\n if (!isCompositeType(type)) {\n throw new Error(\n `Expected ${inspect(type)} to be a GraphQL composite type.`,\n );\n }\n return type;\n}\n\n/**\n * These types may describe the parent context of a selection set.\n */\nexport type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType;\n\nexport function isAbstractType(type: unknown): type is GraphQLAbstractType {\n return isInterfaceType(type) || isUnionType(type);\n}\n\nexport function assertAbstractType(type: unknown): GraphQLAbstractType {\n if (!isAbstractType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL abstract type.`);\n }\n return type;\n}\n\n/**\n * List Type Wrapper\n *\n * A list is a wrapping type which points to another type.\n * Lists are often created within the context of defining the fields of\n * an object type.\n *\n * Example:\n *\n * ```ts\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * parents: { type: new GraphQLList(PersonType) },\n * children: { type: new GraphQLList(PersonType) },\n * })\n * })\n * ```\n */\nexport class GraphQLList\n implements GraphQLSchemaElement\n{\n readonly ofType: T;\n\n constructor(ofType: T) {\n this.ofType = ofType;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLList';\n }\n\n toString(): string {\n return '[' + String(this.ofType) + ']';\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/**\n * Non-Null Type Wrapper\n *\n * A non-null is a wrapping type which points to another type.\n * Non-null types enforce that their values are never null and can ensure\n * an error is raised if this ever occurs during a request. It is useful for\n * fields which you can make a strong guarantee on non-nullability, for example\n * usually the id field of a database row will never be null.\n *\n * Example:\n *\n * ```ts\n * const RowType = new GraphQLObjectType({\n * name: 'Row',\n * fields: () => ({\n * id: { type: new GraphQLNonNull(GraphQLString) },\n * })\n * })\n * ```\n * Note: the enforcement of non-nullability occurs within the executor.\n */\nexport class GraphQLNonNull\n implements GraphQLSchemaElement\n{\n readonly ofType: T;\n\n constructor(ofType: T) {\n this.ofType = ofType;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLNonNull';\n }\n\n toString(): string {\n return String(this.ofType) + '!';\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/**\n * These types wrap and modify other types\n */\n\nexport type GraphQLWrappingType =\n | GraphQLList\n | GraphQLNonNull;\n\nexport function isWrappingType(type: unknown): type is GraphQLWrappingType {\n return isListType(type) || isNonNullType(type);\n}\n\nexport function assertWrappingType(type: unknown): GraphQLWrappingType {\n if (!isWrappingType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL wrapping type.`);\n }\n return type;\n}\n\n/**\n * These types can all accept null as a value.\n */\nexport type GraphQLNullableType = GraphQLNamedType | GraphQLList;\n\nexport function isNullableType(type: unknown): type is GraphQLNullableType {\n return isType(type) && !isNonNullType(type);\n}\n\nexport function assertNullableType(type: unknown): GraphQLNullableType {\n if (!isNullableType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL nullable type.`);\n }\n return type;\n}\n\nexport function getNullableType(type: undefined | null): void;\nexport function getNullableType(\n type: T | GraphQLNonNull,\n): T;\nexport function getNullableType(\n type: Maybe,\n): GraphQLNullableType | undefined;\nexport function getNullableType(\n type: Maybe,\n): GraphQLNullableType | undefined {\n if (type) {\n return isNonNullType(type) ? type.ofType : type;\n }\n}\n\n/**\n * These named types do not include modifiers like List or NonNull.\n */\nexport type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;\n\nexport type GraphQLNamedInputType =\n | GraphQLScalarType\n | GraphQLEnumType\n | GraphQLInputObjectType;\n\nexport type GraphQLNamedOutputType =\n | GraphQLScalarType\n | GraphQLObjectType\n | GraphQLInterfaceType\n | GraphQLUnionType\n | GraphQLEnumType;\n\nexport function isNamedType(type: unknown): type is GraphQLNamedType {\n return (\n isScalarType(type) ||\n isObjectType(type) ||\n isInterfaceType(type) ||\n isUnionType(type) ||\n isEnumType(type) ||\n isInputObjectType(type)\n );\n}\n\nexport function assertNamedType(type: unknown): GraphQLNamedType {\n if (!isNamedType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL named type.`);\n }\n return type;\n}\n\nexport function getNamedType(type: undefined | null): void;\nexport function getNamedType(type: GraphQLInputType): GraphQLNamedInputType;\nexport function getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType;\nexport function getNamedType(type: GraphQLType): GraphQLNamedType;\nexport function getNamedType(\n type: Maybe,\n): GraphQLNamedType | undefined;\nexport function getNamedType(\n type: Maybe,\n): GraphQLNamedType | undefined {\n if (type) {\n let unwrappedType = type;\n while (isWrappingType(unwrappedType)) {\n unwrappedType = unwrappedType.ofType;\n }\n return unwrappedType;\n }\n}\n\n/**\n * An interface for all Schema Elements.\n */\n\nexport interface GraphQLSchemaElement {\n toString: () => string;\n toJSON: () => string;\n}\n\n/**\n * Used while defining GraphQL types to allow for circular references in\n * otherwise immutable type definitions.\n */\nexport type ThunkReadonlyArray = (() => ReadonlyArray) | ReadonlyArray;\nexport type ThunkObjMap = (() => ObjMap) | ObjMap;\n\nexport function resolveReadonlyArrayThunk(\n thunk: ThunkReadonlyArray,\n): ReadonlyArray {\n return typeof thunk === 'function' ? thunk() : thunk;\n}\n\nexport function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap {\n return typeof thunk === 'function' ? thunk() : thunk;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLScalarTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Scalar Type Definition\n *\n * The leaf values of any request and input values to arguments are\n * Scalars (or Enums) and are defined with a name and a series of functions\n * used to parse input from ast or variables and to ensure validity.\n *\n * If a type's coerceOutputValue function returns `null` or does not return a\n * value (i.e. it returns `undefined`) then an error will be raised and a\n * `null` value will be returned in the response. It is always better to\n * validate.\n *\n * Example:\n *\n * ```ts\n * function ensureOdd(value) {\n * if (!Number.isFinite(value)) {\n * throw new Error(\n * `Scalar \"Odd\" cannot represent \"${value}\" since it is not a finite number.`,\n * );\n * }\n *\n * if (value % 2 === 0) {\n * throw new Error(`Scalar \"Odd\" cannot represent \"${value}\" since it is even.`);\n * }\n * }\n *\n * const OddType = new GraphQLScalarType({\n * name: 'Odd',\n * coerceOutputValue(value) {\n * return ensureOdd(value);\n * },\n * coerceInputValue(value) {\n * return ensureOdd(value);\n * }\n * valueToLiteral(value) {\n * return parse(`${ensureOdd(value)`);\n * }\n * });\n * ```\n *\n * Custom scalars behavior is defined via the following functions:\n *\n * - coerceOutputValue(value): Implements \"Result Coercion\". Given an internal value,\n * produces an external value valid for this type. Returns undefined or\n * throws an error to indicate invalid values.\n *\n * - coerceInputValue(value): Implements \"Input Coercion\" for values. Given an\n * external value (for example, variable values), produces an internal value\n * valid for this type. Returns undefined or throws an error to indicate\n * invalid values.\n *\n * - coerceInputLiteral(ast): Implements \"Input Coercion\" for constant literals.\n * Given an GraphQL literal (AST) (for example, an argument value), produces\n * an internal value valid for this type. Returns undefined or throws an\n * error to indicate invalid values.\n *\n * - valueToLiteral(value): Converts an external value to a GraphQL\n * literal (AST). Returns undefined or throws an error to indicate\n * invalid values.\n *\n * Deprecated, to be removed in v18:\n *\n * - serialize(value): Implements \"Result Coercion\". Renamed to\n * `coerceOutputValue()`.\n *\n * - parseValue(value): Implements \"Input Coercion\" for values. Renamed to\n * `coerceInputValue()`.\n *\n * - parseLiteral(ast): Implements \"Input Coercion\" for literals including\n * non-specified replacement of variables embedded within complex scalars.\n * Replaced by the combination of the `replaceVariables()` utility and the\n * `coerceInputLiteral()` method.\n *\n */\nexport class GraphQLScalarType\n implements GraphQLSchemaElement\n{\n name: string;\n description: Maybe;\n specifiedByURL: Maybe;\n /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */\n serialize: GraphQLScalarSerializer;\n /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */\n parseValue: GraphQLScalarValueParser;\n /** @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */\n parseLiteral: GraphQLScalarLiteralParser;\n coerceOutputValue: GraphQLScalarOutputValueCoercer;\n coerceInputValue: GraphQLScalarInputValueCoercer;\n coerceInputLiteral: GraphQLScalarInputLiteralCoercer | undefined;\n valueToLiteral: GraphQLScalarValueToLiteral | undefined;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.specifiedByURL = config.specifiedByURL;\n this.serialize =\n config.serialize ??\n config.coerceOutputValue ??\n (identityFunc as GraphQLScalarSerializer);\n this.parseValue =\n config.parseValue ??\n config.coerceInputValue ??\n (identityFunc as GraphQLScalarValueParser);\n this.parseLiteral =\n config.parseLiteral ??\n ((node, variables) =>\n this.coerceInputValue(valueFromASTUntyped(node, variables)));\n this.coerceOutputValue = config.coerceOutputValue ?? this.serialize;\n this.coerceInputValue = config.coerceInputValue ?? this.parseValue;\n this.coerceInputLiteral = config.coerceInputLiteral;\n this.valueToLiteral = config.valueToLiteral;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n if (config.parseLiteral) {\n devAssert(\n typeof config.parseValue === 'function' &&\n typeof config.parseLiteral === 'function',\n `${this.name} must provide both \"parseValue\" and \"parseLiteral\" functions.`,\n );\n }\n\n if (config.coerceInputLiteral) {\n devAssert(\n typeof config.coerceInputValue === 'function' &&\n typeof config.coerceInputLiteral === 'function',\n `${this.name} must provide both \"coerceInputValue\" and \"coerceInputLiteral\" functions.`,\n );\n }\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLScalarType';\n }\n\n toConfig(): GraphQLScalarTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n specifiedByURL: this.specifiedByURL,\n serialize: this.serialize,\n parseValue: this.parseValue,\n parseLiteral: this.parseLiteral,\n coerceOutputValue: this.coerceOutputValue,\n coerceInputValue: this.coerceInputValue,\n coerceInputLiteral: this.coerceInputLiteral,\n valueToLiteral: this.valueToLiteral,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/* @deprecated in favor of GraphQLScalarOutputValueCoercer, will be removed in v18 */\nexport type GraphQLScalarSerializer = (\n outputValue: unknown,\n) => TExternal;\n\nexport type GraphQLScalarOutputValueCoercer = (\n outputValue: unknown,\n) => TExternal;\n\n/* @deprecated in favor of GraphQLScalarInputValueCoercer, will be removed in v18 */\nexport type GraphQLScalarValueParser = (\n inputValue: unknown,\n) => TInternal;\n\nexport type GraphQLScalarInputValueCoercer = (\n inputValue: unknown,\n) => TInternal;\n\n/* @deprecated in favor of GraphQLScalarInputLiteralCoercer, will be removed in v18 */\nexport type GraphQLScalarLiteralParser = (\n valueNode: ValueNode,\n variables: Maybe>,\n) => Maybe;\n\nexport type GraphQLScalarInputLiteralCoercer = (\n valueNode: ConstValueNode,\n) => Maybe;\n\nexport type GraphQLScalarValueToLiteral = (\n inputValue: unknown,\n) => ConstValueNode | undefined;\n\nexport interface GraphQLScalarTypeConfig {\n name: string;\n description?: Maybe;\n specifiedByURL?: Maybe;\n /** Serializes an internal value to include in a response. */\n /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */\n serialize?: GraphQLScalarSerializer | undefined;\n /** Parses an externally provided value to use as an input. */\n /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */\n parseValue?: GraphQLScalarValueParser | undefined;\n /** Parses an externally provided literal value to use as an input. */\n /** @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */\n parseLiteral?: GraphQLScalarLiteralParser | undefined;\n /** Coerces an internal value to include in a response. */\n coerceOutputValue?: GraphQLScalarOutputValueCoercer | undefined;\n /** Coerces an externally provided value to use as an input. */\n coerceInputValue?: GraphQLScalarInputValueCoercer | undefined;\n /** Coerces an externally provided const literal value to use as an input. */\n coerceInputLiteral?: GraphQLScalarInputLiteralCoercer | undefined;\n /** Translates an externally provided value to a literal (AST). */\n valueToLiteral?: GraphQLScalarValueToLiteral | undefined;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLScalarTypeNormalizedConfig\n extends GraphQLScalarTypeConfig {\n serialize: GraphQLScalarSerializer;\n parseValue: GraphQLScalarValueParser;\n parseLiteral: GraphQLScalarLiteralParser;\n coerceOutputValue: GraphQLScalarOutputValueCoercer;\n coerceInputValue: GraphQLScalarInputValueCoercer;\n coerceInputLiteral: GraphQLScalarInputLiteralCoercer | undefined;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n *\n * We've provided these template arguments because this is an open type and\n * you may find them useful.\n */\nexport interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Object Type Definition\n *\n * Almost all of the GraphQL types you define will be object types. Object types\n * have a name, but most importantly describe their fields.\n *\n * Example:\n *\n * ```ts\n * const AddressType = new GraphQLObjectType({\n * name: 'Address',\n * fields: {\n * street: { type: GraphQLString },\n * number: { type: GraphQLInt },\n * formatted: {\n * type: GraphQLString,\n * resolve(obj) {\n * return obj.number + ' ' + obj.street\n * }\n * }\n * }\n * });\n * ```\n *\n * When two types need to refer to each other, or a type needs to refer to\n * itself in a field, you can use a function expression (aka a closure or a\n * thunk) to supply the fields lazily.\n *\n * Example:\n *\n * ```ts\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * name: { type: GraphQLString },\n * bestFriend: { type: PersonType },\n * })\n * });\n * ```\n */\nexport class GraphQLObjectType\n implements GraphQLSchemaElement\n{\n name: string;\n description: Maybe;\n isTypeOf: Maybe>;\n extensions: Readonly>;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _fields: ThunkObjMap>;\n private _interfaces: ThunkReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.isTypeOf = config.isTypeOf;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n this._fields = (defineFieldMap).bind(\n undefined,\n this,\n config.fields,\n );\n this._interfaces = defineInterfaces.bind(undefined, config.interfaces);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLObjectType';\n }\n\n getFields(): GraphQLFieldMap {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n return this._fields;\n }\n\n getInterfaces(): ReadonlyArray {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n return this._interfaces;\n }\n\n toConfig(): GraphQLObjectTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: mapValue(this.getFields(), (field) => field.toConfig()),\n isTypeOf: this.isTypeOf,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction defineInterfaces(\n interfaces: Maybe>,\n): ReadonlyArray {\n return resolveReadonlyArrayThunk(interfaces ?? []);\n}\n\nfunction defineFieldMap(\n parentType:\n | GraphQLObjectType\n | GraphQLInterfaceType,\n fields: ThunkObjMap>,\n): GraphQLFieldMap {\n const fieldMap = resolveObjMapThunk(fields);\n\n return mapValue(\n fieldMap,\n (fieldConfig, fieldName) =>\n new GraphQLField(parentType, fieldName, fieldConfig),\n );\n}\n\nexport interface GraphQLObjectTypeConfig {\n name: string;\n description?: Maybe;\n interfaces?: ThunkReadonlyArray | undefined;\n fields: ThunkObjMap>;\n isTypeOf?: Maybe>;\n extensions?: Maybe>>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLObjectTypeNormalizedConfig\n extends GraphQLObjectTypeConfig {\n interfaces: ReadonlyArray;\n fields: GraphQLFieldNormalizedConfigMap;\n extensions: Readonly>;\n extensionASTNodes: ReadonlyArray;\n}\n\nexport type GraphQLTypeResolver = (\n value: TSource,\n context: TContext,\n info: GraphQLResolveInfo,\n abstractType: GraphQLAbstractType,\n) => PromiseOrValue;\n\nexport type GraphQLIsTypeOfFn = (\n source: TSource,\n context: TContext,\n info: GraphQLResolveInfo,\n) => PromiseOrValue;\n\nexport type GraphQLFieldResolver<\n TSource,\n TContext,\n TArgs = any,\n TResult = unknown,\n> = (\n source: TSource,\n args: TArgs,\n context: TContext,\n info: GraphQLResolveInfo,\n abortSignal: AbortSignal | undefined,\n) => TResult;\n\nexport interface GraphQLResolveInfo {\n readonly fieldName: string;\n readonly fieldNodes: ReadonlyArray;\n readonly returnType: GraphQLOutputType;\n readonly parentType: GraphQLObjectType;\n readonly path: Path;\n readonly schema: GraphQLSchema;\n readonly fragments: ObjMap;\n readonly rootValue: unknown;\n readonly operation: OperationDefinitionNode;\n readonly variableValues: VariableValues;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n *\n * We've provided these template arguments because this is an open type and\n * you may find them useful.\n */\nexport interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLFieldConfig {\n description?: Maybe;\n type: GraphQLOutputType;\n args?: GraphQLFieldConfigArgumentMap | undefined;\n resolve?: GraphQLFieldResolver | undefined;\n subscribe?: GraphQLFieldResolver | undefined;\n deprecationReason?: Maybe;\n extensions?: Maybe<\n Readonly>\n >;\n astNode?: Maybe;\n}\n\nexport interface GraphQLFieldNormalizedConfig\n extends GraphQLFieldConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n extensions: Readonly>;\n}\n\nexport type GraphQLFieldConfigArgumentMap = ObjMap;\n\nexport type GraphQLFieldNormalizedConfigArgumentMap =\n ObjMap;\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLArgumentExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLArgumentConfig {\n description?: Maybe;\n type: GraphQLInputType;\n /** @deprecated use default instead, defaultValue will be removed in v18 **/\n defaultValue?: unknown;\n default?: GraphQLDefaultInput | undefined;\n deprecationReason?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport interface GraphQLArgumentNormalizedConfig extends GraphQLArgumentConfig {\n default: GraphQLDefaultInput | undefined;\n extensions: Readonly;\n}\n\nexport type GraphQLFieldConfigMap = ObjMap<\n GraphQLFieldConfig\n>;\n\nexport type GraphQLFieldNormalizedConfigMap = ObjMap<\n GraphQLFieldNormalizedConfig\n>;\n\nexport class GraphQLField\n implements GraphQLSchemaElement\n{\n parentType:\n | GraphQLObjectType\n | GraphQLInterfaceType\n | undefined;\n name: string;\n description: Maybe;\n type: GraphQLOutputType;\n args: ReadonlyArray;\n resolve?: GraphQLFieldResolver | undefined;\n subscribe?: GraphQLFieldResolver | undefined;\n deprecationReason: Maybe;\n extensions: Readonly>;\n astNode: Maybe;\n\n constructor(\n parentType:\n | GraphQLObjectType\n | GraphQLInterfaceType\n | undefined,\n name: string,\n config: GraphQLFieldConfig,\n ) {\n this.parentType = parentType;\n this.name = assertName(name);\n this.description = config.description;\n this.type = config.type;\n\n const argsConfig = config.args;\n this.args = argsConfig\n ? Object.entries(argsConfig).map(\n ([argName, argConfig]) =>\n new GraphQLArgument(this, argName, argConfig),\n )\n : [];\n\n this.resolve = config.resolve;\n this.subscribe = config.subscribe;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLField';\n }\n\n toConfig(): GraphQLFieldNormalizedConfig {\n return {\n description: this.description,\n type: this.type,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n resolve: this.resolve,\n subscribe: this.subscribe,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parentType ?? ''}.${this.name}`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport class GraphQLArgument implements GraphQLSchemaElement {\n parent: GraphQLField | GraphQLDirective;\n name: string;\n description: Maybe;\n type: GraphQLInputType;\n defaultValue: unknown;\n default: GraphQLDefaultInput | undefined;\n deprecationReason: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(\n parent: GraphQLField | GraphQLDirective,\n name: string,\n config: GraphQLArgumentConfig,\n ) {\n this.parent = parent;\n this.name = assertName(name);\n this.description = config.description;\n this.type = config.type;\n this.defaultValue = config.defaultValue;\n this.default = config.default;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLArgument';\n }\n\n toConfig(): GraphQLArgumentNormalizedConfig {\n return {\n description: this.description,\n type: this.type,\n defaultValue: this.defaultValue,\n default: this.default,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parent}(${this.name}:)`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport function isRequiredArgument(\n arg: GraphQLArgument | GraphQLVariableSignature,\n): boolean {\n return (\n isNonNullType(arg.type) &&\n arg.default === undefined &&\n arg.defaultValue === undefined\n );\n}\n\nexport type GraphQLFieldMap = ObjMap<\n GraphQLField\n>;\n\nexport type GraphQLDefaultInput =\n | { value: unknown; literal?: never }\n | { literal: ConstValueNode; value?: never };\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLInterfaceTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Interface Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Interface type\n * is used to describe what types are possible, what fields are in common across\n * all types, as well as a function to determine which type is actually used\n * when the field is resolved.\n *\n * Example:\n *\n * ```ts\n * const EntityType = new GraphQLInterfaceType({\n * name: 'Entity',\n * fields: {\n * name: { type: GraphQLString }\n * }\n * });\n * ```\n */\nexport class GraphQLInterfaceType\n implements GraphQLSchemaElement\n{\n name: string;\n description: Maybe;\n resolveType: Maybe>;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _fields: ThunkObjMap>;\n private _interfaces: ThunkReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n this._fields = (defineFieldMap).bind(\n undefined,\n this,\n config.fields,\n );\n this._interfaces = defineInterfaces.bind(undefined, config.interfaces);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInterfaceType';\n }\n\n getFields(): GraphQLFieldMap {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n return this._fields;\n }\n\n getInterfaces(): ReadonlyArray {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n return this._interfaces;\n }\n\n toConfig(): GraphQLInterfaceTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: mapValue(this.getFields(), (field) => field.toConfig()),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport interface GraphQLInterfaceTypeConfig {\n name: string;\n description?: Maybe;\n interfaces?: ThunkReadonlyArray | undefined;\n fields: ThunkObjMap>;\n /**\n * Optionally provide a custom type resolver function. If one is not provided,\n * the default implementation will call `isTypeOf` on each implementing\n * Object type.\n */\n resolveType?: Maybe>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLInterfaceTypeNormalizedConfig\n extends GraphQLInterfaceTypeConfig {\n interfaces: ReadonlyArray;\n fields: GraphQLFieldNormalizedConfigMap;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLUnionTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Union Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Union type\n * is used to describe what types are possible as well as providing a function\n * to determine which type is actually used when the field is resolved.\n *\n * Example:\n *\n * ```ts\n * const PetType = new GraphQLUnionType({\n * name: 'Pet',\n * types: [ DogType, CatType ],\n * resolveType(value) {\n * if (value instanceof Dog) {\n * return DogType;\n * }\n * if (value instanceof Cat) {\n * return CatType;\n * }\n * }\n * });\n * ```\n */\nexport class GraphQLUnionType implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n resolveType: Maybe>;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _types: ThunkReadonlyArray;\n\n constructor(config: Readonly>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._types = defineTypes.bind(undefined, config.types);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLUnionType';\n }\n\n getTypes(): ReadonlyArray {\n if (typeof this._types === 'function') {\n this._types = this._types();\n }\n return this._types;\n }\n\n toConfig(): GraphQLUnionTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n types: this.getTypes(),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction defineTypes(\n types: ThunkReadonlyArray,\n): ReadonlyArray {\n return resolveReadonlyArrayThunk(types);\n}\n\nexport interface GraphQLUnionTypeConfig {\n name: string;\n description?: Maybe;\n types: ThunkReadonlyArray;\n /**\n * Optionally provide a custom type resolver function. If one is not provided,\n * the default implementation will call `isTypeOf` on each implementing\n * Object type.\n */\n resolveType?: Maybe>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLUnionTypeNormalizedConfig\n extends GraphQLUnionTypeConfig {\n types: ReadonlyArray;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLEnumTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Enum Type Definition\n *\n * Some leaf values of requests and input values are Enums. GraphQL coerces\n * Enum values as strings, however internally Enums can be represented by any\n * kind of type, often integers.\n *\n * Example:\n *\n * ```ts\n * const RGBType = new GraphQLEnumType({\n * name: 'RGB',\n * values: {\n * RED: { value: 0 },\n * GREEN: { value: 1 },\n * BLUE: { value: 2 }\n * }\n * });\n * ```\n *\n * Note: If a value is not provided in a definition, the name of the enum value\n * will be used as its internal value.\n */\nexport class GraphQLEnumType /* */ implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n private _values:\n | ReadonlyArray */>\n | (() => GraphQLEnumValueConfigMap);\n\n private _valueLookup: ReadonlyMap | null;\n private _nameLookup: ObjMap | null;\n\n constructor(config: Readonly */>) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._values =\n typeof config.values === 'function'\n ? config.values\n : Object.entries(config.values).map(\n ([valueName, valueConfig]) =>\n new GraphQLEnumValue(this, valueName, valueConfig),\n );\n this._valueLookup = null;\n this._nameLookup = null;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLEnumType';\n }\n\n getValues(): ReadonlyArray */> {\n if (typeof this._values === 'function') {\n this._values = Object.entries(this._values()).map(\n ([valueName, valueConfig]) =>\n new GraphQLEnumValue(this, valueName, valueConfig),\n );\n }\n return this._values;\n }\n\n getValue(name: string): Maybe {\n if (this._nameLookup === null) {\n this._nameLookup = keyMap(this.getValues(), (value) => value.name);\n }\n return this._nameLookup[name];\n }\n\n /** @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18 */\n serialize(outputValue: unknown /* T */): Maybe {\n return this.coerceOutputValue(outputValue);\n }\n\n coerceOutputValue(outputValue: unknown /* T */): Maybe {\n if (this._valueLookup === null) {\n this._valueLookup = new Map(\n this.getValues().map((enumValue) => [enumValue.value, enumValue]),\n );\n }\n const enumValue = this._valueLookup.get(outputValue);\n if (enumValue === undefined) {\n throw new GraphQLError(\n `Enum \"${this.name}\" cannot represent value: ${inspect(outputValue)}`,\n );\n }\n return enumValue.name;\n }\n\n /** @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18 */\n parseValue(\n inputValue: unknown,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n return this.coerceInputValue(inputValue, hideSuggestions);\n }\n\n coerceInputValue(\n inputValue: unknown,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n if (typeof inputValue !== 'string') {\n const valueStr = inspect(inputValue);\n throw new GraphQLError(\n `Enum \"${this.name}\" cannot represent non-string value: ${valueStr}.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)),\n );\n }\n\n const enumValue = this.getValue(inputValue);\n if (enumValue == null) {\n throw new GraphQLError(\n `Value \"${inputValue}\" does not exist in \"${this.name}\" enum.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, inputValue)),\n );\n }\n return enumValue.value;\n }\n\n /** @deprecated use `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18 */\n parseLiteral(\n valueNode: ValueNode,\n _variables: Maybe>,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n // Note: variables will be resolved to a value before calling this function.\n return this.coerceInputLiteral(\n valueNode as ConstValueNode,\n hideSuggestions,\n );\n }\n\n coerceInputLiteral(\n valueNode: ConstValueNode,\n hideSuggestions?: Maybe,\n ): Maybe /* T */ {\n if (valueNode.kind !== Kind.ENUM) {\n const valueStr = print(valueNode);\n throw new GraphQLError(\n `Enum \"${this.name}\" cannot represent non-enum value: ${valueStr}.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)),\n { nodes: valueNode },\n );\n }\n\n const enumValue = this.getValue(valueNode.value);\n if (enumValue == null) {\n const valueStr = print(valueNode);\n throw new GraphQLError(\n `Value \"${valueStr}\" does not exist in \"${this.name}\" enum.` +\n (hideSuggestions ? '' : didYouMeanEnumValue(this, valueStr)),\n { nodes: valueNode },\n );\n }\n return enumValue.value;\n }\n\n valueToLiteral(value: unknown): ConstValueNode | undefined {\n if (typeof value === 'string' && this.getValue(value)) {\n return { kind: Kind.ENUM, value };\n }\n }\n\n toConfig(): GraphQLEnumTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n values: keyValMap(\n this.getValues(),\n (value) => value.name,\n (value) => value.toConfig(),\n ),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction didYouMeanEnumValue(\n enumType: GraphQLEnumType,\n unknownValueStr: string,\n): string {\n const allNames = enumType.getValues().map((value) => value.name);\n const suggestedValues = suggestionList(unknownValueStr, allNames);\n\n return didYouMean('the enum value', suggestedValues);\n}\n\nexport interface GraphQLEnumTypeConfig {\n name: string;\n description?: Maybe;\n values: ThunkObjMap */>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\nexport interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig {\n values: GraphQLEnumValueNormalizedConfigMap;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\nexport type GraphQLEnumValueConfigMap /* */ =\n ObjMap */>;\n\nexport type GraphQLEnumValueNormalizedConfigMap /* */ =\n ObjMap */>;\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLEnumValueExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLEnumValueConfig {\n description?: Maybe;\n value?: any /* T */;\n deprecationReason?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport interface GraphQLEnumValueNormalizedConfig\n extends GraphQLEnumValueConfig {\n extensions: Readonly;\n}\n\nexport class GraphQLEnumValue implements GraphQLSchemaElement {\n parentEnum: GraphQLEnumType;\n name: string;\n description: Maybe;\n value: any /* T */;\n deprecationReason: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(\n parentEnum: GraphQLEnumType,\n name: string,\n config: GraphQLEnumValueConfig,\n ) {\n this.parentEnum = parentEnum;\n this.name = assertEnumValueName(name);\n this.description = config.description;\n this.value = config.value !== undefined ? config.value : name;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLEnumValue';\n }\n\n toConfig(): GraphQLEnumValueNormalizedConfig {\n return {\n description: this.description,\n value: this.value,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parentEnum.name}.${this.name}`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLInputObjectTypeExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Input Object Type Definition\n *\n * An input object defines a structured collection of fields which may be\n * supplied to a field argument.\n *\n * Using `NonNull` will ensure that a value must be provided by the query\n *\n * Example:\n *\n * ```ts\n * const GeoPoint = new GraphQLInputObjectType({\n * name: 'GeoPoint',\n * fields: {\n * lat: { type: new GraphQLNonNull(GraphQLFloat) },\n * lon: { type: new GraphQLNonNull(GraphQLFloat) },\n * alt: { type: GraphQLFloat, defaultValue: 0 },\n * }\n * });\n * ```\n */\nexport class GraphQLInputObjectType implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n isOneOf: boolean;\n\n private _fields: ThunkObjMap;\n\n constructor(config: Readonly) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n this.isOneOf = config.isOneOf ?? false;\n\n this._fields = defineInputFieldMap.bind(undefined, this, config.fields);\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInputObjectType';\n }\n\n getFields(): GraphQLInputFieldMap {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n return this._fields;\n }\n\n toConfig(): GraphQLInputObjectTypeNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n fields: mapValue(this.getFields(), (field) => field.toConfig()),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n isOneOf: this.isOneOf,\n };\n }\n\n toString(): string {\n return this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nfunction defineInputFieldMap(\n parentType: GraphQLInputObjectType,\n fields: ThunkObjMap,\n): GraphQLInputFieldMap {\n const fieldMap = resolveObjMapThunk(fields);\n return mapValue(\n fieldMap,\n (fieldConfig, fieldName) =>\n new GraphQLInputField(parentType, fieldName, fieldConfig),\n );\n}\n\nexport interface GraphQLInputObjectTypeConfig {\n name: string;\n description?: Maybe;\n fields: ThunkObjMap;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n isOneOf?: boolean;\n}\n\nexport interface GraphQLInputObjectTypeNormalizedConfig\n extends GraphQLInputObjectTypeConfig {\n fields: GraphQLInputFieldNormalizedConfigMap;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLInputFieldExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\nexport interface GraphQLInputFieldConfig {\n description?: Maybe;\n type: GraphQLInputType;\n /** @deprecated use default instead, defaultValue will be removed in v18 **/\n defaultValue?: unknown;\n default?: GraphQLDefaultInput | undefined;\n deprecationReason?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport type GraphQLInputFieldConfigMap = ObjMap;\n\nexport interface GraphQLInputFieldNormalizedConfig\n extends GraphQLInputFieldConfig {\n default: GraphQLDefaultInput | undefined;\n extensions: Readonly;\n}\n\nexport type GraphQLInputFieldNormalizedConfigMap =\n ObjMap;\n\nexport class GraphQLInputField implements GraphQLSchemaElement {\n parentType: GraphQLInputObjectType;\n name: string;\n description: Maybe;\n type: GraphQLInputType;\n defaultValue: unknown;\n default: GraphQLDefaultInput | undefined;\n deprecationReason: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(\n parentType: GraphQLInputObjectType,\n name: string,\n config: GraphQLInputFieldConfig,\n ) {\n devAssert(\n !('resolve' in config),\n `${parentType}.${name} field has a resolve property, but Input Types cannot define resolvers.`,\n );\n\n this.parentType = parentType;\n this.name = assertName(name);\n this.description = config.description;\n this.type = config.type;\n this.defaultValue = config.defaultValue;\n this.default = config.default;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInputField';\n }\n\n toConfig(): GraphQLInputFieldNormalizedConfig {\n return {\n description: this.description,\n type: this.type,\n defaultValue: this.defaultValue,\n default: this.default,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return `${this.parentType}.${this.name}`;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport function isRequiredInputField(field: GraphQLInputField): boolean {\n return (\n isNonNullType(field.type) &&\n field.defaultValue === undefined &&\n field.default === undefined\n );\n}\n\nexport type GraphQLInputFieldMap = ObjMap;\n"]} \ No newline at end of file diff --git a/type/directives.d.ts b/type/directives.d.ts new file mode 100644 index 0000000000..f573a91c1f --- /dev/null +++ b/type/directives.d.ts @@ -0,0 +1,96 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { DirectiveDefinitionNode } from '../language/ast.js'; +import { DirectiveLocation } from '../language/directiveLocation.js'; +import type { GraphQLArgumentConfig, GraphQLFieldNormalizedConfigArgumentMap, GraphQLSchemaElement } from './definition.js'; +import { GraphQLArgument } from './definition.js'; +/** + * Test if the given value is a GraphQL directive. + */ +export declare function isDirective(directive: unknown): directive is GraphQLDirective; +export declare function assertDirective(directive: unknown): GraphQLDirective; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLDirectiveExtensions { + [attributeName: string | symbol]: unknown; +} +/** + * Directives are used by the GraphQL runtime as a way of modifying execution + * behavior. Type system creators will usually not create these directly. + */ +export declare class GraphQLDirective implements GraphQLSchemaElement { + name: string; + description: Maybe; + locations: ReadonlyArray; + args: ReadonlyArray; + isRepeatable: boolean; + extensions: Readonly; + astNode: Maybe; + constructor(config: Readonly); + get [Symbol.toStringTag](): string; + toConfig(): GraphQLDirectiveNormalizedConfig; + toString(): string; + toJSON(): string; +} +export interface GraphQLDirectiveConfig { + name: string; + description?: Maybe; + locations: ReadonlyArray; + args?: Maybe>; + isRepeatable?: Maybe; + extensions?: Maybe>; + astNode?: Maybe; +} +export interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig { + args: GraphQLFieldNormalizedConfigArgumentMap; + isRepeatable: boolean; + extensions: Readonly; +} +/** + * Used to conditionally include fields or fragments. + */ +export declare const GraphQLIncludeDirective: GraphQLDirective; +/** + * Used to conditionally skip (exclude) fields or fragments. + */ +export declare const GraphQLSkipDirective: GraphQLDirective; +/** + * Used to conditionally defer fragments. + */ +export declare const GraphQLDeferDirective: GraphQLDirective; +/** + * Used to conditionally stream list fields. + */ +export declare const GraphQLStreamDirective: GraphQLDirective; +/** + * Constant string used for default reason for a deprecation. + */ +export declare const DEFAULT_DEPRECATION_REASON = "No longer supported"; +/** + * Used to declare element of a GraphQL schema as deprecated. + */ +export declare const GraphQLDeprecatedDirective: GraphQLDirective; +/** + * Used to provide a URL for specifying the behavior of custom scalar definitions. + */ +export declare const GraphQLSpecifiedByDirective: GraphQLDirective; +/** + * Used to indicate an Input Object is a OneOf Input Object. + */ +export declare const GraphQLOneOfDirective: GraphQLDirective; +/** + * Disables error propagation (experimental). + */ +export declare const GraphQLDisableErrorPropagationDirective: GraphQLDirective; +/** + * The full list of specified directives. + */ +export declare const specifiedDirectives: ReadonlyArray; +export declare function isSpecifiedDirective(directive: GraphQLDirective): boolean; diff --git a/type/directives.js b/type/directives.js new file mode 100644 index 0000000000..d453503219 --- /dev/null +++ b/type/directives.js @@ -0,0 +1,222 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.specifiedDirectives = exports.GraphQLDisableErrorPropagationDirective = exports.GraphQLOneOfDirective = exports.GraphQLSpecifiedByDirective = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLStreamDirective = exports.GraphQLDeferDirective = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = void 0; +exports.isDirective = isDirective; +exports.assertDirective = assertDirective; +exports.isSpecifiedDirective = isSpecifiedDirective; +const devAssert_js_1 = require("../jsutils/devAssert.js"); +const inspect_js_1 = require("../jsutils/inspect.js"); +const instanceOf_js_1 = require("../jsutils/instanceOf.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const keyValMap_js_1 = require("../jsutils/keyValMap.js"); +const toObjMap_js_1 = require("../jsutils/toObjMap.js"); +const directiveLocation_js_1 = require("../language/directiveLocation.js"); +const assertName_js_1 = require("./assertName.js"); +const definition_js_1 = require("./definition.js"); +const scalars_js_1 = require("./scalars.js"); +/** + * Test if the given value is a GraphQL directive. + */ +function isDirective(directive) { + return (0, instanceOf_js_1.instanceOf)(directive, GraphQLDirective); +} +function assertDirective(directive) { + if (!isDirective(directive)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(directive)} to be a GraphQL directive.`); + } + return directive; +} +/** + * Directives are used by the GraphQL runtime as a way of modifying execution + * behavior. Type system creators will usually not create these directly. + */ +class GraphQLDirective { + constructor(config) { + this.name = (0, assertName_js_1.assertName)(config.name); + this.description = config.description; + this.locations = config.locations; + this.isRepeatable = config.isRepeatable ?? false; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + (Array.isArray(config.locations)) || (0, devAssert_js_1.devAssert)(false, `@${this.name} locations must be an Array.`); + const args = config.args ?? {}; + ((0, isObjectLike_js_1.isObjectLike)(args) && !Array.isArray(args)) || (0, devAssert_js_1.devAssert)(false, `@${this.name} args must be an object with argument names as keys.`); + this.args = Object.entries(args).map(([argName, argConfig]) => new definition_js_1.GraphQLArgument(this, argName, argConfig)); + } + get [Symbol.toStringTag]() { + return 'GraphQLDirective'; + } + toConfig() { + return { + name: this.name, + description: this.description, + locations: this.locations, + args: (0, keyValMap_js_1.keyValMap)(this.args, (arg) => arg.name, (arg) => arg.toConfig()), + isRepeatable: this.isRepeatable, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return '@' + this.name; + } + toJSON() { + return this.toString(); + } +} +exports.GraphQLDirective = GraphQLDirective; +/** + * Used to conditionally include fields or fragments. + */ +exports.GraphQLIncludeDirective = new GraphQLDirective({ + name: 'include', + description: 'Directs the executor to include this field or fragment only when the `if` argument is true.', + locations: [ + directiveLocation_js_1.DirectiveLocation.FIELD, + directiveLocation_js_1.DirectiveLocation.FRAGMENT_SPREAD, + directiveLocation_js_1.DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + description: 'Included when true.', + }, + }, +}); +/** + * Used to conditionally skip (exclude) fields or fragments. + */ +exports.GraphQLSkipDirective = new GraphQLDirective({ + name: 'skip', + description: 'Directs the executor to skip this field or fragment when the `if` argument is true.', + locations: [ + directiveLocation_js_1.DirectiveLocation.FIELD, + directiveLocation_js_1.DirectiveLocation.FRAGMENT_SPREAD, + directiveLocation_js_1.DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + description: 'Skipped when true.', + }, + }, +}); +/** + * Used to conditionally defer fragments. + */ +exports.GraphQLDeferDirective = new GraphQLDirective({ + name: 'defer', + description: 'Directs the executor to defer this fragment when the `if` argument is true or undefined.', + locations: [ + directiveLocation_js_1.DirectiveLocation.FRAGMENT_SPREAD, + directiveLocation_js_1.DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + description: 'Deferred when true or undefined.', + default: { value: true }, + }, + label: { + type: scalars_js_1.GraphQLString, + description: 'Unique name', + }, + }, +}); +/** + * Used to conditionally stream list fields. + */ +exports.GraphQLStreamDirective = new GraphQLDirective({ + name: 'stream', + description: 'Directs the executor to stream plural fields when the `if` argument is true or undefined.', + locations: [directiveLocation_js_1.DirectiveLocation.FIELD], + args: { + initialCount: { + default: { value: 0 }, + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLInt), + description: 'Number of items to return immediately', + }, + if: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + description: 'Stream when true or undefined.', + default: { value: true }, + }, + label: { + type: scalars_js_1.GraphQLString, + description: 'Unique name', + }, + }, +}); +/** + * Constant string used for default reason for a deprecation. + */ +exports.DEFAULT_DEPRECATION_REASON = 'No longer supported'; +/** + * Used to declare element of a GraphQL schema as deprecated. + */ +exports.GraphQLDeprecatedDirective = new GraphQLDirective({ + name: 'deprecated', + description: 'Marks an element of a GraphQL schema as no longer supported.', + locations: [ + directiveLocation_js_1.DirectiveLocation.FIELD_DEFINITION, + directiveLocation_js_1.DirectiveLocation.ARGUMENT_DEFINITION, + directiveLocation_js_1.DirectiveLocation.INPUT_FIELD_DEFINITION, + directiveLocation_js_1.DirectiveLocation.ENUM_VALUE, + ], + args: { + reason: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString), + description: 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).', + default: { value: exports.DEFAULT_DEPRECATION_REASON }, + }, + }, +}); +/** + * Used to provide a URL for specifying the behavior of custom scalar definitions. + */ +exports.GraphQLSpecifiedByDirective = new GraphQLDirective({ + name: 'specifiedBy', + description: 'Exposes a URL that specifies the behavior of this scalar.', + locations: [directiveLocation_js_1.DirectiveLocation.SCALAR], + args: { + url: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString), + description: 'The URL that specifies the behavior of this scalar.', + }, + }, +}); +/** + * Used to indicate an Input Object is a OneOf Input Object. + */ +exports.GraphQLOneOfDirective = new GraphQLDirective({ + name: 'oneOf', + description: 'Indicates exactly one field must be supplied and this field must not be `null`.', + locations: [directiveLocation_js_1.DirectiveLocation.INPUT_OBJECT], + args: {}, +}); +/** + * Disables error propagation (experimental). + */ +exports.GraphQLDisableErrorPropagationDirective = new GraphQLDirective({ + name: 'experimental_disableErrorPropagation', + description: 'Disables error propagation.', + locations: [ + directiveLocation_js_1.DirectiveLocation.QUERY, + directiveLocation_js_1.DirectiveLocation.MUTATION, + directiveLocation_js_1.DirectiveLocation.SUBSCRIPTION, + ], +}); +/** + * The full list of specified directives. + */ +exports.specifiedDirectives = Object.freeze([ + exports.GraphQLIncludeDirective, + exports.GraphQLSkipDirective, + exports.GraphQLDeprecatedDirective, + exports.GraphQLSpecifiedByDirective, + exports.GraphQLOneOfDirective, +]); +function isSpecifiedDirective(directive) { + return exports.specifiedDirectives.some(({ name }) => name === directive.name); +} +//# sourceMappingURL=directives.js.map \ No newline at end of file diff --git a/type/directives.js.map b/type/directives.js.map new file mode 100644 index 0000000000..9085ef7e54 --- /dev/null +++ b/type/directives.js.map @@ -0,0 +1 @@ +{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/type/directives.ts"],"names":[],"mapp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;AACU,QAAA,uCAAuC,GAAG,IAAI,gBAAgB,CAAC;IAC1E,IAAI,EAAE,sCAAsC;IAC5C,WAAW,EAAE,6BAA6B;IAC1C,SAAS,EAAE;QACT,wCAAiB,CAAC,KAAK;QACvB,wCAAiB,CAAC,QAAQ;QAC1B,wCAAiB,CAAC,YAAY;KAC/B;CACF,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,mBAAmB,GAC9B,MAAM,CAAC,MAAM,CAAC;IACZ,+BAAuB;IACvB,4BAAoB;IACpB,kCAA0B;IAC1B,mCAA2B;IAC3B,6BAAqB;CACtB,CAAC,CAAC;AAEL,SAAgB,oBAAoB,CAAC,SAA2B;IAC9D,OAAO,2BAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyValMap } from '../jsutils/keyValMap.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.js';\n\nimport type { DirectiveDefinitionNode } from '../language/ast.js';\nimport { DirectiveLocation } from '../language/directiveLocation.js';\n\nimport { assertName } from './assertName.js';\nimport type {\n GraphQLArgumentConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLSchemaElement,\n} from './definition.js';\nimport { GraphQLArgument, GraphQLNonNull } from './definition.js';\nimport { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.js';\n\n/**\n * Test if the given value is a GraphQL directive.\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, GraphQLDirective);\n}\n\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n locations: ReadonlyArray;\n args: ReadonlyArray;\n isRepeatable: boolean;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(config: Readonly) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n\n devAssert(\n Array.isArray(config.locations),\n `@${this.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${this.name} args must be an object with argument names as keys.`,\n );\n\n this.args = Object.entries(args).map(\n ([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig),\n );\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLDirective';\n }\n\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n isRepeatable: this.isRepeatable,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return '@' + this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport interface GraphQLDirectiveConfig {\n name: string;\n description?: Maybe;\n locations: ReadonlyArray;\n args?: Maybe>;\n isRepeatable?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport interface GraphQLDirectiveNormalizedConfig\n extends GraphQLDirectiveConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Readonly;\n}\n\n/**\n * Used to conditionally include fields or fragments.\n */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: 'include',\n description:\n 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.',\n },\n },\n});\n\n/**\n * Used to conditionally skip (exclude) fields or fragments.\n */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: 'skip',\n description:\n 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.',\n },\n },\n});\n\n/**\n * Used to conditionally defer fragments.\n */\nexport const GraphQLDeferDirective = new GraphQLDirective({\n name: 'defer',\n description:\n 'Directs the executor to defer this fragment when the `if` argument is true or undefined.',\n locations: [\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Deferred when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Used to conditionally stream list fields.\n */\nexport const GraphQLStreamDirective = new GraphQLDirective({\n name: 'stream',\n description:\n 'Directs the executor to stream plural fields when the `if` argument is true or undefined.',\n locations: [DirectiveLocation.FIELD],\n args: {\n initialCount: {\n default: { value: 0 },\n type: new GraphQLNonNull(GraphQLInt),\n description: 'Number of items to return immediately',\n },\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Stream when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Constant string used for default reason for a deprecation.\n */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n ],\n args: {\n reason: {\n type: new GraphQLNonNull(GraphQLString),\n description:\n 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n default: { value: DEFAULT_DEPRECATION_REASON },\n },\n },\n });\n\n/**\n * Used to provide a URL for specifying the behavior of custom scalar definitions.\n */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behavior of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behavior of this scalar.',\n },\n },\n });\n\n/**\n * Used to indicate an Input Object is a OneOf Input Object.\n */\nexport const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({\n name: 'oneOf',\n description:\n 'Indicates exactly one field must be supplied and this field must not be `null`.',\n locations: [DirectiveLocation.INPUT_OBJECT],\n args: {},\n});\n\n/**\n * Disables error propagation (experimental).\n */\nexport const GraphQLDisableErrorPropagationDirective = new GraphQLDirective({\n name: 'experimental_disableErrorPropagation',\n description: 'Disables error propagation.',\n locations: [\n DirectiveLocation.QUERY,\n DirectiveLocation.MUTATION,\n DirectiveLocation.SUBSCRIPTION,\n ],\n});\n\n/**\n * The full list of specified directives.\n */\nexport const specifiedDirectives: ReadonlyArray =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n ]);\n\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"]} \ No newline at end of file diff --git a/type/directives.mjs b/type/directives.mjs new file mode 100644 index 0000000000..c417d28285 --- /dev/null +++ b/type/directives.mjs @@ -0,0 +1,215 @@ +import { devAssert } from "../jsutils/devAssert.mjs"; +import { inspect } from "../jsutils/inspect.mjs"; +import { instanceOf } from "../jsutils/instanceOf.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { keyValMap } from "../jsutils/keyValMap.mjs"; +import { toObjMapWithSymbols } from "../jsutils/toObjMap.mjs"; +import { DirectiveLocation } from "../language/directiveLocation.mjs"; +import { assertName } from "./assertName.mjs"; +import { GraphQLArgument, GraphQLNonNull } from "./definition.mjs"; +import { GraphQLBoolean, GraphQLInt, GraphQLString } from "./scalars.mjs"; +/** + * Test if the given value is a GraphQL directive. + */ +export function isDirective(directive) { + return instanceOf(directive, GraphQLDirective); +} +export function assertDirective(directive) { + if (!isDirective(directive)) { + throw new Error(`Expected ${inspect(directive)} to be a GraphQL directive.`); + } + return directive; +} +/** + * Directives are used by the GraphQL runtime as a way of modifying execution + * behavior. Type system creators will usually not create these directly. + */ +export class GraphQLDirective { + constructor(config) { + this.name = assertName(config.name); + this.description = config.description; + this.locations = config.locations; + this.isRepeatable = config.isRepeatable ?? false; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + (Array.isArray(config.locations)) || devAssert(false, `@${this.name} locations must be an Array.`); + const args = config.args ?? {}; + (isObjectLike(args) && !Array.isArray(args)) || devAssert(false, `@${this.name} args must be an object with argument names as keys.`); + this.args = Object.entries(args).map(([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig)); + } + get [Symbol.toStringTag]() { + return 'GraphQLDirective'; + } + toConfig() { + return { + name: this.name, + description: this.description, + locations: this.locations, + args: keyValMap(this.args, (arg) => arg.name, (arg) => arg.toConfig()), + isRepeatable: this.isRepeatable, + extensions: this.extensions, + astNode: this.astNode, + }; + } + toString() { + return '@' + this.name; + } + toJSON() { + return this.toString(); + } +} +/** + * Used to conditionally include fields or fragments. + */ +export const GraphQLIncludeDirective = new GraphQLDirective({ + name: 'include', + description: 'Directs the executor to include this field or fragment only when the `if` argument is true.', + locations: [ + DirectiveLocation.FIELD, + DirectiveLocation.FRAGMENT_SPREAD, + DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new GraphQLNonNull(GraphQLBoolean), + description: 'Included when true.', + }, + }, +}); +/** + * Used to conditionally skip (exclude) fields or fragments. + */ +export const GraphQLSkipDirective = new GraphQLDirective({ + name: 'skip', + description: 'Directs the executor to skip this field or fragment when the `if` argument is true.', + locations: [ + DirectiveLocation.FIELD, + DirectiveLocation.FRAGMENT_SPREAD, + DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new GraphQLNonNull(GraphQLBoolean), + description: 'Skipped when true.', + }, + }, +}); +/** + * Used to conditionally defer fragments. + */ +export const GraphQLDeferDirective = new GraphQLDirective({ + name: 'defer', + description: 'Directs the executor to defer this fragment when the `if` argument is true or undefined.', + locations: [ + DirectiveLocation.FRAGMENT_SPREAD, + DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new GraphQLNonNull(GraphQLBoolean), + description: 'Deferred when true or undefined.', + default: { value: true }, + }, + label: { + type: GraphQLString, + description: 'Unique name', + }, + }, +}); +/** + * Used to conditionally stream list fields. + */ +export const GraphQLStreamDirective = new GraphQLDirective({ + name: 'stream', + description: 'Directs the executor to stream plural fields when the `if` argument is true or undefined.', + locations: [DirectiveLocation.FIELD], + args: { + initialCount: { + default: { value: 0 }, + type: new GraphQLNonNull(GraphQLInt), + description: 'Number of items to return immediately', + }, + if: { + type: new GraphQLNonNull(GraphQLBoolean), + description: 'Stream when true or undefined.', + default: { value: true }, + }, + label: { + type: GraphQLString, + description: 'Unique name', + }, + }, +}); +/** + * Constant string used for default reason for a deprecation. + */ +export const DEFAULT_DEPRECATION_REASON = 'No longer supported'; +/** + * Used to declare element of a GraphQL schema as deprecated. + */ +export const GraphQLDeprecatedDirective = new GraphQLDirective({ + name: 'deprecated', + description: 'Marks an element of a GraphQL schema as no longer supported.', + locations: [ + DirectiveLocation.FIELD_DEFINITION, + DirectiveLocation.ARGUMENT_DEFINITION, + DirectiveLocation.INPUT_FIELD_DEFINITION, + DirectiveLocation.ENUM_VALUE, + ], + args: { + reason: { + type: new GraphQLNonNull(GraphQLString), + description: 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).', + default: { value: DEFAULT_DEPRECATION_REASON }, + }, + }, +}); +/** + * Used to provide a URL for specifying the behavior of custom scalar definitions. + */ +export const GraphQLSpecifiedByDirective = new GraphQLDirective({ + name: 'specifiedBy', + description: 'Exposes a URL that specifies the behavior of this scalar.', + locations: [DirectiveLocation.SCALAR], + args: { + url: { + type: new GraphQLNonNull(GraphQLString), + description: 'The URL that specifies the behavior of this scalar.', + }, + }, +}); +/** + * Used to indicate an Input Object is a OneOf Input Object. + */ +export const GraphQLOneOfDirective = new GraphQLDirective({ + name: 'oneOf', + description: 'Indicates exactly one field must be supplied and this field must not be `null`.', + locations: [DirectiveLocation.INPUT_OBJECT], + args: {}, +}); +/** + * Disables error propagation (experimental). + */ +export const GraphQLDisableErrorPropagationDirective = new GraphQLDirective({ + name: 'experimental_disableErrorPropagation', + description: 'Disables error propagation.', + locations: [ + DirectiveLocation.QUERY, + DirectiveLocation.MUTATION, + DirectiveLocation.SUBSCRIPTION, + ], +}); +/** + * The full list of specified directives. + */ +export const specifiedDirectives = Object.freeze([ + GraphQLIncludeDirective, + GraphQLSkipDirective, + GraphQLDeprecatedDirective, + GraphQLSpecifiedByDirective, + GraphQLOneOfDirective, +]); +export function isSpecifiedDirective(directive) { + return specifiedDirectives.some(({ name }) => name === directive.name); +} +//# sourceMappingURL=directives.js.map \ No newline at end of file diff --git a/type/directives.mjs.map b/type/directives.mjs.map new file mode 100644 index 0000000000..71e5b747f5 --- /dev/null +++ b/type/directives.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/type/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,UAAU,EAAE,kCAAiC;AACtD,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,gCAA+B;AAG7D,OAAO,EAAE,iBAAiB,EAAE,0CAAyC;AAErE,OAAO,EAAE,UAAU,EAAE,yBAAwB;AAM7C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,yBAAwB;AAClE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,sBAAqB;AAEzE;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,SAAkB;IAC5C,OAAO,UAAU,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAkB;IAChD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,CAAC,SAAS,CAAC,6BAA6B,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAeD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAS3B,YAAY,MAAwC;QAClD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,MAA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/C;KACF;CACF,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACtC,IAAI,gBAAgB,CAAC;IACnB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,2DAA2D;IACxE,SAAS,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC;YACvC,WAAW,EAAE,qDAAqD;SACnE;KACF;CACF,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqB,IAAI,gBAAgB,CAAC;IAC1E,IAAI,EAAE,OAAO;IACb,WAAW,EACT,iFAAiF;IACnF,SAAS,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC;IAC3C,IAAI,EAAE,EAAE;CACT,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,IAAI,gBAAgB,CAAC;IAC1E,IAAI,EAAE,sCAAsC;IAC5C,WAAW,EAAE,6BAA6B;IAC1C,SAAS,EAAE;QACT,iBAAiB,CAAC,KAAK;QACvB,iBAAiB,CAAC,QAAQ;QAC1B,iBAAiB,CAAC,YAAY;KAC/B;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,MAAM,CAAC,MAAM,CAAC;IACZ,uBAAuB;IACvB,oBAAoB;IACpB,0BAA0B;IAC1B,2BAA2B;IAC3B,qBAAqB;CACtB,CAAC,CAAC;AAEL,MAAM,UAAU,oBAAoB,CAAC,SAA2B;IAC9D,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyValMap } from '../jsutils/keyValMap.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.js';\n\nimport type { DirectiveDefinitionNode } from '../language/ast.js';\nimport { DirectiveLocation } from '../language/directiveLocation.js';\n\nimport { assertName } from './assertName.js';\nimport type {\n GraphQLArgumentConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLSchemaElement,\n} from './definition.js';\nimport { GraphQLArgument, GraphQLNonNull } from './definition.js';\nimport { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.js';\n\n/**\n * Test if the given value is a GraphQL directive.\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, GraphQLDirective);\n}\n\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective implements GraphQLSchemaElement {\n name: string;\n description: Maybe;\n locations: ReadonlyArray;\n args: ReadonlyArray;\n isRepeatable: boolean;\n extensions: Readonly;\n astNode: Maybe;\n\n constructor(config: Readonly) {\n this.name = assertName(config.name);\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n\n devAssert(\n Array.isArray(config.locations),\n `@${this.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${this.name} args must be an object with argument names as keys.`,\n );\n\n this.args = Object.entries(args).map(\n ([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig),\n );\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLDirective';\n }\n\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n isRepeatable: this.isRepeatable,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return '@' + this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n\nexport interface GraphQLDirectiveConfig {\n name: string;\n description?: Maybe;\n locations: ReadonlyArray;\n args?: Maybe>;\n isRepeatable?: Maybe;\n extensions?: Maybe>;\n astNode?: Maybe;\n}\n\nexport interface GraphQLDirectiveNormalizedConfig\n extends GraphQLDirectiveConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Readonly;\n}\n\n/**\n * Used to conditionally include fields or fragments.\n */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: 'include',\n description:\n 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.',\n },\n },\n});\n\n/**\n * Used to conditionally skip (exclude) fields or fragments.\n */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: 'skip',\n description:\n 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.',\n },\n },\n});\n\n/**\n * Used to conditionally defer fragments.\n */\nexport const GraphQLDeferDirective = new GraphQLDirective({\n name: 'defer',\n description:\n 'Directs the executor to defer this fragment when the `if` argument is true or undefined.',\n locations: [\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Deferred when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Used to conditionally stream list fields.\n */\nexport const GraphQLStreamDirective = new GraphQLDirective({\n name: 'stream',\n description:\n 'Directs the executor to stream plural fields when the `if` argument is true or undefined.',\n locations: [DirectiveLocation.FIELD],\n args: {\n initialCount: {\n default: { value: 0 },\n type: new GraphQLNonNull(GraphQLInt),\n description: 'Number of items to return immediately',\n },\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Stream when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Constant string used for default reason for a deprecation.\n */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n ],\n args: {\n reason: {\n type: new GraphQLNonNull(GraphQLString),\n description:\n 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n default: { value: DEFAULT_DEPRECATION_REASON },\n },\n },\n });\n\n/**\n * Used to provide a URL for specifying the behavior of custom scalar definitions.\n */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behavior of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behavior of this scalar.',\n },\n },\n });\n\n/**\n * Used to indicate an Input Object is a OneOf Input Object.\n */\nexport const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({\n name: 'oneOf',\n description:\n 'Indicates exactly one field must be supplied and this field must not be `null`.',\n locations: [DirectiveLocation.INPUT_OBJECT],\n args: {},\n});\n\n/**\n * Disables error propagation (experimental).\n */\nexport const GraphQLDisableErrorPropagationDirective = new GraphQLDirective({\n name: 'experimental_disableErrorPropagation',\n description: 'Disables error propagation.',\n locations: [\n DirectiveLocation.QUERY,\n DirectiveLocation.MUTATION,\n DirectiveLocation.SUBSCRIPTION,\n ],\n});\n\n/**\n * The full list of specified directives.\n */\nexport const specifiedDirectives: ReadonlyArray =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n ]);\n\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"]} \ No newline at end of file diff --git a/type/index.d.ts b/type/index.d.ts new file mode 100644 index 0000000000..42b65c2dce --- /dev/null +++ b/type/index.d.ts @@ -0,0 +1,12 @@ +export type { Path as ResponsePath } from '../jsutils/Path.js'; +export { isSchema, assertSchema, GraphQLSchema, } from './schema.js'; +export type { GraphQLSchemaConfig, GraphQLSchemaExtensions } from './schema.js'; +export type { GraphQLField, GraphQLArgument, GraphQLEnumValue, GraphQLInputField, } from './definition.js'; +export { resolveObjMapThunk, resolveReadonlyArrayThunk, isType, isScalarType, isObjectType, isField, isArgument, isInterfaceType, isUnionType, isEnumType, isEnumValue, isInputObjectType, isListType, isNonNullType, isInputType, isInputField, isOutputType, isLeafType, isCompositeType, isAbstractType, isWrappingType, isNullableType, isNamedType, isRequiredArgument, isRequiredInputField, assertType, assertScalarType, assertObjectType, assertField, assertArgument, assertInterfaceType, assertUnionType, assertEnumType, assertEnumValue, assertInputObjectType, assertInputField, assertListType, assertNonNullType, assertInputType, assertOutputType, assertLeafType, assertCompositeType, assertAbstractType, assertWrappingType, assertNullableType, assertNamedType, getNullableType, getNamedType, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, GraphQLList, GraphQLNonNull, } from './definition.js'; +export type { GraphQLType, GraphQLInputType, GraphQLOutputType, GraphQLLeafType, GraphQLCompositeType, GraphQLAbstractType, GraphQLWrappingType, GraphQLNullableType, GraphQLNullableInputType, GraphQLNullableOutputType, GraphQLNamedType, GraphQLNamedInputType, GraphQLNamedOutputType, ThunkReadonlyArray, ThunkObjMap, GraphQLArgumentConfig, GraphQLArgumentExtensions, GraphQLEnumTypeConfig, GraphQLEnumTypeExtensions, GraphQLEnumValueConfig, GraphQLEnumValueConfigMap, GraphQLEnumValueExtensions, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLFieldExtensions, GraphQLFieldMap, GraphQLFieldResolver, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputFieldExtensions, GraphQLInputFieldMap, GraphQLInputObjectTypeConfig, GraphQLInputObjectTypeExtensions, GraphQLInterfaceTypeConfig, GraphQLInterfaceTypeExtensions, GraphQLIsTypeOfFn, GraphQLObjectTypeConfig, GraphQLObjectTypeExtensions, GraphQLResolveInfo, GraphQLScalarTypeConfig, GraphQLScalarTypeExtensions, GraphQLTypeResolver, GraphQLUnionTypeConfig, GraphQLUnionTypeExtensions, GraphQLScalarSerializer, GraphQLScalarValueParser, GraphQLScalarLiteralParser, GraphQLScalarOutputValueCoercer, GraphQLScalarInputValueCoercer, GraphQLScalarInputLiteralCoercer, GraphQLDefaultInput, } from './definition.js'; +export { isDirective, assertDirective, GraphQLDirective, isSpecifiedDirective, specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeferDirective, GraphQLStreamDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective, GraphQLOneOfDirective, DEFAULT_DEPRECATION_REASON, } from './directives.js'; +export type { GraphQLDirectiveConfig, GraphQLDirectiveExtensions, } from './directives.js'; +export { isSpecifiedScalarType, specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID, GRAPHQL_MAX_INT, GRAPHQL_MIN_INT, } from './scalars.js'; +export { isIntrospectionType, introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, TypeKind, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, } from './introspection.js'; +export { validateSchema, assertValidSchema } from './validate.js'; +export { assertName, assertEnumValueName } from './assertName.js'; diff --git a/type/index.js b/type/index.js new file mode 100644 index 0000000000..71d8785afd --- /dev/null +++ b/type/index.js @@ -0,0 +1,134 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getNullableType = exports.assertNamedType = exports.assertNullableType = exports.assertWrappingType = exports.assertAbstractType = exports.assertCompositeType = exports.assertLeafType = exports.assertOutputType = exports.assertInputType = exports.assertNonNullType = exports.assertListType = exports.assertInputField = exports.assertInputObjectType = exports.assertEnumValue = exports.assertEnumType = exports.assertUnionType = exports.assertInterfaceType = exports.assertArgument = exports.assertField = exports.assertObjectType = exports.assertScalarType = exports.assertType = exports.isRequiredInputField = exports.isRequiredArgument = exports.isNamedType = exports.isNullableType = exports.isWrappingType = exports.isAbstractType = exports.isCompositeType = exports.isLeafType = exports.isOutputType = exports.isInputField = exports.isInputType = exports.isNonNullType = exports.isListType = exports.isInputObjectType = exports.isEnumValue = exports.isEnumType = exports.isUnionType = exports.isInterfaceType = exports.isArgument = exports.isField = exports.isObjectType = exports.isScalarType = exports.isType = exports.resolveReadonlyArrayThunk = exports.resolveObjMapThunk = exports.GraphQLSchema = exports.assertSchema = exports.isSchema = void 0; +exports.assertEnumValueName = exports.assertName = exports.assertValidSchema = exports.validateSchema = exports.TypeNameMetaFieldDef = exports.TypeMetaFieldDef = exports.SchemaMetaFieldDef = exports.TypeKind = exports.__TypeKind = exports.__EnumValue = exports.__InputValue = exports.__Field = exports.__Type = exports.__DirectiveLocation = exports.__Directive = exports.__Schema = exports.introspectionTypes = exports.isIntrospectionType = exports.GRAPHQL_MIN_INT = exports.GRAPHQL_MAX_INT = exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = exports.specifiedScalarTypes = exports.isSpecifiedScalarType = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLOneOfDirective = exports.GraphQLSpecifiedByDirective = exports.GraphQLDeprecatedDirective = exports.GraphQLStreamDirective = exports.GraphQLDeferDirective = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.specifiedDirectives = exports.isSpecifiedDirective = exports.GraphQLDirective = exports.assertDirective = exports.isDirective = exports.GraphQLNonNull = exports.GraphQLList = exports.GraphQLInputObjectType = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLObjectType = exports.GraphQLScalarType = exports.getNamedType = void 0; +var schema_js_1 = require("./schema.js"); +// Predicate +Object.defineProperty(exports, "isSchema", { enumerable: true, get: function () { return schema_js_1.isSchema; } }); +// Assertion +Object.defineProperty(exports, "assertSchema", { enumerable: true, get: function () { return schema_js_1.assertSchema; } }); +// GraphQL Schema definition +Object.defineProperty(exports, "GraphQLSchema", { enumerable: true, get: function () { return schema_js_1.GraphQLSchema; } }); +var definition_js_1 = require("./definition.js"); +Object.defineProperty(exports, "resolveObjMapThunk", { enumerable: true, get: function () { return definition_js_1.resolveObjMapThunk; } }); +Object.defineProperty(exports, "resolveReadonlyArrayThunk", { enumerable: true, get: function () { return definition_js_1.resolveReadonlyArrayThunk; } }); +// Predicates +Object.defineProperty(exports, "isType", { enumerable: true, get: function () { return definition_js_1.isType; } }); +Object.defineProperty(exports, "isScalarType", { enumerable: true, get: function () { return definition_js_1.isScalarType; } }); +Object.defineProperty(exports, "isObjectType", { enumerable: true, get: function () { return definition_js_1.isObjectType; } }); +Object.defineProperty(exports, "isField", { enumerable: true, get: function () { return definition_js_1.isField; } }); +Object.defineProperty(exports, "isArgument", { enumerable: true, get: function () { return definition_js_1.isArgument; } }); +Object.defineProperty(exports, "isInterfaceType", { enumerable: true, get: function () { return definition_js_1.isInterfaceType; } }); +Object.defineProperty(exports, "isUnionType", { enumerable: true, get: function () { return definition_js_1.isUnionType; } }); +Object.defineProperty(exports, "isEnumType", { enumerable: true, get: function () { return definition_js_1.isEnumType; } }); +Object.defineProperty(exports, "isEnumValue", { enumerable: true, get: function () { return definition_js_1.isEnumValue; } }); +Object.defineProperty(exports, "isInputObjectType", { enumerable: true, get: function () { return definition_js_1.isInputObjectType; } }); +Object.defineProperty(exports, "isListType", { enumerable: true, get: function () { return definition_js_1.isListType; } }); +Object.defineProperty(exports, "isNonNullType", { enumerable: true, get: function () { return definition_js_1.isNonNullType; } }); +Object.defineProperty(exports, "isInputType", { enumerable: true, get: function () { return definition_js_1.isInputType; } }); +Object.defineProperty(exports, "isInputField", { enumerable: true, get: function () { return definition_js_1.isInputField; } }); +Object.defineProperty(exports, "isOutputType", { enumerable: true, get: function () { return definition_js_1.isOutputType; } }); +Object.defineProperty(exports, "isLeafType", { enumerable: true, get: function () { return definition_js_1.isLeafType; } }); +Object.defineProperty(exports, "isCompositeType", { enumerable: true, get: function () { return definition_js_1.isCompositeType; } }); +Object.defineProperty(exports, "isAbstractType", { enumerable: true, get: function () { return definition_js_1.isAbstractType; } }); +Object.defineProperty(exports, "isWrappingType", { enumerable: true, get: function () { return definition_js_1.isWrappingType; } }); +Object.defineProperty(exports, "isNullableType", { enumerable: true, get: function () { return definition_js_1.isNullableType; } }); +Object.defineProperty(exports, "isNamedType", { enumerable: true, get: function () { return definition_js_1.isNamedType; } }); +Object.defineProperty(exports, "isRequiredArgument", { enumerable: true, get: function () { return definition_js_1.isRequiredArgument; } }); +Object.defineProperty(exports, "isRequiredInputField", { enumerable: true, get: function () { return definition_js_1.isRequiredInputField; } }); +// Assertions +Object.defineProperty(exports, "assertType", { enumerable: true, get: function () { return definition_js_1.assertType; } }); +Object.defineProperty(exports, "assertScalarType", { enumerable: true, get: function () { return definition_js_1.assertScalarType; } }); +Object.defineProperty(exports, "assertObjectType", { enumerable: true, get: function () { return definition_js_1.assertObjectType; } }); +Object.defineProperty(exports, "assertField", { enumerable: true, get: function () { return definition_js_1.assertField; } }); +Object.defineProperty(exports, "assertArgument", { enumerable: true, get: function () { return definition_js_1.assertArgument; } }); +Object.defineProperty(exports, "assertInterfaceType", { enumerable: true, get: function () { return definition_js_1.assertInterfaceType; } }); +Object.defineProperty(exports, "assertUnionType", { enumerable: true, get: function () { return definition_js_1.assertUnionType; } }); +Object.defineProperty(exports, "assertEnumType", { enumerable: true, get: function () { return definition_js_1.assertEnumType; } }); +Object.defineProperty(exports, "assertEnumValue", { enumerable: true, get: function () { return definition_js_1.assertEnumValue; } }); +Object.defineProperty(exports, "assertInputObjectType", { enumerable: true, get: function () { return definition_js_1.assertInputObjectType; } }); +Object.defineProperty(exports, "assertInputField", { enumerable: true, get: function () { return definition_js_1.assertInputField; } }); +Object.defineProperty(exports, "assertListType", { enumerable: true, get: function () { return definition_js_1.assertListType; } }); +Object.defineProperty(exports, "assertNonNullType", { enumerable: true, get: function () { return definition_js_1.assertNonNullType; } }); +Object.defineProperty(exports, "assertInputType", { enumerable: true, get: function () { return definition_js_1.assertInputType; } }); +Object.defineProperty(exports, "assertOutputType", { enumerable: true, get: function () { return definition_js_1.assertOutputType; } }); +Object.defineProperty(exports, "assertLeafType", { enumerable: true, get: function () { return definition_js_1.assertLeafType; } }); +Object.defineProperty(exports, "assertCompositeType", { enumerable: true, get: function () { return definition_js_1.assertCompositeType; } }); +Object.defineProperty(exports, "assertAbstractType", { enumerable: true, get: function () { return definition_js_1.assertAbstractType; } }); +Object.defineProperty(exports, "assertWrappingType", { enumerable: true, get: function () { return definition_js_1.assertWrappingType; } }); +Object.defineProperty(exports, "assertNullableType", { enumerable: true, get: function () { return definition_js_1.assertNullableType; } }); +Object.defineProperty(exports, "assertNamedType", { enumerable: true, get: function () { return definition_js_1.assertNamedType; } }); +// Un-modifiers +Object.defineProperty(exports, "getNullableType", { enumerable: true, get: function () { return definition_js_1.getNullableType; } }); +Object.defineProperty(exports, "getNamedType", { enumerable: true, get: function () { return definition_js_1.getNamedType; } }); +// Definitions +Object.defineProperty(exports, "GraphQLScalarType", { enumerable: true, get: function () { return definition_js_1.GraphQLScalarType; } }); +Object.defineProperty(exports, "GraphQLObjectType", { enumerable: true, get: function () { return definition_js_1.GraphQLObjectType; } }); +Object.defineProperty(exports, "GraphQLInterfaceType", { enumerable: true, get: function () { return definition_js_1.GraphQLInterfaceType; } }); +Object.defineProperty(exports, "GraphQLUnionType", { enumerable: true, get: function () { return definition_js_1.GraphQLUnionType; } }); +Object.defineProperty(exports, "GraphQLEnumType", { enumerable: true, get: function () { return definition_js_1.GraphQLEnumType; } }); +Object.defineProperty(exports, "GraphQLInputObjectType", { enumerable: true, get: function () { return definition_js_1.GraphQLInputObjectType; } }); +// Type Wrappers +Object.defineProperty(exports, "GraphQLList", { enumerable: true, get: function () { return definition_js_1.GraphQLList; } }); +Object.defineProperty(exports, "GraphQLNonNull", { enumerable: true, get: function () { return definition_js_1.GraphQLNonNull; } }); +var directives_js_1 = require("./directives.js"); +// Predicate +Object.defineProperty(exports, "isDirective", { enumerable: true, get: function () { return directives_js_1.isDirective; } }); +// Assertion +Object.defineProperty(exports, "assertDirective", { enumerable: true, get: function () { return directives_js_1.assertDirective; } }); +// Directives Definition +Object.defineProperty(exports, "GraphQLDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLDirective; } }); +// Built-in Directives defined by the Spec +Object.defineProperty(exports, "isSpecifiedDirective", { enumerable: true, get: function () { return directives_js_1.isSpecifiedDirective; } }); +Object.defineProperty(exports, "specifiedDirectives", { enumerable: true, get: function () { return directives_js_1.specifiedDirectives; } }); +Object.defineProperty(exports, "GraphQLIncludeDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLIncludeDirective; } }); +Object.defineProperty(exports, "GraphQLSkipDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLSkipDirective; } }); +Object.defineProperty(exports, "GraphQLDeferDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLDeferDirective; } }); +Object.defineProperty(exports, "GraphQLStreamDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLStreamDirective; } }); +Object.defineProperty(exports, "GraphQLDeprecatedDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLDeprecatedDirective; } }); +Object.defineProperty(exports, "GraphQLSpecifiedByDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLSpecifiedByDirective; } }); +Object.defineProperty(exports, "GraphQLOneOfDirective", { enumerable: true, get: function () { return directives_js_1.GraphQLOneOfDirective; } }); +// Constant Deprecation Reason +Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", { enumerable: true, get: function () { return directives_js_1.DEFAULT_DEPRECATION_REASON; } }); +// Common built-in scalar instances. +var scalars_js_1 = require("./scalars.js"); +// Predicate +Object.defineProperty(exports, "isSpecifiedScalarType", { enumerable: true, get: function () { return scalars_js_1.isSpecifiedScalarType; } }); +// Standard GraphQL Scalars +Object.defineProperty(exports, "specifiedScalarTypes", { enumerable: true, get: function () { return scalars_js_1.specifiedScalarTypes; } }); +Object.defineProperty(exports, "GraphQLInt", { enumerable: true, get: function () { return scalars_js_1.GraphQLInt; } }); +Object.defineProperty(exports, "GraphQLFloat", { enumerable: true, get: function () { return scalars_js_1.GraphQLFloat; } }); +Object.defineProperty(exports, "GraphQLString", { enumerable: true, get: function () { return scalars_js_1.GraphQLString; } }); +Object.defineProperty(exports, "GraphQLBoolean", { enumerable: true, get: function () { return scalars_js_1.GraphQLBoolean; } }); +Object.defineProperty(exports, "GraphQLID", { enumerable: true, get: function () { return scalars_js_1.GraphQLID; } }); +// Int boundaries constants +Object.defineProperty(exports, "GRAPHQL_MAX_INT", { enumerable: true, get: function () { return scalars_js_1.GRAPHQL_MAX_INT; } }); +Object.defineProperty(exports, "GRAPHQL_MIN_INT", { enumerable: true, get: function () { return scalars_js_1.GRAPHQL_MIN_INT; } }); +var introspection_js_1 = require("./introspection.js"); +// Predicate +Object.defineProperty(exports, "isIntrospectionType", { enumerable: true, get: function () { return introspection_js_1.isIntrospectionType; } }); +// GraphQL Types for introspection. +Object.defineProperty(exports, "introspectionTypes", { enumerable: true, get: function () { return introspection_js_1.introspectionTypes; } }); +Object.defineProperty(exports, "__Schema", { enumerable: true, get: function () { return introspection_js_1.__Schema; } }); +Object.defineProperty(exports, "__Directive", { enumerable: true, get: function () { return introspection_js_1.__Directive; } }); +Object.defineProperty(exports, "__DirectiveLocation", { enumerable: true, get: function () { return introspection_js_1.__DirectiveLocation; } }); +Object.defineProperty(exports, "__Type", { enumerable: true, get: function () { return introspection_js_1.__Type; } }); +Object.defineProperty(exports, "__Field", { enumerable: true, get: function () { return introspection_js_1.__Field; } }); +Object.defineProperty(exports, "__InputValue", { enumerable: true, get: function () { return introspection_js_1.__InputValue; } }); +Object.defineProperty(exports, "__EnumValue", { enumerable: true, get: function () { return introspection_js_1.__EnumValue; } }); +Object.defineProperty(exports, "__TypeKind", { enumerable: true, get: function () { return introspection_js_1.__TypeKind; } }); +// "Enum" of Type Kinds +Object.defineProperty(exports, "TypeKind", { enumerable: true, get: function () { return introspection_js_1.TypeKind; } }); +// Meta-field definitions. +Object.defineProperty(exports, "SchemaMetaFieldDef", { enumerable: true, get: function () { return introspection_js_1.SchemaMetaFieldDef; } }); +Object.defineProperty(exports, "TypeMetaFieldDef", { enumerable: true, get: function () { return introspection_js_1.TypeMetaFieldDef; } }); +Object.defineProperty(exports, "TypeNameMetaFieldDef", { enumerable: true, get: function () { return introspection_js_1.TypeNameMetaFieldDef; } }); +// Validate GraphQL schema. +var validate_js_1 = require("./validate.js"); +Object.defineProperty(exports, "validateSchema", { enumerable: true, get: function () { return validate_js_1.validateSchema; } }); +Object.defineProperty(exports, "assertValidSchema", { enumerable: true, get: function () { return validate_js_1.assertValidSchema; } }); +// Upholds the spec rules about naming. +var assertName_js_1 = require("./assertName.js"); +Object.defineProperty(exports, "assertName", { enumerable: true, get: function () { return assertName_js_1.assertName; } }); +Object.defineProperty(exports, "assertEnumValueName", { enumerable: true, get: function () { return assertName_js_1.assertEnumValueName; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/type/index.js.map b/type/index.js.map new file mode 100644 index 0000000000..a000675827 --- /dev/null +++ b/type/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/type/index.ts"],"names":[],"mappings":";;;;AAEA,yCAOqB;AANnB,YAAY;AACZ,qGAAA,QAAQ,OAAA;AACR,YAAY;AACZ,yGAAA,YAAY,OAAA;AACZ,4BAA4B;AAC5B,0GAAA,aAAa,OAAA;AAUf,iDA8DyB;AA7DvB,mHAAA,kBAAkB,OAAA;AAClB,0HAAA,yBAAyB,OAAA;AACzB,aAAa;AACb,uGAAA,MAAM,OAAA;AACN,6GAAA,YAAY,OAAA;AACZ,6GAAA,YAAY,OAAA;AACZ,wGAAA,OAAO,OAAA;AACP,2GAAA,UAAU,OAAA;AACV,gHAAA,eAAe,OAAA;AACf,4GAAA,WAAW,OAAA;AACX,2GAAA,UAAU,OAAA;AACV,4GAAA,WAAW,OAAA;AACX,kHAAA,iBAAiB,OAAA;AACjB,2GAAA,UAAU,OAAA;AACV,8GAAA,aAAa,OAAA;AACb,4GAAA,WAAW,OAAA;AACX,6GAAA,YAAY,OAAA;AACZ,6GAAA,YAAY,OAAA;AACZ,2GAAA,UAAU,OAAA;AACV,gHAAA,eAAe,OAAA;AACf,+GAAA,cAAc,O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AAoB,OAAA;AACpB,sHAAA,qBAAqB,OAAA;AACrB,uHAAA,sBAAsB,OAAA;AACtB,2HAAA,0BAA0B,OAAA;AAC1B,4HAAA,2BAA2B,OAAA;AAC3B,sHAAA,qBAAqB,OAAA;AACrB,8BAA8B;AAC9B,2HAAA,0BAA0B,OAAA;AAQ5B,oCAAoC;AACpC,2CAasB;AAZpB,YAAY;AACZ,mHAAA,qBAAqB,OAAA;AACrB,2BAA2B;AAC3B,kHAAA,oBAAoB,OAAA;AACpB,wGAAA,UAAU,OAAA;AACV,0GAAA,YAAY,OAAA;AACZ,2GAAA,aAAa,OAAA;AACb,4GAAA,cAAc,OAAA;AACd,uGAAA,SAAS,OAAA;AACT,2BAA2B;AAC3B,6GAAA,eAAe,OAAA;AACf,6GAAA,eAAe,OAAA;AAGjB,uDAmB4B;AAlB1B,YAAY;AACZ,uHAAA,mBAAmB,OAAA;AACnB,mCAAmC;AACnC,sHAAA,kBAAkB,OAAA;AAClB,4GAAA,QAAQ,OAAA;AACR,+GAAA,WAAW,OAAA;AACX,uHAAA,mBAAmB,OAAA;AACnB,0GAAA,MAAM,OAAA;AACN,2GAAA,OAAO,OAAA;AACP,gHAAA,YAAY,OAAA;AACZ,+GAAA,WAAW,OAAA;AACX,8GAAA,UAAU,OAAA;AACV,uBAAuB;AACvB,4GAAA,QAAQ,OAAA;AACR,0BAA0B;AAC1B,sHAAA,kBAAkB,OAAA;AAClB,oHAAA,gBAAgB,OAAA;AAChB,wHAAA,oBAAoB,OAAA;AAGtB,2BAA2B;AAC3B,6CAAkE;AAAzD,6GAAA,cAAc,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAE1C,uCAAuC;AACvC,iDAAkE;AAAzD,2GAAA,UAAU,OAAA;AAAE,oHAAA,mBAAmB,OAAA","sourcesContent":["export type { Path as ResponsePath } from '../jsutils/Path.js';\n\nexport {\n // Predicate\n isSchema,\n // Assertion\n assertSchema,\n // GraphQL Schema definition\n GraphQLSchema,\n} from './schema.js';\nexport type { GraphQLSchemaConfig, GraphQLSchemaExtensions } from './schema.js';\n\nexport type {\n GraphQLField,\n GraphQLArgument,\n GraphQLEnumValue,\n GraphQLInputField,\n} from './definition.js';\nexport {\n resolveObjMapThunk,\n resolveReadonlyArrayThunk,\n // Predicates\n isType,\n isScalarType,\n isObjectType,\n isField,\n isArgument,\n isInterfaceType,\n isUnionType,\n isEnumType,\n isEnumValue,\n isInputObjectType,\n isListType,\n isNonNullType,\n isInputType,\n isInputField,\n isOutputType,\n isLeafType,\n isCompositeType,\n isAbstractType,\n isWrappingType,\n isNullableType,\n isNamedType,\n isRequiredArgument,\n isRequiredInputField,\n // Assertions\n assertType,\n assertScalarType,\n assertObjectType,\n assertField,\n assertArgument,\n assertInterfaceType,\n assertUnionType,\n assertEnumType,\n assertEnumValue,\n assertInputObjectType,\n assertInputField,\n assertListType,\n assertNonNullType,\n assertInputType,\n assertOutputType,\n assertLeafType,\n assertCompositeType,\n assertAbstractType,\n assertWrappingType,\n assertNullableType,\n assertNamedType,\n // Un-modifiers\n getNullableType,\n getNamedType,\n // Definitions\n GraphQLScalarType,\n GraphQLObjectType,\n GraphQLInterfaceType,\n GraphQLUnionType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n // Type Wrappers\n GraphQLList,\n GraphQLNonNull,\n} from './definition.js';\n\nexport type {\n GraphQLType,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLLeafType,\n GraphQLCompositeType,\n GraphQLAbstractType,\n GraphQLWrappingType,\n GraphQLNullableType,\n GraphQLNullableInputType,\n GraphQLNullableOutputType,\n GraphQLNamedType,\n GraphQLNamedInputType,\n GraphQLNamedOutputType,\n ThunkReadonlyArray,\n ThunkObjMap,\n GraphQLArgumentConfig,\n GraphQLArgumentExtensions,\n GraphQLEnumTypeConfig,\n GraphQLEnumTypeExtensions,\n GraphQLEnumValueConfig,\n GraphQLEnumValueConfigMap,\n GraphQLEnumValueExtensions,\n GraphQLFieldConfig,\n GraphQLFieldConfigArgumentMap,\n GraphQLFieldConfigMap,\n GraphQLFieldExtensions,\n GraphQLFieldMap,\n GraphQLFieldResolver,\n GraphQLInputFieldConfig,\n GraphQLInputFieldConfigMap,\n GraphQLInputFieldExtensions,\n GraphQLInputFieldMap,\n GraphQLInputObjectTypeConfig,\n GraphQLInputObjectTypeExtensions,\n GraphQLInterfaceTypeConfig,\n GraphQLInterfaceTypeExtensions,\n GraphQLIsTypeOfFn,\n GraphQLObjectTypeConfig,\n GraphQLObjectTypeExtensions,\n GraphQLResolveInfo,\n GraphQLScalarTypeConfig,\n GraphQLScalarTypeExtensions,\n GraphQLTypeResolver,\n GraphQLUnionTypeConfig,\n GraphQLUnionTypeExtensions,\n GraphQLScalarSerializer,\n GraphQLScalarValueParser,\n GraphQLScalarLiteralParser,\n GraphQLScalarOutputValueCoercer,\n GraphQLScalarInputValueCoercer,\n GraphQLScalarInputLiteralCoercer,\n GraphQLDefaultInput,\n} from './definition.js';\n\nexport {\n // Predicate\n isDirective,\n // Assertion\n assertDirective,\n // Directives Definition\n GraphQLDirective,\n // Built-in Directives defined by the Spec\n isSpecifiedDirective,\n specifiedDirectives,\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n // Constant Deprecation Reason\n DEFAULT_DEPRECATION_REASON,\n} from './directives.js';\n\nexport type {\n GraphQLDirectiveConfig,\n GraphQLDirectiveExtensions,\n} from './directives.js';\n\n// Common built-in scalar instances.\nexport {\n // Predicate\n isSpecifiedScalarType,\n // Standard GraphQL Scalars\n specifiedScalarTypes,\n GraphQLInt,\n GraphQLFloat,\n GraphQLString,\n GraphQLBoolean,\n GraphQLID,\n // Int boundaries constants\n GRAPHQL_MAX_INT,\n GRAPHQL_MIN_INT,\n} from './scalars.js';\n\nexport {\n // Predicate\n isIntrospectionType,\n // GraphQL Types for introspection.\n introspectionTypes,\n __Schema,\n __Directive,\n __DirectiveLocation,\n __Type,\n __Field,\n __InputValue,\n __EnumValue,\n __TypeKind,\n // \"Enum\" of Type Kinds\n TypeKind,\n // Meta-field definitions.\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n} from './introspection.js';\n\n// Validate GraphQL schema.\nexport { validateSchema, assertValidSchema } from './validate.js';\n\n// Upholds the spec rules about naming.\nexport { assertName, assertEnumValueName } from './assertName.js';\n"]} \ No newline at end of file diff --git a/type/index.mjs b/type/index.mjs new file mode 100644 index 0000000000..95ddb3ddd7 --- /dev/null +++ b/type/index.mjs @@ -0,0 +1,51 @@ +export { +// Predicate +isSchema, +// Assertion +assertSchema, +// GraphQL Schema definition +GraphQLSchema, } from "./schema.mjs"; +export { resolveObjMapThunk, resolveReadonlyArrayThunk, +// Predicates +isType, isScalarType, isObjectType, isField, isArgument, isInterfaceType, isUnionType, isEnumType, isEnumValue, isInputObjectType, isListType, isNonNullType, isInputType, isInputField, isOutputType, isLeafType, isCompositeType, isAbstractType, isWrappingType, isNullableType, isNamedType, isRequiredArgument, isRequiredInputField, +// Assertions +assertType, assertScalarType, assertObjectType, assertField, assertArgument, assertInterfaceType, assertUnionType, assertEnumType, assertEnumValue, assertInputObjectType, assertInputField, assertListType, assertNonNullType, assertInputType, assertOutputType, assertLeafType, assertCompositeType, assertAbstractType, assertWrappingType, assertNullableType, assertNamedType, +// Un-modifiers +getNullableType, getNamedType, +// Definitions +GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, +// Type Wrappers +GraphQLList, GraphQLNonNull, } from "./definition.mjs"; +export { +// Predicate +isDirective, +// Assertion +assertDirective, +// Directives Definition +GraphQLDirective, +// Built-in Directives defined by the Spec +isSpecifiedDirective, specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeferDirective, GraphQLStreamDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective, GraphQLOneOfDirective, +// Constant Deprecation Reason +DEFAULT_DEPRECATION_REASON, } from "./directives.mjs"; +// Common built-in scalar instances. +export { +// Predicate +isSpecifiedScalarType, +// Standard GraphQL Scalars +specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID, +// Int boundaries constants +GRAPHQL_MAX_INT, GRAPHQL_MIN_INT, } from "./scalars.mjs"; +export { +// Predicate +isIntrospectionType, +// GraphQL Types for introspection. +introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, +// "Enum" of Type Kinds +TypeKind, +// Meta-field definitions. +SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, } from "./introspection.mjs"; +// Validate GraphQL schema. +export { validateSchema, assertValidSchema } from "./validate.mjs"; +// Upholds the spec rules about naming. +export { assertName, assertEnumValueName } from "./assertName.mjs"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/type/index.mjs.map b/type/index.mjs.map new file mode 100644 index 0000000000..f587cef425 --- /dev/null +++ b/type/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/type/index.ts"],"names":[],"mappings":"AAEA,OAAO;AACL,YAAY;AACZ,QAAQ;AACR,YAAY;AACZ,YAAY;AACZ,4BAA4B;AAC5B,aAAa,GACd,qBAAoB;AASrB,OAAO,EACL,kBAAkB,EAClB,yBAAyB;AACzB,aAAa;AACb,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,oBAAoB;AACpB,aAAa;AACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,cAAc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BAAmB,EAAE,yBAAwB","sourcesContent":["export type { Path as ResponsePath } from '../jsutils/Path.js';\n\nexport {\n // Predicate\n isSchema,\n // Assertion\n assertSchema,\n // GraphQL Schema definition\n GraphQLSchema,\n} from './schema.js';\nexport type { GraphQLSchemaConfig, GraphQLSchemaExtensions } from './schema.js';\n\nexport type {\n GraphQLField,\n GraphQLArgument,\n GraphQLEnumValue,\n GraphQLInputField,\n} from './definition.js';\nexport {\n resolveObjMapThunk,\n resolveReadonlyArrayThunk,\n // Predicates\n isType,\n isScalarType,\n isObjectType,\n isField,\n isArgument,\n isInterfaceType,\n isUnionType,\n isEnumType,\n isEnumValue,\n isInputObjectType,\n isListType,\n isNonNullType,\n isInputType,\n isInputField,\n isOutputType,\n isLeafType,\n isCompositeType,\n isAbstractType,\n isWrappingType,\n isNullableType,\n isNamedType,\n isRequiredArgument,\n isRequiredInputField,\n // Assertions\n assertType,\n assertScalarType,\n assertObjectType,\n assertField,\n assertArgument,\n assertInterfaceType,\n assertUnionType,\n assertEnumType,\n assertEnumValue,\n assertInputObjectType,\n assertInputField,\n assertListType,\n assertNonNullType,\n assertInputType,\n assertOutputType,\n assertLeafType,\n assertCompositeType,\n assertAbstractType,\n assertWrappingType,\n assertNullableType,\n assertNamedType,\n // Un-modifiers\n getNullableType,\n getNamedType,\n // Definitions\n GraphQLScalarType,\n GraphQLObjectType,\n GraphQLInterfaceType,\n GraphQLUnionType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n // Type Wrappers\n GraphQLList,\n GraphQLNonNull,\n} from './definition.js';\n\nexport type {\n GraphQLType,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLLeafType,\n GraphQLCompositeType,\n GraphQLAbstractType,\n GraphQLWrappingType,\n GraphQLNullableType,\n GraphQLNullableInputType,\n GraphQLNullableOutputType,\n GraphQLNamedType,\n GraphQLNamedInputType,\n GraphQLNamedOutputType,\n ThunkReadonlyArray,\n ThunkObjMap,\n GraphQLArgumentConfig,\n GraphQLArgumentExtensions,\n GraphQLEnumTypeConfig,\n GraphQLEnumTypeExtensions,\n GraphQLEnumValueConfig,\n GraphQLEnumValueConfigMap,\n GraphQLEnumValueExtensions,\n GraphQLFieldConfig,\n GraphQLFieldConfigArgumentMap,\n GraphQLFieldConfigMap,\n GraphQLFieldExtensions,\n GraphQLFieldMap,\n GraphQLFieldResolver,\n GraphQLInputFieldConfig,\n GraphQLInputFieldConfigMap,\n GraphQLInputFieldExtensions,\n GraphQLInputFieldMap,\n GraphQLInputObjectTypeConfig,\n GraphQLInputObjectTypeExtensions,\n GraphQLInterfaceTypeConfig,\n GraphQLInterfaceTypeExtensions,\n GraphQLIsTypeOfFn,\n GraphQLObjectTypeConfig,\n GraphQLObjectTypeExtensions,\n GraphQLResolveInfo,\n GraphQLScalarTypeConfig,\n GraphQLScalarTypeExtensions,\n GraphQLTypeResolver,\n GraphQLUnionTypeConfig,\n GraphQLUnionTypeExtensions,\n GraphQLScalarSerializer,\n GraphQLScalarValueParser,\n GraphQLScalarLiteralParser,\n GraphQLScalarOutputValueCoercer,\n GraphQLScalarInputValueCoercer,\n GraphQLScalarInputLiteralCoercer,\n GraphQLDefaultInput,\n} from './definition.js';\n\nexport {\n // Predicate\n isDirective,\n // Assertion\n assertDirective,\n // Directives Definition\n GraphQLDirective,\n // Built-in Directives defined by the Spec\n isSpecifiedDirective,\n specifiedDirectives,\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n // Constant Deprecation Reason\n DEFAULT_DEPRECATION_REASON,\n} from './directives.js';\n\nexport type {\n GraphQLDirectiveConfig,\n GraphQLDirectiveExtensions,\n} from './directives.js';\n\n// Common built-in scalar instances.\nexport {\n // Predicate\n isSpecifiedScalarType,\n // Standard GraphQL Scalars\n specifiedScalarTypes,\n GraphQLInt,\n GraphQLFloat,\n GraphQLString,\n GraphQLBoolean,\n GraphQLID,\n // Int boundaries constants\n GRAPHQL_MAX_INT,\n GRAPHQL_MIN_INT,\n} from './scalars.js';\n\nexport {\n // Predicate\n isIntrospectionType,\n // GraphQL Types for introspection.\n introspectionTypes,\n __Schema,\n __Directive,\n __DirectiveLocation,\n __Type,\n __Field,\n __InputValue,\n __EnumValue,\n __TypeKind,\n // \"Enum\" of Type Kinds\n TypeKind,\n // Meta-field definitions.\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n} from './introspection.js';\n\n// Validate GraphQL schema.\nexport { validateSchema, assertValidSchema } from './validate.js';\n\n// Upholds the spec rules about naming.\nexport { assertName, assertEnumValueName } from './assertName.js';\n"]} \ No newline at end of file diff --git a/type/introspection.d.ts b/type/introspection.d.ts new file mode 100644 index 0000000000..d52d3e23ad --- /dev/null +++ b/type/introspection.d.ts @@ -0,0 +1,26 @@ +import type { GraphQLNamedType } from './definition.js'; +import { GraphQLEnumType, GraphQLField, GraphQLObjectType } from './definition.js'; +export declare const __Schema: GraphQLObjectType; +export declare const __Directive: GraphQLObjectType; +export declare const __DirectiveLocation: GraphQLEnumType; +export declare const __Type: GraphQLObjectType; +export declare const __Field: GraphQLObjectType; +export declare const __InputValue: GraphQLObjectType; +export declare const __EnumValue: GraphQLObjectType; +export declare const TypeKind: { + readonly SCALAR: "SCALAR"; + readonly OBJECT: "OBJECT"; + readonly INTERFACE: "INTERFACE"; + readonly UNION: "UNION"; + readonly ENUM: "ENUM"; + readonly INPUT_OBJECT: "INPUT_OBJECT"; + readonly LIST: "LIST"; + readonly NON_NULL: "NON_NULL"; +}; +export type TypeKind = (typeof TypeKind)[keyof typeof TypeKind]; +export declare const __TypeKind: GraphQLEnumType; +export declare const SchemaMetaFieldDef: GraphQLField; +export declare const TypeMetaFieldDef: GraphQLField; +export declare const TypeNameMetaFieldDef: GraphQLField; +export declare const introspectionTypes: ReadonlyArray; +export declare function isIntrospectionType(type: GraphQLNamedType): boolean; diff --git a/type/introspection.js b/type/introspection.js new file mode 100644 index 0000000000..cb856904d7 --- /dev/null +++ b/type/introspection.js @@ -0,0 +1,479 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.introspectionTypes = exports.TypeNameMetaFieldDef = exports.TypeMetaFieldDef = exports.SchemaMetaFieldDef = exports.__TypeKind = exports.TypeKind = exports.__EnumValue = exports.__InputValue = exports.__Field = exports.__Type = exports.__DirectiveLocation = exports.__Directive = exports.__Schema = void 0; +exports.isIntrospectionType = isIntrospectionType; +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const directiveLocation_js_1 = require("../language/directiveLocation.js"); +const printer_js_1 = require("../language/printer.js"); +const getDefaultValueAST_js_1 = require("../utilities/getDefaultValueAST.js"); +const definition_js_1 = require("./definition.js"); +const scalars_js_1 = require("./scalars.js"); +exports.__Schema = new definition_js_1.GraphQLObjectType({ + name: '__Schema', + description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', + fields: () => ({ + description: { + type: scalars_js_1.GraphQLString, + resolve: (schema) => schema.description, + }, + types: { + description: 'A list of all types supported by this server.', + type: new definition_js_1.GraphQLNonNull(new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__Type))), + resolve(schema) { + return Object.values(schema.getTypeMap()); + }, + }, + queryType: { + description: 'The type that query operations will be rooted at.', + type: new definition_js_1.GraphQLNonNull(exports.__Type), + resolve: (schema) => schema.getQueryType(), + }, + mutationType: { + description: 'If this server supports mutation, the type that mutation operations will be rooted at.', + type: exports.__Type, + resolve: (schema) => schema.getMutationType(), + }, + subscriptionType: { + description: 'If this server support subscription, the type that subscription operations will be rooted at.', + type: exports.__Type, + resolve: (schema) => schema.getSubscriptionType(), + }, + directives: { + description: 'A list of all directives supported by this server.', + type: new definition_js_1.GraphQLNonNull(new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__Directive))), + resolve: (schema) => schema.getDirectives(), + }, + }), +}); +exports.__Directive = new definition_js_1.GraphQLObjectType({ + name: '__Directive', + description: "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + fields: () => ({ + name: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString), + resolve: (directive) => directive.name, + }, + description: { + type: scalars_js_1.GraphQLString, + resolve: (directive) => directive.description, + }, + isRepeatable: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + resolve: (directive) => directive.isRepeatable, + }, + locations: { + type: new definition_js_1.GraphQLNonNull(new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__DirectiveLocation))), + resolve: (directive) => directive.locations, + }, + args: { + type: new definition_js_1.GraphQLNonNull(new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__InputValue))), + args: { + includeDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(field, { includeDeprecated }) { + return includeDeprecated === true + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + }), +}); +exports.__DirectiveLocation = new definition_js_1.GraphQLEnumType({ + name: '__DirectiveLocation', + description: 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.', + values: { + QUERY: { + value: directiveLocation_js_1.DirectiveLocation.QUERY, + description: 'Location adjacent to a query operation.', + }, + MUTATION: { + value: directiveLocation_js_1.DirectiveLocation.MUTATION, + description: 'Location adjacent to a mutation operation.', + }, + SUBSCRIPTION: { + value: directiveLocation_js_1.DirectiveLocation.SUBSCRIPTION, + description: 'Location adjacent to a subscription operation.', + }, + FIELD: { + value: directiveLocation_js_1.DirectiveLocation.FIELD, + description: 'Location adjacent to a field.', + }, + FRAGMENT_DEFINITION: { + value: directiveLocation_js_1.DirectiveLocation.FRAGMENT_DEFINITION, + description: 'Location adjacent to a fragment definition.', + }, + FRAGMENT_SPREAD: { + value: directiveLocation_js_1.DirectiveLocation.FRAGMENT_SPREAD, + description: 'Location adjacent to a fragment spread.', + }, + INLINE_FRAGMENT: { + value: directiveLocation_js_1.DirectiveLocation.INLINE_FRAGMENT, + description: 'Location adjacent to an inline fragment.', + }, + VARIABLE_DEFINITION: { + value: directiveLocation_js_1.DirectiveLocation.VARIABLE_DEFINITION, + description: 'Location adjacent to an operation variable definition.', + }, + FRAGMENT_VARIABLE_DEFINITION: { + value: directiveLocation_js_1.DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION, + description: 'Location adjacent to a fragment variable definition.', + }, + SCHEMA: { + value: directiveLocation_js_1.DirectiveLocation.SCHEMA, + description: 'Location adjacent to a schema definition.', + }, + SCALAR: { + value: directiveLocation_js_1.DirectiveLocation.SCALAR, + description: 'Location adjacent to a scalar definition.', + }, + OBJECT: { + value: directiveLocation_js_1.DirectiveLocation.OBJECT, + description: 'Location adjacent to an object type definition.', + }, + FIELD_DEFINITION: { + value: directiveLocation_js_1.DirectiveLocation.FIELD_DEFINITION, + description: 'Location adjacent to a field definition.', + }, + ARGUMENT_DEFINITION: { + value: directiveLocation_js_1.DirectiveLocation.ARGUMENT_DEFINITION, + description: 'Location adjacent to an argument definition.', + }, + INTERFACE: { + value: directiveLocation_js_1.DirectiveLocation.INTERFACE, + description: 'Location adjacent to an interface definition.', + }, + UNION: { + value: directiveLocation_js_1.DirectiveLocation.UNION, + description: 'Location adjacent to a union definition.', + }, + ENUM: { + value: directiveLocation_js_1.DirectiveLocation.ENUM, + description: 'Location adjacent to an enum definition.', + }, + ENUM_VALUE: { + value: directiveLocation_js_1.DirectiveLocation.ENUM_VALUE, + description: 'Location adjacent to an enum value definition.', + }, + INPUT_OBJECT: { + value: directiveLocation_js_1.DirectiveLocation.INPUT_OBJECT, + description: 'Location adjacent to an input object type definition.', + }, + INPUT_FIELD_DEFINITION: { + value: directiveLocation_js_1.DirectiveLocation.INPUT_FIELD_DEFINITION, + description: 'Location adjacent to an input object field definition.', + }, + }, +}); +exports.__Type = new definition_js_1.GraphQLObjectType({ + name: '__Type', + description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', + fields: () => ({ + kind: { + type: new definition_js_1.GraphQLNonNull(exports.__TypeKind), + resolve(type) { + if ((0, definition_js_1.isScalarType)(type)) { + return exports.TypeKind.SCALAR; + } + if ((0, definition_js_1.isObjectType)(type)) { + return exports.TypeKind.OBJECT; + } + if ((0, definition_js_1.isInterfaceType)(type)) { + return exports.TypeKind.INTERFACE; + } + if ((0, definition_js_1.isUnionType)(type)) { + return exports.TypeKind.UNION; + } + if ((0, definition_js_1.isEnumType)(type)) { + return exports.TypeKind.ENUM; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + return exports.TypeKind.INPUT_OBJECT; + } + if ((0, definition_js_1.isListType)(type)) { + return exports.TypeKind.LIST; + } + if ((0, definition_js_1.isNonNullType)(type)) { + return exports.TypeKind.NON_NULL; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered) + (false) || (0, invariant_js_1.invariant)(false, `Unexpected type: "${(0, inspect_js_1.inspect)(type)}".`); + }, + }, + name: { + type: scalars_js_1.GraphQLString, + resolve: (type) => ('name' in type ? type.name : undefined), + }, + description: { + type: scalars_js_1.GraphQLString, + resolve: (type) => + // FIXME: add test case + /* c8 ignore next */ + 'description' in type ? type.description : undefined, + }, + specifiedByURL: { + type: scalars_js_1.GraphQLString, + resolve: (obj) => 'specifiedByURL' in obj ? obj.specifiedByURL : undefined, + }, + fields: { + type: new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__Field)), + args: { + includeDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(type, { includeDeprecated }) { + if ((0, definition_js_1.isObjectType)(type) || (0, definition_js_1.isInterfaceType)(type)) { + const fields = Object.values(type.getFields()); + return includeDeprecated === true + ? fields + : fields.filter((field) => field.deprecationReason == null); + } + }, + }, + interfaces: { + type: new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__Type)), + resolve(type) { + if ((0, definition_js_1.isObjectType)(type) || (0, definition_js_1.isInterfaceType)(type)) { + return type.getInterfaces(); + } + }, + }, + possibleTypes: { + type: new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__Type)), + resolve(type, _args, _context, { schema }) { + if ((0, definition_js_1.isAbstractType)(type)) { + return schema.getPossibleTypes(type); + } + }, + }, + enumValues: { + type: new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__EnumValue)), + args: { + includeDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(type, { includeDeprecated }) { + if ((0, definition_js_1.isEnumType)(type)) { + const values = type.getValues(); + return includeDeprecated === true + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + inputFields: { + type: new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__InputValue)), + args: { + includeDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(type, { includeDeprecated }) { + if ((0, definition_js_1.isInputObjectType)(type)) { + const values = Object.values(type.getFields()); + return includeDeprecated === true + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + ofType: { + type: exports.__Type, + resolve: (type) => ('ofType' in type ? type.ofType : undefined), + }, + isOneOf: { + type: scalars_js_1.GraphQLBoolean, + resolve: (type) => { + if ((0, definition_js_1.isInputObjectType)(type)) { + return type.isOneOf; + } + }, + }, + }), +}); +exports.__Field = new definition_js_1.GraphQLObjectType({ + name: '__Field', + description: 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.', + fields: () => ({ + name: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString), + resolve: (field) => field.name, + }, + description: { + type: scalars_js_1.GraphQLString, + resolve: (field) => field.description, + }, + args: { + type: new definition_js_1.GraphQLNonNull(new definition_js_1.GraphQLList(new definition_js_1.GraphQLNonNull(exports.__InputValue))), + args: { + includeDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(field, { includeDeprecated }) { + return includeDeprecated === true + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + type: { + type: new definition_js_1.GraphQLNonNull(exports.__Type), + resolve: (field) => field.type, + }, + isDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: scalars_js_1.GraphQLString, + resolve: (field) => field.deprecationReason, + }, + }), +}); +exports.__InputValue = new definition_js_1.GraphQLObjectType({ + name: '__InputValue', + description: 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.', + fields: () => ({ + name: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString), + resolve: (inputValue) => inputValue.name, + }, + description: { + type: scalars_js_1.GraphQLString, + resolve: (inputValue) => inputValue.description, + }, + type: { + type: new definition_js_1.GraphQLNonNull(exports.__Type), + resolve: (inputValue) => inputValue.type, + }, + defaultValue: { + type: scalars_js_1.GraphQLString, + description: 'A GraphQL-formatted string representing the default value for this input value.', + resolve(inputValue) { + const ast = (0, getDefaultValueAST_js_1.getDefaultValueAST)(inputValue); + if (ast) { + return (0, printer_js_1.print)(ast); + } + return null; + }, + }, + isDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: scalars_js_1.GraphQLString, + resolve: (obj) => obj.deprecationReason, + }, + }), +}); +exports.__EnumValue = new definition_js_1.GraphQLObjectType({ + name: '__EnumValue', + description: 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.', + fields: () => ({ + name: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString), + resolve: (enumValue) => enumValue.name, + }, + description: { + type: scalars_js_1.GraphQLString, + resolve: (enumValue) => enumValue.description, + }, + isDeprecated: { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLBoolean), + resolve: (enumValue) => enumValue.deprecationReason != null, + }, + deprecationReason: { + type: scalars_js_1.GraphQLString, + resolve: (enumValue) => enumValue.deprecationReason, + }, + }), +}); +exports.TypeKind = { + SCALAR: 'SCALAR', + OBJECT: 'OBJECT', + INTERFACE: 'INTERFACE', + UNION: 'UNION', + ENUM: 'ENUM', + INPUT_OBJECT: 'INPUT_OBJECT', + LIST: 'LIST', + NON_NULL: 'NON_NULL', +}; +exports.__TypeKind = new definition_js_1.GraphQLEnumType({ + name: '__TypeKind', + description: 'An enum describing what kind of type a given `__Type` is.', + values: { + SCALAR: { + value: exports.TypeKind.SCALAR, + description: 'Indicates this type is a scalar.', + }, + OBJECT: { + value: exports.TypeKind.OBJECT, + description: 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', + }, + INTERFACE: { + value: exports.TypeKind.INTERFACE, + description: 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', + }, + UNION: { + value: exports.TypeKind.UNION, + description: 'Indicates this type is a union. `possibleTypes` is a valid field.', + }, + ENUM: { + value: exports.TypeKind.ENUM, + description: 'Indicates this type is an enum. `enumValues` is a valid field.', + }, + INPUT_OBJECT: { + value: exports.TypeKind.INPUT_OBJECT, + description: 'Indicates this type is an input object. `inputFields` is a valid field.', + }, + LIST: { + value: exports.TypeKind.LIST, + description: 'Indicates this type is a list. `ofType` is a valid field.', + }, + NON_NULL: { + value: exports.TypeKind.NON_NULL, + description: 'Indicates this type is a non-null. `ofType` is a valid field.', + }, + }, +}); +exports.SchemaMetaFieldDef = new definition_js_1.GraphQLField(undefined, '__schema', { + type: new definition_js_1.GraphQLNonNull(exports.__Schema), + description: 'Access the current type schema of this server.', + resolve: (_source, _args, _context, { schema }) => schema, +}); +exports.TypeMetaFieldDef = new definition_js_1.GraphQLField(undefined, '__type', { + type: exports.__Type, + description: 'Request the type information of a single type.', + args: { name: { type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString) } }, + resolve: (_source, { name }, _context, { schema }) => schema.getType(name), +}); +exports.TypeNameMetaFieldDef = new definition_js_1.GraphQLField(undefined, '__typename', { + type: new definition_js_1.GraphQLNonNull(scalars_js_1.GraphQLString), + description: 'The name of the current Object type at runtime.', + resolve: (_source, _args, _context, { parentType }) => parentType.name, +}); +exports.introspectionTypes = Object.freeze([ + exports.__Schema, + exports.__Directive, + exports.__DirectiveLocation, + exports.__Type, + exports.__Field, + exports.__InputValue, + exports.__EnumValue, + exports.__TypeKind, +]); +function isIntrospectionType(type) { + return exports.introspectionTypes.some(({ name }) => type.name === name); +} +//# sourceMappingURL=introspection.js.map \ No newline at end of file diff --git a/type/introspection.js.map b/type/introspection.js.map new file mode 100644 index 0000000000..a58e110af9 --- /dev/null +++ b/type/introspection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"introspection.js","sourceRoot":"","sources":["../../src/type/introspection.ts"],"names":[],"mappings":";;;AAmiBA,kDAEC;AAriBD,sDAAgD;AAChD,0DAAoD;AAEpD,2EAAqE;AACrE,uDAA+C;AAE/C,8EAAwE;AASxE,mDAeyB;AAEzB,6CAA6D;AAGhD,QAAA,QAAQ,GAAsB,IAAI,iCAAiB,CAAC;IAC/D,IAAI,EAAE,UAAU;IAChB,WAAW,EACT,2MAA2M;IAC7M,MAAM,EAAE,GAAG,EAAE,CACX,CAAC;QACC,WAAW,EAAE;YACX,IAAI,EAAE,0BAAa;YACnB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1D,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,IAAI,4BAAY,CAAC,SAAS,EAAE,QAAQ,EAAE;IACpE,IAAI,EAAE,cAAM;IACZ,WAAW,EAAE,gDAAgD;IAC7D,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,8BAAc,CAAC,0BAAa,CAAC,EAAE,EAAE;IAC3D,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;CAC3E,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,IAAI,4BAAY,CAAC,SAAS,EAAE,YAAY,EAAE;IAC5E,IAAI,EAAE,IAAI,8BAAc,CAAC,0BAAa,CAAC;IACvC,WAAW,EAAE,iDAAiD;IAC9D,OAAO,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI;CACvE,CAAC,CAAC;AAEU,QAAA,kBAAkB,GAC7B,MAAM,CAAC,MAAM,CAAC;IACZ,gBAAQ;IACR,mBAAW;IACX,2BAAmB;IACnB,cAAM;IACN,eAAO;IACP,oBAAY;IACZ,mBAAW;IACX,kBAAU;CACX,CAAC,CAAC;AAEL,SAAgB,mBAAmB,CAAC,IAAsB;IACxD,OAAO,0BAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\n\nimport { DirectiveLocation } from '../language/directiveLocation.js';\nimport { print } from '../language/printer.js';\n\nimport { getDefaultValueAST } from '../utilities/getDefaultValueAST.js';\n\nimport type {\n GraphQLEnumValue,\n GraphQLFieldConfigMap,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLType,\n} from './definition.js';\nimport {\n GraphQLEnumType,\n GraphQLField,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isListType,\n isNonNullType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from './definition.js';\nimport type { GraphQLDirective } from './directives.js';\nimport { GraphQLBoolean, GraphQLString } from './scalars.js';\nimport type { GraphQLSchema } from './schema.js';\n\nexport const __Schema: GraphQLObjectType = new GraphQLObjectType({\n name: '__Schema',\n description:\n 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.',\n fields: () =>\n ({\n description: {\n type: GraphQLString,\n resolve: (schema) => schema.description,\n },\n types: {\n description: 'A list of all types supported by this server.',\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Type))),\n resolve(schema) {\n return Object.values(schema.getTypeMap());\n },\n },\n queryType: {\n description: 'The type that query operations will be rooted at.',\n type: new GraphQLNonNull(__Type),\n resolve: (schema) => schema.getQueryType(),\n },\n mutationType: {\n description:\n 'If this server supports mutation, the type that mutation operations will be rooted at.',\n type: __Type,\n resolve: (schema) => schema.getMutationType(),\n },\n subscriptionType: {\n description:\n 'If this server support subscription, the type that subscription operations will be rooted at.',\n type: __Type,\n resolve: (schema) => schema.getSubscriptionType(),\n },\n directives: {\n description: 'A list of all directives supported by this server.',\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__Directive)),\n ),\n resolve: (schema) => schema.getDirectives(),\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __Directive: GraphQLObjectType = new GraphQLObjectType({\n name: '__Directive',\n description:\n \"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\\n\\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.\",\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (directive) => directive.name,\n },\n description: {\n type: GraphQLString,\n resolve: (directive) => directive.description,\n },\n isRepeatable: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (directive) => directive.isRepeatable,\n },\n locations: {\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__DirectiveLocation)),\n ),\n resolve: (directive) => directive.locations,\n },\n args: {\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__InputValue)),\n ),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(field, { includeDeprecated }) {\n return includeDeprecated === true\n ? field.args\n : field.args.filter((arg) => arg.deprecationReason == null);\n },\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __DirectiveLocation: GraphQLEnumType = new GraphQLEnumType({\n name: '__DirectiveLocation',\n description:\n 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.',\n values: {\n QUERY: {\n value: DirectiveLocation.QUERY,\n description: 'Location adjacent to a query operation.',\n },\n MUTATION: {\n value: DirectiveLocation.MUTATION,\n description: 'Location adjacent to a mutation operation.',\n },\n SUBSCRIPTION: {\n value: DirectiveLocation.SUBSCRIPTION,\n description: 'Location adjacent to a subscription operation.',\n },\n FIELD: {\n value: DirectiveLocation.FIELD,\n description: 'Location adjacent to a field.',\n },\n FRAGMENT_DEFINITION: {\n value: DirectiveLocation.FRAGMENT_DEFINITION,\n description: 'Location adjacent to a fragment definition.',\n },\n FRAGMENT_SPREAD: {\n value: DirectiveLocation.FRAGMENT_SPREAD,\n description: 'Location adjacent to a fragment spread.',\n },\n INLINE_FRAGMENT: {\n value: DirectiveLocation.INLINE_FRAGMENT,\n description: 'Location adjacent to an inline fragment.',\n },\n VARIABLE_DEFINITION: {\n value: DirectiveLocation.VARIABLE_DEFINITION,\n description: 'Location adjacent to an operation variable definition.',\n },\n FRAGMENT_VARIABLE_DEFINITION: {\n value: DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION,\n description: 'Location adjacent to a fragment variable definition.',\n },\n SCHEMA: {\n value: DirectiveLocation.SCHEMA,\n description: 'Location adjacent to a schema definition.',\n },\n SCALAR: {\n value: DirectiveLocation.SCALAR,\n description: 'Location adjacent to a scalar definition.',\n },\n OBJECT: {\n value: DirectiveLocation.OBJECT,\n description: 'Location adjacent to an object type definition.',\n },\n FIELD_DEFINITION: {\n value: DirectiveLocation.FIELD_DEFINITION,\n description: 'Location adjacent to a field definition.',\n },\n ARGUMENT_DEFINITION: {\n value: DirectiveLocation.ARGUMENT_DEFINITION,\n description: 'Location adjacent to an argument definition.',\n },\n INTERFACE: {\n value: DirectiveLocation.INTERFACE,\n description: 'Location adjacent to an interface definition.',\n },\n UNION: {\n value: DirectiveLocation.UNION,\n description: 'Location adjacent to a union definition.',\n },\n ENUM: {\n value: DirectiveLocation.ENUM,\n description: 'Location adjacent to an enum definition.',\n },\n ENUM_VALUE: {\n value: DirectiveLocation.ENUM_VALUE,\n description: 'Location adjacent to an enum value definition.',\n },\n INPUT_OBJECT: {\n value: DirectiveLocation.INPUT_OBJECT,\n description: 'Location adjacent to an input object type definition.',\n },\n INPUT_FIELD_DEFINITION: {\n value: DirectiveLocation.INPUT_FIELD_DEFINITION,\n description: 'Location adjacent to an input object field definition.',\n },\n },\n});\n\nexport const __Type: GraphQLObjectType = new GraphQLObjectType({\n name: '__Type',\n description:\n 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\\n\\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',\n fields: () =>\n ({\n kind: {\n type: new GraphQLNonNull(__TypeKind),\n resolve(type) {\n if (isScalarType(type)) {\n return TypeKind.SCALAR;\n }\n if (isObjectType(type)) {\n return TypeKind.OBJECT;\n }\n if (isInterfaceType(type)) {\n return TypeKind.INTERFACE;\n }\n if (isUnionType(type)) {\n return TypeKind.UNION;\n }\n if (isEnumType(type)) {\n return TypeKind.ENUM;\n }\n if (isInputObjectType(type)) {\n return TypeKind.INPUT_OBJECT;\n }\n if (isListType(type)) {\n return TypeKind.LIST;\n }\n if (isNonNullType(type)) {\n return TypeKind.NON_NULL;\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered)\n invariant(false, `Unexpected type: \"${inspect(type)}\".`);\n },\n },\n name: {\n type: GraphQLString,\n resolve: (type) => ('name' in type ? type.name : undefined),\n },\n description: {\n type: GraphQLString,\n resolve: (type) =>\n // FIXME: add test case\n /* c8 ignore next */\n 'description' in type ? type.description : undefined,\n },\n specifiedByURL: {\n type: GraphQLString,\n resolve: (obj) =>\n 'specifiedByURL' in obj ? obj.specifiedByURL : undefined,\n },\n fields: {\n type: new GraphQLList(new GraphQLNonNull(__Field)),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(type, { includeDeprecated }) {\n if (isObjectType(type) || isInterfaceType(type)) {\n const fields = Object.values(type.getFields());\n return includeDeprecated === true\n ? fields\n : fields.filter((field) => field.deprecationReason == null);\n }\n },\n },\n interfaces: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n resolve(type) {\n if (isObjectType(type) || isInterfaceType(type)) {\n return type.getInterfaces();\n }\n },\n },\n possibleTypes: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n resolve(type, _args, _context, { schema }) {\n if (isAbstractType(type)) {\n return schema.getPossibleTypes(type);\n }\n },\n },\n enumValues: {\n type: new GraphQLList(new GraphQLNonNull(__EnumValue)),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(type, { includeDeprecated }) {\n if (isEnumType(type)) {\n const values = type.getValues();\n return includeDeprecated === true\n ? values\n : values.filter((field) => field.deprecationReason == null);\n }\n },\n },\n inputFields: {\n type: new GraphQLList(new GraphQLNonNull(__InputValue)),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(type, { includeDeprecated }) {\n if (isInputObjectType(type)) {\n const values = Object.values(type.getFields());\n return includeDeprecated === true\n ? values\n : values.filter((field) => field.deprecationReason == null);\n }\n },\n },\n ofType: {\n type: __Type,\n resolve: (type) => ('ofType' in type ? type.ofType : undefined),\n },\n isOneOf: {\n type: GraphQLBoolean,\n resolve: (type) => {\n if (isInputObjectType(type)) {\n return type.isOneOf;\n }\n },\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __Field: GraphQLObjectType = new GraphQLObjectType({\n name: '__Field',\n description:\n 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.',\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (field) => field.name,\n },\n description: {\n type: GraphQLString,\n resolve: (field) => field.description,\n },\n args: {\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__InputValue)),\n ),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(field, { includeDeprecated }) {\n return includeDeprecated === true\n ? field.args\n : field.args.filter((arg) => arg.deprecationReason == null);\n },\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: (field) => field.type,\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (field) => field.deprecationReason != null,\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: (field) => field.deprecationReason,\n },\n }) as GraphQLFieldConfigMap, unknown>,\n});\n\nexport const __InputValue: GraphQLObjectType = new GraphQLObjectType({\n name: '__InputValue',\n description:\n 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.',\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (inputValue) => inputValue.name,\n },\n description: {\n type: GraphQLString,\n resolve: (inputValue) => inputValue.description,\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: (inputValue) => inputValue.type,\n },\n defaultValue: {\n type: GraphQLString,\n description:\n 'A GraphQL-formatted string representing the default value for this input value.',\n resolve(inputValue) {\n const ast = getDefaultValueAST(inputValue);\n if (ast) {\n return print(ast);\n }\n return null;\n },\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (field) => field.deprecationReason != null,\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: (obj) => obj.deprecationReason,\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __EnumValue: GraphQLObjectType = new GraphQLObjectType({\n name: '__EnumValue',\n description:\n 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.',\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (enumValue) => enumValue.name,\n },\n description: {\n type: GraphQLString,\n resolve: (enumValue) => enumValue.description,\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (enumValue) => enumValue.deprecationReason != null,\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: (enumValue) => enumValue.deprecationReason,\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const TypeKind = {\n SCALAR: 'SCALAR' as const,\n OBJECT: 'OBJECT' as const,\n INTERFACE: 'INTERFACE' as const,\n UNION: 'UNION' as const,\n ENUM: 'ENUM' as const,\n INPUT_OBJECT: 'INPUT_OBJECT' as const,\n LIST: 'LIST' as const,\n NON_NULL: 'NON_NULL' as const,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type TypeKind = (typeof TypeKind)[keyof typeof TypeKind];\n\nexport const __TypeKind: GraphQLEnumType = new GraphQLEnumType({\n name: '__TypeKind',\n description: 'An enum describing what kind of type a given `__Type` is.',\n values: {\n SCALAR: {\n value: TypeKind.SCALAR,\n description: 'Indicates this type is a scalar.',\n },\n OBJECT: {\n value: TypeKind.OBJECT,\n description:\n 'Indicates this type is an object. `fields` and `interfaces` are valid fields.',\n },\n INTERFACE: {\n value: TypeKind.INTERFACE,\n description:\n 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.',\n },\n UNION: {\n value: TypeKind.UNION,\n description:\n 'Indicates this type is a union. `possibleTypes` is a valid field.',\n },\n ENUM: {\n value: TypeKind.ENUM,\n description:\n 'Indicates this type is an enum. `enumValues` is a valid field.',\n },\n INPUT_OBJECT: {\n value: TypeKind.INPUT_OBJECT,\n description:\n 'Indicates this type is an input object. `inputFields` is a valid field.',\n },\n LIST: {\n value: TypeKind.LIST,\n description: 'Indicates this type is a list. `ofType` is a valid field.',\n },\n NON_NULL: {\n value: TypeKind.NON_NULL,\n description:\n 'Indicates this type is a non-null. `ofType` is a valid field.',\n },\n },\n});\n\nexport const SchemaMetaFieldDef = new GraphQLField(undefined, '__schema', {\n type: new GraphQLNonNull(__Schema),\n description: 'Access the current type schema of this server.',\n resolve: (_source, _args, _context, { schema }) => schema,\n});\n\nexport const TypeMetaFieldDef = new GraphQLField(undefined, '__type', {\n type: __Type,\n description: 'Request the type information of a single type.',\n args: { name: { type: new GraphQLNonNull(GraphQLString) } },\n resolve: (_source, { name }, _context, { schema }) => schema.getType(name),\n});\n\nexport const TypeNameMetaFieldDef = new GraphQLField(undefined, '__typename', {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The name of the current Object type at runtime.',\n resolve: (_source, _args, _context, { parentType }) => parentType.name,\n});\n\nexport const introspectionTypes: ReadonlyArray =\n Object.freeze([\n __Schema,\n __Directive,\n __DirectiveLocation,\n __Type,\n __Field,\n __InputValue,\n __EnumValue,\n __TypeKind,\n ]);\n\nexport function isIntrospectionType(type: GraphQLNamedType): boolean {\n return introspectionTypes.some(({ name }) => type.name === name);\n}\n"]} \ No newline at end of file diff --git a/type/introspection.mjs b/type/introspection.mjs new file mode 100644 index 0000000000..15f775dff8 --- /dev/null +++ b/type/introspection.mjs @@ -0,0 +1,475 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { DirectiveLocation } from "../language/directiveLocation.mjs"; +import { print } from "../language/printer.mjs"; +import { getDefaultValueAST } from "../utilities/getDefaultValueAST.mjs"; +import { GraphQLEnumType, GraphQLField, GraphQLList, GraphQLNonNull, GraphQLObjectType, isAbstractType, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, } from "./definition.mjs"; +import { GraphQLBoolean, GraphQLString } from "./scalars.mjs"; +export const __Schema = new GraphQLObjectType({ + name: '__Schema', + description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', + fields: () => ({ + description: { + type: GraphQLString, + resolve: (schema) => schema.description, + }, + types: { + description: 'A list of all types supported by this server.', + type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Type))), + resolve(schema) { + return Object.values(schema.getTypeMap()); + }, + }, + queryType: { + description: 'The type that query operations will be rooted at.', + type: new GraphQLNonNull(__Type), + resolve: (schema) => schema.getQueryType(), + }, + mutationType: { + description: 'If this server supports mutation, the type that mutation operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getMutationType(), + }, + subscriptionType: { + description: 'If this server support subscription, the type that subscription operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getSubscriptionType(), + }, + directives: { + description: 'A list of all directives supported by this server.', + type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Directive))), + resolve: (schema) => schema.getDirectives(), + }, + }), +}); +export const __Directive = new GraphQLObjectType({ + name: '__Directive', + description: "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + fields: () => ({ + name: { + type: new GraphQLNonNull(GraphQLString), + resolve: (directive) => directive.name, + }, + description: { + type: GraphQLString, + resolve: (directive) => directive.description, + }, + isRepeatable: { + type: new GraphQLNonNull(GraphQLBoolean), + resolve: (directive) => directive.isRepeatable, + }, + locations: { + type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__DirectiveLocation))), + resolve: (directive) => directive.locations, + }, + args: { + type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))), + args: { + includeDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(field, { includeDeprecated }) { + return includeDeprecated === true + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + }), +}); +export const __DirectiveLocation = new GraphQLEnumType({ + name: '__DirectiveLocation', + description: 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.', + values: { + QUERY: { + value: DirectiveLocation.QUERY, + description: 'Location adjacent to a query operation.', + }, + MUTATION: { + value: DirectiveLocation.MUTATION, + description: 'Location adjacent to a mutation operation.', + }, + SUBSCRIPTION: { + value: DirectiveLocation.SUBSCRIPTION, + description: 'Location adjacent to a subscription operation.', + }, + FIELD: { + value: DirectiveLocation.FIELD, + description: 'Location adjacent to a field.', + }, + FRAGMENT_DEFINITION: { + value: DirectiveLocation.FRAGMENT_DEFINITION, + description: 'Location adjacent to a fragment definition.', + }, + FRAGMENT_SPREAD: { + value: DirectiveLocation.FRAGMENT_SPREAD, + description: 'Location adjacent to a fragment spread.', + }, + INLINE_FRAGMENT: { + value: DirectiveLocation.INLINE_FRAGMENT, + description: 'Location adjacent to an inline fragment.', + }, + VARIABLE_DEFINITION: { + value: DirectiveLocation.VARIABLE_DEFINITION, + description: 'Location adjacent to an operation variable definition.', + }, + FRAGMENT_VARIABLE_DEFINITION: { + value: DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION, + description: 'Location adjacent to a fragment variable definition.', + }, + SCHEMA: { + value: DirectiveLocation.SCHEMA, + description: 'Location adjacent to a schema definition.', + }, + SCALAR: { + value: DirectiveLocation.SCALAR, + description: 'Location adjacent to a scalar definition.', + }, + OBJECT: { + value: DirectiveLocation.OBJECT, + description: 'Location adjacent to an object type definition.', + }, + FIELD_DEFINITION: { + value: DirectiveLocation.FIELD_DEFINITION, + description: 'Location adjacent to a field definition.', + }, + ARGUMENT_DEFINITION: { + value: DirectiveLocation.ARGUMENT_DEFINITION, + description: 'Location adjacent to an argument definition.', + }, + INTERFACE: { + value: DirectiveLocation.INTERFACE, + description: 'Location adjacent to an interface definition.', + }, + UNION: { + value: DirectiveLocation.UNION, + description: 'Location adjacent to a union definition.', + }, + ENUM: { + value: DirectiveLocation.ENUM, + description: 'Location adjacent to an enum definition.', + }, + ENUM_VALUE: { + value: DirectiveLocation.ENUM_VALUE, + description: 'Location adjacent to an enum value definition.', + }, + INPUT_OBJECT: { + value: DirectiveLocation.INPUT_OBJECT, + description: 'Location adjacent to an input object type definition.', + }, + INPUT_FIELD_DEFINITION: { + value: DirectiveLocation.INPUT_FIELD_DEFINITION, + description: 'Location adjacent to an input object field definition.', + }, + }, +}); +export const __Type = new GraphQLObjectType({ + name: '__Type', + description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', + fields: () => ({ + kind: { + type: new GraphQLNonNull(__TypeKind), + resolve(type) { + if (isScalarType(type)) { + return TypeKind.SCALAR; + } + if (isObjectType(type)) { + return TypeKind.OBJECT; + } + if (isInterfaceType(type)) { + return TypeKind.INTERFACE; + } + if (isUnionType(type)) { + return TypeKind.UNION; + } + if (isEnumType(type)) { + return TypeKind.ENUM; + } + if (isInputObjectType(type)) { + return TypeKind.INPUT_OBJECT; + } + if (isListType(type)) { + return TypeKind.LIST; + } + if (isNonNullType(type)) { + return TypeKind.NON_NULL; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered) + (false) || invariant(false, `Unexpected type: "${inspect(type)}".`); + }, + }, + name: { + type: GraphQLString, + resolve: (type) => ('name' in type ? type.name : undefined), + }, + description: { + type: GraphQLString, + resolve: (type) => + // FIXME: add test case + /* c8 ignore next */ + 'description' in type ? type.description : undefined, + }, + specifiedByURL: { + type: GraphQLString, + resolve: (obj) => 'specifiedByURL' in obj ? obj.specifiedByURL : undefined, + }, + fields: { + type: new GraphQLList(new GraphQLNonNull(__Field)), + args: { + includeDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(type, { includeDeprecated }) { + if (isObjectType(type) || isInterfaceType(type)) { + const fields = Object.values(type.getFields()); + return includeDeprecated === true + ? fields + : fields.filter((field) => field.deprecationReason == null); + } + }, + }, + interfaces: { + type: new GraphQLList(new GraphQLNonNull(__Type)), + resolve(type) { + if (isObjectType(type) || isInterfaceType(type)) { + return type.getInterfaces(); + } + }, + }, + possibleTypes: { + type: new GraphQLList(new GraphQLNonNull(__Type)), + resolve(type, _args, _context, { schema }) { + if (isAbstractType(type)) { + return schema.getPossibleTypes(type); + } + }, + }, + enumValues: { + type: new GraphQLList(new GraphQLNonNull(__EnumValue)), + args: { + includeDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(type, { includeDeprecated }) { + if (isEnumType(type)) { + const values = type.getValues(); + return includeDeprecated === true + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + inputFields: { + type: new GraphQLList(new GraphQLNonNull(__InputValue)), + args: { + includeDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(type, { includeDeprecated }) { + if (isInputObjectType(type)) { + const values = Object.values(type.getFields()); + return includeDeprecated === true + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + ofType: { + type: __Type, + resolve: (type) => ('ofType' in type ? type.ofType : undefined), + }, + isOneOf: { + type: GraphQLBoolean, + resolve: (type) => { + if (isInputObjectType(type)) { + return type.isOneOf; + } + }, + }, + }), +}); +export const __Field = new GraphQLObjectType({ + name: '__Field', + description: 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.', + fields: () => ({ + name: { + type: new GraphQLNonNull(GraphQLString), + resolve: (field) => field.name, + }, + description: { + type: GraphQLString, + resolve: (field) => field.description, + }, + args: { + type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))), + args: { + includeDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + default: { value: false }, + }, + }, + resolve(field, { includeDeprecated }) { + return includeDeprecated === true + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + type: { + type: new GraphQLNonNull(__Type), + resolve: (field) => field.type, + }, + isDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: GraphQLString, + resolve: (field) => field.deprecationReason, + }, + }), +}); +export const __InputValue = new GraphQLObjectType({ + name: '__InputValue', + description: 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.', + fields: () => ({ + name: { + type: new GraphQLNonNull(GraphQLString), + resolve: (inputValue) => inputValue.name, + }, + description: { + type: GraphQLString, + resolve: (inputValue) => inputValue.description, + }, + type: { + type: new GraphQLNonNull(__Type), + resolve: (inputValue) => inputValue.type, + }, + defaultValue: { + type: GraphQLString, + description: 'A GraphQL-formatted string representing the default value for this input value.', + resolve(inputValue) { + const ast = getDefaultValueAST(inputValue); + if (ast) { + return print(ast); + } + return null; + }, + }, + isDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: GraphQLString, + resolve: (obj) => obj.deprecationReason, + }, + }), +}); +export const __EnumValue = new GraphQLObjectType({ + name: '__EnumValue', + description: 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.', + fields: () => ({ + name: { + type: new GraphQLNonNull(GraphQLString), + resolve: (enumValue) => enumValue.name, + }, + description: { + type: GraphQLString, + resolve: (enumValue) => enumValue.description, + }, + isDeprecated: { + type: new GraphQLNonNull(GraphQLBoolean), + resolve: (enumValue) => enumValue.deprecationReason != null, + }, + deprecationReason: { + type: GraphQLString, + resolve: (enumValue) => enumValue.deprecationReason, + }, + }), +}); +export const TypeKind = { + SCALAR: 'SCALAR', + OBJECT: 'OBJECT', + INTERFACE: 'INTERFACE', + UNION: 'UNION', + ENUM: 'ENUM', + INPUT_OBJECT: 'INPUT_OBJECT', + LIST: 'LIST', + NON_NULL: 'NON_NULL', +}; +export const __TypeKind = new GraphQLEnumType({ + name: '__TypeKind', + description: 'An enum describing what kind of type a given `__Type` is.', + values: { + SCALAR: { + value: TypeKind.SCALAR, + description: 'Indicates this type is a scalar.', + }, + OBJECT: { + value: TypeKind.OBJECT, + description: 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', + }, + INTERFACE: { + value: TypeKind.INTERFACE, + description: 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', + }, + UNION: { + value: TypeKind.UNION, + description: 'Indicates this type is a union. `possibleTypes` is a valid field.', + }, + ENUM: { + value: TypeKind.ENUM, + description: 'Indicates this type is an enum. `enumValues` is a valid field.', + }, + INPUT_OBJECT: { + value: TypeKind.INPUT_OBJECT, + description: 'Indicates this type is an input object. `inputFields` is a valid field.', + }, + LIST: { + value: TypeKind.LIST, + description: 'Indicates this type is a list. `ofType` is a valid field.', + }, + NON_NULL: { + value: TypeKind.NON_NULL, + description: 'Indicates this type is a non-null. `ofType` is a valid field.', + }, + }, +}); +export const SchemaMetaFieldDef = new GraphQLField(undefined, '__schema', { + type: new GraphQLNonNull(__Schema), + description: 'Access the current type schema of this server.', + resolve: (_source, _args, _context, { schema }) => schema, +}); +export const TypeMetaFieldDef = new GraphQLField(undefined, '__type', { + type: __Type, + description: 'Request the type information of a single type.', + args: { name: { type: new GraphQLNonNull(GraphQLString) } }, + resolve: (_source, { name }, _context, { schema }) => schema.getType(name), +}); +export const TypeNameMetaFieldDef = new GraphQLField(undefined, '__typename', { + type: new GraphQLNonNull(GraphQLString), + description: 'The name of the current Object type at runtime.', + resolve: (_source, _args, _context, { parentType }) => parentType.name, +}); +export const introspectionTypes = Object.freeze([ + __Schema, + __Directive, + __DirectiveLocation, + __Type, + __Field, + __InputValue, + __EnumValue, + __TypeKind, +]); +export function isIntrospectionType(type) { + return introspectionTypes.some(({ name }) => type.name === name); +} +//# sourceMappingURL=introspection.js.map \ No newline at end of file diff --git a/type/introspection.mjs.map b/type/introspection.mjs.map new file mode 100644 index 0000000000..d2fdc035c1 --- /dev/null +++ b/type/introspection.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"introspection.js","sourceRoot":"","sources":["../../src/type/introspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,0CAAyC;AACrE,OAAO,EAAE,KAAK,EAAE,gCAA+B;AAE/C,OAAO,EAAE,kBAAkB,EAAE,4CAA2C;AASxE,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,yBAAwB;AAEzB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,sBAAqB;AAG7D,MAAM,CAAC,MAAM,QAAQ,GAAsB,IAAI,iBAAiB,CAAC;IAC/D,IAAI,EAAE,UAAU;IAChB,WAAW,EACT,2MAA2M;IAC7M,MAAM,EAAE,GAAG,EAAE,CACX,CAAC;QACC,WAAW,EAAE;YACX,IAAI,EAAE,aAAa;YACnB,O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DAAgD;IAC7D,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE;IAC3D,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;CAC3E,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE;IAC5E,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC;IACvC,WAAW,EAAE,iDAAiD;IAC9D,OAAO,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI;CACvE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAC7B,MAAM,CAAC,MAAM,CAAC;IACZ,QAAQ;IACR,WAAW;IACX,mBAAmB;IACnB,MAAM;IACN,OAAO;IACP,YAAY;IACZ,WAAW;IACX,UAAU;CACX,CAAC,CAAC;AAEL,MAAM,UAAU,mBAAmB,CAAC,IAAsB;IACxD,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\n\nimport { DirectiveLocation } from '../language/directiveLocation.js';\nimport { print } from '../language/printer.js';\n\nimport { getDefaultValueAST } from '../utilities/getDefaultValueAST.js';\n\nimport type {\n GraphQLEnumValue,\n GraphQLFieldConfigMap,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLType,\n} from './definition.js';\nimport {\n GraphQLEnumType,\n GraphQLField,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isListType,\n isNonNullType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from './definition.js';\nimport type { GraphQLDirective } from './directives.js';\nimport { GraphQLBoolean, GraphQLString } from './scalars.js';\nimport type { GraphQLSchema } from './schema.js';\n\nexport const __Schema: GraphQLObjectType = new GraphQLObjectType({\n name: '__Schema',\n description:\n 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.',\n fields: () =>\n ({\n description: {\n type: GraphQLString,\n resolve: (schema) => schema.description,\n },\n types: {\n description: 'A list of all types supported by this server.',\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Type))),\n resolve(schema) {\n return Object.values(schema.getTypeMap());\n },\n },\n queryType: {\n description: 'The type that query operations will be rooted at.',\n type: new GraphQLNonNull(__Type),\n resolve: (schema) => schema.getQueryType(),\n },\n mutationType: {\n description:\n 'If this server supports mutation, the type that mutation operations will be rooted at.',\n type: __Type,\n resolve: (schema) => schema.getMutationType(),\n },\n subscriptionType: {\n description:\n 'If this server support subscription, the type that subscription operations will be rooted at.',\n type: __Type,\n resolve: (schema) => schema.getSubscriptionType(),\n },\n directives: {\n description: 'A list of all directives supported by this server.',\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__Directive)),\n ),\n resolve: (schema) => schema.getDirectives(),\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __Directive: GraphQLObjectType = new GraphQLObjectType({\n name: '__Directive',\n description:\n \"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\\n\\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.\",\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (directive) => directive.name,\n },\n description: {\n type: GraphQLString,\n resolve: (directive) => directive.description,\n },\n isRepeatable: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (directive) => directive.isRepeatable,\n },\n locations: {\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__DirectiveLocation)),\n ),\n resolve: (directive) => directive.locations,\n },\n args: {\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__InputValue)),\n ),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(field, { includeDeprecated }) {\n return includeDeprecated === true\n ? field.args\n : field.args.filter((arg) => arg.deprecationReason == null);\n },\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __DirectiveLocation: GraphQLEnumType = new GraphQLEnumType({\n name: '__DirectiveLocation',\n description:\n 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.',\n values: {\n QUERY: {\n value: DirectiveLocation.QUERY,\n description: 'Location adjacent to a query operation.',\n },\n MUTATION: {\n value: DirectiveLocation.MUTATION,\n description: 'Location adjacent to a mutation operation.',\n },\n SUBSCRIPTION: {\n value: DirectiveLocation.SUBSCRIPTION,\n description: 'Location adjacent to a subscription operation.',\n },\n FIELD: {\n value: DirectiveLocation.FIELD,\n description: 'Location adjacent to a field.',\n },\n FRAGMENT_DEFINITION: {\n value: DirectiveLocation.FRAGMENT_DEFINITION,\n description: 'Location adjacent to a fragment definition.',\n },\n FRAGMENT_SPREAD: {\n value: DirectiveLocation.FRAGMENT_SPREAD,\n description: 'Location adjacent to a fragment spread.',\n },\n INLINE_FRAGMENT: {\n value: DirectiveLocation.INLINE_FRAGMENT,\n description: 'Location adjacent to an inline fragment.',\n },\n VARIABLE_DEFINITION: {\n value: DirectiveLocation.VARIABLE_DEFINITION,\n description: 'Location adjacent to an operation variable definition.',\n },\n FRAGMENT_VARIABLE_DEFINITION: {\n value: DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION,\n description: 'Location adjacent to a fragment variable definition.',\n },\n SCHEMA: {\n value: DirectiveLocation.SCHEMA,\n description: 'Location adjacent to a schema definition.',\n },\n SCALAR: {\n value: DirectiveLocation.SCALAR,\n description: 'Location adjacent to a scalar definition.',\n },\n OBJECT: {\n value: DirectiveLocation.OBJECT,\n description: 'Location adjacent to an object type definition.',\n },\n FIELD_DEFINITION: {\n value: DirectiveLocation.FIELD_DEFINITION,\n description: 'Location adjacent to a field definition.',\n },\n ARGUMENT_DEFINITION: {\n value: DirectiveLocation.ARGUMENT_DEFINITION,\n description: 'Location adjacent to an argument definition.',\n },\n INTERFACE: {\n value: DirectiveLocation.INTERFACE,\n description: 'Location adjacent to an interface definition.',\n },\n UNION: {\n value: DirectiveLocation.UNION,\n description: 'Location adjacent to a union definition.',\n },\n ENUM: {\n value: DirectiveLocation.ENUM,\n description: 'Location adjacent to an enum definition.',\n },\n ENUM_VALUE: {\n value: DirectiveLocation.ENUM_VALUE,\n description: 'Location adjacent to an enum value definition.',\n },\n INPUT_OBJECT: {\n value: DirectiveLocation.INPUT_OBJECT,\n description: 'Location adjacent to an input object type definition.',\n },\n INPUT_FIELD_DEFINITION: {\n value: DirectiveLocation.INPUT_FIELD_DEFINITION,\n description: 'Location adjacent to an input object field definition.',\n },\n },\n});\n\nexport const __Type: GraphQLObjectType = new GraphQLObjectType({\n name: '__Type',\n description:\n 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\\n\\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',\n fields: () =>\n ({\n kind: {\n type: new GraphQLNonNull(__TypeKind),\n resolve(type) {\n if (isScalarType(type)) {\n return TypeKind.SCALAR;\n }\n if (isObjectType(type)) {\n return TypeKind.OBJECT;\n }\n if (isInterfaceType(type)) {\n return TypeKind.INTERFACE;\n }\n if (isUnionType(type)) {\n return TypeKind.UNION;\n }\n if (isEnumType(type)) {\n return TypeKind.ENUM;\n }\n if (isInputObjectType(type)) {\n return TypeKind.INPUT_OBJECT;\n }\n if (isListType(type)) {\n return TypeKind.LIST;\n }\n if (isNonNullType(type)) {\n return TypeKind.NON_NULL;\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered)\n invariant(false, `Unexpected type: \"${inspect(type)}\".`);\n },\n },\n name: {\n type: GraphQLString,\n resolve: (type) => ('name' in type ? type.name : undefined),\n },\n description: {\n type: GraphQLString,\n resolve: (type) =>\n // FIXME: add test case\n /* c8 ignore next */\n 'description' in type ? type.description : undefined,\n },\n specifiedByURL: {\n type: GraphQLString,\n resolve: (obj) =>\n 'specifiedByURL' in obj ? obj.specifiedByURL : undefined,\n },\n fields: {\n type: new GraphQLList(new GraphQLNonNull(__Field)),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(type, { includeDeprecated }) {\n if (isObjectType(type) || isInterfaceType(type)) {\n const fields = Object.values(type.getFields());\n return includeDeprecated === true\n ? fields\n : fields.filter((field) => field.deprecationReason == null);\n }\n },\n },\n interfaces: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n resolve(type) {\n if (isObjectType(type) || isInterfaceType(type)) {\n return type.getInterfaces();\n }\n },\n },\n possibleTypes: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n resolve(type, _args, _context, { schema }) {\n if (isAbstractType(type)) {\n return schema.getPossibleTypes(type);\n }\n },\n },\n enumValues: {\n type: new GraphQLList(new GraphQLNonNull(__EnumValue)),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(type, { includeDeprecated }) {\n if (isEnumType(type)) {\n const values = type.getValues();\n return includeDeprecated === true\n ? values\n : values.filter((field) => field.deprecationReason == null);\n }\n },\n },\n inputFields: {\n type: new GraphQLList(new GraphQLNonNull(__InputValue)),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(type, { includeDeprecated }) {\n if (isInputObjectType(type)) {\n const values = Object.values(type.getFields());\n return includeDeprecated === true\n ? values\n : values.filter((field) => field.deprecationReason == null);\n }\n },\n },\n ofType: {\n type: __Type,\n resolve: (type) => ('ofType' in type ? type.ofType : undefined),\n },\n isOneOf: {\n type: GraphQLBoolean,\n resolve: (type) => {\n if (isInputObjectType(type)) {\n return type.isOneOf;\n }\n },\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __Field: GraphQLObjectType = new GraphQLObjectType({\n name: '__Field',\n description:\n 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.',\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (field) => field.name,\n },\n description: {\n type: GraphQLString,\n resolve: (field) => field.description,\n },\n args: {\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(__InputValue)),\n ),\n args: {\n includeDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n default: { value: false },\n },\n },\n resolve(field, { includeDeprecated }) {\n return includeDeprecated === true\n ? field.args\n : field.args.filter((arg) => arg.deprecationReason == null);\n },\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: (field) => field.type,\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (field) => field.deprecationReason != null,\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: (field) => field.deprecationReason,\n },\n }) as GraphQLFieldConfigMap, unknown>,\n});\n\nexport const __InputValue: GraphQLObjectType = new GraphQLObjectType({\n name: '__InputValue',\n description:\n 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.',\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (inputValue) => inputValue.name,\n },\n description: {\n type: GraphQLString,\n resolve: (inputValue) => inputValue.description,\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: (inputValue) => inputValue.type,\n },\n defaultValue: {\n type: GraphQLString,\n description:\n 'A GraphQL-formatted string representing the default value for this input value.',\n resolve(inputValue) {\n const ast = getDefaultValueAST(inputValue);\n if (ast) {\n return print(ast);\n }\n return null;\n },\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (field) => field.deprecationReason != null,\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: (obj) => obj.deprecationReason,\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const __EnumValue: GraphQLObjectType = new GraphQLObjectType({\n name: '__EnumValue',\n description:\n 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.',\n fields: () =>\n ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: (enumValue) => enumValue.name,\n },\n description: {\n type: GraphQLString,\n resolve: (enumValue) => enumValue.description,\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: (enumValue) => enumValue.deprecationReason != null,\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: (enumValue) => enumValue.deprecationReason,\n },\n }) as GraphQLFieldConfigMap,\n});\n\nexport const TypeKind = {\n SCALAR: 'SCALAR' as const,\n OBJECT: 'OBJECT' as const,\n INTERFACE: 'INTERFACE' as const,\n UNION: 'UNION' as const,\n ENUM: 'ENUM' as const,\n INPUT_OBJECT: 'INPUT_OBJECT' as const,\n LIST: 'LIST' as const,\n NON_NULL: 'NON_NULL' as const,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type TypeKind = (typeof TypeKind)[keyof typeof TypeKind];\n\nexport const __TypeKind: GraphQLEnumType = new GraphQLEnumType({\n name: '__TypeKind',\n description: 'An enum describing what kind of type a given `__Type` is.',\n values: {\n SCALAR: {\n value: TypeKind.SCALAR,\n description: 'Indicates this type is a scalar.',\n },\n OBJECT: {\n value: TypeKind.OBJECT,\n description:\n 'Indicates this type is an object. `fields` and `interfaces` are valid fields.',\n },\n INTERFACE: {\n value: TypeKind.INTERFACE,\n description:\n 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.',\n },\n UNION: {\n value: TypeKind.UNION,\n description:\n 'Indicates this type is a union. `possibleTypes` is a valid field.',\n },\n ENUM: {\n value: TypeKind.ENUM,\n description:\n 'Indicates this type is an enum. `enumValues` is a valid field.',\n },\n INPUT_OBJECT: {\n value: TypeKind.INPUT_OBJECT,\n description:\n 'Indicates this type is an input object. `inputFields` is a valid field.',\n },\n LIST: {\n value: TypeKind.LIST,\n description: 'Indicates this type is a list. `ofType` is a valid field.',\n },\n NON_NULL: {\n value: TypeKind.NON_NULL,\n description:\n 'Indicates this type is a non-null. `ofType` is a valid field.',\n },\n },\n});\n\nexport const SchemaMetaFieldDef = new GraphQLField(undefined, '__schema', {\n type: new GraphQLNonNull(__Schema),\n description: 'Access the current type schema of this server.',\n resolve: (_source, _args, _context, { schema }) => schema,\n});\n\nexport const TypeMetaFieldDef = new GraphQLField(undefined, '__type', {\n type: __Type,\n description: 'Request the type information of a single type.',\n args: { name: { type: new GraphQLNonNull(GraphQLString) } },\n resolve: (_source, { name }, _context, { schema }) => schema.getType(name),\n});\n\nexport const TypeNameMetaFieldDef = new GraphQLField(undefined, '__typename', {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The name of the current Object type at runtime.',\n resolve: (_source, _args, _context, { parentType }) => parentType.name,\n});\n\nexport const introspectionTypes: ReadonlyArray =\n Object.freeze([\n __Schema,\n __Directive,\n __DirectiveLocation,\n __Type,\n __Field,\n __InputValue,\n __EnumValue,\n __TypeKind,\n ]);\n\nexport function isIntrospectionType(type: GraphQLNamedType): boolean {\n return introspectionTypes.some(({ name }) => type.name === name);\n}\n"]} \ No newline at end of file diff --git a/type/scalars.d.ts b/type/scalars.d.ts new file mode 100644 index 0000000000..947fd93d21 --- /dev/null +++ b/type/scalars.d.ts @@ -0,0 +1,19 @@ +import type { GraphQLNamedType } from './definition.js'; +import { GraphQLScalarType } from './definition.js'; +/** + * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1 + * */ +export declare const GRAPHQL_MAX_INT = 2147483647; +/** + * Minimum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1) + * */ +export declare const GRAPHQL_MIN_INT = -2147483648; +export declare const GraphQLInt: GraphQLScalarType; +export declare const GraphQLFloat: GraphQLScalarType; +export declare const GraphQLString: GraphQLScalarType; +export declare const GraphQLBoolean: GraphQLScalarType; +export declare const GraphQLID: GraphQLScalarType; +export declare const specifiedScalarTypes: ReadonlyArray; +export declare function isSpecifiedScalarType(type: GraphQLNamedType): boolean; diff --git a/type/scalars.js b/type/scalars.js new file mode 100644 index 0000000000..9555e36040 --- /dev/null +++ b/type/scalars.js @@ -0,0 +1,243 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.specifiedScalarTypes = exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = exports.GRAPHQL_MIN_INT = exports.GRAPHQL_MAX_INT = void 0; +exports.isSpecifiedScalarType = isSpecifiedScalarType; +const inspect_js_1 = require("../jsutils/inspect.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const kinds_js_1 = require("../language/kinds.js"); +const printer_js_1 = require("../language/printer.js"); +const valueToLiteral_js_1 = require("../utilities/valueToLiteral.js"); +const definition_js_1 = require("./definition.js"); +/** + * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1 + * */ +exports.GRAPHQL_MAX_INT = 2147483647; +/** + * Minimum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1) + * */ +exports.GRAPHQL_MIN_INT = -2147483648; +exports.GraphQLInt = new definition_js_1.GraphQLScalarType({ + name: 'Int', + description: 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + let num = coercedValue; + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + if (typeof num !== 'number' || !Number.isInteger(num)) { + throw new GraphQLError_js_1.GraphQLError(`Int cannot represent non-integer value: ${(0, inspect_js_1.inspect)(coercedValue)}`); + } + if (num > exports.GRAPHQL_MAX_INT || num < exports.GRAPHQL_MIN_INT) { + throw new GraphQLError_js_1.GraphQLError('Int cannot represent non 32-bit signed integer value: ' + + (0, inspect_js_1.inspect)(coercedValue)); + } + return num; + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) { + throw new GraphQLError_js_1.GraphQLError(`Int cannot represent non-integer value: ${(0, inspect_js_1.inspect)(inputValue)}`); + } + if (inputValue > exports.GRAPHQL_MAX_INT || inputValue < exports.GRAPHQL_MIN_INT) { + throw new GraphQLError_js_1.GraphQLError(`Int cannot represent non 32-bit signed integer value: ${inputValue}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== kinds_js_1.Kind.INT) { + throw new GraphQLError_js_1.GraphQLError(`Int cannot represent non-integer value: ${(0, printer_js_1.print)(valueNode)}`, { nodes: valueNode }); + } + const num = parseInt(valueNode.value, 10); + if (num > exports.GRAPHQL_MAX_INT || num < exports.GRAPHQL_MIN_INT) { + throw new GraphQLError_js_1.GraphQLError(`Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, { nodes: valueNode }); + } + return num; + }, + valueToLiteral(value) { + if (typeof value === 'number' && + Number.isInteger(value) && + value <= exports.GRAPHQL_MAX_INT && + value >= exports.GRAPHQL_MIN_INT) { + return { kind: kinds_js_1.Kind.INT, value: String(value) }; + } + }, +}); +exports.GraphQLFloat = new definition_js_1.GraphQLScalarType({ + name: 'Float', + description: 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + let num = coercedValue; + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + if (typeof num !== 'number' || !Number.isFinite(num)) { + throw new GraphQLError_js_1.GraphQLError(`Float cannot represent non numeric value: ${(0, inspect_js_1.inspect)(coercedValue)}`); + } + return num; + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) { + throw new GraphQLError_js_1.GraphQLError(`Float cannot represent non numeric value: ${(0, inspect_js_1.inspect)(inputValue)}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== kinds_js_1.Kind.FLOAT && valueNode.kind !== kinds_js_1.Kind.INT) { + throw new GraphQLError_js_1.GraphQLError(`Float cannot represent non numeric value: ${(0, printer_js_1.print)(valueNode)}`, { nodes: valueNode }); + } + return parseFloat(valueNode.value); + }, + valueToLiteral(value) { + const literal = (0, valueToLiteral_js_1.defaultScalarValueToLiteral)(value); + if (literal.kind === kinds_js_1.Kind.FLOAT || literal.kind === kinds_js_1.Kind.INT) { + return literal; + } + }, +}); +exports.GraphQLString = new definition_js_1.GraphQLScalarType({ + name: 'String', + description: 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + // Coerces string, boolean and number values to a string, but do not + // attempt to coerce object, function, symbol, or other types as strings. + if (typeof coercedValue === 'string') { + return coercedValue; + } + if (typeof coercedValue === 'boolean') { + return coercedValue ? 'true' : 'false'; + } + if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) { + return coercedValue.toString(); + } + throw new GraphQLError_js_1.GraphQLError(`String cannot represent value: ${(0, inspect_js_1.inspect)(outputValue)}`); + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'string') { + throw new GraphQLError_js_1.GraphQLError(`String cannot represent a non string value: ${(0, inspect_js_1.inspect)(inputValue)}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== kinds_js_1.Kind.STRING) { + throw new GraphQLError_js_1.GraphQLError(`String cannot represent a non string value: ${(0, printer_js_1.print)(valueNode)}`, { nodes: valueNode }); + } + return valueNode.value; + }, + valueToLiteral(value) { + const literal = (0, valueToLiteral_js_1.defaultScalarValueToLiteral)(value); + if (literal.kind === kinds_js_1.Kind.STRING) { + return literal; + } + }, +}); +exports.GraphQLBoolean = new definition_js_1.GraphQLScalarType({ + name: 'Boolean', + description: 'The `Boolean` scalar type represents `true` or `false`.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'boolean') { + return coercedValue; + } + if (Number.isFinite(coercedValue)) { + return coercedValue !== 0; + } + throw new GraphQLError_js_1.GraphQLError(`Boolean cannot represent a non boolean value: ${(0, inspect_js_1.inspect)(coercedValue)}`); + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'boolean') { + throw new GraphQLError_js_1.GraphQLError(`Boolean cannot represent a non boolean value: ${(0, inspect_js_1.inspect)(inputValue)}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== kinds_js_1.Kind.BOOLEAN) { + throw new GraphQLError_js_1.GraphQLError(`Boolean cannot represent a non boolean value: ${(0, printer_js_1.print)(valueNode)}`, { nodes: valueNode }); + } + return valueNode.value; + }, + valueToLiteral(value) { + const literal = (0, valueToLiteral_js_1.defaultScalarValueToLiteral)(value); + if (literal.kind === kinds_js_1.Kind.BOOLEAN) { + return literal; + } + }, +}); +exports.GraphQLID = new definition_js_1.GraphQLScalarType({ + name: 'ID', + description: 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'string') { + return coercedValue; + } + if (Number.isInteger(coercedValue)) { + return String(coercedValue); + } + throw new GraphQLError_js_1.GraphQLError(`ID cannot represent value: ${(0, inspect_js_1.inspect)(outputValue)}`); + }, + coerceInputValue(inputValue) { + if (typeof inputValue === 'string') { + return inputValue; + } + if (typeof inputValue === 'number' && Number.isInteger(inputValue)) { + return inputValue.toString(); + } + throw new GraphQLError_js_1.GraphQLError(`ID cannot represent value: ${(0, inspect_js_1.inspect)(inputValue)}`); + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== kinds_js_1.Kind.STRING && valueNode.kind !== kinds_js_1.Kind.INT) { + throw new GraphQLError_js_1.GraphQLError('ID cannot represent a non-string and non-integer value: ' + + (0, printer_js_1.print)(valueNode), { nodes: valueNode }); + } + return valueNode.value; + }, + valueToLiteral(value) { + // ID types can use number values and Int literals. + const stringValue = Number.isInteger(value) ? String(value) : value; + if (typeof stringValue === 'string') { + // Will parse as an IntValue. + return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue) + ? { kind: kinds_js_1.Kind.INT, value: stringValue } + : { kind: kinds_js_1.Kind.STRING, value: stringValue, block: false }; + } + }, +}); +exports.specifiedScalarTypes = Object.freeze([ + exports.GraphQLString, + exports.GraphQLInt, + exports.GraphQLFloat, + exports.GraphQLBoolean, + exports.GraphQLID, +]); +function isSpecifiedScalarType(type) { + return exports.specifiedScalarTypes.some(({ name }) => type.name === name); +} +// Support coercing objects with custom valueOf() or toJSON() functions - +// a common way to represent a complex value which can be represented as +// a string (ex: MongoDB id objects). +function coerceOutputValueObject(outputValue) { + if ((0, isObjectLike_js_1.isObjectLike)(outputValue)) { + if (typeof outputValue.valueOf === 'function') { + const valueOfResult = outputValue.valueOf(); + if (!(0, isObjectLike_js_1.isObjectLike)(valueOfResult)) { + return valueOfResult; + } + } + if (typeof outputValue.toJSON === 'function') { + return outputValue.toJSON(); + } + } + return outputValue; +} +//# sourceMappingURL=scalars.js.map \ No newline at end of file diff --git a/type/scalars.js.map b/type/scalars.js.map new file mode 100644 index 0000000000..73d40875da --- /dev/null +++ b/type/scalars.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scalars.js","sourceRoot":"","sources":["../../src/type/scalars.ts"],"names":[],"mappings":";;;AA+SA,sDAEC;AAjTD,sDAAgD;AAChD,gEAA0D;AAE1D,8DAAwD;AAExD,mDAA4C;AAC5C,uDAA+C;AAE/C,sEAA6E;AAG7E,mDAAoD;AAEpD;;;KAGK;AACQ,QAAA,eAAe,GAAG,UAAU,CAAC;AAE1C;;;KAGK;AACQ,QAAA,eAAe,GAAG,CAAC,UAAU,CAAC;AAE9B,QAAA,UAAU,GAAG,IAAI,iCAAiB,CAAS;IACtD,IAAI,EAAE,KAAK;IACX,WAAW,EACT,qIAAqI;IAEvI,iBAAiB,CAAC,WAAW;QAC3B,MAAM,YAAY,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAE1D,IAAI,OAAO,YAAY,KAAK,SAAS,EAAE,CAAC;YACtC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,GAAG,GAAG,YAAY,CAAC;QACvB,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,EAAE,EAAE,CAAC;YAC5D,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,8BAAY,CACpB,2CAA2C,IAAA,oBAAO,EAAC,YAAY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V,oBAAY;IACZ,sBAAc;IACd,iBAAS;CACV,CAAC,CAAC;AAEL,SAAgB,qBAAqB,CAAC,IAAsB;IAC1D,OAAO,4BAAoB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACrE,CAAC;AAED,yEAAyE;AACzE,wEAAwE;AACxE,qCAAqC;AACrC,SAAS,uBAAuB,CAAC,WAAoB;IACnD,IAAI,IAAA,8BAAY,EAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YAC9C,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC;YAC5C,IAAI,CAAC,IAAA,8BAAY,EAAC,aAAa,CAAC,EAAE,CAAC;gBACjC,OAAO,aAAa,CAAC;YACvB,CAAC;QACH,CAAC;QACD,IAAI,OAAO,WAAW,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAC7C,OAAO,WAAW,CAAC,MAAM,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport { defaultScalarValueToLiteral } from '../utilities/valueToLiteral.js';\n\nimport type { GraphQLNamedType } from './definition.js';\nimport { GraphQLScalarType } from './definition.js';\n\n/**\n * Maximum possible Int value as per GraphQL Spec (32-bit signed integer).\n * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1\n * */\nexport const GRAPHQL_MAX_INT = 2147483647;\n\n/**\n * Minimum possible Int value as per GraphQL Spec (32-bit signed integer).\n * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1)\n * */\nexport const GRAPHQL_MIN_INT = -2147483648;\n\nexport const GraphQLInt = new GraphQLScalarType({\n name: 'Int',\n description:\n 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isInteger(num)) {\n throw new GraphQLError(\n `Int cannot represent non-integer value: ${inspect(coercedValue)}`,\n );\n }\n if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {\n throw new GraphQLError(\n 'Int cannot represent non 32-bit signed integer value: ' +\n inspect(coercedValue),\n );\n }\n return num;\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) {\n throw new GraphQLError(\n `Int cannot represent non-integer value: ${inspect(inputValue)}`,\n );\n }\n if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) {\n throw new GraphQLError(\n `Int cannot represent non 32-bit signed integer value: ${inputValue}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.INT) {\n throw new GraphQLError(\n `Int cannot represent non-integer value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n const num = parseInt(valueNode.value, 10);\n if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {\n throw new GraphQLError(\n `Int cannot represent non 32-bit signed integer value: ${valueNode.value}`,\n { nodes: valueNode },\n );\n }\n return num;\n },\n valueToLiteral(value) {\n if (\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value <= GRAPHQL_MAX_INT &&\n value >= GRAPHQL_MIN_INT\n ) {\n return { kind: Kind.INT, value: String(value) };\n }\n },\n});\n\nexport const GraphQLFloat = new GraphQLScalarType({\n name: 'Float',\n description:\n 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isFinite(num)) {\n throw new GraphQLError(\n `Float cannot represent non numeric value: ${inspect(coercedValue)}`,\n );\n }\n return num;\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) {\n throw new GraphQLError(\n `Float cannot represent non numeric value: ${inspect(inputValue)}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.FLOAT && valueNode.kind !== Kind.INT) {\n throw new GraphQLError(\n `Float cannot represent non numeric value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n return parseFloat(valueNode.value);\n },\n valueToLiteral(value) {\n const literal = defaultScalarValueToLiteral(value);\n if (literal.kind === Kind.FLOAT || literal.kind === Kind.INT) {\n return literal;\n }\n },\n});\n\nexport const GraphQLString = new GraphQLScalarType({\n name: 'String',\n description:\n 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n // Coerces string, boolean and number values to a string, but do not\n // attempt to coerce object, function, symbol, or other types as strings.\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 'true' : 'false';\n }\n if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) {\n return coercedValue.toString();\n }\n throw new GraphQLError(\n `String cannot represent value: ${inspect(outputValue)}`,\n );\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'string') {\n throw new GraphQLError(\n `String cannot represent a non string value: ${inspect(inputValue)}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING) {\n throw new GraphQLError(\n `String cannot represent a non string value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n return valueNode.value;\n },\n valueToLiteral(value) {\n const literal = defaultScalarValueToLiteral(value);\n if (literal.kind === Kind.STRING) {\n return literal;\n }\n },\n});\n\nexport const GraphQLBoolean = new GraphQLScalarType({\n name: 'Boolean',\n description: 'The `Boolean` scalar type represents `true` or `false`.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue;\n }\n if (Number.isFinite(coercedValue)) {\n return coercedValue !== 0;\n }\n throw new GraphQLError(\n `Boolean cannot represent a non boolean value: ${inspect(coercedValue)}`,\n );\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'boolean') {\n throw new GraphQLError(\n `Boolean cannot represent a non boolean value: ${inspect(inputValue)}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.BOOLEAN) {\n throw new GraphQLError(\n `Boolean cannot represent a non boolean value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n return valueNode.value;\n },\n valueToLiteral(value) {\n const literal = defaultScalarValueToLiteral(value);\n if (literal.kind === Kind.BOOLEAN) {\n return literal;\n }\n },\n});\n\nexport const GraphQLID = new GraphQLScalarType({\n name: 'ID',\n description:\n 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n if (Number.isInteger(coercedValue)) {\n return String(coercedValue);\n }\n throw new GraphQLError(\n `ID cannot represent value: ${inspect(outputValue)}`,\n );\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue === 'string') {\n return inputValue;\n }\n if (typeof inputValue === 'number' && Number.isInteger(inputValue)) {\n return inputValue.toString();\n }\n throw new GraphQLError(`ID cannot represent value: ${inspect(inputValue)}`);\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING && valueNode.kind !== Kind.INT) {\n throw new GraphQLError(\n 'ID cannot represent a non-string and non-integer value: ' +\n print(valueNode),\n { nodes: valueNode },\n );\n }\n return valueNode.value;\n },\n valueToLiteral(value) {\n // ID types can use number values and Int literals.\n const stringValue = Number.isInteger(value) ? String(value) : value;\n if (typeof stringValue === 'string') {\n // Will parse as an IntValue.\n return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue)\n ? { kind: Kind.INT, value: stringValue }\n : { kind: Kind.STRING, value: stringValue, block: false };\n }\n },\n});\n\nexport const specifiedScalarTypes: ReadonlyArray =\n Object.freeze([\n GraphQLString,\n GraphQLInt,\n GraphQLFloat,\n GraphQLBoolean,\n GraphQLID,\n ]);\n\nexport function isSpecifiedScalarType(type: GraphQLNamedType): boolean {\n return specifiedScalarTypes.some(({ name }) => type.name === name);\n}\n\n// Support coercing objects with custom valueOf() or toJSON() functions -\n// a common way to represent a complex value which can be represented as\n// a string (ex: MongoDB id objects).\nfunction coerceOutputValueObject(outputValue: unknown): unknown {\n if (isObjectLike(outputValue)) {\n if (typeof outputValue.valueOf === 'function') {\n const valueOfResult = outputValue.valueOf();\n if (!isObjectLike(valueOfResult)) {\n return valueOfResult;\n }\n }\n if (typeof outputValue.toJSON === 'function') {\n return outputValue.toJSON();\n }\n }\n return outputValue;\n}\n"]} \ No newline at end of file diff --git a/type/scalars.mjs b/type/scalars.mjs new file mode 100644 index 0000000000..2b0275ee35 --- /dev/null +++ b/type/scalars.mjs @@ -0,0 +1,239 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { print } from "../language/printer.mjs"; +import { defaultScalarValueToLiteral } from "../utilities/valueToLiteral.mjs"; +import { GraphQLScalarType } from "./definition.mjs"; +/** + * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1 + * */ +export const GRAPHQL_MAX_INT = 2147483647; +/** + * Minimum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1) + * */ +export const GRAPHQL_MIN_INT = -2147483648; +export const GraphQLInt = new GraphQLScalarType({ + name: 'Int', + description: 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + let num = coercedValue; + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + if (typeof num !== 'number' || !Number.isInteger(num)) { + throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(coercedValue)}`); + } + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new GraphQLError('Int cannot represent non 32-bit signed integer value: ' + + inspect(coercedValue)); + } + return num; + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) { + throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(inputValue)}`); + } + if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) { + throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${inputValue}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== Kind.INT) { + throw new GraphQLError(`Int cannot represent non-integer value: ${print(valueNode)}`, { nodes: valueNode }); + } + const num = parseInt(valueNode.value, 10); + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, { nodes: valueNode }); + } + return num; + }, + valueToLiteral(value) { + if (typeof value === 'number' && + Number.isInteger(value) && + value <= GRAPHQL_MAX_INT && + value >= GRAPHQL_MIN_INT) { + return { kind: Kind.INT, value: String(value) }; + } + }, +}); +export const GraphQLFloat = new GraphQLScalarType({ + name: 'Float', + description: 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + let num = coercedValue; + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + if (typeof num !== 'number' || !Number.isFinite(num)) { + throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(coercedValue)}`); + } + return num; + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) { + throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(inputValue)}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== Kind.FLOAT && valueNode.kind !== Kind.INT) { + throw new GraphQLError(`Float cannot represent non numeric value: ${print(valueNode)}`, { nodes: valueNode }); + } + return parseFloat(valueNode.value); + }, + valueToLiteral(value) { + const literal = defaultScalarValueToLiteral(value); + if (literal.kind === Kind.FLOAT || literal.kind === Kind.INT) { + return literal; + } + }, +}); +export const GraphQLString = new GraphQLScalarType({ + name: 'String', + description: 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + // Coerces string, boolean and number values to a string, but do not + // attempt to coerce object, function, symbol, or other types as strings. + if (typeof coercedValue === 'string') { + return coercedValue; + } + if (typeof coercedValue === 'boolean') { + return coercedValue ? 'true' : 'false'; + } + if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) { + return coercedValue.toString(); + } + throw new GraphQLError(`String cannot represent value: ${inspect(outputValue)}`); + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'string') { + throw new GraphQLError(`String cannot represent a non string value: ${inspect(inputValue)}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== Kind.STRING) { + throw new GraphQLError(`String cannot represent a non string value: ${print(valueNode)}`, { nodes: valueNode }); + } + return valueNode.value; + }, + valueToLiteral(value) { + const literal = defaultScalarValueToLiteral(value); + if (literal.kind === Kind.STRING) { + return literal; + } + }, +}); +export const GraphQLBoolean = new GraphQLScalarType({ + name: 'Boolean', + description: 'The `Boolean` scalar type represents `true` or `false`.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'boolean') { + return coercedValue; + } + if (Number.isFinite(coercedValue)) { + return coercedValue !== 0; + } + throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(coercedValue)}`); + }, + coerceInputValue(inputValue) { + if (typeof inputValue !== 'boolean') { + throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(inputValue)}`); + } + return inputValue; + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== Kind.BOOLEAN) { + throw new GraphQLError(`Boolean cannot represent a non boolean value: ${print(valueNode)}`, { nodes: valueNode }); + } + return valueNode.value; + }, + valueToLiteral(value) { + const literal = defaultScalarValueToLiteral(value); + if (literal.kind === Kind.BOOLEAN) { + return literal; + } + }, +}); +export const GraphQLID = new GraphQLScalarType({ + name: 'ID', + description: 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.', + coerceOutputValue(outputValue) { + const coercedValue = coerceOutputValueObject(outputValue); + if (typeof coercedValue === 'string') { + return coercedValue; + } + if (Number.isInteger(coercedValue)) { + return String(coercedValue); + } + throw new GraphQLError(`ID cannot represent value: ${inspect(outputValue)}`); + }, + coerceInputValue(inputValue) { + if (typeof inputValue === 'string') { + return inputValue; + } + if (typeof inputValue === 'number' && Number.isInteger(inputValue)) { + return inputValue.toString(); + } + throw new GraphQLError(`ID cannot represent value: ${inspect(inputValue)}`); + }, + coerceInputLiteral(valueNode) { + if (valueNode.kind !== Kind.STRING && valueNode.kind !== Kind.INT) { + throw new GraphQLError('ID cannot represent a non-string and non-integer value: ' + + print(valueNode), { nodes: valueNode }); + } + return valueNode.value; + }, + valueToLiteral(value) { + // ID types can use number values and Int literals. + const stringValue = Number.isInteger(value) ? String(value) : value; + if (typeof stringValue === 'string') { + // Will parse as an IntValue. + return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue) + ? { kind: Kind.INT, value: stringValue } + : { kind: Kind.STRING, value: stringValue, block: false }; + } + }, +}); +export const specifiedScalarTypes = Object.freeze([ + GraphQLString, + GraphQLInt, + GraphQLFloat, + GraphQLBoolean, + GraphQLID, +]); +export function isSpecifiedScalarType(type) { + return specifiedScalarTypes.some(({ name }) => type.name === name); +} +// Support coercing objects with custom valueOf() or toJSON() functions - +// a common way to represent a complex value which can be represented as +// a string (ex: MongoDB id objects). +function coerceOutputValueObject(outputValue) { + if (isObjectLike(outputValue)) { + if (typeof outputValue.valueOf === 'function') { + const valueOfResult = outputValue.valueOf(); + if (!isObjectLike(valueOfResult)) { + return valueOfResult; + } + } + if (typeof outputValue.toJSON === 'function') { + return outputValue.toJSON(); + } + } + return outputValue; +} +//# sourceMappingURL=scalars.js.map \ No newline at end of file diff --git a/type/scalars.mjs.map b/type/scalars.mjs.map new file mode 100644 index 0000000000..e04449fa35 --- /dev/null +++ b/type/scalars.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"scalars.js","sourceRoot":"","sources":["../../src/type/scalars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EA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;IACnD,IAAI,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YAC9C,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC;YAC5C,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC;gBACjC,OAAO,aAAa,CAAC;YACvB,CAAC;QACH,CAAC;QACD,IAAI,OAAO,WAAW,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAC7C,OAAO,WAAW,CAAC,MAAM,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport { defaultScalarValueToLiteral } from '../utilities/valueToLiteral.js';\n\nimport type { GraphQLNamedType } from './definition.js';\nimport { GraphQLScalarType } from './definition.js';\n\n/**\n * Maximum possible Int value as per GraphQL Spec (32-bit signed integer).\n * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1\n * */\nexport const GRAPHQL_MAX_INT = 2147483647;\n\n/**\n * Minimum possible Int value as per GraphQL Spec (32-bit signed integer).\n * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1)\n * */\nexport const GRAPHQL_MIN_INT = -2147483648;\n\nexport const GraphQLInt = new GraphQLScalarType({\n name: 'Int',\n description:\n 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isInteger(num)) {\n throw new GraphQLError(\n `Int cannot represent non-integer value: ${inspect(coercedValue)}`,\n );\n }\n if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {\n throw new GraphQLError(\n 'Int cannot represent non 32-bit signed integer value: ' +\n inspect(coercedValue),\n );\n }\n return num;\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) {\n throw new GraphQLError(\n `Int cannot represent non-integer value: ${inspect(inputValue)}`,\n );\n }\n if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) {\n throw new GraphQLError(\n `Int cannot represent non 32-bit signed integer value: ${inputValue}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.INT) {\n throw new GraphQLError(\n `Int cannot represent non-integer value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n const num = parseInt(valueNode.value, 10);\n if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {\n throw new GraphQLError(\n `Int cannot represent non 32-bit signed integer value: ${valueNode.value}`,\n { nodes: valueNode },\n );\n }\n return num;\n },\n valueToLiteral(value) {\n if (\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value <= GRAPHQL_MAX_INT &&\n value >= GRAPHQL_MIN_INT\n ) {\n return { kind: Kind.INT, value: String(value) };\n }\n },\n});\n\nexport const GraphQLFloat = new GraphQLScalarType({\n name: 'Float',\n description:\n 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isFinite(num)) {\n throw new GraphQLError(\n `Float cannot represent non numeric value: ${inspect(coercedValue)}`,\n );\n }\n return num;\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) {\n throw new GraphQLError(\n `Float cannot represent non numeric value: ${inspect(inputValue)}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.FLOAT && valueNode.kind !== Kind.INT) {\n throw new GraphQLError(\n `Float cannot represent non numeric value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n return parseFloat(valueNode.value);\n },\n valueToLiteral(value) {\n const literal = defaultScalarValueToLiteral(value);\n if (literal.kind === Kind.FLOAT || literal.kind === Kind.INT) {\n return literal;\n }\n },\n});\n\nexport const GraphQLString = new GraphQLScalarType({\n name: 'String',\n description:\n 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n // Coerces string, boolean and number values to a string, but do not\n // attempt to coerce object, function, symbol, or other types as strings.\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 'true' : 'false';\n }\n if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) {\n return coercedValue.toString();\n }\n throw new GraphQLError(\n `String cannot represent value: ${inspect(outputValue)}`,\n );\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'string') {\n throw new GraphQLError(\n `String cannot represent a non string value: ${inspect(inputValue)}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING) {\n throw new GraphQLError(\n `String cannot represent a non string value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n return valueNode.value;\n },\n valueToLiteral(value) {\n const literal = defaultScalarValueToLiteral(value);\n if (literal.kind === Kind.STRING) {\n return literal;\n }\n },\n});\n\nexport const GraphQLBoolean = new GraphQLScalarType({\n name: 'Boolean',\n description: 'The `Boolean` scalar type represents `true` or `false`.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue;\n }\n if (Number.isFinite(coercedValue)) {\n return coercedValue !== 0;\n }\n throw new GraphQLError(\n `Boolean cannot represent a non boolean value: ${inspect(coercedValue)}`,\n );\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue !== 'boolean') {\n throw new GraphQLError(\n `Boolean cannot represent a non boolean value: ${inspect(inputValue)}`,\n );\n }\n return inputValue;\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.BOOLEAN) {\n throw new GraphQLError(\n `Boolean cannot represent a non boolean value: ${print(valueNode)}`,\n { nodes: valueNode },\n );\n }\n return valueNode.value;\n },\n valueToLiteral(value) {\n const literal = defaultScalarValueToLiteral(value);\n if (literal.kind === Kind.BOOLEAN) {\n return literal;\n }\n },\n});\n\nexport const GraphQLID = new GraphQLScalarType({\n name: 'ID',\n description:\n 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.',\n\n coerceOutputValue(outputValue) {\n const coercedValue = coerceOutputValueObject(outputValue);\n\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n if (Number.isInteger(coercedValue)) {\n return String(coercedValue);\n }\n throw new GraphQLError(\n `ID cannot represent value: ${inspect(outputValue)}`,\n );\n },\n\n coerceInputValue(inputValue) {\n if (typeof inputValue === 'string') {\n return inputValue;\n }\n if (typeof inputValue === 'number' && Number.isInteger(inputValue)) {\n return inputValue.toString();\n }\n throw new GraphQLError(`ID cannot represent value: ${inspect(inputValue)}`);\n },\n\n coerceInputLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING && valueNode.kind !== Kind.INT) {\n throw new GraphQLError(\n 'ID cannot represent a non-string and non-integer value: ' +\n print(valueNode),\n { nodes: valueNode },\n );\n }\n return valueNode.value;\n },\n valueToLiteral(value) {\n // ID types can use number values and Int literals.\n const stringValue = Number.isInteger(value) ? String(value) : value;\n if (typeof stringValue === 'string') {\n // Will parse as an IntValue.\n return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue)\n ? { kind: Kind.INT, value: stringValue }\n : { kind: Kind.STRING, value: stringValue, block: false };\n }\n },\n});\n\nexport const specifiedScalarTypes: ReadonlyArray =\n Object.freeze([\n GraphQLString,\n GraphQLInt,\n GraphQLFloat,\n GraphQLBoolean,\n GraphQLID,\n ]);\n\nexport function isSpecifiedScalarType(type: GraphQLNamedType): boolean {\n return specifiedScalarTypes.some(({ name }) => type.name === name);\n}\n\n// Support coercing objects with custom valueOf() or toJSON() functions -\n// a common way to represent a complex value which can be represented as\n// a string (ex: MongoDB id objects).\nfunction coerceOutputValueObject(outputValue: unknown): unknown {\n if (isObjectLike(outputValue)) {\n if (typeof outputValue.valueOf === 'function') {\n const valueOfResult = outputValue.valueOf();\n if (!isObjectLike(valueOfResult)) {\n return valueOfResult;\n }\n }\n if (typeof outputValue.toJSON === 'function') {\n return outputValue.toJSON();\n }\n }\n return outputValue;\n}\n"]} \ No newline at end of file diff --git a/type/schema.d.ts b/type/schema.d.ts new file mode 100644 index 0000000000..b2b319c665 --- /dev/null +++ b/type/schema.d.ts @@ -0,0 +1,170 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { GraphQLError } from '../error/GraphQLError.js'; +import type { SchemaDefinitionNode, SchemaExtensionNode } from '../language/ast.js'; +import { OperationTypeNode } from '../language/ast.js'; +import type { GraphQLAbstractType, GraphQLCompositeType, GraphQLField, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType } from './definition.js'; +import type { GraphQLDirective } from './directives.js'; +/** + * Test if the given value is a GraphQL schema. + */ +export declare function isSchema(schema: unknown): schema is GraphQLSchema; +export declare function assertSchema(schema: unknown): GraphQLSchema; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLSchemaExtensions { + [attributeName: string | symbol]: unknown; +} +/** + * Schema Definition + * + * A Schema is created by supplying the root types of each type of operation, + * query and mutation (optional). A schema definition is then supplied to the + * validator and executor. + * + * Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * query: MyAppQueryRootType, + * mutation: MyAppMutationRootType, + * }) + * ``` + * + * Note: When the schema is constructed, by default only the types that are + * reachable by traversing the root types are included, other types must be + * explicitly referenced. + * + * Example: + * + * ```ts + * const characterInterface = new GraphQLInterfaceType({ + * name: 'Character', + * ... + * }); + * + * const humanType = new GraphQLObjectType({ + * name: 'Human', + * interfaces: [characterInterface], + * ... + * }); + * + * const droidType = new GraphQLObjectType({ + * name: 'Droid', + * interfaces: [characterInterface], + * ... + * }); + * + * const schema = new GraphQLSchema({ + * query: new GraphQLObjectType({ + * name: 'Query', + * fields: { + * hero: { type: characterInterface, ... }, + * } + * }), + * ... + * // Since this schema references only the `Character` interface it's + * // necessary to explicitly list the types that implement it if + * // you want them to be included in the final schema. + * types: [humanType, droidType], + * }) + * ``` + * + * Note: If an array of `directives` are provided to GraphQLSchema, that will be + * the exact list of directives represented and allowed. If `directives` is not + * provided then a default set of the specified directives (e.g. `@include` and + * `@skip`) will be used. If you wish to provide *additional* directives to these + * specified directives, you must explicitly declare them. Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * ... + * directives: specifiedDirectives.concat([ myCustomDirective ]), + * }) + * ``` + */ +export declare class GraphQLSchema { + description: Maybe; + extensions: Readonly; + astNode: Maybe; + extensionASTNodes: ReadonlyArray; + assumeValid: boolean; + __validationErrors: Maybe>; + private _queryType; + private _mutationType; + private _subscriptionType; + private _directives; + private _typeMap; + private _subTypeMap; + private _implementationsMap; + constructor(config: Readonly); + get [Symbol.toStringTag](): string; + getQueryType(): Maybe; + getMutationType(): Maybe; + getSubscriptionType(): Maybe; + getRootType(operation: OperationTypeNode): Maybe; + getTypeMap(): TypeMap; + getType(name: string): GraphQLNamedType | undefined; + getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray; + getImplementations(interfaceType: GraphQLInterfaceType): { + objects: ReadonlyArray; + interfaces: ReadonlyArray; + }; + isSubType(abstractType: GraphQLAbstractType, maybeSubType: GraphQLObjectType | GraphQLInterfaceType): boolean; + getDirectives(): ReadonlyArray; + getDirective(name: string): Maybe; + /** + * This method looks up the field on the given type definition. + * It has special casing for the three introspection fields, `__schema`, + * `__type` and `__typename`. + * + * `__typename` is special because it can always be queried as a field, even + * in situations where no other fields are allowed, like on a Union. + * + * `__schema` and `__type` could get automatically added to the query type, + * but that would require mutating type definitions, which would cause issues. + */ + getField(parentType: GraphQLCompositeType, fieldName: string): GraphQLField | undefined; + toConfig(): GraphQLSchemaNormalizedConfig; +} +type TypeMap = ObjMap; +export interface GraphQLSchemaValidationOptions { + /** + * When building a schema from a GraphQL service's introspection result, it + * might be safe to assume the schema is valid. Set to true to assume the + * produced schema is valid. + * + * Default: false + */ + assumeValid?: boolean | undefined; +} +export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { + description?: Maybe; + query?: Maybe; + mutation?: Maybe; + subscription?: Maybe; + types?: Maybe>; + directives?: Maybe>; + extensions?: Maybe>; + astNode?: Maybe; + extensionASTNodes?: Maybe>; +} +/** + * @internal + */ +export interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig { + description: Maybe; + types: ReadonlyArray; + directives: ReadonlyArray; + extensions: Readonly; + extensionASTNodes: ReadonlyArray; + assumeValid: boolean; +} +export {}; diff --git a/type/schema.js b/type/schema.js new file mode 100644 index 0000000000..b214023620 --- /dev/null +++ b/type/schema.js @@ -0,0 +1,319 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GraphQLSchema = void 0; +exports.isSchema = isSchema; +exports.assertSchema = assertSchema; +const inspect_js_1 = require("../jsutils/inspect.js"); +const instanceOf_js_1 = require("../jsutils/instanceOf.js"); +const toObjMap_js_1 = require("../jsutils/toObjMap.js"); +const ast_js_1 = require("../language/ast.js"); +const definition_js_1 = require("./definition.js"); +const directives_js_1 = require("./directives.js"); +const introspection_js_1 = require("./introspection.js"); +/** + * Test if the given value is a GraphQL schema. + */ +function isSchema(schema) { + return (0, instanceOf_js_1.instanceOf)(schema, GraphQLSchema); +} +function assertSchema(schema) { + if (!isSchema(schema)) { + throw new Error(`Expected ${(0, inspect_js_1.inspect)(schema)} to be a GraphQL schema.`); + } + return schema; +} +/** + * Schema Definition + * + * A Schema is created by supplying the root types of each type of operation, + * query and mutation (optional). A schema definition is then supplied to the + * validator and executor. + * + * Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * query: MyAppQueryRootType, + * mutation: MyAppMutationRootType, + * }) + * ``` + * + * Note: When the schema is constructed, by default only the types that are + * reachable by traversing the root types are included, other types must be + * explicitly referenced. + * + * Example: + * + * ```ts + * const characterInterface = new GraphQLInterfaceType({ + * name: 'Character', + * ... + * }); + * + * const humanType = new GraphQLObjectType({ + * name: 'Human', + * interfaces: [characterInterface], + * ... + * }); + * + * const droidType = new GraphQLObjectType({ + * name: 'Droid', + * interfaces: [characterInterface], + * ... + * }); + * + * const schema = new GraphQLSchema({ + * query: new GraphQLObjectType({ + * name: 'Query', + * fields: { + * hero: { type: characterInterface, ... }, + * } + * }), + * ... + * // Since this schema references only the `Character` interface it's + * // necessary to explicitly list the types that implement it if + * // you want them to be included in the final schema. + * types: [humanType, droidType], + * }) + * ``` + * + * Note: If an array of `directives` are provided to GraphQLSchema, that will be + * the exact list of directives represented and allowed. If `directives` is not + * provided then a default set of the specified directives (e.g. `@include` and + * `@skip`) will be used. If you wish to provide *additional* directives to these + * specified directives, you must explicitly declare them. Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * ... + * directives: specifiedDirectives.concat([ myCustomDirective ]), + * }) + * ``` + */ +class GraphQLSchema { + constructor(config) { + // If this schema was built from a source known to be valid, then it may be + // marked with assumeValid to avoid an additional type system validation. + this.assumeValid = config.assumeValid ?? false; + // Used as a cache for validateSchema(). + this.__validationErrors = config.assumeValid === true ? [] : undefined; + this.description = config.description; + this.extensions = (0, toObjMap_js_1.toObjMapWithSymbols)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._queryType = config.query; + this._mutationType = config.mutation; + this._subscriptionType = config.subscription; + // Provide specified directives (e.g. @include and @skip) by default. + this._directives = config.directives ?? directives_js_1.specifiedDirectives; + // To preserve order of user-provided types, we add first to add them to + // the set of "collected" types, so `collectReferencedTypes` ignore them. + const allReferencedTypes = new Set(config.types); + if (config.types != null) { + for (const type of config.types) { + // When we ready to process this type, we remove it from "collected" types + // and then add it together with all dependent types in the correct position. + allReferencedTypes.delete(type); + collectReferencedTypes(type, allReferencedTypes); + } + } + if (this._queryType != null) { + collectReferencedTypes(this._queryType, allReferencedTypes); + } + if (this._mutationType != null) { + collectReferencedTypes(this._mutationType, allReferencedTypes); + } + if (this._subscriptionType != null) { + collectReferencedTypes(this._subscriptionType, allReferencedTypes); + } + for (const directive of this._directives) { + // Directives are not validated until validateSchema() is called. + if ((0, directives_js_1.isDirective)(directive)) { + for (const arg of directive.args) { + collectReferencedTypes(arg.type, allReferencedTypes); + } + } + } + collectReferencedTypes(introspection_js_1.__Schema, allReferencedTypes); + // Storing the resulting map for reference by the schema. + this._typeMap = Object.create(null); + this._subTypeMap = new Map(); + // Keep track of all implementations by interface name. + this._implementationsMap = Object.create(null); + for (const namedType of allReferencedTypes) { + if (namedType == null) { + continue; + } + const typeName = namedType.name; + if (this._typeMap[typeName] !== undefined) { + throw new Error(`Schema must contain uniquely named types but contains multiple types named "${typeName}".`); + } + this._typeMap[typeName] = namedType; + if ((0, definition_js_1.isInterfaceType)(namedType)) { + // Store implementations by interface. + for (const iface of namedType.getInterfaces()) { + if ((0, definition_js_1.isInterfaceType)(iface)) { + let implementations = this._implementationsMap[iface.name]; + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + implementations.interfaces.push(namedType); + } + } + } + else if ((0, definition_js_1.isObjectType)(namedType)) { + // Store implementations by objects. + for (const iface of namedType.getInterfaces()) { + if ((0, definition_js_1.isInterfaceType)(iface)) { + let implementations = this._implementationsMap[iface.name]; + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + implementations.objects.push(namedType); + } + } + } + } + } + get [Symbol.toStringTag]() { + return 'GraphQLSchema'; + } + getQueryType() { + return this._queryType; + } + getMutationType() { + return this._mutationType; + } + getSubscriptionType() { + return this._subscriptionType; + } + getRootType(operation) { + switch (operation) { + case ast_js_1.OperationTypeNode.QUERY: + return this.getQueryType(); + case ast_js_1.OperationTypeNode.MUTATION: + return this.getMutationType(); + case ast_js_1.OperationTypeNode.SUBSCRIPTION: + return this.getSubscriptionType(); + } + } + getTypeMap() { + return this._typeMap; + } + getType(name) { + return this.getTypeMap()[name]; + } + getPossibleTypes(abstractType) { + return (0, definition_js_1.isUnionType)(abstractType) + ? abstractType.getTypes() + : this.getImplementations(abstractType).objects; + } + getImplementations(interfaceType) { + const implementations = this._implementationsMap[interfaceType.name]; + return implementations ?? { objects: [], interfaces: [] }; + } + isSubType(abstractType, maybeSubType) { + let set = this._subTypeMap.get(abstractType); + if (set === undefined) { + if ((0, definition_js_1.isUnionType)(abstractType)) { + set = new Set(abstractType.getTypes()); + } + else { + const implementations = this.getImplementations(abstractType); + set = new Set([ + ...implementations.objects, + ...implementations.interfaces, + ]); + } + this._subTypeMap.set(abstractType, set); + } + return set.has(maybeSubType); + } + getDirectives() { + return this._directives; + } + getDirective(name) { + return this.getDirectives().find((directive) => directive.name === name); + } + /** + * This method looks up the field on the given type definition. + * It has special casing for the three introspection fields, `__schema`, + * `__type` and `__typename`. + * + * `__typename` is special because it can always be queried as a field, even + * in situations where no other fields are allowed, like on a Union. + * + * `__schema` and `__type` could get automatically added to the query type, + * but that would require mutating type definitions, which would cause issues. + */ + getField(parentType, fieldName) { + switch (fieldName) { + case introspection_js_1.SchemaMetaFieldDef.name: + return this.getQueryType() === parentType + ? introspection_js_1.SchemaMetaFieldDef + : undefined; + case introspection_js_1.TypeMetaFieldDef.name: + return this.getQueryType() === parentType + ? introspection_js_1.TypeMetaFieldDef + : undefined; + case introspection_js_1.TypeNameMetaFieldDef.name: + return introspection_js_1.TypeNameMetaFieldDef; + } + // this function is part "hot" path inside executor and check presence + // of 'getFields' is faster than to use `!isUnionType` + if ('getFields' in parentType) { + return parentType.getFields()[fieldName]; + } + return undefined; + } + toConfig() { + return { + description: this.description, + query: this.getQueryType(), + mutation: this.getMutationType(), + subscription: this.getSubscriptionType(), + types: Object.values(this.getTypeMap()), + directives: this.getDirectives(), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + assumeValid: this.assumeValid, + }; + } +} +exports.GraphQLSchema = GraphQLSchema; +function collectReferencedTypes(type, typeSet) { + const namedType = (0, definition_js_1.getNamedType)(type); + if (!typeSet.has(namedType)) { + typeSet.add(namedType); + if ((0, definition_js_1.isUnionType)(namedType)) { + for (const memberType of namedType.getTypes()) { + collectReferencedTypes(memberType, typeSet); + } + } + else if ((0, definition_js_1.isObjectType)(namedType) || (0, definition_js_1.isInterfaceType)(namedType)) { + for (const interfaceType of namedType.getInterfaces()) { + collectReferencedTypes(interfaceType, typeSet); + } + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + for (const arg of field.args) { + collectReferencedTypes(arg.type, typeSet); + } + } + } + else if ((0, definition_js_1.isInputObjectType)(namedType)) { + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + } + } + } + return typeSet; +} +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/type/schema.js.map b/type/schema.js.map new file mode 100644 index 0000000000..54924c820a --- /dev/null +++ b/type/schema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/type/schema.ts"],"names":[],"mappings":";;;AA0CA,4BAEC;AAED,oCAKC;AAnDD,sDAAgD;AAChD,4DAAsD;AAGtD,wDAA6D;AAQ7D,+CAAuD;AAWvD,mDAMyB;AAEzB,mDAAmE;AACnE,yDAK4B;AAE5B;;GAEG;AACH,SAAgB,QAAQ,CAAC,MAAe;IACtC,OAAO,IAAA,0BAAU,EAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,YAAY,CAAC,MAAe;IAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,oBAAO,EAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAa,aAAa;IAwBxB,YAAY,MAAqC;QAC/C,2EAA2E;QAC3E,yEAAyE;QACzE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC;QAC/C,wCAAwC;QACxC,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAEvE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAA,iCAAmB,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,IAAI,EAAE,CAAC;QAExD,IAAI,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AC,SAAS,EAAE,CAAC,EAAE,CAAC;gBACzD,sBAAsB,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n SchemaDefinitionNode,\n SchemaExtensionNode,\n} from '../language/ast.js';\nimport { OperationTypeNode } from '../language/ast.js';\n\nimport type {\n GraphQLAbstractType,\n GraphQLCompositeType,\n GraphQLField,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLType,\n} from './definition.js';\nimport {\n getNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isUnionType,\n} from './definition.js';\nimport type { GraphQLDirective } from './directives.js';\nimport { isDirective, specifiedDirectives } from './directives.js';\nimport {\n __Schema,\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n} from './introspection.js';\n\n/**\n * Test if the given value is a GraphQL schema.\n */\nexport function isSchema(schema: unknown): schema is GraphQLSchema {\n return instanceOf(schema, GraphQLSchema);\n}\n\nexport function assertSchema(schema: unknown): GraphQLSchema {\n if (!isSchema(schema)) {\n throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`);\n }\n return schema;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLSchemaExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Schema Definition\n *\n * A Schema is created by supplying the root types of each type of operation,\n * query and mutation (optional). A schema definition is then supplied to the\n * validator and executor.\n *\n * Example:\n *\n * ```ts\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * mutation: MyAppMutationRootType,\n * })\n * ```\n *\n * Note: When the schema is constructed, by default only the types that are\n * reachable by traversing the root types are included, other types must be\n * explicitly referenced.\n *\n * Example:\n *\n * ```ts\n * const characterInterface = new GraphQLInterfaceType({\n * name: 'Character',\n * ...\n * });\n *\n * const humanType = new GraphQLObjectType({\n * name: 'Human',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const droidType = new GraphQLObjectType({\n * name: 'Droid',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const schema = new GraphQLSchema({\n * query: new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * hero: { type: characterInterface, ... },\n * }\n * }),\n * ...\n * // Since this schema references only the `Character` interface it's\n * // necessary to explicitly list the types that implement it if\n * // you want them to be included in the final schema.\n * types: [humanType, droidType],\n * })\n * ```\n *\n * Note: If an array of `directives` are provided to GraphQLSchema, that will be\n * the exact list of directives represented and allowed. If `directives` is not\n * provided then a default set of the specified directives (e.g. `@include` and\n * `@skip`) will be used. If you wish to provide *additional* directives to these\n * specified directives, you must explicitly declare them. Example:\n *\n * ```ts\n * const MyAppSchema = new GraphQLSchema({\n * ...\n * directives: specifiedDirectives.concat([ myCustomDirective ]),\n * })\n * ```\n */\nexport class GraphQLSchema {\n description: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n assumeValid: boolean;\n __validationErrors: Maybe>;\n\n private _queryType: Maybe;\n private _mutationType: Maybe;\n private _subscriptionType: Maybe;\n private _directives: ReadonlyArray;\n private _typeMap: TypeMap;\n private _subTypeMap: Map<\n GraphQLAbstractType,\n Set\n >;\n\n private _implementationsMap: ObjMap<{\n objects: Array;\n interfaces: Array;\n }>;\n\n constructor(config: Readonly) {\n // If this schema was built from a source known to be valid, then it may be\n // marked with assumeValid to avoid an additional type system validation.\n this.assumeValid = config.assumeValid ?? false;\n // Used as a cache for validateSchema().\n this.__validationErrors = config.assumeValid === true ? [] : undefined;\n\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._queryType = config.query;\n this._mutationType = config.mutation;\n this._subscriptionType = config.subscription;\n // Provide specified directives (e.g. @include and @skip) by default.\n this._directives = config.directives ?? specifiedDirectives;\n\n // To preserve order of user-provided types, we add first to add them to\n // the set of \"collected\" types, so `collectReferencedTypes` ignore them.\n const allReferencedTypes = new Set(config.types);\n if (config.types != null) {\n for (const type of config.types) {\n // When we ready to process this type, we remove it from \"collected\" types\n // and then add it together with all dependent types in the correct position.\n allReferencedTypes.delete(type);\n collectReferencedTypes(type, allReferencedTypes);\n }\n }\n\n if (this._queryType != null) {\n collectReferencedTypes(this._queryType, allReferencedTypes);\n }\n if (this._mutationType != null) {\n collectReferencedTypes(this._mutationType, allReferencedTypes);\n }\n if (this._subscriptionType != null) {\n collectReferencedTypes(this._subscriptionType, allReferencedTypes);\n }\n\n for (const directive of this._directives) {\n // Directives are not validated until validateSchema() is called.\n if (isDirective(directive)) {\n for (const arg of directive.args) {\n collectReferencedTypes(arg.type, allReferencedTypes);\n }\n }\n }\n collectReferencedTypes(__Schema, allReferencedTypes);\n\n // Storing the resulting map for reference by the schema.\n this._typeMap = Object.create(null);\n this._subTypeMap = new Map();\n // Keep track of all implementations by interface name.\n this._implementationsMap = Object.create(null);\n\n for (const namedType of allReferencedTypes) {\n if (namedType == null) {\n continue;\n }\n\n const typeName = namedType.name;\n if (this._typeMap[typeName] !== undefined) {\n throw new Error(\n `Schema must contain uniquely named types but contains multiple types named \"${typeName}\".`,\n );\n }\n this._typeMap[typeName] = namedType;\n\n if (isInterfaceType(namedType)) {\n // Store implementations by interface.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n }\n\n implementations.interfaces.push(namedType);\n }\n }\n } else if (isObjectType(namedType)) {\n // Store implementations by objects.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n }\n\n implementations.objects.push(namedType);\n }\n }\n }\n }\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLSchema';\n }\n\n getQueryType(): Maybe {\n return this._queryType;\n }\n\n getMutationType(): Maybe {\n return this._mutationType;\n }\n\n getSubscriptionType(): Maybe {\n return this._subscriptionType;\n }\n\n getRootType(operation: OperationTypeNode): Maybe {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return this.getQueryType();\n case OperationTypeNode.MUTATION:\n return this.getMutationType();\n case OperationTypeNode.SUBSCRIPTION:\n return this.getSubscriptionType();\n }\n }\n\n getTypeMap(): TypeMap {\n return this._typeMap;\n }\n\n getType(name: string): GraphQLNamedType | undefined {\n return this.getTypeMap()[name];\n }\n\n getPossibleTypes(\n abstractType: GraphQLAbstractType,\n ): ReadonlyArray {\n return isUnionType(abstractType)\n ? abstractType.getTypes()\n : this.getImplementations(abstractType).objects;\n }\n\n getImplementations(interfaceType: GraphQLInterfaceType): {\n objects: ReadonlyArray;\n interfaces: ReadonlyArray;\n } {\n const implementations = this._implementationsMap[interfaceType.name];\n return implementations ?? { objects: [], interfaces: [] };\n }\n\n isSubType(\n abstractType: GraphQLAbstractType,\n maybeSubType: GraphQLObjectType | GraphQLInterfaceType,\n ): boolean {\n let set = this._subTypeMap.get(abstractType);\n if (set === undefined) {\n if (isUnionType(abstractType)) {\n set = new Set(abstractType.getTypes());\n } else {\n const implementations = this.getImplementations(abstractType);\n set = new Set([\n ...implementations.objects,\n ...implementations.interfaces,\n ]);\n }\n\n this._subTypeMap.set(abstractType, set);\n }\n return set.has(maybeSubType);\n }\n\n getDirectives(): ReadonlyArray {\n return this._directives;\n }\n\n getDirective(name: string): Maybe {\n return this.getDirectives().find((directive) => directive.name === name);\n }\n\n /**\n * This method looks up the field on the given type definition.\n * It has special casing for the three introspection fields, `__schema`,\n * `__type` and `__typename`.\n *\n * `__typename` is special because it can always be queried as a field, even\n * in situations where no other fields are allowed, like on a Union.\n *\n * `__schema` and `__type` could get automatically added to the query type,\n * but that would require mutating type definitions, which would cause issues.\n */\n getField(\n parentType: GraphQLCompositeType,\n fieldName: string,\n ): GraphQLField | undefined {\n switch (fieldName) {\n case SchemaMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? SchemaMetaFieldDef\n : undefined;\n case TypeMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? TypeMetaFieldDef\n : undefined;\n case TypeNameMetaFieldDef.name:\n return TypeNameMetaFieldDef;\n }\n\n // this function is part \"hot\" path inside executor and check presence\n // of 'getFields' is faster than to use `!isUnionType`\n if ('getFields' in parentType) {\n return parentType.getFields()[fieldName];\n }\n return undefined;\n }\n\n toConfig(): GraphQLSchemaNormalizedConfig {\n return {\n description: this.description,\n query: this.getQueryType(),\n mutation: this.getMutationType(),\n subscription: this.getSubscriptionType(),\n types: Object.values(this.getTypeMap()),\n directives: this.getDirectives(),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n assumeValid: this.assumeValid,\n };\n }\n}\n\ntype TypeMap = ObjMap;\n\nexport interface GraphQLSchemaValidationOptions {\n /**\n * When building a schema from a GraphQL service's introspection result, it\n * might be safe to assume the schema is valid. Set to true to assume the\n * produced schema is valid.\n *\n * Default: false\n */\n assumeValid?: boolean | undefined;\n}\n\nexport interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {\n description?: Maybe;\n query?: Maybe;\n mutation?: Maybe;\n subscription?: Maybe;\n types?: Maybe>;\n directives?: Maybe>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\n/**\n * @internal\n */\nexport interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig {\n description: Maybe;\n types: ReadonlyArray;\n directives: ReadonlyArray;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n assumeValid: boolean;\n}\n\nfunction collectReferencedTypes(\n type: GraphQLType,\n typeSet: Set,\n): Set {\n const namedType = getNamedType(type);\n\n if (!typeSet.has(namedType)) {\n typeSet.add(namedType);\n if (isUnionType(namedType)) {\n for (const memberType of namedType.getTypes()) {\n collectReferencedTypes(memberType, typeSet);\n }\n } else if (isObjectType(namedType) || isInterfaceType(namedType)) {\n for (const interfaceType of namedType.getInterfaces()) {\n collectReferencedTypes(interfaceType, typeSet);\n }\n\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n for (const arg of field.args) {\n collectReferencedTypes(arg.type, typeSet);\n }\n }\n } else if (isInputObjectType(namedType)) {\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n }\n }\n }\n\n return typeSet;\n}\n"]} \ No newline at end of file diff --git a/type/schema.mjs b/type/schema.mjs new file mode 100644 index 0000000000..32bfb763c4 --- /dev/null +++ b/type/schema.mjs @@ -0,0 +1,313 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { instanceOf } from "../jsutils/instanceOf.mjs"; +import { toObjMapWithSymbols } from "../jsutils/toObjMap.mjs"; +import { OperationTypeNode } from "../language/ast.mjs"; +import { getNamedType, isInputObjectType, isInterfaceType, isObjectType, isUnionType, } from "./definition.mjs"; +import { isDirective, specifiedDirectives } from "./directives.mjs"; +import { __Schema, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, } from "./introspection.mjs"; +/** + * Test if the given value is a GraphQL schema. + */ +export function isSchema(schema) { + return instanceOf(schema, GraphQLSchema); +} +export function assertSchema(schema) { + if (!isSchema(schema)) { + throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`); + } + return schema; +} +/** + * Schema Definition + * + * A Schema is created by supplying the root types of each type of operation, + * query and mutation (optional). A schema definition is then supplied to the + * validator and executor. + * + * Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * query: MyAppQueryRootType, + * mutation: MyAppMutationRootType, + * }) + * ``` + * + * Note: When the schema is constructed, by default only the types that are + * reachable by traversing the root types are included, other types must be + * explicitly referenced. + * + * Example: + * + * ```ts + * const characterInterface = new GraphQLInterfaceType({ + * name: 'Character', + * ... + * }); + * + * const humanType = new GraphQLObjectType({ + * name: 'Human', + * interfaces: [characterInterface], + * ... + * }); + * + * const droidType = new GraphQLObjectType({ + * name: 'Droid', + * interfaces: [characterInterface], + * ... + * }); + * + * const schema = new GraphQLSchema({ + * query: new GraphQLObjectType({ + * name: 'Query', + * fields: { + * hero: { type: characterInterface, ... }, + * } + * }), + * ... + * // Since this schema references only the `Character` interface it's + * // necessary to explicitly list the types that implement it if + * // you want them to be included in the final schema. + * types: [humanType, droidType], + * }) + * ``` + * + * Note: If an array of `directives` are provided to GraphQLSchema, that will be + * the exact list of directives represented and allowed. If `directives` is not + * provided then a default set of the specified directives (e.g. `@include` and + * `@skip`) will be used. If you wish to provide *additional* directives to these + * specified directives, you must explicitly declare them. Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * ... + * directives: specifiedDirectives.concat([ myCustomDirective ]), + * }) + * ``` + */ +export class GraphQLSchema { + constructor(config) { + // If this schema was built from a source known to be valid, then it may be + // marked with assumeValid to avoid an additional type system validation. + this.assumeValid = config.assumeValid ?? false; + // Used as a cache for validateSchema(). + this.__validationErrors = config.assumeValid === true ? [] : undefined; + this.description = config.description; + this.extensions = toObjMapWithSymbols(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = config.extensionASTNodes ?? []; + this._queryType = config.query; + this._mutationType = config.mutation; + this._subscriptionType = config.subscription; + // Provide specified directives (e.g. @include and @skip) by default. + this._directives = config.directives ?? specifiedDirectives; + // To preserve order of user-provided types, we add first to add them to + // the set of "collected" types, so `collectReferencedTypes` ignore them. + const allReferencedTypes = new Set(config.types); + if (config.types != null) { + for (const type of config.types) { + // When we ready to process this type, we remove it from "collected" types + // and then add it together with all dependent types in the correct position. + allReferencedTypes.delete(type); + collectReferencedTypes(type, allReferencedTypes); + } + } + if (this._queryType != null) { + collectReferencedTypes(this._queryType, allReferencedTypes); + } + if (this._mutationType != null) { + collectReferencedTypes(this._mutationType, allReferencedTypes); + } + if (this._subscriptionType != null) { + collectReferencedTypes(this._subscriptionType, allReferencedTypes); + } + for (const directive of this._directives) { + // Directives are not validated until validateSchema() is called. + if (isDirective(directive)) { + for (const arg of directive.args) { + collectReferencedTypes(arg.type, allReferencedTypes); + } + } + } + collectReferencedTypes(__Schema, allReferencedTypes); + // Storing the resulting map for reference by the schema. + this._typeMap = Object.create(null); + this._subTypeMap = new Map(); + // Keep track of all implementations by interface name. + this._implementationsMap = Object.create(null); + for (const namedType of allReferencedTypes) { + if (namedType == null) { + continue; + } + const typeName = namedType.name; + if (this._typeMap[typeName] !== undefined) { + throw new Error(`Schema must contain uniquely named types but contains multiple types named "${typeName}".`); + } + this._typeMap[typeName] = namedType; + if (isInterfaceType(namedType)) { + // Store implementations by interface. + for (const iface of namedType.getInterfaces()) { + if (isInterfaceType(iface)) { + let implementations = this._implementationsMap[iface.name]; + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + implementations.interfaces.push(namedType); + } + } + } + else if (isObjectType(namedType)) { + // Store implementations by objects. + for (const iface of namedType.getInterfaces()) { + if (isInterfaceType(iface)) { + let implementations = this._implementationsMap[iface.name]; + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + implementations.objects.push(namedType); + } + } + } + } + } + get [Symbol.toStringTag]() { + return 'GraphQLSchema'; + } + getQueryType() { + return this._queryType; + } + getMutationType() { + return this._mutationType; + } + getSubscriptionType() { + return this._subscriptionType; + } + getRootType(operation) { + switch (operation) { + case OperationTypeNode.QUERY: + return this.getQueryType(); + case OperationTypeNode.MUTATION: + return this.getMutationType(); + case OperationTypeNode.SUBSCRIPTION: + return this.getSubscriptionType(); + } + } + getTypeMap() { + return this._typeMap; + } + getType(name) { + return this.getTypeMap()[name]; + } + getPossibleTypes(abstractType) { + return isUnionType(abstractType) + ? abstractType.getTypes() + : this.getImplementations(abstractType).objects; + } + getImplementations(interfaceType) { + const implementations = this._implementationsMap[interfaceType.name]; + return implementations ?? { objects: [], interfaces: [] }; + } + isSubType(abstractType, maybeSubType) { + let set = this._subTypeMap.get(abstractType); + if (set === undefined) { + if (isUnionType(abstractType)) { + set = new Set(abstractType.getTypes()); + } + else { + const implementations = this.getImplementations(abstractType); + set = new Set([ + ...implementations.objects, + ...implementations.interfaces, + ]); + } + this._subTypeMap.set(abstractType, set); + } + return set.has(maybeSubType); + } + getDirectives() { + return this._directives; + } + getDirective(name) { + return this.getDirectives().find((directive) => directive.name === name); + } + /** + * This method looks up the field on the given type definition. + * It has special casing for the three introspection fields, `__schema`, + * `__type` and `__typename`. + * + * `__typename` is special because it can always be queried as a field, even + * in situations where no other fields are allowed, like on a Union. + * + * `__schema` and `__type` could get automatically added to the query type, + * but that would require mutating type definitions, which would cause issues. + */ + getField(parentType, fieldName) { + switch (fieldName) { + case SchemaMetaFieldDef.name: + return this.getQueryType() === parentType + ? SchemaMetaFieldDef + : undefined; + case TypeMetaFieldDef.name: + return this.getQueryType() === parentType + ? TypeMetaFieldDef + : undefined; + case TypeNameMetaFieldDef.name: + return TypeNameMetaFieldDef; + } + // this function is part "hot" path inside executor and check presence + // of 'getFields' is faster than to use `!isUnionType` + if ('getFields' in parentType) { + return parentType.getFields()[fieldName]; + } + return undefined; + } + toConfig() { + return { + description: this.description, + query: this.getQueryType(), + mutation: this.getMutationType(), + subscription: this.getSubscriptionType(), + types: Object.values(this.getTypeMap()), + directives: this.getDirectives(), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + assumeValid: this.assumeValid, + }; + } +} +function collectReferencedTypes(type, typeSet) { + const namedType = getNamedType(type); + if (!typeSet.has(namedType)) { + typeSet.add(namedType); + if (isUnionType(namedType)) { + for (const memberType of namedType.getTypes()) { + collectReferencedTypes(memberType, typeSet); + } + } + else if (isObjectType(namedType) || isInterfaceType(namedType)) { + for (const interfaceType of namedType.getInterfaces()) { + collectReferencedTypes(interfaceType, typeSet); + } + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + for (const arg of field.args) { + collectReferencedTypes(arg.type, typeSet); + } + } + } + else if (isInputObjectType(namedType)) { + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + } + } + } + return typeSet; +} +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/type/schema.mjs.map b/type/schema.mjs.map new file mode 100644 index 0000000000..73a6d5d20f --- /dev/null +++ b/type/schema.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/type/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,UAAU,EAAE,kCAAiC;AAGtD,OAAO,EAAE,mBAAmB,EAAE,gCAA+B;AAQ7D,OAAO,EAAE,iBAAiB,EAAE,4BAA2B;AAWvD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,yBAAwB;AAEzB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,yBAAwB;AACnE,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,GACrB,4BAA2B;AAE5B;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAe;IACtC,OAAO,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MA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H,CAAC;aAAM,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC;YACjE,KAAK,MAAM,aAAa,IAAI,SAAS,CAAC,aAAa,EAAE,EAAE,CAAC;gBACtD,sBAAsB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;gBACzD,sBAAsB,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC5C,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;oBAC7B,sBAAsB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;YACxC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;gBACzD,sBAAsB,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { instanceOf } from '../jsutils/instanceOf.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n SchemaDefinitionNode,\n SchemaExtensionNode,\n} from '../language/ast.js';\nimport { OperationTypeNode } from '../language/ast.js';\n\nimport type {\n GraphQLAbstractType,\n GraphQLCompositeType,\n GraphQLField,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLType,\n} from './definition.js';\nimport {\n getNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isUnionType,\n} from './definition.js';\nimport type { GraphQLDirective } from './directives.js';\nimport { isDirective, specifiedDirectives } from './directives.js';\nimport {\n __Schema,\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n} from './introspection.js';\n\n/**\n * Test if the given value is a GraphQL schema.\n */\nexport function isSchema(schema: unknown): schema is GraphQLSchema {\n return instanceOf(schema, GraphQLSchema);\n}\n\nexport function assertSchema(schema: unknown): GraphQLSchema {\n if (!isSchema(schema)) {\n throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`);\n }\n return schema;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLSchemaExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Schema Definition\n *\n * A Schema is created by supplying the root types of each type of operation,\n * query and mutation (optional). A schema definition is then supplied to the\n * validator and executor.\n *\n * Example:\n *\n * ```ts\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * mutation: MyAppMutationRootType,\n * })\n * ```\n *\n * Note: When the schema is constructed, by default only the types that are\n * reachable by traversing the root types are included, other types must be\n * explicitly referenced.\n *\n * Example:\n *\n * ```ts\n * const characterInterface = new GraphQLInterfaceType({\n * name: 'Character',\n * ...\n * });\n *\n * const humanType = new GraphQLObjectType({\n * name: 'Human',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const droidType = new GraphQLObjectType({\n * name: 'Droid',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const schema = new GraphQLSchema({\n * query: new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * hero: { type: characterInterface, ... },\n * }\n * }),\n * ...\n * // Since this schema references only the `Character` interface it's\n * // necessary to explicitly list the types that implement it if\n * // you want them to be included in the final schema.\n * types: [humanType, droidType],\n * })\n * ```\n *\n * Note: If an array of `directives` are provided to GraphQLSchema, that will be\n * the exact list of directives represented and allowed. If `directives` is not\n * provided then a default set of the specified directives (e.g. `@include` and\n * `@skip`) will be used. If you wish to provide *additional* directives to these\n * specified directives, you must explicitly declare them. Example:\n *\n * ```ts\n * const MyAppSchema = new GraphQLSchema({\n * ...\n * directives: specifiedDirectives.concat([ myCustomDirective ]),\n * })\n * ```\n */\nexport class GraphQLSchema {\n description: Maybe;\n extensions: Readonly;\n astNode: Maybe;\n extensionASTNodes: ReadonlyArray;\n\n assumeValid: boolean;\n __validationErrors: Maybe>;\n\n private _queryType: Maybe;\n private _mutationType: Maybe;\n private _subscriptionType: Maybe;\n private _directives: ReadonlyArray;\n private _typeMap: TypeMap;\n private _subTypeMap: Map<\n GraphQLAbstractType,\n Set\n >;\n\n private _implementationsMap: ObjMap<{\n objects: Array;\n interfaces: Array;\n }>;\n\n constructor(config: Readonly) {\n // If this schema was built from a source known to be valid, then it may be\n // marked with assumeValid to avoid an additional type system validation.\n this.assumeValid = config.assumeValid ?? false;\n // Used as a cache for validateSchema().\n this.__validationErrors = config.assumeValid === true ? [] : undefined;\n\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._queryType = config.query;\n this._mutationType = config.mutation;\n this._subscriptionType = config.subscription;\n // Provide specified directives (e.g. @include and @skip) by default.\n this._directives = config.directives ?? specifiedDirectives;\n\n // To preserve order of user-provided types, we add first to add them to\n // the set of \"collected\" types, so `collectReferencedTypes` ignore them.\n const allReferencedTypes = new Set(config.types);\n if (config.types != null) {\n for (const type of config.types) {\n // When we ready to process this type, we remove it from \"collected\" types\n // and then add it together with all dependent types in the correct position.\n allReferencedTypes.delete(type);\n collectReferencedTypes(type, allReferencedTypes);\n }\n }\n\n if (this._queryType != null) {\n collectReferencedTypes(this._queryType, allReferencedTypes);\n }\n if (this._mutationType != null) {\n collectReferencedTypes(this._mutationType, allReferencedTypes);\n }\n if (this._subscriptionType != null) {\n collectReferencedTypes(this._subscriptionType, allReferencedTypes);\n }\n\n for (const directive of this._directives) {\n // Directives are not validated until validateSchema() is called.\n if (isDirective(directive)) {\n for (const arg of directive.args) {\n collectReferencedTypes(arg.type, allReferencedTypes);\n }\n }\n }\n collectReferencedTypes(__Schema, allReferencedTypes);\n\n // Storing the resulting map for reference by the schema.\n this._typeMap = Object.create(null);\n this._subTypeMap = new Map();\n // Keep track of all implementations by interface name.\n this._implementationsMap = Object.create(null);\n\n for (const namedType of allReferencedTypes) {\n if (namedType == null) {\n continue;\n }\n\n const typeName = namedType.name;\n if (this._typeMap[typeName] !== undefined) {\n throw new Error(\n `Schema must contain uniquely named types but contains multiple types named \"${typeName}\".`,\n );\n }\n this._typeMap[typeName] = namedType;\n\n if (isInterfaceType(namedType)) {\n // Store implementations by interface.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n }\n\n implementations.interfaces.push(namedType);\n }\n }\n } else if (isObjectType(namedType)) {\n // Store implementations by objects.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n }\n\n implementations.objects.push(namedType);\n }\n }\n }\n }\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLSchema';\n }\n\n getQueryType(): Maybe {\n return this._queryType;\n }\n\n getMutationType(): Maybe {\n return this._mutationType;\n }\n\n getSubscriptionType(): Maybe {\n return this._subscriptionType;\n }\n\n getRootType(operation: OperationTypeNode): Maybe {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return this.getQueryType();\n case OperationTypeNode.MUTATION:\n return this.getMutationType();\n case OperationTypeNode.SUBSCRIPTION:\n return this.getSubscriptionType();\n }\n }\n\n getTypeMap(): TypeMap {\n return this._typeMap;\n }\n\n getType(name: string): GraphQLNamedType | undefined {\n return this.getTypeMap()[name];\n }\n\n getPossibleTypes(\n abstractType: GraphQLAbstractType,\n ): ReadonlyArray {\n return isUnionType(abstractType)\n ? abstractType.getTypes()\n : this.getImplementations(abstractType).objects;\n }\n\n getImplementations(interfaceType: GraphQLInterfaceType): {\n objects: ReadonlyArray;\n interfaces: ReadonlyArray;\n } {\n const implementations = this._implementationsMap[interfaceType.name];\n return implementations ?? { objects: [], interfaces: [] };\n }\n\n isSubType(\n abstractType: GraphQLAbstractType,\n maybeSubType: GraphQLObjectType | GraphQLInterfaceType,\n ): boolean {\n let set = this._subTypeMap.get(abstractType);\n if (set === undefined) {\n if (isUnionType(abstractType)) {\n set = new Set(abstractType.getTypes());\n } else {\n const implementations = this.getImplementations(abstractType);\n set = new Set([\n ...implementations.objects,\n ...implementations.interfaces,\n ]);\n }\n\n this._subTypeMap.set(abstractType, set);\n }\n return set.has(maybeSubType);\n }\n\n getDirectives(): ReadonlyArray {\n return this._directives;\n }\n\n getDirective(name: string): Maybe {\n return this.getDirectives().find((directive) => directive.name === name);\n }\n\n /**\n * This method looks up the field on the given type definition.\n * It has special casing for the three introspection fields, `__schema`,\n * `__type` and `__typename`.\n *\n * `__typename` is special because it can always be queried as a field, even\n * in situations where no other fields are allowed, like on a Union.\n *\n * `__schema` and `__type` could get automatically added to the query type,\n * but that would require mutating type definitions, which would cause issues.\n */\n getField(\n parentType: GraphQLCompositeType,\n fieldName: string,\n ): GraphQLField | undefined {\n switch (fieldName) {\n case SchemaMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? SchemaMetaFieldDef\n : undefined;\n case TypeMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? TypeMetaFieldDef\n : undefined;\n case TypeNameMetaFieldDef.name:\n return TypeNameMetaFieldDef;\n }\n\n // this function is part \"hot\" path inside executor and check presence\n // of 'getFields' is faster than to use `!isUnionType`\n if ('getFields' in parentType) {\n return parentType.getFields()[fieldName];\n }\n return undefined;\n }\n\n toConfig(): GraphQLSchemaNormalizedConfig {\n return {\n description: this.description,\n query: this.getQueryType(),\n mutation: this.getMutationType(),\n subscription: this.getSubscriptionType(),\n types: Object.values(this.getTypeMap()),\n directives: this.getDirectives(),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n assumeValid: this.assumeValid,\n };\n }\n}\n\ntype TypeMap = ObjMap;\n\nexport interface GraphQLSchemaValidationOptions {\n /**\n * When building a schema from a GraphQL service's introspection result, it\n * might be safe to assume the schema is valid. Set to true to assume the\n * produced schema is valid.\n *\n * Default: false\n */\n assumeValid?: boolean | undefined;\n}\n\nexport interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {\n description?: Maybe;\n query?: Maybe;\n mutation?: Maybe;\n subscription?: Maybe;\n types?: Maybe>;\n directives?: Maybe>;\n extensions?: Maybe>;\n astNode?: Maybe;\n extensionASTNodes?: Maybe>;\n}\n\n/**\n * @internal\n */\nexport interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig {\n description: Maybe;\n types: ReadonlyArray;\n directives: ReadonlyArray;\n extensions: Readonly;\n extensionASTNodes: ReadonlyArray;\n assumeValid: boolean;\n}\n\nfunction collectReferencedTypes(\n type: GraphQLType,\n typeSet: Set,\n): Set {\n const namedType = getNamedType(type);\n\n if (!typeSet.has(namedType)) {\n typeSet.add(namedType);\n if (isUnionType(namedType)) {\n for (const memberType of namedType.getTypes()) {\n collectReferencedTypes(memberType, typeSet);\n }\n } else if (isObjectType(namedType) || isInterfaceType(namedType)) {\n for (const interfaceType of namedType.getInterfaces()) {\n collectReferencedTypes(interfaceType, typeSet);\n }\n\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n for (const arg of field.args) {\n collectReferencedTypes(arg.type, typeSet);\n }\n }\n } else if (isInputObjectType(namedType)) {\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n }\n }\n }\n\n return typeSet;\n}\n"]} \ No newline at end of file diff --git a/type/validate.d.ts b/type/validate.d.ts new file mode 100644 index 0000000000..daa48eb783 --- /dev/null +++ b/type/validate.d.ts @@ -0,0 +1,15 @@ +import { GraphQLError } from '../error/GraphQLError.js'; +import type { GraphQLSchema } from './schema.js'; +/** + * Implements the "Type Validation" sub-sections of the specification's + * "Type System" section. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the Schema is valid. + */ +export declare function validateSchema(schema: GraphQLSchema): ReadonlyArray; +/** + * Utility function which asserts a schema is valid by throwing an error if + * it is invalid. + */ +export declare function assertValidSchema(schema: GraphQLSchema): void; diff --git a/type/validate.js b/type/validate.js new file mode 100644 index 0000000000..99dadb167b --- /dev/null +++ b/type/validate.js @@ -0,0 +1,625 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateSchema = validateSchema; +exports.assertValidSchema = assertValidSchema; +const AccumulatorMap_js_1 = require("../jsutils/AccumulatorMap.js"); +const capitalize_js_1 = require("../jsutils/capitalize.js"); +const formatList_js_1 = require("../jsutils/formatList.js"); +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const isIterableObject_js_1 = require("../jsutils/isIterableObject.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const keyMap_js_1 = require("../jsutils/keyMap.js"); +const mapValue_js_1 = require("../jsutils/mapValue.js"); +const printPathArray_js_1 = require("../jsutils/printPathArray.js"); +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const ast_js_1 = require("../language/ast.js"); +const kinds_js_1 = require("../language/kinds.js"); +const typeComparators_js_1 = require("../utilities/typeComparators.js"); +const validateInputValue_js_1 = require("../utilities/validateInputValue.js"); +const definition_js_1 = require("./definition.js"); +const directives_js_1 = require("./directives.js"); +const introspection_js_1 = require("./introspection.js"); +const schema_js_1 = require("./schema.js"); +/** + * Implements the "Type Validation" sub-sections of the specification's + * "Type System" section. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the Schema is valid. + */ +function validateSchema(schema) { + // First check to ensure the provided value is in fact a GraphQLSchema. + (0, schema_js_1.assertSchema)(schema); + // If this Schema has already been validated, return the previous results. + if (schema.__validationErrors) { + return schema.__validationErrors; + } + // Validate the schema, producing a list of errors. + const context = new SchemaValidationContext(schema); + validateRootTypes(context); + validateDirectives(context); + validateTypes(context); + // Persist the results of validation before returning to ensure validation + // does not run multiple times for this schema. + const errors = context.getErrors(); + schema.__validationErrors = errors; + return errors; +} +/** + * Utility function which asserts a schema is valid by throwing an error if + * it is invalid. + */ +function assertValidSchema(schema) { + const errors = validateSchema(schema); + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +class SchemaValidationContext { + constructor(schema) { + this._errors = []; + this.schema = schema; + } + reportError(message, nodes) { + const _nodes = Array.isArray(nodes) + ? nodes.filter(Boolean) + : nodes; + this._errors.push(new GraphQLError_js_1.GraphQLError(message, { nodes: _nodes })); + } + getErrors() { + return this._errors; + } +} +function validateRootTypes(context) { + const schema = context.schema; + if (schema.getQueryType() == null) { + context.reportError('Query root type must be provided.', schema.astNode); + } + const rootTypesMap = new AccumulatorMap_js_1.AccumulatorMap(); + for (const operationType of Object.values(ast_js_1.OperationTypeNode)) { + const rootType = schema.getRootType(operationType); + if (rootType != null) { + if (!(0, definition_js_1.isObjectType)(rootType)) { + const operationTypeStr = (0, capitalize_js_1.capitalize)(operationType); + const rootTypeStr = (0, inspect_js_1.inspect)(rootType); + context.reportError(operationType === ast_js_1.OperationTypeNode.QUERY + ? `${operationTypeStr} root type must be Object type, it cannot be ${rootTypeStr}.` + : `${operationTypeStr} root type must be Object type if provided, it cannot be ${rootTypeStr}.`, getOperationTypeNode(schema, operationType) ?? + rootType.astNode); + } + else { + rootTypesMap.add(rootType, operationType); + } + } + } + for (const [rootType, operationTypes] of rootTypesMap) { + if (operationTypes.length > 1) { + const operationList = (0, formatList_js_1.andList)(operationTypes); + context.reportError(`All root types must be different, "${rootType}" type is used as ${operationList} root types.`, operationTypes.map((operationType) => getOperationTypeNode(schema, operationType))); + } + } +} +function getOperationTypeNode(schema, operation) { + return [schema.astNode, ...schema.extensionASTNodes] + .flatMap((schemaNode) => schemaNode?.operationTypes ?? []) + .find((operationNode) => operationNode.operation === operation)?.type; +} +function validateDirectives(context) { + for (const directive of context.schema.getDirectives()) { + // Ensure all directives are in fact GraphQL directives. + if (!(0, directives_js_1.isDirective)(directive)) { + context.reportError(`Expected directive but got: ${(0, inspect_js_1.inspect)(directive)}.`, directive?.astNode); + continue; + } + // Ensure they are named correctly. + validateName(context, directive); + if (directive.locations.length === 0) { + context.reportError(`Directive ${directive} must include 1 or more locations.`, directive.astNode); + } + // Ensure the arguments are valid. + for (const arg of directive.args) { + // Ensure they are named correctly. + validateName(context, arg); + // Ensure the type is an input type. + if (!(0, definition_js_1.isInputType)(arg.type)) { + context.reportError(`The type of ${arg} must be Input Type ` + + `but got: ${(0, inspect_js_1.inspect)(arg.type)}.`, arg.astNode); + } + if ((0, definition_js_1.isRequiredArgument)(arg) && arg.deprecationReason != null) { + context.reportError(`Required argument ${arg} cannot be deprecated.`, [ + getDeprecatedDirectiveNode(arg.astNode), + arg.astNode?.type, + ]); + } + validateDefaultValue(context, arg); + } + } +} +function validateDefaultValue(context, inputValue) { + const defaultInput = inputValue.default; + if (!defaultInput) { + return; + } + if (defaultInput.literal) { + (0, validateInputValue_js_1.validateInputLiteral)(defaultInput.literal, inputValue.type, (error, path) => { + context.reportError(`${inputValue} has invalid default value${(0, printPathArray_js_1.printPathArray)(path)}: ${error.message}`, error.nodes); + }); + } + else { + const errors = []; + (0, validateInputValue_js_1.validateInputValue)(defaultInput.value, inputValue.type, (error, path) => { + errors.push([error, path]); + }); + // If there were validation errors, check to see if it can be "uncoerced" + // and then correctly validated. If so, report a clear error with a path + // to resolution. + if (errors.length > 0) { + try { + const uncoercedValue = uncoerceDefaultValue(defaultInput.value, inputValue.type); + const uncoercedErrors = []; + (0, validateInputValue_js_1.validateInputValue)(uncoercedValue, inputValue.type, (error, path) => { + uncoercedErrors.push([error, path]); + }); + if (uncoercedErrors.length === 0) { + context.reportError(`${inputValue} has invalid default value: ${(0, inspect_js_1.inspect)(defaultInput.value)}. Did you mean: ${(0, inspect_js_1.inspect)(uncoercedValue)}?`, inputValue.astNode?.defaultValue); + return; + } + } + catch (_error) { + // ignore + } + } + // Otherwise report the original set of errors. + for (const [error, path] of errors) { + context.reportError(`${inputValue} has invalid default value${(0, printPathArray_js_1.printPathArray)(path)}: ${error.message}`, inputValue.astNode?.defaultValue); + } + } +} +/** + * Historically GraphQL.js allowed default values to be provided as + * assumed-coerced "internal" values, however default values should be provided + * as "external" pre-coerced values. `uncoerceDefaultValue()` will convert such + * "internal" values to "external" values to display as part of validation. + * + * This performs the "opposite" of `coerceInputValue()`. Given an "internal" + * coerced value, reverse the process to provide an "external" uncoerced value. + */ +function uncoerceDefaultValue(value, type) { + if ((0, definition_js_1.isNonNullType)(type)) { + return uncoerceDefaultValue(value, type.ofType); + } + if (value === null) { + return null; + } + if ((0, definition_js_1.isListType)(type)) { + if ((0, isIterableObject_js_1.isIterableObject)(value)) { + return Array.from(value, (itemValue) => uncoerceDefaultValue(itemValue, type.ofType)); + } + return [uncoerceDefaultValue(value, type.ofType)]; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + ((0, isObjectLike_js_1.isObjectLike)(value)) || (0, invariant_js_1.invariant)(false); + const fieldDefs = type.getFields(); + return (0, mapValue_js_1.mapValue)(value, (fieldValue, fieldName) => { + (fieldName in fieldDefs) || (0, invariant_js_1.invariant)(false); + return uncoerceDefaultValue(fieldValue, fieldDefs[fieldName].type); + }); + } + (0, definition_js_1.assertLeafType)(type); + // For most leaf types (Scalars, Enums), output value coercion ("serialize") is + // the inverse of input coercion ("parseValue") and will produce an + // "external" value. Historically, this method was also used as part of the + // now-deprecated "astFromValue" to perform the same behavior. + return type.coerceOutputValue(value); +} +function validateName(context, node) { + // Ensure names are valid, however introspection types opt out. + if (node.name.startsWith('__')) { + context.reportError(`Name "${node.name}" must not begin with "__", which is reserved by GraphQL introspection.`, node.astNode); + } +} +function validateTypes(context) { + // Ensure Input Objects do not contain non-nullable circular references. + const validateInputObjectNonNullCircularRefs = createInputObjectNonNullCircularRefsValidator(context); + const validateInputObjectDefaultValueCircularRefs = createInputObjectDefaultValueCircularRefsValidator(context); + const typeMap = context.schema.getTypeMap(); + for (const type of Object.values(typeMap)) { + // Ensure all provided types are in fact GraphQL type. + if (!(0, definition_js_1.isNamedType)(type)) { + context.reportError(`Expected GraphQL named type but got: ${(0, inspect_js_1.inspect)(type)}.`, type.astNode); + continue; + } + // Ensure it is named correctly (excluding introspection types). + if (!(0, introspection_js_1.isIntrospectionType)(type)) { + validateName(context, type); + } + if ((0, definition_js_1.isObjectType)(type)) { + // Ensure fields are valid + validateFields(context, type); + // Ensure objects implement the interfaces they claim to. + validateInterfaces(context, type); + } + else if ((0, definition_js_1.isInterfaceType)(type)) { + // Ensure fields are valid. + validateFields(context, type); + // Ensure interfaces implement the interfaces they claim to. + validateInterfaces(context, type); + } + else if ((0, definition_js_1.isUnionType)(type)) { + // Ensure Unions include valid member types. + validateUnionMembers(context, type); + } + else if ((0, definition_js_1.isEnumType)(type)) { + // Ensure Enums have valid values. + validateEnumValues(context, type); + } + else if ((0, definition_js_1.isInputObjectType)(type)) { + // Ensure Input Object fields are valid. + validateInputFields(context, type); + // Ensure Input Objects do not contain invalid field circular references. + // Ensure Input Objects do not contain non-nullable circular references. + validateInputObjectNonNullCircularRefs(type); + // Ensure Input Objects do not contain invalid default value circular references. + validateInputObjectDefaultValueCircularRefs(type); + } + } +} +function validateFields(context, type) { + const fields = Object.values(type.getFields()); + // Objects and Interfaces both must define one or more fields. + if (fields.length === 0) { + context.reportError(`Type ${type} must define one or more fields.`, [ + type.astNode, + ...type.extensionASTNodes, + ]); + } + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); + // Ensure the type is an output type + if (!(0, definition_js_1.isOutputType)(field.type)) { + context.reportError(`The type of ${field} must be Output Type ` + + `but got: ${(0, inspect_js_1.inspect)(field.type)}.`, field.astNode?.type); + } + // Ensure the arguments are valid + for (const arg of field.args) { + // Ensure they are named correctly. + validateName(context, arg); + // Ensure the type is an input type + if (!(0, definition_js_1.isInputType)(arg.type)) { + context.reportError(`The type of ${arg} must be Input Type but got: ${(0, inspect_js_1.inspect)(arg.type)}.`, arg.astNode?.type); + } + if ((0, definition_js_1.isRequiredArgument)(arg) && arg.deprecationReason != null) { + context.reportError(`Required argument ${arg} cannot be deprecated.`, [ + getDeprecatedDirectiveNode(arg.astNode), + arg.astNode?.type, + ]); + } + validateDefaultValue(context, arg); + } + } +} +function validateInterfaces(context, type) { + const ifaceTypeNames = new Set(); + for (const iface of type.getInterfaces()) { + if (!(0, definition_js_1.isInterfaceType)(iface)) { + context.reportError(`Type ${type} must only implement Interface types, ` + + `it cannot implement ${(0, inspect_js_1.inspect)(iface)}.`, getAllImplementsInterfaceNodes(type, iface)); + continue; + } + if (type === iface) { + context.reportError(`Type ${type} cannot implement itself because it would create a circular reference.`, getAllImplementsInterfaceNodes(type, iface)); + continue; + } + if (ifaceTypeNames.has(iface.name)) { + context.reportError(`Type ${type} can only implement ${iface} once.`, getAllImplementsInterfaceNodes(type, iface)); + continue; + } + ifaceTypeNames.add(iface.name); + validateTypeImplementsAncestors(context, type, iface); + validateTypeImplementsInterface(context, type, iface); + } +} +function validateTypeImplementsInterface(context, type, iface) { + const typeFieldMap = type.getFields(); + // Assert each interface field is implemented. + for (const ifaceField of Object.values(iface.getFields())) { + const typeField = typeFieldMap[ifaceField.name]; + // Assert interface field exists on type. + if (typeField == null) { + context.reportError(`Interface field ${ifaceField} expected but ${type} does not provide it.`, [ifaceField.astNode, type.astNode, ...type.extensionASTNodes]); + continue; + } + // Assert interface field type is satisfied by type field type, by being + // a valid subtype. (covariant) + if (!(0, typeComparators_js_1.isTypeSubTypeOf)(context.schema, typeField.type, ifaceField.type)) { + context.reportError(`Interface field ${ifaceField} expects type ${ifaceField.type} ` + + `but ${typeField} is type ${typeField.type}.`, [ifaceField.astNode?.type, typeField.astNode?.type]); + } + // Assert each interface field arg is implemented. + for (const ifaceArg of ifaceField.args) { + const typeArg = typeField.args.find((arg) => arg.name === ifaceArg.name); + // Assert interface field arg exists on object field. + if (!typeArg) { + context.reportError(`Interface field argument ${ifaceArg} expected but ${typeField} does not provide it.`, [ifaceArg.astNode, typeField.astNode]); + continue; + } + // Assert interface field arg type matches object field arg type. + // (invariant) + // TODO: change to contravariant? + if (!(0, typeComparators_js_1.isEqualType)(ifaceArg.type, typeArg.type)) { + context.reportError(`Interface field argument ${ifaceArg} expects type ${ifaceArg.type} ` + + `but ${typeArg} is type ${typeArg.type}.`, [ifaceArg.astNode?.type, typeArg.astNode?.type]); + } + } + // Assert additional arguments must not be required. + for (const typeArg of typeField.args) { + if ((0, definition_js_1.isRequiredArgument)(typeArg)) { + const ifaceArg = ifaceField.args.find((arg) => arg.name === typeArg.name); + if (!ifaceArg) { + context.reportError(`Argument "${typeArg}" must not be required type "${typeArg.type}" ` + + `if not provided by the Interface field "${ifaceField}".`, [typeArg.astNode, ifaceField.astNode]); + } + } + } + // Asserts that field is not deprecated unless interface field is + if (typeField.deprecationReason != null && + ifaceField.deprecationReason == null) { + context.reportError(`Interface field ${iface.name}.${ifaceField.name} is not deprecated, so ` + + `implementation field ${type.name}.${typeField.name} must not be deprecated.`, [ + getDeprecatedDirectiveNode(typeField.astNode), + typeField.astNode?.type, + ]); + } + } +} +function validateTypeImplementsAncestors(context, type, iface) { + const ifaceInterfaces = type.getInterfaces(); + for (const transitive of iface.getInterfaces()) { + if (!ifaceInterfaces.includes(transitive)) { + context.reportError(transitive === type + ? `Type ${type} cannot implement ${iface} because it would create a circular reference.` + : `Type ${type} must implement ${transitive} because it is implemented by ${iface}.`, [ + ...getAllImplementsInterfaceNodes(iface, transitive), + ...getAllImplementsInterfaceNodes(type, iface), + ]); + } + } +} +function validateUnionMembers(context, union) { + const memberTypes = union.getTypes(); + if (memberTypes.length === 0) { + context.reportError(`Union type ${union} must define one or more member types.`, [union.astNode, ...union.extensionASTNodes]); + } + const includedTypeNames = new Set(); + for (const memberType of memberTypes) { + if (includedTypeNames.has(memberType.name)) { + context.reportError(`Union type ${union} can only include type ${memberType} once.`, getUnionMemberTypeNodes(union, memberType.name)); + continue; + } + includedTypeNames.add(memberType.name); + if (!(0, definition_js_1.isObjectType)(memberType)) { + context.reportError(`Union type ${union} can only include Object types, ` + + `it cannot include ${(0, inspect_js_1.inspect)(memberType)}.`, getUnionMemberTypeNodes(union, String(memberType))); + } + } +} +function validateEnumValues(context, enumType) { + const enumValues = enumType.getValues(); + if (enumValues.length === 0) { + context.reportError(`Enum type ${enumType} must define one or more values.`, [enumType.astNode, ...enumType.extensionASTNodes]); + } + for (const enumValue of enumValues) { + // Ensure valid name. + validateName(context, enumValue); + } +} +function validateInputFields(context, inputObj) { + const fields = Object.values(inputObj.getFields()); + if (fields.length === 0) { + context.reportError(`Input Object type ${inputObj} must define one or more fields.`, [inputObj.astNode, ...inputObj.extensionASTNodes]); + } + // Ensure the input fields are valid + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); + // Ensure the type is an input type + if (!(0, definition_js_1.isInputType)(field.type)) { + context.reportError(`The type of ${field} must be Input Type ` + + `but got: ${(0, inspect_js_1.inspect)(field.type)}.`, field.astNode?.type); + } + if ((0, definition_js_1.isRequiredInputField)(field) && field.deprecationReason != null) { + context.reportError(`Required input field ${field} cannot be deprecated.`, [getDeprecatedDirectiveNode(field.astNode), field.astNode?.type]); + } + validateDefaultValue(context, field); + if (inputObj.isOneOf) { + validateOneOfInputObjectField(inputObj, field, context); + } + } +} +function validateOneOfInputObjectField(type, field, context) { + if ((0, definition_js_1.isNonNullType)(field.type)) { + context.reportError(`OneOf input field ${type}.${field.name} must be nullable.`, field.astNode?.type); + } + if (field.default !== undefined || field.defaultValue !== undefined) { + context.reportError(`OneOf input field ${type}.${field.name} cannot have a default value.`, field.astNode); + } +} +function createInputObjectNonNullCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedTypes = new Set(); + // Array of types nodes used to produce meaningful errors + const fieldPath = []; + // Position in the type path + const fieldPathIndexByTypeName = Object.create(null); + return detectCycleRecursive; + // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + function detectCycleRecursive(inputObj) { + if (visitedTypes.has(inputObj)) { + return; + } + visitedTypes.add(inputObj); + fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; + const fields = Object.values(inputObj.getFields()); + for (const field of fields) { + if ((0, definition_js_1.isNonNullType)(field.type) && (0, definition_js_1.isInputObjectType)(field.type.ofType)) { + const fieldType = field.type.ofType; + const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; + fieldPath.push({ + fieldStr: `${inputObj}.${field.name}`, + astNode: field.astNode, + }); + if (cycleIndex === undefined) { + detectCycleRecursive(fieldType); + } + else { + const cyclePath = fieldPath.slice(cycleIndex); + const pathStr = cyclePath + .map((fieldObj) => fieldObj.fieldStr) + .join(', '); + context.reportError(`Invalid circular reference. The Input Object ${fieldType} references itself ${cyclePath.length > 1 + ? 'via the non-null fields:' + : 'in the non-null field'} ${pathStr}.`, cyclePath.map((fieldObj) => fieldObj.astNode)); + } + fieldPath.pop(); + } + } + fieldPathIndexByTypeName[inputObj.name] = undefined; + } +} +function createInputObjectDefaultValueCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFields = Object.create(null); + // Array of keys for fields and default values used to produce meaningful errors. + const fieldPath = []; + // Position in the path + const fieldPathIndex = Object.create(null); + // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + return function validateInputObjectDefaultValueCircularRefs(inputObj) { + // Start with an empty object as a way to visit every field in this input + // object type and apply every default value. + return detectValueDefaultValueCycle(inputObj, {}); + }; + function detectValueDefaultValueCycle(inputObj, defaultValue) { + // If the value is a List, recursively check each entry for a cycle. + // Otherwise, only object values can contain a cycle. + if ((0, isIterableObject_js_1.isIterableObject)(defaultValue)) { + for (const itemValue of defaultValue) { + detectValueDefaultValueCycle(inputObj, itemValue); + } + return; + } + else if (!(0, isObjectLike_js_1.isObjectLike)(defaultValue)) { + return; + } + // Check each defined field for a cycle. + for (const field of Object.values(inputObj.getFields())) { + const namedFieldType = (0, definition_js_1.getNamedType)(field.type); + // Only input object type fields can result in a cycle. + if (!(0, definition_js_1.isInputObjectType)(namedFieldType)) { + continue; + } + if (Object.hasOwn(defaultValue, field.name)) { + // If the provided value has this field defined, recursively check it + // for cycles. + detectValueDefaultValueCycle(namedFieldType, defaultValue[field.name]); + } + else { + // Otherwise check this field's default value for cycles. + detectFieldDefaultValueCycle(field, namedFieldType, `${inputObj}.${field.name}`); + } + } + } + function detectLiteralDefaultValueCycle(inputObj, defaultValue) { + // If the value is a List, recursively check each entry for a cycle. + // Otherwise, only object values can contain a cycle. + if (defaultValue.kind === kinds_js_1.Kind.LIST) { + for (const itemLiteral of defaultValue.values) { + detectLiteralDefaultValueCycle(inputObj, itemLiteral); + } + return; + } + else if (defaultValue.kind !== kinds_js_1.Kind.OBJECT) { + return; + } + // Check each defined field for a cycle. + const fieldNodes = (0, keyMap_js_1.keyMap)(defaultValue.fields, (field) => field.name.value); + for (const field of Object.values(inputObj.getFields())) { + const namedFieldType = (0, definition_js_1.getNamedType)(field.type); + // Only input object type fields can result in a cycle. + if (!(0, definition_js_1.isInputObjectType)(namedFieldType)) { + continue; + } + if (Object.hasOwn(fieldNodes, field.name)) { + // If the provided value has this field defined, recursively check it + // for cycles. + detectLiteralDefaultValueCycle(namedFieldType, fieldNodes[field.name].value); + } + else { + // Otherwise check this field's default value for cycles. + detectFieldDefaultValueCycle(field, namedFieldType, `${inputObj}.${field.name}`); + } + } + } + function detectFieldDefaultValueCycle(field, fieldType, fieldStr) { + // Only a field with a default value can result in a cycle. + const defaultInput = field.default; + if (defaultInput === undefined) { + return; + } + // Check to see if there is cycle. + const cycleIndex = fieldPathIndex[fieldStr]; + if (cycleIndex !== undefined && cycleIndex > 0) { + context.reportError(`Invalid circular reference. The default value of Input Object field ${fieldStr} references itself${cycleIndex < fieldPath.length + ? ` via the default values of: ${fieldPath + .slice(cycleIndex) + .map(([stringForMessage]) => stringForMessage) + .join(', ')}` + : ''}.`, fieldPath.slice(cycleIndex - 1).map(([, node]) => node)); + return; + } + // Recurse into this field's default value once, tracking the path. + if (visitedFields[fieldStr] === undefined) { + visitedFields[fieldStr] = true; + fieldPathIndex[fieldStr] = fieldPath.push([ + fieldStr, + field.astNode?.defaultValue, + ]); + if (defaultInput.literal) { + detectLiteralDefaultValueCycle(fieldType, defaultInput.literal); + } + else { + detectValueDefaultValueCycle(fieldType, defaultInput.value); + } + fieldPath.pop(); + fieldPathIndex[fieldStr] = undefined; + } + } +} +function getAllImplementsInterfaceNodes(type, iface) { + const { astNode, extensionASTNodes } = type; + const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; + return nodes + .flatMap((typeNode) => typeNode.interfaces ?? []) + .filter((ifaceNode) => ifaceNode.name.value === iface.name); +} +function getUnionMemberTypeNodes(union, typeName) { + const { astNode, extensionASTNodes } = union; + const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; + return nodes + .flatMap((unionNode) => /* c8 ignore next */ unionNode.types ?? []) + .filter((typeNode) => typeNode.name.value === typeName); +} +function getDeprecatedDirectiveNode(definitionNode) { + return definitionNode?.directives?.find((node) => node.name.value === directives_js_1.GraphQLDeprecatedDirective.name); +} +//# sourceMappingURL=validate.js.map \ No newline at end of file diff --git a/type/validate.js.map b/type/validate.js.map new file mode 100644 index 0000000000..532cab8999 --- /dev/null +++ b/type/validate.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/type/validate.ts"],"names":[],"mappings":";;AA0EA,wCAsBC;AAMD,8CAKC;AA3GD,oEAA8D;AAC9D,4DAAsD;AACtD,4DAAmD;AACnD,sDAAgD;AAChD,0DAAoD;AACpD,wEAAkE;AAClE,gEAA0D;AAC1D,oDAA8C;AAC9C,wDAAkD;AAGlD,oEAA8D;AAE9D,8DAAwD;AAcxD,+CAAuD;AACvD,mDAA4C;AAE5C,wEAA+E;AAC/E,8EAG4C;AAY5C,mDAeyB;AACzB,mDAA0E;AAC1E,yDAAyD;AAEzD,2CAA2C;AAE3C;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,MAAqB;IAErB,uEAAuE;IACvE,IAAA,wBAAY,EAAC,MAAM,CAAC,CAAC;IAErB,0EAA0E;IAC1E,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAED,mDAAmD;IACnD,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACpD,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3B,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC5B,aAAa,CAAC,OAAO,CAAC,CAAC;IAEvB,0EAA0E;IAC1E,+CAA+C;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC;IACnC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,MAAqB;IACrD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,MAAM,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AE,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IAC5C,MAAM,KAAK,GAKP,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAE1E,OAAO,KAAK;SACT,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;SAChD,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,uBAAuB,CAC9B,KAAuB,EACvB,QAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC;IAC7C,MAAM,KAAK,GACT,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAExE,OAAO,KAAK;SACT,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC;SAClE,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,0BAA0B,CACjC,cAEE;IAEF,OAAO,cAAc,EAAE,UAAU,EAAE,IAAI,CACrC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,0CAA0B,CAAC,IAAI,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["import { AccumulatorMap } from '../jsutils/AccumulatorMap.js';\nimport { capitalize } from '../jsutils/capitalize.js';\nimport { andList } from '../jsutils/formatList.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyMap } from '../jsutils/keyMap.js';\nimport { mapValue } from '../jsutils/mapValue.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { printPathArray } from '../jsutils/printPathArray.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ASTNode,\n ConstValueNode,\n DirectiveNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n NamedTypeNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n} from '../language/ast.js';\nimport { OperationTypeNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators.js';\nimport {\n validateInputLiteral,\n validateInputValue,\n} from '../utilities/validateInputValue.js';\n\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInputType,\n GraphQLInterfaceType,\n GraphQLObjectType,\n GraphQLUnionType,\n} from './definition.js';\nimport {\n assertLeafType,\n getNamedType,\n isEnumType,\n isInputObjectType,\n isInputType,\n isInterfaceType,\n isListType,\n isNamedType,\n isNonNullType,\n isObjectType,\n isOutputType,\n isRequiredArgument,\n isRequiredInputField,\n isUnionType,\n} from './definition.js';\nimport { GraphQLDeprecatedDirective, isDirective } from './directives.js';\nimport { isIntrospectionType } from './introspection.js';\nimport type { GraphQLSchema } from './schema.js';\nimport { assertSchema } from './schema.js';\n\n/**\n * Implements the \"Type Validation\" sub-sections of the specification's\n * \"Type System\" section.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the Schema is valid.\n */\nexport function validateSchema(\n schema: GraphQLSchema,\n): ReadonlyArray {\n // First check to ensure the provided value is in fact a GraphQLSchema.\n assertSchema(schema);\n\n // If this Schema has already been validated, return the previous results.\n if (schema.__validationErrors) {\n return schema.__validationErrors;\n }\n\n // Validate the schema, producing a list of errors.\n const context = new SchemaValidationContext(schema);\n validateRootTypes(context);\n validateDirectives(context);\n validateTypes(context);\n\n // Persist the results of validation before returning to ensure validation\n // does not run multiple times for this schema.\n const errors = context.getErrors();\n schema.__validationErrors = errors;\n return errors;\n}\n\n/**\n * Utility function which asserts a schema is valid by throwing an error if\n * it is invalid.\n */\nexport function assertValidSchema(schema: GraphQLSchema): void {\n const errors = validateSchema(schema);\n if (errors.length !== 0) {\n throw new Error(errors.map((error) => error.message).join('\\n\\n'));\n }\n}\n\nclass SchemaValidationContext {\n readonly _errors: Array;\n readonly schema: GraphQLSchema;\n\n constructor(schema: GraphQLSchema) {\n this._errors = [];\n this.schema = schema;\n }\n\n reportError(\n message: string,\n nodes?: ReadonlyArray> | Maybe,\n ): void {\n const _nodes = Array.isArray(nodes)\n ? (nodes.filter(Boolean) as ReadonlyArray)\n : (nodes as Maybe);\n this._errors.push(new GraphQLError(message, { nodes: _nodes }));\n }\n\n getErrors(): ReadonlyArray {\n return this._errors;\n }\n}\n\nfunction validateRootTypes(context: SchemaValidationContext): void {\n const schema = context.schema;\n\n if (schema.getQueryType() == null) {\n context.reportError('Query root type must be provided.', schema.astNode);\n }\n\n const rootTypesMap = new AccumulatorMap<\n GraphQLObjectType,\n OperationTypeNode\n >();\n for (const operationType of Object.values(OperationTypeNode)) {\n const rootType = schema.getRootType(operationType);\n\n if (rootType != null) {\n if (!isObjectType(rootType)) {\n const operationTypeStr = capitalize(operationType);\n const rootTypeStr = inspect(rootType);\n context.reportError(\n operationType === OperationTypeNode.QUERY\n ? `${operationTypeStr} root type must be Object type, it cannot be ${rootTypeStr}.`\n : `${operationTypeStr} root type must be Object type if provided, it cannot be ${rootTypeStr}.`,\n getOperationTypeNode(schema, operationType) ??\n (rootType as any).astNode,\n );\n } else {\n rootTypesMap.add(rootType, operationType);\n }\n }\n }\n\n for (const [rootType, operationTypes] of rootTypesMap) {\n if (operationTypes.length > 1) {\n const operationList = andList(operationTypes);\n context.reportError(\n `All root types must be different, \"${rootType}\" type is used as ${operationList} root types.`,\n operationTypes.map((operationType) =>\n getOperationTypeNode(schema, operationType),\n ),\n );\n }\n }\n}\n\nfunction getOperationTypeNode(\n schema: GraphQLSchema,\n operation: OperationTypeNode,\n): Maybe {\n return [schema.astNode, ...schema.extensionASTNodes]\n .flatMap((schemaNode) => schemaNode?.operationTypes ?? [])\n .find((operationNode) => operationNode.operation === operation)?.type;\n}\n\nfunction validateDirectives(context: SchemaValidationContext): void {\n for (const directive of context.schema.getDirectives()) {\n // Ensure all directives are in fact GraphQL directives.\n if (!isDirective(directive)) {\n context.reportError(\n `Expected directive but got: ${inspect(directive)}.`,\n (directive as any)?.astNode,\n );\n continue;\n }\n\n // Ensure they are named correctly.\n validateName(context, directive);\n\n if (directive.locations.length === 0) {\n context.reportError(\n `Directive ${directive} must include 1 or more locations.`,\n directive.astNode,\n );\n }\n\n // Ensure the arguments are valid.\n for (const arg of directive.args) {\n // Ensure they are named correctly.\n validateName(context, arg);\n\n // Ensure the type is an input type.\n if (!isInputType(arg.type)) {\n context.reportError(\n `The type of ${arg} must be Input Type ` +\n `but got: ${inspect(arg.type)}.`,\n arg.astNode,\n );\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument ${arg} cannot be deprecated.`, [\n getDeprecatedDirectiveNode(arg.astNode),\n arg.astNode?.type,\n ]);\n }\n\n validateDefaultValue(context, arg);\n }\n }\n}\n\nfunction validateDefaultValue(\n context: SchemaValidationContext,\n inputValue: GraphQLArgument | GraphQLInputField,\n): void {\n const defaultInput = inputValue.default;\n\n if (!defaultInput) {\n return;\n }\n\n if (defaultInput.literal) {\n validateInputLiteral(\n defaultInput.literal,\n inputValue.type,\n (error, path) => {\n context.reportError(\n `${inputValue} has invalid default value${printPathArray(path)}: ${\n error.message\n }`,\n error.nodes,\n );\n },\n );\n } else {\n const errors: Array<[GraphQLError, ReadonlyArray]> = [];\n validateInputValue(defaultInput.value, inputValue.type, (error, path) => {\n errors.push([error, path]);\n });\n\n // If there were validation errors, check to see if it can be \"uncoerced\"\n // and then correctly validated. If so, report a clear error with a path\n // to resolution.\n if (errors.length > 0) {\n try {\n const uncoercedValue = uncoerceDefaultValue(\n defaultInput.value,\n inputValue.type,\n );\n\n const uncoercedErrors = [];\n validateInputValue(uncoercedValue, inputValue.type, (error, path) => {\n uncoercedErrors.push([error, path]);\n });\n\n if (uncoercedErrors.length === 0) {\n context.reportError(\n `${inputValue} has invalid default value: ${inspect(\n defaultInput.value,\n )}. Did you mean: ${inspect(uncoercedValue)}?`,\n inputValue.astNode?.defaultValue,\n );\n return;\n }\n } catch (_error) {\n // ignore\n }\n }\n\n // Otherwise report the original set of errors.\n for (const [error, path] of errors) {\n context.reportError(\n `${inputValue} has invalid default value${printPathArray(path)}: ${\n error.message\n }`,\n inputValue.astNode?.defaultValue,\n );\n }\n }\n}\n\n/**\n * Historically GraphQL.js allowed default values to be provided as\n * assumed-coerced \"internal\" values, however default values should be provided\n * as \"external\" pre-coerced values. `uncoerceDefaultValue()` will convert such\n * \"internal\" values to \"external\" values to display as part of validation.\n *\n * This performs the \"opposite\" of `coerceInputValue()`. Given an \"internal\"\n * coerced value, reverse the process to provide an \"external\" uncoerced value.\n */\nfunction uncoerceDefaultValue(value: unknown, type: GraphQLInputType): unknown {\n if (isNonNullType(type)) {\n return uncoerceDefaultValue(value, type.ofType);\n }\n\n if (value === null) {\n return null;\n }\n\n if (isListType(type)) {\n if (isIterableObject(value)) {\n return Array.from(value, (itemValue) =>\n uncoerceDefaultValue(itemValue, type.ofType),\n );\n }\n return [uncoerceDefaultValue(value, type.ofType)];\n }\n\n if (isInputObjectType(type)) {\n invariant(isObjectLike(value));\n const fieldDefs = type.getFields();\n return mapValue(value, (fieldValue, fieldName) => {\n invariant(fieldName in fieldDefs);\n return uncoerceDefaultValue(fieldValue, fieldDefs[fieldName].type);\n });\n }\n\n assertLeafType(type);\n\n // For most leaf types (Scalars, Enums), output value coercion (\"serialize\") is\n // the inverse of input coercion (\"parseValue\") and will produce an\n // \"external\" value. Historically, this method was also used as part of the\n // now-deprecated \"astFromValue\" to perform the same behavior.\n return type.coerceOutputValue(value);\n}\n\nfunction validateName(\n context: SchemaValidationContext,\n node: { readonly name: string; readonly astNode: Maybe },\n): void {\n // Ensure names are valid, however introspection types opt out.\n if (node.name.startsWith('__')) {\n context.reportError(\n `Name \"${node.name}\" must not begin with \"__\", which is reserved by GraphQL introspection.`,\n node.astNode,\n );\n }\n}\n\nfunction validateTypes(context: SchemaValidationContext): void {\n // Ensure Input Objects do not contain non-nullable circular references.\n const validateInputObjectNonNullCircularRefs =\n createInputObjectNonNullCircularRefsValidator(context);\n const validateInputObjectDefaultValueCircularRefs =\n createInputObjectDefaultValueCircularRefsValidator(context);\n const typeMap = context.schema.getTypeMap();\n for (const type of Object.values(typeMap)) {\n // Ensure all provided types are in fact GraphQL type.\n if (!isNamedType(type)) {\n context.reportError(\n `Expected GraphQL named type but got: ${inspect(type)}.`,\n (type as any).astNode,\n );\n continue;\n }\n\n // Ensure it is named correctly (excluding introspection types).\n if (!isIntrospectionType(type)) {\n validateName(context, type);\n }\n\n if (isObjectType(type)) {\n // Ensure fields are valid\n validateFields(context, type);\n\n // Ensure objects implement the interfaces they claim to.\n validateInterfaces(context, type);\n } else if (isInterfaceType(type)) {\n // Ensure fields are valid.\n validateFields(context, type);\n\n // Ensure interfaces implement the interfaces they claim to.\n validateInterfaces(context, type);\n } else if (isUnionType(type)) {\n // Ensure Unions include valid member types.\n validateUnionMembers(context, type);\n } else if (isEnumType(type)) {\n // Ensure Enums have valid values.\n validateEnumValues(context, type);\n } else if (isInputObjectType(type)) {\n // Ensure Input Object fields are valid.\n validateInputFields(context, type);\n\n // Ensure Input Objects do not contain invalid field circular references.\n // Ensure Input Objects do not contain non-nullable circular references.\n validateInputObjectNonNullCircularRefs(type);\n\n // Ensure Input Objects do not contain invalid default value circular references.\n validateInputObjectDefaultValueCircularRefs(type);\n }\n }\n}\n\nfunction validateFields(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n): void {\n const fields = Object.values(type.getFields());\n\n // Objects and Interfaces both must define one or more fields.\n if (fields.length === 0) {\n context.reportError(`Type ${type} must define one or more fields.`, [\n type.astNode,\n ...type.extensionASTNodes,\n ]);\n }\n\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field);\n\n // Ensure the type is an output type\n if (!isOutputType(field.type)) {\n context.reportError(\n `The type of ${field} must be Output Type ` +\n `but got: ${inspect(field.type)}.`,\n field.astNode?.type,\n );\n }\n\n // Ensure the arguments are valid\n for (const arg of field.args) {\n // Ensure they are named correctly.\n validateName(context, arg);\n\n // Ensure the type is an input type\n if (!isInputType(arg.type)) {\n context.reportError(\n `The type of ${arg} must be Input Type but got: ${inspect(arg.type)}.`,\n arg.astNode?.type,\n );\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument ${arg} cannot be deprecated.`, [\n getDeprecatedDirectiveNode(arg.astNode),\n arg.astNode?.type,\n ]);\n }\n\n validateDefaultValue(context, arg);\n }\n }\n}\n\nfunction validateInterfaces(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n): void {\n const ifaceTypeNames = new Set();\n for (const iface of type.getInterfaces()) {\n if (!isInterfaceType(iface)) {\n context.reportError(\n `Type ${type} must only implement Interface types, ` +\n `it cannot implement ${inspect(iface)}.`,\n getAllImplementsInterfaceNodes(type, iface),\n );\n continue;\n }\n\n if (type === iface) {\n context.reportError(\n `Type ${type} cannot implement itself because it would create a circular reference.`,\n getAllImplementsInterfaceNodes(type, iface),\n );\n continue;\n }\n\n if (ifaceTypeNames.has(iface.name)) {\n context.reportError(\n `Type ${type} can only implement ${iface} once.`,\n getAllImplementsInterfaceNodes(type, iface),\n );\n continue;\n }\n\n ifaceTypeNames.add(iface.name);\n\n validateTypeImplementsAncestors(context, type, iface);\n validateTypeImplementsInterface(context, type, iface);\n }\n}\n\nfunction validateTypeImplementsInterface(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n iface: GraphQLInterfaceType,\n): void {\n const typeFieldMap = type.getFields();\n\n // Assert each interface field is implemented.\n for (const ifaceField of Object.values(iface.getFields())) {\n const typeField = typeFieldMap[ifaceField.name];\n\n // Assert interface field exists on type.\n if (typeField == null) {\n context.reportError(\n `Interface field ${ifaceField} expected but ${type} does not provide it.`,\n [ifaceField.astNode, type.astNode, ...type.extensionASTNodes],\n );\n continue;\n }\n\n // Assert interface field type is satisfied by type field type, by being\n // a valid subtype. (covariant)\n if (!isTypeSubTypeOf(context.schema, typeField.type, ifaceField.type)) {\n context.reportError(\n `Interface field ${ifaceField} expects type ${ifaceField.type} ` +\n `but ${typeField} is type ${typeField.type}.`,\n [ifaceField.astNode?.type, typeField.astNode?.type],\n );\n }\n\n // Assert each interface field arg is implemented.\n for (const ifaceArg of ifaceField.args) {\n const typeArg = typeField.args.find((arg) => arg.name === ifaceArg.name);\n\n // Assert interface field arg exists on object field.\n if (!typeArg) {\n context.reportError(\n `Interface field argument ${ifaceArg} expected but ${typeField} does not provide it.`,\n [ifaceArg.astNode, typeField.astNode],\n );\n continue;\n }\n\n // Assert interface field arg type matches object field arg type.\n // (invariant)\n // TODO: change to contravariant?\n if (!isEqualType(ifaceArg.type, typeArg.type)) {\n context.reportError(\n `Interface field argument ${ifaceArg} expects type ${ifaceArg.type} ` +\n `but ${typeArg} is type ${typeArg.type}.`,\n [ifaceArg.astNode?.type, typeArg.astNode?.type],\n );\n }\n }\n\n // Assert additional arguments must not be required.\n for (const typeArg of typeField.args) {\n if (isRequiredArgument(typeArg)) {\n const ifaceArg = ifaceField.args.find(\n (arg) => arg.name === typeArg.name,\n );\n if (!ifaceArg) {\n context.reportError(\n `Argument \"${typeArg}\" must not be required type \"${typeArg.type}\" ` +\n `if not provided by the Interface field \"${ifaceField}\".`,\n [typeArg.astNode, ifaceField.astNode],\n );\n }\n }\n }\n\n // Asserts that field is not deprecated unless interface field is\n if (\n typeField.deprecationReason != null &&\n ifaceField.deprecationReason == null\n ) {\n context.reportError(\n `Interface field ${iface.name}.${ifaceField.name} is not deprecated, so ` +\n `implementation field ${type.name}.${typeField.name} must not be deprecated.`,\n [\n getDeprecatedDirectiveNode(typeField.astNode),\n typeField.astNode?.type,\n ],\n );\n }\n }\n}\n\nfunction validateTypeImplementsAncestors(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n iface: GraphQLInterfaceType,\n): void {\n const ifaceInterfaces = type.getInterfaces();\n for (const transitive of iface.getInterfaces()) {\n if (!ifaceInterfaces.includes(transitive)) {\n context.reportError(\n transitive === type\n ? `Type ${type} cannot implement ${iface} because it would create a circular reference.`\n : `Type ${type} must implement ${transitive} because it is implemented by ${iface}.`,\n [\n ...getAllImplementsInterfaceNodes(iface, transitive),\n ...getAllImplementsInterfaceNodes(type, iface),\n ],\n );\n }\n }\n}\n\nfunction validateUnionMembers(\n context: SchemaValidationContext,\n union: GraphQLUnionType,\n): void {\n const memberTypes = union.getTypes();\n\n if (memberTypes.length === 0) {\n context.reportError(\n `Union type ${union} must define one or more member types.`,\n [union.astNode, ...union.extensionASTNodes],\n );\n }\n\n const includedTypeNames = new Set();\n for (const memberType of memberTypes) {\n if (includedTypeNames.has(memberType.name)) {\n context.reportError(\n `Union type ${union} can only include type ${memberType} once.`,\n getUnionMemberTypeNodes(union, memberType.name),\n );\n continue;\n }\n includedTypeNames.add(memberType.name);\n if (!isObjectType(memberType)) {\n context.reportError(\n `Union type ${union} can only include Object types, ` +\n `it cannot include ${inspect(memberType)}.`,\n getUnionMemberTypeNodes(union, String(memberType)),\n );\n }\n }\n}\n\nfunction validateEnumValues(\n context: SchemaValidationContext,\n enumType: GraphQLEnumType,\n): void {\n const enumValues = enumType.getValues();\n\n if (enumValues.length === 0) {\n context.reportError(\n `Enum type ${enumType} must define one or more values.`,\n [enumType.astNode, ...enumType.extensionASTNodes],\n );\n }\n\n for (const enumValue of enumValues) {\n // Ensure valid name.\n validateName(context, enumValue);\n }\n}\n\nfunction validateInputFields(\n context: SchemaValidationContext,\n inputObj: GraphQLInputObjectType,\n): void {\n const fields = Object.values(inputObj.getFields());\n\n if (fields.length === 0) {\n context.reportError(\n `Input Object type ${inputObj} must define one or more fields.`,\n [inputObj.astNode, ...inputObj.extensionASTNodes],\n );\n }\n\n // Ensure the input fields are valid\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field);\n\n // Ensure the type is an input type\n if (!isInputType(field.type)) {\n context.reportError(\n `The type of ${field} must be Input Type ` +\n `but got: ${inspect(field.type)}.`,\n field.astNode?.type,\n );\n }\n\n if (isRequiredInputField(field) && field.deprecationReason != null) {\n context.reportError(\n `Required input field ${field} cannot be deprecated.`,\n [getDeprecatedDirectiveNode(field.astNode), field.astNode?.type],\n );\n }\n\n validateDefaultValue(context, field);\n\n if (inputObj.isOneOf) {\n validateOneOfInputObjectField(inputObj, field, context);\n }\n }\n}\n\nfunction validateOneOfInputObjectField(\n type: GraphQLInputObjectType,\n field: GraphQLInputField,\n context: SchemaValidationContext,\n): void {\n if (isNonNullType(field.type)) {\n context.reportError(\n `OneOf input field ${type}.${field.name} must be nullable.`,\n field.astNode?.type,\n );\n }\n\n if (field.default !== undefined || field.defaultValue !== undefined) {\n context.reportError(\n `OneOf input field ${type}.${field.name} cannot have a default value.`,\n field.astNode,\n );\n }\n}\n\nfunction createInputObjectNonNullCircularRefsValidator(\n context: SchemaValidationContext,\n): (inputObj: GraphQLInputObjectType) => void {\n // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.\n // Tracks already visited types to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedTypes = new Set();\n\n // Array of types nodes used to produce meaningful errors\n const fieldPath: Array<{ fieldStr: string; astNode: Maybe }> = [];\n\n // Position in the type path\n const fieldPathIndexByTypeName: ObjMap =\n Object.create(null);\n\n return detectCycleRecursive;\n\n // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n function detectCycleRecursive(inputObj: GraphQLInputObjectType): void {\n if (visitedTypes.has(inputObj)) {\n return;\n }\n\n visitedTypes.add(inputObj);\n fieldPathIndexByTypeName[inputObj.name] = fieldPath.length;\n\n const fields = Object.values(inputObj.getFields());\n for (const field of fields) {\n if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) {\n const fieldType = field.type.ofType;\n const cycleIndex = fieldPathIndexByTypeName[fieldType.name];\n\n fieldPath.push({\n fieldStr: `${inputObj}.${field.name}`,\n astNode: field.astNode,\n });\n if (cycleIndex === undefined) {\n detectCycleRecursive(fieldType);\n } else {\n const cyclePath = fieldPath.slice(cycleIndex);\n const pathStr = cyclePath\n .map((fieldObj) => fieldObj.fieldStr)\n .join(', ');\n context.reportError(\n `Invalid circular reference. The Input Object ${fieldType} references itself ${\n cyclePath.length > 1\n ? 'via the non-null fields:'\n : 'in the non-null field'\n } ${pathStr}.`,\n cyclePath.map((fieldObj) => fieldObj.astNode),\n );\n }\n fieldPath.pop();\n }\n }\n\n fieldPathIndexByTypeName[inputObj.name] = undefined;\n }\n}\n\nfunction createInputObjectDefaultValueCircularRefsValidator(\n context: SchemaValidationContext,\n): (inputObj: GraphQLInputObjectType) => void {\n // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.\n // Tracks already visited types to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedFields = Object.create(null);\n\n // Array of keys for fields and default values used to produce meaningful errors.\n const fieldPath: Array<\n [fieldStr: string, defaultValue: ConstValueNode | undefined]\n > = [];\n\n // Position in the path\n const fieldPathIndex: ObjMap = Object.create(null);\n\n // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n return function validateInputObjectDefaultValueCircularRefs(\n inputObj: GraphQLInputObjectType,\n ): void {\n // Start with an empty object as a way to visit every field in this input\n // object type and apply every default value.\n return detectValueDefaultValueCycle(inputObj, {});\n };\n\n function detectValueDefaultValueCycle(\n inputObj: GraphQLInputObjectType,\n defaultValue: unknown,\n ): void {\n // If the value is a List, recursively check each entry for a cycle.\n // Otherwise, only object values can contain a cycle.\n if (isIterableObject(defaultValue)) {\n for (const itemValue of defaultValue) {\n detectValueDefaultValueCycle(inputObj, itemValue);\n }\n return;\n } else if (!isObjectLike(defaultValue)) {\n return;\n }\n\n // Check each defined field for a cycle.\n for (const field of Object.values(inputObj.getFields())) {\n const namedFieldType = getNamedType(field.type);\n\n // Only input object type fields can result in a cycle.\n if (!isInputObjectType(namedFieldType)) {\n continue;\n }\n\n if (Object.hasOwn(defaultValue, field.name)) {\n // If the provided value has this field defined, recursively check it\n // for cycles.\n detectValueDefaultValueCycle(namedFieldType, defaultValue[field.name]);\n } else {\n // Otherwise check this field's default value for cycles.\n detectFieldDefaultValueCycle(\n field,\n namedFieldType,\n `${inputObj}.${field.name}`,\n );\n }\n }\n }\n\n function detectLiteralDefaultValueCycle(\n inputObj: GraphQLInputObjectType,\n defaultValue: ConstValueNode,\n ): void {\n // If the value is a List, recursively check each entry for a cycle.\n // Otherwise, only object values can contain a cycle.\n if (defaultValue.kind === Kind.LIST) {\n for (const itemLiteral of defaultValue.values) {\n detectLiteralDefaultValueCycle(inputObj, itemLiteral);\n }\n return;\n } else if (defaultValue.kind !== Kind.OBJECT) {\n return;\n }\n\n // Check each defined field for a cycle.\n const fieldNodes = keyMap(defaultValue.fields, (field) => field.name.value);\n for (const field of Object.values(inputObj.getFields())) {\n const namedFieldType = getNamedType(field.type);\n\n // Only input object type fields can result in a cycle.\n if (!isInputObjectType(namedFieldType)) {\n continue;\n }\n\n if (Object.hasOwn(fieldNodes, field.name)) {\n // If the provided value has this field defined, recursively check it\n // for cycles.\n detectLiteralDefaultValueCycle(\n namedFieldType,\n fieldNodes[field.name].value,\n );\n } else {\n // Otherwise check this field's default value for cycles.\n detectFieldDefaultValueCycle(\n field,\n namedFieldType,\n `${inputObj}.${field.name}`,\n );\n }\n }\n }\n\n function detectFieldDefaultValueCycle(\n field: GraphQLInputField,\n fieldType: GraphQLInputObjectType,\n fieldStr: string,\n ): void {\n // Only a field with a default value can result in a cycle.\n const defaultInput = field.default;\n if (defaultInput === undefined) {\n return;\n }\n\n // Check to see if there is cycle.\n const cycleIndex = fieldPathIndex[fieldStr];\n if (cycleIndex !== undefined && cycleIndex > 0) {\n context.reportError(\n `Invalid circular reference. The default value of Input Object field ${fieldStr} references itself${\n cycleIndex < fieldPath.length\n ? ` via the default values of: ${fieldPath\n .slice(cycleIndex)\n .map(([stringForMessage]) => stringForMessage)\n .join(', ')}`\n : ''\n }.`,\n fieldPath.slice(cycleIndex - 1).map(([, node]) => node),\n );\n return;\n }\n\n // Recurse into this field's default value once, tracking the path.\n if (visitedFields[fieldStr] === undefined) {\n visitedFields[fieldStr] = true;\n fieldPathIndex[fieldStr] = fieldPath.push([\n fieldStr,\n field.astNode?.defaultValue,\n ]);\n if (defaultInput.literal) {\n detectLiteralDefaultValueCycle(fieldType, defaultInput.literal);\n } else {\n detectValueDefaultValueCycle(fieldType, defaultInput.value);\n }\n fieldPath.pop();\n fieldPathIndex[fieldStr] = undefined;\n }\n }\n}\n\nfunction getAllImplementsInterfaceNodes(\n type: GraphQLObjectType | GraphQLInterfaceType,\n iface: GraphQLInterfaceType,\n): ReadonlyArray {\n const { astNode, extensionASTNodes } = type;\n const nodes: ReadonlyArray<\n | ObjectTypeDefinitionNode\n | ObjectTypeExtensionNode\n | InterfaceTypeDefinitionNode\n | InterfaceTypeExtensionNode\n > = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes;\n\n return nodes\n .flatMap((typeNode) => typeNode.interfaces ?? [])\n .filter((ifaceNode) => ifaceNode.name.value === iface.name);\n}\n\nfunction getUnionMemberTypeNodes(\n union: GraphQLUnionType,\n typeName: string,\n): ReadonlyArray {\n const { astNode, extensionASTNodes } = union;\n const nodes: ReadonlyArray =\n astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes;\n\n return nodes\n .flatMap((unionNode) => /* c8 ignore next */ unionNode.types ?? [])\n .filter((typeNode) => typeNode.name.value === typeName);\n}\n\nfunction getDeprecatedDirectiveNode(\n definitionNode: Maybe<{\n readonly directives?: ReadonlyArray | undefined;\n }>,\n): Maybe {\n return definitionNode?.directives?.find(\n (node) => node.name.value === GraphQLDeprecatedDirective.name,\n );\n}\n"]} \ No newline at end of file diff --git a/type/validate.mjs b/type/validate.mjs new file mode 100644 index 0000000000..b31e662da9 --- /dev/null +++ b/type/validate.mjs @@ -0,0 +1,621 @@ +import { AccumulatorMap } from "../jsutils/AccumulatorMap.mjs"; +import { capitalize } from "../jsutils/capitalize.mjs"; +import { andList } from "../jsutils/formatList.mjs"; +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { isIterableObject } from "../jsutils/isIterableObject.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { keyMap } from "../jsutils/keyMap.mjs"; +import { mapValue } from "../jsutils/mapValue.mjs"; +import { printPathArray } from "../jsutils/printPathArray.mjs"; +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { OperationTypeNode } from "../language/ast.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { isEqualType, isTypeSubTypeOf } from "../utilities/typeComparators.mjs"; +import { validateInputLiteral, validateInputValue, } from "../utilities/validateInputValue.mjs"; +import { assertLeafType, getNamedType, isEnumType, isInputObjectType, isInputType, isInterfaceType, isListType, isNamedType, isNonNullType, isObjectType, isOutputType, isRequiredArgument, isRequiredInputField, isUnionType, } from "./definition.mjs"; +import { GraphQLDeprecatedDirective, isDirective } from "./directives.mjs"; +import { isIntrospectionType } from "./introspection.mjs"; +import { assertSchema } from "./schema.mjs"; +/** + * Implements the "Type Validation" sub-sections of the specification's + * "Type System" section. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the Schema is valid. + */ +export function validateSchema(schema) { + // First check to ensure the provided value is in fact a GraphQLSchema. + assertSchema(schema); + // If this Schema has already been validated, return the previous results. + if (schema.__validationErrors) { + return schema.__validationErrors; + } + // Validate the schema, producing a list of errors. + const context = new SchemaValidationContext(schema); + validateRootTypes(context); + validateDirectives(context); + validateTypes(context); + // Persist the results of validation before returning to ensure validation + // does not run multiple times for this schema. + const errors = context.getErrors(); + schema.__validationErrors = errors; + return errors; +} +/** + * Utility function which asserts a schema is valid by throwing an error if + * it is invalid. + */ +export function assertValidSchema(schema) { + const errors = validateSchema(schema); + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +class SchemaValidationContext { + constructor(schema) { + this._errors = []; + this.schema = schema; + } + reportError(message, nodes) { + const _nodes = Array.isArray(nodes) + ? nodes.filter(Boolean) + : nodes; + this._errors.push(new GraphQLError(message, { nodes: _nodes })); + } + getErrors() { + return this._errors; + } +} +function validateRootTypes(context) { + const schema = context.schema; + if (schema.getQueryType() == null) { + context.reportError('Query root type must be provided.', schema.astNode); + } + const rootTypesMap = new AccumulatorMap(); + for (const operationType of Object.values(OperationTypeNode)) { + const rootType = schema.getRootType(operationType); + if (rootType != null) { + if (!isObjectType(rootType)) { + const operationTypeStr = capitalize(operationType); + const rootTypeStr = inspect(rootType); + context.reportError(operationType === OperationTypeNode.QUERY + ? `${operationTypeStr} root type must be Object type, it cannot be ${rootTypeStr}.` + : `${operationTypeStr} root type must be Object type if provided, it cannot be ${rootTypeStr}.`, getOperationTypeNode(schema, operationType) ?? + rootType.astNode); + } + else { + rootTypesMap.add(rootType, operationType); + } + } + } + for (const [rootType, operationTypes] of rootTypesMap) { + if (operationTypes.length > 1) { + const operationList = andList(operationTypes); + context.reportError(`All root types must be different, "${rootType}" type is used as ${operationList} root types.`, operationTypes.map((operationType) => getOperationTypeNode(schema, operationType))); + } + } +} +function getOperationTypeNode(schema, operation) { + return [schema.astNode, ...schema.extensionASTNodes] + .flatMap((schemaNode) => schemaNode?.operationTypes ?? []) + .find((operationNode) => operationNode.operation === operation)?.type; +} +function validateDirectives(context) { + for (const directive of context.schema.getDirectives()) { + // Ensure all directives are in fact GraphQL directives. + if (!isDirective(directive)) { + context.reportError(`Expected directive but got: ${inspect(directive)}.`, directive?.astNode); + continue; + } + // Ensure they are named correctly. + validateName(context, directive); + if (directive.locations.length === 0) { + context.reportError(`Directive ${directive} must include 1 or more locations.`, directive.astNode); + } + // Ensure the arguments are valid. + for (const arg of directive.args) { + // Ensure they are named correctly. + validateName(context, arg); + // Ensure the type is an input type. + if (!isInputType(arg.type)) { + context.reportError(`The type of ${arg} must be Input Type ` + + `but got: ${inspect(arg.type)}.`, arg.astNode); + } + if (isRequiredArgument(arg) && arg.deprecationReason != null) { + context.reportError(`Required argument ${arg} cannot be deprecated.`, [ + getDeprecatedDirectiveNode(arg.astNode), + arg.astNode?.type, + ]); + } + validateDefaultValue(context, arg); + } + } +} +function validateDefaultValue(context, inputValue) { + const defaultInput = inputValue.default; + if (!defaultInput) { + return; + } + if (defaultInput.literal) { + validateInputLiteral(defaultInput.literal, inputValue.type, (error, path) => { + context.reportError(`${inputValue} has invalid default value${printPathArray(path)}: ${error.message}`, error.nodes); + }); + } + else { + const errors = []; + validateInputValue(defaultInput.value, inputValue.type, (error, path) => { + errors.push([error, path]); + }); + // If there were validation errors, check to see if it can be "uncoerced" + // and then correctly validated. If so, report a clear error with a path + // to resolution. + if (errors.length > 0) { + try { + const uncoercedValue = uncoerceDefaultValue(defaultInput.value, inputValue.type); + const uncoercedErrors = []; + validateInputValue(uncoercedValue, inputValue.type, (error, path) => { + uncoercedErrors.push([error, path]); + }); + if (uncoercedErrors.length === 0) { + context.reportError(`${inputValue} has invalid default value: ${inspect(defaultInput.value)}. Did you mean: ${inspect(uncoercedValue)}?`, inputValue.astNode?.defaultValue); + return; + } + } + catch (_error) { + // ignore + } + } + // Otherwise report the original set of errors. + for (const [error, path] of errors) { + context.reportError(`${inputValue} has invalid default value${printPathArray(path)}: ${error.message}`, inputValue.astNode?.defaultValue); + } + } +} +/** + * Historically GraphQL.js allowed default values to be provided as + * assumed-coerced "internal" values, however default values should be provided + * as "external" pre-coerced values. `uncoerceDefaultValue()` will convert such + * "internal" values to "external" values to display as part of validation. + * + * This performs the "opposite" of `coerceInputValue()`. Given an "internal" + * coerced value, reverse the process to provide an "external" uncoerced value. + */ +function uncoerceDefaultValue(value, type) { + if (isNonNullType(type)) { + return uncoerceDefaultValue(value, type.ofType); + } + if (value === null) { + return null; + } + if (isListType(type)) { + if (isIterableObject(value)) { + return Array.from(value, (itemValue) => uncoerceDefaultValue(itemValue, type.ofType)); + } + return [uncoerceDefaultValue(value, type.ofType)]; + } + if (isInputObjectType(type)) { + (isObjectLike(value)) || invariant(false); + const fieldDefs = type.getFields(); + return mapValue(value, (fieldValue, fieldName) => { + (fieldName in fieldDefs) || invariant(false); + return uncoerceDefaultValue(fieldValue, fieldDefs[fieldName].type); + }); + } + assertLeafType(type); + // For most leaf types (Scalars, Enums), output value coercion ("serialize") is + // the inverse of input coercion ("parseValue") and will produce an + // "external" value. Historically, this method was also used as part of the + // now-deprecated "astFromValue" to perform the same behavior. + return type.coerceOutputValue(value); +} +function validateName(context, node) { + // Ensure names are valid, however introspection types opt out. + if (node.name.startsWith('__')) { + context.reportError(`Name "${node.name}" must not begin with "__", which is reserved by GraphQL introspection.`, node.astNode); + } +} +function validateTypes(context) { + // Ensure Input Objects do not contain non-nullable circular references. + const validateInputObjectNonNullCircularRefs = createInputObjectNonNullCircularRefsValidator(context); + const validateInputObjectDefaultValueCircularRefs = createInputObjectDefaultValueCircularRefsValidator(context); + const typeMap = context.schema.getTypeMap(); + for (const type of Object.values(typeMap)) { + // Ensure all provided types are in fact GraphQL type. + if (!isNamedType(type)) { + context.reportError(`Expected GraphQL named type but got: ${inspect(type)}.`, type.astNode); + continue; + } + // Ensure it is named correctly (excluding introspection types). + if (!isIntrospectionType(type)) { + validateName(context, type); + } + if (isObjectType(type)) { + // Ensure fields are valid + validateFields(context, type); + // Ensure objects implement the interfaces they claim to. + validateInterfaces(context, type); + } + else if (isInterfaceType(type)) { + // Ensure fields are valid. + validateFields(context, type); + // Ensure interfaces implement the interfaces they claim to. + validateInterfaces(context, type); + } + else if (isUnionType(type)) { + // Ensure Unions include valid member types. + validateUnionMembers(context, type); + } + else if (isEnumType(type)) { + // Ensure Enums have valid values. + validateEnumValues(context, type); + } + else if (isInputObjectType(type)) { + // Ensure Input Object fields are valid. + validateInputFields(context, type); + // Ensure Input Objects do not contain invalid field circular references. + // Ensure Input Objects do not contain non-nullable circular references. + validateInputObjectNonNullCircularRefs(type); + // Ensure Input Objects do not contain invalid default value circular references. + validateInputObjectDefaultValueCircularRefs(type); + } + } +} +function validateFields(context, type) { + const fields = Object.values(type.getFields()); + // Objects and Interfaces both must define one or more fields. + if (fields.length === 0) { + context.reportError(`Type ${type} must define one or more fields.`, [ + type.astNode, + ...type.extensionASTNodes, + ]); + } + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); + // Ensure the type is an output type + if (!isOutputType(field.type)) { + context.reportError(`The type of ${field} must be Output Type ` + + `but got: ${inspect(field.type)}.`, field.astNode?.type); + } + // Ensure the arguments are valid + for (const arg of field.args) { + // Ensure they are named correctly. + validateName(context, arg); + // Ensure the type is an input type + if (!isInputType(arg.type)) { + context.reportError(`The type of ${arg} must be Input Type but got: ${inspect(arg.type)}.`, arg.astNode?.type); + } + if (isRequiredArgument(arg) && arg.deprecationReason != null) { + context.reportError(`Required argument ${arg} cannot be deprecated.`, [ + getDeprecatedDirectiveNode(arg.astNode), + arg.astNode?.type, + ]); + } + validateDefaultValue(context, arg); + } + } +} +function validateInterfaces(context, type) { + const ifaceTypeNames = new Set(); + for (const iface of type.getInterfaces()) { + if (!isInterfaceType(iface)) { + context.reportError(`Type ${type} must only implement Interface types, ` + + `it cannot implement ${inspect(iface)}.`, getAllImplementsInterfaceNodes(type, iface)); + continue; + } + if (type === iface) { + context.reportError(`Type ${type} cannot implement itself because it would create a circular reference.`, getAllImplementsInterfaceNodes(type, iface)); + continue; + } + if (ifaceTypeNames.has(iface.name)) { + context.reportError(`Type ${type} can only implement ${iface} once.`, getAllImplementsInterfaceNodes(type, iface)); + continue; + } + ifaceTypeNames.add(iface.name); + validateTypeImplementsAncestors(context, type, iface); + validateTypeImplementsInterface(context, type, iface); + } +} +function validateTypeImplementsInterface(context, type, iface) { + const typeFieldMap = type.getFields(); + // Assert each interface field is implemented. + for (const ifaceField of Object.values(iface.getFields())) { + const typeField = typeFieldMap[ifaceField.name]; + // Assert interface field exists on type. + if (typeField == null) { + context.reportError(`Interface field ${ifaceField} expected but ${type} does not provide it.`, [ifaceField.astNode, type.astNode, ...type.extensionASTNodes]); + continue; + } + // Assert interface field type is satisfied by type field type, by being + // a valid subtype. (covariant) + if (!isTypeSubTypeOf(context.schema, typeField.type, ifaceField.type)) { + context.reportError(`Interface field ${ifaceField} expects type ${ifaceField.type} ` + + `but ${typeField} is type ${typeField.type}.`, [ifaceField.astNode?.type, typeField.astNode?.type]); + } + // Assert each interface field arg is implemented. + for (const ifaceArg of ifaceField.args) { + const typeArg = typeField.args.find((arg) => arg.name === ifaceArg.name); + // Assert interface field arg exists on object field. + if (!typeArg) { + context.reportError(`Interface field argument ${ifaceArg} expected but ${typeField} does not provide it.`, [ifaceArg.astNode, typeField.astNode]); + continue; + } + // Assert interface field arg type matches object field arg type. + // (invariant) + // TODO: change to contravariant? + if (!isEqualType(ifaceArg.type, typeArg.type)) { + context.reportError(`Interface field argument ${ifaceArg} expects type ${ifaceArg.type} ` + + `but ${typeArg} is type ${typeArg.type}.`, [ifaceArg.astNode?.type, typeArg.astNode?.type]); + } + } + // Assert additional arguments must not be required. + for (const typeArg of typeField.args) { + if (isRequiredArgument(typeArg)) { + const ifaceArg = ifaceField.args.find((arg) => arg.name === typeArg.name); + if (!ifaceArg) { + context.reportError(`Argument "${typeArg}" must not be required type "${typeArg.type}" ` + + `if not provided by the Interface field "${ifaceField}".`, [typeArg.astNode, ifaceField.astNode]); + } + } + } + // Asserts that field is not deprecated unless interface field is + if (typeField.deprecationReason != null && + ifaceField.deprecationReason == null) { + context.reportError(`Interface field ${iface.name}.${ifaceField.name} is not deprecated, so ` + + `implementation field ${type.name}.${typeField.name} must not be deprecated.`, [ + getDeprecatedDirectiveNode(typeField.astNode), + typeField.astNode?.type, + ]); + } + } +} +function validateTypeImplementsAncestors(context, type, iface) { + const ifaceInterfaces = type.getInterfaces(); + for (const transitive of iface.getInterfaces()) { + if (!ifaceInterfaces.includes(transitive)) { + context.reportError(transitive === type + ? `Type ${type} cannot implement ${iface} because it would create a circular reference.` + : `Type ${type} must implement ${transitive} because it is implemented by ${iface}.`, [ + ...getAllImplementsInterfaceNodes(iface, transitive), + ...getAllImplementsInterfaceNodes(type, iface), + ]); + } + } +} +function validateUnionMembers(context, union) { + const memberTypes = union.getTypes(); + if (memberTypes.length === 0) { + context.reportError(`Union type ${union} must define one or more member types.`, [union.astNode, ...union.extensionASTNodes]); + } + const includedTypeNames = new Set(); + for (const memberType of memberTypes) { + if (includedTypeNames.has(memberType.name)) { + context.reportError(`Union type ${union} can only include type ${memberType} once.`, getUnionMemberTypeNodes(union, memberType.name)); + continue; + } + includedTypeNames.add(memberType.name); + if (!isObjectType(memberType)) { + context.reportError(`Union type ${union} can only include Object types, ` + + `it cannot include ${inspect(memberType)}.`, getUnionMemberTypeNodes(union, String(memberType))); + } + } +} +function validateEnumValues(context, enumType) { + const enumValues = enumType.getValues(); + if (enumValues.length === 0) { + context.reportError(`Enum type ${enumType} must define one or more values.`, [enumType.astNode, ...enumType.extensionASTNodes]); + } + for (const enumValue of enumValues) { + // Ensure valid name. + validateName(context, enumValue); + } +} +function validateInputFields(context, inputObj) { + const fields = Object.values(inputObj.getFields()); + if (fields.length === 0) { + context.reportError(`Input Object type ${inputObj} must define one or more fields.`, [inputObj.astNode, ...inputObj.extensionASTNodes]); + } + // Ensure the input fields are valid + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); + // Ensure the type is an input type + if (!isInputType(field.type)) { + context.reportError(`The type of ${field} must be Input Type ` + + `but got: ${inspect(field.type)}.`, field.astNode?.type); + } + if (isRequiredInputField(field) && field.deprecationReason != null) { + context.reportError(`Required input field ${field} cannot be deprecated.`, [getDeprecatedDirectiveNode(field.astNode), field.astNode?.type]); + } + validateDefaultValue(context, field); + if (inputObj.isOneOf) { + validateOneOfInputObjectField(inputObj, field, context); + } + } +} +function validateOneOfInputObjectField(type, field, context) { + if (isNonNullType(field.type)) { + context.reportError(`OneOf input field ${type}.${field.name} must be nullable.`, field.astNode?.type); + } + if (field.default !== undefined || field.defaultValue !== undefined) { + context.reportError(`OneOf input field ${type}.${field.name} cannot have a default value.`, field.astNode); + } +} +function createInputObjectNonNullCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedTypes = new Set(); + // Array of types nodes used to produce meaningful errors + const fieldPath = []; + // Position in the type path + const fieldPathIndexByTypeName = Object.create(null); + return detectCycleRecursive; + // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + function detectCycleRecursive(inputObj) { + if (visitedTypes.has(inputObj)) { + return; + } + visitedTypes.add(inputObj); + fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; + const fields = Object.values(inputObj.getFields()); + for (const field of fields) { + if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) { + const fieldType = field.type.ofType; + const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; + fieldPath.push({ + fieldStr: `${inputObj}.${field.name}`, + astNode: field.astNode, + }); + if (cycleIndex === undefined) { + detectCycleRecursive(fieldType); + } + else { + const cyclePath = fieldPath.slice(cycleIndex); + const pathStr = cyclePath + .map((fieldObj) => fieldObj.fieldStr) + .join(', '); + context.reportError(`Invalid circular reference. The Input Object ${fieldType} references itself ${cyclePath.length > 1 + ? 'via the non-null fields:' + : 'in the non-null field'} ${pathStr}.`, cyclePath.map((fieldObj) => fieldObj.astNode)); + } + fieldPath.pop(); + } + } + fieldPathIndexByTypeName[inputObj.name] = undefined; + } +} +function createInputObjectDefaultValueCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFields = Object.create(null); + // Array of keys for fields and default values used to produce meaningful errors. + const fieldPath = []; + // Position in the path + const fieldPathIndex = Object.create(null); + // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + return function validateInputObjectDefaultValueCircularRefs(inputObj) { + // Start with an empty object as a way to visit every field in this input + // object type and apply every default value. + return detectValueDefaultValueCycle(inputObj, {}); + }; + function detectValueDefaultValueCycle(inputObj, defaultValue) { + // If the value is a List, recursively check each entry for a cycle. + // Otherwise, only object values can contain a cycle. + if (isIterableObject(defaultValue)) { + for (const itemValue of defaultValue) { + detectValueDefaultValueCycle(inputObj, itemValue); + } + return; + } + else if (!isObjectLike(defaultValue)) { + return; + } + // Check each defined field for a cycle. + for (const field of Object.values(inputObj.getFields())) { + const namedFieldType = getNamedType(field.type); + // Only input object type fields can result in a cycle. + if (!isInputObjectType(namedFieldType)) { + continue; + } + if (Object.hasOwn(defaultValue, field.name)) { + // If the provided value has this field defined, recursively check it + // for cycles. + detectValueDefaultValueCycle(namedFieldType, defaultValue[field.name]); + } + else { + // Otherwise check this field's default value for cycles. + detectFieldDefaultValueCycle(field, namedFieldType, `${inputObj}.${field.name}`); + } + } + } + function detectLiteralDefaultValueCycle(inputObj, defaultValue) { + // If the value is a List, recursively check each entry for a cycle. + // Otherwise, only object values can contain a cycle. + if (defaultValue.kind === Kind.LIST) { + for (const itemLiteral of defaultValue.values) { + detectLiteralDefaultValueCycle(inputObj, itemLiteral); + } + return; + } + else if (defaultValue.kind !== Kind.OBJECT) { + return; + } + // Check each defined field for a cycle. + const fieldNodes = keyMap(defaultValue.fields, (field) => field.name.value); + for (const field of Object.values(inputObj.getFields())) { + const namedFieldType = getNamedType(field.type); + // Only input object type fields can result in a cycle. + if (!isInputObjectType(namedFieldType)) { + continue; + } + if (Object.hasOwn(fieldNodes, field.name)) { + // If the provided value has this field defined, recursively check it + // for cycles. + detectLiteralDefaultValueCycle(namedFieldType, fieldNodes[field.name].value); + } + else { + // Otherwise check this field's default value for cycles. + detectFieldDefaultValueCycle(field, namedFieldType, `${inputObj}.${field.name}`); + } + } + } + function detectFieldDefaultValueCycle(field, fieldType, fieldStr) { + // Only a field with a default value can result in a cycle. + const defaultInput = field.default; + if (defaultInput === undefined) { + return; + } + // Check to see if there is cycle. + const cycleIndex = fieldPathIndex[fieldStr]; + if (cycleIndex !== undefined && cycleIndex > 0) { + context.reportError(`Invalid circular reference. The default value of Input Object field ${fieldStr} references itself${cycleIndex < fieldPath.length + ? ` via the default values of: ${fieldPath + .slice(cycleIndex) + .map(([stringForMessage]) => stringForMessage) + .join(', ')}` + : ''}.`, fieldPath.slice(cycleIndex - 1).map(([, node]) => node)); + return; + } + // Recurse into this field's default value once, tracking the path. + if (visitedFields[fieldStr] === undefined) { + visitedFields[fieldStr] = true; + fieldPathIndex[fieldStr] = fieldPath.push([ + fieldStr, + field.astNode?.defaultValue, + ]); + if (defaultInput.literal) { + detectLiteralDefaultValueCycle(fieldType, defaultInput.literal); + } + else { + detectValueDefaultValueCycle(fieldType, defaultInput.value); + } + fieldPath.pop(); + fieldPathIndex[fieldStr] = undefined; + } + } +} +function getAllImplementsInterfaceNodes(type, iface) { + const { astNode, extensionASTNodes } = type; + const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; + return nodes + .flatMap((typeNode) => typeNode.interfaces ?? []) + .filter((ifaceNode) => ifaceNode.name.value === iface.name); +} +function getUnionMemberTypeNodes(union, typeName) { + const { astNode, extensionASTNodes } = union; + const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; + return nodes + .flatMap((unionNode) => /* c8 ignore next */ unionNode.types ?? []) + .filter((typeNode) => typeNode.name.value === typeName); +} +function getDeprecatedDirectiveNode(definitionNode) { + return definitionNode?.directives?.find((node) => node.name.value === GraphQLDeprecatedDirective.name); +} +//# sourceMappingURL=validate.js.map \ No newline at end of file diff --git a/type/validate.mjs.map b/type/validate.mjs.map new file mode 100644 index 0000000000..89a3b79908 --- /dev/null +++ b/type/validate.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/type/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAC9D,OAAO,EAAE,UAAU,EAAE,kCAAiC;AACtD,OAAO,EAAE,OAAO,EAAE,kCAAiC;AACnD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,gBAAgB,EAAE,wCAAuC;AAClE,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,MAAM,EAAE,8BAA6B;AAC9C,OAAO,EAAE,QAAQ,EAAE,gCAA+B;AAGlD,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAE9D,OAAO,EAAE,YAAY,EAAE,kCAAiC;AAcxD,OAAO,EAAE,iBAAiB,EAAE,4BAA2B;AACvD,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,yCAAwC;AAC/E,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,4CAA2C;AAY5C,OAAO,EACL,cAAc,EACd,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,GACZ,yBAAwB;AACzB,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,yBAAwB;AAC1E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,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,0BAA0B,CACjC,cAEE;IAEF,OAAO,cAAc,EAAE,UAAU,EAAE,IAAI,CACrC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,0BAA0B,CAAC,IAAI,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["import { AccumulatorMap } from '../jsutils/AccumulatorMap.js';\nimport { capitalize } from '../jsutils/capitalize.js';\nimport { andList } from '../jsutils/formatList.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyMap } from '../jsutils/keyMap.js';\nimport { mapValue } from '../jsutils/mapValue.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\nimport { printPathArray } from '../jsutils/printPathArray.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n ASTNode,\n ConstValueNode,\n DirectiveNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n NamedTypeNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n} from '../language/ast.js';\nimport { OperationTypeNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators.js';\nimport {\n validateInputLiteral,\n validateInputValue,\n} from '../utilities/validateInputValue.js';\n\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInputType,\n GraphQLInterfaceType,\n GraphQLObjectType,\n GraphQLUnionType,\n} from './definition.js';\nimport {\n assertLeafType,\n getNamedType,\n isEnumType,\n isInputObjectType,\n isInputType,\n isInterfaceType,\n isListType,\n isNamedType,\n isNonNullType,\n isObjectType,\n isOutputType,\n isRequiredArgument,\n isRequiredInputField,\n isUnionType,\n} from './definition.js';\nimport { GraphQLDeprecatedDirective, isDirective } from './directives.js';\nimport { isIntrospectionType } from './introspection.js';\nimport type { GraphQLSchema } from './schema.js';\nimport { assertSchema } from './schema.js';\n\n/**\n * Implements the \"Type Validation\" sub-sections of the specification's\n * \"Type System\" section.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the Schema is valid.\n */\nexport function validateSchema(\n schema: GraphQLSchema,\n): ReadonlyArray {\n // First check to ensure the provided value is in fact a GraphQLSchema.\n assertSchema(schema);\n\n // If this Schema has already been validated, return the previous results.\n if (schema.__validationErrors) {\n return schema.__validationErrors;\n }\n\n // Validate the schema, producing a list of errors.\n const context = new SchemaValidationContext(schema);\n validateRootTypes(context);\n validateDirectives(context);\n validateTypes(context);\n\n // Persist the results of validation before returning to ensure validation\n // does not run multiple times for this schema.\n const errors = context.getErrors();\n schema.__validationErrors = errors;\n return errors;\n}\n\n/**\n * Utility function which asserts a schema is valid by throwing an error if\n * it is invalid.\n */\nexport function assertValidSchema(schema: GraphQLSchema): void {\n const errors = validateSchema(schema);\n if (errors.length !== 0) {\n throw new Error(errors.map((error) => error.message).join('\\n\\n'));\n }\n}\n\nclass SchemaValidationContext {\n readonly _errors: Array;\n readonly schema: GraphQLSchema;\n\n constructor(schema: GraphQLSchema) {\n this._errors = [];\n this.schema = schema;\n }\n\n reportError(\n message: string,\n nodes?: ReadonlyArray> | Maybe,\n ): void {\n const _nodes = Array.isArray(nodes)\n ? (nodes.filter(Boolean) as ReadonlyArray)\n : (nodes as Maybe);\n this._errors.push(new GraphQLError(message, { nodes: _nodes }));\n }\n\n getErrors(): ReadonlyArray {\n return this._errors;\n }\n}\n\nfunction validateRootTypes(context: SchemaValidationContext): void {\n const schema = context.schema;\n\n if (schema.getQueryType() == null) {\n context.reportError('Query root type must be provided.', schema.astNode);\n }\n\n const rootTypesMap = new AccumulatorMap<\n GraphQLObjectType,\n OperationTypeNode\n >();\n for (const operationType of Object.values(OperationTypeNode)) {\n const rootType = schema.getRootType(operationType);\n\n if (rootType != null) {\n if (!isObjectType(rootType)) {\n const operationTypeStr = capitalize(operationType);\n const rootTypeStr = inspect(rootType);\n context.reportError(\n operationType === OperationTypeNode.QUERY\n ? `${operationTypeStr} root type must be Object type, it cannot be ${rootTypeStr}.`\n : `${operationTypeStr} root type must be Object type if provided, it cannot be ${rootTypeStr}.`,\n getOperationTypeNode(schema, operationType) ??\n (rootType as any).astNode,\n );\n } else {\n rootTypesMap.add(rootType, operationType);\n }\n }\n }\n\n for (const [rootType, operationTypes] of rootTypesMap) {\n if (operationTypes.length > 1) {\n const operationList = andList(operationTypes);\n context.reportError(\n `All root types must be different, \"${rootType}\" type is used as ${operationList} root types.`,\n operationTypes.map((operationType) =>\n getOperationTypeNode(schema, operationType),\n ),\n );\n }\n }\n}\n\nfunction getOperationTypeNode(\n schema: GraphQLSchema,\n operation: OperationTypeNode,\n): Maybe {\n return [schema.astNode, ...schema.extensionASTNodes]\n .flatMap((schemaNode) => schemaNode?.operationTypes ?? [])\n .find((operationNode) => operationNode.operation === operation)?.type;\n}\n\nfunction validateDirectives(context: SchemaValidationContext): void {\n for (const directive of context.schema.getDirectives()) {\n // Ensure all directives are in fact GraphQL directives.\n if (!isDirective(directive)) {\n context.reportError(\n `Expected directive but got: ${inspect(directive)}.`,\n (directive as any)?.astNode,\n );\n continue;\n }\n\n // Ensure they are named correctly.\n validateName(context, directive);\n\n if (directive.locations.length === 0) {\n context.reportError(\n `Directive ${directive} must include 1 or more locations.`,\n directive.astNode,\n );\n }\n\n // Ensure the arguments are valid.\n for (const arg of directive.args) {\n // Ensure they are named correctly.\n validateName(context, arg);\n\n // Ensure the type is an input type.\n if (!isInputType(arg.type)) {\n context.reportError(\n `The type of ${arg} must be Input Type ` +\n `but got: ${inspect(arg.type)}.`,\n arg.astNode,\n );\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument ${arg} cannot be deprecated.`, [\n getDeprecatedDirectiveNode(arg.astNode),\n arg.astNode?.type,\n ]);\n }\n\n validateDefaultValue(context, arg);\n }\n }\n}\n\nfunction validateDefaultValue(\n context: SchemaValidationContext,\n inputValue: GraphQLArgument | GraphQLInputField,\n): void {\n const defaultInput = inputValue.default;\n\n if (!defaultInput) {\n return;\n }\n\n if (defaultInput.literal) {\n validateInputLiteral(\n defaultInput.literal,\n inputValue.type,\n (error, path) => {\n context.reportError(\n `${inputValue} has invalid default value${printPathArray(path)}: ${\n error.message\n }`,\n error.nodes,\n );\n },\n );\n } else {\n const errors: Array<[GraphQLError, ReadonlyArray]> = [];\n validateInputValue(defaultInput.value, inputValue.type, (error, path) => {\n errors.push([error, path]);\n });\n\n // If there were validation errors, check to see if it can be \"uncoerced\"\n // and then correctly validated. If so, report a clear error with a path\n // to resolution.\n if (errors.length > 0) {\n try {\n const uncoercedValue = uncoerceDefaultValue(\n defaultInput.value,\n inputValue.type,\n );\n\n const uncoercedErrors = [];\n validateInputValue(uncoercedValue, inputValue.type, (error, path) => {\n uncoercedErrors.push([error, path]);\n });\n\n if (uncoercedErrors.length === 0) {\n context.reportError(\n `${inputValue} has invalid default value: ${inspect(\n defaultInput.value,\n )}. Did you mean: ${inspect(uncoercedValue)}?`,\n inputValue.astNode?.defaultValue,\n );\n return;\n }\n } catch (_error) {\n // ignore\n }\n }\n\n // Otherwise report the original set of errors.\n for (const [error, path] of errors) {\n context.reportError(\n `${inputValue} has invalid default value${printPathArray(path)}: ${\n error.message\n }`,\n inputValue.astNode?.defaultValue,\n );\n }\n }\n}\n\n/**\n * Historically GraphQL.js allowed default values to be provided as\n * assumed-coerced \"internal\" values, however default values should be provided\n * as \"external\" pre-coerced values. `uncoerceDefaultValue()` will convert such\n * \"internal\" values to \"external\" values to display as part of validation.\n *\n * This performs the \"opposite\" of `coerceInputValue()`. Given an \"internal\"\n * coerced value, reverse the process to provide an \"external\" uncoerced value.\n */\nfunction uncoerceDefaultValue(value: unknown, type: GraphQLInputType): unknown {\n if (isNonNullType(type)) {\n return uncoerceDefaultValue(value, type.ofType);\n }\n\n if (value === null) {\n return null;\n }\n\n if (isListType(type)) {\n if (isIterableObject(value)) {\n return Array.from(value, (itemValue) =>\n uncoerceDefaultValue(itemValue, type.ofType),\n );\n }\n return [uncoerceDefaultValue(value, type.ofType)];\n }\n\n if (isInputObjectType(type)) {\n invariant(isObjectLike(value));\n const fieldDefs = type.getFields();\n return mapValue(value, (fieldValue, fieldName) => {\n invariant(fieldName in fieldDefs);\n return uncoerceDefaultValue(fieldValue, fieldDefs[fieldName].type);\n });\n }\n\n assertLeafType(type);\n\n // For most leaf types (Scalars, Enums), output value coercion (\"serialize\") is\n // the inverse of input coercion (\"parseValue\") and will produce an\n // \"external\" value. Historically, this method was also used as part of the\n // now-deprecated \"astFromValue\" to perform the same behavior.\n return type.coerceOutputValue(value);\n}\n\nfunction validateName(\n context: SchemaValidationContext,\n node: { readonly name: string; readonly astNode: Maybe },\n): void {\n // Ensure names are valid, however introspection types opt out.\n if (node.name.startsWith('__')) {\n context.reportError(\n `Name \"${node.name}\" must not begin with \"__\", which is reserved by GraphQL introspection.`,\n node.astNode,\n );\n }\n}\n\nfunction validateTypes(context: SchemaValidationContext): void {\n // Ensure Input Objects do not contain non-nullable circular references.\n const validateInputObjectNonNullCircularRefs =\n createInputObjectNonNullCircularRefsValidator(context);\n const validateInputObjectDefaultValueCircularRefs =\n createInputObjectDefaultValueCircularRefsValidator(context);\n const typeMap = context.schema.getTypeMap();\n for (const type of Object.values(typeMap)) {\n // Ensure all provided types are in fact GraphQL type.\n if (!isNamedType(type)) {\n context.reportError(\n `Expected GraphQL named type but got: ${inspect(type)}.`,\n (type as any).astNode,\n );\n continue;\n }\n\n // Ensure it is named correctly (excluding introspection types).\n if (!isIntrospectionType(type)) {\n validateName(context, type);\n }\n\n if (isObjectType(type)) {\n // Ensure fields are valid\n validateFields(context, type);\n\n // Ensure objects implement the interfaces they claim to.\n validateInterfaces(context, type);\n } else if (isInterfaceType(type)) {\n // Ensure fields are valid.\n validateFields(context, type);\n\n // Ensure interfaces implement the interfaces they claim to.\n validateInterfaces(context, type);\n } else if (isUnionType(type)) {\n // Ensure Unions include valid member types.\n validateUnionMembers(context, type);\n } else if (isEnumType(type)) {\n // Ensure Enums have valid values.\n validateEnumValues(context, type);\n } else if (isInputObjectType(type)) {\n // Ensure Input Object fields are valid.\n validateInputFields(context, type);\n\n // Ensure Input Objects do not contain invalid field circular references.\n // Ensure Input Objects do not contain non-nullable circular references.\n validateInputObjectNonNullCircularRefs(type);\n\n // Ensure Input Objects do not contain invalid default value circular references.\n validateInputObjectDefaultValueCircularRefs(type);\n }\n }\n}\n\nfunction validateFields(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n): void {\n const fields = Object.values(type.getFields());\n\n // Objects and Interfaces both must define one or more fields.\n if (fields.length === 0) {\n context.reportError(`Type ${type} must define one or more fields.`, [\n type.astNode,\n ...type.extensionASTNodes,\n ]);\n }\n\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field);\n\n // Ensure the type is an output type\n if (!isOutputType(field.type)) {\n context.reportError(\n `The type of ${field} must be Output Type ` +\n `but got: ${inspect(field.type)}.`,\n field.astNode?.type,\n );\n }\n\n // Ensure the arguments are valid\n for (const arg of field.args) {\n // Ensure they are named correctly.\n validateName(context, arg);\n\n // Ensure the type is an input type\n if (!isInputType(arg.type)) {\n context.reportError(\n `The type of ${arg} must be Input Type but got: ${inspect(arg.type)}.`,\n arg.astNode?.type,\n );\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument ${arg} cannot be deprecated.`, [\n getDeprecatedDirectiveNode(arg.astNode),\n arg.astNode?.type,\n ]);\n }\n\n validateDefaultValue(context, arg);\n }\n }\n}\n\nfunction validateInterfaces(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n): void {\n const ifaceTypeNames = new Set();\n for (const iface of type.getInterfaces()) {\n if (!isInterfaceType(iface)) {\n context.reportError(\n `Type ${type} must only implement Interface types, ` +\n `it cannot implement ${inspect(iface)}.`,\n getAllImplementsInterfaceNodes(type, iface),\n );\n continue;\n }\n\n if (type === iface) {\n context.reportError(\n `Type ${type} cannot implement itself because it would create a circular reference.`,\n getAllImplementsInterfaceNodes(type, iface),\n );\n continue;\n }\n\n if (ifaceTypeNames.has(iface.name)) {\n context.reportError(\n `Type ${type} can only implement ${iface} once.`,\n getAllImplementsInterfaceNodes(type, iface),\n );\n continue;\n }\n\n ifaceTypeNames.add(iface.name);\n\n validateTypeImplementsAncestors(context, type, iface);\n validateTypeImplementsInterface(context, type, iface);\n }\n}\n\nfunction validateTypeImplementsInterface(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n iface: GraphQLInterfaceType,\n): void {\n const typeFieldMap = type.getFields();\n\n // Assert each interface field is implemented.\n for (const ifaceField of Object.values(iface.getFields())) {\n const typeField = typeFieldMap[ifaceField.name];\n\n // Assert interface field exists on type.\n if (typeField == null) {\n context.reportError(\n `Interface field ${ifaceField} expected but ${type} does not provide it.`,\n [ifaceField.astNode, type.astNode, ...type.extensionASTNodes],\n );\n continue;\n }\n\n // Assert interface field type is satisfied by type field type, by being\n // a valid subtype. (covariant)\n if (!isTypeSubTypeOf(context.schema, typeField.type, ifaceField.type)) {\n context.reportError(\n `Interface field ${ifaceField} expects type ${ifaceField.type} ` +\n `but ${typeField} is type ${typeField.type}.`,\n [ifaceField.astNode?.type, typeField.astNode?.type],\n );\n }\n\n // Assert each interface field arg is implemented.\n for (const ifaceArg of ifaceField.args) {\n const typeArg = typeField.args.find((arg) => arg.name === ifaceArg.name);\n\n // Assert interface field arg exists on object field.\n if (!typeArg) {\n context.reportError(\n `Interface field argument ${ifaceArg} expected but ${typeField} does not provide it.`,\n [ifaceArg.astNode, typeField.astNode],\n );\n continue;\n }\n\n // Assert interface field arg type matches object field arg type.\n // (invariant)\n // TODO: change to contravariant?\n if (!isEqualType(ifaceArg.type, typeArg.type)) {\n context.reportError(\n `Interface field argument ${ifaceArg} expects type ${ifaceArg.type} ` +\n `but ${typeArg} is type ${typeArg.type}.`,\n [ifaceArg.astNode?.type, typeArg.astNode?.type],\n );\n }\n }\n\n // Assert additional arguments must not be required.\n for (const typeArg of typeField.args) {\n if (isRequiredArgument(typeArg)) {\n const ifaceArg = ifaceField.args.find(\n (arg) => arg.name === typeArg.name,\n );\n if (!ifaceArg) {\n context.reportError(\n `Argument \"${typeArg}\" must not be required type \"${typeArg.type}\" ` +\n `if not provided by the Interface field \"${ifaceField}\".`,\n [typeArg.astNode, ifaceField.astNode],\n );\n }\n }\n }\n\n // Asserts that field is not deprecated unless interface field is\n if (\n typeField.deprecationReason != null &&\n ifaceField.deprecationReason == null\n ) {\n context.reportError(\n `Interface field ${iface.name}.${ifaceField.name} is not deprecated, so ` +\n `implementation field ${type.name}.${typeField.name} must not be deprecated.`,\n [\n getDeprecatedDirectiveNode(typeField.astNode),\n typeField.astNode?.type,\n ],\n );\n }\n }\n}\n\nfunction validateTypeImplementsAncestors(\n context: SchemaValidationContext,\n type: GraphQLObjectType | GraphQLInterfaceType,\n iface: GraphQLInterfaceType,\n): void {\n const ifaceInterfaces = type.getInterfaces();\n for (const transitive of iface.getInterfaces()) {\n if (!ifaceInterfaces.includes(transitive)) {\n context.reportError(\n transitive === type\n ? `Type ${type} cannot implement ${iface} because it would create a circular reference.`\n : `Type ${type} must implement ${transitive} because it is implemented by ${iface}.`,\n [\n ...getAllImplementsInterfaceNodes(iface, transitive),\n ...getAllImplementsInterfaceNodes(type, iface),\n ],\n );\n }\n }\n}\n\nfunction validateUnionMembers(\n context: SchemaValidationContext,\n union: GraphQLUnionType,\n): void {\n const memberTypes = union.getTypes();\n\n if (memberTypes.length === 0) {\n context.reportError(\n `Union type ${union} must define one or more member types.`,\n [union.astNode, ...union.extensionASTNodes],\n );\n }\n\n const includedTypeNames = new Set();\n for (const memberType of memberTypes) {\n if (includedTypeNames.has(memberType.name)) {\n context.reportError(\n `Union type ${union} can only include type ${memberType} once.`,\n getUnionMemberTypeNodes(union, memberType.name),\n );\n continue;\n }\n includedTypeNames.add(memberType.name);\n if (!isObjectType(memberType)) {\n context.reportError(\n `Union type ${union} can only include Object types, ` +\n `it cannot include ${inspect(memberType)}.`,\n getUnionMemberTypeNodes(union, String(memberType)),\n );\n }\n }\n}\n\nfunction validateEnumValues(\n context: SchemaValidationContext,\n enumType: GraphQLEnumType,\n): void {\n const enumValues = enumType.getValues();\n\n if (enumValues.length === 0) {\n context.reportError(\n `Enum type ${enumType} must define one or more values.`,\n [enumType.astNode, ...enumType.extensionASTNodes],\n );\n }\n\n for (const enumValue of enumValues) {\n // Ensure valid name.\n validateName(context, enumValue);\n }\n}\n\nfunction validateInputFields(\n context: SchemaValidationContext,\n inputObj: GraphQLInputObjectType,\n): void {\n const fields = Object.values(inputObj.getFields());\n\n if (fields.length === 0) {\n context.reportError(\n `Input Object type ${inputObj} must define one or more fields.`,\n [inputObj.astNode, ...inputObj.extensionASTNodes],\n );\n }\n\n // Ensure the input fields are valid\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field);\n\n // Ensure the type is an input type\n if (!isInputType(field.type)) {\n context.reportError(\n `The type of ${field} must be Input Type ` +\n `but got: ${inspect(field.type)}.`,\n field.astNode?.type,\n );\n }\n\n if (isRequiredInputField(field) && field.deprecationReason != null) {\n context.reportError(\n `Required input field ${field} cannot be deprecated.`,\n [getDeprecatedDirectiveNode(field.astNode), field.astNode?.type],\n );\n }\n\n validateDefaultValue(context, field);\n\n if (inputObj.isOneOf) {\n validateOneOfInputObjectField(inputObj, field, context);\n }\n }\n}\n\nfunction validateOneOfInputObjectField(\n type: GraphQLInputObjectType,\n field: GraphQLInputField,\n context: SchemaValidationContext,\n): void {\n if (isNonNullType(field.type)) {\n context.reportError(\n `OneOf input field ${type}.${field.name} must be nullable.`,\n field.astNode?.type,\n );\n }\n\n if (field.default !== undefined || field.defaultValue !== undefined) {\n context.reportError(\n `OneOf input field ${type}.${field.name} cannot have a default value.`,\n field.astNode,\n );\n }\n}\n\nfunction createInputObjectNonNullCircularRefsValidator(\n context: SchemaValidationContext,\n): (inputObj: GraphQLInputObjectType) => void {\n // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.\n // Tracks already visited types to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedTypes = new Set();\n\n // Array of types nodes used to produce meaningful errors\n const fieldPath: Array<{ fieldStr: string; astNode: Maybe }> = [];\n\n // Position in the type path\n const fieldPathIndexByTypeName: ObjMap =\n Object.create(null);\n\n return detectCycleRecursive;\n\n // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n function detectCycleRecursive(inputObj: GraphQLInputObjectType): void {\n if (visitedTypes.has(inputObj)) {\n return;\n }\n\n visitedTypes.add(inputObj);\n fieldPathIndexByTypeName[inputObj.name] = fieldPath.length;\n\n const fields = Object.values(inputObj.getFields());\n for (const field of fields) {\n if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) {\n const fieldType = field.type.ofType;\n const cycleIndex = fieldPathIndexByTypeName[fieldType.name];\n\n fieldPath.push({\n fieldStr: `${inputObj}.${field.name}`,\n astNode: field.astNode,\n });\n if (cycleIndex === undefined) {\n detectCycleRecursive(fieldType);\n } else {\n const cyclePath = fieldPath.slice(cycleIndex);\n const pathStr = cyclePath\n .map((fieldObj) => fieldObj.fieldStr)\n .join(', ');\n context.reportError(\n `Invalid circular reference. The Input Object ${fieldType} references itself ${\n cyclePath.length > 1\n ? 'via the non-null fields:'\n : 'in the non-null field'\n } ${pathStr}.`,\n cyclePath.map((fieldObj) => fieldObj.astNode),\n );\n }\n fieldPath.pop();\n }\n }\n\n fieldPathIndexByTypeName[inputObj.name] = undefined;\n }\n}\n\nfunction createInputObjectDefaultValueCircularRefsValidator(\n context: SchemaValidationContext,\n): (inputObj: GraphQLInputObjectType) => void {\n // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.\n // Tracks already visited types to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedFields = Object.create(null);\n\n // Array of keys for fields and default values used to produce meaningful errors.\n const fieldPath: Array<\n [fieldStr: string, defaultValue: ConstValueNode | undefined]\n > = [];\n\n // Position in the path\n const fieldPathIndex: ObjMap = Object.create(null);\n\n // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n return function validateInputObjectDefaultValueCircularRefs(\n inputObj: GraphQLInputObjectType,\n ): void {\n // Start with an empty object as a way to visit every field in this input\n // object type and apply every default value.\n return detectValueDefaultValueCycle(inputObj, {});\n };\n\n function detectValueDefaultValueCycle(\n inputObj: GraphQLInputObjectType,\n defaultValue: unknown,\n ): void {\n // If the value is a List, recursively check each entry for a cycle.\n // Otherwise, only object values can contain a cycle.\n if (isIterableObject(defaultValue)) {\n for (const itemValue of defaultValue) {\n detectValueDefaultValueCycle(inputObj, itemValue);\n }\n return;\n } else if (!isObjectLike(defaultValue)) {\n return;\n }\n\n // Check each defined field for a cycle.\n for (const field of Object.values(inputObj.getFields())) {\n const namedFieldType = getNamedType(field.type);\n\n // Only input object type fields can result in a cycle.\n if (!isInputObjectType(namedFieldType)) {\n continue;\n }\n\n if (Object.hasOwn(defaultValue, field.name)) {\n // If the provided value has this field defined, recursively check it\n // for cycles.\n detectValueDefaultValueCycle(namedFieldType, defaultValue[field.name]);\n } else {\n // Otherwise check this field's default value for cycles.\n detectFieldDefaultValueCycle(\n field,\n namedFieldType,\n `${inputObj}.${field.name}`,\n );\n }\n }\n }\n\n function detectLiteralDefaultValueCycle(\n inputObj: GraphQLInputObjectType,\n defaultValue: ConstValueNode,\n ): void {\n // If the value is a List, recursively check each entry for a cycle.\n // Otherwise, only object values can contain a cycle.\n if (defaultValue.kind === Kind.LIST) {\n for (const itemLiteral of defaultValue.values) {\n detectLiteralDefaultValueCycle(inputObj, itemLiteral);\n }\n return;\n } else if (defaultValue.kind !== Kind.OBJECT) {\n return;\n }\n\n // Check each defined field for a cycle.\n const fieldNodes = keyMap(defaultValue.fields, (field) => field.name.value);\n for (const field of Object.values(inputObj.getFields())) {\n const namedFieldType = getNamedType(field.type);\n\n // Only input object type fields can result in a cycle.\n if (!isInputObjectType(namedFieldType)) {\n continue;\n }\n\n if (Object.hasOwn(fieldNodes, field.name)) {\n // If the provided value has this field defined, recursively check it\n // for cycles.\n detectLiteralDefaultValueCycle(\n namedFieldType,\n fieldNodes[field.name].value,\n );\n } else {\n // Otherwise check this field's default value for cycles.\n detectFieldDefaultValueCycle(\n field,\n namedFieldType,\n `${inputObj}.${field.name}`,\n );\n }\n }\n }\n\n function detectFieldDefaultValueCycle(\n field: GraphQLInputField,\n fieldType: GraphQLInputObjectType,\n fieldStr: string,\n ): void {\n // Only a field with a default value can result in a cycle.\n const defaultInput = field.default;\n if (defaultInput === undefined) {\n return;\n }\n\n // Check to see if there is cycle.\n const cycleIndex = fieldPathIndex[fieldStr];\n if (cycleIndex !== undefined && cycleIndex > 0) {\n context.reportError(\n `Invalid circular reference. The default value of Input Object field ${fieldStr} references itself${\n cycleIndex < fieldPath.length\n ? ` via the default values of: ${fieldPath\n .slice(cycleIndex)\n .map(([stringForMessage]) => stringForMessage)\n .join(', ')}`\n : ''\n }.`,\n fieldPath.slice(cycleIndex - 1).map(([, node]) => node),\n );\n return;\n }\n\n // Recurse into this field's default value once, tracking the path.\n if (visitedFields[fieldStr] === undefined) {\n visitedFields[fieldStr] = true;\n fieldPathIndex[fieldStr] = fieldPath.push([\n fieldStr,\n field.astNode?.defaultValue,\n ]);\n if (defaultInput.literal) {\n detectLiteralDefaultValueCycle(fieldType, defaultInput.literal);\n } else {\n detectValueDefaultValueCycle(fieldType, defaultInput.value);\n }\n fieldPath.pop();\n fieldPathIndex[fieldStr] = undefined;\n }\n }\n}\n\nfunction getAllImplementsInterfaceNodes(\n type: GraphQLObjectType | GraphQLInterfaceType,\n iface: GraphQLInterfaceType,\n): ReadonlyArray {\n const { astNode, extensionASTNodes } = type;\n const nodes: ReadonlyArray<\n | ObjectTypeDefinitionNode\n | ObjectTypeExtensionNode\n | InterfaceTypeDefinitionNode\n | InterfaceTypeExtensionNode\n > = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes;\n\n return nodes\n .flatMap((typeNode) => typeNode.interfaces ?? [])\n .filter((ifaceNode) => ifaceNode.name.value === iface.name);\n}\n\nfunction getUnionMemberTypeNodes(\n union: GraphQLUnionType,\n typeName: string,\n): ReadonlyArray {\n const { astNode, extensionASTNodes } = union;\n const nodes: ReadonlyArray =\n astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes;\n\n return nodes\n .flatMap((unionNode) => /* c8 ignore next */ unionNode.types ?? [])\n .filter((typeNode) => typeNode.name.value === typeName);\n}\n\nfunction getDeprecatedDirectiveNode(\n definitionNode: Maybe<{\n readonly directives?: ReadonlyArray | undefined;\n }>,\n): Maybe {\n return definitionNode?.directives?.find(\n (node) => node.name.value === GraphQLDeprecatedDirective.name,\n );\n}\n"]} \ No newline at end of file diff --git a/utilities/TypeInfo.d.ts b/utilities/TypeInfo.d.ts new file mode 100644 index 0000000000..45c2c07aa1 --- /dev/null +++ b/utilities/TypeInfo.d.ts @@ -0,0 +1,55 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ASTNode, FragmentDefinitionNode, VariableDefinitionNode } from '../language/ast.js'; +import type { ASTVisitor } from '../language/visitor.js'; +import type { GraphQLArgument, GraphQLCompositeType, GraphQLEnumValue, GraphQLField, GraphQLInputType, GraphQLOutputType, GraphQLType } from '../type/definition.js'; +import type { GraphQLDirective } from '../type/directives.js'; +import type { GraphQLSchema } from '../type/schema.js'; +export interface FragmentSignature { + readonly definition: FragmentDefinitionNode; + readonly variableDefinitions: Map; +} +/** + * TypeInfo is a utility class which, given a GraphQL schema, can keep track + * of the current field and type definitions at any point in a GraphQL document + * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + */ +export declare class TypeInfo { + private _schema; + private _typeStack; + private _parentTypeStack; + private _inputTypeStack; + private _fieldDefStack; + private _defaultValueStack; + private _directive; + private _argument; + private _enumValue; + private _fragmentSignaturesByName; + private _fragmentSignature; + private _fragmentArgument; + constructor(schema: GraphQLSchema, + /** + * Initial type may be provided in rare cases to facilitate traversals + * beginning somewhere other than documents. + */ + initialType?: Maybe, fragmentSignatures?: Maybe<(fragmentName: string) => Maybe>); + get [Symbol.toStringTag](): string; + getType(): Maybe; + getParentType(): Maybe; + getInputType(): Maybe; + getParentInputType(): Maybe; + getFieldDef(): Maybe>; + getDefaultValue(): unknown; + getDirective(): Maybe; + getArgument(): Maybe; + getFragmentSignature(): Maybe; + getFragmentSignatureByName(): (fragmentName: string) => Maybe; + getFragmentArgument(): Maybe; + getEnumValue(): Maybe; + enter(node: ASTNode): void; + leave(node: ASTNode): void; +} +/** + * Creates a new visitor instance which maintains a provided TypeInfo instance + * along with visiting visitor. + */ +export declare function visitWithTypeInfo(typeInfo: TypeInfo, visitor: ASTVisitor): ASTVisitor; diff --git a/utilities/TypeInfo.js b/utilities/TypeInfo.js new file mode 100644 index 0000000000..6bc98f452c --- /dev/null +++ b/utilities/TypeInfo.js @@ -0,0 +1,305 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TypeInfo = void 0; +exports.visitWithTypeInfo = visitWithTypeInfo; +const ast_js_1 = require("../language/ast.js"); +const kinds_js_1 = require("../language/kinds.js"); +const visitor_js_1 = require("../language/visitor.js"); +const definition_js_1 = require("../type/definition.js"); +const typeFromAST_js_1 = require("./typeFromAST.js"); +/** + * TypeInfo is a utility class which, given a GraphQL schema, can keep track + * of the current field and type definitions at any point in a GraphQL document + * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + */ +class TypeInfo { + constructor(schema, + /** + * Initial type may be provided in rare cases to facilitate traversals + * beginning somewhere other than documents. + */ + initialType, fragmentSignatures) { + this._schema = schema; + this._typeStack = []; + this._parentTypeStack = []; + this._inputTypeStack = []; + this._fieldDefStack = []; + this._defaultValueStack = []; + this._directive = null; + this._argument = null; + this._enumValue = null; + this._fragmentSignaturesByName = fragmentSignatures ?? (() => null); + this._fragmentSignature = null; + this._fragmentArgument = null; + if (initialType) { + if ((0, definition_js_1.isInputType)(initialType)) { + this._inputTypeStack.push(initialType); + } + if ((0, definition_js_1.isCompositeType)(initialType)) { + this._parentTypeStack.push(initialType); + } + if ((0, definition_js_1.isOutputType)(initialType)) { + this._typeStack.push(initialType); + } + } + } + get [Symbol.toStringTag]() { + return 'TypeInfo'; + } + getType() { + return this._typeStack.at(-1); + } + getParentType() { + return this._parentTypeStack.at(-1); + } + getInputType() { + return this._inputTypeStack.at(-1); + } + getParentInputType() { + return this._inputTypeStack.at(-2); + } + getFieldDef() { + return this._fieldDefStack.at(-1); + } + getDefaultValue() { + return this._defaultValueStack.at(-1); + } + getDirective() { + return this._directive; + } + getArgument() { + return this._argument; + } + getFragmentSignature() { + return this._fragmentSignature; + } + getFragmentSignatureByName() { + return this._fragmentSignaturesByName; + } + getFragmentArgument() { + return this._fragmentArgument; + } + getEnumValue() { + return this._enumValue; + } + enter(node) { + const schema = this._schema; + // Note: many of the types below are explicitly typed as "unknown" to drop + // any assumptions of a valid schema to ensure runtime types are properly + // checked before continuing since TypeInfo is used as part of validation + // which occurs before guarantees of schema and document validity. + switch (node.kind) { + case kinds_js_1.Kind.DOCUMENT: { + const fragmentSignatures = getFragmentSignatures(node); + this._fragmentSignaturesByName = (fragmentName) => fragmentSignatures.get(fragmentName); + break; + } + case kinds_js_1.Kind.SELECTION_SET: { + const namedType = (0, definition_js_1.getNamedType)(this.getType()); + this._parentTypeStack.push((0, definition_js_1.isCompositeType)(namedType) ? namedType : undefined); + break; + } + case kinds_js_1.Kind.FIELD: { + const parentType = this.getParentType(); + let fieldDef; + let fieldType; + if (parentType) { + fieldDef = schema.getField(parentType, node.name.value); + if (fieldDef) { + fieldType = fieldDef.type; + } + } + this._fieldDefStack.push(fieldDef); + this._typeStack.push((0, definition_js_1.isOutputType)(fieldType) ? fieldType : undefined); + break; + } + case kinds_js_1.Kind.DIRECTIVE: + this._directive = schema.getDirective(node.name.value); + break; + case kinds_js_1.Kind.OPERATION_DEFINITION: { + const rootType = schema.getRootType(node.operation); + this._typeStack.push((0, definition_js_1.isObjectType)(rootType) ? rootType : undefined); + break; + } + case kinds_js_1.Kind.FRAGMENT_SPREAD: { + this._fragmentSignature = this.getFragmentSignatureByName()(node.name.value); + break; + } + case kinds_js_1.Kind.INLINE_FRAGMENT: + case kinds_js_1.Kind.FRAGMENT_DEFINITION: { + const typeConditionAST = node.typeCondition; + const outputType = typeConditionAST + ? (0, typeFromAST_js_1.typeFromAST)(schema, typeConditionAST) + : (0, definition_js_1.getNamedType)(this.getType()); + this._typeStack.push((0, definition_js_1.isOutputType)(outputType) ? outputType : undefined); + break; + } + case kinds_js_1.Kind.VARIABLE_DEFINITION: { + const inputType = (0, typeFromAST_js_1.typeFromAST)(schema, node.type); + this._inputTypeStack.push((0, definition_js_1.isInputType)(inputType) ? inputType : undefined); + break; + } + case kinds_js_1.Kind.ARGUMENT: { + let argDef; + let argType; + const fieldOrDirective = this.getDirective() ?? this.getFieldDef(); + if (fieldOrDirective) { + argDef = fieldOrDirective.args.find((arg) => arg.name === node.name.value); + if (argDef) { + argType = argDef.type; + } + } + this._argument = argDef; + this._defaultValueStack.push(argDef?.default ?? argDef?.defaultValue ?? undefined); + this._inputTypeStack.push((0, definition_js_1.isInputType)(argType) ? argType : undefined); + break; + } + case kinds_js_1.Kind.FRAGMENT_ARGUMENT: { + const fragmentSignature = this.getFragmentSignature(); + const argDef = fragmentSignature?.variableDefinitions.get(node.name.value); + this._fragmentArgument = argDef; + let argType; + if (argDef) { + argType = (0, typeFromAST_js_1.typeFromAST)(this._schema, argDef.type); + } + this._inputTypeStack.push((0, definition_js_1.isInputType)(argType) ? argType : undefined); + break; + } + case kinds_js_1.Kind.LIST: { + const listType = (0, definition_js_1.getNullableType)(this.getInputType()); + const itemType = (0, definition_js_1.isListType)(listType) + ? listType.ofType + : listType; + // List positions never have a default value. + this._defaultValueStack.push(undefined); + this._inputTypeStack.push((0, definition_js_1.isInputType)(itemType) ? itemType : undefined); + break; + } + case kinds_js_1.Kind.OBJECT_FIELD: { + const objectType = (0, definition_js_1.getNamedType)(this.getInputType()); + let inputFieldType; + let inputField; + if ((0, definition_js_1.isInputObjectType)(objectType)) { + inputField = objectType.getFields()[node.name.value]; + if (inputField != null) { + inputFieldType = inputField.type; + } + } + this._defaultValueStack.push(inputField?.default ?? inputField?.defaultValue ?? undefined); + this._inputTypeStack.push((0, definition_js_1.isInputType)(inputFieldType) ? inputFieldType : undefined); + break; + } + case kinds_js_1.Kind.ENUM: { + const enumType = (0, definition_js_1.getNamedType)(this.getInputType()); + let enumValue; + if ((0, definition_js_1.isEnumType)(enumType)) { + enumValue = enumType.getValue(node.value); + } + this._enumValue = enumValue; + break; + } + default: + // Ignore other nodes + } + } + leave(node) { + switch (node.kind) { + case kinds_js_1.Kind.DOCUMENT: + this._fragmentSignaturesByName = /* c8 ignore start */ () => null /* c8 ignore end */; + break; + case kinds_js_1.Kind.SELECTION_SET: + this._parentTypeStack.pop(); + break; + case kinds_js_1.Kind.FIELD: + this._fieldDefStack.pop(); + this._typeStack.pop(); + break; + case kinds_js_1.Kind.DIRECTIVE: + this._directive = null; + break; + case kinds_js_1.Kind.FRAGMENT_SPREAD: + this._fragmentSignature = null; + break; + case kinds_js_1.Kind.OPERATION_DEFINITION: + case kinds_js_1.Kind.INLINE_FRAGMENT: + case kinds_js_1.Kind.FRAGMENT_DEFINITION: + this._typeStack.pop(); + break; + case kinds_js_1.Kind.VARIABLE_DEFINITION: + this._inputTypeStack.pop(); + break; + case kinds_js_1.Kind.ARGUMENT: + this._argument = null; + this._defaultValueStack.pop(); + this._inputTypeStack.pop(); + break; + case kinds_js_1.Kind.FRAGMENT_ARGUMENT: { + this._fragmentArgument = null; + this._defaultValueStack.pop(); + this._inputTypeStack.pop(); + break; + } + case kinds_js_1.Kind.LIST: + case kinds_js_1.Kind.OBJECT_FIELD: + this._defaultValueStack.pop(); + this._inputTypeStack.pop(); + break; + case kinds_js_1.Kind.ENUM: + this._enumValue = null; + break; + default: + // Ignore other nodes + } + } +} +exports.TypeInfo = TypeInfo; +function getFragmentSignatures(document) { + const fragmentSignatures = new Map(); + for (const definition of document.definitions) { + if (definition.kind === kinds_js_1.Kind.FRAGMENT_DEFINITION) { + const variableDefinitions = new Map(); + if (definition.variableDefinitions) { + for (const varDef of definition.variableDefinitions) { + variableDefinitions.set(varDef.variable.name.value, varDef); + } + } + const signature = { definition, variableDefinitions }; + fragmentSignatures.set(definition.name.value, signature); + } + } + return fragmentSignatures; +} +/** + * Creates a new visitor instance which maintains a provided TypeInfo instance + * along with visiting visitor. + */ +function visitWithTypeInfo(typeInfo, visitor) { + return { + enter(...args) { + const node = args[0]; + typeInfo.enter(node); + const fn = (0, visitor_js_1.getEnterLeaveForKind)(visitor, node.kind).enter; + if (fn) { + const result = fn.apply(visitor, args); + if (result !== undefined) { + typeInfo.leave(node); + if ((0, ast_js_1.isNode)(result)) { + typeInfo.enter(result); + } + } + return result; + } + }, + leave(...args) { + const node = args[0]; + const fn = (0, visitor_js_1.getEnterLeaveForKind)(visitor, node.kind).leave; + let result; + if (fn) { + result = fn.apply(visitor, args); + } + typeInfo.leave(node); + return result; + }, + }; +} +//# sourceMappingURL=TypeInfo.js.map \ No newline at end of file diff --git a/utilities/TypeInfo.js.map b/utilities/TypeInfo.js.map new file mode 100644 index 0000000000..cafe176b03 --- /dev/null +++ b/utilities/TypeInfo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TypeInfo.js","sourceRoot":"","sources":["../../src/utilities/TypeInfo.ts"],"names":[],"mappings":";;;AAiXA,8CA+BC;AAxYD,+CAA4C;AAC5C,mDA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,MAAM,CAAC;YACX,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACnC,CAAC;YACD,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n ASTNode,\n DocumentNode,\n FragmentDefinitionNode,\n VariableDefinitionNode,\n} from '../language/ast.js';\nimport { isNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport type { ASTVisitor } from '../language/visitor.js';\nimport { getEnterLeaveForKind } from '../language/visitor.js';\n\nimport type {\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLEnumValue,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLType,\n} from '../type/definition.js';\nimport {\n getNamedType,\n getNullableType,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isInputType,\n isListType,\n isObjectType,\n isOutputType,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { typeFromAST } from './typeFromAST.js';\n\nexport interface FragmentSignature {\n readonly definition: FragmentDefinitionNode;\n readonly variableDefinitions: Map;\n}\n\n/**\n * TypeInfo is a utility class which, given a GraphQL schema, can keep track\n * of the current field and type definitions at any point in a GraphQL document\n * AST during a recursive descent by calling `enter(node)` and `leave(node)`.\n */\nexport class TypeInfo {\n private _schema: GraphQLSchema;\n private _typeStack: Array>;\n private _parentTypeStack: Array>;\n private _inputTypeStack: Array>;\n private _fieldDefStack: Array>>;\n private _defaultValueStack: Array;\n private _directive: Maybe;\n private _argument: Maybe;\n private _enumValue: Maybe;\n private _fragmentSignaturesByName: (\n fragmentName: string,\n ) => Maybe;\n\n private _fragmentSignature: Maybe;\n private _fragmentArgument: Maybe;\n\n constructor(\n schema: GraphQLSchema,\n /**\n * Initial type may be provided in rare cases to facilitate traversals\n * beginning somewhere other than documents.\n */\n initialType?: Maybe,\n fragmentSignatures?: Maybe<\n (fragmentName: string) => Maybe\n >,\n ) {\n this._schema = schema;\n this._typeStack = [];\n this._parentTypeStack = [];\n this._inputTypeStack = [];\n this._fieldDefStack = [];\n this._defaultValueStack = [];\n this._directive = null;\n this._argument = null;\n this._enumValue = null;\n this._fragmentSignaturesByName = fragmentSignatures ?? (() => null);\n this._fragmentSignature = null;\n this._fragmentArgument = null;\n if (initialType) {\n if (isInputType(initialType)) {\n this._inputTypeStack.push(initialType);\n }\n if (isCompositeType(initialType)) {\n this._parentTypeStack.push(initialType);\n }\n if (isOutputType(initialType)) {\n this._typeStack.push(initialType);\n }\n }\n }\n\n get [Symbol.toStringTag]() {\n return 'TypeInfo';\n }\n\n getType(): Maybe {\n return this._typeStack.at(-1);\n }\n\n getParentType(): Maybe {\n return this._parentTypeStack.at(-1);\n }\n\n getInputType(): Maybe {\n return this._inputTypeStack.at(-1);\n }\n\n getParentInputType(): Maybe {\n return this._inputTypeStack.at(-2);\n }\n\n getFieldDef(): Maybe> {\n return this._fieldDefStack.at(-1);\n }\n\n getDefaultValue(): unknown {\n return this._defaultValueStack.at(-1);\n }\n\n getDirective(): Maybe {\n return this._directive;\n }\n\n getArgument(): Maybe {\n return this._argument;\n }\n\n getFragmentSignature(): Maybe {\n return this._fragmentSignature;\n }\n\n getFragmentSignatureByName(): (\n fragmentName: string,\n ) => Maybe {\n return this._fragmentSignaturesByName;\n }\n\n getFragmentArgument(): Maybe {\n return this._fragmentArgument;\n }\n\n getEnumValue(): Maybe {\n return this._enumValue;\n }\n\n enter(node: ASTNode) {\n const schema = this._schema;\n // Note: many of the types below are explicitly typed as \"unknown\" to drop\n // any assumptions of a valid schema to ensure runtime types are properly\n // checked before continuing since TypeInfo is used as part of validation\n // which occurs before guarantees of schema and document validity.\n switch (node.kind) {\n case Kind.DOCUMENT: {\n const fragmentSignatures = getFragmentSignatures(node);\n this._fragmentSignaturesByName = (fragmentName: string) =>\n fragmentSignatures.get(fragmentName);\n break;\n }\n case Kind.SELECTION_SET: {\n const namedType: unknown = getNamedType(this.getType());\n this._parentTypeStack.push(\n isCompositeType(namedType) ? namedType : undefined,\n );\n break;\n }\n case Kind.FIELD: {\n const parentType = this.getParentType();\n let fieldDef;\n let fieldType: unknown;\n if (parentType) {\n fieldDef = schema.getField(parentType, node.name.value);\n if (fieldDef) {\n fieldType = fieldDef.type;\n }\n }\n this._fieldDefStack.push(fieldDef);\n this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined);\n break;\n }\n case Kind.DIRECTIVE:\n this._directive = schema.getDirective(node.name.value);\n break;\n case Kind.OPERATION_DEFINITION: {\n const rootType = schema.getRootType(node.operation);\n this._typeStack.push(isObjectType(rootType) ? rootType : undefined);\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n this._fragmentSignature = this.getFragmentSignatureByName()(\n node.name.value,\n );\n break;\n }\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION: {\n const typeConditionAST = node.typeCondition;\n const outputType: unknown = typeConditionAST\n ? typeFromAST(schema, typeConditionAST)\n : getNamedType(this.getType());\n this._typeStack.push(isOutputType(outputType) ? outputType : undefined);\n break;\n }\n case Kind.VARIABLE_DEFINITION: {\n const inputType: unknown = typeFromAST(schema, node.type);\n this._inputTypeStack.push(\n isInputType(inputType) ? inputType : undefined,\n );\n break;\n }\n case Kind.ARGUMENT: {\n let argDef;\n let argType: unknown;\n const fieldOrDirective = this.getDirective() ?? this.getFieldDef();\n if (fieldOrDirective) {\n argDef = fieldOrDirective.args.find(\n (arg) => arg.name === node.name.value,\n );\n if (argDef) {\n argType = argDef.type;\n }\n }\n this._argument = argDef;\n this._defaultValueStack.push(\n argDef?.default ?? argDef?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.FRAGMENT_ARGUMENT: {\n const fragmentSignature = this.getFragmentSignature();\n const argDef = fragmentSignature?.variableDefinitions.get(\n node.name.value,\n );\n this._fragmentArgument = argDef;\n let argType: unknown;\n if (argDef) {\n argType = typeFromAST(this._schema, argDef.type);\n }\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.LIST: {\n const listType: unknown = getNullableType(this.getInputType());\n const itemType: unknown = isListType(listType)\n ? listType.ofType\n : listType;\n // List positions never have a default value.\n this._defaultValueStack.push(undefined);\n this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined);\n break;\n }\n case Kind.OBJECT_FIELD: {\n const objectType: unknown = getNamedType(this.getInputType());\n let inputFieldType: GraphQLInputType | undefined;\n let inputField: GraphQLInputField | undefined;\n if (isInputObjectType(objectType)) {\n inputField = objectType.getFields()[node.name.value];\n if (inputField != null) {\n inputFieldType = inputField.type;\n }\n }\n this._defaultValueStack.push(\n inputField?.default ?? inputField?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(\n isInputType(inputFieldType) ? inputFieldType : undefined,\n );\n break;\n }\n case Kind.ENUM: {\n const enumType: unknown = getNamedType(this.getInputType());\n let enumValue;\n if (isEnumType(enumType)) {\n enumValue = enumType.getValue(node.value);\n }\n this._enumValue = enumValue;\n break;\n }\n default:\n // Ignore other nodes\n }\n }\n\n leave(node: ASTNode) {\n switch (node.kind) {\n case Kind.DOCUMENT:\n this._fragmentSignaturesByName = /* c8 ignore start */ () =>\n null /* c8 ignore end */;\n break;\n case Kind.SELECTION_SET:\n this._parentTypeStack.pop();\n break;\n case Kind.FIELD:\n this._fieldDefStack.pop();\n this._typeStack.pop();\n break;\n case Kind.DIRECTIVE:\n this._directive = null;\n break;\n case Kind.FRAGMENT_SPREAD:\n this._fragmentSignature = null;\n break;\n case Kind.OPERATION_DEFINITION:\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n this._typeStack.pop();\n break;\n case Kind.VARIABLE_DEFINITION:\n this._inputTypeStack.pop();\n break;\n case Kind.ARGUMENT:\n this._argument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.FRAGMENT_ARGUMENT: {\n this._fragmentArgument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n }\n case Kind.LIST:\n case Kind.OBJECT_FIELD:\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.ENUM:\n this._enumValue = null;\n break;\n default:\n // Ignore other nodes\n }\n }\n}\n\nfunction getFragmentSignatures(\n document: DocumentNode,\n): Map {\n const fragmentSignatures = new Map();\n for (const definition of document.definitions) {\n if (definition.kind === Kind.FRAGMENT_DEFINITION) {\n const variableDefinitions = new Map();\n if (definition.variableDefinitions) {\n for (const varDef of definition.variableDefinitions) {\n variableDefinitions.set(varDef.variable.name.value, varDef);\n }\n }\n const signature = { definition, variableDefinitions };\n fragmentSignatures.set(definition.name.value, signature);\n }\n }\n return fragmentSignatures;\n}\n\n/**\n * Creates a new visitor instance which maintains a provided TypeInfo instance\n * along with visiting visitor.\n */\nexport function visitWithTypeInfo(\n typeInfo: TypeInfo,\n visitor: ASTVisitor,\n): ASTVisitor {\n return {\n enter(...args) {\n const node = args[0];\n typeInfo.enter(node);\n const fn = getEnterLeaveForKind(visitor, node.kind).enter;\n if (fn) {\n const result = fn.apply(visitor, args);\n if (result !== undefined) {\n typeInfo.leave(node);\n if (isNode(result)) {\n typeInfo.enter(result);\n }\n }\n return result;\n }\n },\n leave(...args) {\n const node = args[0];\n const fn = getEnterLeaveForKind(visitor, node.kind).leave;\n let result;\n if (fn) {\n result = fn.apply(visitor, args);\n }\n typeInfo.leave(node);\n return result;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/utilities/TypeInfo.mjs b/utilities/TypeInfo.mjs new file mode 100644 index 0000000000..11e1b347b5 --- /dev/null +++ b/utilities/TypeInfo.mjs @@ -0,0 +1,300 @@ +import { isNode } from "../language/ast.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { getEnterLeaveForKind } from "../language/visitor.mjs"; +import { getNamedType, getNullableType, isCompositeType, isEnumType, isInputObjectType, isInputType, isListType, isObjectType, isOutputType, } from "../type/definition.mjs"; +import { typeFromAST } from "./typeFromAST.mjs"; +/** + * TypeInfo is a utility class which, given a GraphQL schema, can keep track + * of the current field and type definitions at any point in a GraphQL document + * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + */ +export class TypeInfo { + constructor(schema, + /** + * Initial type may be provided in rare cases to facilitate traversals + * beginning somewhere other than documents. + */ + initialType, fragmentSignatures) { + this._schema = schema; + this._typeStack = []; + this._parentTypeStack = []; + this._inputTypeStack = []; + this._fieldDefStack = []; + this._defaultValueStack = []; + this._directive = null; + this._argument = null; + this._enumValue = null; + this._fragmentSignaturesByName = fragmentSignatures ?? (() => null); + this._fragmentSignature = null; + this._fragmentArgument = null; + if (initialType) { + if (isInputType(initialType)) { + this._inputTypeStack.push(initialType); + } + if (isCompositeType(initialType)) { + this._parentTypeStack.push(initialType); + } + if (isOutputType(initialType)) { + this._typeStack.push(initialType); + } + } + } + get [Symbol.toStringTag]() { + return 'TypeInfo'; + } + getType() { + return this._typeStack.at(-1); + } + getParentType() { + return this._parentTypeStack.at(-1); + } + getInputType() { + return this._inputTypeStack.at(-1); + } + getParentInputType() { + return this._inputTypeStack.at(-2); + } + getFieldDef() { + return this._fieldDefStack.at(-1); + } + getDefaultValue() { + return this._defaultValueStack.at(-1); + } + getDirective() { + return this._directive; + } + getArgument() { + return this._argument; + } + getFragmentSignature() { + return this._fragmentSignature; + } + getFragmentSignatureByName() { + return this._fragmentSignaturesByName; + } + getFragmentArgument() { + return this._fragmentArgument; + } + getEnumValue() { + return this._enumValue; + } + enter(node) { + const schema = this._schema; + // Note: many of the types below are explicitly typed as "unknown" to drop + // any assumptions of a valid schema to ensure runtime types are properly + // checked before continuing since TypeInfo is used as part of validation + // which occurs before guarantees of schema and document validity. + switch (node.kind) { + case Kind.DOCUMENT: { + const fragmentSignatures = getFragmentSignatures(node); + this._fragmentSignaturesByName = (fragmentName) => fragmentSignatures.get(fragmentName); + break; + } + case Kind.SELECTION_SET: { + const namedType = getNamedType(this.getType()); + this._parentTypeStack.push(isCompositeType(namedType) ? namedType : undefined); + break; + } + case Kind.FIELD: { + const parentType = this.getParentType(); + let fieldDef; + let fieldType; + if (parentType) { + fieldDef = schema.getField(parentType, node.name.value); + if (fieldDef) { + fieldType = fieldDef.type; + } + } + this._fieldDefStack.push(fieldDef); + this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined); + break; + } + case Kind.DIRECTIVE: + this._directive = schema.getDirective(node.name.value); + break; + case Kind.OPERATION_DEFINITION: { + const rootType = schema.getRootType(node.operation); + this._typeStack.push(isObjectType(rootType) ? rootType : undefined); + break; + } + case Kind.FRAGMENT_SPREAD: { + this._fragmentSignature = this.getFragmentSignatureByName()(node.name.value); + break; + } + case Kind.INLINE_FRAGMENT: + case Kind.FRAGMENT_DEFINITION: { + const typeConditionAST = node.typeCondition; + const outputType = typeConditionAST + ? typeFromAST(schema, typeConditionAST) + : getNamedType(this.getType()); + this._typeStack.push(isOutputType(outputType) ? outputType : undefined); + break; + } + case Kind.VARIABLE_DEFINITION: { + const inputType = typeFromAST(schema, node.type); + this._inputTypeStack.push(isInputType(inputType) ? inputType : undefined); + break; + } + case Kind.ARGUMENT: { + let argDef; + let argType; + const fieldOrDirective = this.getDirective() ?? this.getFieldDef(); + if (fieldOrDirective) { + argDef = fieldOrDirective.args.find((arg) => arg.name === node.name.value); + if (argDef) { + argType = argDef.type; + } + } + this._argument = argDef; + this._defaultValueStack.push(argDef?.default ?? argDef?.defaultValue ?? undefined); + this._inputTypeStack.push(isInputType(argType) ? argType : undefined); + break; + } + case Kind.FRAGMENT_ARGUMENT: { + const fragmentSignature = this.getFragmentSignature(); + const argDef = fragmentSignature?.variableDefinitions.get(node.name.value); + this._fragmentArgument = argDef; + let argType; + if (argDef) { + argType = typeFromAST(this._schema, argDef.type); + } + this._inputTypeStack.push(isInputType(argType) ? argType : undefined); + break; + } + case Kind.LIST: { + const listType = getNullableType(this.getInputType()); + const itemType = isListType(listType) + ? listType.ofType + : listType; + // List positions never have a default value. + this._defaultValueStack.push(undefined); + this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined); + break; + } + case Kind.OBJECT_FIELD: { + const objectType = getNamedType(this.getInputType()); + let inputFieldType; + let inputField; + if (isInputObjectType(objectType)) { + inputField = objectType.getFields()[node.name.value]; + if (inputField != null) { + inputFieldType = inputField.type; + } + } + this._defaultValueStack.push(inputField?.default ?? inputField?.defaultValue ?? undefined); + this._inputTypeStack.push(isInputType(inputFieldType) ? inputFieldType : undefined); + break; + } + case Kind.ENUM: { + const enumType = getNamedType(this.getInputType()); + let enumValue; + if (isEnumType(enumType)) { + enumValue = enumType.getValue(node.value); + } + this._enumValue = enumValue; + break; + } + default: + // Ignore other nodes + } + } + leave(node) { + switch (node.kind) { + case Kind.DOCUMENT: + this._fragmentSignaturesByName = /* c8 ignore start */ () => null /* c8 ignore end */; + break; + case Kind.SELECTION_SET: + this._parentTypeStack.pop(); + break; + case Kind.FIELD: + this._fieldDefStack.pop(); + this._typeStack.pop(); + break; + case Kind.DIRECTIVE: + this._directive = null; + break; + case Kind.FRAGMENT_SPREAD: + this._fragmentSignature = null; + break; + case Kind.OPERATION_DEFINITION: + case Kind.INLINE_FRAGMENT: + case Kind.FRAGMENT_DEFINITION: + this._typeStack.pop(); + break; + case Kind.VARIABLE_DEFINITION: + this._inputTypeStack.pop(); + break; + case Kind.ARGUMENT: + this._argument = null; + this._defaultValueStack.pop(); + this._inputTypeStack.pop(); + break; + case Kind.FRAGMENT_ARGUMENT: { + this._fragmentArgument = null; + this._defaultValueStack.pop(); + this._inputTypeStack.pop(); + break; + } + case Kind.LIST: + case Kind.OBJECT_FIELD: + this._defaultValueStack.pop(); + this._inputTypeStack.pop(); + break; + case Kind.ENUM: + this._enumValue = null; + break; + default: + // Ignore other nodes + } + } +} +function getFragmentSignatures(document) { + const fragmentSignatures = new Map(); + for (const definition of document.definitions) { + if (definition.kind === Kind.FRAGMENT_DEFINITION) { + const variableDefinitions = new Map(); + if (definition.variableDefinitions) { + for (const varDef of definition.variableDefinitions) { + variableDefinitions.set(varDef.variable.name.value, varDef); + } + } + const signature = { definition, variableDefinitions }; + fragmentSignatures.set(definition.name.value, signature); + } + } + return fragmentSignatures; +} +/** + * Creates a new visitor instance which maintains a provided TypeInfo instance + * along with visiting visitor. + */ +export function visitWithTypeInfo(typeInfo, visitor) { + return { + enter(...args) { + const node = args[0]; + typeInfo.enter(node); + const fn = getEnterLeaveForKind(visitor, node.kind).enter; + if (fn) { + const result = fn.apply(visitor, args); + if (result !== undefined) { + typeInfo.leave(node); + if (isNode(result)) { + typeInfo.enter(result); + } + } + return result; + } + }, + leave(...args) { + const node = args[0]; + const fn = getEnterLeaveForKind(visitor, node.kind).leave; + let result; + if (fn) { + result = fn.apply(visitor, args); + } + typeInfo.leave(node); + return result; + }, + }; +} +//# sourceMappingURL=TypeInfo.js.map \ No newline at end of file diff --git a/utilities/TypeInfo.mjs.map b/utilities/TypeInfo.mjs.map new file mode 100644 index 0000000000..1debe63672 --- /dev/null +++ b/utilities/TypeInfo.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"TypeInfo.js","sourceRoot":"","sources":["../../src/utilities/TypeInfo.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,4BAA2B;AAC5C,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C,OAAO,EAAE,oBAAoB,EAAE,gCAA+B;AAY9D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,GACb,+BAA8B;AAI/B,OAAO,EAAE,WAAW,EAAE,0BAAyB;AAO/C;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IAiBnB,YACE,MAAqB;IACrB;;;OAGG;IACH,WAAgC,EAChC,kBAEC;QAED,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B,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAkB,EAClB,OAAmB;IAEnB,OAAO;QACL,KAAK,CAAC,GAAG,IAAI;YACX,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,MAAM,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;YAC1D,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBACzB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBACrB,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;wBACnB,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,GAAG,IAAI;YACX,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;YAC1D,IAAI,MAAM,CAAC;YACX,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACnC,CAAC;YACD,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n ASTNode,\n DocumentNode,\n FragmentDefinitionNode,\n VariableDefinitionNode,\n} from '../language/ast.js';\nimport { isNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport type { ASTVisitor } from '../language/visitor.js';\nimport { getEnterLeaveForKind } from '../language/visitor.js';\n\nimport type {\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLEnumValue,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLType,\n} from '../type/definition.js';\nimport {\n getNamedType,\n getNullableType,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isInputType,\n isListType,\n isObjectType,\n isOutputType,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { typeFromAST } from './typeFromAST.js';\n\nexport interface FragmentSignature {\n readonly definition: FragmentDefinitionNode;\n readonly variableDefinitions: Map;\n}\n\n/**\n * TypeInfo is a utility class which, given a GraphQL schema, can keep track\n * of the current field and type definitions at any point in a GraphQL document\n * AST during a recursive descent by calling `enter(node)` and `leave(node)`.\n */\nexport class TypeInfo {\n private _schema: GraphQLSchema;\n private _typeStack: Array>;\n private _parentTypeStack: Array>;\n private _inputTypeStack: Array>;\n private _fieldDefStack: Array>>;\n private _defaultValueStack: Array;\n private _directive: Maybe;\n private _argument: Maybe;\n private _enumValue: Maybe;\n private _fragmentSignaturesByName: (\n fragmentName: string,\n ) => Maybe;\n\n private _fragmentSignature: Maybe;\n private _fragmentArgument: Maybe;\n\n constructor(\n schema: GraphQLSchema,\n /**\n * Initial type may be provided in rare cases to facilitate traversals\n * beginning somewhere other than documents.\n */\n initialType?: Maybe,\n fragmentSignatures?: Maybe<\n (fragmentName: string) => Maybe\n >,\n ) {\n this._schema = schema;\n this._typeStack = [];\n this._parentTypeStack = [];\n this._inputTypeStack = [];\n this._fieldDefStack = [];\n this._defaultValueStack = [];\n this._directive = null;\n this._argument = null;\n this._enumValue = null;\n this._fragmentSignaturesByName = fragmentSignatures ?? (() => null);\n this._fragmentSignature = null;\n this._fragmentArgument = null;\n if (initialType) {\n if (isInputType(initialType)) {\n this._inputTypeStack.push(initialType);\n }\n if (isCompositeType(initialType)) {\n this._parentTypeStack.push(initialType);\n }\n if (isOutputType(initialType)) {\n this._typeStack.push(initialType);\n }\n }\n }\n\n get [Symbol.toStringTag]() {\n return 'TypeInfo';\n }\n\n getType(): Maybe {\n return this._typeStack.at(-1);\n }\n\n getParentType(): Maybe {\n return this._parentTypeStack.at(-1);\n }\n\n getInputType(): Maybe {\n return this._inputTypeStack.at(-1);\n }\n\n getParentInputType(): Maybe {\n return this._inputTypeStack.at(-2);\n }\n\n getFieldDef(): Maybe> {\n return this._fieldDefStack.at(-1);\n }\n\n getDefaultValue(): unknown {\n return this._defaultValueStack.at(-1);\n }\n\n getDirective(): Maybe {\n return this._directive;\n }\n\n getArgument(): Maybe {\n return this._argument;\n }\n\n getFragmentSignature(): Maybe {\n return this._fragmentSignature;\n }\n\n getFragmentSignatureByName(): (\n fragmentName: string,\n ) => Maybe {\n return this._fragmentSignaturesByName;\n }\n\n getFragmentArgument(): Maybe {\n return this._fragmentArgument;\n }\n\n getEnumValue(): Maybe {\n return this._enumValue;\n }\n\n enter(node: ASTNode) {\n const schema = this._schema;\n // Note: many of the types below are explicitly typed as \"unknown\" to drop\n // any assumptions of a valid schema to ensure runtime types are properly\n // checked before continuing since TypeInfo is used as part of validation\n // which occurs before guarantees of schema and document validity.\n switch (node.kind) {\n case Kind.DOCUMENT: {\n const fragmentSignatures = getFragmentSignatures(node);\n this._fragmentSignaturesByName = (fragmentName: string) =>\n fragmentSignatures.get(fragmentName);\n break;\n }\n case Kind.SELECTION_SET: {\n const namedType: unknown = getNamedType(this.getType());\n this._parentTypeStack.push(\n isCompositeType(namedType) ? namedType : undefined,\n );\n break;\n }\n case Kind.FIELD: {\n const parentType = this.getParentType();\n let fieldDef;\n let fieldType: unknown;\n if (parentType) {\n fieldDef = schema.getField(parentType, node.name.value);\n if (fieldDef) {\n fieldType = fieldDef.type;\n }\n }\n this._fieldDefStack.push(fieldDef);\n this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined);\n break;\n }\n case Kind.DIRECTIVE:\n this._directive = schema.getDirective(node.name.value);\n break;\n case Kind.OPERATION_DEFINITION: {\n const rootType = schema.getRootType(node.operation);\n this._typeStack.push(isObjectType(rootType) ? rootType : undefined);\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n this._fragmentSignature = this.getFragmentSignatureByName()(\n node.name.value,\n );\n break;\n }\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION: {\n const typeConditionAST = node.typeCondition;\n const outputType: unknown = typeConditionAST\n ? typeFromAST(schema, typeConditionAST)\n : getNamedType(this.getType());\n this._typeStack.push(isOutputType(outputType) ? outputType : undefined);\n break;\n }\n case Kind.VARIABLE_DEFINITION: {\n const inputType: unknown = typeFromAST(schema, node.type);\n this._inputTypeStack.push(\n isInputType(inputType) ? inputType : undefined,\n );\n break;\n }\n case Kind.ARGUMENT: {\n let argDef;\n let argType: unknown;\n const fieldOrDirective = this.getDirective() ?? this.getFieldDef();\n if (fieldOrDirective) {\n argDef = fieldOrDirective.args.find(\n (arg) => arg.name === node.name.value,\n );\n if (argDef) {\n argType = argDef.type;\n }\n }\n this._argument = argDef;\n this._defaultValueStack.push(\n argDef?.default ?? argDef?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.FRAGMENT_ARGUMENT: {\n const fragmentSignature = this.getFragmentSignature();\n const argDef = fragmentSignature?.variableDefinitions.get(\n node.name.value,\n );\n this._fragmentArgument = argDef;\n let argType: unknown;\n if (argDef) {\n argType = typeFromAST(this._schema, argDef.type);\n }\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.LIST: {\n const listType: unknown = getNullableType(this.getInputType());\n const itemType: unknown = isListType(listType)\n ? listType.ofType\n : listType;\n // List positions never have a default value.\n this._defaultValueStack.push(undefined);\n this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined);\n break;\n }\n case Kind.OBJECT_FIELD: {\n const objectType: unknown = getNamedType(this.getInputType());\n let inputFieldType: GraphQLInputType | undefined;\n let inputField: GraphQLInputField | undefined;\n if (isInputObjectType(objectType)) {\n inputField = objectType.getFields()[node.name.value];\n if (inputField != null) {\n inputFieldType = inputField.type;\n }\n }\n this._defaultValueStack.push(\n inputField?.default ?? inputField?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(\n isInputType(inputFieldType) ? inputFieldType : undefined,\n );\n break;\n }\n case Kind.ENUM: {\n const enumType: unknown = getNamedType(this.getInputType());\n let enumValue;\n if (isEnumType(enumType)) {\n enumValue = enumType.getValue(node.value);\n }\n this._enumValue = enumValue;\n break;\n }\n default:\n // Ignore other nodes\n }\n }\n\n leave(node: ASTNode) {\n switch (node.kind) {\n case Kind.DOCUMENT:\n this._fragmentSignaturesByName = /* c8 ignore start */ () =>\n null /* c8 ignore end */;\n break;\n case Kind.SELECTION_SET:\n this._parentTypeStack.pop();\n break;\n case Kind.FIELD:\n this._fieldDefStack.pop();\n this._typeStack.pop();\n break;\n case Kind.DIRECTIVE:\n this._directive = null;\n break;\n case Kind.FRAGMENT_SPREAD:\n this._fragmentSignature = null;\n break;\n case Kind.OPERATION_DEFINITION:\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n this._typeStack.pop();\n break;\n case Kind.VARIABLE_DEFINITION:\n this._inputTypeStack.pop();\n break;\n case Kind.ARGUMENT:\n this._argument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.FRAGMENT_ARGUMENT: {\n this._fragmentArgument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n }\n case Kind.LIST:\n case Kind.OBJECT_FIELD:\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.ENUM:\n this._enumValue = null;\n break;\n default:\n // Ignore other nodes\n }\n }\n}\n\nfunction getFragmentSignatures(\n document: DocumentNode,\n): Map {\n const fragmentSignatures = new Map();\n for (const definition of document.definitions) {\n if (definition.kind === Kind.FRAGMENT_DEFINITION) {\n const variableDefinitions = new Map();\n if (definition.variableDefinitions) {\n for (const varDef of definition.variableDefinitions) {\n variableDefinitions.set(varDef.variable.name.value, varDef);\n }\n }\n const signature = { definition, variableDefinitions };\n fragmentSignatures.set(definition.name.value, signature);\n }\n }\n return fragmentSignatures;\n}\n\n/**\n * Creates a new visitor instance which maintains a provided TypeInfo instance\n * along with visiting visitor.\n */\nexport function visitWithTypeInfo(\n typeInfo: TypeInfo,\n visitor: ASTVisitor,\n): ASTVisitor {\n return {\n enter(...args) {\n const node = args[0];\n typeInfo.enter(node);\n const fn = getEnterLeaveForKind(visitor, node.kind).enter;\n if (fn) {\n const result = fn.apply(visitor, args);\n if (result !== undefined) {\n typeInfo.leave(node);\n if (isNode(result)) {\n typeInfo.enter(result);\n }\n }\n return result;\n }\n },\n leave(...args) {\n const node = args[0];\n const fn = getEnterLeaveForKind(visitor, node.kind).leave;\n let result;\n if (fn) {\n result = fn.apply(visitor, args);\n }\n typeInfo.leave(node);\n return result;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/utilities/astFromValue.d.ts b/utilities/astFromValue.d.ts new file mode 100644 index 0000000000..d16f5fe169 --- /dev/null +++ b/utilities/astFromValue.d.ts @@ -0,0 +1,26 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ConstValueNode } from '../language/ast.js'; +import type { GraphQLInputType } from '../type/definition.js'; +/** + * Produces a GraphQL Value AST given a JavaScript object. + * Function will match JavaScript/JSON values to GraphQL AST schema format + * by using suggested GraphQLInputType. For example: + * + * astFromValue("value", GraphQLString) + * + * A GraphQL type must be provided, which will be used to interpret different + * JavaScript values. + * + * | JSON Value | GraphQL Value | + * | ------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String / Enum Value | + * | Number | Int / Float | + * | Unknown | Enum Value | + * | null | NullValue | + * + * @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 + */ +export declare function astFromValue(value: unknown, type: GraphQLInputType): Maybe; diff --git a/utilities/astFromValue.js b/utilities/astFromValue.js new file mode 100644 index 0000000000..66c6d59058 --- /dev/null +++ b/utilities/astFromValue.js @@ -0,0 +1,128 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.astFromValue = astFromValue; +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const isIterableObject_js_1 = require("../jsutils/isIterableObject.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +const scalars_js_1 = require("../type/scalars.js"); +/** + * Produces a GraphQL Value AST given a JavaScript object. + * Function will match JavaScript/JSON values to GraphQL AST schema format + * by using suggested GraphQLInputType. For example: + * + * astFromValue("value", GraphQLString) + * + * A GraphQL type must be provided, which will be used to interpret different + * JavaScript values. + * + * | JSON Value | GraphQL Value | + * | ------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String / Enum Value | + * | Number | Int / Float | + * | Unknown | Enum Value | + * | null | NullValue | + * + * @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 + */ +function astFromValue(value, type) { + if ((0, definition_js_1.isNonNullType)(type)) { + const astValue = astFromValue(value, type.ofType); + if (astValue?.kind === kinds_js_1.Kind.NULL) { + return null; + } + return astValue; + } + // only explicit null, not undefined, NaN + if (value === null) { + return { kind: kinds_js_1.Kind.NULL }; + } + // undefined + if (value === undefined) { + return null; + } + // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but + // the value is not an array, convert the value using the list's item type. + if ((0, definition_js_1.isListType)(type)) { + const itemType = type.ofType; + if ((0, isIterableObject_js_1.isIterableObject)(value)) { + const valuesNodes = []; + for (const item of value) { + const itemNode = astFromValue(item, itemType); + if (itemNode != null) { + valuesNodes.push(itemNode); + } + } + return { kind: kinds_js_1.Kind.LIST, values: valuesNodes }; + } + return astFromValue(value, itemType); + } + // Populate the fields of the input object by creating ASTs from each value + // in the JavaScript object according to the fields in the input type. + if ((0, definition_js_1.isInputObjectType)(type)) { + if (!(0, isObjectLike_js_1.isObjectLike)(value)) { + return null; + } + const fieldNodes = []; + for (const field of Object.values(type.getFields())) { + const fieldValue = astFromValue(value[field.name], field.type); + if (fieldValue) { + fieldNodes.push({ + kind: kinds_js_1.Kind.OBJECT_FIELD, + name: { kind: kinds_js_1.Kind.NAME, value: field.name }, + value: fieldValue, + }); + } + } + return { kind: kinds_js_1.Kind.OBJECT, fields: fieldNodes }; + } + if ((0, definition_js_1.isLeafType)(type)) { + // Since value is an internally represented value, it must be coerced + // to an externally represented value before converting into an AST. + const coerced = type.coerceOutputValue(value); + if (coerced == null) { + return null; + } + // Others coerce based on their corresponding JavaScript scalar types. + if (typeof coerced === 'boolean') { + return { kind: kinds_js_1.Kind.BOOLEAN, value: coerced }; + } + // JavaScript numbers can be Int or Float values. + if (typeof coerced === 'number' && Number.isFinite(coerced)) { + const stringNum = String(coerced); + return integerStringRegExp.test(stringNum) + ? { kind: kinds_js_1.Kind.INT, value: stringNum } + : { kind: kinds_js_1.Kind.FLOAT, value: stringNum }; + } + if (typeof coerced === 'string') { + // Enum types use Enum literals. + if ((0, definition_js_1.isEnumType)(type)) { + return { kind: kinds_js_1.Kind.ENUM, value: coerced }; + } + // ID types can use Int literals. + if (type === scalars_js_1.GraphQLID && integerStringRegExp.test(coerced)) { + return { kind: kinds_js_1.Kind.INT, value: coerced }; + } + return { + kind: kinds_js_1.Kind.STRING, + value: coerced, + }; + } + throw new TypeError(`Cannot convert value to AST: ${(0, inspect_js_1.inspect)(coerced)}.`); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected input type: ' + (0, inspect_js_1.inspect)(type)); +} +/** + * IntValue: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit ( Digit+ )? + */ +const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; +//# sourceMappingURL=astFromValue.js.map \ No newline at end of file diff --git a/utilities/astFromValue.js.map b/utilities/astFromValue.js.map new file mode 100644 index 0000000000..04dcc374c2 --- /dev/null +++ b/utilities/astFromValue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"astFromValue.js","sourceRoot":"","sources":["../../src/utilities/astFromValue.ts"],"names":[],"mappings":";;AAyCA,oCAsGC;AA/ID,sDAAgD;AAChD,0DAAoD;AACpD,wEAAkE;AAClE,gEAA0D;AAI1D,mDAA4C;AAG5C,yDAM+B;AAC/B,mDAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,YAAY,CAC1B,KAAc,EACd,IAAsB;IAEtB,IAAI,IAAA,6BAAa,EAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,QAAQ,EAAE,IAAI,KAAK,eAAI,CAAC,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,yCAAyC;IACzC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,EAAE,IAAI,EAAE,eAAI,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,YAAY;IACZ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8EAA8E;IAC9E,2EAA2E;IAC3E,IAAI,IAAA,0BAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;QAC7B,IAAI,IAAA,sCAAgB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG,EAAE,CAAC;YACvB,KAAK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,CAAC;QAED,MAAM,IAAI,SAAS,CAAC,gCAAgC,IAAA,oBAAO,EAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3E,CAAC;IACD,sBAAsB;IACtB,0DAA0D;IAC1D,CAAU,KAAK,SAAf,wBAAS,SAAQ,yBAAyB,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,EAAE;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,uBAAuB,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ConstObjectFieldNode, ConstValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isLeafType,\n isListType,\n isNonNullType,\n} from '../type/definition.js';\nimport { GraphQLID } from '../type/scalars.js';\n\n/**\n * Produces a GraphQL Value AST given a JavaScript object.\n * Function will match JavaScript/JSON values to GraphQL AST schema format\n * by using suggested GraphQLInputType. For example:\n *\n * astFromValue(\"value\", GraphQLString)\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * JavaScript values.\n *\n * | JSON Value | GraphQL Value |\n * | ------------- | -------------------- |\n * | Object | Input Object |\n * | Array | List |\n * | Boolean | Boolean |\n * | String | String / Enum Value |\n * | Number | Int / Float |\n * | Unknown | Enum Value |\n * | null | NullValue |\n *\n * @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18\n */\nexport function astFromValue(\n value: unknown,\n type: GraphQLInputType,\n): Maybe {\n if (isNonNullType(type)) {\n const astValue = astFromValue(value, type.ofType);\n if (astValue?.kind === Kind.NULL) {\n return null;\n }\n return astValue;\n }\n\n // only explicit null, not undefined, NaN\n if (value === null) {\n return { kind: Kind.NULL };\n }\n\n // undefined\n if (value === undefined) {\n return null;\n }\n\n // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but\n // the value is not an array, convert the value using the list's item type.\n if (isListType(type)) {\n const itemType = type.ofType;\n if (isIterableObject(value)) {\n const valuesNodes = [];\n for (const item of value) {\n const itemNode = astFromValue(item, itemType);\n if (itemNode != null) {\n valuesNodes.push(itemNode);\n }\n }\n return { kind: Kind.LIST, values: valuesNodes };\n }\n return astFromValue(value, itemType);\n }\n\n // Populate the fields of the input object by creating ASTs from each value\n // in the JavaScript object according to the fields in the input type.\n if (isInputObjectType(type)) {\n if (!isObjectLike(value)) {\n return null;\n }\n const fieldNodes: Array = [];\n for (const field of Object.values(type.getFields())) {\n const fieldValue = astFromValue(value[field.name], field.type);\n if (fieldValue) {\n fieldNodes.push({\n kind: Kind.OBJECT_FIELD,\n name: { kind: Kind.NAME, value: field.name },\n value: fieldValue,\n });\n }\n }\n return { kind: Kind.OBJECT, fields: fieldNodes };\n }\n\n if (isLeafType(type)) {\n // Since value is an internally represented value, it must be coerced\n // to an externally represented value before converting into an AST.\n const coerced = type.coerceOutputValue(value);\n if (coerced == null) {\n return null;\n }\n\n // Others coerce based on their corresponding JavaScript scalar types.\n if (typeof coerced === 'boolean') {\n return { kind: Kind.BOOLEAN, value: coerced };\n }\n\n // JavaScript numbers can be Int or Float values.\n if (typeof coerced === 'number' && Number.isFinite(coerced)) {\n const stringNum = String(coerced);\n return integerStringRegExp.test(stringNum)\n ? { kind: Kind.INT, value: stringNum }\n : { kind: Kind.FLOAT, value: stringNum };\n }\n\n if (typeof coerced === 'string') {\n // Enum types use Enum literals.\n if (isEnumType(type)) {\n return { kind: Kind.ENUM, value: coerced };\n }\n\n // ID types can use Int literals.\n if (type === GraphQLID && integerStringRegExp.test(coerced)) {\n return { kind: Kind.INT, value: coerced };\n }\n\n return {\n kind: Kind.STRING,\n value: coerced,\n };\n }\n\n throw new TypeError(`Cannot convert value to AST: ${inspect(coerced)}.`);\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered.\n invariant(false, 'Unexpected input type: ' + inspect(type));\n}\n\n/**\n * IntValue:\n * - NegativeSign? 0\n * - NegativeSign? NonZeroDigit ( Digit+ )?\n */\nconst integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;\n"]} \ No newline at end of file diff --git a/utilities/astFromValue.mjs b/utilities/astFromValue.mjs new file mode 100644 index 0000000000..8b0db6602f --- /dev/null +++ b/utilities/astFromValue.mjs @@ -0,0 +1,125 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { isIterableObject } from "../jsutils/isIterableObject.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { isEnumType, isInputObjectType, isLeafType, isListType, isNonNullType, } from "../type/definition.mjs"; +import { GraphQLID } from "../type/scalars.mjs"; +/** + * Produces a GraphQL Value AST given a JavaScript object. + * Function will match JavaScript/JSON values to GraphQL AST schema format + * by using suggested GraphQLInputType. For example: + * + * astFromValue("value", GraphQLString) + * + * A GraphQL type must be provided, which will be used to interpret different + * JavaScript values. + * + * | JSON Value | GraphQL Value | + * | ------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String / Enum Value | + * | Number | Int / Float | + * | Unknown | Enum Value | + * | null | NullValue | + * + * @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 + */ +export function astFromValue(value, type) { + if (isNonNullType(type)) { + const astValue = astFromValue(value, type.ofType); + if (astValue?.kind === Kind.NULL) { + return null; + } + return astValue; + } + // only explicit null, not undefined, NaN + if (value === null) { + return { kind: Kind.NULL }; + } + // undefined + if (value === undefined) { + return null; + } + // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but + // the value is not an array, convert the value using the list's item type. + if (isListType(type)) { + const itemType = type.ofType; + if (isIterableObject(value)) { + const valuesNodes = []; + for (const item of value) { + const itemNode = astFromValue(item, itemType); + if (itemNode != null) { + valuesNodes.push(itemNode); + } + } + return { kind: Kind.LIST, values: valuesNodes }; + } + return astFromValue(value, itemType); + } + // Populate the fields of the input object by creating ASTs from each value + // in the JavaScript object according to the fields in the input type. + if (isInputObjectType(type)) { + if (!isObjectLike(value)) { + return null; + } + const fieldNodes = []; + for (const field of Object.values(type.getFields())) { + const fieldValue = astFromValue(value[field.name], field.type); + if (fieldValue) { + fieldNodes.push({ + kind: Kind.OBJECT_FIELD, + name: { kind: Kind.NAME, value: field.name }, + value: fieldValue, + }); + } + } + return { kind: Kind.OBJECT, fields: fieldNodes }; + } + if (isLeafType(type)) { + // Since value is an internally represented value, it must be coerced + // to an externally represented value before converting into an AST. + const coerced = type.coerceOutputValue(value); + if (coerced == null) { + return null; + } + // Others coerce based on their corresponding JavaScript scalar types. + if (typeof coerced === 'boolean') { + return { kind: Kind.BOOLEAN, value: coerced }; + } + // JavaScript numbers can be Int or Float values. + if (typeof coerced === 'number' && Number.isFinite(coerced)) { + const stringNum = String(coerced); + return integerStringRegExp.test(stringNum) + ? { kind: Kind.INT, value: stringNum } + : { kind: Kind.FLOAT, value: stringNum }; + } + if (typeof coerced === 'string') { + // Enum types use Enum literals. + if (isEnumType(type)) { + return { kind: Kind.ENUM, value: coerced }; + } + // ID types can use Int literals. + if (type === GraphQLID && integerStringRegExp.test(coerced)) { + return { kind: Kind.INT, value: coerced }; + } + return { + kind: Kind.STRING, + value: coerced, + }; + } + throw new TypeError(`Cannot convert value to AST: ${inspect(coerced)}.`); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + (false) || invariant(false, 'Unexpected input type: ' + inspect(type)); +} +/** + * IntValue: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit ( Digit+ )? + */ +const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; +//# sourceMappingURL=astFromValue.js.map \ No newline at end of file diff --git a/utilities/astFromValue.mjs.map b/utilities/astFromValue.mjs.map new file mode 100644 index 0000000000..bf8e6db92d --- /dev/null +++ b/utilities/astFromValue.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"astFromValue.js","sourceRoot":"","sources":["../../src/utilities/astFromValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,gBAAgB,EAAE,wCAAuC;AAClE,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAI1D,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAG5C,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,aAAa,GACd,+BAA8B;AAC/B,OAAO,EAAE,SAAS,EAAE,4BAA2B;AAE/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAc,EACd,IAAsB;IAEtB,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,QAAQ,EAAE,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,yCAAyC;IACzC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,YAAY;IACZ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8EAA8E;IAC9E,2EAA2E;IAC3E,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;QAC7B,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG,EAAE,CAAC;YACvB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I,SAAS,CAAC,gCAAgC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3E,CAAC;IACD,sBAAsB;IACtB,0DAA0D;IAC1D,CAAU,KAAK,KAAf,SAAS,QAAQ,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,uBAAuB,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ConstObjectFieldNode, ConstValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isLeafType,\n isListType,\n isNonNullType,\n} from '../type/definition.js';\nimport { GraphQLID } from '../type/scalars.js';\n\n/**\n * Produces a GraphQL Value AST given a JavaScript object.\n * Function will match JavaScript/JSON values to GraphQL AST schema format\n * by using suggested GraphQLInputType. For example:\n *\n * astFromValue(\"value\", GraphQLString)\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * JavaScript values.\n *\n * | JSON Value | GraphQL Value |\n * | ------------- | -------------------- |\n * | Object | Input Object |\n * | Array | List |\n * | Boolean | Boolean |\n * | String | String / Enum Value |\n * | Number | Int / Float |\n * | Unknown | Enum Value |\n * | null | NullValue |\n *\n * @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18\n */\nexport function astFromValue(\n value: unknown,\n type: GraphQLInputType,\n): Maybe {\n if (isNonNullType(type)) {\n const astValue = astFromValue(value, type.ofType);\n if (astValue?.kind === Kind.NULL) {\n return null;\n }\n return astValue;\n }\n\n // only explicit null, not undefined, NaN\n if (value === null) {\n return { kind: Kind.NULL };\n }\n\n // undefined\n if (value === undefined) {\n return null;\n }\n\n // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but\n // the value is not an array, convert the value using the list's item type.\n if (isListType(type)) {\n const itemType = type.ofType;\n if (isIterableObject(value)) {\n const valuesNodes = [];\n for (const item of value) {\n const itemNode = astFromValue(item, itemType);\n if (itemNode != null) {\n valuesNodes.push(itemNode);\n }\n }\n return { kind: Kind.LIST, values: valuesNodes };\n }\n return astFromValue(value, itemType);\n }\n\n // Populate the fields of the input object by creating ASTs from each value\n // in the JavaScript object according to the fields in the input type.\n if (isInputObjectType(type)) {\n if (!isObjectLike(value)) {\n return null;\n }\n const fieldNodes: Array = [];\n for (const field of Object.values(type.getFields())) {\n const fieldValue = astFromValue(value[field.name], field.type);\n if (fieldValue) {\n fieldNodes.push({\n kind: Kind.OBJECT_FIELD,\n name: { kind: Kind.NAME, value: field.name },\n value: fieldValue,\n });\n }\n }\n return { kind: Kind.OBJECT, fields: fieldNodes };\n }\n\n if (isLeafType(type)) {\n // Since value is an internally represented value, it must be coerced\n // to an externally represented value before converting into an AST.\n const coerced = type.coerceOutputValue(value);\n if (coerced == null) {\n return null;\n }\n\n // Others coerce based on their corresponding JavaScript scalar types.\n if (typeof coerced === 'boolean') {\n return { kind: Kind.BOOLEAN, value: coerced };\n }\n\n // JavaScript numbers can be Int or Float values.\n if (typeof coerced === 'number' && Number.isFinite(coerced)) {\n const stringNum = String(coerced);\n return integerStringRegExp.test(stringNum)\n ? { kind: Kind.INT, value: stringNum }\n : { kind: Kind.FLOAT, value: stringNum };\n }\n\n if (typeof coerced === 'string') {\n // Enum types use Enum literals.\n if (isEnumType(type)) {\n return { kind: Kind.ENUM, value: coerced };\n }\n\n // ID types can use Int literals.\n if (type === GraphQLID && integerStringRegExp.test(coerced)) {\n return { kind: Kind.INT, value: coerced };\n }\n\n return {\n kind: Kind.STRING,\n value: coerced,\n };\n }\n\n throw new TypeError(`Cannot convert value to AST: ${inspect(coerced)}.`);\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered.\n invariant(false, 'Unexpected input type: ' + inspect(type));\n}\n\n/**\n * IntValue:\n * - NegativeSign? 0\n * - NegativeSign? NonZeroDigit ( Digit+ )?\n */\nconst integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;\n"]} \ No newline at end of file diff --git a/utilities/buildASTSchema.d.ts b/utilities/buildASTSchema.d.ts new file mode 100644 index 0000000000..178456c398 --- /dev/null +++ b/utilities/buildASTSchema.d.ts @@ -0,0 +1,29 @@ +import type { DocumentNode } from '../language/ast.js'; +import type { ParseOptions } from '../language/parser.js'; +import type { Source } from '../language/source.js'; +import type { GraphQLSchemaValidationOptions } from '../type/schema.js'; +import { GraphQLSchema } from '../type/schema.js'; +export interface BuildSchemaOptions extends GraphQLSchemaValidationOptions { + /** + * Set to true to assume the SDL is valid. + * + * Default: false + */ + assumeValidSDL?: boolean | undefined; +} +/** + * This takes the ast of a schema document produced by the parse function in + * src/language/parser.js. + * + * If no schema definition is provided, then it will look for types named Query, + * Mutation and Subscription. + * + * Given that AST it constructs a GraphQLSchema. The resulting schema + * has no resolve methods, so execution will use default resolvers. + */ +export declare function buildASTSchema(documentAST: DocumentNode, options?: BuildSchemaOptions): GraphQLSchema; +/** + * A helper function to build a GraphQLSchema directly from a source + * document. + */ +export declare function buildSchema(source: string | Source, options?: BuildSchemaOptions & ParseOptions): GraphQLSchema; diff --git a/utilities/buildASTSchema.js b/utilities/buildASTSchema.js new file mode 100644 index 0000000000..ef75291227 --- /dev/null +++ b/utilities/buildASTSchema.js @@ -0,0 +1,75 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.buildASTSchema = buildASTSchema; +exports.buildSchema = buildSchema; +const parser_js_1 = require("../language/parser.js"); +const directives_js_1 = require("../type/directives.js"); +const schema_js_1 = require("../type/schema.js"); +const validate_js_1 = require("../validation/validate.js"); +const extendSchema_js_1 = require("./extendSchema.js"); +/** + * This takes the ast of a schema document produced by the parse function in + * src/language/parser.js. + * + * If no schema definition is provided, then it will look for types named Query, + * Mutation and Subscription. + * + * Given that AST it constructs a GraphQLSchema. The resulting schema + * has no resolve methods, so execution will use default resolvers. + */ +function buildASTSchema(documentAST, options) { + if (options?.assumeValid !== true && options?.assumeValidSDL !== true) { + (0, validate_js_1.assertValidSDL)(documentAST); + } + const emptySchemaConfig = { + description: undefined, + types: [], + directives: [], + extensions: Object.create(null), + extensionASTNodes: [], + assumeValid: false, + }; + const config = (0, extendSchema_js_1.extendSchemaImpl)(emptySchemaConfig, documentAST, options); + if (config.astNode == null) { + for (const type of config.types) { + switch (type.name) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + case 'Query': + // @ts-expect-error validated in `validateSchema` + config.query = type; + break; + case 'Mutation': + // @ts-expect-error validated in `validateSchema` + config.mutation = type; + break; + case 'Subscription': + // @ts-expect-error validated in `validateSchema` + config.subscription = type; + break; + } + } + } + const directives = [ + ...config.directives, + // If specified directives were not explicitly declared, add them. + ...directives_js_1.specifiedDirectives.filter((stdDirective) => config.directives.every((directive) => directive.name !== stdDirective.name)), + ]; + return new schema_js_1.GraphQLSchema({ ...config, directives }); +} +/** + * A helper function to build a GraphQLSchema directly from a source + * document. + */ +function buildSchema(source, options) { + const document = (0, parser_js_1.parse)(source, { + noLocation: options?.noLocation, + experimentalFragmentArguments: options?.experimentalFragmentArguments, + }); + return buildASTSchema(document, { + assumeValidSDL: options?.assumeValidSDL, + assumeValid: options?.assumeValid, + }); +} +//# sourceMappingURL=buildASTSchema.js.map \ No newline at end of file diff --git a/utilities/buildASTSchema.js.map b/utilities/buildASTSchema.js.map new file mode 100644 index 0000000000..758909338d --- /dev/null +++ b/utilities/buildASTSchema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buildASTSchema.js","sourceRoot":"","sources":["../../src/utilities/buildASTSchema.ts"],"names":[],"mappings":";;AAgCA,wCAmDC;AAMD,kCAaC;AApGD,qDAA8C;AAG9C,yDAA4D;AAE5D,iDAAkD;AAElD,2DAA2D;AAE3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AE,CAAC,SAAS,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CACpD,CACF;KACF,CAAC;IAEF,OAAO,IAAI,yBAAa,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,SAAgB,WAAW,CACzB,MAAuB,EACvB,OAA2C;IAE3C,MAAM,QAAQ,GAAG,IAAA,iBAAK,EAAC,MAAM,EAAE;QAC7B,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,6BAA6B,EAAE,OAAO,EAAE,6BAA6B;KACtE,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC,QAAQ,EAAE;QAC9B,cAAc,EAAE,OAAO,EAAE,cAAc;QACvC,WAAW,EAAE,OAAO,EAAE,WAAW;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { DocumentNode } from '../language/ast.js';\nimport type { ParseOptions } from '../language/parser.js';\nimport { parse } from '../language/parser.js';\nimport type { Source } from '../language/source.js';\n\nimport { specifiedDirectives } from '../type/directives.js';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.js';\nimport { GraphQLSchema } from '../type/schema.js';\n\nimport { assertValidSDL } from '../validation/validate.js';\n\nimport { extendSchemaImpl } from './extendSchema.js';\n\nexport interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {\n /**\n * Set to true to assume the SDL is valid.\n *\n * Default: false\n */\n assumeValidSDL?: boolean | undefined;\n}\n\n/**\n * This takes the ast of a schema document produced by the parse function in\n * src/language/parser.js.\n *\n * If no schema definition is provided, then it will look for types named Query,\n * Mutation and Subscription.\n *\n * Given that AST it constructs a GraphQLSchema. The resulting schema\n * has no resolve methods, so execution will use default resolvers.\n */\nexport function buildASTSchema(\n documentAST: DocumentNode,\n options?: BuildSchemaOptions,\n): GraphQLSchema {\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDL(documentAST);\n }\n\n const emptySchemaConfig = {\n description: undefined,\n types: [],\n directives: [],\n extensions: Object.create(null),\n extensionASTNodes: [],\n assumeValid: false,\n };\n const config = extendSchemaImpl(emptySchemaConfig, documentAST, options);\n\n if (config.astNode == null) {\n for (const type of config.types) {\n switch (type.name) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n case 'Query':\n // @ts-expect-error validated in `validateSchema`\n config.query = type;\n break;\n case 'Mutation':\n // @ts-expect-error validated in `validateSchema`\n config.mutation = type;\n break;\n case 'Subscription':\n // @ts-expect-error validated in `validateSchema`\n config.subscription = type;\n break;\n }\n }\n }\n\n const directives = [\n ...config.directives,\n // If specified directives were not explicitly declared, add them.\n ...specifiedDirectives.filter((stdDirective) =>\n config.directives.every(\n (directive) => directive.name !== stdDirective.name,\n ),\n ),\n ];\n\n return new GraphQLSchema({ ...config, directives });\n}\n\n/**\n * A helper function to build a GraphQLSchema directly from a source\n * document.\n */\nexport function buildSchema(\n source: string | Source,\n options?: BuildSchemaOptions & ParseOptions,\n): GraphQLSchema {\n const document = parse(source, {\n noLocation: options?.noLocation,\n experimentalFragmentArguments: options?.experimentalFragmentArguments,\n });\n\n return buildASTSchema(document, {\n assumeValidSDL: options?.assumeValidSDL,\n assumeValid: options?.assumeValid,\n });\n}\n"]} \ No newline at end of file diff --git a/utilities/buildASTSchema.mjs b/utilities/buildASTSchema.mjs new file mode 100644 index 0000000000..7371762245 --- /dev/null +++ b/utilities/buildASTSchema.mjs @@ -0,0 +1,71 @@ +import { parse } from "../language/parser.mjs"; +import { specifiedDirectives } from "../type/directives.mjs"; +import { GraphQLSchema } from "../type/schema.mjs"; +import { assertValidSDL } from "../validation/validate.mjs"; +import { extendSchemaImpl } from "./extendSchema.mjs"; +/** + * This takes the ast of a schema document produced by the parse function in + * src/language/parser.js. + * + * If no schema definition is provided, then it will look for types named Query, + * Mutation and Subscription. + * + * Given that AST it constructs a GraphQLSchema. The resulting schema + * has no resolve methods, so execution will use default resolvers. + */ +export function buildASTSchema(documentAST, options) { + if (options?.assumeValid !== true && options?.assumeValidSDL !== true) { + assertValidSDL(documentAST); + } + const emptySchemaConfig = { + description: undefined, + types: [], + directives: [], + extensions: Object.create(null), + extensionASTNodes: [], + assumeValid: false, + }; + const config = extendSchemaImpl(emptySchemaConfig, documentAST, options); + if (config.astNode == null) { + for (const type of config.types) { + switch (type.name) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + case 'Query': + // @ts-expect-error validated in `validateSchema` + config.query = type; + break; + case 'Mutation': + // @ts-expect-error validated in `validateSchema` + config.mutation = type; + break; + case 'Subscription': + // @ts-expect-error validated in `validateSchema` + config.subscription = type; + break; + } + } + } + const directives = [ + ...config.directives, + // If specified directives were not explicitly declared, add them. + ...specifiedDirectives.filter((stdDirective) => config.directives.every((directive) => directive.name !== stdDirective.name)), + ]; + return new GraphQLSchema({ ...config, directives }); +} +/** + * A helper function to build a GraphQLSchema directly from a source + * document. + */ +export function buildSchema(source, options) { + const document = parse(source, { + noLocation: options?.noLocation, + experimentalFragmentArguments: options?.experimentalFragmentArguments, + }); + return buildASTSchema(document, { + assumeValidSDL: options?.assumeValidSDL, + assumeValid: options?.assumeValid, + }); +} +//# sourceMappingURL=buildASTSchema.js.map \ No newline at end of file diff --git a/utilities/buildASTSchema.mjs.map b/utilities/buildASTSchema.mjs.map new file mode 100644 index 0000000000..cc7c751f03 --- /dev/null +++ b/utilities/buildASTSchema.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"buildASTSchema.js","sourceRoot":"","sources":["../../src/utilities/buildASTSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,+BAA8B;AAG9C,OAAO,EAAE,mBAAmB,EAAE,+BAA8B;AAE5D,OAAO,EAAE,aAAa,EAAE,2BAA0B;AAElD,OAAO,EAAE,cAAc,EAAE,mCAAkC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,2BAA0B;AAWrD;;;;;;;;;GASG;AACH,MAA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I,CACpD,CACF;KACF,CAAC;IAEF,OAAO,IAAI,aAAa,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,MAAuB,EACvB,OAA2C;IAE3C,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE;QAC7B,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,6BAA6B,EAAE,OAAO,EAAE,6BAA6B;KACtE,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC,QAAQ,EAAE;QAC9B,cAAc,EAAE,OAAO,EAAE,cAAc;QACvC,WAAW,EAAE,OAAO,EAAE,WAAW;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { DocumentNode } from '../language/ast.js';\nimport type { ParseOptions } from '../language/parser.js';\nimport { parse } from '../language/parser.js';\nimport type { Source } from '../language/source.js';\n\nimport { specifiedDirectives } from '../type/directives.js';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.js';\nimport { GraphQLSchema } from '../type/schema.js';\n\nimport { assertValidSDL } from '../validation/validate.js';\n\nimport { extendSchemaImpl } from './extendSchema.js';\n\nexport interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {\n /**\n * Set to true to assume the SDL is valid.\n *\n * Default: false\n */\n assumeValidSDL?: boolean | undefined;\n}\n\n/**\n * This takes the ast of a schema document produced by the parse function in\n * src/language/parser.js.\n *\n * If no schema definition is provided, then it will look for types named Query,\n * Mutation and Subscription.\n *\n * Given that AST it constructs a GraphQLSchema. The resulting schema\n * has no resolve methods, so execution will use default resolvers.\n */\nexport function buildASTSchema(\n documentAST: DocumentNode,\n options?: BuildSchemaOptions,\n): GraphQLSchema {\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDL(documentAST);\n }\n\n const emptySchemaConfig = {\n description: undefined,\n types: [],\n directives: [],\n extensions: Object.create(null),\n extensionASTNodes: [],\n assumeValid: false,\n };\n const config = extendSchemaImpl(emptySchemaConfig, documentAST, options);\n\n if (config.astNode == null) {\n for (const type of config.types) {\n switch (type.name) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n case 'Query':\n // @ts-expect-error validated in `validateSchema`\n config.query = type;\n break;\n case 'Mutation':\n // @ts-expect-error validated in `validateSchema`\n config.mutation = type;\n break;\n case 'Subscription':\n // @ts-expect-error validated in `validateSchema`\n config.subscription = type;\n break;\n }\n }\n }\n\n const directives = [\n ...config.directives,\n // If specified directives were not explicitly declared, add them.\n ...specifiedDirectives.filter((stdDirective) =>\n config.directives.every(\n (directive) => directive.name !== stdDirective.name,\n ),\n ),\n ];\n\n return new GraphQLSchema({ ...config, directives });\n}\n\n/**\n * A helper function to build a GraphQLSchema directly from a source\n * document.\n */\nexport function buildSchema(\n source: string | Source,\n options?: BuildSchemaOptions & ParseOptions,\n): GraphQLSchema {\n const document = parse(source, {\n noLocation: options?.noLocation,\n experimentalFragmentArguments: options?.experimentalFragmentArguments,\n });\n\n return buildASTSchema(document, {\n assumeValidSDL: options?.assumeValidSDL,\n assumeValid: options?.assumeValid,\n });\n}\n"]} \ No newline at end of file diff --git a/utilities/buildClientSchema.d.ts b/utilities/buildClientSchema.d.ts new file mode 100644 index 0000000000..75331bbb28 --- /dev/null +++ b/utilities/buildClientSchema.d.ts @@ -0,0 +1,16 @@ +import type { GraphQLSchemaValidationOptions } from '../type/schema.js'; +import { GraphQLSchema } from '../type/schema.js'; +import type { IntrospectionQuery } from './getIntrospectionQuery.js'; +/** + * Build a GraphQLSchema for use by client tools. + * + * Given the result of a client running the introspection query, creates and + * returns a GraphQLSchema instance which can be then used with all graphql-js + * tools, but cannot be used to execute a query, as introspection does not + * represent the "resolver", "coerceInputValue" or "coerceOutputValue" + * functions or any other server-internal mechanisms. + * + * This function expects a complete introspection result. Don't forget to check + * the "errors" field of a server response before calling this function. + */ +export declare function buildClientSchema(introspection: IntrospectionQuery, options?: GraphQLSchemaValidationOptions): GraphQLSchema; diff --git a/utilities/buildClientSchema.js b/utilities/buildClientSchema.js new file mode 100644 index 0000000000..3a75875996 --- /dev/null +++ b/utilities/buildClientSchema.js @@ -0,0 +1,258 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.buildClientSchema = buildClientSchema; +const devAssert_js_1 = require("../jsutils/devAssert.js"); +const inspect_js_1 = require("../jsutils/inspect.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const keyValMap_js_1 = require("../jsutils/keyValMap.js"); +const parser_js_1 = require("../language/parser.js"); +const definition_js_1 = require("../type/definition.js"); +const directives_js_1 = require("../type/directives.js"); +const introspection_js_1 = require("../type/introspection.js"); +const scalars_js_1 = require("../type/scalars.js"); +const schema_js_1 = require("../type/schema.js"); +/** + * Build a GraphQLSchema for use by client tools. + * + * Given the result of a client running the introspection query, creates and + * returns a GraphQLSchema instance which can be then used with all graphql-js + * tools, but cannot be used to execute a query, as introspection does not + * represent the "resolver", "coerceInputValue" or "coerceOutputValue" + * functions or any other server-internal mechanisms. + * + * This function expects a complete introspection result. Don't forget to check + * the "errors" field of a server response before calling this function. + */ +function buildClientSchema(introspection, options) { + // Even though the `introspection` argument is typed, in most cases it's received + // as an untyped value from the server, so we will do an additional check here. + ((0, isObjectLike_js_1.isObjectLike)(introspection) && (0, isObjectLike_js_1.isObjectLike)(introspection.__schema)) || (0, devAssert_js_1.devAssert)(false, `Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${(0, inspect_js_1.inspect)(introspection)}.`); + // Get the schema from the introspection result. + const schemaIntrospection = introspection.__schema; + // Iterate through all types, getting the type definition for each. + const typeMap = new Map(schemaIntrospection.types.map((typeIntrospection) => [ + typeIntrospection.name, + buildType(typeIntrospection), + ])); + // Include standard types only if they are used. + for (const stdType of [...scalars_js_1.specifiedScalarTypes, ...introspection_js_1.introspectionTypes]) { + if (typeMap.has(stdType.name)) { + typeMap.set(stdType.name, stdType); + } + } + // Get the root Query, Mutation, and Subscription types. + const queryType = schemaIntrospection.queryType != null + ? getObjectType(schemaIntrospection.queryType) + : null; + const mutationType = schemaIntrospection.mutationType != null + ? getObjectType(schemaIntrospection.mutationType) + : null; + const subscriptionType = schemaIntrospection.subscriptionType != null + ? getObjectType(schemaIntrospection.subscriptionType) + : null; + // Get the directives supported by Introspection, assuming empty-set if + // directives were not queried for. + const directives = schemaIntrospection.directives != null + ? schemaIntrospection.directives.map(buildDirective) + : []; + // Then produce and return a Schema with these types. + return new schema_js_1.GraphQLSchema({ + description: schemaIntrospection.description, + query: queryType, + mutation: mutationType, + subscription: subscriptionType, + types: [...typeMap.values()], + directives, + assumeValid: options?.assumeValid, + }); + // Given a type reference in introspection, return the GraphQLType instance. + // preferring cached instances before building new instances. + function getType(typeRef) { + if (typeRef.kind === introspection_js_1.TypeKind.LIST) { + const itemRef = typeRef.ofType; + if (itemRef == null) { + throw new Error('Decorated type deeper than introspection query.'); + } + return new definition_js_1.GraphQLList(getType(itemRef)); + } + if (typeRef.kind === introspection_js_1.TypeKind.NON_NULL) { + const nullableRef = typeRef.ofType; + if (nullableRef == null) { + throw new Error('Decorated type deeper than introspection query.'); + } + const nullableType = getType(nullableRef); + return new definition_js_1.GraphQLNonNull((0, definition_js_1.assertNullableType)(nullableType)); + } + return getNamedType(typeRef); + } + function getNamedType(typeRef) { + const typeName = typeRef.name; + if (!typeName) { + throw new Error(`Unknown type reference: ${(0, inspect_js_1.inspect)(typeRef)}.`); + } + const type = typeMap.get(typeName); + if (type == null) { + throw new Error(`Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`); + } + return type; + } + function getObjectType(typeRef) { + return (0, definition_js_1.assertObjectType)(getNamedType(typeRef)); + } + function getInterfaceType(typeRef) { + return (0, definition_js_1.assertInterfaceType)(getNamedType(typeRef)); + } + // Given a type's introspection result, construct the correct + // GraphQLType instance. + function buildType(type) { + switch (type.kind) { + case introspection_js_1.TypeKind.SCALAR: + return buildScalarDef(type); + case introspection_js_1.TypeKind.OBJECT: + return buildObjectDef(type); + case introspection_js_1.TypeKind.INTERFACE: + return buildInterfaceDef(type); + case introspection_js_1.TypeKind.UNION: + return buildUnionDef(type); + case introspection_js_1.TypeKind.ENUM: + return buildEnumDef(type); + case introspection_js_1.TypeKind.INPUT_OBJECT: + return buildInputObjectDef(type); + } + // Unreachable. + // @ts-expect-error + throw new Error(`Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${(0, inspect_js_1.inspect)(type)}.`); + } + function buildScalarDef(scalarIntrospection) { + return new definition_js_1.GraphQLScalarType({ + name: scalarIntrospection.name, + description: scalarIntrospection.description, + specifiedByURL: scalarIntrospection.specifiedByURL, + }); + } + function buildImplementationsList(implementingIntrospection) { + // TODO: Temporary workaround until GraphQL ecosystem will fully support + // 'interfaces' on interface types. + if (implementingIntrospection.interfaces === null && + implementingIntrospection.kind === introspection_js_1.TypeKind.INTERFACE) { + return []; + } + if (implementingIntrospection.interfaces == null) { + const implementingIntrospectionStr = (0, inspect_js_1.inspect)(implementingIntrospection); + throw new Error(`Introspection result missing interfaces: ${implementingIntrospectionStr}.`); + } + return implementingIntrospection.interfaces.map(getInterfaceType); + } + function buildObjectDef(objectIntrospection) { + return new definition_js_1.GraphQLObjectType({ + name: objectIntrospection.name, + description: objectIntrospection.description, + interfaces: () => buildImplementationsList(objectIntrospection), + fields: () => buildFieldDefMap(objectIntrospection), + }); + } + function buildInterfaceDef(interfaceIntrospection) { + return new definition_js_1.GraphQLInterfaceType({ + name: interfaceIntrospection.name, + description: interfaceIntrospection.description, + interfaces: () => buildImplementationsList(interfaceIntrospection), + fields: () => buildFieldDefMap(interfaceIntrospection), + }); + } + function buildUnionDef(unionIntrospection) { + if (unionIntrospection.possibleTypes == null) { + const unionIntrospectionStr = (0, inspect_js_1.inspect)(unionIntrospection); + throw new Error(`Introspection result missing possibleTypes: ${unionIntrospectionStr}.`); + } + return new definition_js_1.GraphQLUnionType({ + name: unionIntrospection.name, + description: unionIntrospection.description, + types: () => unionIntrospection.possibleTypes.map(getObjectType), + }); + } + function buildEnumDef(enumIntrospection) { + if (enumIntrospection.enumValues == null) { + const enumIntrospectionStr = (0, inspect_js_1.inspect)(enumIntrospection); + throw new Error(`Introspection result missing enumValues: ${enumIntrospectionStr}.`); + } + return new definition_js_1.GraphQLEnumType({ + name: enumIntrospection.name, + description: enumIntrospection.description, + values: (0, keyValMap_js_1.keyValMap)(enumIntrospection.enumValues, (valueIntrospection) => valueIntrospection.name, (valueIntrospection) => ({ + description: valueIntrospection.description, + deprecationReason: valueIntrospection.deprecationReason, + })), + }); + } + function buildInputObjectDef(inputObjectIntrospection) { + if (inputObjectIntrospection.inputFields == null) { + const inputObjectIntrospectionStr = (0, inspect_js_1.inspect)(inputObjectIntrospection); + throw new Error(`Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`); + } + return new definition_js_1.GraphQLInputObjectType({ + name: inputObjectIntrospection.name, + description: inputObjectIntrospection.description, + fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields), + isOneOf: inputObjectIntrospection.isOneOf, + }); + } + function buildFieldDefMap(typeIntrospection) { + if (typeIntrospection.fields == null) { + throw new Error(`Introspection result missing fields: ${(0, inspect_js_1.inspect)(typeIntrospection)}.`); + } + return (0, keyValMap_js_1.keyValMap)(typeIntrospection.fields, (fieldIntrospection) => fieldIntrospection.name, buildField); + } + function buildField(fieldIntrospection) { + const type = getType(fieldIntrospection.type); + if (!(0, definition_js_1.isOutputType)(type)) { + const typeStr = (0, inspect_js_1.inspect)(type); + throw new Error(`Introspection must provide output type for fields, but received: ${typeStr}.`); + } + if (fieldIntrospection.args == null) { + const fieldIntrospectionStr = (0, inspect_js_1.inspect)(fieldIntrospection); + throw new Error(`Introspection result missing field args: ${fieldIntrospectionStr}.`); + } + return { + description: fieldIntrospection.description, + deprecationReason: fieldIntrospection.deprecationReason, + type, + args: buildInputValueDefMap(fieldIntrospection.args), + }; + } + function buildInputValueDefMap(inputValueIntrospections) { + return (0, keyValMap_js_1.keyValMap)(inputValueIntrospections, (inputValue) => inputValue.name, buildInputValue); + } + function buildInputValue(inputValueIntrospection) { + const type = getType(inputValueIntrospection.type); + if (!(0, definition_js_1.isInputType)(type)) { + const typeStr = (0, inspect_js_1.inspect)(type); + throw new Error(`Introspection must provide input type for arguments, but received: ${typeStr}.`); + } + return { + description: inputValueIntrospection.description, + type, + default: inputValueIntrospection.defaultValue != null + ? { literal: (0, parser_js_1.parseConstValue)(inputValueIntrospection.defaultValue) } + : undefined, + deprecationReason: inputValueIntrospection.deprecationReason, + }; + } + function buildDirective(directiveIntrospection) { + if (directiveIntrospection.args == null) { + const directiveIntrospectionStr = (0, inspect_js_1.inspect)(directiveIntrospection); + throw new Error(`Introspection result missing directive args: ${directiveIntrospectionStr}.`); + } + if (directiveIntrospection.locations == null) { + const directiveIntrospectionStr = (0, inspect_js_1.inspect)(directiveIntrospection); + throw new Error(`Introspection result missing directive locations: ${directiveIntrospectionStr}.`); + } + return new directives_js_1.GraphQLDirective({ + name: directiveIntrospection.name, + description: directiveIntrospection.description, + isRepeatable: directiveIntrospection.isRepeatable, + locations: directiveIntrospection.locations.slice(), + args: buildInputValueDefMap(directiveIntrospection.args), + }); + } +} +//# sourceMappingURL=buildClientSchema.js.map \ No newline at end of file diff --git a/utilities/buildClientSchema.js.map b/utilities/buildClientSchema.js.map new file mode 100644 index 0000000000..3b69ecd478 --- /dev/null +++ b/utilities/buildClientSchema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buildClientSchema.js","sourceRoot":"","sources":["../../src/utilities/buildClientSchema.ts"],"names":[],"mappings":";;AA8DA,8CA2VC;AAzZD,0DAAoD;AACpD,sDAAgD;AAChD,gEAA0D;AAC1D,0DAAoD;AAEpD,qDAAwD;AAQxD,yDAc+B;AAC/B,yDAAyD;AACzD,+DAAwE;AACxE,mDAA0D;AAE1D,iDAAkD;AAkBlD;;;;;;;;;;;GAWG;AACH,SAAgB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M,yBAAyB,GAAG,IAAA,oBAAO,EAAC,sBAAsB,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,gDAAgD,yBAAyB,GAAG,CAC7E,CAAC;QACJ,CAAC;QACD,IAAI,sBAAsB,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7C,MAAM,yBAAyB,GAAG,IAAA,oBAAO,EAAC,sBAAsB,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,qDAAqD,yBAAyB,GAAG,CAClF,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,gCAAgB,CAAC;YAC1B,IAAI,EAAE,sBAAsB,CAAC,IAAI;YACjC,WAAW,EAAE,sBAAsB,CAAC,WAAW;YAC/C,YAAY,EAAE,sBAAsB,CAAC,YAAY;YACjD,SAAS,EAAE,sBAAsB,CAAC,SAAS,CAAC,KAAK,EAAE;YACnD,IAAI,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyValMap } from '../jsutils/keyValMap.js';\n\nimport { parseConstValue } from '../language/parser.js';\n\nimport type {\n GraphQLFieldConfig,\n GraphQLFieldConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.js';\nimport {\n assertInterfaceType,\n assertNullableType,\n assertObjectType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isInputType,\n isOutputType,\n} from '../type/definition.js';\nimport { GraphQLDirective } from '../type/directives.js';\nimport { introspectionTypes, TypeKind } from '../type/introspection.js';\nimport { specifiedScalarTypes } from '../type/scalars.js';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.js';\nimport { GraphQLSchema } from '../type/schema.js';\n\nimport type {\n IntrospectionDirective,\n IntrospectionEnumType,\n IntrospectionField,\n IntrospectionInputObjectType,\n IntrospectionInputValue,\n IntrospectionInterfaceType,\n IntrospectionNamedTypeRef,\n IntrospectionObjectType,\n IntrospectionQuery,\n IntrospectionScalarType,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionUnionType,\n} from './getIntrospectionQuery.js';\n\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"coerceInputValue\" or \"coerceOutputValue\"\n * functions or any other server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n */\nexport function buildClientSchema(\n introspection: IntrospectionQuery,\n options?: GraphQLSchemaValidationOptions,\n): GraphQLSchema {\n // Even though the `introspection` argument is typed, in most cases it's received\n // as an untyped value from the server, so we will do an additional check here.\n devAssert(\n isObjectLike(introspection) && isObjectLike(introspection.__schema),\n `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(\n introspection,\n )}.`,\n );\n\n // Get the schema from the introspection result.\n const schemaIntrospection = introspection.__schema;\n\n // Iterate through all types, getting the type definition for each.\n const typeMap = new Map(\n schemaIntrospection.types.map((typeIntrospection) => [\n typeIntrospection.name,\n buildType(typeIntrospection),\n ]),\n );\n\n // Include standard types only if they are used.\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap.has(stdType.name)) {\n typeMap.set(stdType.name, stdType);\n }\n }\n\n // Get the root Query, Mutation, and Subscription types.\n const queryType =\n schemaIntrospection.queryType != null\n ? getObjectType(schemaIntrospection.queryType)\n : null;\n\n const mutationType =\n schemaIntrospection.mutationType != null\n ? getObjectType(schemaIntrospection.mutationType)\n : null;\n\n const subscriptionType =\n schemaIntrospection.subscriptionType != null\n ? getObjectType(schemaIntrospection.subscriptionType)\n : null;\n\n // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n const directives =\n schemaIntrospection.directives != null\n ? schemaIntrospection.directives.map(buildDirective)\n : [];\n\n // Then produce and return a Schema with these types.\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: [...typeMap.values()],\n directives,\n assumeValid: options?.assumeValid,\n });\n\n // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n function getType(typeRef: IntrospectionTypeRef): GraphQLType {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n if (itemRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n return new GraphQLList(getType(itemRef));\n }\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n if (nullableRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef: IntrospectionNamedTypeRef): GraphQLNamedType {\n const typeName = typeRef.name;\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap.get(typeName);\n if (type == null) {\n throw new Error(\n `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`,\n );\n }\n\n return type;\n }\n\n function getObjectType(\n typeRef: IntrospectionNamedTypeRef,\n ): GraphQLObjectType {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(\n typeRef: IntrospectionNamedTypeRef,\n ): GraphQLInterfaceType {\n return assertInterfaceType(getNamedType(typeRef));\n }\n\n // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n function buildType(type: IntrospectionType): GraphQLNamedType {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n case TypeKind.UNION:\n return buildUnionDef(type);\n case TypeKind.ENUM:\n return buildEnumDef(type);\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n }\n // Unreachable.\n // @ts-expect-error\n throw new Error(\n `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${inspect(\n type,\n )}.`,\n );\n }\n\n function buildScalarDef(\n scalarIntrospection: IntrospectionScalarType,\n ): GraphQLScalarType {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByURL: scalarIntrospection.specifiedByURL,\n });\n }\n\n function buildImplementationsList(\n implementingIntrospection:\n | IntrospectionObjectType\n | IntrospectionInterfaceType,\n ): Array {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (\n implementingIntrospection.interfaces === null &&\n implementingIntrospection.kind === TypeKind.INTERFACE\n ) {\n return [];\n }\n\n if (implementingIntrospection.interfaces == null) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(\n `Introspection result missing interfaces: ${implementingIntrospectionStr}.`,\n );\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(\n objectIntrospection: IntrospectionObjectType,\n ): GraphQLObjectType {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection),\n });\n }\n\n function buildInterfaceDef(\n interfaceIntrospection: IntrospectionInterfaceType,\n ): GraphQLInterfaceType {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection),\n });\n }\n\n function buildUnionDef(\n unionIntrospection: IntrospectionUnionType,\n ): GraphQLUnionType {\n if (unionIntrospection.possibleTypes == null) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(\n `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`,\n );\n }\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType),\n });\n }\n\n function buildEnumDef(\n enumIntrospection: IntrospectionEnumType,\n ): GraphQLEnumType {\n if (enumIntrospection.enumValues == null) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(\n `Introspection result missing enumValues: ${enumIntrospectionStr}.`,\n );\n }\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(\n enumIntrospection.enumValues,\n (valueIntrospection) => valueIntrospection.name,\n (valueIntrospection) => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason,\n }),\n ),\n });\n }\n\n function buildInputObjectDef(\n inputObjectIntrospection: IntrospectionInputObjectType,\n ): GraphQLInputObjectType {\n if (inputObjectIntrospection.inputFields == null) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(\n `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`,\n );\n }\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields),\n isOneOf: inputObjectIntrospection.isOneOf,\n });\n }\n\n function buildFieldDefMap(\n typeIntrospection: IntrospectionObjectType | IntrospectionInterfaceType,\n ): GraphQLFieldConfigMap {\n if (typeIntrospection.fields == null) {\n throw new Error(\n `Introspection result missing fields: ${inspect(typeIntrospection)}.`,\n );\n }\n\n return keyValMap(\n typeIntrospection.fields,\n (fieldIntrospection) => fieldIntrospection.name,\n buildField,\n );\n }\n\n function buildField(\n fieldIntrospection: IntrospectionField,\n ): GraphQLFieldConfig {\n const type = getType(fieldIntrospection.type);\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide output type for fields, but received: ${typeStr}.`,\n );\n }\n\n if (fieldIntrospection.args == null) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(\n `Introspection result missing field args: ${fieldIntrospectionStr}.`,\n );\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args),\n };\n }\n\n function buildInputValueDefMap(\n inputValueIntrospections: ReadonlyArray,\n ) {\n return keyValMap(\n inputValueIntrospections,\n (inputValue) => inputValue.name,\n buildInputValue,\n );\n }\n\n function buildInputValue(inputValueIntrospection: IntrospectionInputValue) {\n const type = getType(inputValueIntrospection.type);\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide input type for arguments, but received: ${typeStr}.`,\n );\n }\n\n return {\n description: inputValueIntrospection.description,\n type,\n default:\n inputValueIntrospection.defaultValue != null\n ? { literal: parseConstValue(inputValueIntrospection.defaultValue) }\n : undefined,\n deprecationReason: inputValueIntrospection.deprecationReason,\n };\n }\n\n function buildDirective(\n directiveIntrospection: IntrospectionDirective,\n ): GraphQLDirective {\n if (directiveIntrospection.args == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive args: ${directiveIntrospectionStr}.`,\n );\n }\n if (directiveIntrospection.locations == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive locations: ${directiveIntrospectionStr}.`,\n );\n }\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args),\n });\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/buildClientSchema.mjs b/utilities/buildClientSchema.mjs new file mode 100644 index 0000000000..d82fc7a4d4 --- /dev/null +++ b/utilities/buildClientSchema.mjs @@ -0,0 +1,255 @@ +import { devAssert } from "../jsutils/devAssert.mjs"; +import { inspect } from "../jsutils/inspect.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { keyValMap } from "../jsutils/keyValMap.mjs"; +import { parseConstValue } from "../language/parser.mjs"; +import { assertInterfaceType, assertNullableType, assertObjectType, GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLUnionType, isInputType, isOutputType, } from "../type/definition.mjs"; +import { GraphQLDirective } from "../type/directives.mjs"; +import { introspectionTypes, TypeKind } from "../type/introspection.mjs"; +import { specifiedScalarTypes } from "../type/scalars.mjs"; +import { GraphQLSchema } from "../type/schema.mjs"; +/** + * Build a GraphQLSchema for use by client tools. + * + * Given the result of a client running the introspection query, creates and + * returns a GraphQLSchema instance which can be then used with all graphql-js + * tools, but cannot be used to execute a query, as introspection does not + * represent the "resolver", "coerceInputValue" or "coerceOutputValue" + * functions or any other server-internal mechanisms. + * + * This function expects a complete introspection result. Don't forget to check + * the "errors" field of a server response before calling this function. + */ +export function buildClientSchema(introspection, options) { + // Even though the `introspection` argument is typed, in most cases it's received + // as an untyped value from the server, so we will do an additional check here. + (isObjectLike(introspection) && isObjectLike(introspection.__schema)) || devAssert(false, `Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${inspect(introspection)}.`); + // Get the schema from the introspection result. + const schemaIntrospection = introspection.__schema; + // Iterate through all types, getting the type definition for each. + const typeMap = new Map(schemaIntrospection.types.map((typeIntrospection) => [ + typeIntrospection.name, + buildType(typeIntrospection), + ])); + // Include standard types only if they are used. + for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) { + if (typeMap.has(stdType.name)) { + typeMap.set(stdType.name, stdType); + } + } + // Get the root Query, Mutation, and Subscription types. + const queryType = schemaIntrospection.queryType != null + ? getObjectType(schemaIntrospection.queryType) + : null; + const mutationType = schemaIntrospection.mutationType != null + ? getObjectType(schemaIntrospection.mutationType) + : null; + const subscriptionType = schemaIntrospection.subscriptionType != null + ? getObjectType(schemaIntrospection.subscriptionType) + : null; + // Get the directives supported by Introspection, assuming empty-set if + // directives were not queried for. + const directives = schemaIntrospection.directives != null + ? schemaIntrospection.directives.map(buildDirective) + : []; + // Then produce and return a Schema with these types. + return new GraphQLSchema({ + description: schemaIntrospection.description, + query: queryType, + mutation: mutationType, + subscription: subscriptionType, + types: [...typeMap.values()], + directives, + assumeValid: options?.assumeValid, + }); + // Given a type reference in introspection, return the GraphQLType instance. + // preferring cached instances before building new instances. + function getType(typeRef) { + if (typeRef.kind === TypeKind.LIST) { + const itemRef = typeRef.ofType; + if (itemRef == null) { + throw new Error('Decorated type deeper than introspection query.'); + } + return new GraphQLList(getType(itemRef)); + } + if (typeRef.kind === TypeKind.NON_NULL) { + const nullableRef = typeRef.ofType; + if (nullableRef == null) { + throw new Error('Decorated type deeper than introspection query.'); + } + const nullableType = getType(nullableRef); + return new GraphQLNonNull(assertNullableType(nullableType)); + } + return getNamedType(typeRef); + } + function getNamedType(typeRef) { + const typeName = typeRef.name; + if (!typeName) { + throw new Error(`Unknown type reference: ${inspect(typeRef)}.`); + } + const type = typeMap.get(typeName); + if (type == null) { + throw new Error(`Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`); + } + return type; + } + function getObjectType(typeRef) { + return assertObjectType(getNamedType(typeRef)); + } + function getInterfaceType(typeRef) { + return assertInterfaceType(getNamedType(typeRef)); + } + // Given a type's introspection result, construct the correct + // GraphQLType instance. + function buildType(type) { + switch (type.kind) { + case TypeKind.SCALAR: + return buildScalarDef(type); + case TypeKind.OBJECT: + return buildObjectDef(type); + case TypeKind.INTERFACE: + return buildInterfaceDef(type); + case TypeKind.UNION: + return buildUnionDef(type); + case TypeKind.ENUM: + return buildEnumDef(type); + case TypeKind.INPUT_OBJECT: + return buildInputObjectDef(type); + } + // Unreachable. + // @ts-expect-error + throw new Error(`Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${inspect(type)}.`); + } + function buildScalarDef(scalarIntrospection) { + return new GraphQLScalarType({ + name: scalarIntrospection.name, + description: scalarIntrospection.description, + specifiedByURL: scalarIntrospection.specifiedByURL, + }); + } + function buildImplementationsList(implementingIntrospection) { + // TODO: Temporary workaround until GraphQL ecosystem will fully support + // 'interfaces' on interface types. + if (implementingIntrospection.interfaces === null && + implementingIntrospection.kind === TypeKind.INTERFACE) { + return []; + } + if (implementingIntrospection.interfaces == null) { + const implementingIntrospectionStr = inspect(implementingIntrospection); + throw new Error(`Introspection result missing interfaces: ${implementingIntrospectionStr}.`); + } + return implementingIntrospection.interfaces.map(getInterfaceType); + } + function buildObjectDef(objectIntrospection) { + return new GraphQLObjectType({ + name: objectIntrospection.name, + description: objectIntrospection.description, + interfaces: () => buildImplementationsList(objectIntrospection), + fields: () => buildFieldDefMap(objectIntrospection), + }); + } + function buildInterfaceDef(interfaceIntrospection) { + return new GraphQLInterfaceType({ + name: interfaceIntrospection.name, + description: interfaceIntrospection.description, + interfaces: () => buildImplementationsList(interfaceIntrospection), + fields: () => buildFieldDefMap(interfaceIntrospection), + }); + } + function buildUnionDef(unionIntrospection) { + if (unionIntrospection.possibleTypes == null) { + const unionIntrospectionStr = inspect(unionIntrospection); + throw new Error(`Introspection result missing possibleTypes: ${unionIntrospectionStr}.`); + } + return new GraphQLUnionType({ + name: unionIntrospection.name, + description: unionIntrospection.description, + types: () => unionIntrospection.possibleTypes.map(getObjectType), + }); + } + function buildEnumDef(enumIntrospection) { + if (enumIntrospection.enumValues == null) { + const enumIntrospectionStr = inspect(enumIntrospection); + throw new Error(`Introspection result missing enumValues: ${enumIntrospectionStr}.`); + } + return new GraphQLEnumType({ + name: enumIntrospection.name, + description: enumIntrospection.description, + values: keyValMap(enumIntrospection.enumValues, (valueIntrospection) => valueIntrospection.name, (valueIntrospection) => ({ + description: valueIntrospection.description, + deprecationReason: valueIntrospection.deprecationReason, + })), + }); + } + function buildInputObjectDef(inputObjectIntrospection) { + if (inputObjectIntrospection.inputFields == null) { + const inputObjectIntrospectionStr = inspect(inputObjectIntrospection); + throw new Error(`Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`); + } + return new GraphQLInputObjectType({ + name: inputObjectIntrospection.name, + description: inputObjectIntrospection.description, + fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields), + isOneOf: inputObjectIntrospection.isOneOf, + }); + } + function buildFieldDefMap(typeIntrospection) { + if (typeIntrospection.fields == null) { + throw new Error(`Introspection result missing fields: ${inspect(typeIntrospection)}.`); + } + return keyValMap(typeIntrospection.fields, (fieldIntrospection) => fieldIntrospection.name, buildField); + } + function buildField(fieldIntrospection) { + const type = getType(fieldIntrospection.type); + if (!isOutputType(type)) { + const typeStr = inspect(type); + throw new Error(`Introspection must provide output type for fields, but received: ${typeStr}.`); + } + if (fieldIntrospection.args == null) { + const fieldIntrospectionStr = inspect(fieldIntrospection); + throw new Error(`Introspection result missing field args: ${fieldIntrospectionStr}.`); + } + return { + description: fieldIntrospection.description, + deprecationReason: fieldIntrospection.deprecationReason, + type, + args: buildInputValueDefMap(fieldIntrospection.args), + }; + } + function buildInputValueDefMap(inputValueIntrospections) { + return keyValMap(inputValueIntrospections, (inputValue) => inputValue.name, buildInputValue); + } + function buildInputValue(inputValueIntrospection) { + const type = getType(inputValueIntrospection.type); + if (!isInputType(type)) { + const typeStr = inspect(type); + throw new Error(`Introspection must provide input type for arguments, but received: ${typeStr}.`); + } + return { + description: inputValueIntrospection.description, + type, + default: inputValueIntrospection.defaultValue != null + ? { literal: parseConstValue(inputValueIntrospection.defaultValue) } + : undefined, + deprecationReason: inputValueIntrospection.deprecationReason, + }; + } + function buildDirective(directiveIntrospection) { + if (directiveIntrospection.args == null) { + const directiveIntrospectionStr = inspect(directiveIntrospection); + throw new Error(`Introspection result missing directive args: ${directiveIntrospectionStr}.`); + } + if (directiveIntrospection.locations == null) { + const directiveIntrospectionStr = inspect(directiveIntrospection); + throw new Error(`Introspection result missing directive locations: ${directiveIntrospectionStr}.`); + } + return new GraphQLDirective({ + name: directiveIntrospection.name, + description: directiveIntrospection.description, + isRepeatable: directiveIntrospection.isRepeatable, + locations: directiveIntrospection.locations.slice(), + args: buildInputValueDefMap(directiveIntrospection.args), + }); + } +} +//# sourceMappingURL=buildClientSchema.js.map \ No newline at end of file diff --git a/utilities/buildClientSchema.mjs.map b/utilities/buildClientSchema.mjs.map new file mode 100644 index 0000000000..24944114da --- /dev/null +++ b/utilities/buildClientSchema.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"buildClientSchema.js","sourceRoot":"","sources":["../../src/utilities/buildClientSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAEpD,OAAO,EAAE,eAAe,EAAE,+BAA8B;AAQxD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,+BAA8B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,+BAA8B;AACzD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,kCAAiC;AACxE,OAAO,EAAE,oBAAoB,EAAE,4BAA2B;AAE1D,OAAO,EAAE,aAAa,EAAE,2BAA0B;AAkBlD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAC/B,aAAiC,EACjC,OAAwC;IAExC,iFAAiF;IACjF,+EAA+E;IAC/E,CACE,YAAY,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,KADrE,SAAS,QAEP,6JAA6J,OAAO,CAClK,aAAa,CACd,GAAG,EACJ;IAEF,gDAAgD;IAChD,MAAM,mBAAm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sB,CAAC,WAAW;YAC/C,YAAY,EAAE,sBAAsB,CAAC,YAAY;YACjD,SAAS,EAAE,sBAAsB,CAAC,SAAS,CAAC,KAAK,EAAE;YACnD,IAAI,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyValMap } from '../jsutils/keyValMap.js';\n\nimport { parseConstValue } from '../language/parser.js';\n\nimport type {\n GraphQLFieldConfig,\n GraphQLFieldConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.js';\nimport {\n assertInterfaceType,\n assertNullableType,\n assertObjectType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isInputType,\n isOutputType,\n} from '../type/definition.js';\nimport { GraphQLDirective } from '../type/directives.js';\nimport { introspectionTypes, TypeKind } from '../type/introspection.js';\nimport { specifiedScalarTypes } from '../type/scalars.js';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.js';\nimport { GraphQLSchema } from '../type/schema.js';\n\nimport type {\n IntrospectionDirective,\n IntrospectionEnumType,\n IntrospectionField,\n IntrospectionInputObjectType,\n IntrospectionInputValue,\n IntrospectionInterfaceType,\n IntrospectionNamedTypeRef,\n IntrospectionObjectType,\n IntrospectionQuery,\n IntrospectionScalarType,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionUnionType,\n} from './getIntrospectionQuery.js';\n\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"coerceInputValue\" or \"coerceOutputValue\"\n * functions or any other server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n */\nexport function buildClientSchema(\n introspection: IntrospectionQuery,\n options?: GraphQLSchemaValidationOptions,\n): GraphQLSchema {\n // Even though the `introspection` argument is typed, in most cases it's received\n // as an untyped value from the server, so we will do an additional check here.\n devAssert(\n isObjectLike(introspection) && isObjectLike(introspection.__schema),\n `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(\n introspection,\n )}.`,\n );\n\n // Get the schema from the introspection result.\n const schemaIntrospection = introspection.__schema;\n\n // Iterate through all types, getting the type definition for each.\n const typeMap = new Map(\n schemaIntrospection.types.map((typeIntrospection) => [\n typeIntrospection.name,\n buildType(typeIntrospection),\n ]),\n );\n\n // Include standard types only if they are used.\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap.has(stdType.name)) {\n typeMap.set(stdType.name, stdType);\n }\n }\n\n // Get the root Query, Mutation, and Subscription types.\n const queryType =\n schemaIntrospection.queryType != null\n ? getObjectType(schemaIntrospection.queryType)\n : null;\n\n const mutationType =\n schemaIntrospection.mutationType != null\n ? getObjectType(schemaIntrospection.mutationType)\n : null;\n\n const subscriptionType =\n schemaIntrospection.subscriptionType != null\n ? getObjectType(schemaIntrospection.subscriptionType)\n : null;\n\n // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n const directives =\n schemaIntrospection.directives != null\n ? schemaIntrospection.directives.map(buildDirective)\n : [];\n\n // Then produce and return a Schema with these types.\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: [...typeMap.values()],\n directives,\n assumeValid: options?.assumeValid,\n });\n\n // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n function getType(typeRef: IntrospectionTypeRef): GraphQLType {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n if (itemRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n return new GraphQLList(getType(itemRef));\n }\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n if (nullableRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef: IntrospectionNamedTypeRef): GraphQLNamedType {\n const typeName = typeRef.name;\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap.get(typeName);\n if (type == null) {\n throw new Error(\n `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`,\n );\n }\n\n return type;\n }\n\n function getObjectType(\n typeRef: IntrospectionNamedTypeRef,\n ): GraphQLObjectType {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(\n typeRef: IntrospectionNamedTypeRef,\n ): GraphQLInterfaceType {\n return assertInterfaceType(getNamedType(typeRef));\n }\n\n // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n function buildType(type: IntrospectionType): GraphQLNamedType {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n case TypeKind.UNION:\n return buildUnionDef(type);\n case TypeKind.ENUM:\n return buildEnumDef(type);\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n }\n // Unreachable.\n // @ts-expect-error\n throw new Error(\n `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${inspect(\n type,\n )}.`,\n );\n }\n\n function buildScalarDef(\n scalarIntrospection: IntrospectionScalarType,\n ): GraphQLScalarType {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByURL: scalarIntrospection.specifiedByURL,\n });\n }\n\n function buildImplementationsList(\n implementingIntrospection:\n | IntrospectionObjectType\n | IntrospectionInterfaceType,\n ): Array {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (\n implementingIntrospection.interfaces === null &&\n implementingIntrospection.kind === TypeKind.INTERFACE\n ) {\n return [];\n }\n\n if (implementingIntrospection.interfaces == null) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(\n `Introspection result missing interfaces: ${implementingIntrospectionStr}.`,\n );\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(\n objectIntrospection: IntrospectionObjectType,\n ): GraphQLObjectType {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection),\n });\n }\n\n function buildInterfaceDef(\n interfaceIntrospection: IntrospectionInterfaceType,\n ): GraphQLInterfaceType {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection),\n });\n }\n\n function buildUnionDef(\n unionIntrospection: IntrospectionUnionType,\n ): GraphQLUnionType {\n if (unionIntrospection.possibleTypes == null) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(\n `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`,\n );\n }\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType),\n });\n }\n\n function buildEnumDef(\n enumIntrospection: IntrospectionEnumType,\n ): GraphQLEnumType {\n if (enumIntrospection.enumValues == null) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(\n `Introspection result missing enumValues: ${enumIntrospectionStr}.`,\n );\n }\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(\n enumIntrospection.enumValues,\n (valueIntrospection) => valueIntrospection.name,\n (valueIntrospection) => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason,\n }),\n ),\n });\n }\n\n function buildInputObjectDef(\n inputObjectIntrospection: IntrospectionInputObjectType,\n ): GraphQLInputObjectType {\n if (inputObjectIntrospection.inputFields == null) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(\n `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`,\n );\n }\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields),\n isOneOf: inputObjectIntrospection.isOneOf,\n });\n }\n\n function buildFieldDefMap(\n typeIntrospection: IntrospectionObjectType | IntrospectionInterfaceType,\n ): GraphQLFieldConfigMap {\n if (typeIntrospection.fields == null) {\n throw new Error(\n `Introspection result missing fields: ${inspect(typeIntrospection)}.`,\n );\n }\n\n return keyValMap(\n typeIntrospection.fields,\n (fieldIntrospection) => fieldIntrospection.name,\n buildField,\n );\n }\n\n function buildField(\n fieldIntrospection: IntrospectionField,\n ): GraphQLFieldConfig {\n const type = getType(fieldIntrospection.type);\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide output type for fields, but received: ${typeStr}.`,\n );\n }\n\n if (fieldIntrospection.args == null) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(\n `Introspection result missing field args: ${fieldIntrospectionStr}.`,\n );\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args),\n };\n }\n\n function buildInputValueDefMap(\n inputValueIntrospections: ReadonlyArray,\n ) {\n return keyValMap(\n inputValueIntrospections,\n (inputValue) => inputValue.name,\n buildInputValue,\n );\n }\n\n function buildInputValue(inputValueIntrospection: IntrospectionInputValue) {\n const type = getType(inputValueIntrospection.type);\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide input type for arguments, but received: ${typeStr}.`,\n );\n }\n\n return {\n description: inputValueIntrospection.description,\n type,\n default:\n inputValueIntrospection.defaultValue != null\n ? { literal: parseConstValue(inputValueIntrospection.defaultValue) }\n : undefined,\n deprecationReason: inputValueIntrospection.deprecationReason,\n };\n }\n\n function buildDirective(\n directiveIntrospection: IntrospectionDirective,\n ): GraphQLDirective {\n if (directiveIntrospection.args == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive args: ${directiveIntrospectionStr}.`,\n );\n }\n if (directiveIntrospection.locations == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive locations: ${directiveIntrospectionStr}.`,\n );\n }\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args),\n });\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/coerceInputValue.d.ts b/utilities/coerceInputValue.d.ts new file mode 100644 index 0000000000..219b56e4bd --- /dev/null +++ b/utilities/coerceInputValue.d.ts @@ -0,0 +1,29 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ValueNode } from '../language/ast.js'; +import type { GraphQLDefaultInput, GraphQLInputType } from '../type/definition.js'; +import type { FragmentVariableValues } from '../execution/collectFields.js'; +import type { VariableValues } from '../execution/values.js'; +/** + * Coerces a JavaScript value given a GraphQL Input Type. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + */ +export declare function coerceInputValue(inputValue: unknown, type: GraphQLInputType): unknown; +/** + * Produces a coerced "internal" JavaScript value given a GraphQL Value AST. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + */ +export declare function coerceInputLiteral(valueNode: ValueNode, type: GraphQLInputType, variableValues?: Maybe, fragmentVariableValues?: Maybe): unknown; +interface InputValue { + type: GraphQLInputType; + default?: GraphQLDefaultInput | undefined; + defaultValue?: unknown; +} +/** + * @internal + */ +export declare function coerceDefaultValue(inputValue: InputValue): unknown; +export {}; diff --git a/utilities/coerceInputValue.js b/utilities/coerceInputValue.js new file mode 100644 index 0000000000..0c9de5d5d4 --- /dev/null +++ b/utilities/coerceInputValue.js @@ -0,0 +1,234 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.coerceInputValue = coerceInputValue; +exports.coerceInputLiteral = coerceInputLiteral; +exports.coerceDefaultValue = coerceDefaultValue; +const invariant_js_1 = require("../jsutils/invariant.js"); +const isIterableObject_js_1 = require("../jsutils/isIterableObject.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +const replaceVariables_js_1 = require("./replaceVariables.js"); +/** + * Coerces a JavaScript value given a GraphQL Input Type. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + */ +function coerceInputValue(inputValue, type) { + if ((0, definition_js_1.isNonNullType)(type)) { + if (inputValue == null) { + return; // Invalid: intentionally return no value. + } + return coerceInputValue(inputValue, type.ofType); + } + if (inputValue == null) { + return null; // Explicitly return the value null. + } + if ((0, definition_js_1.isListType)(type)) { + if (!(0, isIterableObject_js_1.isIterableObject)(inputValue)) { + // Lists accept a non-list value as a list of one. + const coercedItem = coerceInputValue(inputValue, type.ofType); + if (coercedItem === undefined) { + return; // Invalid: intentionally return no value. + } + return [coercedItem]; + } + const coercedValue = []; + for (const itemValue of inputValue) { + const coercedItem = coerceInputValue(itemValue, type.ofType); + if (coercedItem === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValue.push(coercedItem); + } + return coercedValue; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + if (!(0, isObjectLike_js_1.isObjectLike)(inputValue)) { + return; // Invalid: intentionally return no value. + } + const coercedValue = {}; + const fieldDefs = type.getFields(); + const hasUndefinedField = Object.keys(inputValue).some((name) => !Object.hasOwn(fieldDefs, name)); + if (hasUndefinedField) { + return; // Invalid: intentionally return no value. + } + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; + if (fieldValue === undefined) { + if ((0, definition_js_1.isRequiredInputField)(field)) { + return; // Invalid: intentionally return no value. + } + const coercedDefaultValue = coerceDefaultValue(field); + if (coercedDefaultValue !== undefined) { + coercedValue[field.name] = coercedDefaultValue; + } + } + else { + const coercedField = coerceInputValue(fieldValue, field.type); + if (coercedField === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValue[field.name] = coercedField; + } + } + if (type.isOneOf) { + const keys = Object.keys(coercedValue); + if (keys.length !== 1) { + return; // Invalid: intentionally return no value. + } + const key = keys[0]; + const value = coercedValue[key]; + if (value === null) { + return; // Invalid: intentionally return no value. + } + } + return coercedValue; + } + const leafType = (0, definition_js_1.assertLeafType)(type); + try { + return leafType.coerceInputValue(inputValue); + } + catch (_error) { + // Invalid: ignore error and intentionally return no value. + } +} +/** + * Produces a coerced "internal" JavaScript value given a GraphQL Value AST. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + */ +function coerceInputLiteral(valueNode, type, variableValues, fragmentVariableValues) { + if (valueNode.kind === kinds_js_1.Kind.VARIABLE) { + const coercedVariableValue = getCoercedVariableValue(valueNode, variableValues, fragmentVariableValues); + if (coercedVariableValue == null && (0, definition_js_1.isNonNullType)(type)) { + return; // Invalid: intentionally return no value. + } + // Note: This does no further checking that this variable is correct. + // This assumes validated has checked this variable is of the correct type. + return coercedVariableValue; + } + if ((0, definition_js_1.isNonNullType)(type)) { + if (valueNode.kind === kinds_js_1.Kind.NULL) { + return; // Invalid: intentionally return no value. + } + return coerceInputLiteral(valueNode, type.ofType, variableValues, fragmentVariableValues); + } + if (valueNode.kind === kinds_js_1.Kind.NULL) { + return null; // Explicitly return the value null. + } + if ((0, definition_js_1.isListType)(type)) { + if (valueNode.kind !== kinds_js_1.Kind.LIST) { + // Lists accept a non-list value as a list of one. + const itemValue = coerceInputLiteral(valueNode, type.ofType, variableValues, fragmentVariableValues); + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + return [itemValue]; + } + const coercedValue = []; + for (const itemNode of valueNode.values) { + let itemValue = coerceInputLiteral(itemNode, type.ofType, variableValues, fragmentVariableValues); + if (itemValue === undefined) { + if (itemNode.kind === kinds_js_1.Kind.VARIABLE && + getCoercedVariableValue(itemNode, variableValues, fragmentVariableValues) == null && + !(0, definition_js_1.isNonNullType)(type.ofType)) { + // A missing variable within a list is coerced to null. + itemValue = null; + } + else { + return; // Invalid: intentionally return no value. + } + } + coercedValue.push(itemValue); + } + return coercedValue; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + if (valueNode.kind !== kinds_js_1.Kind.OBJECT) { + return; // Invalid: intentionally return no value. + } + const coercedValue = {}; + const fieldDefs = type.getFields(); + const hasUndefinedField = valueNode.fields.some((field) => !Object.hasOwn(fieldDefs, field.name.value)); + if (hasUndefinedField) { + return; // Invalid: intentionally return no value. + } + const fieldNodes = new Map(valueNode.fields.map((field) => [field.name.value, field])); + for (const field of Object.values(fieldDefs)) { + const fieldNode = fieldNodes.get(field.name); + if (!fieldNode || + (fieldNode.value.kind === kinds_js_1.Kind.VARIABLE && + getCoercedVariableValue(fieldNode.value, variableValues, fragmentVariableValues) == null)) { + if ((0, definition_js_1.isRequiredInputField)(field)) { + return; // Invalid: intentionally return no value. + } + const coercedDefaultValue = coerceDefaultValue(field); + if (coercedDefaultValue !== undefined) { + coercedValue[field.name] = coercedDefaultValue; + } + } + else { + const fieldValue = coerceInputLiteral(fieldNode.value, field.type, variableValues, fragmentVariableValues); + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValue[field.name] = fieldValue; + } + } + if (type.isOneOf) { + const keys = Object.keys(coercedValue); + if (keys.length !== 1) { + return; // Invalid: not exactly one key, intentionally return no value. + } + if (coercedValue[keys[0]] === null) { + return; // Invalid: value not non-null, intentionally return no value. + } + } + return coercedValue; + } + const leafType = (0, definition_js_1.assertLeafType)(type); + try { + return leafType.coerceInputLiteral + ? leafType.coerceInputLiteral((0, replaceVariables_js_1.replaceVariables)(valueNode, variableValues, fragmentVariableValues)) + : leafType.parseLiteral(valueNode, variableValues?.coerced); + } + catch (_error) { + // Invalid: ignore error and intentionally return no value. + } +} +// Retrieves the variable value for the given variable node. +function getCoercedVariableValue(variableNode, variableValues, fragmentVariableValues) { + const varName = variableNode.name.value; + if (fragmentVariableValues?.sources[varName] !== undefined) { + return fragmentVariableValues.coerced[varName]; + } + return variableValues?.coerced[varName]; +} +/** + * @internal + */ +function coerceDefaultValue(inputValue) { + // Memoize the result of coercing the default value in a hidden field. + let coercedDefaultValue = inputValue._memoizedCoercedDefaultValue; + if (coercedDefaultValue !== undefined) { + return coercedDefaultValue; + } + const defaultInput = inputValue.default; + if (defaultInput !== undefined) { + coercedDefaultValue = defaultInput.literal + ? coerceInputLiteral(defaultInput.literal, inputValue.type) + : coerceInputValue(defaultInput.value, inputValue.type); + (coercedDefaultValue !== undefined) || (0, invariant_js_1.invariant)(false); + inputValue._memoizedCoercedDefaultValue = coercedDefaultValue; + return coercedDefaultValue; + } + const defaultValue = inputValue.defaultValue; + if (defaultValue !== undefined) { + inputValue._memoizedCoercedDefaultValue = defaultValue; + } + return defaultValue; +} +//# sourceMappingURL=coerceInputValue.js.map \ No newline at end of file diff --git a/utilities/coerceInputValue.js.map b/utilities/coerceInputValue.js.map new file mode 100644 index 0000000000..f5ed2358c5 --- /dev/null +++ b/utilities/coerceInputValue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"coerceInputValue.js","sourceRoot":"","sources":["../../src/utilities/coerceInputValue.ts"],"names":[],"mappings":";;AA+BA,4CA0FC;AAQD,gDAuJC;AAyBD,gDAsBC;AAvUD,0DAAoD;AACpD,wEAAkE;AAClE,gEAA0D;AAI1D,mDAA4C;AAM5C,yDAM+B;AAK/B,+DAAyD;AAEzD;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC9B,UAAmB,EACnB,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cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC;AAQD;;GAEG;AACH,SAAgB,kBAAkB,CAAC,UAAsB;IACvD,sEAAsE;IACtE,IAAI,mBAAmB,GAAI,UAAkB,CAAC,4BAA4B,CAAC;IAC3E,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC;IACxC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,mBAAmB,GAAG,YAAY,CAAC,OAAO;YACxC,CAAC,CAAC,kBAAkB,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC;YAC3D,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1D,CAAU,mBAAmB,KAAK,SAAS,SAA3C,wBAAS,SAAoC;QAC5C,UAAkB,CAAC,4BAA4B,GAAG,mBAAmB,CAAC;QACvE,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IAC7C,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC9B,UAAkB,CAAC,4BAA4B,GAAG,YAAY,CAAC;IAClE,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ValueNode, VariableNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type {\n GraphQLDefaultInput,\n GraphQLInputType,\n} from '../type/definition.js';\nimport {\n assertLeafType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isRequiredInputField,\n} from '../type/definition.js';\n\nimport type { FragmentVariableValues } from '../execution/collectFields.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { replaceVariables } from './replaceVariables.js';\n\n/**\n * Coerces a JavaScript value given a GraphQL Input Type.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n */\nexport function coerceInputValue(\n inputValue: unknown,\n type: GraphQLInputType,\n): unknown {\n if (isNonNullType(type)) {\n if (inputValue == null) {\n return; // Invalid: intentionally return no value.\n }\n return coerceInputValue(inputValue, type.ofType);\n }\n\n if (inputValue == null) {\n return null; // Explicitly return the value null.\n }\n\n if (isListType(type)) {\n if (!isIterableObject(inputValue)) {\n // Lists accept a non-list value as a list of one.\n const coercedItem = coerceInputValue(inputValue, type.ofType);\n if (coercedItem === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return [coercedItem];\n }\n const coercedValue = [];\n for (const itemValue of inputValue) {\n const coercedItem = coerceInputValue(itemValue, type.ofType);\n if (coercedItem === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValue.push(coercedItem);\n }\n return coercedValue;\n }\n\n if (isInputObjectType(type)) {\n if (!isObjectLike(inputValue)) {\n return; // Invalid: intentionally return no value.\n }\n\n const coercedValue: any = {};\n const fieldDefs = type.getFields();\n const hasUndefinedField = Object.keys(inputValue).some(\n (name) => !Object.hasOwn(fieldDefs, name),\n );\n if (hasUndefinedField) {\n return; // Invalid: intentionally return no value.\n }\n for (const field of Object.values(fieldDefs)) {\n const fieldValue = inputValue[field.name];\n if (fieldValue === undefined) {\n if (isRequiredInputField(field)) {\n return; // Invalid: intentionally return no value.\n }\n const coercedDefaultValue = coerceDefaultValue(field);\n if (coercedDefaultValue !== undefined) {\n coercedValue[field.name] = coercedDefaultValue;\n }\n } else {\n const coercedField = coerceInputValue(fieldValue, field.type);\n if (coercedField === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValue[field.name] = coercedField;\n }\n }\n\n if (type.isOneOf) {\n const keys = Object.keys(coercedValue);\n if (keys.length !== 1) {\n return; // Invalid: intentionally return no value.\n }\n\n const key = keys[0];\n const value = coercedValue[key];\n if (value === null) {\n return; // Invalid: intentionally return no value.\n }\n }\n\n return coercedValue;\n }\n\n const leafType = assertLeafType(type);\n\n try {\n return leafType.coerceInputValue(inputValue);\n } catch (_error) {\n // Invalid: ignore error and intentionally return no value.\n }\n}\n\n/**\n * Produces a coerced \"internal\" JavaScript value given a GraphQL Value AST.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n */\nexport function coerceInputLiteral(\n valueNode: ValueNode,\n type: GraphQLInputType,\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n): unknown {\n if (valueNode.kind === Kind.VARIABLE) {\n const coercedVariableValue = getCoercedVariableValue(\n valueNode,\n variableValues,\n fragmentVariableValues,\n );\n if (coercedVariableValue == null && isNonNullType(type)) {\n return; // Invalid: intentionally return no value.\n }\n // Note: This does no further checking that this variable is correct.\n // This assumes validated has checked this variable is of the correct type.\n return coercedVariableValue;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n return coerceInputLiteral(\n valueNode,\n type.ofType,\n variableValues,\n fragmentVariableValues,\n );\n }\n\n if (valueNode.kind === Kind.NULL) {\n return null; // Explicitly return the value null.\n }\n\n if (isListType(type)) {\n if (valueNode.kind !== Kind.LIST) {\n // Lists accept a non-list value as a list of one.\n const itemValue = coerceInputLiteral(\n valueNode,\n type.ofType,\n variableValues,\n fragmentVariableValues,\n );\n if (itemValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return [itemValue];\n }\n const coercedValue: Array = [];\n for (const itemNode of valueNode.values) {\n let itemValue = coerceInputLiteral(\n itemNode,\n type.ofType,\n variableValues,\n fragmentVariableValues,\n );\n if (itemValue === undefined) {\n if (\n itemNode.kind === Kind.VARIABLE &&\n getCoercedVariableValue(\n itemNode,\n variableValues,\n fragmentVariableValues,\n ) == null &&\n !isNonNullType(type.ofType)\n ) {\n // A missing variable within a list is coerced to null.\n itemValue = null;\n } else {\n return; // Invalid: intentionally return no value.\n }\n }\n coercedValue.push(itemValue);\n }\n return coercedValue;\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n\n const coercedValue: { [field: string]: unknown } = {};\n const fieldDefs = type.getFields();\n const hasUndefinedField = valueNode.fields.some(\n (field) => !Object.hasOwn(fieldDefs, field.name.value),\n );\n if (hasUndefinedField) {\n return; // Invalid: intentionally return no value.\n }\n const fieldNodes = new Map(\n valueNode.fields.map((field) => [field.name.value, field]),\n );\n for (const field of Object.values(fieldDefs)) {\n const fieldNode = fieldNodes.get(field.name);\n if (\n !fieldNode ||\n (fieldNode.value.kind === Kind.VARIABLE &&\n getCoercedVariableValue(\n fieldNode.value,\n variableValues,\n fragmentVariableValues,\n ) == null)\n ) {\n if (isRequiredInputField(field)) {\n return; // Invalid: intentionally return no value.\n }\n const coercedDefaultValue = coerceDefaultValue(field);\n if (coercedDefaultValue !== undefined) {\n coercedValue[field.name] = coercedDefaultValue;\n }\n } else {\n const fieldValue = coerceInputLiteral(\n fieldNode.value,\n field.type,\n variableValues,\n fragmentVariableValues,\n );\n if (fieldValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValue[field.name] = fieldValue;\n }\n }\n\n if (type.isOneOf) {\n const keys = Object.keys(coercedValue);\n if (keys.length !== 1) {\n return; // Invalid: not exactly one key, intentionally return no value.\n }\n\n if (coercedValue[keys[0]] === null) {\n return; // Invalid: value not non-null, intentionally return no value.\n }\n }\n\n return coercedValue;\n }\n\n const leafType = assertLeafType(type);\n try {\n return leafType.coerceInputLiteral\n ? leafType.coerceInputLiteral(\n replaceVariables(valueNode, variableValues, fragmentVariableValues),\n )\n : leafType.parseLiteral(valueNode, variableValues?.coerced);\n } catch (_error) {\n // Invalid: ignore error and intentionally return no value.\n }\n}\n\n// Retrieves the variable value for the given variable node.\nfunction getCoercedVariableValue(\n variableNode: VariableNode,\n variableValues: Maybe,\n fragmentVariableValues: Maybe,\n): unknown {\n const varName = variableNode.name.value;\n if (fragmentVariableValues?.sources[varName] !== undefined) {\n return fragmentVariableValues.coerced[varName];\n }\n\n return variableValues?.coerced[varName];\n}\n\ninterface InputValue {\n type: GraphQLInputType;\n default?: GraphQLDefaultInput | undefined;\n defaultValue?: unknown;\n}\n\n/**\n * @internal\n */\nexport function coerceDefaultValue(inputValue: InputValue): unknown {\n // Memoize the result of coercing the default value in a hidden field.\n let coercedDefaultValue = (inputValue as any)._memoizedCoercedDefaultValue;\n if (coercedDefaultValue !== undefined) {\n return coercedDefaultValue;\n }\n\n const defaultInput = inputValue.default;\n if (defaultInput !== undefined) {\n coercedDefaultValue = defaultInput.literal\n ? coerceInputLiteral(defaultInput.literal, inputValue.type)\n : coerceInputValue(defaultInput.value, inputValue.type);\n invariant(coercedDefaultValue !== undefined);\n (inputValue as any)._memoizedCoercedDefaultValue = coercedDefaultValue;\n return coercedDefaultValue;\n }\n\n const defaultValue = inputValue.defaultValue;\n if (defaultValue !== undefined) {\n (inputValue as any)._memoizedCoercedDefaultValue = defaultValue;\n }\n return defaultValue;\n}\n"]} \ No newline at end of file diff --git a/utilities/coerceInputValue.mjs b/utilities/coerceInputValue.mjs new file mode 100644 index 0000000000..1e82f0e7c8 --- /dev/null +++ b/utilities/coerceInputValue.mjs @@ -0,0 +1,229 @@ +import { invariant } from "../jsutils/invariant.mjs"; +import { isIterableObject } from "../jsutils/isIterableObject.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { assertLeafType, isInputObjectType, isListType, isNonNullType, isRequiredInputField, } from "../type/definition.mjs"; +import { replaceVariables } from "./replaceVariables.mjs"; +/** + * Coerces a JavaScript value given a GraphQL Input Type. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + */ +export function coerceInputValue(inputValue, type) { + if (isNonNullType(type)) { + if (inputValue == null) { + return; // Invalid: intentionally return no value. + } + return coerceInputValue(inputValue, type.ofType); + } + if (inputValue == null) { + return null; // Explicitly return the value null. + } + if (isListType(type)) { + if (!isIterableObject(inputValue)) { + // Lists accept a non-list value as a list of one. + const coercedItem = coerceInputValue(inputValue, type.ofType); + if (coercedItem === undefined) { + return; // Invalid: intentionally return no value. + } + return [coercedItem]; + } + const coercedValue = []; + for (const itemValue of inputValue) { + const coercedItem = coerceInputValue(itemValue, type.ofType); + if (coercedItem === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValue.push(coercedItem); + } + return coercedValue; + } + if (isInputObjectType(type)) { + if (!isObjectLike(inputValue)) { + return; // Invalid: intentionally return no value. + } + const coercedValue = {}; + const fieldDefs = type.getFields(); + const hasUndefinedField = Object.keys(inputValue).some((name) => !Object.hasOwn(fieldDefs, name)); + if (hasUndefinedField) { + return; // Invalid: intentionally return no value. + } + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; + if (fieldValue === undefined) { + if (isRequiredInputField(field)) { + return; // Invalid: intentionally return no value. + } + const coercedDefaultValue = coerceDefaultValue(field); + if (coercedDefaultValue !== undefined) { + coercedValue[field.name] = coercedDefaultValue; + } + } + else { + const coercedField = coerceInputValue(fieldValue, field.type); + if (coercedField === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValue[field.name] = coercedField; + } + } + if (type.isOneOf) { + const keys = Object.keys(coercedValue); + if (keys.length !== 1) { + return; // Invalid: intentionally return no value. + } + const key = keys[0]; + const value = coercedValue[key]; + if (value === null) { + return; // Invalid: intentionally return no value. + } + } + return coercedValue; + } + const leafType = assertLeafType(type); + try { + return leafType.coerceInputValue(inputValue); + } + catch (_error) { + // Invalid: ignore error and intentionally return no value. + } +} +/** + * Produces a coerced "internal" JavaScript value given a GraphQL Value AST. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + */ +export function coerceInputLiteral(valueNode, type, variableValues, fragmentVariableValues) { + if (valueNode.kind === Kind.VARIABLE) { + const coercedVariableValue = getCoercedVariableValue(valueNode, variableValues, fragmentVariableValues); + if (coercedVariableValue == null && isNonNullType(type)) { + return; // Invalid: intentionally return no value. + } + // Note: This does no further checking that this variable is correct. + // This assumes validated has checked this variable is of the correct type. + return coercedVariableValue; + } + if (isNonNullType(type)) { + if (valueNode.kind === Kind.NULL) { + return; // Invalid: intentionally return no value. + } + return coerceInputLiteral(valueNode, type.ofType, variableValues, fragmentVariableValues); + } + if (valueNode.kind === Kind.NULL) { + return null; // Explicitly return the value null. + } + if (isListType(type)) { + if (valueNode.kind !== Kind.LIST) { + // Lists accept a non-list value as a list of one. + const itemValue = coerceInputLiteral(valueNode, type.ofType, variableValues, fragmentVariableValues); + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + return [itemValue]; + } + const coercedValue = []; + for (const itemNode of valueNode.values) { + let itemValue = coerceInputLiteral(itemNode, type.ofType, variableValues, fragmentVariableValues); + if (itemValue === undefined) { + if (itemNode.kind === Kind.VARIABLE && + getCoercedVariableValue(itemNode, variableValues, fragmentVariableValues) == null && + !isNonNullType(type.ofType)) { + // A missing variable within a list is coerced to null. + itemValue = null; + } + else { + return; // Invalid: intentionally return no value. + } + } + coercedValue.push(itemValue); + } + return coercedValue; + } + if (isInputObjectType(type)) { + if (valueNode.kind !== Kind.OBJECT) { + return; // Invalid: intentionally return no value. + } + const coercedValue = {}; + const fieldDefs = type.getFields(); + const hasUndefinedField = valueNode.fields.some((field) => !Object.hasOwn(fieldDefs, field.name.value)); + if (hasUndefinedField) { + return; // Invalid: intentionally return no value. + } + const fieldNodes = new Map(valueNode.fields.map((field) => [field.name.value, field])); + for (const field of Object.values(fieldDefs)) { + const fieldNode = fieldNodes.get(field.name); + if (!fieldNode || + (fieldNode.value.kind === Kind.VARIABLE && + getCoercedVariableValue(fieldNode.value, variableValues, fragmentVariableValues) == null)) { + if (isRequiredInputField(field)) { + return; // Invalid: intentionally return no value. + } + const coercedDefaultValue = coerceDefaultValue(field); + if (coercedDefaultValue !== undefined) { + coercedValue[field.name] = coercedDefaultValue; + } + } + else { + const fieldValue = coerceInputLiteral(fieldNode.value, field.type, variableValues, fragmentVariableValues); + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValue[field.name] = fieldValue; + } + } + if (type.isOneOf) { + const keys = Object.keys(coercedValue); + if (keys.length !== 1) { + return; // Invalid: not exactly one key, intentionally return no value. + } + if (coercedValue[keys[0]] === null) { + return; // Invalid: value not non-null, intentionally return no value. + } + } + return coercedValue; + } + const leafType = assertLeafType(type); + try { + return leafType.coerceInputLiteral + ? leafType.coerceInputLiteral(replaceVariables(valueNode, variableValues, fragmentVariableValues)) + : leafType.parseLiteral(valueNode, variableValues?.coerced); + } + catch (_error) { + // Invalid: ignore error and intentionally return no value. + } +} +// Retrieves the variable value for the given variable node. +function getCoercedVariableValue(variableNode, variableValues, fragmentVariableValues) { + const varName = variableNode.name.value; + if (fragmentVariableValues?.sources[varName] !== undefined) { + return fragmentVariableValues.coerced[varName]; + } + return variableValues?.coerced[varName]; +} +/** + * @internal + */ +export function coerceDefaultValue(inputValue) { + // Memoize the result of coercing the default value in a hidden field. + let coercedDefaultValue = inputValue._memoizedCoercedDefaultValue; + if (coercedDefaultValue !== undefined) { + return coercedDefaultValue; + } + const defaultInput = inputValue.default; + if (defaultInput !== undefined) { + coercedDefaultValue = defaultInput.literal + ? coerceInputLiteral(defaultInput.literal, inputValue.type) + : coerceInputValue(defaultInput.value, inputValue.type); + (coercedDefaultValue !== undefined) || invariant(false); + inputValue._memoizedCoercedDefaultValue = coercedDefaultValue; + return coercedDefaultValue; + } + const defaultValue = inputValue.defaultValue; + if (defaultValue !== undefined) { + inputValue._memoizedCoercedDefaultValue = defaultValue; + } + return defaultValue; +} +//# sourceMappingURL=coerceInputValue.js.map \ No newline at end of file diff --git a/utilities/coerceInputValue.mjs.map b/utilities/coerceInputValue.mjs.map new file mode 100644 index 0000000000..88894b20c3 --- /dev/null +++ b/utilities/coerceInputValue.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"coerceInputValue.js","sourceRoot":"","s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../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { ValueNode, VariableNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type {\n GraphQLDefaultInput,\n GraphQLInputType,\n} from '../type/definition.js';\nimport {\n assertLeafType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isRequiredInputField,\n} from '../type/definition.js';\n\nimport type { FragmentVariableValues } from '../execution/collectFields.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { replaceVariables } from './replaceVariables.js';\n\n/**\n * Coerces a JavaScript value given a GraphQL Input Type.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n */\nexport function coerceInputValue(\n inputValue: unknown,\n type: GraphQLInputType,\n): unknown {\n if (isNonNullType(type)) {\n if (inputValue == null) {\n return; // Invalid: intentionally return no value.\n }\n return coerceInputValue(inputValue, type.ofType);\n }\n\n if (inputValue == null) {\n return null; // Explicitly return the value null.\n }\n\n if (isListType(type)) {\n if (!isIterableObject(inputValue)) {\n // Lists accept a non-list value as a list of one.\n const coercedItem = coerceInputValue(inputValue, type.ofType);\n if (coercedItem === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return [coercedItem];\n }\n const coercedValue = [];\n for (const itemValue of inputValue) {\n const coercedItem = coerceInputValue(itemValue, type.ofType);\n if (coercedItem === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValue.push(coercedItem);\n }\n return coercedValue;\n }\n\n if (isInputObjectType(type)) {\n if (!isObjectLike(inputValue)) {\n return; // Invalid: intentionally return no value.\n }\n\n const coercedValue: any = {};\n const fieldDefs = type.getFields();\n const hasUndefinedField = Object.keys(inputValue).some(\n (name) => !Object.hasOwn(fieldDefs, name),\n );\n if (hasUndefinedField) {\n return; // Invalid: intentionally return no value.\n }\n for (const field of Object.values(fieldDefs)) {\n const fieldValue = inputValue[field.name];\n if (fieldValue === undefined) {\n if (isRequiredInputField(field)) {\n return; // Invalid: intentionally return no value.\n }\n const coercedDefaultValue = coerceDefaultValue(field);\n if (coercedDefaultValue !== undefined) {\n coercedValue[field.name] = coercedDefaultValue;\n }\n } else {\n const coercedField = coerceInputValue(fieldValue, field.type);\n if (coercedField === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValue[field.name] = coercedField;\n }\n }\n\n if (type.isOneOf) {\n const keys = Object.keys(coercedValue);\n if (keys.length !== 1) {\n return; // Invalid: intentionally return no value.\n }\n\n const key = keys[0];\n const value = coercedValue[key];\n if (value === null) {\n return; // Invalid: intentionally return no value.\n }\n }\n\n return coercedValue;\n }\n\n const leafType = assertLeafType(type);\n\n try {\n return leafType.coerceInputValue(inputValue);\n } catch (_error) {\n // Invalid: ignore error and intentionally return no value.\n }\n}\n\n/**\n * Produces a coerced \"internal\" JavaScript value given a GraphQL Value AST.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n */\nexport function coerceInputLiteral(\n valueNode: ValueNode,\n type: GraphQLInputType,\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n): unknown {\n if (valueNode.kind === Kind.VARIABLE) {\n const coercedVariableValue = getCoercedVariableValue(\n valueNode,\n variableValues,\n fragmentVariableValues,\n );\n if (coercedVariableValue == null && isNonNullType(type)) {\n return; // Invalid: intentionally return no value.\n }\n // Note: This does no further checking that this variable is correct.\n // This assumes validated has checked this variable is of the correct type.\n return coercedVariableValue;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n return coerceInputLiteral(\n valueNode,\n type.ofType,\n variableValues,\n fragmentVariableValues,\n );\n }\n\n if (valueNode.kind === Kind.NULL) {\n return null; // Explicitly return the value null.\n }\n\n if (isListType(type)) {\n if (valueNode.kind !== Kind.LIST) {\n // Lists accept a non-list value as a list of one.\n const itemValue = coerceInputLiteral(\n valueNode,\n type.ofType,\n variableValues,\n fragmentVariableValues,\n );\n if (itemValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return [itemValue];\n }\n const coercedValue: Array = [];\n for (const itemNode of valueNode.values) {\n let itemValue = coerceInputLiteral(\n itemNode,\n type.ofType,\n variableValues,\n fragmentVariableValues,\n );\n if (itemValue === undefined) {\n if (\n itemNode.kind === Kind.VARIABLE &&\n getCoercedVariableValue(\n itemNode,\n variableValues,\n fragmentVariableValues,\n ) == null &&\n !isNonNullType(type.ofType)\n ) {\n // A missing variable within a list is coerced to null.\n itemValue = null;\n } else {\n return; // Invalid: intentionally return no value.\n }\n }\n coercedValue.push(itemValue);\n }\n return coercedValue;\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n\n const coercedValue: { [field: string]: unknown } = {};\n const fieldDefs = type.getFields();\n const hasUndefinedField = valueNode.fields.some(\n (field) => !Object.hasOwn(fieldDefs, field.name.value),\n );\n if (hasUndefinedField) {\n return; // Invalid: intentionally return no value.\n }\n const fieldNodes = new Map(\n valueNode.fields.map((field) => [field.name.value, field]),\n );\n for (const field of Object.values(fieldDefs)) {\n const fieldNode = fieldNodes.get(field.name);\n if (\n !fieldNode ||\n (fieldNode.value.kind === Kind.VARIABLE &&\n getCoercedVariableValue(\n fieldNode.value,\n variableValues,\n fragmentVariableValues,\n ) == null)\n ) {\n if (isRequiredInputField(field)) {\n return; // Invalid: intentionally return no value.\n }\n const coercedDefaultValue = coerceDefaultValue(field);\n if (coercedDefaultValue !== undefined) {\n coercedValue[field.name] = coercedDefaultValue;\n }\n } else {\n const fieldValue = coerceInputLiteral(\n fieldNode.value,\n field.type,\n variableValues,\n fragmentVariableValues,\n );\n if (fieldValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValue[field.name] = fieldValue;\n }\n }\n\n if (type.isOneOf) {\n const keys = Object.keys(coercedValue);\n if (keys.length !== 1) {\n return; // Invalid: not exactly one key, intentionally return no value.\n }\n\n if (coercedValue[keys[0]] === null) {\n return; // Invalid: value not non-null, intentionally return no value.\n }\n }\n\n return coercedValue;\n }\n\n const leafType = assertLeafType(type);\n try {\n return leafType.coerceInputLiteral\n ? leafType.coerceInputLiteral(\n replaceVariables(valueNode, variableValues, fragmentVariableValues),\n )\n : leafType.parseLiteral(valueNode, variableValues?.coerced);\n } catch (_error) {\n // Invalid: ignore error and intentionally return no value.\n }\n}\n\n// Retrieves the variable value for the given variable node.\nfunction getCoercedVariableValue(\n variableNode: VariableNode,\n variableValues: Maybe,\n fragmentVariableValues: Maybe,\n): unknown {\n const varName = variableNode.name.value;\n if (fragmentVariableValues?.sources[varName] !== undefined) {\n return fragmentVariableValues.coerced[varName];\n }\n\n return variableValues?.coerced[varName];\n}\n\ninterface InputValue {\n type: GraphQLInputType;\n default?: GraphQLDefaultInput | undefined;\n defaultValue?: unknown;\n}\n\n/**\n * @internal\n */\nexport function coerceDefaultValue(inputValue: InputValue): unknown {\n // Memoize the result of coercing the default value in a hidden field.\n let coercedDefaultValue = (inputValue as any)._memoizedCoercedDefaultValue;\n if (coercedDefaultValue !== undefined) {\n return coercedDefaultValue;\n }\n\n const defaultInput = inputValue.default;\n if (defaultInput !== undefined) {\n coercedDefaultValue = defaultInput.literal\n ? coerceInputLiteral(defaultInput.literal, inputValue.type)\n : coerceInputValue(defaultInput.value, inputValue.type);\n invariant(coercedDefaultValue !== undefined);\n (inputValue as any)._memoizedCoercedDefaultValue = coercedDefaultValue;\n return coercedDefaultValue;\n }\n\n const defaultValue = inputValue.defaultValue;\n if (defaultValue !== undefined) {\n (inputValue as any)._memoizedCoercedDefaultValue = defaultValue;\n }\n return defaultValue;\n}\n"]} \ No newline at end of file diff --git a/utilities/concatAST.d.ts b/utilities/concatAST.d.ts new file mode 100644 index 0000000000..c8ababdaf5 --- /dev/null +++ b/utilities/concatAST.d.ts @@ -0,0 +1,7 @@ +import type { DocumentNode } from '../language/ast.js'; +/** + * Provided a collection of ASTs, presumably each from different files, + * concatenate the ASTs together into batched AST, useful for validating many + * GraphQL source files which together represent one conceptual application. + */ +export declare function concatAST(documents: ReadonlyArray): DocumentNode; diff --git a/utilities/concatAST.js b/utilities/concatAST.js new file mode 100644 index 0000000000..56470a28b3 --- /dev/null +++ b/utilities/concatAST.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.concatAST = concatAST; +const kinds_js_1 = require("../language/kinds.js"); +/** + * Provided a collection of ASTs, presumably each from different files, + * concatenate the ASTs together into batched AST, useful for validating many + * GraphQL source files which together represent one conceptual application. + */ +function concatAST(documents) { + const definitions = []; + for (const doc of documents) { + definitions.push(...doc.definitions); + } + return { kind: kinds_js_1.Kind.DOCUMENT, definitions }; +} +//# sourceMappingURL=concatAST.js.map \ No newline at end of file diff --git a/utilities/concatAST.js.map b/utilities/concatAST.js.map new file mode 100644 index 0000000000..aa80e263e2 --- /dev/null +++ b/utilities/concatAST.js.map @@ -0,0 +1 @@ +{"version":3,"file":"concatAST.js","sourceRoot":"","sources":["../../src/utilities/concatAST.ts"],"names":[],"mappings":";;AAQA,8BAQC;AAfD,mDAA4C;AAE5C;;;;GAIG;AACH,SAAgB,SAAS,CACvB,SAAsC;IAEtC,MAAM,WAAW,GAA0B,EAAE,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,WAAW,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,eAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["import type { DefinitionNode, DocumentNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Provided a collection of ASTs, presumably each from different files,\n * concatenate the ASTs together into batched AST, useful for validating many\n * GraphQL source files which together represent one conceptual application.\n */\nexport function concatAST(\n documents: ReadonlyArray,\n): DocumentNode {\n const definitions: Array = [];\n for (const doc of documents) {\n definitions.push(...doc.definitions);\n }\n return { kind: Kind.DOCUMENT, definitions };\n}\n"]} \ No newline at end of file diff --git a/utilities/concatAST.mjs b/utilities/concatAST.mjs new file mode 100644 index 0000000000..f47cca478a --- /dev/null +++ b/utilities/concatAST.mjs @@ -0,0 +1,14 @@ +import { Kind } from "../language/kinds.mjs"; +/** + * Provided a collection of ASTs, presumably each from different files, + * concatenate the ASTs together into batched AST, useful for validating many + * GraphQL source files which together represent one conceptual application. + */ +export function concatAST(documents) { + const definitions = []; + for (const doc of documents) { + definitions.push(...doc.definitions); + } + return { kind: Kind.DOCUMENT, definitions }; +} +//# sourceMappingURL=concatAST.js.map \ No newline at end of file diff --git a/utilities/concatAST.mjs.map b/utilities/concatAST.mjs.map new file mode 100644 index 0000000000..ce3ec01ced --- /dev/null +++ b/utilities/concatAST.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"concatAST.js","sourceRoot":"","sources":["../../src/utilities/concatAST.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,SAAsC;IAEtC,MAAM,WAAW,GAA0B,EAAE,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,WAAW,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["import type { DefinitionNode, DocumentNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Provided a collection of ASTs, presumably each from different files,\n * concatenate the ASTs together into batched AST, useful for validating many\n * GraphQL source files which together represent one conceptual application.\n */\nexport function concatAST(\n documents: ReadonlyArray,\n): DocumentNode {\n const definitions: Array = [];\n for (const doc of documents) {\n definitions.push(...doc.definitions);\n }\n return { kind: Kind.DOCUMENT, definitions };\n}\n"]} \ No newline at end of file diff --git a/utilities/extendSchema.d.ts b/utilities/extendSchema.d.ts new file mode 100644 index 0000000000..1e45745ea8 --- /dev/null +++ b/utilities/extendSchema.d.ts @@ -0,0 +1,29 @@ +import type { DocumentNode } from '../language/ast.js'; +import type { GraphQLSchemaNormalizedConfig, GraphQLSchemaValidationOptions } from '../type/schema.js'; +import { GraphQLSchema } from '../type/schema.js'; +interface Options extends GraphQLSchemaValidationOptions { + /** + * Set to true to assume the SDL is valid. + * + * Default: false + */ + assumeValidSDL?: boolean | undefined; +} +/** + * Produces a new schema given an existing schema and a document which may + * contain GraphQL type extensions and definitions. The original schema will + * remain unaltered. + * + * Because a schema represents a graph of references, a schema cannot be + * extended without effectively making an entire copy. We do not know until it's + * too late if subgraphs remain unchanged. + * + * This algorithm copies the provided schema, applying extensions while + * producing the copy. The original schema remains unaltered. + */ +export declare function extendSchema(schema: GraphQLSchema, documentAST: DocumentNode, options?: Options): GraphQLSchema; +/** + * @internal + */ +export declare function extendSchemaImpl(schemaConfig: GraphQLSchemaNormalizedConfig, documentAST: DocumentNode, options?: Options): GraphQLSchemaNormalizedConfig; +export {}; diff --git a/utilities/extendSchema.js b/utilities/extendSchema.js new file mode 100644 index 0000000000..220c6a6392 --- /dev/null +++ b/utilities/extendSchema.js @@ -0,0 +1,442 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.extendSchema = extendSchema; +exports.extendSchemaImpl = extendSchemaImpl; +const AccumulatorMap_js_1 = require("../jsutils/AccumulatorMap.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +const directives_js_1 = require("../type/directives.js"); +const introspection_js_1 = require("../type/introspection.js"); +const scalars_js_1 = require("../type/scalars.js"); +const schema_js_1 = require("../type/schema.js"); +const validate_js_1 = require("../validation/validate.js"); +const values_js_1 = require("../execution/values.js"); +const mapSchemaConfig_js_1 = require("./mapSchemaConfig.js"); +/** + * Produces a new schema given an existing schema and a document which may + * contain GraphQL type extensions and definitions. The original schema will + * remain unaltered. + * + * Because a schema represents a graph of references, a schema cannot be + * extended without effectively making an entire copy. We do not know until it's + * too late if subgraphs remain unchanged. + * + * This algorithm copies the provided schema, applying extensions while + * producing the copy. The original schema remains unaltered. + */ +function extendSchema(schema, documentAST, options) { + (0, schema_js_1.assertSchema)(schema); + if (options?.assumeValid !== true && options?.assumeValidSDL !== true) { + (0, validate_js_1.assertValidSDLExtension)(documentAST, schema); + } + const schemaConfig = schema.toConfig(); + const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options); + return schemaConfig === extendedConfig + ? schema + : new schema_js_1.GraphQLSchema(extendedConfig); +} +/** + * @internal + */ +function extendSchemaImpl(schemaConfig, documentAST, options) { + // Collect the type definitions and extensions found in the document. + const typeDefs = []; + const scalarExtensions = new AccumulatorMap_js_1.AccumulatorMap(); + const objectExtensions = new AccumulatorMap_js_1.AccumulatorMap(); + const interfaceExtensions = new AccumulatorMap_js_1.AccumulatorMap(); + const unionExtensions = new AccumulatorMap_js_1.AccumulatorMap(); + const enumExtensions = new AccumulatorMap_js_1.AccumulatorMap(); + const inputObjectExtensions = new AccumulatorMap_js_1.AccumulatorMap(); + // New directives and types are separate because a directives and types can + // have the same name. For example, a type named "skip". + const directiveDefs = []; + let schemaDef; + // Schema extensions are collected which may add additional operation types. + const schemaExtensions = []; + let isSchemaChanged = false; + for (const def of documentAST.definitions) { + switch (def.kind) { + case kinds_js_1.Kind.SCHEMA_DEFINITION: + schemaDef = def; + break; + case kinds_js_1.Kind.SCHEMA_EXTENSION: + schemaExtensions.push(def); + break; + case kinds_js_1.Kind.DIRECTIVE_DEFINITION: + directiveDefs.push(def); + break; + // Type Definitions + case kinds_js_1.Kind.SCALAR_TYPE_DEFINITION: + case kinds_js_1.Kind.OBJECT_TYPE_DEFINITION: + case kinds_js_1.Kind.INTERFACE_TYPE_DEFINITION: + case kinds_js_1.Kind.UNION_TYPE_DEFINITION: + case kinds_js_1.Kind.ENUM_TYPE_DEFINITION: + case kinds_js_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: + typeDefs.push(def); + break; + // Type System Extensions + case kinds_js_1.Kind.SCALAR_TYPE_EXTENSION: + scalarExtensions.add(def.name.value, def); + break; + case kinds_js_1.Kind.OBJECT_TYPE_EXTENSION: + objectExtensions.add(def.name.value, def); + break; + case kinds_js_1.Kind.INTERFACE_TYPE_EXTENSION: + interfaceExtensions.add(def.name.value, def); + break; + case kinds_js_1.Kind.UNION_TYPE_EXTENSION: + unionExtensions.add(def.name.value, def); + break; + case kinds_js_1.Kind.ENUM_TYPE_EXTENSION: + enumExtensions.add(def.name.value, def); + break; + case kinds_js_1.Kind.INPUT_OBJECT_TYPE_EXTENSION: + inputObjectExtensions.add(def.name.value, def); + break; + default: + continue; + } + isSchemaChanged = true; + } + // If this document contains no new types, extensions, or directives then + // return the same unmodified GraphQLSchema instance. + if (!isSchemaChanged) { + return schemaConfig; + } + return (0, mapSchemaConfig_js_1.mapSchemaConfig)(schemaConfig, (context) => { + const { getNamedType, setNamedType, getNamedTypes } = context; + return { + [mapSchemaConfig_js_1.SchemaElementKind.SCHEMA]: (config) => { + for (const typeNode of typeDefs) { + const type = stdTypeMap.get(typeNode.name.value) ?? buildNamedType(typeNode); + setNamedType(type); + } + const operationTypes = { + // Get the extended root operation types. + query: config.query && + getNamedType(config.query.name), + mutation: config.mutation && + getNamedType(config.mutation.name), + subscription: config.subscription && + getNamedType(config.subscription.name), + // Then, incorporate schema definition and all schema extensions. + ...(schemaDef && getOperationTypes([schemaDef])), + ...getOperationTypes(schemaExtensions), + }; + // Then produce and return a Schema config with these types. + return { + description: schemaDef?.description?.value ?? config.description, + ...operationTypes, + types: getNamedTypes(), + directives: [ + ...config.directives, + ...directiveDefs.map(buildDirective), + ], + extensions: config.extensions, + astNode: schemaDef ?? config.astNode, + extensionASTNodes: config.extensionASTNodes.concat(schemaExtensions), + assumeValid: options?.assumeValid ?? false, + }; + }, + [mapSchemaConfig_js_1.SchemaElementKind.INPUT_OBJECT]: (config) => { + const extensions = inputObjectExtensions.get(config.name) ?? []; + return { + ...config, + fields: () => ({ + ...config.fields(), + ...buildInputFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [mapSchemaConfig_js_1.SchemaElementKind.ENUM]: (config) => { + const extensions = enumExtensions.get(config.name) ?? []; + return { + ...config, + values: () => ({ + ...config.values(), + ...buildEnumValueMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [mapSchemaConfig_js_1.SchemaElementKind.SCALAR]: (config) => { + const extensions = scalarExtensions.get(config.name) ?? []; + let specifiedByURL = config.specifiedByURL; + for (const extensionNode of extensions) { + specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL; + } + return { + ...config, + specifiedByURL, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [mapSchemaConfig_js_1.SchemaElementKind.OBJECT]: (config) => { + const extensions = objectExtensions.get(config.name) ?? []; + return { + ...config, + interfaces: () => [ + ...config.interfaces(), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...config.fields(), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [mapSchemaConfig_js_1.SchemaElementKind.INTERFACE]: (config) => { + const extensions = interfaceExtensions.get(config.name) ?? []; + return { + ...config, + interfaces: () => [ + ...config.interfaces(), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...config.fields(), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [mapSchemaConfig_js_1.SchemaElementKind.UNION]: (config) => { + const extensions = unionExtensions.get(config.name) ?? []; + return { + ...config, + types: () => [...config.types(), ...buildUnionTypes(extensions)], + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + }; + function getOperationTypes(nodes) { + const opTypes = {}; + for (const node of nodes) { + const operationTypesNodes = node.operationTypes ?? []; + for (const operationType of operationTypesNodes) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + opTypes[operationType.operation] = namedTypeFromAST(operationType.type); + } + } + return opTypes; + } + function namedTypeFromAST(node) { + const name = node.name.value; + const type = getNamedType(name); + (type !== undefined) || (0, invariant_js_1.invariant)(false, `Unknown type: "${name}".`); + return type; + } + function typeFromAST(node) { + if (node.kind === kinds_js_1.Kind.LIST_TYPE) { + return new definition_js_1.GraphQLList(typeFromAST(node.type)); + } + if (node.kind === kinds_js_1.Kind.NON_NULL_TYPE) { + return new definition_js_1.GraphQLNonNull(typeFromAST(node.type)); + } + return namedTypeFromAST(node); + } + function buildDirective(node) { + return new directives_js_1.GraphQLDirective({ + name: node.name.value, + description: node.description?.value, + // @ts-expect-error + locations: node.locations.map(({ value }) => value), + isRepeatable: node.repeatable, + args: buildArgumentMap(node.arguments), + astNode: node, + }); + } + function buildFieldMap(nodes) { + const fieldConfigMap = Object.create(null); + for (const node of nodes) { + const nodeFields = node.fields ?? []; + for (const field of nodeFields) { + fieldConfigMap[field.name.value] = { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + type: typeFromAST(field.type), + description: field.description?.value, + args: buildArgumentMap(field.arguments), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + return fieldConfigMap; + } + function buildArgumentMap(args) { + const argsNodes = args ?? []; + const argConfigMap = Object.create(null); + for (const arg of argsNodes) { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = typeFromAST(arg.type); + argConfigMap[arg.name.value] = { + type, + description: arg.description?.value, + default: arg.defaultValue && { literal: arg.defaultValue }, + deprecationReason: getDeprecationReason(arg), + astNode: arg, + }; + } + return argConfigMap; + } + function buildInputFieldMap(nodes) { + const inputFieldMap = Object.create(null); + for (const node of nodes) { + const fieldsNodes = node.fields ?? []; + for (const field of fieldsNodes) { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = typeFromAST(field.type); + inputFieldMap[field.name.value] = { + type, + description: field.description?.value, + default: field.defaultValue && { literal: field.defaultValue }, + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + return inputFieldMap; + } + function buildEnumValueMap(nodes) { + const enumValueMap = Object.create(null); + for (const node of nodes) { + const valuesNodes = node.values ?? []; + for (const value of valuesNodes) { + enumValueMap[value.name.value] = { + description: value.description?.value, + deprecationReason: getDeprecationReason(value), + astNode: value, + }; + } + } + return enumValueMap; + } + function buildInterfaces(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap((node) => node.interfaces?.map(namedTypeFromAST) ?? []); + } + function buildUnionTypes(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap((node) => node.types?.map(namedTypeFromAST) ?? []); + } + function buildNamedType(astNode) { + const name = astNode.name.value; + switch (astNode.kind) { + case kinds_js_1.Kind.OBJECT_TYPE_DEFINITION: { + const extensionASTNodes = objectExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new definition_js_1.GraphQLObjectType({ + name, + description: astNode.description?.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + case kinds_js_1.Kind.INTERFACE_TYPE_DEFINITION: { + const extensionASTNodes = interfaceExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new definition_js_1.GraphQLInterfaceType({ + name, + description: astNode.description?.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + case kinds_js_1.Kind.ENUM_TYPE_DEFINITION: { + const extensionASTNodes = enumExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new definition_js_1.GraphQLEnumType({ + name, + description: astNode.description?.value, + values: () => buildEnumValueMap(allNodes), + astNode, + extensionASTNodes, + }); + } + case kinds_js_1.Kind.UNION_TYPE_DEFINITION: { + const extensionASTNodes = unionExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new definition_js_1.GraphQLUnionType({ + name, + description: astNode.description?.value, + types: () => buildUnionTypes(allNodes), + astNode, + extensionASTNodes, + }); + } + case kinds_js_1.Kind.SCALAR_TYPE_DEFINITION: { + const extensionASTNodes = scalarExtensions.get(name) ?? []; + return new definition_js_1.GraphQLScalarType({ + name, + description: astNode.description?.value, + specifiedByURL: getSpecifiedByURL(astNode), + astNode, + extensionASTNodes, + }); + } + case kinds_js_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: { + const extensionASTNodes = inputObjectExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new definition_js_1.GraphQLInputObjectType({ + name, + description: astNode.description?.value, + fields: () => buildInputFieldMap(allNodes), + astNode, + extensionASTNodes, + isOneOf: isOneOf(astNode), + }); + } + } + } + }); +} +const stdTypeMap = new Map([...scalars_js_1.specifiedScalarTypes, ...introspection_js_1.introspectionTypes].map((type) => [ + type.name, + type, +])); +/** + * Given a field or enum value node, returns the string value for the + * deprecation reason. + */ +function getDeprecationReason(node) { + const deprecated = (0, values_js_1.getDirectiveValues)(directives_js_1.GraphQLDeprecatedDirective, node); + // @ts-expect-error validated by `getDirectiveValues` + return deprecated?.reason; +} +/** + * Given a scalar node, returns the string value for the specifiedByURL. + */ +function getSpecifiedByURL(node) { + const specifiedBy = (0, values_js_1.getDirectiveValues)(directives_js_1.GraphQLSpecifiedByDirective, node); + // @ts-expect-error validated by `getDirectiveValues` + return specifiedBy?.url; +} +/** + * Given an input object node, returns if the node should be OneOf. + */ +function isOneOf(node) { + return Boolean((0, values_js_1.getDirectiveValues)(directives_js_1.GraphQLOneOfDirective, node)); +} +//# sourceMappingURL=extendSchema.js.map \ No newline at end of file diff --git a/utilities/extendSchema.js.map b/utilities/extendSchema.js.map new file mode 100644 index 0000000000..543daf953b --- /dev/null +++ b/utilities/extendSchema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extendSchema.js","sourceRoot":"","sources":["../../src/utilities/extendSchema.ts"],"names":[],"mappings":";;AAyFA,oCAgBC;AAKD,4CA6cC;AA3jBD,oEAA8D;AAC9D,0DAAoD;AA2BpD,mDAA4C;AAU5C,yDAS+B;AAC/B,yDAK+B;AAC/B,+DAA8D;AAC9D,mDAA0D;AAK1D,iDAAgE;AAEhE,2DAAoE;AAEpE,sDAA4D;AAE5D,6DAA0E;AAW1E;;;;;;;;;;;GAWG;AACH,SAAgB,YAAY,CAC1B,MAAqB,EACrB,WAAyB,EACzB,OAAiB;IAEjB,IAAA,wBAAY,EAAC,MAAM,CAAC,CAAC;IAErB,IAAI,OAAO,EAAE,WAAW,KAAK,IAAI,IAAI,OAAO,EAAE,cAAc,KAAK,IAAI,EAAE,CAAC;QACtE,IAAA,qCAAuB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IACvC,MAAM,cAAc,GAAG,gBAAgB,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAC5E,OAAO,YAAY,KAAK,cAAc;QACpC,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,IAAI,yBAAa,CAAC,cAAc,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,YAA2C,EAC3C,WAAyB,EACzB,OAAiB;IAEjB,qEAAqE;IACrE,MAAM,QAAQ,GAA8B,EAAE,CAAC;IAE/C,MAAM,gBAAgB,GAAG,IAAI,kCAAc,EAGxC,CAAC;IACJ,MAAM,gBAAgB,GAAG,IAAI,kCAAc,EAGxC,CAAC;IACJ,MAAM,mBAAmB,GAAG,IAAI,kCAAc,EAG3C,CAAC;I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ACjB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;qBAC1B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,CAAC,GAAG,iCAAoB,EAAE,GAAG,qCAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC7D,IAAI,CAAC,IAAI;IACT,IAAI;CACL,CAAC,CACH,CAAC;AAEF;;;GAGG;AACH,SAAS,oBAAoB,CAC3B,IAG4B;IAE5B,MAAM,UAAU,GAAG,IAAA,8BAAkB,EAAC,0CAA0B,EAAE,IAAI,CAAC,CAAC;IACxE,qDAAqD;IACrD,OAAO,UAAU,EAAE,MAAM,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CACxB,IAAwD;IAExD,MAAM,WAAW,GAAG,IAAA,8BAAkB,EAAC,2CAA2B,EAAE,IAAI,CAAC,CAAC;IAC1E,qDAAqD;IACrD,OAAO,WAAW,EAAE,GAAG,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,IAAmC;IAClD,OAAO,OAAO,CAAC,IAAA,8BAAkB,EAAC,qCAAqB,EAAE,IAAI,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { AccumulatorMap } from '../jsutils/AccumulatorMap.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n DirectiveDefinitionNode,\n DocumentNode,\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n EnumValueDefinitionNode,\n FieldDefinitionNode,\n InputObjectTypeDefinitionNode,\n InputObjectTypeExtensionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n NamedTypeNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n ScalarTypeDefinitionNode,\n ScalarTypeExtensionNode,\n SchemaDefinitionNode,\n SchemaExtensionNode,\n TypeDefinitionNode,\n TypeNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type {\n GraphQLEnumValueNormalizedConfigMap,\n GraphQLFieldConfigArgumentMap,\n GraphQLFieldNormalizedConfigMap,\n GraphQLInputFieldNormalizedConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.js';\nimport {\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n} from '../type/definition.js';\nimport {\n GraphQLDeprecatedDirective,\n GraphQLDirective,\n GraphQLOneOfDirective,\n GraphQLSpecifiedByDirective,\n} from '../type/directives.js';\nimport { introspectionTypes } from '../type/introspection.js';\nimport { specifiedScalarTypes } from '../type/scalars.js';\nimport type {\n GraphQLSchemaNormalizedConfig,\n GraphQLSchemaValidationOptions,\n} from '../type/schema.js';\nimport { assertSchema, GraphQLSchema } from '../type/schema.js';\n\nimport { assertValidSDLExtension } from '../validation/validate.js';\n\nimport { getDirectiveValues } from '../execution/values.js';\n\nimport { mapSchemaConfig, SchemaElementKind } from './mapSchemaConfig.js';\n\ninterface Options extends GraphQLSchemaValidationOptions {\n /**\n * Set to true to assume the SDL is valid.\n *\n * Default: false\n */\n assumeValidSDL?: boolean | undefined;\n}\n\n/**\n * Produces a new schema given an existing schema and a document which may\n * contain GraphQL type extensions and definitions. The original schema will\n * remain unaltered.\n *\n * Because a schema represents a graph of references, a schema cannot be\n * extended without effectively making an entire copy. We do not know until it's\n * too late if subgraphs remain unchanged.\n *\n * This algorithm copies the provided schema, applying extensions while\n * producing the copy. The original schema remains unaltered.\n */\nexport function extendSchema(\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n options?: Options,\n): GraphQLSchema {\n assertSchema(schema);\n\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDLExtension(documentAST, schema);\n }\n\n const schemaConfig = schema.toConfig();\n const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options);\n return schemaConfig === extendedConfig\n ? schema\n : new GraphQLSchema(extendedConfig);\n}\n\n/**\n * @internal\n */\nexport function extendSchemaImpl(\n schemaConfig: GraphQLSchemaNormalizedConfig,\n documentAST: DocumentNode,\n options?: Options,\n): GraphQLSchemaNormalizedConfig {\n // Collect the type definitions and extensions found in the document.\n const typeDefs: Array = [];\n\n const scalarExtensions = new AccumulatorMap<\n string,\n ScalarTypeExtensionNode\n >();\n const objectExtensions = new AccumulatorMap<\n string,\n ObjectTypeExtensionNode\n >();\n const interfaceExtensions = new AccumulatorMap<\n string,\n InterfaceTypeExtensionNode\n >();\n const unionExtensions = new AccumulatorMap();\n const enumExtensions = new AccumulatorMap();\n const inputObjectExtensions = new AccumulatorMap<\n string,\n InputObjectTypeExtensionNode\n >();\n\n // New directives and types are separate because a directives and types can\n // have the same name. For example, a type named \"skip\".\n const directiveDefs: Array = [];\n\n let schemaDef: Maybe;\n // Schema extensions are collected which may add additional operation types.\n const schemaExtensions: Array = [];\n\n let isSchemaChanged = false;\n for (const def of documentAST.definitions) {\n switch (def.kind) {\n case Kind.SCHEMA_DEFINITION:\n schemaDef = def;\n break;\n case Kind.SCHEMA_EXTENSION:\n schemaExtensions.push(def);\n break;\n case Kind.DIRECTIVE_DEFINITION:\n directiveDefs.push(def);\n break;\n\n // Type Definitions\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.INTERFACE_TYPE_DEFINITION:\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n typeDefs.push(def);\n break;\n\n // Type System Extensions\n case Kind.SCALAR_TYPE_EXTENSION:\n scalarExtensions.add(def.name.value, def);\n break;\n case Kind.OBJECT_TYPE_EXTENSION:\n objectExtensions.add(def.name.value, def);\n break;\n case Kind.INTERFACE_TYPE_EXTENSION:\n interfaceExtensions.add(def.name.value, def);\n break;\n case Kind.UNION_TYPE_EXTENSION:\n unionExtensions.add(def.name.value, def);\n break;\n case Kind.ENUM_TYPE_EXTENSION:\n enumExtensions.add(def.name.value, def);\n break;\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n inputObjectExtensions.add(def.name.value, def);\n break;\n default:\n continue;\n }\n isSchemaChanged = true;\n }\n\n // If this document contains no new types, extensions, or directives then\n // return the same unmodified GraphQLSchema instance.\n if (!isSchemaChanged) {\n return schemaConfig;\n }\n\n return mapSchemaConfig(schemaConfig, (context) => {\n const { getNamedType, setNamedType, getNamedTypes } = context;\n return {\n [SchemaElementKind.SCHEMA]: (config) => {\n for (const typeNode of typeDefs) {\n const type =\n stdTypeMap.get(typeNode.name.value) ?? buildNamedType(typeNode);\n setNamedType(type);\n }\n\n const operationTypes = {\n // Get the extended root operation types.\n query:\n config.query &&\n (getNamedType(config.query.name) as GraphQLObjectType),\n mutation:\n config.mutation &&\n (getNamedType(config.mutation.name) as GraphQLObjectType),\n subscription:\n config.subscription &&\n (getNamedType(config.subscription.name) as GraphQLObjectType),\n // Then, incorporate schema definition and all schema extensions.\n ...(schemaDef && getOperationTypes([schemaDef])),\n ...getOperationTypes(schemaExtensions),\n };\n\n // Then produce and return a Schema config with these types.\n return {\n description: schemaDef?.description?.value ?? config.description,\n ...operationTypes,\n types: getNamedTypes(),\n directives: [\n ...config.directives,\n ...directiveDefs.map(buildDirective),\n ],\n extensions: config.extensions,\n astNode: schemaDef ?? config.astNode,\n extensionASTNodes: config.extensionASTNodes.concat(schemaExtensions),\n assumeValid: options?.assumeValid ?? false,\n };\n },\n [SchemaElementKind.INPUT_OBJECT]: (config) => {\n const extensions = inputObjectExtensions.get(config.name) ?? [];\n return {\n ...config,\n fields: () => ({\n ...config.fields(),\n ...buildInputFieldMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.ENUM]: (config) => {\n const extensions = enumExtensions.get(config.name) ?? [];\n return {\n ...config,\n values: () => ({\n ...config.values(),\n ...buildEnumValueMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.SCALAR]: (config) => {\n const extensions = scalarExtensions.get(config.name) ?? [];\n let specifiedByURL = config.specifiedByURL;\n for (const extensionNode of extensions) {\n specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL;\n }\n return {\n ...config,\n specifiedByURL,\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.OBJECT]: (config) => {\n const extensions = objectExtensions.get(config.name) ?? [];\n return {\n ...config,\n interfaces: () => [\n ...config.interfaces(),\n ...buildInterfaces(extensions),\n ],\n fields: () => ({\n ...config.fields(),\n ...buildFieldMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.INTERFACE]: (config) => {\n const extensions = interfaceExtensions.get(config.name) ?? [];\n return {\n ...config,\n interfaces: () => [\n ...config.interfaces(),\n ...buildInterfaces(extensions),\n ],\n fields: () => ({\n ...config.fields(),\n ...buildFieldMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.UNION]: (config) => {\n const extensions = unionExtensions.get(config.name) ?? [];\n return {\n ...config,\n types: () => [...config.types(), ...buildUnionTypes(extensions)],\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n };\n\n function getOperationTypes(\n nodes: ReadonlyArray,\n ): {\n query?: Maybe;\n mutation?: Maybe;\n subscription?: Maybe;\n } {\n const opTypes = {};\n for (const node of nodes) {\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n // @ts-expect-error\n opTypes[operationType.operation] = namedTypeFromAST(\n operationType.type,\n );\n }\n }\n\n return opTypes;\n }\n\n function namedTypeFromAST(node: NamedTypeNode): GraphQLNamedType {\n const name = node.name.value;\n const type = getNamedType(name);\n invariant(type !== undefined, `Unknown type: \"${name}\".`);\n return type;\n }\n\n function typeFromAST(node: TypeNode): GraphQLType {\n if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(typeFromAST(node.type));\n }\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(typeFromAST(node.type));\n }\n return namedTypeFromAST(node);\n }\n\n function buildDirective(node: DirectiveDefinitionNode): GraphQLDirective {\n return new GraphQLDirective({\n name: node.name.value,\n description: node.description?.value,\n // @ts-expect-error\n locations: node.locations.map(({ value }) => value),\n isRepeatable: node.repeatable,\n args: buildArgumentMap(node.arguments),\n astNode: node,\n });\n }\n\n function buildFieldMap(\n nodes: ReadonlyArray<\n | InterfaceTypeDefinitionNode\n | InterfaceTypeExtensionNode\n | ObjectTypeDefinitionNode\n | ObjectTypeExtensionNode\n >,\n ): GraphQLFieldNormalizedConfigMap {\n const fieldConfigMap = Object.create(null);\n for (const node of nodes) {\n const nodeFields = node.fields ?? [];\n\n for (const field of nodeFields) {\n fieldConfigMap[field.name.value] = {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n type: typeFromAST(field.type),\n description: field.description?.value,\n args: buildArgumentMap(field.arguments),\n deprecationReason: getDeprecationReason(field),\n astNode: field,\n };\n }\n }\n return fieldConfigMap;\n }\n\n function buildArgumentMap(\n args: Maybe>,\n ): GraphQLFieldConfigArgumentMap {\n const argsNodes = args ?? [];\n\n const argConfigMap = Object.create(null);\n for (const arg of argsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type: any = typeFromAST(arg.type);\n\n argConfigMap[arg.name.value] = {\n type,\n description: arg.description?.value,\n default: arg.defaultValue && { literal: arg.defaultValue },\n deprecationReason: getDeprecationReason(arg),\n astNode: arg,\n };\n }\n return argConfigMap;\n }\n\n function buildInputFieldMap(\n nodes: ReadonlyArray<\n InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode\n >,\n ): GraphQLInputFieldNormalizedConfigMap {\n const inputFieldMap = Object.create(null);\n for (const node of nodes) {\n const fieldsNodes = node.fields ?? [];\n\n for (const field of fieldsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type: any = typeFromAST(field.type);\n\n inputFieldMap[field.name.value] = {\n type,\n description: field.description?.value,\n default: field.defaultValue && { literal: field.defaultValue },\n deprecationReason: getDeprecationReason(field),\n astNode: field,\n };\n }\n }\n return inputFieldMap;\n }\n\n function buildEnumValueMap(\n nodes: ReadonlyArray,\n ): GraphQLEnumValueNormalizedConfigMap {\n const enumValueMap = Object.create(null);\n for (const node of nodes) {\n const valuesNodes = node.values ?? [];\n\n for (const value of valuesNodes) {\n enumValueMap[value.name.value] = {\n description: value.description?.value,\n deprecationReason: getDeprecationReason(value),\n astNode: value,\n };\n }\n }\n return enumValueMap;\n }\n\n function buildInterfaces(\n nodes: ReadonlyArray<\n | InterfaceTypeDefinitionNode\n | InterfaceTypeExtensionNode\n | ObjectTypeDefinitionNode\n | ObjectTypeExtensionNode\n >,\n ): Array {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n // @ts-expect-error\n return nodes.flatMap(\n (node) => node.interfaces?.map(namedTypeFromAST) ?? [],\n );\n }\n\n function buildUnionTypes(\n nodes: ReadonlyArray,\n ): Array {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n // @ts-expect-error\n return nodes.flatMap((node) => node.types?.map(namedTypeFromAST) ?? []);\n }\n\n function buildNamedType(astNode: TypeDefinitionNode): GraphQLNamedType {\n const name = astNode.name.value;\n\n switch (astNode.kind) {\n case Kind.OBJECT_TYPE_DEFINITION: {\n const extensionASTNodes = objectExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLObjectType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.INTERFACE_TYPE_DEFINITION: {\n const extensionASTNodes = interfaceExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLInterfaceType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.ENUM_TYPE_DEFINITION: {\n const extensionASTNodes = enumExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLEnumType({\n name,\n description: astNode.description?.value,\n values: () => buildEnumValueMap(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.UNION_TYPE_DEFINITION: {\n const extensionASTNodes = unionExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLUnionType({\n name,\n description: astNode.description?.value,\n types: () => buildUnionTypes(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.SCALAR_TYPE_DEFINITION: {\n const extensionASTNodes = scalarExtensions.get(name) ?? [];\n return new GraphQLScalarType({\n name,\n description: astNode.description?.value,\n specifiedByURL: getSpecifiedByURL(astNode),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.INPUT_OBJECT_TYPE_DEFINITION: {\n const extensionASTNodes = inputObjectExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLInputObjectType({\n name,\n description: astNode.description?.value,\n fields: () => buildInputFieldMap(allNodes),\n astNode,\n extensionASTNodes,\n isOneOf: isOneOf(astNode),\n });\n }\n }\n }\n });\n}\n\nconst stdTypeMap = new Map(\n [...specifiedScalarTypes, ...introspectionTypes].map((type) => [\n type.name,\n type,\n ]),\n);\n\n/**\n * Given a field or enum value node, returns the string value for the\n * deprecation reason.\n */\nfunction getDeprecationReason(\n node:\n | EnumValueDefinitionNode\n | FieldDefinitionNode\n | InputValueDefinitionNode,\n): Maybe {\n const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node);\n // @ts-expect-error validated by `getDirectiveValues`\n return deprecated?.reason;\n}\n\n/**\n * Given a scalar node, returns the string value for the specifiedByURL.\n */\nfunction getSpecifiedByURL(\n node: ScalarTypeDefinitionNode | ScalarTypeExtensionNode,\n): Maybe {\n const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node);\n // @ts-expect-error validated by `getDirectiveValues`\n return specifiedBy?.url;\n}\n\n/**\n * Given an input object node, returns if the node should be OneOf.\n */\nfunction isOneOf(node: InputObjectTypeDefinitionNode): boolean {\n return Boolean(getDirectiveValues(GraphQLOneOfDirective, node));\n}\n"]} \ No newline at end of file diff --git a/utilities/extendSchema.mjs b/utilities/extendSchema.mjs new file mode 100644 index 0000000000..f2e4894945 --- /dev/null +++ b/utilities/extendSchema.mjs @@ -0,0 +1,438 @@ +import { AccumulatorMap } from "../jsutils/AccumulatorMap.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLUnionType, } from "../type/definition.mjs"; +import { GraphQLDeprecatedDirective, GraphQLDirective, GraphQLOneOfDirective, GraphQLSpecifiedByDirective, } from "../type/directives.mjs"; +import { introspectionTypes } from "../type/introspection.mjs"; +import { specifiedScalarTypes } from "../type/scalars.mjs"; +import { assertSchema, GraphQLSchema } from "../type/schema.mjs"; +import { assertValidSDLExtension } from "../validation/validate.mjs"; +import { getDirectiveValues } from "../execution/values.mjs"; +import { mapSchemaConfig, SchemaElementKind } from "./mapSchemaConfig.mjs"; +/** + * Produces a new schema given an existing schema and a document which may + * contain GraphQL type extensions and definitions. The original schema will + * remain unaltered. + * + * Because a schema represents a graph of references, a schema cannot be + * extended without effectively making an entire copy. We do not know until it's + * too late if subgraphs remain unchanged. + * + * This algorithm copies the provided schema, applying extensions while + * producing the copy. The original schema remains unaltered. + */ +export function extendSchema(schema, documentAST, options) { + assertSchema(schema); + if (options?.assumeValid !== true && options?.assumeValidSDL !== true) { + assertValidSDLExtension(documentAST, schema); + } + const schemaConfig = schema.toConfig(); + const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options); + return schemaConfig === extendedConfig + ? schema + : new GraphQLSchema(extendedConfig); +} +/** + * @internal + */ +export function extendSchemaImpl(schemaConfig, documentAST, options) { + // Collect the type definitions and extensions found in the document. + const typeDefs = []; + const scalarExtensions = new AccumulatorMap(); + const objectExtensions = new AccumulatorMap(); + const interfaceExtensions = new AccumulatorMap(); + const unionExtensions = new AccumulatorMap(); + const enumExtensions = new AccumulatorMap(); + const inputObjectExtensions = new AccumulatorMap(); + // New directives and types are separate because a directives and types can + // have the same name. For example, a type named "skip". + const directiveDefs = []; + let schemaDef; + // Schema extensions are collected which may add additional operation types. + const schemaExtensions = []; + let isSchemaChanged = false; + for (const def of documentAST.definitions) { + switch (def.kind) { + case Kind.SCHEMA_DEFINITION: + schemaDef = def; + break; + case Kind.SCHEMA_EXTENSION: + schemaExtensions.push(def); + break; + case Kind.DIRECTIVE_DEFINITION: + directiveDefs.push(def); + break; + // Type Definitions + case Kind.SCALAR_TYPE_DEFINITION: + case Kind.OBJECT_TYPE_DEFINITION: + case Kind.INTERFACE_TYPE_DEFINITION: + case Kind.UNION_TYPE_DEFINITION: + case Kind.ENUM_TYPE_DEFINITION: + case Kind.INPUT_OBJECT_TYPE_DEFINITION: + typeDefs.push(def); + break; + // Type System Extensions + case Kind.SCALAR_TYPE_EXTENSION: + scalarExtensions.add(def.name.value, def); + break; + case Kind.OBJECT_TYPE_EXTENSION: + objectExtensions.add(def.name.value, def); + break; + case Kind.INTERFACE_TYPE_EXTENSION: + interfaceExtensions.add(def.name.value, def); + break; + case Kind.UNION_TYPE_EXTENSION: + unionExtensions.add(def.name.value, def); + break; + case Kind.ENUM_TYPE_EXTENSION: + enumExtensions.add(def.name.value, def); + break; + case Kind.INPUT_OBJECT_TYPE_EXTENSION: + inputObjectExtensions.add(def.name.value, def); + break; + default: + continue; + } + isSchemaChanged = true; + } + // If this document contains no new types, extensions, or directives then + // return the same unmodified GraphQLSchema instance. + if (!isSchemaChanged) { + return schemaConfig; + } + return mapSchemaConfig(schemaConfig, (context) => { + const { getNamedType, setNamedType, getNamedTypes } = context; + return { + [SchemaElementKind.SCHEMA]: (config) => { + for (const typeNode of typeDefs) { + const type = stdTypeMap.get(typeNode.name.value) ?? buildNamedType(typeNode); + setNamedType(type); + } + const operationTypes = { + // Get the extended root operation types. + query: config.query && + getNamedType(config.query.name), + mutation: config.mutation && + getNamedType(config.mutation.name), + subscription: config.subscription && + getNamedType(config.subscription.name), + // Then, incorporate schema definition and all schema extensions. + ...(schemaDef && getOperationTypes([schemaDef])), + ...getOperationTypes(schemaExtensions), + }; + // Then produce and return a Schema config with these types. + return { + description: schemaDef?.description?.value ?? config.description, + ...operationTypes, + types: getNamedTypes(), + directives: [ + ...config.directives, + ...directiveDefs.map(buildDirective), + ], + extensions: config.extensions, + astNode: schemaDef ?? config.astNode, + extensionASTNodes: config.extensionASTNodes.concat(schemaExtensions), + assumeValid: options?.assumeValid ?? false, + }; + }, + [SchemaElementKind.INPUT_OBJECT]: (config) => { + const extensions = inputObjectExtensions.get(config.name) ?? []; + return { + ...config, + fields: () => ({ + ...config.fields(), + ...buildInputFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [SchemaElementKind.ENUM]: (config) => { + const extensions = enumExtensions.get(config.name) ?? []; + return { + ...config, + values: () => ({ + ...config.values(), + ...buildEnumValueMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [SchemaElementKind.SCALAR]: (config) => { + const extensions = scalarExtensions.get(config.name) ?? []; + let specifiedByURL = config.specifiedByURL; + for (const extensionNode of extensions) { + specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL; + } + return { + ...config, + specifiedByURL, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [SchemaElementKind.OBJECT]: (config) => { + const extensions = objectExtensions.get(config.name) ?? []; + return { + ...config, + interfaces: () => [ + ...config.interfaces(), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...config.fields(), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [SchemaElementKind.INTERFACE]: (config) => { + const extensions = interfaceExtensions.get(config.name) ?? []; + return { + ...config, + interfaces: () => [ + ...config.interfaces(), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...config.fields(), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + [SchemaElementKind.UNION]: (config) => { + const extensions = unionExtensions.get(config.name) ?? []; + return { + ...config, + types: () => [...config.types(), ...buildUnionTypes(extensions)], + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }; + }, + }; + function getOperationTypes(nodes) { + const opTypes = {}; + for (const node of nodes) { + const operationTypesNodes = node.operationTypes ?? []; + for (const operationType of operationTypesNodes) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + opTypes[operationType.operation] = namedTypeFromAST(operationType.type); + } + } + return opTypes; + } + function namedTypeFromAST(node) { + const name = node.name.value; + const type = getNamedType(name); + (type !== undefined) || invariant(false, `Unknown type: "${name}".`); + return type; + } + function typeFromAST(node) { + if (node.kind === Kind.LIST_TYPE) { + return new GraphQLList(typeFromAST(node.type)); + } + if (node.kind === Kind.NON_NULL_TYPE) { + return new GraphQLNonNull(typeFromAST(node.type)); + } + return namedTypeFromAST(node); + } + function buildDirective(node) { + return new GraphQLDirective({ + name: node.name.value, + description: node.description?.value, + // @ts-expect-error + locations: node.locations.map(({ value }) => value), + isRepeatable: node.repeatable, + args: buildArgumentMap(node.arguments), + astNode: node, + }); + } + function buildFieldMap(nodes) { + const fieldConfigMap = Object.create(null); + for (const node of nodes) { + const nodeFields = node.fields ?? []; + for (const field of nodeFields) { + fieldConfigMap[field.name.value] = { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + type: typeFromAST(field.type), + description: field.description?.value, + args: buildArgumentMap(field.arguments), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + return fieldConfigMap; + } + function buildArgumentMap(args) { + const argsNodes = args ?? []; + const argConfigMap = Object.create(null); + for (const arg of argsNodes) { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = typeFromAST(arg.type); + argConfigMap[arg.name.value] = { + type, + description: arg.description?.value, + default: arg.defaultValue && { literal: arg.defaultValue }, + deprecationReason: getDeprecationReason(arg), + astNode: arg, + }; + } + return argConfigMap; + } + function buildInputFieldMap(nodes) { + const inputFieldMap = Object.create(null); + for (const node of nodes) { + const fieldsNodes = node.fields ?? []; + for (const field of fieldsNodes) { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = typeFromAST(field.type); + inputFieldMap[field.name.value] = { + type, + description: field.description?.value, + default: field.defaultValue && { literal: field.defaultValue }, + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + return inputFieldMap; + } + function buildEnumValueMap(nodes) { + const enumValueMap = Object.create(null); + for (const node of nodes) { + const valuesNodes = node.values ?? []; + for (const value of valuesNodes) { + enumValueMap[value.name.value] = { + description: value.description?.value, + deprecationReason: getDeprecationReason(value), + astNode: value, + }; + } + } + return enumValueMap; + } + function buildInterfaces(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap((node) => node.interfaces?.map(namedTypeFromAST) ?? []); + } + function buildUnionTypes(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap((node) => node.types?.map(namedTypeFromAST) ?? []); + } + function buildNamedType(astNode) { + const name = astNode.name.value; + switch (astNode.kind) { + case Kind.OBJECT_TYPE_DEFINITION: { + const extensionASTNodes = objectExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new GraphQLObjectType({ + name, + description: astNode.description?.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + case Kind.INTERFACE_TYPE_DEFINITION: { + const extensionASTNodes = interfaceExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new GraphQLInterfaceType({ + name, + description: astNode.description?.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + case Kind.ENUM_TYPE_DEFINITION: { + const extensionASTNodes = enumExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new GraphQLEnumType({ + name, + description: astNode.description?.value, + values: () => buildEnumValueMap(allNodes), + astNode, + extensionASTNodes, + }); + } + case Kind.UNION_TYPE_DEFINITION: { + const extensionASTNodes = unionExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new GraphQLUnionType({ + name, + description: astNode.description?.value, + types: () => buildUnionTypes(allNodes), + astNode, + extensionASTNodes, + }); + } + case Kind.SCALAR_TYPE_DEFINITION: { + const extensionASTNodes = scalarExtensions.get(name) ?? []; + return new GraphQLScalarType({ + name, + description: astNode.description?.value, + specifiedByURL: getSpecifiedByURL(astNode), + astNode, + extensionASTNodes, + }); + } + case Kind.INPUT_OBJECT_TYPE_DEFINITION: { + const extensionASTNodes = inputObjectExtensions.get(name) ?? []; + const allNodes = [astNode, ...extensionASTNodes]; + return new GraphQLInputObjectType({ + name, + description: astNode.description?.value, + fields: () => buildInputFieldMap(allNodes), + astNode, + extensionASTNodes, + isOneOf: isOneOf(astNode), + }); + } + } + } + }); +} +const stdTypeMap = new Map([...specifiedScalarTypes, ...introspectionTypes].map((type) => [ + type.name, + type, +])); +/** + * Given a field or enum value node, returns the string value for the + * deprecation reason. + */ +function getDeprecationReason(node) { + const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node); + // @ts-expect-error validated by `getDirectiveValues` + return deprecated?.reason; +} +/** + * Given a scalar node, returns the string value for the specifiedByURL. + */ +function getSpecifiedByURL(node) { + const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node); + // @ts-expect-error validated by `getDirectiveValues` + return specifiedBy?.url; +} +/** + * Given an input object node, returns if the node should be OneOf. + */ +function isOneOf(node) { + return Boolean(getDirectiveValues(GraphQLOneOfDirective, node)); +} +//# sourceMappingURL=extendSchema.js.map \ No newline at end of file diff --git a/utilities/extendSchema.mjs.map b/utilities/extendSchema.mjs.map new file mode 100644 index 0000000000..be5ee7d984 --- /dev/null +++ b/utilities/extendSchema.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"extendSchema.js","sourceRoot":"","sources":["../../src/utilities/extendSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAC9D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AA2BpD,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAU5C,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,+BAA8B;AAC/B,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,GAC5B,+BAA8B;AAC/B,OAAO,EAAE,kBAAkB,EAAE,kCAAiC;AAC9D,OAAO,EAAE,oBAAoB,EA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AC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC7D,IAAI,CAAC,IAAI;IACT,IAAI;CACL,CAAC,CACH,CAAC;AAEF;;;GAGG;AACH,SAAS,oBAAoB,CAC3B,IAG4B;IAE5B,MAAM,UAAU,GAAG,kBAAkB,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAAC;IACxE,qDAAqD;IACrD,OAAO,UAAU,EAAE,MAAM,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CACxB,IAAwD;IAExD,MAAM,WAAW,GAAG,kBAAkB,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;IAC1E,qDAAqD;IACrD,OAAO,WAAW,EAAE,GAAG,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,IAAmC;IAClD,OAAO,OAAO,CAAC,kBAAkB,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { AccumulatorMap } from '../jsutils/AccumulatorMap.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n DirectiveDefinitionNode,\n DocumentNode,\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n EnumValueDefinitionNode,\n FieldDefinitionNode,\n InputObjectTypeDefinitionNode,\n InputObjectTypeExtensionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n InterfaceTypeExtensionNode,\n NamedTypeNode,\n ObjectTypeDefinitionNode,\n ObjectTypeExtensionNode,\n ScalarTypeDefinitionNode,\n ScalarTypeExtensionNode,\n SchemaDefinitionNode,\n SchemaExtensionNode,\n TypeDefinitionNode,\n TypeNode,\n UnionTypeDefinitionNode,\n UnionTypeExtensionNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type {\n GraphQLEnumValueNormalizedConfigMap,\n GraphQLFieldConfigArgumentMap,\n GraphQLFieldNormalizedConfigMap,\n GraphQLInputFieldNormalizedConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.js';\nimport {\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n} from '../type/definition.js';\nimport {\n GraphQLDeprecatedDirective,\n GraphQLDirective,\n GraphQLOneOfDirective,\n GraphQLSpecifiedByDirective,\n} from '../type/directives.js';\nimport { introspectionTypes } from '../type/introspection.js';\nimport { specifiedScalarTypes } from '../type/scalars.js';\nimport type {\n GraphQLSchemaNormalizedConfig,\n GraphQLSchemaValidationOptions,\n} from '../type/schema.js';\nimport { assertSchema, GraphQLSchema } from '../type/schema.js';\n\nimport { assertValidSDLExtension } from '../validation/validate.js';\n\nimport { getDirectiveValues } from '../execution/values.js';\n\nimport { mapSchemaConfig, SchemaElementKind } from './mapSchemaConfig.js';\n\ninterface Options extends GraphQLSchemaValidationOptions {\n /**\n * Set to true to assume the SDL is valid.\n *\n * Default: false\n */\n assumeValidSDL?: boolean | undefined;\n}\n\n/**\n * Produces a new schema given an existing schema and a document which may\n * contain GraphQL type extensions and definitions. The original schema will\n * remain unaltered.\n *\n * Because a schema represents a graph of references, a schema cannot be\n * extended without effectively making an entire copy. We do not know until it's\n * too late if subgraphs remain unchanged.\n *\n * This algorithm copies the provided schema, applying extensions while\n * producing the copy. The original schema remains unaltered.\n */\nexport function extendSchema(\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n options?: Options,\n): GraphQLSchema {\n assertSchema(schema);\n\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDLExtension(documentAST, schema);\n }\n\n const schemaConfig = schema.toConfig();\n const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options);\n return schemaConfig === extendedConfig\n ? schema\n : new GraphQLSchema(extendedConfig);\n}\n\n/**\n * @internal\n */\nexport function extendSchemaImpl(\n schemaConfig: GraphQLSchemaNormalizedConfig,\n documentAST: DocumentNode,\n options?: Options,\n): GraphQLSchemaNormalizedConfig {\n // Collect the type definitions and extensions found in the document.\n const typeDefs: Array = [];\n\n const scalarExtensions = new AccumulatorMap<\n string,\n ScalarTypeExtensionNode\n >();\n const objectExtensions = new AccumulatorMap<\n string,\n ObjectTypeExtensionNode\n >();\n const interfaceExtensions = new AccumulatorMap<\n string,\n InterfaceTypeExtensionNode\n >();\n const unionExtensions = new AccumulatorMap();\n const enumExtensions = new AccumulatorMap();\n const inputObjectExtensions = new AccumulatorMap<\n string,\n InputObjectTypeExtensionNode\n >();\n\n // New directives and types are separate because a directives and types can\n // have the same name. For example, a type named \"skip\".\n const directiveDefs: Array = [];\n\n let schemaDef: Maybe;\n // Schema extensions are collected which may add additional operation types.\n const schemaExtensions: Array = [];\n\n let isSchemaChanged = false;\n for (const def of documentAST.definitions) {\n switch (def.kind) {\n case Kind.SCHEMA_DEFINITION:\n schemaDef = def;\n break;\n case Kind.SCHEMA_EXTENSION:\n schemaExtensions.push(def);\n break;\n case Kind.DIRECTIVE_DEFINITION:\n directiveDefs.push(def);\n break;\n\n // Type Definitions\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.INTERFACE_TYPE_DEFINITION:\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n typeDefs.push(def);\n break;\n\n // Type System Extensions\n case Kind.SCALAR_TYPE_EXTENSION:\n scalarExtensions.add(def.name.value, def);\n break;\n case Kind.OBJECT_TYPE_EXTENSION:\n objectExtensions.add(def.name.value, def);\n break;\n case Kind.INTERFACE_TYPE_EXTENSION:\n interfaceExtensions.add(def.name.value, def);\n break;\n case Kind.UNION_TYPE_EXTENSION:\n unionExtensions.add(def.name.value, def);\n break;\n case Kind.ENUM_TYPE_EXTENSION:\n enumExtensions.add(def.name.value, def);\n break;\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n inputObjectExtensions.add(def.name.value, def);\n break;\n default:\n continue;\n }\n isSchemaChanged = true;\n }\n\n // If this document contains no new types, extensions, or directives then\n // return the same unmodified GraphQLSchema instance.\n if (!isSchemaChanged) {\n return schemaConfig;\n }\n\n return mapSchemaConfig(schemaConfig, (context) => {\n const { getNamedType, setNamedType, getNamedTypes } = context;\n return {\n [SchemaElementKind.SCHEMA]: (config) => {\n for (const typeNode of typeDefs) {\n const type =\n stdTypeMap.get(typeNode.name.value) ?? buildNamedType(typeNode);\n setNamedType(type);\n }\n\n const operationTypes = {\n // Get the extended root operation types.\n query:\n config.query &&\n (getNamedType(config.query.name) as GraphQLObjectType),\n mutation:\n config.mutation &&\n (getNamedType(config.mutation.name) as GraphQLObjectType),\n subscription:\n config.subscription &&\n (getNamedType(config.subscription.name) as GraphQLObjectType),\n // Then, incorporate schema definition and all schema extensions.\n ...(schemaDef && getOperationTypes([schemaDef])),\n ...getOperationTypes(schemaExtensions),\n };\n\n // Then produce and return a Schema config with these types.\n return {\n description: schemaDef?.description?.value ?? config.description,\n ...operationTypes,\n types: getNamedTypes(),\n directives: [\n ...config.directives,\n ...directiveDefs.map(buildDirective),\n ],\n extensions: config.extensions,\n astNode: schemaDef ?? config.astNode,\n extensionASTNodes: config.extensionASTNodes.concat(schemaExtensions),\n assumeValid: options?.assumeValid ?? false,\n };\n },\n [SchemaElementKind.INPUT_OBJECT]: (config) => {\n const extensions = inputObjectExtensions.get(config.name) ?? [];\n return {\n ...config,\n fields: () => ({\n ...config.fields(),\n ...buildInputFieldMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.ENUM]: (config) => {\n const extensions = enumExtensions.get(config.name) ?? [];\n return {\n ...config,\n values: () => ({\n ...config.values(),\n ...buildEnumValueMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.SCALAR]: (config) => {\n const extensions = scalarExtensions.get(config.name) ?? [];\n let specifiedByURL = config.specifiedByURL;\n for (const extensionNode of extensions) {\n specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL;\n }\n return {\n ...config,\n specifiedByURL,\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.OBJECT]: (config) => {\n const extensions = objectExtensions.get(config.name) ?? [];\n return {\n ...config,\n interfaces: () => [\n ...config.interfaces(),\n ...buildInterfaces(extensions),\n ],\n fields: () => ({\n ...config.fields(),\n ...buildFieldMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.INTERFACE]: (config) => {\n const extensions = interfaceExtensions.get(config.name) ?? [];\n return {\n ...config,\n interfaces: () => [\n ...config.interfaces(),\n ...buildInterfaces(extensions),\n ],\n fields: () => ({\n ...config.fields(),\n ...buildFieldMap(extensions),\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n [SchemaElementKind.UNION]: (config) => {\n const extensions = unionExtensions.get(config.name) ?? [];\n return {\n ...config,\n types: () => [...config.types(), ...buildUnionTypes(extensions)],\n extensionASTNodes: config.extensionASTNodes.concat(extensions),\n };\n },\n };\n\n function getOperationTypes(\n nodes: ReadonlyArray,\n ): {\n query?: Maybe;\n mutation?: Maybe;\n subscription?: Maybe;\n } {\n const opTypes = {};\n for (const node of nodes) {\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n // @ts-expect-error\n opTypes[operationType.operation] = namedTypeFromAST(\n operationType.type,\n );\n }\n }\n\n return opTypes;\n }\n\n function namedTypeFromAST(node: NamedTypeNode): GraphQLNamedType {\n const name = node.name.value;\n const type = getNamedType(name);\n invariant(type !== undefined, `Unknown type: \"${name}\".`);\n return type;\n }\n\n function typeFromAST(node: TypeNode): GraphQLType {\n if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(typeFromAST(node.type));\n }\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(typeFromAST(node.type));\n }\n return namedTypeFromAST(node);\n }\n\n function buildDirective(node: DirectiveDefinitionNode): GraphQLDirective {\n return new GraphQLDirective({\n name: node.name.value,\n description: node.description?.value,\n // @ts-expect-error\n locations: node.locations.map(({ value }) => value),\n isRepeatable: node.repeatable,\n args: buildArgumentMap(node.arguments),\n astNode: node,\n });\n }\n\n function buildFieldMap(\n nodes: ReadonlyArray<\n | InterfaceTypeDefinitionNode\n | InterfaceTypeExtensionNode\n | ObjectTypeDefinitionNode\n | ObjectTypeExtensionNode\n >,\n ): GraphQLFieldNormalizedConfigMap {\n const fieldConfigMap = Object.create(null);\n for (const node of nodes) {\n const nodeFields = node.fields ?? [];\n\n for (const field of nodeFields) {\n fieldConfigMap[field.name.value] = {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n type: typeFromAST(field.type),\n description: field.description?.value,\n args: buildArgumentMap(field.arguments),\n deprecationReason: getDeprecationReason(field),\n astNode: field,\n };\n }\n }\n return fieldConfigMap;\n }\n\n function buildArgumentMap(\n args: Maybe>,\n ): GraphQLFieldConfigArgumentMap {\n const argsNodes = args ?? [];\n\n const argConfigMap = Object.create(null);\n for (const arg of argsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type: any = typeFromAST(arg.type);\n\n argConfigMap[arg.name.value] = {\n type,\n description: arg.description?.value,\n default: arg.defaultValue && { literal: arg.defaultValue },\n deprecationReason: getDeprecationReason(arg),\n astNode: arg,\n };\n }\n return argConfigMap;\n }\n\n function buildInputFieldMap(\n nodes: ReadonlyArray<\n InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode\n >,\n ): GraphQLInputFieldNormalizedConfigMap {\n const inputFieldMap = Object.create(null);\n for (const node of nodes) {\n const fieldsNodes = node.fields ?? [];\n\n for (const field of fieldsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type: any = typeFromAST(field.type);\n\n inputFieldMap[field.name.value] = {\n type,\n description: field.description?.value,\n default: field.defaultValue && { literal: field.defaultValue },\n deprecationReason: getDeprecationReason(field),\n astNode: field,\n };\n }\n }\n return inputFieldMap;\n }\n\n function buildEnumValueMap(\n nodes: ReadonlyArray,\n ): GraphQLEnumValueNormalizedConfigMap {\n const enumValueMap = Object.create(null);\n for (const node of nodes) {\n const valuesNodes = node.values ?? [];\n\n for (const value of valuesNodes) {\n enumValueMap[value.name.value] = {\n description: value.description?.value,\n deprecationReason: getDeprecationReason(value),\n astNode: value,\n };\n }\n }\n return enumValueMap;\n }\n\n function buildInterfaces(\n nodes: ReadonlyArray<\n | InterfaceTypeDefinitionNode\n | InterfaceTypeExtensionNode\n | ObjectTypeDefinitionNode\n | ObjectTypeExtensionNode\n >,\n ): Array {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n // @ts-expect-error\n return nodes.flatMap(\n (node) => node.interfaces?.map(namedTypeFromAST) ?? [],\n );\n }\n\n function buildUnionTypes(\n nodes: ReadonlyArray,\n ): Array {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n // @ts-expect-error\n return nodes.flatMap((node) => node.types?.map(namedTypeFromAST) ?? []);\n }\n\n function buildNamedType(astNode: TypeDefinitionNode): GraphQLNamedType {\n const name = astNode.name.value;\n\n switch (astNode.kind) {\n case Kind.OBJECT_TYPE_DEFINITION: {\n const extensionASTNodes = objectExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLObjectType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.INTERFACE_TYPE_DEFINITION: {\n const extensionASTNodes = interfaceExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLInterfaceType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.ENUM_TYPE_DEFINITION: {\n const extensionASTNodes = enumExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLEnumType({\n name,\n description: astNode.description?.value,\n values: () => buildEnumValueMap(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.UNION_TYPE_DEFINITION: {\n const extensionASTNodes = unionExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLUnionType({\n name,\n description: astNode.description?.value,\n types: () => buildUnionTypes(allNodes),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.SCALAR_TYPE_DEFINITION: {\n const extensionASTNodes = scalarExtensions.get(name) ?? [];\n return new GraphQLScalarType({\n name,\n description: astNode.description?.value,\n specifiedByURL: getSpecifiedByURL(astNode),\n astNode,\n extensionASTNodes,\n });\n }\n case Kind.INPUT_OBJECT_TYPE_DEFINITION: {\n const extensionASTNodes = inputObjectExtensions.get(name) ?? [];\n const allNodes = [astNode, ...extensionASTNodes];\n\n return new GraphQLInputObjectType({\n name,\n description: astNode.description?.value,\n fields: () => buildInputFieldMap(allNodes),\n astNode,\n extensionASTNodes,\n isOneOf: isOneOf(astNode),\n });\n }\n }\n }\n });\n}\n\nconst stdTypeMap = new Map(\n [...specifiedScalarTypes, ...introspectionTypes].map((type) => [\n type.name,\n type,\n ]),\n);\n\n/**\n * Given a field or enum value node, returns the string value for the\n * deprecation reason.\n */\nfunction getDeprecationReason(\n node:\n | EnumValueDefinitionNode\n | FieldDefinitionNode\n | InputValueDefinitionNode,\n): Maybe {\n const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node);\n // @ts-expect-error validated by `getDirectiveValues`\n return deprecated?.reason;\n}\n\n/**\n * Given a scalar node, returns the string value for the specifiedByURL.\n */\nfunction getSpecifiedByURL(\n node: ScalarTypeDefinitionNode | ScalarTypeExtensionNode,\n): Maybe {\n const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node);\n // @ts-expect-error validated by `getDirectiveValues`\n return specifiedBy?.url;\n}\n\n/**\n * Given an input object node, returns if the node should be OneOf.\n */\nfunction isOneOf(node: InputObjectTypeDefinitionNode): boolean {\n return Boolean(getDirectiveValues(GraphQLOneOfDirective, node));\n}\n"]} \ No newline at end of file diff --git a/utilities/findSchemaChanges.d.ts b/utilities/findSchemaChanges.d.ts new file mode 100644 index 0000000000..894c18bf2f --- /dev/null +++ b/utilities/findSchemaChanges.d.ts @@ -0,0 +1,72 @@ +import type { GraphQLSchema } from '../type/schema.js'; +export declare const BreakingChangeType: { + readonly TYPE_REMOVED: "TYPE_REMOVED"; + readonly TYPE_CHANGED_KIND: "TYPE_CHANGED_KIND"; + readonly TYPE_REMOVED_FROM_UNION: "TYPE_REMOVED_FROM_UNION"; + readonly VALUE_REMOVED_FROM_ENUM: "VALUE_REMOVED_FROM_ENUM"; + readonly REQUIRED_INPUT_FIELD_ADDED: "REQUIRED_INPUT_FIELD_ADDED"; + readonly IMPLEMENTED_INTERFACE_REMOVED: "IMPLEMENTED_INTERFACE_REMOVED"; + readonly FIELD_REMOVED: "FIELD_REMOVED"; + readonly FIELD_CHANGED_KIND: "FIELD_CHANGED_KIND"; + readonly REQUIRED_ARG_ADDED: "REQUIRED_ARG_ADDED"; + readonly ARG_REMOVED: "ARG_REMOVED"; + readonly ARG_CHANGED_KIND: "ARG_CHANGED_KIND"; + readonly DIRECTIVE_REMOVED: "DIRECTIVE_REMOVED"; + readonly DIRECTIVE_ARG_REMOVED: "DIRECTIVE_ARG_REMOVED"; + readonly REQUIRED_DIRECTIVE_ARG_ADDED: "REQUIRED_DIRECTIVE_ARG_ADDED"; + readonly DIRECTIVE_REPEATABLE_REMOVED: "DIRECTIVE_REPEATABLE_REMOVED"; + readonly DIRECTIVE_LOCATION_REMOVED: "DIRECTIVE_LOCATION_REMOVED"; +}; +export type BreakingChangeType = (typeof BreakingChangeType)[keyof typeof BreakingChangeType]; +export declare const DangerousChangeType: { + VALUE_ADDED_TO_ENUM: "VALUE_ADDED_TO_ENUM"; + TYPE_ADDED_TO_UNION: "TYPE_ADDED_TO_UNION"; + OPTIONAL_INPUT_FIELD_ADDED: "OPTIONAL_INPUT_FIELD_ADDED"; + OPTIONAL_ARG_ADDED: "OPTIONAL_ARG_ADDED"; + IMPLEMENTED_INTERFACE_ADDED: "IMPLEMENTED_INTERFACE_ADDED"; + ARG_DEFAULT_VALUE_CHANGE: "ARG_DEFAULT_VALUE_CHANGE"; +}; +export type DangerousChangeType = (typeof DangerousChangeType)[keyof typeof DangerousChangeType]; +export declare const SafeChangeType: { + DESCRIPTION_CHANGED: "DESCRIPTION_CHANGED"; + TYPE_ADDED: "TYPE_ADDED"; + OPTIONAL_INPUT_FIELD_ADDED: "OPTIONAL_INPUT_FIELD_ADDED"; + OPTIONAL_ARG_ADDED: "OPTIONAL_ARG_ADDED"; + DIRECTIVE_ADDED: "DIRECTIVE_ADDED"; + FIELD_ADDED: "FIELD_ADDED"; + DIRECTIVE_REPEATABLE_ADDED: "DIRECTIVE_REPEATABLE_ADDED"; + DIRECTIVE_LOCATION_ADDED: "DIRECTIVE_LOCATION_ADDED"; + OPTIONAL_DIRECTIVE_ARG_ADDED: "OPTIONAL_DIRECTIVE_ARG_ADDED"; + FIELD_CHANGED_KIND_SAFE: "FIELD_CHANGED_KIND_SAFE"; + ARG_CHANGED_KIND_SAFE: "ARG_CHANGED_KIND_SAFE"; + ARG_DEFAULT_VALUE_ADDED: "ARG_DEFAULT_VALUE_ADDED"; +}; +export type SafeChangeType = (typeof SafeChangeType)[keyof typeof SafeChangeType]; +export interface BreakingChange { + type: BreakingChangeType; + description: string; +} +export interface DangerousChange { + type: DangerousChangeType; + description: string; +} +export interface SafeChange { + type: SafeChangeType; + description: string; +} +export type SchemaChange = SafeChange | DangerousChange | BreakingChange; +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of breaking changes covered by the other functions down below. + * + * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18. + */ +export declare function findBreakingChanges(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array; +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of potentially dangerous changes covered by the other functions down below. + * + * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18. + */ +export declare function findDangerousChanges(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array; +export declare function findSchemaChanges(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array; diff --git a/utilities/findSchemaChanges.js b/utilities/findSchemaChanges.js new file mode 100644 index 0000000000..6c52809ff4 --- /dev/null +++ b/utilities/findSchemaChanges.js @@ -0,0 +1,560 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SafeChangeType = exports.DangerousChangeType = exports.BreakingChangeType = void 0; +exports.findBreakingChanges = findBreakingChanges; +exports.findDangerousChanges = findDangerousChanges; +exports.findSchemaChanges = findSchemaChanges; +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const keyMap_js_1 = require("../jsutils/keyMap.js"); +const printer_js_1 = require("../language/printer.js"); +const definition_js_1 = require("../type/definition.js"); +const scalars_js_1 = require("../type/scalars.js"); +const getDefaultValueAST_js_1 = require("./getDefaultValueAST.js"); +const sortValueNode_js_1 = require("./sortValueNode.js"); +exports.BreakingChangeType = { + TYPE_REMOVED: 'TYPE_REMOVED', + TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND', + TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION', + VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM', + REQUIRED_INPUT_FIELD_ADDED: 'REQUIRED_INPUT_FIELD_ADDED', + IMPLEMENTED_INTERFACE_REMOVED: 'IMPLEMENTED_INTERFACE_REMOVED', + FIELD_REMOVED: 'FIELD_REMOVED', + FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND', + REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED', + ARG_REMOVED: 'ARG_REMOVED', + ARG_CHANGED_KIND: 'ARG_CHANGED_KIND', + DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED', + DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED', + REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED', + DIRECTIVE_REPEATABLE_REMOVED: 'DIRECTIVE_REPEATABLE_REMOVED', + DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED', +}; +exports.DangerousChangeType = { + VALUE_ADDED_TO_ENUM: 'VALUE_ADDED_TO_ENUM', + TYPE_ADDED_TO_UNION: 'TYPE_ADDED_TO_UNION', + OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED', + OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED', + IMPLEMENTED_INTERFACE_ADDED: 'IMPLEMENTED_INTERFACE_ADDED', + ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE', +}; +exports.SafeChangeType = { + DESCRIPTION_CHANGED: 'DESCRIPTION_CHANGED', + TYPE_ADDED: 'TYPE_ADDED', + OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED', + OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED', + DIRECTIVE_ADDED: 'DIRECTIVE_ADDED', + FIELD_ADDED: 'FIELD_ADDED', + DIRECTIVE_REPEATABLE_ADDED: 'DIRECTIVE_REPEATABLE_ADDED', + DIRECTIVE_LOCATION_ADDED: 'DIRECTIVE_LOCATION_ADDED', + OPTIONAL_DIRECTIVE_ARG_ADDED: 'OPTIONAL_DIRECTIVE_ARG_ADDED', + FIELD_CHANGED_KIND_SAFE: 'FIELD_CHANGED_KIND_SAFE', + ARG_CHANGED_KIND_SAFE: 'ARG_CHANGED_KIND_SAFE', + ARG_DEFAULT_VALUE_ADDED: 'ARG_DEFAULT_VALUE_ADDED', +}; +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of breaking changes covered by the other functions down below. + * + * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18. + */ +function findBreakingChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter((change) => change.type in exports.BreakingChangeType); +} +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of potentially dangerous changes covered by the other functions down below. + * + * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18. + */ +function findDangerousChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter((change) => change.type in exports.DangerousChangeType); +} +function findSchemaChanges(oldSchema, newSchema) { + return [ + ...findTypeChanges(oldSchema, newSchema), + ...findDirectiveChanges(oldSchema, newSchema), + ]; +} +function findDirectiveChanges(oldSchema, newSchema) { + const schemaChanges = []; + const directivesDiff = diff(oldSchema.getDirectives(), newSchema.getDirectives()); + for (const oldDirective of directivesDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.DIRECTIVE_REMOVED, + description: `Directive ${oldDirective} was removed.`, + }); + } + for (const newDirective of directivesDiff.added) { + schemaChanges.push({ + type: exports.SafeChangeType.DIRECTIVE_ADDED, + description: `Directive @${newDirective.name} was added.`, + }); + } + for (const [oldDirective, newDirective] of directivesDiff.persisted) { + const argsDiff = diff(oldDirective.args, newDirective.args); + for (const newArg of argsDiff.added) { + if ((0, definition_js_1.isRequiredArgument)(newArg)) { + schemaChanges.push({ + type: exports.BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, + description: `A required argument ${newArg} was added.`, + }); + } + else { + schemaChanges.push({ + type: exports.SafeChangeType.OPTIONAL_DIRECTIVE_ARG_ADDED, + description: `An optional argument @${oldDirective.name}(${newArg.name}:) was added.`, + }); + } + } + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.DIRECTIVE_ARG_REMOVED, + description: `Argument ${oldArg} was removed.`, + }); + } + for (const [oldArg, newArg] of argsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldArg.type, newArg.type); + const oldDefaultValueStr = getDefaultValue(oldArg); + const newDefaultValueStr = getDefaultValue(newArg); + if (!isSafe) { + schemaChanges.push({ + type: exports.BreakingChangeType.ARG_CHANGED_KIND, + description: `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } + else if (oldDefaultValueStr !== undefined) { + if (newDefaultValueStr === undefined) { + schemaChanges.push({ + type: exports.DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `@${oldDirective.name}(${oldArg.name}:) defaultValue was removed.`, + }); + } + else if (oldDefaultValueStr !== newDefaultValueStr) { + schemaChanges.push({ + type: exports.DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `@${oldDirective.name}(${oldArg.name}:) has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`, + }); + } + } + else if (newDefaultValueStr !== undefined && + oldDefaultValueStr === undefined) { + schemaChanges.push({ + type: exports.SafeChangeType.ARG_DEFAULT_VALUE_ADDED, + description: `@${oldDirective.name}(${oldArg.name}:) added a defaultValue ${newDefaultValueStr}.`, + }); + } + else if (oldArg.type.toString() !== newArg.type.toString()) { + schemaChanges.push({ + type: exports.SafeChangeType.ARG_CHANGED_KIND_SAFE, + description: `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } + if (oldArg.description !== newArg.description) { + schemaChanges.push({ + type: exports.SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of @${oldDirective.name}(${oldDirective.name}) has changed to "${newArg.description}".`, + }); + } + } + if (oldDirective.isRepeatable && !newDirective.isRepeatable) { + schemaChanges.push({ + type: exports.BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, + description: `Repeatable flag was removed from ${oldDirective}.`, + }); + } + else if (newDirective.isRepeatable && !oldDirective.isRepeatable) { + schemaChanges.push({ + type: exports.SafeChangeType.DIRECTIVE_REPEATABLE_ADDED, + description: `Repeatable flag was added to @${oldDirective.name}.`, + }); + } + if (oldDirective.description !== newDirective.description) { + schemaChanges.push({ + type: exports.SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of @${oldDirective.name} has changed to "${newDirective.description}".`, + }); + } + for (const location of oldDirective.locations) { + if (!newDirective.locations.includes(location)) { + schemaChanges.push({ + type: exports.BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, + description: `${location} was removed from ${oldDirective}.`, + }); + } + } + for (const location of newDirective.locations) { + if (!oldDirective.locations.includes(location)) { + schemaChanges.push({ + type: exports.SafeChangeType.DIRECTIVE_LOCATION_ADDED, + description: `${location} was added to @${oldDirective.name}.`, + }); + } + } + } + return schemaChanges; +} +function findTypeChanges(oldSchema, newSchema) { + const schemaChanges = []; + const typesDiff = diff(Object.values(oldSchema.getTypeMap()), Object.values(newSchema.getTypeMap())); + for (const oldType of typesDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.TYPE_REMOVED, + description: (0, scalars_js_1.isSpecifiedScalarType)(oldType) + ? `Standard scalar ${oldType} was removed because it is not referenced anymore.` + : `${oldType} was removed.`, + }); + } + for (const newType of typesDiff.added) { + schemaChanges.push({ + type: exports.SafeChangeType.TYPE_ADDED, + description: `${newType} was added.`, + }); + } + for (const [oldType, newType] of typesDiff.persisted) { + if (oldType.description !== newType.description) { + schemaChanges.push({ + type: exports.SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of ${oldType.name} has changed to "${newType.description}".`, + }); + } + if ((0, definition_js_1.isEnumType)(oldType) && (0, definition_js_1.isEnumType)(newType)) { + schemaChanges.push(...findEnumTypeChanges(oldType, newType)); + } + else if ((0, definition_js_1.isUnionType)(oldType) && (0, definition_js_1.isUnionType)(newType)) { + schemaChanges.push(...findUnionTypeChanges(oldType, newType)); + } + else if ((0, definition_js_1.isInputObjectType)(oldType) && (0, definition_js_1.isInputObjectType)(newType)) { + schemaChanges.push(...findInputObjectTypeChanges(oldType, newType)); + } + else if ((0, definition_js_1.isObjectType)(oldType) && (0, definition_js_1.isObjectType)(newType)) { + schemaChanges.push(...findFieldChanges(oldType, newType), ...findImplementedInterfacesChanges(oldType, newType)); + } + else if ((0, definition_js_1.isInterfaceType)(oldType) && (0, definition_js_1.isInterfaceType)(newType)) { + schemaChanges.push(...findFieldChanges(oldType, newType), ...findImplementedInterfacesChanges(oldType, newType)); + } + else if (oldType.constructor !== newType.constructor) { + schemaChanges.push({ + type: exports.BreakingChangeType.TYPE_CHANGED_KIND, + description: `${oldType} changed from ${typeKindName(oldType)} to ${typeKindName(newType)}.`, + }); + } + } + return schemaChanges; +} +function findInputObjectTypeChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff(Object.values(oldType.getFields()), Object.values(newType.getFields())); + for (const newField of fieldsDiff.added) { + if ((0, definition_js_1.isRequiredInputField)(newField)) { + schemaChanges.push({ + type: exports.BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, + description: `A required field ${newField} was added.`, + }); + } + else { + schemaChanges.push({ + type: exports.DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, + description: `An optional field ${newField} was added.`, + }); + } + } + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.FIELD_REMOVED, + description: `Field ${oldField} was removed.`, + }); + } + for (const [oldField, newField] of fieldsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldField.type, newField.type); + if (!isSafe) { + schemaChanges.push({ + type: exports.BreakingChangeType.FIELD_CHANGED_KIND, + description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`, + }); + } + else if (oldField.type.toString() !== newField.type.toString()) { + schemaChanges.push({ + type: exports.SafeChangeType.FIELD_CHANGED_KIND_SAFE, + description: `Field ${oldType}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + if (oldField.description !== newField.description) { + schemaChanges.push({ + type: exports.SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of input-field ${newType}.${newField.name} has changed to "${newField.description}".`, + }); + } + } + return schemaChanges; +} +function findUnionTypeChanges(oldType, newType) { + const schemaChanges = []; + const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes()); + for (const newPossibleType of possibleTypesDiff.added) { + schemaChanges.push({ + type: exports.DangerousChangeType.TYPE_ADDED_TO_UNION, + description: `${newPossibleType} was added to union type ${oldType}.`, + }); + } + for (const oldPossibleType of possibleTypesDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.TYPE_REMOVED_FROM_UNION, + description: `${oldPossibleType} was removed from union type ${oldType}.`, + }); + } + return schemaChanges; +} +function findEnumTypeChanges(oldType, newType) { + const schemaChanges = []; + const valuesDiff = diff(oldType.getValues(), newType.getValues()); + for (const newValue of valuesDiff.added) { + schemaChanges.push({ + type: exports.DangerousChangeType.VALUE_ADDED_TO_ENUM, + description: `Enum value ${newValue} was added.`, + }); + } + for (const oldValue of valuesDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.VALUE_REMOVED_FROM_ENUM, + description: `Enum value ${oldValue} was removed.`, + }); + } + for (const [oldValue, newValue] of valuesDiff.persisted) { + if (oldValue.description !== newValue.description) { + schemaChanges.push({ + type: exports.SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of enum value ${oldType}.${oldValue.name} has changed to "${newValue.description}".`, + }); + } + } + return schemaChanges; +} +function findImplementedInterfacesChanges(oldType, newType) { + const schemaChanges = []; + const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces()); + for (const newInterface of interfacesDiff.added) { + schemaChanges.push({ + type: exports.DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, + description: `${newInterface} added to interfaces implemented by ${oldType}.`, + }); + } + for (const oldInterface of interfacesDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, + description: `${oldType} no longer implements interface ${oldInterface}.`, + }); + } + return schemaChanges; +} +function findFieldChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff(Object.values(oldType.getFields()), Object.values(newType.getFields())); + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.FIELD_REMOVED, + description: `Field ${oldField} was removed.`, + }); + } + for (const newField of fieldsDiff.added) { + schemaChanges.push({ + type: exports.SafeChangeType.FIELD_ADDED, + description: `Field ${oldType}.${newField.name} was added.`, + }); + } + for (const [oldField, newField] of fieldsDiff.persisted) { + schemaChanges.push(...findArgChanges(oldField, newField)); + const isSafe = isChangeSafeForObjectOrInterfaceField(oldField.type, newField.type); + if (!isSafe) { + schemaChanges.push({ + type: exports.BreakingChangeType.FIELD_CHANGED_KIND, + description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`, + }); + } + else if (oldField.type.toString() !== newField.type.toString()) { + schemaChanges.push({ + type: exports.SafeChangeType.FIELD_CHANGED_KIND_SAFE, + description: `Field ${oldType}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + if (oldField.description !== newField.description) { + schemaChanges.push({ + type: exports.SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of field ${oldType}.${oldField.name} has changed to "${newField.description}".`, + }); + } + } + return schemaChanges; +} +function findArgChanges(oldField, newField) { + const schemaChanges = []; + const argsDiff = diff(oldField.args, newField.args); + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: exports.BreakingChangeType.ARG_REMOVED, + description: `Argument ${oldArg} was removed.`, + }); + } + for (const [oldArg, newArg] of argsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldArg.type, newArg.type); + const oldDefaultValueStr = getDefaultValue(oldArg); + const newDefaultValueStr = getDefaultValue(newArg); + if (!isSafe) { + schemaChanges.push({ + type: exports.BreakingChangeType.ARG_CHANGED_KIND, + description: `Argument ${newArg} has changed type from ${oldArg.type} to ${newArg.type}.`, + }); + } + else if (oldDefaultValueStr !== undefined) { + if (newDefaultValueStr === undefined) { + schemaChanges.push({ + type: exports.DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldArg} defaultValue was removed.`, + }); + } + else if (oldDefaultValueStr !== newDefaultValueStr) { + schemaChanges.push({ + type: exports.DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldArg} has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`, + }); + } + } + else if (newDefaultValueStr !== undefined && + oldDefaultValueStr === undefined) { + schemaChanges.push({ + type: exports.SafeChangeType.ARG_DEFAULT_VALUE_ADDED, + description: `${oldArg} added a defaultValue ${newDefaultValueStr}.`, + }); + } + else if (oldArg.type.toString() !== newArg.type.toString()) { + schemaChanges.push({ + type: exports.SafeChangeType.ARG_CHANGED_KIND_SAFE, + description: `Argument ${oldArg} has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } + if (oldArg.description !== newArg.description) { + schemaChanges.push({ + type: exports.SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of argument ${oldArg} has changed to "${newArg.description}".`, + }); + } + } + for (const newArg of argsDiff.added) { + if ((0, definition_js_1.isRequiredArgument)(newArg)) { + schemaChanges.push({ + type: exports.BreakingChangeType.REQUIRED_ARG_ADDED, + description: `A required argument ${newArg} was added.`, + }); + } + else { + schemaChanges.push({ + type: exports.DangerousChangeType.OPTIONAL_ARG_ADDED, + description: `An optional argument ${newArg} was added.`, + }); + } + } + return schemaChanges; +} +function isChangeSafeForObjectOrInterfaceField(oldType, newType) { + if ((0, definition_js_1.isListType)(oldType)) { + return ( + // if they're both lists, make sure the underlying types are compatible + ((0, definition_js_1.isListType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType)) || + // moving from nullable to non-null of the same underlying type is safe + ((0, definition_js_1.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))); + } + if ((0, definition_js_1.isNonNullType)(oldType)) { + // if they're both non-null, make sure the underlying types are compatible + return ((0, definition_js_1.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType)); + } + return ( + // if they're both named types, see if their names are equivalent + ((0, definition_js_1.isNamedType)(newType) && oldType.name === newType.name) || + // moving from nullable to non-null of the same underlying type is safe + ((0, definition_js_1.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))); +} +function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) { + if ((0, definition_js_1.isListType)(oldType)) { + // if they're both lists, make sure the underlying types are compatible + return ((0, definition_js_1.isListType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType)); + } + if ((0, definition_js_1.isNonNullType)(oldType)) { + return ( + // if they're both non-null, make sure the underlying types are + // compatible + ((0, definition_js_1.isNonNullType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType)) || + // moving from non-null to nullable of the same underlying type is safe + (!(0, definition_js_1.isNonNullType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType))); + } + // if they're both named types, see if their names are equivalent + return (0, definition_js_1.isNamedType)(newType) && oldType.name === newType.name; +} +function typeKindName(type) { + if ((0, definition_js_1.isScalarType)(type)) { + return 'a Scalar type'; + } + if ((0, definition_js_1.isObjectType)(type)) { + return 'an Object type'; + } + if ((0, definition_js_1.isInterfaceType)(type)) { + return 'an Interface type'; + } + if ((0, definition_js_1.isUnionType)(type)) { + return 'a Union type'; + } + if ((0, definition_js_1.isEnumType)(type)) { + return 'an Enum type'; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + return 'an Input type'; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected type: ' + (0, inspect_js_1.inspect)(type)); +} +// Since we looking only for client's observable changes we should +// compare default values in the same representation as they are +// represented inside introspection. +function getDefaultValue(argOrInputField) { + const ast = (0, getDefaultValueAST_js_1.getDefaultValueAST)(argOrInputField); + if (ast) { + return (0, printer_js_1.print)((0, sortValueNode_js_1.sortValueNode)(ast)); + } +} +function diff(oldArray, newArray) { + const added = []; + const removed = []; + const persisted = []; + const oldMap = (0, keyMap_js_1.keyMap)(oldArray, ({ name }) => name); + const newMap = (0, keyMap_js_1.keyMap)(newArray, ({ name }) => name); + for (const oldItem of oldArray) { + const newItem = newMap[oldItem.name]; + if (newItem === undefined) { + removed.push(oldItem); + } + else { + persisted.push([oldItem, newItem]); + } + } + for (const newItem of newArray) { + if (oldMap[newItem.name] === undefined) { + added.push(newItem); + } + } + return { added, persisted, removed }; +} +//# sourceMappingURL=findSchemaChanges.js.map \ No newline at end of file diff --git a/utilities/findSchemaChanges.js.map b/utilities/findSchemaChanges.js.map new file mode 100644 index 0000000000..5098186453 --- /dev/null +++ b/utilities/findSchemaChanges.js.map @@ -0,0 +1 @@ +{"version":3,"file":"findSchemaChanges.js","sourceRoot":"","sources":["../../src/utilities/findSchemaChanges.ts"],"names":[],"mappings":";;;AAgHA,kDAQC;AAQD,oDAQC;AAED,8CAQC;AAlJD,sDAAgD;AAChD,0DAAoD;AACpD,oDAA8C;AAE9C,uDAA+C;AAc/C,yDAY+B;AAC/B,mDAA2D;AAG3D,mEAA6D;AAC7D,yDAAmD;AAEtC,QAAA,kBAAkB,GAAG;IAChC,YAAY,EAAE,cAAuB;IACrC,iBAAiB,EAAE,mBAA4B;IAC/C,uBAAuB,EAAE,yBAAkC;IAC3D,uBAAuB,EAAE,yBAAkC;IAC3D,0BAA0B,EAAE,4BAAqC;IACjE,6BAA6B,EAAE,+BAAwC;IACvE,aAAa,EAAE,eAAwB;IACvC,kBAAkB,EAAE,oBAA6B;IACjD,kBAAkB,EA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IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { keyMap } from '../jsutils/keyMap.js';\n\nimport { print } from '../language/printer.js';\n\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLType,\n GraphQLUnionType,\n} from '../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isListType,\n isNamedType,\n isNonNullType,\n isObjectType,\n isRequiredArgument,\n isRequiredInputField,\n isScalarType,\n isUnionType,\n} from '../type/definition.js';\nimport { isSpecifiedScalarType } from '../type/scalars.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { getDefaultValueAST } from './getDefaultValueAST.js';\nimport { sortValueNode } from './sortValueNode.js';\n\nexport const BreakingChangeType = {\n TYPE_REMOVED: 'TYPE_REMOVED' as const,\n TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND' as const,\n TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION' as const,\n VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM' as const,\n REQUIRED_INPUT_FIELD_ADDED: 'REQUIRED_INPUT_FIELD_ADDED' as const,\n IMPLEMENTED_INTERFACE_REMOVED: 'IMPLEMENTED_INTERFACE_REMOVED' as const,\n FIELD_REMOVED: 'FIELD_REMOVED' as const,\n FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND' as const,\n REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED' as const,\n ARG_REMOVED: 'ARG_REMOVED' as const,\n ARG_CHANGED_KIND: 'ARG_CHANGED_KIND' as const,\n DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED' as const,\n DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED' as const,\n REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED' as const,\n DIRECTIVE_REPEATABLE_REMOVED: 'DIRECTIVE_REPEATABLE_REMOVED' as const,\n DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type BreakingChangeType =\n (typeof BreakingChangeType)[keyof typeof BreakingChangeType];\n\nexport const DangerousChangeType = {\n VALUE_ADDED_TO_ENUM: 'VALUE_ADDED_TO_ENUM' as const,\n TYPE_ADDED_TO_UNION: 'TYPE_ADDED_TO_UNION' as const,\n OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED' as const,\n OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED' as const,\n IMPLEMENTED_INTERFACE_ADDED: 'IMPLEMENTED_INTERFACE_ADDED' as const,\n ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE' as const,\n};\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type DangerousChangeType =\n (typeof DangerousChangeType)[keyof typeof DangerousChangeType];\n\nexport const SafeChangeType = {\n DESCRIPTION_CHANGED: 'DESCRIPTION_CHANGED' as const,\n TYPE_ADDED: 'TYPE_ADDED' as const,\n OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED' as const,\n OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED' as const,\n DIRECTIVE_ADDED: 'DIRECTIVE_ADDED' as const,\n FIELD_ADDED: 'FIELD_ADDED' as const,\n DIRECTIVE_REPEATABLE_ADDED: 'DIRECTIVE_REPEATABLE_ADDED' as const,\n DIRECTIVE_LOCATION_ADDED: 'DIRECTIVE_LOCATION_ADDED' as const,\n OPTIONAL_DIRECTIVE_ARG_ADDED: 'OPTIONAL_DIRECTIVE_ARG_ADDED' as const,\n FIELD_CHANGED_KIND_SAFE: 'FIELD_CHANGED_KIND_SAFE' as const,\n ARG_CHANGED_KIND_SAFE: 'ARG_CHANGED_KIND_SAFE' as const,\n ARG_DEFAULT_VALUE_ADDED: 'ARG_DEFAULT_VALUE_ADDED' as const,\n};\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type SafeChangeType =\n (typeof SafeChangeType)[keyof typeof SafeChangeType];\n\nexport interface BreakingChange {\n type: BreakingChangeType;\n description: string;\n}\n\nexport interface DangerousChange {\n type: DangerousChangeType;\n description: string;\n}\n\nexport interface SafeChange {\n type: SafeChangeType;\n description: string;\n}\n\nexport type SchemaChange = SafeChange | DangerousChange | BreakingChange;\n\n/**\n * Given two schemas, returns an Array containing descriptions of all the types\n * of breaking changes covered by the other functions down below.\n *\n * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18.\n */\nexport function findBreakingChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n // @ts-expect-error\n return findSchemaChanges(oldSchema, newSchema).filter(\n (change) => change.type in BreakingChangeType,\n );\n}\n\n/**\n * Given two schemas, returns an Array containing descriptions of all the types\n * of potentially dangerous changes covered by the other functions down below.\n *\n * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18.\n */\nexport function findDangerousChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n // @ts-expect-error\n return findSchemaChanges(oldSchema, newSchema).filter(\n (change) => change.type in DangerousChangeType,\n );\n}\n\nexport function findSchemaChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n return [\n ...findTypeChanges(oldSchema, newSchema),\n ...findDirectiveChanges(oldSchema, newSchema),\n ];\n}\n\nfunction findDirectiveChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n const schemaChanges = [];\n\n const directivesDiff = diff(\n oldSchema.getDirectives(),\n newSchema.getDirectives(),\n );\n\n for (const oldDirective of directivesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_REMOVED,\n description: `Directive ${oldDirective} was removed.`,\n });\n }\n\n for (const newDirective of directivesDiff.added) {\n schemaChanges.push({\n type: SafeChangeType.DIRECTIVE_ADDED,\n description: `Directive @${newDirective.name} was added.`,\n });\n }\n\n for (const [oldDirective, newDirective] of directivesDiff.persisted) {\n const argsDiff = diff(oldDirective.args, newDirective.args);\n\n for (const newArg of argsDiff.added) {\n if (isRequiredArgument(newArg)) {\n schemaChanges.push({\n type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED,\n description: `A required argument ${newArg} was added.`,\n });\n } else {\n schemaChanges.push({\n type: SafeChangeType.OPTIONAL_DIRECTIVE_ARG_ADDED,\n description: `An optional argument @${oldDirective.name}(${newArg.name}:) was added.`,\n });\n }\n }\n\n for (const oldArg of argsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_ARG_REMOVED,\n description: `Argument ${oldArg} was removed.`,\n });\n }\n\n for (const [oldArg, newArg] of argsDiff.persisted) {\n const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(\n oldArg.type,\n newArg.type,\n );\n\n const oldDefaultValueStr = getDefaultValue(oldArg);\n const newDefaultValueStr = getDefaultValue(newArg);\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.ARG_CHANGED_KIND,\n description:\n `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` +\n `${String(oldArg.type)} to ${String(newArg.type)}.`,\n });\n } else if (oldDefaultValueStr !== undefined) {\n if (newDefaultValueStr === undefined) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `@${oldDirective.name}(${oldArg.name}:) defaultValue was removed.`,\n });\n } else if (oldDefaultValueStr !== newDefaultValueStr) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `@${oldDirective.name}(${oldArg.name}:) has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`,\n });\n }\n } else if (\n newDefaultValueStr !== undefined &&\n oldDefaultValueStr === undefined\n ) {\n schemaChanges.push({\n type: SafeChangeType.ARG_DEFAULT_VALUE_ADDED,\n description: `@${oldDirective.name}(${oldArg.name}:) added a defaultValue ${newDefaultValueStr}.`,\n });\n } else if (oldArg.type.toString() !== newArg.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.ARG_CHANGED_KIND_SAFE,\n description:\n `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` +\n `${String(oldArg.type)} to ${String(newArg.type)}.`,\n });\n }\n\n if (oldArg.description !== newArg.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of @${oldDirective.name}(${oldDirective.name}) has changed to \"${newArg.description}\".`,\n });\n }\n }\n\n if (oldDirective.isRepeatable && !newDirective.isRepeatable) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED,\n description: `Repeatable flag was removed from ${oldDirective}.`,\n });\n } else if (newDirective.isRepeatable && !oldDirective.isRepeatable) {\n schemaChanges.push({\n type: SafeChangeType.DIRECTIVE_REPEATABLE_ADDED,\n description: `Repeatable flag was added to @${oldDirective.name}.`,\n });\n }\n\n if (oldDirective.description !== newDirective.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of @${oldDirective.name} has changed to \"${newDirective.description}\".`,\n });\n }\n\n for (const location of oldDirective.locations) {\n if (!newDirective.locations.includes(location)) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED,\n description: `${location} was removed from ${oldDirective}.`,\n });\n }\n }\n\n for (const location of newDirective.locations) {\n if (!oldDirective.locations.includes(location)) {\n schemaChanges.push({\n type: SafeChangeType.DIRECTIVE_LOCATION_ADDED,\n description: `${location} was added to @${oldDirective.name}.`,\n });\n }\n }\n }\n\n return schemaChanges;\n}\n\nfunction findTypeChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n const schemaChanges = [];\n\n const typesDiff = diff(\n Object.values(oldSchema.getTypeMap()),\n Object.values(newSchema.getTypeMap()),\n );\n\n for (const oldType of typesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.TYPE_REMOVED,\n description: isSpecifiedScalarType(oldType)\n ? `Standard scalar ${oldType} was removed because it is not referenced anymore.`\n : `${oldType} was removed.`,\n });\n }\n\n for (const newType of typesDiff.added) {\n schemaChanges.push({\n type: SafeChangeType.TYPE_ADDED,\n description: `${newType} was added.`,\n });\n }\n\n for (const [oldType, newType] of typesDiff.persisted) {\n if (oldType.description !== newType.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of ${oldType.name} has changed to \"${newType.description}\".`,\n });\n }\n\n if (isEnumType(oldType) && isEnumType(newType)) {\n schemaChanges.push(...findEnumTypeChanges(oldType, newType));\n } else if (isUnionType(oldType) && isUnionType(newType)) {\n schemaChanges.push(...findUnionTypeChanges(oldType, newType));\n } else if (isInputObjectType(oldType) && isInputObjectType(newType)) {\n schemaChanges.push(...findInputObjectTypeChanges(oldType, newType));\n } else if (isObjectType(oldType) && isObjectType(newType)) {\n schemaChanges.push(\n ...findFieldChanges(oldType, newType),\n ...findImplementedInterfacesChanges(oldType, newType),\n );\n } else if (isInterfaceType(oldType) && isInterfaceType(newType)) {\n schemaChanges.push(\n ...findFieldChanges(oldType, newType),\n ...findImplementedInterfacesChanges(oldType, newType),\n );\n } else if (oldType.constructor !== newType.constructor) {\n schemaChanges.push({\n type: BreakingChangeType.TYPE_CHANGED_KIND,\n description: `${oldType} changed from ${typeKindName(\n oldType,\n )} to ${typeKindName(newType)}.`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findInputObjectTypeChanges(\n oldType: GraphQLInputObjectType,\n newType: GraphQLInputObjectType,\n): Array {\n const schemaChanges = [];\n const fieldsDiff = diff(\n Object.values(oldType.getFields()),\n Object.values(newType.getFields()),\n );\n\n for (const newField of fieldsDiff.added) {\n if (isRequiredInputField(newField)) {\n schemaChanges.push({\n type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED,\n description: `A required field ${newField} was added.`,\n });\n } else {\n schemaChanges.push({\n type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED,\n description: `An optional field ${newField} was added.`,\n });\n }\n }\n\n for (const oldField of fieldsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_REMOVED,\n description: `Field ${oldField} was removed.`,\n });\n }\n\n for (const [oldField, newField] of fieldsDiff.persisted) {\n const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(\n oldField.type,\n newField.type,\n );\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_CHANGED_KIND,\n description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`,\n });\n } else if (oldField.type.toString() !== newField.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.FIELD_CHANGED_KIND_SAFE,\n description:\n `Field ${oldType}.${oldField.name} changed type from ` +\n `${String(oldField.type)} to ${String(newField.type)}.`,\n });\n }\n\n if (oldField.description !== newField.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of input-field ${newType}.${newField.name} has changed to \"${newField.description}\".`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findUnionTypeChanges(\n oldType: GraphQLUnionType,\n newType: GraphQLUnionType,\n): Array {\n const schemaChanges = [];\n const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes());\n\n for (const newPossibleType of possibleTypesDiff.added) {\n schemaChanges.push({\n type: DangerousChangeType.TYPE_ADDED_TO_UNION,\n description: `${newPossibleType} was added to union type ${oldType}.`,\n });\n }\n\n for (const oldPossibleType of possibleTypesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.TYPE_REMOVED_FROM_UNION,\n description: `${oldPossibleType} was removed from union type ${oldType}.`,\n });\n }\n\n return schemaChanges;\n}\n\nfunction findEnumTypeChanges(\n oldType: GraphQLEnumType,\n newType: GraphQLEnumType,\n): Array {\n const schemaChanges = [];\n const valuesDiff = diff(oldType.getValues(), newType.getValues());\n\n for (const newValue of valuesDiff.added) {\n schemaChanges.push({\n type: DangerousChangeType.VALUE_ADDED_TO_ENUM,\n description: `Enum value ${newValue} was added.`,\n });\n }\n\n for (const oldValue of valuesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM,\n description: `Enum value ${oldValue} was removed.`,\n });\n }\n\n for (const [oldValue, newValue] of valuesDiff.persisted) {\n if (oldValue.description !== newValue.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of enum value ${oldType}.${oldValue.name} has changed to \"${newValue.description}\".`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findImplementedInterfacesChanges(\n oldType: GraphQLObjectType | GraphQLInterfaceType,\n newType: GraphQLObjectType | GraphQLInterfaceType,\n): Array {\n const schemaChanges = [];\n const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces());\n\n for (const newInterface of interfacesDiff.added) {\n schemaChanges.push({\n type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED,\n description: `${newInterface} added to interfaces implemented by ${oldType}.`,\n });\n }\n\n for (const oldInterface of interfacesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED,\n description: `${oldType} no longer implements interface ${oldInterface}.`,\n });\n }\n\n return schemaChanges;\n}\n\nfunction findFieldChanges(\n oldType: GraphQLObjectType | GraphQLInterfaceType,\n newType: GraphQLObjectType | GraphQLInterfaceType,\n): Array {\n const schemaChanges = [];\n const fieldsDiff = diff(\n Object.values(oldType.getFields()),\n Object.values(newType.getFields()),\n );\n\n for (const oldField of fieldsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_REMOVED,\n description: `Field ${oldField} was removed.`,\n });\n }\n\n for (const newField of fieldsDiff.added) {\n schemaChanges.push({\n type: SafeChangeType.FIELD_ADDED,\n description: `Field ${oldType}.${newField.name} was added.`,\n });\n }\n\n for (const [oldField, newField] of fieldsDiff.persisted) {\n schemaChanges.push(...findArgChanges(oldField, newField));\n\n const isSafe = isChangeSafeForObjectOrInterfaceField(\n oldField.type,\n newField.type,\n );\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_CHANGED_KIND,\n description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`,\n });\n } else if (oldField.type.toString() !== newField.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.FIELD_CHANGED_KIND_SAFE,\n description:\n `Field ${oldType}.${oldField.name} changed type from ` +\n `${String(oldField.type)} to ${String(newField.type)}.`,\n });\n }\n\n if (oldField.description !== newField.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of field ${oldType}.${oldField.name} has changed to \"${newField.description}\".`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findArgChanges(\n oldField: GraphQLField,\n newField: GraphQLField,\n): Array {\n const schemaChanges = [];\n const argsDiff = diff(oldField.args, newField.args);\n\n for (const oldArg of argsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.ARG_REMOVED,\n description: `Argument ${oldArg} was removed.`,\n });\n }\n\n for (const [oldArg, newArg] of argsDiff.persisted) {\n const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(\n oldArg.type,\n newArg.type,\n );\n\n const oldDefaultValueStr = getDefaultValue(oldArg);\n const newDefaultValueStr = getDefaultValue(newArg);\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.ARG_CHANGED_KIND,\n description: `Argument ${newArg} has changed type from ${oldArg.type} to ${newArg.type}.`,\n });\n } else if (oldDefaultValueStr !== undefined) {\n if (newDefaultValueStr === undefined) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `${oldArg} defaultValue was removed.`,\n });\n } else if (oldDefaultValueStr !== newDefaultValueStr) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `${oldArg} has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`,\n });\n }\n } else if (\n newDefaultValueStr !== undefined &&\n oldDefaultValueStr === undefined\n ) {\n schemaChanges.push({\n type: SafeChangeType.ARG_DEFAULT_VALUE_ADDED,\n description: `${oldArg} added a defaultValue ${newDefaultValueStr}.`,\n });\n } else if (oldArg.type.toString() !== newArg.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.ARG_CHANGED_KIND_SAFE,\n description:\n `Argument ${oldArg} has changed type from ` +\n `${String(oldArg.type)} to ${String(newArg.type)}.`,\n });\n }\n\n if (oldArg.description !== newArg.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of argument ${oldArg} has changed to \"${newArg.description}\".`,\n });\n }\n }\n\n for (const newArg of argsDiff.added) {\n if (isRequiredArgument(newArg)) {\n schemaChanges.push({\n type: BreakingChangeType.REQUIRED_ARG_ADDED,\n description: `A required argument ${newArg} was added.`,\n });\n } else {\n schemaChanges.push({\n type: DangerousChangeType.OPTIONAL_ARG_ADDED,\n description: `An optional argument ${newArg} was added.`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction isChangeSafeForObjectOrInterfaceField(\n oldType: GraphQLType,\n newType: GraphQLType,\n): boolean {\n if (isListType(oldType)) {\n return (\n // if they're both lists, make sure the underlying types are compatible\n (isListType(newType) &&\n isChangeSafeForObjectOrInterfaceField(\n oldType.ofType,\n newType.ofType,\n )) ||\n // moving from nullable to non-null of the same underlying type is safe\n (isNonNullType(newType) &&\n isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))\n );\n }\n\n if (isNonNullType(oldType)) {\n // if they're both non-null, make sure the underlying types are compatible\n return (\n isNonNullType(newType) &&\n isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType)\n );\n }\n\n return (\n // if they're both named types, see if their names are equivalent\n (isNamedType(newType) && oldType.name === newType.name) ||\n // moving from nullable to non-null of the same underlying type is safe\n (isNonNullType(newType) &&\n isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))\n );\n}\n\nfunction isChangeSafeForInputObjectFieldOrFieldArg(\n oldType: GraphQLType,\n newType: GraphQLType,\n): boolean {\n if (isListType(oldType)) {\n // if they're both lists, make sure the underlying types are compatible\n return (\n isListType(newType) &&\n isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType)\n );\n }\n\n if (isNonNullType(oldType)) {\n return (\n // if they're both non-null, make sure the underlying types are\n // compatible\n (isNonNullType(newType) &&\n isChangeSafeForInputObjectFieldOrFieldArg(\n oldType.ofType,\n newType.ofType,\n )) ||\n // moving from non-null to nullable of the same underlying type is safe\n (!isNonNullType(newType) &&\n isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType))\n );\n }\n\n // if they're both named types, see if their names are equivalent\n return isNamedType(newType) && oldType.name === newType.name;\n}\n\nfunction typeKindName(type: GraphQLNamedType): string {\n if (isScalarType(type)) {\n return 'a Scalar type';\n }\n if (isObjectType(type)) {\n return 'an Object type';\n }\n if (isInterfaceType(type)) {\n return 'an Interface type';\n }\n if (isUnionType(type)) {\n return 'a Union type';\n }\n if (isEnumType(type)) {\n return 'an Enum type';\n }\n if (isInputObjectType(type)) {\n return 'an Input type';\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered.\n invariant(false, 'Unexpected type: ' + inspect(type));\n}\n\n// Since we looking only for client's observable changes we should\n// compare default values in the same representation as they are\n// represented inside introspection.\nfunction getDefaultValue(\n argOrInputField: GraphQLArgument | GraphQLInputField,\n): string | undefined {\n const ast = getDefaultValueAST(argOrInputField);\n if (ast) {\n return print(sortValueNode(ast));\n }\n}\n\nfunction diff(\n oldArray: ReadonlyArray,\n newArray: ReadonlyArray,\n): {\n added: ReadonlyArray;\n removed: ReadonlyArray;\n persisted: ReadonlyArray<[T, T]>;\n} {\n const added: Array = [];\n const removed: Array = [];\n const persisted: Array<[T, T]> = [];\n\n const oldMap = keyMap(oldArray, ({ name }) => name);\n const newMap = keyMap(newArray, ({ name }) => name);\n\n for (const oldItem of oldArray) {\n const newItem = newMap[oldItem.name];\n if (newItem === undefined) {\n removed.push(oldItem);\n } else {\n persisted.push([oldItem, newItem]);\n }\n }\n\n for (const newItem of newArray) {\n if (oldMap[newItem.name] === undefined) {\n added.push(newItem);\n }\n }\n\n return { added, persisted, removed };\n}\n"]} \ No newline at end of file diff --git a/utilities/findSchemaChanges.mjs b/utilities/findSchemaChanges.mjs new file mode 100644 index 0000000000..54a3c5ed27 --- /dev/null +++ b/utilities/findSchemaChanges.mjs @@ -0,0 +1,554 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { keyMap } from "../jsutils/keyMap.mjs"; +import { print } from "../language/printer.mjs"; +import { isEnumType, isInputObjectType, isInterfaceType, isListType, isNamedType, isNonNullType, isObjectType, isRequiredArgument, isRequiredInputField, isScalarType, isUnionType, } from "../type/definition.mjs"; +import { isSpecifiedScalarType } from "../type/scalars.mjs"; +import { getDefaultValueAST } from "./getDefaultValueAST.mjs"; +import { sortValueNode } from "./sortValueNode.mjs"; +export const BreakingChangeType = { + TYPE_REMOVED: 'TYPE_REMOVED', + TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND', + TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION', + VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM', + REQUIRED_INPUT_FIELD_ADDED: 'REQUIRED_INPUT_FIELD_ADDED', + IMPLEMENTED_INTERFACE_REMOVED: 'IMPLEMENTED_INTERFACE_REMOVED', + FIELD_REMOVED: 'FIELD_REMOVED', + FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND', + REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED', + ARG_REMOVED: 'ARG_REMOVED', + ARG_CHANGED_KIND: 'ARG_CHANGED_KIND', + DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED', + DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED', + REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED', + DIRECTIVE_REPEATABLE_REMOVED: 'DIRECTIVE_REPEATABLE_REMOVED', + DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED', +}; +export const DangerousChangeType = { + VALUE_ADDED_TO_ENUM: 'VALUE_ADDED_TO_ENUM', + TYPE_ADDED_TO_UNION: 'TYPE_ADDED_TO_UNION', + OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED', + OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED', + IMPLEMENTED_INTERFACE_ADDED: 'IMPLEMENTED_INTERFACE_ADDED', + ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE', +}; +export const SafeChangeType = { + DESCRIPTION_CHANGED: 'DESCRIPTION_CHANGED', + TYPE_ADDED: 'TYPE_ADDED', + OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED', + OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED', + DIRECTIVE_ADDED: 'DIRECTIVE_ADDED', + FIELD_ADDED: 'FIELD_ADDED', + DIRECTIVE_REPEATABLE_ADDED: 'DIRECTIVE_REPEATABLE_ADDED', + DIRECTIVE_LOCATION_ADDED: 'DIRECTIVE_LOCATION_ADDED', + OPTIONAL_DIRECTIVE_ARG_ADDED: 'OPTIONAL_DIRECTIVE_ARG_ADDED', + FIELD_CHANGED_KIND_SAFE: 'FIELD_CHANGED_KIND_SAFE', + ARG_CHANGED_KIND_SAFE: 'ARG_CHANGED_KIND_SAFE', + ARG_DEFAULT_VALUE_ADDED: 'ARG_DEFAULT_VALUE_ADDED', +}; +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of breaking changes covered by the other functions down below. + * + * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18. + */ +export function findBreakingChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter((change) => change.type in BreakingChangeType); +} +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of potentially dangerous changes covered by the other functions down below. + * + * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18. + */ +export function findDangerousChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter((change) => change.type in DangerousChangeType); +} +export function findSchemaChanges(oldSchema, newSchema) { + return [ + ...findTypeChanges(oldSchema, newSchema), + ...findDirectiveChanges(oldSchema, newSchema), + ]; +} +function findDirectiveChanges(oldSchema, newSchema) { + const schemaChanges = []; + const directivesDiff = diff(oldSchema.getDirectives(), newSchema.getDirectives()); + for (const oldDirective of directivesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REMOVED, + description: `Directive ${oldDirective} was removed.`, + }); + } + for (const newDirective of directivesDiff.added) { + schemaChanges.push({ + type: SafeChangeType.DIRECTIVE_ADDED, + description: `Directive @${newDirective.name} was added.`, + }); + } + for (const [oldDirective, newDirective] of directivesDiff.persisted) { + const argsDiff = diff(oldDirective.args, newDirective.args); + for (const newArg of argsDiff.added) { + if (isRequiredArgument(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, + description: `A required argument ${newArg} was added.`, + }); + } + else { + schemaChanges.push({ + type: SafeChangeType.OPTIONAL_DIRECTIVE_ARG_ADDED, + description: `An optional argument @${oldDirective.name}(${newArg.name}:) was added.`, + }); + } + } + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, + description: `Argument ${oldArg} was removed.`, + }); + } + for (const [oldArg, newArg] of argsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldArg.type, newArg.type); + const oldDefaultValueStr = getDefaultValue(oldArg); + const newDefaultValueStr = getDefaultValue(newArg); + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.ARG_CHANGED_KIND, + description: `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } + else if (oldDefaultValueStr !== undefined) { + if (newDefaultValueStr === undefined) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `@${oldDirective.name}(${oldArg.name}:) defaultValue was removed.`, + }); + } + else if (oldDefaultValueStr !== newDefaultValueStr) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `@${oldDirective.name}(${oldArg.name}:) has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`, + }); + } + } + else if (newDefaultValueStr !== undefined && + oldDefaultValueStr === undefined) { + schemaChanges.push({ + type: SafeChangeType.ARG_DEFAULT_VALUE_ADDED, + description: `@${oldDirective.name}(${oldArg.name}:) added a defaultValue ${newDefaultValueStr}.`, + }); + } + else if (oldArg.type.toString() !== newArg.type.toString()) { + schemaChanges.push({ + type: SafeChangeType.ARG_CHANGED_KIND_SAFE, + description: `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } + if (oldArg.description !== newArg.description) { + schemaChanges.push({ + type: SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of @${oldDirective.name}(${oldDirective.name}) has changed to "${newArg.description}".`, + }); + } + } + if (oldDirective.isRepeatable && !newDirective.isRepeatable) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, + description: `Repeatable flag was removed from ${oldDirective}.`, + }); + } + else if (newDirective.isRepeatable && !oldDirective.isRepeatable) { + schemaChanges.push({ + type: SafeChangeType.DIRECTIVE_REPEATABLE_ADDED, + description: `Repeatable flag was added to @${oldDirective.name}.`, + }); + } + if (oldDirective.description !== newDirective.description) { + schemaChanges.push({ + type: SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of @${oldDirective.name} has changed to "${newDirective.description}".`, + }); + } + for (const location of oldDirective.locations) { + if (!newDirective.locations.includes(location)) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, + description: `${location} was removed from ${oldDirective}.`, + }); + } + } + for (const location of newDirective.locations) { + if (!oldDirective.locations.includes(location)) { + schemaChanges.push({ + type: SafeChangeType.DIRECTIVE_LOCATION_ADDED, + description: `${location} was added to @${oldDirective.name}.`, + }); + } + } + } + return schemaChanges; +} +function findTypeChanges(oldSchema, newSchema) { + const schemaChanges = []; + const typesDiff = diff(Object.values(oldSchema.getTypeMap()), Object.values(newSchema.getTypeMap())); + for (const oldType of typesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED, + description: isSpecifiedScalarType(oldType) + ? `Standard scalar ${oldType} was removed because it is not referenced anymore.` + : `${oldType} was removed.`, + }); + } + for (const newType of typesDiff.added) { + schemaChanges.push({ + type: SafeChangeType.TYPE_ADDED, + description: `${newType} was added.`, + }); + } + for (const [oldType, newType] of typesDiff.persisted) { + if (oldType.description !== newType.description) { + schemaChanges.push({ + type: SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of ${oldType.name} has changed to "${newType.description}".`, + }); + } + if (isEnumType(oldType) && isEnumType(newType)) { + schemaChanges.push(...findEnumTypeChanges(oldType, newType)); + } + else if (isUnionType(oldType) && isUnionType(newType)) { + schemaChanges.push(...findUnionTypeChanges(oldType, newType)); + } + else if (isInputObjectType(oldType) && isInputObjectType(newType)) { + schemaChanges.push(...findInputObjectTypeChanges(oldType, newType)); + } + else if (isObjectType(oldType) && isObjectType(newType)) { + schemaChanges.push(...findFieldChanges(oldType, newType), ...findImplementedInterfacesChanges(oldType, newType)); + } + else if (isInterfaceType(oldType) && isInterfaceType(newType)) { + schemaChanges.push(...findFieldChanges(oldType, newType), ...findImplementedInterfacesChanges(oldType, newType)); + } + else if (oldType.constructor !== newType.constructor) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_CHANGED_KIND, + description: `${oldType} changed from ${typeKindName(oldType)} to ${typeKindName(newType)}.`, + }); + } + } + return schemaChanges; +} +function findInputObjectTypeChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff(Object.values(oldType.getFields()), Object.values(newType.getFields())); + for (const newField of fieldsDiff.added) { + if (isRequiredInputField(newField)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, + description: `A required field ${newField} was added.`, + }); + } + else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, + description: `An optional field ${newField} was added.`, + }); + } + } + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `Field ${oldField} was removed.`, + }); + } + for (const [oldField, newField] of fieldsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldField.type, newField.type); + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`, + }); + } + else if (oldField.type.toString() !== newField.type.toString()) { + schemaChanges.push({ + type: SafeChangeType.FIELD_CHANGED_KIND_SAFE, + description: `Field ${oldType}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + if (oldField.description !== newField.description) { + schemaChanges.push({ + type: SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of input-field ${newType}.${newField.name} has changed to "${newField.description}".`, + }); + } + } + return schemaChanges; +} +function findUnionTypeChanges(oldType, newType) { + const schemaChanges = []; + const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes()); + for (const newPossibleType of possibleTypesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.TYPE_ADDED_TO_UNION, + description: `${newPossibleType} was added to union type ${oldType}.`, + }); + } + for (const oldPossibleType of possibleTypesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, + description: `${oldPossibleType} was removed from union type ${oldType}.`, + }); + } + return schemaChanges; +} +function findEnumTypeChanges(oldType, newType) { + const schemaChanges = []; + const valuesDiff = diff(oldType.getValues(), newType.getValues()); + for (const newValue of valuesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.VALUE_ADDED_TO_ENUM, + description: `Enum value ${newValue} was added.`, + }); + } + for (const oldValue of valuesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, + description: `Enum value ${oldValue} was removed.`, + }); + } + for (const [oldValue, newValue] of valuesDiff.persisted) { + if (oldValue.description !== newValue.description) { + schemaChanges.push({ + type: SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of enum value ${oldType}.${oldValue.name} has changed to "${newValue.description}".`, + }); + } + } + return schemaChanges; +} +function findImplementedInterfacesChanges(oldType, newType) { + const schemaChanges = []; + const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces()); + for (const newInterface of interfacesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, + description: `${newInterface} added to interfaces implemented by ${oldType}.`, + }); + } + for (const oldInterface of interfacesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, + description: `${oldType} no longer implements interface ${oldInterface}.`, + }); + } + return schemaChanges; +} +function findFieldChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff(Object.values(oldType.getFields()), Object.values(newType.getFields())); + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `Field ${oldField} was removed.`, + }); + } + for (const newField of fieldsDiff.added) { + schemaChanges.push({ + type: SafeChangeType.FIELD_ADDED, + description: `Field ${oldType}.${newField.name} was added.`, + }); + } + for (const [oldField, newField] of fieldsDiff.persisted) { + schemaChanges.push(...findArgChanges(oldField, newField)); + const isSafe = isChangeSafeForObjectOrInterfaceField(oldField.type, newField.type); + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`, + }); + } + else if (oldField.type.toString() !== newField.type.toString()) { + schemaChanges.push({ + type: SafeChangeType.FIELD_CHANGED_KIND_SAFE, + description: `Field ${oldType}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + if (oldField.description !== newField.description) { + schemaChanges.push({ + type: SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of field ${oldType}.${oldField.name} has changed to "${newField.description}".`, + }); + } + } + return schemaChanges; +} +function findArgChanges(oldField, newField) { + const schemaChanges = []; + const argsDiff = diff(oldField.args, newField.args); + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.ARG_REMOVED, + description: `Argument ${oldArg} was removed.`, + }); + } + for (const [oldArg, newArg] of argsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldArg.type, newArg.type); + const oldDefaultValueStr = getDefaultValue(oldArg); + const newDefaultValueStr = getDefaultValue(newArg); + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.ARG_CHANGED_KIND, + description: `Argument ${newArg} has changed type from ${oldArg.type} to ${newArg.type}.`, + }); + } + else if (oldDefaultValueStr !== undefined) { + if (newDefaultValueStr === undefined) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldArg} defaultValue was removed.`, + }); + } + else if (oldDefaultValueStr !== newDefaultValueStr) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldArg} has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`, + }); + } + } + else if (newDefaultValueStr !== undefined && + oldDefaultValueStr === undefined) { + schemaChanges.push({ + type: SafeChangeType.ARG_DEFAULT_VALUE_ADDED, + description: `${oldArg} added a defaultValue ${newDefaultValueStr}.`, + }); + } + else if (oldArg.type.toString() !== newArg.type.toString()) { + schemaChanges.push({ + type: SafeChangeType.ARG_CHANGED_KIND_SAFE, + description: `Argument ${oldArg} has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } + if (oldArg.description !== newArg.description) { + schemaChanges.push({ + type: SafeChangeType.DESCRIPTION_CHANGED, + description: `Description of argument ${oldArg} has changed to "${newArg.description}".`, + }); + } + } + for (const newArg of argsDiff.added) { + if (isRequiredArgument(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_ARG_ADDED, + description: `A required argument ${newArg} was added.`, + }); + } + else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_ARG_ADDED, + description: `An optional argument ${newArg} was added.`, + }); + } + } + return schemaChanges; +} +function isChangeSafeForObjectOrInterfaceField(oldType, newType) { + if (isListType(oldType)) { + return ( + // if they're both lists, make sure the underlying types are compatible + (isListType(newType) && + isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType)) || + // moving from nullable to non-null of the same underlying type is safe + (isNonNullType(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))); + } + if (isNonNullType(oldType)) { + // if they're both non-null, make sure the underlying types are compatible + return (isNonNullType(newType) && + isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType)); + } + return ( + // if they're both named types, see if their names are equivalent + (isNamedType(newType) && oldType.name === newType.name) || + // moving from nullable to non-null of the same underlying type is safe + (isNonNullType(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))); +} +function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) { + if (isListType(oldType)) { + // if they're both lists, make sure the underlying types are compatible + return (isListType(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType)); + } + if (isNonNullType(oldType)) { + return ( + // if they're both non-null, make sure the underlying types are + // compatible + (isNonNullType(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType)) || + // moving from non-null to nullable of the same underlying type is safe + (!isNonNullType(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType))); + } + // if they're both named types, see if their names are equivalent + return isNamedType(newType) && oldType.name === newType.name; +} +function typeKindName(type) { + if (isScalarType(type)) { + return 'a Scalar type'; + } + if (isObjectType(type)) { + return 'an Object type'; + } + if (isInterfaceType(type)) { + return 'an Interface type'; + } + if (isUnionType(type)) { + return 'a Union type'; + } + if (isEnumType(type)) { + return 'an Enum type'; + } + if (isInputObjectType(type)) { + return 'an Input type'; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + (false) || invariant(false, 'Unexpected type: ' + inspect(type)); +} +// Since we looking only for client's observable changes we should +// compare default values in the same representation as they are +// represented inside introspection. +function getDefaultValue(argOrInputField) { + const ast = getDefaultValueAST(argOrInputField); + if (ast) { + return print(sortValueNode(ast)); + } +} +function diff(oldArray, newArray) { + const added = []; + const removed = []; + const persisted = []; + const oldMap = keyMap(oldArray, ({ name }) => name); + const newMap = keyMap(newArray, ({ name }) => name); + for (const oldItem of oldArray) { + const newItem = newMap[oldItem.name]; + if (newItem === undefined) { + removed.push(oldItem); + } + else { + persisted.push([oldItem, newItem]); + } + } + for (const newItem of newArray) { + if (oldMap[newItem.name] === undefined) { + added.push(newItem); + } + } + return { added, persisted, removed }; +} +//# sourceMappingURL=findSchemaChanges.js.map \ No newline at end of file diff --git a/utilities/findSchemaChanges.mjs.map b/utilities/findSchemaChanges.mjs.map new file mode 100644 index 0000000000..33db4d09d5 --- /dev/null +++ b/utilities/findSchemaChanges.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"findSchemaChanges.js","sourceRoot":"","sources":["../../src/utilities/findSchemaChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,MAAM,EAAE,8BAA6B;AAE9C,OAAO,EAAE,KAAK,EAAE,gCAA+B;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QACxB,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport { keyMap } from '../jsutils/keyMap.js';\n\nimport { print } from '../language/printer.js';\n\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLType,\n GraphQLUnionType,\n} from '../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isListType,\n isNamedType,\n isNonNullType,\n isObjectType,\n isRequiredArgument,\n isRequiredInputField,\n isScalarType,\n isUnionType,\n} from '../type/definition.js';\nimport { isSpecifiedScalarType } from '../type/scalars.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { getDefaultValueAST } from './getDefaultValueAST.js';\nimport { sortValueNode } from './sortValueNode.js';\n\nexport const BreakingChangeType = {\n TYPE_REMOVED: 'TYPE_REMOVED' as const,\n TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND' as const,\n TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION' as const,\n VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM' as const,\n REQUIRED_INPUT_FIELD_ADDED: 'REQUIRED_INPUT_FIELD_ADDED' as const,\n IMPLEMENTED_INTERFACE_REMOVED: 'IMPLEMENTED_INTERFACE_REMOVED' as const,\n FIELD_REMOVED: 'FIELD_REMOVED' as const,\n FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND' as const,\n REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED' as const,\n ARG_REMOVED: 'ARG_REMOVED' as const,\n ARG_CHANGED_KIND: 'ARG_CHANGED_KIND' as const,\n DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED' as const,\n DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED' as const,\n REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED' as const,\n DIRECTIVE_REPEATABLE_REMOVED: 'DIRECTIVE_REPEATABLE_REMOVED' as const,\n DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type BreakingChangeType =\n (typeof BreakingChangeType)[keyof typeof BreakingChangeType];\n\nexport const DangerousChangeType = {\n VALUE_ADDED_TO_ENUM: 'VALUE_ADDED_TO_ENUM' as const,\n TYPE_ADDED_TO_UNION: 'TYPE_ADDED_TO_UNION' as const,\n OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED' as const,\n OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED' as const,\n IMPLEMENTED_INTERFACE_ADDED: 'IMPLEMENTED_INTERFACE_ADDED' as const,\n ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE' as const,\n};\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type DangerousChangeType =\n (typeof DangerousChangeType)[keyof typeof DangerousChangeType];\n\nexport const SafeChangeType = {\n DESCRIPTION_CHANGED: 'DESCRIPTION_CHANGED' as const,\n TYPE_ADDED: 'TYPE_ADDED' as const,\n OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED' as const,\n OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED' as const,\n DIRECTIVE_ADDED: 'DIRECTIVE_ADDED' as const,\n FIELD_ADDED: 'FIELD_ADDED' as const,\n DIRECTIVE_REPEATABLE_ADDED: 'DIRECTIVE_REPEATABLE_ADDED' as const,\n DIRECTIVE_LOCATION_ADDED: 'DIRECTIVE_LOCATION_ADDED' as const,\n OPTIONAL_DIRECTIVE_ARG_ADDED: 'OPTIONAL_DIRECTIVE_ARG_ADDED' as const,\n FIELD_CHANGED_KIND_SAFE: 'FIELD_CHANGED_KIND_SAFE' as const,\n ARG_CHANGED_KIND_SAFE: 'ARG_CHANGED_KIND_SAFE' as const,\n ARG_DEFAULT_VALUE_ADDED: 'ARG_DEFAULT_VALUE_ADDED' as const,\n};\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type SafeChangeType =\n (typeof SafeChangeType)[keyof typeof SafeChangeType];\n\nexport interface BreakingChange {\n type: BreakingChangeType;\n description: string;\n}\n\nexport interface DangerousChange {\n type: DangerousChangeType;\n description: string;\n}\n\nexport interface SafeChange {\n type: SafeChangeType;\n description: string;\n}\n\nexport type SchemaChange = SafeChange | DangerousChange | BreakingChange;\n\n/**\n * Given two schemas, returns an Array containing descriptions of all the types\n * of breaking changes covered by the other functions down below.\n *\n * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18.\n */\nexport function findBreakingChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n // @ts-expect-error\n return findSchemaChanges(oldSchema, newSchema).filter(\n (change) => change.type in BreakingChangeType,\n );\n}\n\n/**\n * Given two schemas, returns an Array containing descriptions of all the types\n * of potentially dangerous changes covered by the other functions down below.\n *\n * @deprecated Please use `findSchemaChanges` instead. Will be removed in v18.\n */\nexport function findDangerousChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n // @ts-expect-error\n return findSchemaChanges(oldSchema, newSchema).filter(\n (change) => change.type in DangerousChangeType,\n );\n}\n\nexport function findSchemaChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n return [\n ...findTypeChanges(oldSchema, newSchema),\n ...findDirectiveChanges(oldSchema, newSchema),\n ];\n}\n\nfunction findDirectiveChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n const schemaChanges = [];\n\n const directivesDiff = diff(\n oldSchema.getDirectives(),\n newSchema.getDirectives(),\n );\n\n for (const oldDirective of directivesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_REMOVED,\n description: `Directive ${oldDirective} was removed.`,\n });\n }\n\n for (const newDirective of directivesDiff.added) {\n schemaChanges.push({\n type: SafeChangeType.DIRECTIVE_ADDED,\n description: `Directive @${newDirective.name} was added.`,\n });\n }\n\n for (const [oldDirective, newDirective] of directivesDiff.persisted) {\n const argsDiff = diff(oldDirective.args, newDirective.args);\n\n for (const newArg of argsDiff.added) {\n if (isRequiredArgument(newArg)) {\n schemaChanges.push({\n type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED,\n description: `A required argument ${newArg} was added.`,\n });\n } else {\n schemaChanges.push({\n type: SafeChangeType.OPTIONAL_DIRECTIVE_ARG_ADDED,\n description: `An optional argument @${oldDirective.name}(${newArg.name}:) was added.`,\n });\n }\n }\n\n for (const oldArg of argsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_ARG_REMOVED,\n description: `Argument ${oldArg} was removed.`,\n });\n }\n\n for (const [oldArg, newArg] of argsDiff.persisted) {\n const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(\n oldArg.type,\n newArg.type,\n );\n\n const oldDefaultValueStr = getDefaultValue(oldArg);\n const newDefaultValueStr = getDefaultValue(newArg);\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.ARG_CHANGED_KIND,\n description:\n `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` +\n `${String(oldArg.type)} to ${String(newArg.type)}.`,\n });\n } else if (oldDefaultValueStr !== undefined) {\n if (newDefaultValueStr === undefined) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `@${oldDirective.name}(${oldArg.name}:) defaultValue was removed.`,\n });\n } else if (oldDefaultValueStr !== newDefaultValueStr) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `@${oldDirective.name}(${oldArg.name}:) has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`,\n });\n }\n } else if (\n newDefaultValueStr !== undefined &&\n oldDefaultValueStr === undefined\n ) {\n schemaChanges.push({\n type: SafeChangeType.ARG_DEFAULT_VALUE_ADDED,\n description: `@${oldDirective.name}(${oldArg.name}:) added a defaultValue ${newDefaultValueStr}.`,\n });\n } else if (oldArg.type.toString() !== newArg.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.ARG_CHANGED_KIND_SAFE,\n description:\n `Argument @${oldDirective.name}(${oldArg.name}:) has changed type from ` +\n `${String(oldArg.type)} to ${String(newArg.type)}.`,\n });\n }\n\n if (oldArg.description !== newArg.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of @${oldDirective.name}(${oldDirective.name}) has changed to \"${newArg.description}\".`,\n });\n }\n }\n\n if (oldDirective.isRepeatable && !newDirective.isRepeatable) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED,\n description: `Repeatable flag was removed from ${oldDirective}.`,\n });\n } else if (newDirective.isRepeatable && !oldDirective.isRepeatable) {\n schemaChanges.push({\n type: SafeChangeType.DIRECTIVE_REPEATABLE_ADDED,\n description: `Repeatable flag was added to @${oldDirective.name}.`,\n });\n }\n\n if (oldDirective.description !== newDirective.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of @${oldDirective.name} has changed to \"${newDirective.description}\".`,\n });\n }\n\n for (const location of oldDirective.locations) {\n if (!newDirective.locations.includes(location)) {\n schemaChanges.push({\n type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED,\n description: `${location} was removed from ${oldDirective}.`,\n });\n }\n }\n\n for (const location of newDirective.locations) {\n if (!oldDirective.locations.includes(location)) {\n schemaChanges.push({\n type: SafeChangeType.DIRECTIVE_LOCATION_ADDED,\n description: `${location} was added to @${oldDirective.name}.`,\n });\n }\n }\n }\n\n return schemaChanges;\n}\n\nfunction findTypeChanges(\n oldSchema: GraphQLSchema,\n newSchema: GraphQLSchema,\n): Array {\n const schemaChanges = [];\n\n const typesDiff = diff(\n Object.values(oldSchema.getTypeMap()),\n Object.values(newSchema.getTypeMap()),\n );\n\n for (const oldType of typesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.TYPE_REMOVED,\n description: isSpecifiedScalarType(oldType)\n ? `Standard scalar ${oldType} was removed because it is not referenced anymore.`\n : `${oldType} was removed.`,\n });\n }\n\n for (const newType of typesDiff.added) {\n schemaChanges.push({\n type: SafeChangeType.TYPE_ADDED,\n description: `${newType} was added.`,\n });\n }\n\n for (const [oldType, newType] of typesDiff.persisted) {\n if (oldType.description !== newType.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of ${oldType.name} has changed to \"${newType.description}\".`,\n });\n }\n\n if (isEnumType(oldType) && isEnumType(newType)) {\n schemaChanges.push(...findEnumTypeChanges(oldType, newType));\n } else if (isUnionType(oldType) && isUnionType(newType)) {\n schemaChanges.push(...findUnionTypeChanges(oldType, newType));\n } else if (isInputObjectType(oldType) && isInputObjectType(newType)) {\n schemaChanges.push(...findInputObjectTypeChanges(oldType, newType));\n } else if (isObjectType(oldType) && isObjectType(newType)) {\n schemaChanges.push(\n ...findFieldChanges(oldType, newType),\n ...findImplementedInterfacesChanges(oldType, newType),\n );\n } else if (isInterfaceType(oldType) && isInterfaceType(newType)) {\n schemaChanges.push(\n ...findFieldChanges(oldType, newType),\n ...findImplementedInterfacesChanges(oldType, newType),\n );\n } else if (oldType.constructor !== newType.constructor) {\n schemaChanges.push({\n type: BreakingChangeType.TYPE_CHANGED_KIND,\n description: `${oldType} changed from ${typeKindName(\n oldType,\n )} to ${typeKindName(newType)}.`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findInputObjectTypeChanges(\n oldType: GraphQLInputObjectType,\n newType: GraphQLInputObjectType,\n): Array {\n const schemaChanges = [];\n const fieldsDiff = diff(\n Object.values(oldType.getFields()),\n Object.values(newType.getFields()),\n );\n\n for (const newField of fieldsDiff.added) {\n if (isRequiredInputField(newField)) {\n schemaChanges.push({\n type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED,\n description: `A required field ${newField} was added.`,\n });\n } else {\n schemaChanges.push({\n type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED,\n description: `An optional field ${newField} was added.`,\n });\n }\n }\n\n for (const oldField of fieldsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_REMOVED,\n description: `Field ${oldField} was removed.`,\n });\n }\n\n for (const [oldField, newField] of fieldsDiff.persisted) {\n const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(\n oldField.type,\n newField.type,\n );\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_CHANGED_KIND,\n description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`,\n });\n } else if (oldField.type.toString() !== newField.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.FIELD_CHANGED_KIND_SAFE,\n description:\n `Field ${oldType}.${oldField.name} changed type from ` +\n `${String(oldField.type)} to ${String(newField.type)}.`,\n });\n }\n\n if (oldField.description !== newField.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of input-field ${newType}.${newField.name} has changed to \"${newField.description}\".`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findUnionTypeChanges(\n oldType: GraphQLUnionType,\n newType: GraphQLUnionType,\n): Array {\n const schemaChanges = [];\n const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes());\n\n for (const newPossibleType of possibleTypesDiff.added) {\n schemaChanges.push({\n type: DangerousChangeType.TYPE_ADDED_TO_UNION,\n description: `${newPossibleType} was added to union type ${oldType}.`,\n });\n }\n\n for (const oldPossibleType of possibleTypesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.TYPE_REMOVED_FROM_UNION,\n description: `${oldPossibleType} was removed from union type ${oldType}.`,\n });\n }\n\n return schemaChanges;\n}\n\nfunction findEnumTypeChanges(\n oldType: GraphQLEnumType,\n newType: GraphQLEnumType,\n): Array {\n const schemaChanges = [];\n const valuesDiff = diff(oldType.getValues(), newType.getValues());\n\n for (const newValue of valuesDiff.added) {\n schemaChanges.push({\n type: DangerousChangeType.VALUE_ADDED_TO_ENUM,\n description: `Enum value ${newValue} was added.`,\n });\n }\n\n for (const oldValue of valuesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM,\n description: `Enum value ${oldValue} was removed.`,\n });\n }\n\n for (const [oldValue, newValue] of valuesDiff.persisted) {\n if (oldValue.description !== newValue.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of enum value ${oldType}.${oldValue.name} has changed to \"${newValue.description}\".`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findImplementedInterfacesChanges(\n oldType: GraphQLObjectType | GraphQLInterfaceType,\n newType: GraphQLObjectType | GraphQLInterfaceType,\n): Array {\n const schemaChanges = [];\n const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces());\n\n for (const newInterface of interfacesDiff.added) {\n schemaChanges.push({\n type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED,\n description: `${newInterface} added to interfaces implemented by ${oldType}.`,\n });\n }\n\n for (const oldInterface of interfacesDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED,\n description: `${oldType} no longer implements interface ${oldInterface}.`,\n });\n }\n\n return schemaChanges;\n}\n\nfunction findFieldChanges(\n oldType: GraphQLObjectType | GraphQLInterfaceType,\n newType: GraphQLObjectType | GraphQLInterfaceType,\n): Array {\n const schemaChanges = [];\n const fieldsDiff = diff(\n Object.values(oldType.getFields()),\n Object.values(newType.getFields()),\n );\n\n for (const oldField of fieldsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_REMOVED,\n description: `Field ${oldField} was removed.`,\n });\n }\n\n for (const newField of fieldsDiff.added) {\n schemaChanges.push({\n type: SafeChangeType.FIELD_ADDED,\n description: `Field ${oldType}.${newField.name} was added.`,\n });\n }\n\n for (const [oldField, newField] of fieldsDiff.persisted) {\n schemaChanges.push(...findArgChanges(oldField, newField));\n\n const isSafe = isChangeSafeForObjectOrInterfaceField(\n oldField.type,\n newField.type,\n );\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.FIELD_CHANGED_KIND,\n description: `Field ${newField} changed type from ${oldField.type} to ${newField.type}.`,\n });\n } else if (oldField.type.toString() !== newField.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.FIELD_CHANGED_KIND_SAFE,\n description:\n `Field ${oldType}.${oldField.name} changed type from ` +\n `${String(oldField.type)} to ${String(newField.type)}.`,\n });\n }\n\n if (oldField.description !== newField.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of field ${oldType}.${oldField.name} has changed to \"${newField.description}\".`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction findArgChanges(\n oldField: GraphQLField,\n newField: GraphQLField,\n): Array {\n const schemaChanges = [];\n const argsDiff = diff(oldField.args, newField.args);\n\n for (const oldArg of argsDiff.removed) {\n schemaChanges.push({\n type: BreakingChangeType.ARG_REMOVED,\n description: `Argument ${oldArg} was removed.`,\n });\n }\n\n for (const [oldArg, newArg] of argsDiff.persisted) {\n const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(\n oldArg.type,\n newArg.type,\n );\n\n const oldDefaultValueStr = getDefaultValue(oldArg);\n const newDefaultValueStr = getDefaultValue(newArg);\n if (!isSafe) {\n schemaChanges.push({\n type: BreakingChangeType.ARG_CHANGED_KIND,\n description: `Argument ${newArg} has changed type from ${oldArg.type} to ${newArg.type}.`,\n });\n } else if (oldDefaultValueStr !== undefined) {\n if (newDefaultValueStr === undefined) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `${oldArg} defaultValue was removed.`,\n });\n } else if (oldDefaultValueStr !== newDefaultValueStr) {\n schemaChanges.push({\n type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,\n description: `${oldArg} has changed defaultValue from ${oldDefaultValueStr} to ${newDefaultValueStr}.`,\n });\n }\n } else if (\n newDefaultValueStr !== undefined &&\n oldDefaultValueStr === undefined\n ) {\n schemaChanges.push({\n type: SafeChangeType.ARG_DEFAULT_VALUE_ADDED,\n description: `${oldArg} added a defaultValue ${newDefaultValueStr}.`,\n });\n } else if (oldArg.type.toString() !== newArg.type.toString()) {\n schemaChanges.push({\n type: SafeChangeType.ARG_CHANGED_KIND_SAFE,\n description:\n `Argument ${oldArg} has changed type from ` +\n `${String(oldArg.type)} to ${String(newArg.type)}.`,\n });\n }\n\n if (oldArg.description !== newArg.description) {\n schemaChanges.push({\n type: SafeChangeType.DESCRIPTION_CHANGED,\n description: `Description of argument ${oldArg} has changed to \"${newArg.description}\".`,\n });\n }\n }\n\n for (const newArg of argsDiff.added) {\n if (isRequiredArgument(newArg)) {\n schemaChanges.push({\n type: BreakingChangeType.REQUIRED_ARG_ADDED,\n description: `A required argument ${newArg} was added.`,\n });\n } else {\n schemaChanges.push({\n type: DangerousChangeType.OPTIONAL_ARG_ADDED,\n description: `An optional argument ${newArg} was added.`,\n });\n }\n }\n\n return schemaChanges;\n}\n\nfunction isChangeSafeForObjectOrInterfaceField(\n oldType: GraphQLType,\n newType: GraphQLType,\n): boolean {\n if (isListType(oldType)) {\n return (\n // if they're both lists, make sure the underlying types are compatible\n (isListType(newType) &&\n isChangeSafeForObjectOrInterfaceField(\n oldType.ofType,\n newType.ofType,\n )) ||\n // moving from nullable to non-null of the same underlying type is safe\n (isNonNullType(newType) &&\n isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))\n );\n }\n\n if (isNonNullType(oldType)) {\n // if they're both non-null, make sure the underlying types are compatible\n return (\n isNonNullType(newType) &&\n isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType)\n );\n }\n\n return (\n // if they're both named types, see if their names are equivalent\n (isNamedType(newType) && oldType.name === newType.name) ||\n // moving from nullable to non-null of the same underlying type is safe\n (isNonNullType(newType) &&\n isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType))\n );\n}\n\nfunction isChangeSafeForInputObjectFieldOrFieldArg(\n oldType: GraphQLType,\n newType: GraphQLType,\n): boolean {\n if (isListType(oldType)) {\n // if they're both lists, make sure the underlying types are compatible\n return (\n isListType(newType) &&\n isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType)\n );\n }\n\n if (isNonNullType(oldType)) {\n return (\n // if they're both non-null, make sure the underlying types are\n // compatible\n (isNonNullType(newType) &&\n isChangeSafeForInputObjectFieldOrFieldArg(\n oldType.ofType,\n newType.ofType,\n )) ||\n // moving from non-null to nullable of the same underlying type is safe\n (!isNonNullType(newType) &&\n isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType))\n );\n }\n\n // if they're both named types, see if their names are equivalent\n return isNamedType(newType) && oldType.name === newType.name;\n}\n\nfunction typeKindName(type: GraphQLNamedType): string {\n if (isScalarType(type)) {\n return 'a Scalar type';\n }\n if (isObjectType(type)) {\n return 'an Object type';\n }\n if (isInterfaceType(type)) {\n return 'an Interface type';\n }\n if (isUnionType(type)) {\n return 'a Union type';\n }\n if (isEnumType(type)) {\n return 'an Enum type';\n }\n if (isInputObjectType(type)) {\n return 'an Input type';\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered.\n invariant(false, 'Unexpected type: ' + inspect(type));\n}\n\n// Since we looking only for client's observable changes we should\n// compare default values in the same representation as they are\n// represented inside introspection.\nfunction getDefaultValue(\n argOrInputField: GraphQLArgument | GraphQLInputField,\n): string | undefined {\n const ast = getDefaultValueAST(argOrInputField);\n if (ast) {\n return print(sortValueNode(ast));\n }\n}\n\nfunction diff(\n oldArray: ReadonlyArray,\n newArray: ReadonlyArray,\n): {\n added: ReadonlyArray;\n removed: ReadonlyArray;\n persisted: ReadonlyArray<[T, T]>;\n} {\n const added: Array = [];\n const removed: Array = [];\n const persisted: Array<[T, T]> = [];\n\n const oldMap = keyMap(oldArray, ({ name }) => name);\n const newMap = keyMap(newArray, ({ name }) => name);\n\n for (const oldItem of oldArray) {\n const newItem = newMap[oldItem.name];\n if (newItem === undefined) {\n removed.push(oldItem);\n } else {\n persisted.push([oldItem, newItem]);\n }\n }\n\n for (const newItem of newArray) {\n if (oldMap[newItem.name] === undefined) {\n added.push(newItem);\n }\n }\n\n return { added, persisted, removed };\n}\n"]} \ No newline at end of file diff --git a/utilities/getDefaultValueAST.d.ts b/utilities/getDefaultValueAST.d.ts new file mode 100644 index 0000000000..91ae3e2903 --- /dev/null +++ b/utilities/getDefaultValueAST.d.ts @@ -0,0 +1,3 @@ +import type { ConstValueNode } from '../language/ast.js'; +import type { GraphQLArgument, GraphQLInputField } from '../type/definition.js'; +export declare function getDefaultValueAST(argOrInputField: GraphQLArgument | GraphQLInputField): ConstValueNode | undefined; diff --git a/utilities/getDefaultValueAST.js b/utilities/getDefaultValueAST.js new file mode 100644 index 0000000000..52cb7cb39e --- /dev/null +++ b/utilities/getDefaultValueAST.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getDefaultValueAST = getDefaultValueAST; +const invariant_js_1 = require("../jsutils/invariant.js"); +const astFromValue_js_1 = require("./astFromValue.js"); +const valueToLiteral_js_1 = require("./valueToLiteral.js"); +function getDefaultValueAST(argOrInputField) { + const type = argOrInputField.type; + const defaultInput = argOrInputField.default; + if (defaultInput) { + const literal = defaultInput.literal ?? (0, valueToLiteral_js_1.valueToLiteral)(defaultInput.value, type); + (literal != null) || (0, invariant_js_1.invariant)(false, 'Invalid default value'); + return literal; + } + const defaultValue = argOrInputField.defaultValue; + if (defaultValue !== undefined) { + const valueAST = (0, astFromValue_js_1.astFromValue)(defaultValue, type); + (valueAST != null) || (0, invariant_js_1.invariant)(false, 'Invalid default value'); + return valueAST; + } + return undefined; +} +//# sourceMappingURL=getDefaultValueAST.js.map \ No newline at end of file diff --git a/utilities/getDefaultValueAST.js.map b/utilities/getDefaultValueAST.js.map new file mode 100644 index 0000000000..9a060a5706 --- /dev/null +++ b/utilities/getDefaultValueAST.js.map @@ -0,0 +1 @@ +{"version":3,"file":"getDefaultValueAST.js","sourceRoot":"","sources":["../../src/utilities/getDefaultValueAST.ts"],"names":[],"mappings":";;AASA,gDAmBC;AA5BD,0DAAoD;AAMpD,uDAAiD;AACjD,2DAAqD;AAErD,SAAgB,kBAAkB,CAChC,eAAoD;IAEpD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;IAClC,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC;IAC7C,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,OAAO,GACX,YAAY,CAAC,OAAO,IAAI,IAAA,kCAAc,EAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnE,CAAU,OAAO,IAAI,IAAI,SAAzB,wBAAS,SAAkB,uBAAuB,EAAE;QACpD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,YAAY,CAAC;IAClD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAA,8BAAY,EAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAClD,CAAU,QAAQ,IAAI,IAAI,SAA1B,wBAAS,SAAmB,uBAAuB,EAAE;QACrD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\n\nimport type { ConstValueNode } from '../language/ast.js';\n\nimport type { GraphQLArgument, GraphQLInputField } from '../type/definition.js';\n\nimport { astFromValue } from './astFromValue.js';\nimport { valueToLiteral } from './valueToLiteral.js';\n\nexport function getDefaultValueAST(\n argOrInputField: GraphQLArgument | GraphQLInputField,\n): ConstValueNode | undefined {\n const type = argOrInputField.type;\n const defaultInput = argOrInputField.default;\n if (defaultInput) {\n const literal =\n defaultInput.literal ?? valueToLiteral(defaultInput.value, type);\n invariant(literal != null, 'Invalid default value');\n return literal;\n }\n\n const defaultValue = argOrInputField.defaultValue;\n if (defaultValue !== undefined) {\n const valueAST = astFromValue(defaultValue, type);\n invariant(valueAST != null, 'Invalid default value');\n return valueAST;\n }\n return undefined;\n}\n"]} \ No newline at end of file diff --git a/utilities/getDefaultValueAST.mjs b/utilities/getDefaultValueAST.mjs new file mode 100644 index 0000000000..b201c14ab6 --- /dev/null +++ b/utilities/getDefaultValueAST.mjs @@ -0,0 +1,20 @@ +import { invariant } from "../jsutils/invariant.mjs"; +import { astFromValue } from "./astFromValue.mjs"; +import { valueToLiteral } from "./valueToLiteral.mjs"; +export function getDefaultValueAST(argOrInputField) { + const type = argOrInputField.type; + const defaultInput = argOrInputField.default; + if (defaultInput) { + const literal = defaultInput.literal ?? valueToLiteral(defaultInput.value, type); + (literal != null) || invariant(false, 'Invalid default value'); + return literal; + } + const defaultValue = argOrInputField.defaultValue; + if (defaultValue !== undefined) { + const valueAST = astFromValue(defaultValue, type); + (valueAST != null) || invariant(false, 'Invalid default value'); + return valueAST; + } + return undefined; +} +//# sourceMappingURL=getDefaultValueAST.js.map \ No newline at end of file diff --git a/utilities/getDefaultValueAST.mjs.map b/utilities/getDefaultValueAST.mjs.map new file mode 100644 index 0000000000..0b8d9fb589 --- /dev/null +++ b/utilities/getDefaultValueAST.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"getDefaultValueAST.js","sourceRoot":"","sources":["../../src/utilities/getDefaultValueAST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAMpD,OAAO,EAAE,YAAY,EAAE,2BAA0B;AACjD,OAAO,EAAE,cAAc,EAAE,6BAA4B;AAErD,MAAM,UAAU,kBAAkB,CAChC,eAAoD;IAEpD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;IAClC,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC;IAC7C,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,OAAO,GACX,YAAY,CAAC,OAAO,IAAI,cAAc,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnE,CAAU,OAAO,IAAI,IAAI,KAAzB,SAAS,QAAkB,uBAAuB,EAAE;QACpD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,YAAY,CAAC;IAClD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAClD,CAAU,QAAQ,IAAI,IAAI,KAA1B,SAAS,QAAmB,uBAAuB,EAAE;QACrD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\n\nimport type { ConstValueNode } from '../language/ast.js';\n\nimport type { GraphQLArgument, GraphQLInputField } from '../type/definition.js';\n\nimport { astFromValue } from './astFromValue.js';\nimport { valueToLiteral } from './valueToLiteral.js';\n\nexport function getDefaultValueAST(\n argOrInputField: GraphQLArgument | GraphQLInputField,\n): ConstValueNode | undefined {\n const type = argOrInputField.type;\n const defaultInput = argOrInputField.default;\n if (defaultInput) {\n const literal =\n defaultInput.literal ?? valueToLiteral(defaultInput.value, type);\n invariant(literal != null, 'Invalid default value');\n return literal;\n }\n\n const defaultValue = argOrInputField.defaultValue;\n if (defaultValue !== undefined) {\n const valueAST = astFromValue(defaultValue, type);\n invariant(valueAST != null, 'Invalid default value');\n return valueAST;\n }\n return undefined;\n}\n"]} \ No newline at end of file diff --git a/utilities/getIntrospectionQuery.d.ts b/utilities/getIntrospectionQuery.d.ts new file mode 100644 index 0000000000..487658ac82 --- /dev/null +++ b/utilities/getIntrospectionQuery.d.ts @@ -0,0 +1,138 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { DirectiveLocation } from '../language/directiveLocation.js'; +import type { TypeKind } from '../type/introspection.js'; +export interface IntrospectionOptions { + /** + * Whether to include descriptions in the introspection result. + * Default: true + */ + descriptions?: boolean; + /** + * Whether to include `specifiedByURL` in the introspection result. + * Default: false + */ + specifiedByUrl?: boolean; + /** + * Whether to include `isRepeatable` flag on directives. + * Default: false + */ + directiveIsRepeatable?: boolean; + /** + * Whether to include `description` field on schema. + * Default: false + */ + schemaDescription?: boolean; + /** + * Whether target GraphQL server support deprecation of input values. + * Default: false + */ + inputValueDeprecation?: boolean; + /** + * Whether target GraphQL server supports `@oneOf` input objects. + * Default: false + */ + oneOf?: boolean; +} +/** + * Produce the GraphQL query recommended for a full schema introspection. + * Accepts optional IntrospectionOptions. + */ +export declare function getIntrospectionQuery(options?: IntrospectionOptions): string; +export interface IntrospectionQuery { + readonly __schema: IntrospectionSchema; +} +export interface IntrospectionSchema { + readonly description?: Maybe; + readonly queryType: IntrospectionNamedTypeRef; + readonly mutationType: Maybe>; + readonly subscriptionType: Maybe>; + readonly types: ReadonlyArray; + readonly directives: ReadonlyArray; +} +export type IntrospectionType = IntrospectionScalarType | IntrospectionObjectType | IntrospectionInterfaceType | IntrospectionUnionType | IntrospectionEnumType | IntrospectionInputObjectType; +export type IntrospectionOutputType = IntrospectionScalarType | IntrospectionObjectType | IntrospectionInterfaceType | IntrospectionUnionType | IntrospectionEnumType; +export type IntrospectionInputType = IntrospectionScalarType | IntrospectionEnumType | IntrospectionInputObjectType; +export interface IntrospectionScalarType { + readonly kind: typeof TypeKind.SCALAR; + readonly name: string; + readonly description?: Maybe; + readonly specifiedByURL?: Maybe; +} +export interface IntrospectionObjectType { + readonly kind: typeof TypeKind.OBJECT; + readonly name: string; + readonly description?: Maybe; + readonly fields: ReadonlyArray; + readonly interfaces: ReadonlyArray>; +} +export interface IntrospectionInterfaceType { + readonly kind: typeof TypeKind.INTERFACE; + readonly name: string; + readonly description?: Maybe; + readonly fields: ReadonlyArray; + readonly interfaces: ReadonlyArray>; + readonly possibleTypes: ReadonlyArray>; +} +export interface IntrospectionUnionType { + readonly kind: typeof TypeKind.UNION; + readonly name: string; + readonly description?: Maybe; + readonly possibleTypes: ReadonlyArray>; +} +export interface IntrospectionEnumType { + readonly kind: typeof TypeKind.ENUM; + readonly name: string; + readonly description?: Maybe; + readonly enumValues: ReadonlyArray; +} +export interface IntrospectionInputObjectType { + readonly kind: typeof TypeKind.INPUT_OBJECT; + readonly name: string; + readonly description?: Maybe; + readonly inputFields: ReadonlyArray; + readonly isOneOf: boolean; +} +export interface IntrospectionListTypeRef { + readonly kind: typeof TypeKind.LIST; + readonly ofType: T; +} +export interface IntrospectionNonNullTypeRef { + readonly kind: typeof TypeKind.NON_NULL; + readonly ofType: T; +} +export type IntrospectionTypeRef = IntrospectionNamedTypeRef | IntrospectionListTypeRef | IntrospectionNonNullTypeRef; +export type IntrospectionOutputTypeRef = IntrospectionNamedTypeRef | IntrospectionListTypeRef | IntrospectionNonNullTypeRef | IntrospectionListTypeRef>; +export type IntrospectionInputTypeRef = IntrospectionNamedTypeRef | IntrospectionListTypeRef | IntrospectionNonNullTypeRef | IntrospectionListTypeRef>; +export interface IntrospectionNamedTypeRef { + readonly kind: T['kind']; + readonly name: string; +} +export interface IntrospectionField { + readonly name: string; + readonly description?: Maybe; + readonly args: ReadonlyArray; + readonly type: IntrospectionOutputTypeRef; + readonly isDeprecated: boolean; + readonly deprecationReason: Maybe; +} +export interface IntrospectionInputValue { + readonly name: string; + readonly description?: Maybe; + readonly type: IntrospectionInputTypeRef; + readonly defaultValue: Maybe; + readonly isDeprecated?: boolean; + readonly deprecationReason?: Maybe; +} +export interface IntrospectionEnumValue { + readonly name: string; + readonly description?: Maybe; + readonly isDeprecated: boolean; + readonly deprecationReason: Maybe; +} +export interface IntrospectionDirective { + readonly name: string; + readonly description?: Maybe; + readonly isRepeatable?: boolean; + readonly locations: ReadonlyArray; + readonly args: ReadonlyArray; +} diff --git a/utilities/getIntrospectionQuery.js b/utilities/getIntrospectionQuery.js new file mode 100644 index 0000000000..4ee27774d9 --- /dev/null +++ b/utilities/getIntrospectionQuery.js @@ -0,0 +1,140 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getIntrospectionQuery = getIntrospectionQuery; +/** + * Produce the GraphQL query recommended for a full schema introspection. + * Accepts optional IntrospectionOptions. + */ +function getIntrospectionQuery(options) { + const optionsWithDefault = { + descriptions: true, + specifiedByUrl: false, + directiveIsRepeatable: false, + schemaDescription: false, + inputValueDeprecation: false, + oneOf: false, + ...options, + }; + const descriptions = optionsWithDefault.descriptions ? 'description' : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl + ? 'specifiedByURL' + : ''; + const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable + ? 'isRepeatable' + : ''; + const schemaDescription = optionsWithDefault.schemaDescription + ? descriptions + : ''; + function inputDeprecation(str) { + return optionsWithDefault.inputValueDeprecation ? str : ''; + } + const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : ''; + return ` + query IntrospectionQuery { + __schema { + ${schemaDescription} + queryType { name kind } + mutationType { name kind } + subscriptionType { name kind } + types { + ...FullType + } + directives { + name + ${descriptions} + ${directiveIsRepeatable} + locations + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + } + } + } + + fragment FullType on __Type { + kind + name + ${descriptions} + ${specifiedByUrl} + ${oneOf} + fields(includeDeprecated: true) { + name + ${descriptions} + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + ${descriptions} + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } + } + + fragment InputValue on __InputValue { + name + ${descriptions} + type { ...TypeRef } + defaultValue + ${inputDeprecation('isDeprecated')} + ${inputDeprecation('deprecationReason')} + } + + fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + } + } + `; +} +//# sourceMappingURL=getIntrospectionQuery.js.map \ No newline at end of file diff --git a/utilities/getIntrospectionQuery.js.map b/utilities/getIntrospectionQuery.js.map new file mode 100644 index 0000000000..b5ac5aa5ce --- /dev/null +++ b/utilities/getIntrospectionQuery.js.map @@ -0,0 +1 @@ +{"version":3,"file":"getIntrospectionQuery.js","sourceRoot":"","sources":["../../src/utilities/getIntrospectionQuery.ts"],"names":[],"mappings":";;AAgDA,sDAsIC;AA1ID;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,OAA8B;IAClE,MAAM,kBAAkB,GAAG;QACzB,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,KAAK;QAC5B,iBAAiB,EAAE,KAAK;QACxB,qBAAqB,EAAE,KAAK;QAC5B,KAAK,EAAE,KAAK;QACZ,GAAG,OAAO;KACX,CAAC;IAEF,MAAM,YAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc;QACtD,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,qBAAqB;QACpE,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,iBAAiB;QAC5D,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,EAAE,CAAC;IAEP,SAAS,gBAAgB,CAAC,GAAW;QACnC,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,CAAC;IACD,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,OAAO;;;UAGC,iBAAiB;;;;;;;;;YASf,YAAY;YACZ,qBAAqB;;gBAEjB,gBAAgB,CAAC,2BAA2B,CAAC;;;;;;;;;;QAUrD,YAAY;QACZ,cAAc;QACd,KAAK;;;UAGH,YAAY;cACR,gBAAgB,CAAC,2BAA2B,CAAC;;;;;;;;;mBASxC,gBAAgB,CAAC,2BAA2B,CAAC;;;;;;;;UAQtD,YAAY;;;;;;;;;;;QAWd,YAAY;;;QAGZ,gBAAgB,CAAC,cAAc,CAAC;QAChC,gBAAgB,CAAC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2C1C,CAAC;AACJ,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { DirectiveLocation } from '../language/directiveLocation.js';\n\nimport type { TypeKind } from '../type/introspection.js';\n\nexport interface IntrospectionOptions {\n /**\n * Whether to include descriptions in the introspection result.\n * Default: true\n */\n descriptions?: boolean;\n\n /**\n * Whether to include `specifiedByURL` in the introspection result.\n * Default: false\n */\n specifiedByUrl?: boolean;\n\n /**\n * Whether to include `isRepeatable` flag on directives.\n * Default: false\n */\n directiveIsRepeatable?: boolean;\n\n /**\n * Whether to include `description` field on schema.\n * Default: false\n */\n schemaDescription?: boolean;\n\n /**\n * Whether target GraphQL server support deprecation of input values.\n * Default: false\n */\n inputValueDeprecation?: boolean;\n\n /**\n * Whether target GraphQL server supports `@oneOf` input objects.\n * Default: false\n */\n oneOf?: boolean;\n}\n\n/**\n * Produce the GraphQL query recommended for a full schema introspection.\n * Accepts optional IntrospectionOptions.\n */\nexport function getIntrospectionQuery(options?: IntrospectionOptions): string {\n const optionsWithDefault = {\n descriptions: true,\n specifiedByUrl: false,\n directiveIsRepeatable: false,\n schemaDescription: false,\n inputValueDeprecation: false,\n oneOf: false,\n ...options,\n };\n\n const descriptions = optionsWithDefault.descriptions ? 'description' : '';\n const specifiedByUrl = optionsWithDefault.specifiedByUrl\n ? 'specifiedByURL'\n : '';\n const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable\n ? 'isRepeatable'\n : '';\n const schemaDescription = optionsWithDefault.schemaDescription\n ? descriptions\n : '';\n\n function inputDeprecation(str: string) {\n return optionsWithDefault.inputValueDeprecation ? str : '';\n }\n const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : '';\n\n return `\n query IntrospectionQuery {\n __schema {\n ${schemaDescription}\n queryType { name kind }\n mutationType { name kind }\n subscriptionType { name kind }\n types {\n ...FullType\n }\n directives {\n name\n ${descriptions}\n ${directiveIsRepeatable}\n locations\n args${inputDeprecation('(includeDeprecated: true)')} {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n ${descriptions}\n ${specifiedByUrl}\n ${oneOf}\n fields(includeDeprecated: true) {\n name\n ${descriptions}\n args${inputDeprecation('(includeDeprecated: true)')} {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields${inputDeprecation('(includeDeprecated: true)')} {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n ${descriptions}\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n ${descriptions}\n type { ...TypeRef }\n defaultValue\n ${inputDeprecation('isDeprecated')}\n ${inputDeprecation('deprecationReason')}\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n `;\n}\n\nexport interface IntrospectionQuery {\n readonly __schema: IntrospectionSchema;\n}\n\nexport interface IntrospectionSchema {\n readonly description?: Maybe;\n readonly queryType: IntrospectionNamedTypeRef;\n readonly mutationType: Maybe<\n IntrospectionNamedTypeRef\n >;\n readonly subscriptionType: Maybe<\n IntrospectionNamedTypeRef\n >;\n readonly types: ReadonlyArray;\n readonly directives: ReadonlyArray;\n}\n\nexport type IntrospectionType =\n | IntrospectionScalarType\n | IntrospectionObjectType\n | IntrospectionInterfaceType\n | IntrospectionUnionType\n | IntrospectionEnumType\n | IntrospectionInputObjectType;\n\nexport type IntrospectionOutputType =\n | IntrospectionScalarType\n | IntrospectionObjectType\n | IntrospectionInterfaceType\n | IntrospectionUnionType\n | IntrospectionEnumType;\n\nexport type IntrospectionInputType =\n | IntrospectionScalarType\n | IntrospectionEnumType\n | IntrospectionInputObjectType;\n\nexport interface IntrospectionScalarType {\n readonly kind: typeof TypeKind.SCALAR;\n readonly name: string;\n readonly description?: Maybe;\n readonly specifiedByURL?: Maybe;\n}\n\nexport interface IntrospectionObjectType {\n readonly kind: typeof TypeKind.OBJECT;\n readonly name: string;\n readonly description?: Maybe;\n readonly fields: ReadonlyArray;\n readonly interfaces: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n}\n\nexport interface IntrospectionInterfaceType {\n readonly kind: typeof TypeKind.INTERFACE;\n readonly name: string;\n readonly description?: Maybe;\n readonly fields: ReadonlyArray;\n readonly interfaces: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n readonly possibleTypes: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n}\n\nexport interface IntrospectionUnionType {\n readonly kind: typeof TypeKind.UNION;\n readonly name: string;\n readonly description?: Maybe;\n readonly possibleTypes: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n}\n\nexport interface IntrospectionEnumType {\n readonly kind: typeof TypeKind.ENUM;\n readonly name: string;\n readonly description?: Maybe;\n readonly enumValues: ReadonlyArray;\n}\n\nexport interface IntrospectionInputObjectType {\n readonly kind: typeof TypeKind.INPUT_OBJECT;\n readonly name: string;\n readonly description?: Maybe;\n readonly inputFields: ReadonlyArray;\n readonly isOneOf: boolean;\n}\n\nexport interface IntrospectionListTypeRef<\n T extends IntrospectionTypeRef = IntrospectionTypeRef,\n> {\n readonly kind: typeof TypeKind.LIST;\n readonly ofType: T;\n}\n\nexport interface IntrospectionNonNullTypeRef<\n T extends IntrospectionTypeRef = IntrospectionTypeRef,\n> {\n readonly kind: typeof TypeKind.NON_NULL;\n readonly ofType: T;\n}\n\nexport type IntrospectionTypeRef =\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n | IntrospectionNonNullTypeRef<\n IntrospectionNamedTypeRef | IntrospectionListTypeRef\n >;\n\nexport type IntrospectionOutputTypeRef =\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n | IntrospectionNonNullTypeRef<\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n >;\n\nexport type IntrospectionInputTypeRef =\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n | IntrospectionNonNullTypeRef<\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n >;\n\nexport interface IntrospectionNamedTypeRef<\n T extends IntrospectionType = IntrospectionType,\n> {\n readonly kind: T['kind'];\n readonly name: string;\n}\n\nexport interface IntrospectionField {\n readonly name: string;\n readonly description?: Maybe;\n readonly args: ReadonlyArray;\n readonly type: IntrospectionOutputTypeRef;\n readonly isDeprecated: boolean;\n readonly deprecationReason: Maybe;\n}\n\nexport interface IntrospectionInputValue {\n readonly name: string;\n readonly description?: Maybe;\n readonly type: IntrospectionInputTypeRef;\n readonly defaultValue: Maybe;\n readonly isDeprecated?: boolean;\n readonly deprecationReason?: Maybe;\n}\n\nexport interface IntrospectionEnumValue {\n readonly name: string;\n readonly description?: Maybe;\n readonly isDeprecated: boolean;\n readonly deprecationReason: Maybe;\n}\n\nexport interface IntrospectionDirective {\n readonly name: string;\n readonly description?: Maybe;\n readonly isRepeatable?: boolean;\n readonly locations: ReadonlyArray;\n readonly args: ReadonlyArray;\n}\n"]} \ No newline at end of file diff --git a/utilities/getIntrospectionQuery.mjs b/utilities/getIntrospectionQuery.mjs new file mode 100644 index 0000000000..9c58045904 --- /dev/null +++ b/utilities/getIntrospectionQuery.mjs @@ -0,0 +1,137 @@ +/** + * Produce the GraphQL query recommended for a full schema introspection. + * Accepts optional IntrospectionOptions. + */ +export function getIntrospectionQuery(options) { + const optionsWithDefault = { + descriptions: true, + specifiedByUrl: false, + directiveIsRepeatable: false, + schemaDescription: false, + inputValueDeprecation: false, + oneOf: false, + ...options, + }; + const descriptions = optionsWithDefault.descriptions ? 'description' : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl + ? 'specifiedByURL' + : ''; + const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable + ? 'isRepeatable' + : ''; + const schemaDescription = optionsWithDefault.schemaDescription + ? descriptions + : ''; + function inputDeprecation(str) { + return optionsWithDefault.inputValueDeprecation ? str : ''; + } + const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : ''; + return ` + query IntrospectionQuery { + __schema { + ${schemaDescription} + queryType { name kind } + mutationType { name kind } + subscriptionType { name kind } + types { + ...FullType + } + directives { + name + ${descriptions} + ${directiveIsRepeatable} + locations + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + } + } + } + + fragment FullType on __Type { + kind + name + ${descriptions} + ${specifiedByUrl} + ${oneOf} + fields(includeDeprecated: true) { + name + ${descriptions} + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + ${descriptions} + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } + } + + fragment InputValue on __InputValue { + name + ${descriptions} + type { ...TypeRef } + defaultValue + ${inputDeprecation('isDeprecated')} + ${inputDeprecation('deprecationReason')} + } + + fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + } + } + `; +} +//# sourceMappingURL=getIntrospectionQuery.js.map \ No newline at end of file diff --git a/utilities/getIntrospectionQuery.mjs.map b/utilities/getIntrospectionQuery.mjs.map new file mode 100644 index 0000000000..fc5ec2c39f --- /dev/null +++ b/utilities/getIntrospectionQuery.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"getIntrospectionQuery.js","sourceRoot":"","sources":["../../src/utilities/getIntrospectionQuery.ts"],"names":[],"mappings":"AA4CA;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA8B;IAClE,MAAM,kBAAkB,GAAG;QACzB,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,KAAK;QAC5B,iBAAiB,EAAE,KAAK;QACxB,qBAAqB,EAAE,KAAK;QAC5B,KAAK,EAAE,KAAK;QACZ,GAAG,OAAO;KACX,CAAC;IAEF,MAAM,YAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc;QACtD,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,qBAAqB;QACpE,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,iBAAiB;QAC5D,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,EAAE,CAAC;IAEP,SAAS,gBAAgB,CAAC,GAAW;QACnC,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,CAAC;IACD,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,OAAO;;;UAGC,iBAAiB;;;;;;;;;YASf,YAAY;YACZ,qBAAqB;;gBAEjB,gBAAgB,CAAC,2BAA2B,CAAC;;;;;;;;;;QAUrD,YAAY;QACZ,cAAc;QACd,KAAK;;;UAGH,YAAY;cACR,gBAAgB,CAAC,2BAA2B,CAAC;;;;;;;;;mBASxC,gBAAgB,CAAC,2BAA2B,CAAC;;;;;;;;UAQtD,YAAY;;;;;;;;;;;QAWd,YAAY;;;QAGZ,gBAAgB,CAAC,cAAc,CAAC;QAChC,gBAAgB,CAAC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2C1C,CAAC;AACJ,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { DirectiveLocation } from '../language/directiveLocation.js';\n\nimport type { TypeKind } from '../type/introspection.js';\n\nexport interface IntrospectionOptions {\n /**\n * Whether to include descriptions in the introspection result.\n * Default: true\n */\n descriptions?: boolean;\n\n /**\n * Whether to include `specifiedByURL` in the introspection result.\n * Default: false\n */\n specifiedByUrl?: boolean;\n\n /**\n * Whether to include `isRepeatable` flag on directives.\n * Default: false\n */\n directiveIsRepeatable?: boolean;\n\n /**\n * Whether to include `description` field on schema.\n * Default: false\n */\n schemaDescription?: boolean;\n\n /**\n * Whether target GraphQL server support deprecation of input values.\n * Default: false\n */\n inputValueDeprecation?: boolean;\n\n /**\n * Whether target GraphQL server supports `@oneOf` input objects.\n * Default: false\n */\n oneOf?: boolean;\n}\n\n/**\n * Produce the GraphQL query recommended for a full schema introspection.\n * Accepts optional IntrospectionOptions.\n */\nexport function getIntrospectionQuery(options?: IntrospectionOptions): string {\n const optionsWithDefault = {\n descriptions: true,\n specifiedByUrl: false,\n directiveIsRepeatable: false,\n schemaDescription: false,\n inputValueDeprecation: false,\n oneOf: false,\n ...options,\n };\n\n const descriptions = optionsWithDefault.descriptions ? 'description' : '';\n const specifiedByUrl = optionsWithDefault.specifiedByUrl\n ? 'specifiedByURL'\n : '';\n const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable\n ? 'isRepeatable'\n : '';\n const schemaDescription = optionsWithDefault.schemaDescription\n ? descriptions\n : '';\n\n function inputDeprecation(str: string) {\n return optionsWithDefault.inputValueDeprecation ? str : '';\n }\n const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : '';\n\n return `\n query IntrospectionQuery {\n __schema {\n ${schemaDescription}\n queryType { name kind }\n mutationType { name kind }\n subscriptionType { name kind }\n types {\n ...FullType\n }\n directives {\n name\n ${descriptions}\n ${directiveIsRepeatable}\n locations\n args${inputDeprecation('(includeDeprecated: true)')} {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n ${descriptions}\n ${specifiedByUrl}\n ${oneOf}\n fields(includeDeprecated: true) {\n name\n ${descriptions}\n args${inputDeprecation('(includeDeprecated: true)')} {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields${inputDeprecation('(includeDeprecated: true)')} {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n ${descriptions}\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n ${descriptions}\n type { ...TypeRef }\n defaultValue\n ${inputDeprecation('isDeprecated')}\n ${inputDeprecation('deprecationReason')}\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n `;\n}\n\nexport interface IntrospectionQuery {\n readonly __schema: IntrospectionSchema;\n}\n\nexport interface IntrospectionSchema {\n readonly description?: Maybe;\n readonly queryType: IntrospectionNamedTypeRef;\n readonly mutationType: Maybe<\n IntrospectionNamedTypeRef\n >;\n readonly subscriptionType: Maybe<\n IntrospectionNamedTypeRef\n >;\n readonly types: ReadonlyArray;\n readonly directives: ReadonlyArray;\n}\n\nexport type IntrospectionType =\n | IntrospectionScalarType\n | IntrospectionObjectType\n | IntrospectionInterfaceType\n | IntrospectionUnionType\n | IntrospectionEnumType\n | IntrospectionInputObjectType;\n\nexport type IntrospectionOutputType =\n | IntrospectionScalarType\n | IntrospectionObjectType\n | IntrospectionInterfaceType\n | IntrospectionUnionType\n | IntrospectionEnumType;\n\nexport type IntrospectionInputType =\n | IntrospectionScalarType\n | IntrospectionEnumType\n | IntrospectionInputObjectType;\n\nexport interface IntrospectionScalarType {\n readonly kind: typeof TypeKind.SCALAR;\n readonly name: string;\n readonly description?: Maybe;\n readonly specifiedByURL?: Maybe;\n}\n\nexport interface IntrospectionObjectType {\n readonly kind: typeof TypeKind.OBJECT;\n readonly name: string;\n readonly description?: Maybe;\n readonly fields: ReadonlyArray;\n readonly interfaces: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n}\n\nexport interface IntrospectionInterfaceType {\n readonly kind: typeof TypeKind.INTERFACE;\n readonly name: string;\n readonly description?: Maybe;\n readonly fields: ReadonlyArray;\n readonly interfaces: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n readonly possibleTypes: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n}\n\nexport interface IntrospectionUnionType {\n readonly kind: typeof TypeKind.UNION;\n readonly name: string;\n readonly description?: Maybe;\n readonly possibleTypes: ReadonlyArray<\n IntrospectionNamedTypeRef\n >;\n}\n\nexport interface IntrospectionEnumType {\n readonly kind: typeof TypeKind.ENUM;\n readonly name: string;\n readonly description?: Maybe;\n readonly enumValues: ReadonlyArray;\n}\n\nexport interface IntrospectionInputObjectType {\n readonly kind: typeof TypeKind.INPUT_OBJECT;\n readonly name: string;\n readonly description?: Maybe;\n readonly inputFields: ReadonlyArray;\n readonly isOneOf: boolean;\n}\n\nexport interface IntrospectionListTypeRef<\n T extends IntrospectionTypeRef = IntrospectionTypeRef,\n> {\n readonly kind: typeof TypeKind.LIST;\n readonly ofType: T;\n}\n\nexport interface IntrospectionNonNullTypeRef<\n T extends IntrospectionTypeRef = IntrospectionTypeRef,\n> {\n readonly kind: typeof TypeKind.NON_NULL;\n readonly ofType: T;\n}\n\nexport type IntrospectionTypeRef =\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n | IntrospectionNonNullTypeRef<\n IntrospectionNamedTypeRef | IntrospectionListTypeRef\n >;\n\nexport type IntrospectionOutputTypeRef =\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n | IntrospectionNonNullTypeRef<\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n >;\n\nexport type IntrospectionInputTypeRef =\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n | IntrospectionNonNullTypeRef<\n | IntrospectionNamedTypeRef\n | IntrospectionListTypeRef\n >;\n\nexport interface IntrospectionNamedTypeRef<\n T extends IntrospectionType = IntrospectionType,\n> {\n readonly kind: T['kind'];\n readonly name: string;\n}\n\nexport interface IntrospectionField {\n readonly name: string;\n readonly description?: Maybe;\n readonly args: ReadonlyArray;\n readonly type: IntrospectionOutputTypeRef;\n readonly isDeprecated: boolean;\n readonly deprecationReason: Maybe;\n}\n\nexport interface IntrospectionInputValue {\n readonly name: string;\n readonly description?: Maybe;\n readonly type: IntrospectionInputTypeRef;\n readonly defaultValue: Maybe;\n readonly isDeprecated?: boolean;\n readonly deprecationReason?: Maybe;\n}\n\nexport interface IntrospectionEnumValue {\n readonly name: string;\n readonly description?: Maybe;\n readonly isDeprecated: boolean;\n readonly deprecationReason: Maybe;\n}\n\nexport interface IntrospectionDirective {\n readonly name: string;\n readonly description?: Maybe;\n readonly isRepeatable?: boolean;\n readonly locations: ReadonlyArray;\n readonly args: ReadonlyArray;\n}\n"]} \ No newline at end of file diff --git a/utilities/getOperationAST.d.ts b/utilities/getOperationAST.d.ts new file mode 100644 index 0000000000..82fe6dc991 --- /dev/null +++ b/utilities/getOperationAST.d.ts @@ -0,0 +1,8 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { DocumentNode, OperationDefinitionNode } from '../language/ast.js'; +/** + * Returns an operation AST given a document AST and optionally an operation + * name. If a name is not provided, an operation is only returned if only one is + * provided in the document. + */ +export declare function getOperationAST(documentAST: DocumentNode, operationName?: Maybe): Maybe; diff --git a/utilities/getOperationAST.js b/utilities/getOperationAST.js new file mode 100644 index 0000000000..054b76ec35 --- /dev/null +++ b/utilities/getOperationAST.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getOperationAST = getOperationAST; +const kinds_js_1 = require("../language/kinds.js"); +/** + * Returns an operation AST given a document AST and optionally an operation + * name. If a name is not provided, an operation is only returned if only one is + * provided in the document. + */ +function getOperationAST(documentAST, operationName) { + let operation = null; + for (const definition of documentAST.definitions) { + if (definition.kind === kinds_js_1.Kind.OPERATION_DEFINITION) { + if (operationName == null) { + // If no operation name was provided, only return an Operation if there + // is one defined in the document. Upon encountering the second, return + // null. + if (operation) { + return null; + } + operation = definition; + } + else if (definition.name?.value === operationName) { + return definition; + } + } + } + return operation; +} +//# sourceMappingURL=getOperationAST.js.map \ No newline at end of file diff --git a/utilities/getOperationAST.js.map b/utilities/getOperationAST.js.map new file mode 100644 index 0000000000..e923f3198c --- /dev/null +++ b/utilities/getOperationAST.js.map @@ -0,0 +1 @@ +{"version":3,"file":"getOperationAST.js","sourceRoot":"","sources":["../../src/utilities/getOperationAST.ts"],"names":[],"mappings":";;AAUA,0CAqBC;AA5BD,mDAA4C;AAE5C;;;;GAIG;AACH,SAAgB,eAAe,CAC7B,WAAyB,EACzB,aAA6B;IAE7B,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;QACjD,IAAI,UAAU,CAAC,IAAI,KAAK,eAAI,CAAC,oBAAoB,EAAE,CAAC;YAClD,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBAC1B,uEAAuE;gBACvE,uEAAuE;gBACvE,QAAQ;gBACR,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,SAAS,GAAG,UAAU,CAAC;YACzB,CAAC;iBAAM,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,KAAK,aAAa,EAAE,CAAC;gBACpD,OAAO,UAAU,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { DocumentNode, OperationDefinitionNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Returns an operation AST given a document AST and optionally an operation\n * name. If a name is not provided, an operation is only returned if only one is\n * provided in the document.\n */\nexport function getOperationAST(\n documentAST: DocumentNode,\n operationName?: Maybe,\n): Maybe {\n let operation = null;\n for (const definition of documentAST.definitions) {\n if (definition.kind === Kind.OPERATION_DEFINITION) {\n if (operationName == null) {\n // If no operation name was provided, only return an Operation if there\n // is one defined in the document. Upon encountering the second, return\n // null.\n if (operation) {\n return null;\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n return definition;\n }\n }\n }\n return operation;\n}\n"]} \ No newline at end of file diff --git a/utilities/getOperationAST.mjs b/utilities/getOperationAST.mjs new file mode 100644 index 0000000000..4265991af1 --- /dev/null +++ b/utilities/getOperationAST.mjs @@ -0,0 +1,27 @@ +import { Kind } from "../language/kinds.mjs"; +/** + * Returns an operation AST given a document AST and optionally an operation + * name. If a name is not provided, an operation is only returned if only one is + * provided in the document. + */ +export function getOperationAST(documentAST, operationName) { + let operation = null; + for (const definition of documentAST.definitions) { + if (definition.kind === Kind.OPERATION_DEFINITION) { + if (operationName == null) { + // If no operation name was provided, only return an Operation if there + // is one defined in the document. Upon encountering the second, return + // null. + if (operation) { + return null; + } + operation = definition; + } + else if (definition.name?.value === operationName) { + return definition; + } + } + } + return operation; +} +//# sourceMappingURL=getOperationAST.js.map \ No newline at end of file diff --git a/utilities/getOperationAST.mjs.map b/utilities/getOperationAST.mjs.map new file mode 100644 index 0000000000..af8545266f --- /dev/null +++ b/utilities/getOperationAST.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"getOperationAST.js","sourceRoot":"","sources":["../../src/utilities/getOperationAST.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,WAAyB,EACzB,aAA6B;IAE7B,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;QACjD,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAClD,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBAC1B,uEAAuE;gBACvE,uEAAuE;gBACvE,QAAQ;gBACR,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,SAAS,GAAG,UAAU,CAAC;YACzB,CAAC;iBAAM,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,KAAK,aAAa,EAAE,CAAC;gBACpD,OAAO,UAAU,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type { DocumentNode, OperationDefinitionNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Returns an operation AST given a document AST and optionally an operation\n * name. If a name is not provided, an operation is only returned if only one is\n * provided in the document.\n */\nexport function getOperationAST(\n documentAST: DocumentNode,\n operationName?: Maybe,\n): Maybe {\n let operation = null;\n for (const definition of documentAST.definitions) {\n if (definition.kind === Kind.OPERATION_DEFINITION) {\n if (operationName == null) {\n // If no operation name was provided, only return an Operation if there\n // is one defined in the document. Upon encountering the second, return\n // null.\n if (operation) {\n return null;\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n return definition;\n }\n }\n }\n return operation;\n}\n"]} \ No newline at end of file diff --git a/utilities/index.d.ts b/utilities/index.d.ts new file mode 100644 index 0000000000..74c10fe5af --- /dev/null +++ b/utilities/index.d.ts @@ -0,0 +1,30 @@ +export { getIntrospectionQuery } from './getIntrospectionQuery.js'; +export type { IntrospectionOptions, IntrospectionQuery, IntrospectionSchema, IntrospectionType, IntrospectionInputType, IntrospectionOutputType, IntrospectionScalarType, IntrospectionObjectType, IntrospectionInterfaceType, IntrospectionUnionType, IntrospectionEnumType, IntrospectionInputObjectType, IntrospectionTypeRef, IntrospectionInputTypeRef, IntrospectionOutputTypeRef, IntrospectionNamedTypeRef, IntrospectionListTypeRef, IntrospectionNonNullTypeRef, IntrospectionField, IntrospectionInputValue, IntrospectionEnumValue, IntrospectionDirective, } from './getIntrospectionQuery.js'; +export { getOperationAST } from './getOperationAST.js'; +export { introspectionFromSchema } from './introspectionFromSchema.js'; +export { buildClientSchema } from './buildClientSchema.js'; +export { buildASTSchema, buildSchema } from './buildASTSchema.js'; +export type { BuildSchemaOptions } from './buildASTSchema.js'; +export { extendSchema } from './extendSchema.js'; +export { lexicographicSortSchema } from './lexicographicSortSchema.js'; +export { printSchema, printType, printDirective, printIntrospectionSchema, } from './printSchema.js'; +export { typeFromAST } from './typeFromAST.js'; +export { +/** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */ +valueFromAST, } from './valueFromAST.js'; +export { valueFromASTUntyped } from './valueFromASTUntyped.js'; +export { +/** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */ +astFromValue, } from './astFromValue.js'; +export { TypeInfo, visitWithTypeInfo } from './TypeInfo.js'; +export { replaceVariables } from './replaceVariables.js'; +export { valueToLiteral } from './valueToLiteral.js'; +export { coerceInputValue, coerceInputLiteral, } from './coerceInputValue.js'; +export { validateInputValue, validateInputLiteral, } from './validateInputValue.js'; +export { concatAST } from './concatAST.js'; +export { separateOperations } from './separateOperations.js'; +export { stripIgnoredCharacters } from './stripIgnoredCharacters.js'; +export { isEqualType, isTypeSubTypeOf, doTypesOverlap, } from './typeComparators.js'; +export { BreakingChangeType, DangerousChangeType, SafeChangeType, findBreakingChanges, findDangerousChanges, findSchemaChanges, } from './findSchemaChanges.js'; +export type { BreakingChange, DangerousChange, SafeChange, } from './findSchemaChanges.js'; +export type { TypedQueryDocumentNode } from './typedQueryDocumentNode.js'; diff --git a/utilities/index.js b/utilities/index.js new file mode 100644 index 0000000000..4c6688a4c1 --- /dev/null +++ b/utilities/index.js @@ -0,0 +1,88 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.findSchemaChanges = exports.findDangerousChanges = exports.findBreakingChanges = exports.SafeChangeType = exports.DangerousChangeType = exports.BreakingChangeType = exports.doTypesOverlap = exports.isTypeSubTypeOf = exports.isEqualType = exports.stripIgnoredCharacters = exports.separateOperations = exports.concatAST = exports.validateInputLiteral = exports.validateInputValue = exports.coerceInputLiteral = exports.coerceInputValue = exports.valueToLiteral = exports.replaceVariables = exports.visitWithTypeInfo = exports.TypeInfo = exports.astFromValue = exports.valueFromASTUntyped = exports.valueFromAST = exports.typeFromAST = exports.printIntrospectionSchema = exports.printDirective = exports.printType = exports.printSchema = exports.lexicographicSortSchema = exports.extendSchema = exports.buildSchema = exports.buildASTSchema = exports.buildClientSchema = exports.introspectionFromSchema = exports.getOperationAST = exports.getIntrospectionQuery = void 0; +// Produce the GraphQL query recommended for a full schema introspection. +var getIntrospectionQuery_js_1 = require("./getIntrospectionQuery.js"); +Object.defineProperty(exports, "getIntrospectionQuery", { enumerable: true, get: function () { return getIntrospectionQuery_js_1.getIntrospectionQuery; } }); +// Gets the target Operation from a Document. +var getOperationAST_js_1 = require("./getOperationAST.js"); +Object.defineProperty(exports, "getOperationAST", { enumerable: true, get: function () { return getOperationAST_js_1.getOperationAST; } }); +// Convert a GraphQLSchema to an IntrospectionQuery. +var introspectionFromSchema_js_1 = require("./introspectionFromSchema.js"); +Object.defineProperty(exports, "introspectionFromSchema", { enumerable: true, get: function () { return introspectionFromSchema_js_1.introspectionFromSchema; } }); +// Build a GraphQLSchema from an introspection result. +var buildClientSchema_js_1 = require("./buildClientSchema.js"); +Object.defineProperty(exports, "buildClientSchema", { enumerable: true, get: function () { return buildClientSchema_js_1.buildClientSchema; } }); +// Build a GraphQLSchema from GraphQL Schema language. +var buildASTSchema_js_1 = require("./buildASTSchema.js"); +Object.defineProperty(exports, "buildASTSchema", { enumerable: true, get: function () { return buildASTSchema_js_1.buildASTSchema; } }); +Object.defineProperty(exports, "buildSchema", { enumerable: true, get: function () { return buildASTSchema_js_1.buildSchema; } }); +// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. +var extendSchema_js_1 = require("./extendSchema.js"); +Object.defineProperty(exports, "extendSchema", { enumerable: true, get: function () { return extendSchema_js_1.extendSchema; } }); +// Sort a GraphQLSchema. +var lexicographicSortSchema_js_1 = require("./lexicographicSortSchema.js"); +Object.defineProperty(exports, "lexicographicSortSchema", { enumerable: true, get: function () { return lexicographicSortSchema_js_1.lexicographicSortSchema; } }); +// Print a GraphQLSchema to GraphQL Schema language. +var printSchema_js_1 = require("./printSchema.js"); +Object.defineProperty(exports, "printSchema", { enumerable: true, get: function () { return printSchema_js_1.printSchema; } }); +Object.defineProperty(exports, "printType", { enumerable: true, get: function () { return printSchema_js_1.printType; } }); +Object.defineProperty(exports, "printDirective", { enumerable: true, get: function () { return printSchema_js_1.printDirective; } }); +Object.defineProperty(exports, "printIntrospectionSchema", { enumerable: true, get: function () { return printSchema_js_1.printIntrospectionSchema; } }); +// Create a GraphQLType from a GraphQL language AST. +var typeFromAST_js_1 = require("./typeFromAST.js"); +Object.defineProperty(exports, "typeFromAST", { enumerable: true, get: function () { return typeFromAST_js_1.typeFromAST; } }); +// Create a JavaScript value from a GraphQL language AST with a type. +var valueFromAST_js_1 = require("./valueFromAST.js"); +/** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */ +Object.defineProperty(exports, "valueFromAST", { enumerable: true, get: function () { return valueFromAST_js_1.valueFromAST; } }); +// Create a JavaScript value from a GraphQL language AST without a type. +var valueFromASTUntyped_js_1 = require("./valueFromASTUntyped.js"); +Object.defineProperty(exports, "valueFromASTUntyped", { enumerable: true, get: function () { return valueFromASTUntyped_js_1.valueFromASTUntyped; } }); +// Create a GraphQL language AST from a JavaScript value. +var astFromValue_js_1 = require("./astFromValue.js"); +/** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */ +Object.defineProperty(exports, "astFromValue", { enumerable: true, get: function () { return astFromValue_js_1.astFromValue; } }); +// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. +var TypeInfo_js_1 = require("./TypeInfo.js"); +Object.defineProperty(exports, "TypeInfo", { enumerable: true, get: function () { return TypeInfo_js_1.TypeInfo; } }); +Object.defineProperty(exports, "visitWithTypeInfo", { enumerable: true, get: function () { return TypeInfo_js_1.visitWithTypeInfo; } }); +// Converts a value to a const value by replacing variables. +var replaceVariables_js_1 = require("./replaceVariables.js"); +Object.defineProperty(exports, "replaceVariables", { enumerable: true, get: function () { return replaceVariables_js_1.replaceVariables; } }); +// Create a GraphQL literal (AST) from a JavaScript input value. +var valueToLiteral_js_1 = require("./valueToLiteral.js"); +Object.defineProperty(exports, "valueToLiteral", { enumerable: true, get: function () { return valueToLiteral_js_1.valueToLiteral; } }); +var coerceInputValue_js_1 = require("./coerceInputValue.js"); +// Coerces a JavaScript value to a GraphQL type, or returns undefined. +Object.defineProperty(exports, "coerceInputValue", { enumerable: true, get: function () { return coerceInputValue_js_1.coerceInputValue; } }); +// Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined. +Object.defineProperty(exports, "coerceInputLiteral", { enumerable: true, get: function () { return coerceInputValue_js_1.coerceInputLiteral; } }); +var validateInputValue_js_1 = require("./validateInputValue.js"); +// Validate a JavaScript value with a GraphQL type, collecting all errors. +Object.defineProperty(exports, "validateInputValue", { enumerable: true, get: function () { return validateInputValue_js_1.validateInputValue; } }); +// Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors. +Object.defineProperty(exports, "validateInputLiteral", { enumerable: true, get: function () { return validateInputValue_js_1.validateInputLiteral; } }); +// Concatenates multiple AST together. +var concatAST_js_1 = require("./concatAST.js"); +Object.defineProperty(exports, "concatAST", { enumerable: true, get: function () { return concatAST_js_1.concatAST; } }); +// Separates an AST into an AST per Operation. +var separateOperations_js_1 = require("./separateOperations.js"); +Object.defineProperty(exports, "separateOperations", { enumerable: true, get: function () { return separateOperations_js_1.separateOperations; } }); +// Strips characters that are not significant to the validity or execution of a GraphQL document. +var stripIgnoredCharacters_js_1 = require("./stripIgnoredCharacters.js"); +Object.defineProperty(exports, "stripIgnoredCharacters", { enumerable: true, get: function () { return stripIgnoredCharacters_js_1.stripIgnoredCharacters; } }); +// Comparators for types +var typeComparators_js_1 = require("./typeComparators.js"); +Object.defineProperty(exports, "isEqualType", { enumerable: true, get: function () { return typeComparators_js_1.isEqualType; } }); +Object.defineProperty(exports, "isTypeSubTypeOf", { enumerable: true, get: function () { return typeComparators_js_1.isTypeSubTypeOf; } }); +Object.defineProperty(exports, "doTypesOverlap", { enumerable: true, get: function () { return typeComparators_js_1.doTypesOverlap; } }); +// Compares two GraphQLSchemas and detects breaking changes. +var findSchemaChanges_js_1 = require("./findSchemaChanges.js"); +Object.defineProperty(exports, "BreakingChangeType", { enumerable: true, get: function () { return findSchemaChanges_js_1.BreakingChangeType; } }); +Object.defineProperty(exports, "DangerousChangeType", { enumerable: true, get: function () { return findSchemaChanges_js_1.DangerousChangeType; } }); +Object.defineProperty(exports, "SafeChangeType", { enumerable: true, get: function () { return findSchemaChanges_js_1.SafeChangeType; } }); +Object.defineProperty(exports, "findBreakingChanges", { enumerable: true, get: function () { return findSchemaChanges_js_1.findBreakingChanges; } }); +Object.defineProperty(exports, "findDangerousChanges", { enumerable: true, get: function () { return findSchemaChanges_js_1.findDangerousChanges; } }); +Object.defineProperty(exports, "findSchemaChanges", { enumerable: true, get: function () { return findSchemaChanges_js_1.findSchemaChanges; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/utilities/index.js.map b/utilities/index.js.map new file mode 100644 index 0000000000..4596445662 --- /dev/null +++ b/utilities/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;AAAA,yEAAyE;AACzE,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AA2B9B,6CAA6C;AAC7C,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AAExB,oDAAoD;AACpD,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAEhC,sDAAsD;AACtD,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAE1B,sDAAsD;AACtD,yDAAkE;AAAzD,mHAAA,cAAc,OAAA;AAAE,gHAAA,WAAW,OAAA;AAGpC,+EAA+E;AAC/E,qDAAiD;AAAxC,+GAAA,YAAY,OAAA;AAErB,wBAAwB;AACxB,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAEhC,oDAAoD;AACpD,mDAK0B;AAJxB,6GAAA,WAAW,OAAA;AACX,2GAAA,SAAS,OAAA;AACT,gHAAA,cAAc,OAAA;AACd,0HAAA,wBAAwB,OAAA;AAG1B,oDAAoD;AACpD,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AAEpB,qEAAqE;AACrE,qDAG2B;AAFzB,8EAA8E;AAC9E,+GAAA,YAAY,OAAA;AAGd,wEAAwE;AACxE,mEAA+D;AAAtD,6HAAA,mBAAmB,OAAA;AAE5B,yDAAyD;AACzD,qDAG2B;AAFzB,mIAAmI;AACnI,+GAAA,YAAY,OAAA;AAGd,uGAAuG;AACvG,6CAA4D;AAAnD,uGAAA,QAAQ,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAEpC,4DAA4D;AAC5D,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AAEzB,gEAAgE;AAChE,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AAEvB,6DAK+B;AAJ7B,sEAAsE;AACtE,uHAAA,gBAAgB,OAAA;AAChB,2EAA2E;AAC3E,yHAAA,kBAAkB,OAAA;AAGpB,iEAKiC;AAJ/B,0EAA0E;AAC1E,2HAAA,kBAAkB,OAAA;AAClB,+EAA+E;AAC/E,6HAAA,oBAAoB,OAAA;AAGtB,sCAAsC;AACtC,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAElB,8CAA8C;AAC9C,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAE3B,iGAAiG;AACjG,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAE/B,wBAAwB;AACxB,2DAI8B;AAH5B,iHAAA,WAAW,OAAA;AACX,qHAAA,eAAe,OAAA;AACf,oHAAA,cAAc,OAAA;AAGhB,4DAA4D;AAC5D,+DAOgC;AAN9B,0HAAA,kBAAkB,OAAA;AAClB,2HAAA,mBAAmB,OAAA;AACnB,sHAAA,cAAc,OAAA;AACd,2HAAA,mBAAmB,OAAA;AACnB,4HAAA,oBAAoB,OAAA;AACpB,yHAAA,iBAAiB,OAAA","sourcesContent":["// Produce the GraphQL query recommended for a full schema introspection.\nexport { getIntrospectionQuery } from './getIntrospectionQuery.js';\n\nexport type {\n IntrospectionOptions,\n IntrospectionQuery,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionInputType,\n IntrospectionOutputType,\n IntrospectionScalarType,\n IntrospectionObjectType,\n IntrospectionInterfaceType,\n IntrospectionUnionType,\n IntrospectionEnumType,\n IntrospectionInputObjectType,\n IntrospectionTypeRef,\n IntrospectionInputTypeRef,\n IntrospectionOutputTypeRef,\n IntrospectionNamedTypeRef,\n IntrospectionListTypeRef,\n IntrospectionNonNullTypeRef,\n IntrospectionField,\n IntrospectionInputValue,\n IntrospectionEnumValue,\n IntrospectionDirective,\n} from './getIntrospectionQuery.js';\n\n// Gets the target Operation from a Document.\nexport { getOperationAST } from './getOperationAST.js';\n\n// Convert a GraphQLSchema to an IntrospectionQuery.\nexport { introspectionFromSchema } from './introspectionFromSchema.js';\n\n// Build a GraphQLSchema from an introspection result.\nexport { buildClientSchema } from './buildClientSchema.js';\n\n// Build a GraphQLSchema from GraphQL Schema language.\nexport { buildASTSchema, buildSchema } from './buildASTSchema.js';\nexport type { BuildSchemaOptions } from './buildASTSchema.js';\n\n// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.\nexport { extendSchema } from './extendSchema.js';\n\n// Sort a GraphQLSchema.\nexport { lexicographicSortSchema } from './lexicographicSortSchema.js';\n\n// Print a GraphQLSchema to GraphQL Schema language.\nexport {\n printSchema,\n printType,\n printDirective,\n printIntrospectionSchema,\n} from './printSchema.js';\n\n// Create a GraphQLType from a GraphQL language AST.\nexport { typeFromAST } from './typeFromAST.js';\n\n// Create a JavaScript value from a GraphQL language AST with a type.\nexport {\n /** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */\n valueFromAST,\n} from './valueFromAST.js';\n\n// Create a JavaScript value from a GraphQL language AST without a type.\nexport { valueFromASTUntyped } from './valueFromASTUntyped.js';\n\n// Create a GraphQL language AST from a JavaScript value.\nexport {\n /** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */\n astFromValue,\n} from './astFromValue.js';\n\n// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.\nexport { TypeInfo, visitWithTypeInfo } from './TypeInfo.js';\n\n// Converts a value to a const value by replacing variables.\nexport { replaceVariables } from './replaceVariables.js';\n\n// Create a GraphQL literal (AST) from a JavaScript input value.\nexport { valueToLiteral } from './valueToLiteral.js';\n\nexport {\n // Coerces a JavaScript value to a GraphQL type, or returns undefined.\n coerceInputValue,\n // Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined.\n coerceInputLiteral,\n} from './coerceInputValue.js';\n\nexport {\n // Validate a JavaScript value with a GraphQL type, collecting all errors.\n validateInputValue,\n // Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors.\n validateInputLiteral,\n} from './validateInputValue.js';\n\n// Concatenates multiple AST together.\nexport { concatAST } from './concatAST.js';\n\n// Separates an AST into an AST per Operation.\nexport { separateOperations } from './separateOperations.js';\n\n// Strips characters that are not significant to the validity or execution of a GraphQL document.\nexport { stripIgnoredCharacters } from './stripIgnoredCharacters.js';\n\n// Comparators for types\nexport {\n isEqualType,\n isTypeSubTypeOf,\n doTypesOverlap,\n} from './typeComparators.js';\n\n// Compares two GraphQLSchemas and detects breaking changes.\nexport {\n BreakingChangeType,\n DangerousChangeType,\n SafeChangeType,\n findBreakingChanges,\n findDangerousChanges,\n findSchemaChanges,\n} from './findSchemaChanges.js';\nexport type {\n BreakingChange,\n DangerousChange,\n SafeChange,\n} from './findSchemaChanges.js';\n\n// Wrapper type that contains DocumentNode and types that can be deduced from it.\nexport type { TypedQueryDocumentNode } from './typedQueryDocumentNode.js';\n"]} \ No newline at end of file diff --git a/utilities/index.mjs b/utilities/index.mjs new file mode 100644 index 0000000000..29c5bcd5ab --- /dev/null +++ b/utilities/index.mjs @@ -0,0 +1,55 @@ +// Produce the GraphQL query recommended for a full schema introspection. +export { getIntrospectionQuery } from "./getIntrospectionQuery.mjs"; +// Gets the target Operation from a Document. +export { getOperationAST } from "./getOperationAST.mjs"; +// Convert a GraphQLSchema to an IntrospectionQuery. +export { introspectionFromSchema } from "./introspectionFromSchema.mjs"; +// Build a GraphQLSchema from an introspection result. +export { buildClientSchema } from "./buildClientSchema.mjs"; +// Build a GraphQLSchema from GraphQL Schema language. +export { buildASTSchema, buildSchema } from "./buildASTSchema.mjs"; +// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. +export { extendSchema } from "./extendSchema.mjs"; +// Sort a GraphQLSchema. +export { lexicographicSortSchema } from "./lexicographicSortSchema.mjs"; +// Print a GraphQLSchema to GraphQL Schema language. +export { printSchema, printType, printDirective, printIntrospectionSchema, } from "./printSchema.mjs"; +// Create a GraphQLType from a GraphQL language AST. +export { typeFromAST } from "./typeFromAST.mjs"; +// Create a JavaScript value from a GraphQL language AST with a type. +export { +/** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */ +valueFromAST, } from "./valueFromAST.mjs"; +// Create a JavaScript value from a GraphQL language AST without a type. +export { valueFromASTUntyped } from "./valueFromASTUntyped.mjs"; +// Create a GraphQL language AST from a JavaScript value. +export { +/** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */ +astFromValue, } from "./astFromValue.mjs"; +// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. +export { TypeInfo, visitWithTypeInfo } from "./TypeInfo.mjs"; +// Converts a value to a const value by replacing variables. +export { replaceVariables } from "./replaceVariables.mjs"; +// Create a GraphQL literal (AST) from a JavaScript input value. +export { valueToLiteral } from "./valueToLiteral.mjs"; +export { +// Coerces a JavaScript value to a GraphQL type, or returns undefined. +coerceInputValue, +// Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined. +coerceInputLiteral, } from "./coerceInputValue.mjs"; +export { +// Validate a JavaScript value with a GraphQL type, collecting all errors. +validateInputValue, +// Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors. +validateInputLiteral, } from "./validateInputValue.mjs"; +// Concatenates multiple AST together. +export { concatAST } from "./concatAST.mjs"; +// Separates an AST into an AST per Operation. +export { separateOperations } from "./separateOperations.mjs"; +// Strips characters that are not significant to the validity or execution of a GraphQL document. +export { stripIgnoredCharacters } from "./stripIgnoredCharacters.mjs"; +// Comparators for types +export { isEqualType, isTypeSubTypeOf, doTypesOverlap, } from "./typeComparators.mjs"; +// Compares two GraphQLSchemas and detects breaking changes. +export { BreakingChangeType, DangerousChangeType, SafeChangeType, findBreakingChanges, findDangerousChanges, findSchemaChanges, } from "./findSchemaChanges.mjs"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/utilities/index.mjs.map b/utilities/index.mjs.map new file mode 100644 index 0000000000..29ada10fae --- /dev/null +++ b/utilities/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,EAAE,qBAAqB,EAAE,oCAAmC;AA2BnE,6CAA6C;AAC7C,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAEvD,oDAAoD;AACpD,OAAO,EAAE,uBAAuB,EAAE,sCAAqC;AAEvE,sDAAsD;AACtD,OAAO,EAAE,iBAAiB,EAAE,gCAA+B;AAE3D,sDAAsD;AACtD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,6BAA4B;AAGlE,+EAA+E;AAC/E,OAAO,EAAE,YAAY,EAAE,2BAA0B;AAEjD,wBAAwB;AACxB,OAAO,EAAE,uBAAuB,EAAE,sCAAqC;AAEvE,oDAAoD;AACpD,OAAO,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,wBAAwB,GACzB,0BAAyB;AAE1B,oDAAoD;AACpD,OAAO,EAAE,WAAW,EAAE,0BAAyB;AAE/C,qEAAqE;AACrE,OAAO;AACL,8EAA8E;AAC9E,YAAY,GACb,2BAA0B;AAE3B,wEAAwE;AACxE,OAAO,EAAE,mBAAmB,EAAE,kCAAiC;AAE/D,yDAAyD;AACzD,OAAO;AACL,mIAAmI;AACnI,YAAY,GACb,2BAA0B;AAE3B,uGAAuG;AACvG,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,uBAAsB;AAE5D,4DAA4D;AAC5D,OAAO,EAAE,gBAAgB,EAAE,+BAA8B;AAEzD,gEAAgE;AAChE,OAAO,EAAE,cAAc,EAAE,6BAA4B;AAErD,OAAO;AACL,sEAAsE;AACtE,gBAAgB;AAChB,2EAA2E;AAC3E,kBAAkB,GACnB,+BAA8B;AAE/B,OAAO;AACL,0EAA0E;AAC1E,kBAAkB;AAClB,+EAA+E;AAC/E,oBAAoB,GACrB,iCAAgC;AAEjC,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAE3C,8CAA8C;AAC9C,OAAO,EAAE,kBAAkB,EAAE,iCAAgC;AAE7D,iGAAiG;AACjG,OAAO,EAAE,sBAAsB,EAAE,qCAAoC;AAErE,wBAAwB;AACxB,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,GACf,8BAA6B;AAE9B,4DAA4D;AAC5D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB,gCAA+B","sourcesContent":["// Produce the GraphQL query recommended for a full schema introspection.\nexport { getIntrospectionQuery } from './getIntrospectionQuery.js';\n\nexport type {\n IntrospectionOptions,\n IntrospectionQuery,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionInputType,\n IntrospectionOutputType,\n IntrospectionScalarType,\n IntrospectionObjectType,\n IntrospectionInterfaceType,\n IntrospectionUnionType,\n IntrospectionEnumType,\n IntrospectionInputObjectType,\n IntrospectionTypeRef,\n IntrospectionInputTypeRef,\n IntrospectionOutputTypeRef,\n IntrospectionNamedTypeRef,\n IntrospectionListTypeRef,\n IntrospectionNonNullTypeRef,\n IntrospectionField,\n IntrospectionInputValue,\n IntrospectionEnumValue,\n IntrospectionDirective,\n} from './getIntrospectionQuery.js';\n\n// Gets the target Operation from a Document.\nexport { getOperationAST } from './getOperationAST.js';\n\n// Convert a GraphQLSchema to an IntrospectionQuery.\nexport { introspectionFromSchema } from './introspectionFromSchema.js';\n\n// Build a GraphQLSchema from an introspection result.\nexport { buildClientSchema } from './buildClientSchema.js';\n\n// Build a GraphQLSchema from GraphQL Schema language.\nexport { buildASTSchema, buildSchema } from './buildASTSchema.js';\nexport type { BuildSchemaOptions } from './buildASTSchema.js';\n\n// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.\nexport { extendSchema } from './extendSchema.js';\n\n// Sort a GraphQLSchema.\nexport { lexicographicSortSchema } from './lexicographicSortSchema.js';\n\n// Print a GraphQLSchema to GraphQL Schema language.\nexport {\n printSchema,\n printType,\n printDirective,\n printIntrospectionSchema,\n} from './printSchema.js';\n\n// Create a GraphQLType from a GraphQL language AST.\nexport { typeFromAST } from './typeFromAST.js';\n\n// Create a JavaScript value from a GraphQL language AST with a type.\nexport {\n /** @deprecated use `coerceInputLiteral()` instead - will be removed in v18 */\n valueFromAST,\n} from './valueFromAST.js';\n\n// Create a JavaScript value from a GraphQL language AST without a type.\nexport { valueFromASTUntyped } from './valueFromASTUntyped.js';\n\n// Create a GraphQL language AST from a JavaScript value.\nexport {\n /** @deprecated use `valueToLiteral()` instead with care to operate on external values - `astFromValue()` will be removed in v18 */\n astFromValue,\n} from './astFromValue.js';\n\n// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.\nexport { TypeInfo, visitWithTypeInfo } from './TypeInfo.js';\n\n// Converts a value to a const value by replacing variables.\nexport { replaceVariables } from './replaceVariables.js';\n\n// Create a GraphQL literal (AST) from a JavaScript input value.\nexport { valueToLiteral } from './valueToLiteral.js';\n\nexport {\n // Coerces a JavaScript value to a GraphQL type, or returns undefined.\n coerceInputValue,\n // Coerces a GraphQL literal (AST) to a GraphQL type, or returns undefined.\n coerceInputLiteral,\n} from './coerceInputValue.js';\n\nexport {\n // Validate a JavaScript value with a GraphQL type, collecting all errors.\n validateInputValue,\n // Validate a GraphQL literal (AST) with a GraphQL type, collecting all errors.\n validateInputLiteral,\n} from './validateInputValue.js';\n\n// Concatenates multiple AST together.\nexport { concatAST } from './concatAST.js';\n\n// Separates an AST into an AST per Operation.\nexport { separateOperations } from './separateOperations.js';\n\n// Strips characters that are not significant to the validity or execution of a GraphQL document.\nexport { stripIgnoredCharacters } from './stripIgnoredCharacters.js';\n\n// Comparators for types\nexport {\n isEqualType,\n isTypeSubTypeOf,\n doTypesOverlap,\n} from './typeComparators.js';\n\n// Compares two GraphQLSchemas and detects breaking changes.\nexport {\n BreakingChangeType,\n DangerousChangeType,\n SafeChangeType,\n findBreakingChanges,\n findDangerousChanges,\n findSchemaChanges,\n} from './findSchemaChanges.js';\nexport type {\n BreakingChange,\n DangerousChange,\n SafeChange,\n} from './findSchemaChanges.js';\n\n// Wrapper type that contains DocumentNode and types that can be deduced from it.\nexport type { TypedQueryDocumentNode } from './typedQueryDocumentNode.js';\n"]} \ No newline at end of file diff --git a/utilities/introspectionFromSchema.d.ts b/utilities/introspectionFromSchema.d.ts new file mode 100644 index 0000000000..b1515a6d76 --- /dev/null +++ b/utilities/introspectionFromSchema.d.ts @@ -0,0 +1,12 @@ +import type { GraphQLSchema } from '../type/schema.js'; +import type { IntrospectionOptions, IntrospectionQuery } from './getIntrospectionQuery.js'; +/** + * Build an IntrospectionQuery from a GraphQLSchema + * + * IntrospectionQuery is useful for utilities that care about type and field + * relationships, but do not need to traverse through those relationships. + * + * This is the inverse of buildClientSchema. The primary use case is outside + * of the server context, for instance when doing schema comparisons. + */ +export declare function introspectionFromSchema(schema: GraphQLSchema, options?: IntrospectionOptions): IntrospectionQuery; diff --git a/utilities/introspectionFromSchema.js b/utilities/introspectionFromSchema.js new file mode 100644 index 0000000000..e479f4e447 --- /dev/null +++ b/utilities/introspectionFromSchema.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.introspectionFromSchema = introspectionFromSchema; +const invariant_js_1 = require("../jsutils/invariant.js"); +const parser_js_1 = require("../language/parser.js"); +const execute_js_1 = require("../execution/execute.js"); +const getIntrospectionQuery_js_1 = require("./getIntrospectionQuery.js"); +/** + * Build an IntrospectionQuery from a GraphQLSchema + * + * IntrospectionQuery is useful for utilities that care about type and field + * relationships, but do not need to traverse through those relationships. + * + * This is the inverse of buildClientSchema. The primary use case is outside + * of the server context, for instance when doing schema comparisons. + */ +function introspectionFromSchema(schema, options) { + const optionsWithDefaults = { + specifiedByUrl: true, + directiveIsRepeatable: true, + schemaDescription: true, + inputValueDeprecation: true, + oneOf: true, + ...options, + }; + const document = (0, parser_js_1.parse)((0, getIntrospectionQuery_js_1.getIntrospectionQuery)(optionsWithDefaults)); + const result = (0, execute_js_1.executeSync)({ schema, document }); + (result.errors == null && result.data != null) || (0, invariant_js_1.invariant)(false); + return result.data; +} +//# sourceMappingURL=introspectionFromSchema.js.map \ No newline at end of file diff --git a/utilities/introspectionFromSchema.js.map b/utilities/introspectionFromSchema.js.map new file mode 100644 index 0000000000..07610aa8e9 --- /dev/null +++ b/utilities/introspectionFromSchema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"introspectionFromSchema.js","sourceRoot":"","sources":["../../src/utilities/introspectionFromSchema.ts"],"names":[],"mappings":";;AAuBA,0DAiBC;AAxCD,0DAAoD;AAEpD,qDAA8C;AAI9C,wDAAsD;AAMtD,yEAAmE;AAEnE;;;;;;;;GAQG;AACH,SAAgB,uBAAuB,CACrC,MAAqB,EACrB,OAA8B;IAE9B,MAAM,mBAAmB,GAAG;QAC1B,cAAc,EAAE,IAAI;QACpB,qBAAqB,EAAE,IAAI;QAC3B,iBAAiB,EAAE,IAAI;QACvB,qBAAqB,EAAE,IAAI;QAC3B,KAAK,EAAE,IAAI;QACX,GAAG,OAAO;KACX,CAAC;IAEF,MAAM,QAAQ,GAAG,IAAA,iBAAK,EAAC,IAAA,gDAAqB,EAAC,mBAAmB,CAAC,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,IAAA,wBAAW,EAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAU,MAAM,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI,SAAtD,wBAAS,SAA+C;IACxD,OAAO,MAAM,CAAC,IAAW,CAAC;AAC5B,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\n\nimport { parse } from '../language/parser.js';\n\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { executeSync } from '../execution/execute.js';\n\nimport type {\n IntrospectionOptions,\n IntrospectionQuery,\n} from './getIntrospectionQuery.js';\nimport { getIntrospectionQuery } from './getIntrospectionQuery.js';\n\n/**\n * Build an IntrospectionQuery from a GraphQLSchema\n *\n * IntrospectionQuery is useful for utilities that care about type and field\n * relationships, but do not need to traverse through those relationships.\n *\n * This is the inverse of buildClientSchema. The primary use case is outside\n * of the server context, for instance when doing schema comparisons.\n */\nexport function introspectionFromSchema(\n schema: GraphQLSchema,\n options?: IntrospectionOptions,\n): IntrospectionQuery {\n const optionsWithDefaults = {\n specifiedByUrl: true,\n directiveIsRepeatable: true,\n schemaDescription: true,\n inputValueDeprecation: true,\n oneOf: true,\n ...options,\n };\n\n const document = parse(getIntrospectionQuery(optionsWithDefaults));\n const result = executeSync({ schema, document });\n invariant(result.errors == null && result.data != null);\n return result.data as any;\n}\n"]} \ No newline at end of file diff --git a/utilities/introspectionFromSchema.mjs b/utilities/introspectionFromSchema.mjs new file mode 100644 index 0000000000..17687ec794 --- /dev/null +++ b/utilities/introspectionFromSchema.mjs @@ -0,0 +1,28 @@ +import { invariant } from "../jsutils/invariant.mjs"; +import { parse } from "../language/parser.mjs"; +import { executeSync } from "../execution/execute.mjs"; +import { getIntrospectionQuery } from "./getIntrospectionQuery.mjs"; +/** + * Build an IntrospectionQuery from a GraphQLSchema + * + * IntrospectionQuery is useful for utilities that care about type and field + * relationships, but do not need to traverse through those relationships. + * + * This is the inverse of buildClientSchema. The primary use case is outside + * of the server context, for instance when doing schema comparisons. + */ +export function introspectionFromSchema(schema, options) { + const optionsWithDefaults = { + specifiedByUrl: true, + directiveIsRepeatable: true, + schemaDescription: true, + inputValueDeprecation: true, + oneOf: true, + ...options, + }; + const document = parse(getIntrospectionQuery(optionsWithDefaults)); + const result = executeSync({ schema, document }); + (result.errors == null && result.data != null) || invariant(false); + return result.data; +} +//# sourceMappingURL=introspectionFromSchema.js.map \ No newline at end of file diff --git a/utilities/introspectionFromSchema.mjs.map b/utilities/introspectionFromSchema.mjs.map new file mode 100644 index 0000000000..6a4a3b6f1a --- /dev/null +++ b/utilities/introspectionFromSchema.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"introspectionFromSchema.js","sourceRoot":"","sources":["../../src/utilities/introspectionFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAEpD,OAAO,EAAE,KAAK,EAAE,+BAA8B;AAI9C,OAAO,EAAE,WAAW,EAAE,iCAAgC;AAMtD,OAAO,EAAE,qBAAqB,EAAE,oCAAmC;AAEnE;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAqB,EACrB,OAA8B;IAE9B,MAAM,mBAAmB,GAAG;QAC1B,cAAc,EAAE,IAAI;QACpB,qBAAqB,EAAE,IAAI;QAC3B,iBAAiB,EAAE,IAAI;QACvB,qBAAqB,EAAE,IAAI;QAC3B,KAAK,EAAE,IAAI;QACX,GAAG,OAAO;KACX,CAAC;IAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAU,MAAM,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI,KAAtD,SAAS,QAA+C;IACxD,OAAO,MAAM,CAAC,IAAW,CAAC;AAC5B,CAAC","sourcesContent":["import { invariant } from '../jsutils/invariant.js';\n\nimport { parse } from '../language/parser.js';\n\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { executeSync } from '../execution/execute.js';\n\nimport type {\n IntrospectionOptions,\n IntrospectionQuery,\n} from './getIntrospectionQuery.js';\nimport { getIntrospectionQuery } from './getIntrospectionQuery.js';\n\n/**\n * Build an IntrospectionQuery from a GraphQLSchema\n *\n * IntrospectionQuery is useful for utilities that care about type and field\n * relationships, but do not need to traverse through those relationships.\n *\n * This is the inverse of buildClientSchema. The primary use case is outside\n * of the server context, for instance when doing schema comparisons.\n */\nexport function introspectionFromSchema(\n schema: GraphQLSchema,\n options?: IntrospectionOptions,\n): IntrospectionQuery {\n const optionsWithDefaults = {\n specifiedByUrl: true,\n directiveIsRepeatable: true,\n schemaDescription: true,\n inputValueDeprecation: true,\n oneOf: true,\n ...options,\n };\n\n const document = parse(getIntrospectionQuery(optionsWithDefaults));\n const result = executeSync({ schema, document });\n invariant(result.errors == null && result.data != null);\n return result.data as any;\n}\n"]} \ No newline at end of file diff --git a/utilities/lexicographicSortSchema.d.ts b/utilities/lexicographicSortSchema.d.ts new file mode 100644 index 0000000000..4c5a7f11fe --- /dev/null +++ b/utilities/lexicographicSortSchema.d.ts @@ -0,0 +1,7 @@ +import { GraphQLSchema } from '../type/schema.js'; +/** + * Sort GraphQLSchema. + * + * This function returns a sorted copy of the given GraphQLSchema. + */ +export declare function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema; diff --git a/utilities/lexicographicSortSchema.js b/utilities/lexicographicSortSchema.js new file mode 100644 index 0000000000..5eee171d63 --- /dev/null +++ b/utilities/lexicographicSortSchema.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.lexicographicSortSchema = lexicographicSortSchema; +const naturalCompare_js_1 = require("../jsutils/naturalCompare.js"); +const schema_js_1 = require("../type/schema.js"); +const mapSchemaConfig_js_1 = require("./mapSchemaConfig.js"); +/** + * Sort GraphQLSchema. + * + * This function returns a sorted copy of the given GraphQLSchema. + */ +function lexicographicSortSchema(schema) { + return new schema_js_1.GraphQLSchema((0, mapSchemaConfig_js_1.mapSchemaConfig)(schema.toConfig(), () => ({ + [mapSchemaConfig_js_1.SchemaElementKind.OBJECT]: (config) => ({ + ...config, + interfaces: () => sortByName(config.interfaces()), + fields: () => sortObjMap(config.fields()), + }), + [mapSchemaConfig_js_1.SchemaElementKind.FIELD]: (config) => ({ + ...config, + args: sortObjMap(config.args), + }), + [mapSchemaConfig_js_1.SchemaElementKind.INTERFACE]: (config) => ({ + ...config, + interfaces: () => sortByName(config.interfaces()), + fields: () => sortObjMap(config.fields()), + }), + [mapSchemaConfig_js_1.SchemaElementKind.UNION]: (config) => ({ + ...config, + types: () => sortByName(config.types()), + }), + [mapSchemaConfig_js_1.SchemaElementKind.ENUM]: (config) => ({ + ...config, + values: () => sortObjMap(config.values()), + }), + [mapSchemaConfig_js_1.SchemaElementKind.INPUT_OBJECT]: (config) => ({ + ...config, + fields: () => sortObjMap(config.fields()), + }), + [mapSchemaConfig_js_1.SchemaElementKind.DIRECTIVE]: (config) => ({ + ...config, + locations: sortBy(config.locations, (x) => x), + args: sortObjMap(config.args), + }), + [mapSchemaConfig_js_1.SchemaElementKind.SCHEMA]: (config) => ({ + ...config, + types: sortByName(config.types), + directives: sortByName(config.directives), + }), + }))); +} +function sortObjMap(map) { + const sortedMap = Object.create(null); + for (const key of Object.keys(map).sort(naturalCompare_js_1.naturalCompare)) { + sortedMap[key] = map[key]; + } + return sortedMap; +} +function sortByName(array) { + return sortBy(array, (obj) => obj.name); +} +function sortBy(array, mapToKey) { + return array.slice().sort((obj1, obj2) => { + const key1 = mapToKey(obj1); + const key2 = mapToKey(obj2); + return (0, naturalCompare_js_1.naturalCompare)(key1, key2); + }); +} +//# sourceMappingURL=lexicographicSortSchema.js.map \ No newline at end of file diff --git a/utilities/lexicographicSortSchema.js.map b/utilities/lexicographicSortSchema.js.map new file mode 100644 index 0000000000..fe2477e543 --- /dev/null +++ b/utilities/lexicographicSortSchema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lexicographicSortSchema.js","sourceRoot":"","sources":["../../src/utilities/lexicographicSortSchema.ts"],"names":[],"mappings":";;AAYA,0DAyCC;AArDD,oEAA8D;AAG9D,iDAAkD;AAElD,6DAA0E;AAE1E;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,MAAqB;IAC3D,OAAO,IAAI,yBAAa,CACtB,IAAA,oCAAe,EAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACxC,CAAC,sCAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACvC,GAAG,MAAM;YACT,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACjD,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;SAC1C,CAAC;QACF,CAAC,sCAAiB,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACtC,GAAG,MAAM;YACT,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;SAC9B,CAAC;QACF,CAAC,sCAAiB,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC1C,GAAG,MAAM;YACT,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACjD,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;SAC1C,CAAC;QACF,CAAC,sCAAiB,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACtC,GAAG,MAAM;YACT,KAAK,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;SACxC,CAAC;QACF,CAAC,sCAAiB,CA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,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,MAAM,CACb,KAAuB,EACvB,QAA6B;IAE7B,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,IAAA,kCAAc,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { naturalCompare } from '../jsutils/naturalCompare.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport { GraphQLSchema } from '../type/schema.js';\n\nimport { mapSchemaConfig, SchemaElementKind } from './mapSchemaConfig.js';\n\n/**\n * Sort GraphQLSchema.\n *\n * This function returns a sorted copy of the given GraphQLSchema.\n */\nexport function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {\n return new GraphQLSchema(\n mapSchemaConfig(schema.toConfig(), () => ({\n [SchemaElementKind.OBJECT]: (config) => ({\n ...config,\n interfaces: () => sortByName(config.interfaces()),\n fields: () => sortObjMap(config.fields()),\n }),\n [SchemaElementKind.FIELD]: (config) => ({\n ...config,\n args: sortObjMap(config.args),\n }),\n [SchemaElementKind.INTERFACE]: (config) => ({\n ...config,\n interfaces: () => sortByName(config.interfaces()),\n fields: () => sortObjMap(config.fields()),\n }),\n [SchemaElementKind.UNION]: (config) => ({\n ...config,\n types: () => sortByName(config.types()),\n }),\n [SchemaElementKind.ENUM]: (config) => ({\n ...config,\n values: () => sortObjMap(config.values()),\n }),\n [SchemaElementKind.INPUT_OBJECT]: (config) => ({\n ...config,\n fields: () => sortObjMap(config.fields()),\n }),\n [SchemaElementKind.DIRECTIVE]: (config) => ({\n ...config,\n locations: sortBy(config.locations, (x) => x),\n args: sortObjMap(config.args),\n }),\n [SchemaElementKind.SCHEMA]: (config) => ({\n ...config,\n types: sortByName(config.types),\n directives: sortByName(config.directives),\n }),\n })),\n );\n}\n\nfunction sortObjMap(map: ObjMap): ObjMap {\n const sortedMap = Object.create(null);\n for (const key of Object.keys(map).sort(naturalCompare)) {\n sortedMap[key] = map[key];\n }\n return sortedMap;\n}\n\nfunction sortByName(\n array: ReadonlyArray,\n): Array {\n return sortBy(array, (obj) => obj.name);\n}\n\nfunction sortBy(\n array: ReadonlyArray,\n mapToKey: (item: T) => string,\n): Array {\n return array.slice().sort((obj1, obj2) => {\n const key1 = mapToKey(obj1);\n const key2 = mapToKey(obj2);\n return naturalCompare(key1, key2);\n });\n}\n"]} \ No newline at end of file diff --git a/utilities/lexicographicSortSchema.mjs b/utilities/lexicographicSortSchema.mjs new file mode 100644 index 0000000000..211e1a900d --- /dev/null +++ b/utilities/lexicographicSortSchema.mjs @@ -0,0 +1,66 @@ +import { naturalCompare } from "../jsutils/naturalCompare.mjs"; +import { GraphQLSchema } from "../type/schema.mjs"; +import { mapSchemaConfig, SchemaElementKind } from "./mapSchemaConfig.mjs"; +/** + * Sort GraphQLSchema. + * + * This function returns a sorted copy of the given GraphQLSchema. + */ +export function lexicographicSortSchema(schema) { + return new GraphQLSchema(mapSchemaConfig(schema.toConfig(), () => ({ + [SchemaElementKind.OBJECT]: (config) => ({ + ...config, + interfaces: () => sortByName(config.interfaces()), + fields: () => sortObjMap(config.fields()), + }), + [SchemaElementKind.FIELD]: (config) => ({ + ...config, + args: sortObjMap(config.args), + }), + [SchemaElementKind.INTERFACE]: (config) => ({ + ...config, + interfaces: () => sortByName(config.interfaces()), + fields: () => sortObjMap(config.fields()), + }), + [SchemaElementKind.UNION]: (config) => ({ + ...config, + types: () => sortByName(config.types()), + }), + [SchemaElementKind.ENUM]: (config) => ({ + ...config, + values: () => sortObjMap(config.values()), + }), + [SchemaElementKind.INPUT_OBJECT]: (config) => ({ + ...config, + fields: () => sortObjMap(config.fields()), + }), + [SchemaElementKind.DIRECTIVE]: (config) => ({ + ...config, + locations: sortBy(config.locations, (x) => x), + args: sortObjMap(config.args), + }), + [SchemaElementKind.SCHEMA]: (config) => ({ + ...config, + types: sortByName(config.types), + directives: sortByName(config.directives), + }), + }))); +} +function sortObjMap(map) { + const sortedMap = Object.create(null); + for (const key of Object.keys(map).sort(naturalCompare)) { + sortedMap[key] = map[key]; + } + return sortedMap; +} +function sortByName(array) { + return sortBy(array, (obj) => obj.name); +} +function sortBy(array, mapToKey) { + return array.slice().sort((obj1, obj2) => { + const key1 = mapToKey(obj1); + const key2 = mapToKey(obj2); + return naturalCompare(key1, key2); + }); +} +//# sourceMappingURL=lexicographicSortSchema.js.map \ No newline at end of file diff --git a/utilities/lexicographicSortSchema.mjs.map b/utilities/lexicographicSortSchema.mjs.map new file mode 100644 index 0000000000..360f93f1ed --- /dev/null +++ b/utilities/lexicographicSortSchema.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"lexicographicSortSchema.js","sourceRoot":"","sources":["../../src/utilities/lexicographicSortSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAG9D,OAAO,EAAE,aAAa,EAAE,2BAA0B;AAElD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,8BAA6B;AAE1E;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAqB;IAC3D,OAAO,IAAI,aAAa,CACtB,eAAe,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACxC,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACvC,GAAG,MAAM;YACT,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACjD,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAA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I,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;SAC9B,CAAC;QACF,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACvC,GAAG,MAAM;YACT,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC;YAC/B,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC;SAC1C,CAAC;KACH,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAO,GAAc;IACtC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QACxD,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,UAAU,CACjB,KAAuB;IAEvB,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,MAAM,CACb,KAAuB,EACvB,QAA6B;IAE7B,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { naturalCompare } from '../jsutils/naturalCompare.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport { GraphQLSchema } from '../type/schema.js';\n\nimport { mapSchemaConfig, SchemaElementKind } from './mapSchemaConfig.js';\n\n/**\n * Sort GraphQLSchema.\n *\n * This function returns a sorted copy of the given GraphQLSchema.\n */\nexport function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {\n return new GraphQLSchema(\n mapSchemaConfig(schema.toConfig(), () => ({\n [SchemaElementKind.OBJECT]: (config) => ({\n ...config,\n interfaces: () => sortByName(config.interfaces()),\n fields: () => sortObjMap(config.fields()),\n }),\n [SchemaElementKind.FIELD]: (config) => ({\n ...config,\n args: sortObjMap(config.args),\n }),\n [SchemaElementKind.INTERFACE]: (config) => ({\n ...config,\n interfaces: () => sortByName(config.interfaces()),\n fields: () => sortObjMap(config.fields()),\n }),\n [SchemaElementKind.UNION]: (config) => ({\n ...config,\n types: () => sortByName(config.types()),\n }),\n [SchemaElementKind.ENUM]: (config) => ({\n ...config,\n values: () => sortObjMap(config.values()),\n }),\n [SchemaElementKind.INPUT_OBJECT]: (config) => ({\n ...config,\n fields: () => sortObjMap(config.fields()),\n }),\n [SchemaElementKind.DIRECTIVE]: (config) => ({\n ...config,\n locations: sortBy(config.locations, (x) => x),\n args: sortObjMap(config.args),\n }),\n [SchemaElementKind.SCHEMA]: (config) => ({\n ...config,\n types: sortByName(config.types),\n directives: sortByName(config.directives),\n }),\n })),\n );\n}\n\nfunction sortObjMap(map: ObjMap): ObjMap {\n const sortedMap = Object.create(null);\n for (const key of Object.keys(map).sort(naturalCompare)) {\n sortedMap[key] = map[key];\n }\n return sortedMap;\n}\n\nfunction sortByName(\n array: ReadonlyArray,\n): Array {\n return sortBy(array, (obj) => obj.name);\n}\n\nfunction sortBy(\n array: ReadonlyArray,\n mapToKey: (item: T) => string,\n): Array {\n return array.slice().sort((obj1, obj2) => {\n const key1 = mapToKey(obj1);\n const key2 = mapToKey(obj2);\n return naturalCompare(key1, key2);\n });\n}\n"]} \ No newline at end of file diff --git a/utilities/mapSchemaConfig.d.ts b/utilities/mapSchemaConfig.d.ts new file mode 100644 index 0000000000..29fddf1ddb --- /dev/null +++ b/utilities/mapSchemaConfig.d.ts @@ -0,0 +1,66 @@ +import type { GraphQLArgumentNormalizedConfig, GraphQLEnumTypeNormalizedConfig, GraphQLEnumValueConfig, GraphQLFieldNormalizedConfig, GraphQLInputFieldConfig, GraphQLInputObjectTypeNormalizedConfig, GraphQLInterfaceTypeNormalizedConfig, GraphQLNamedType, GraphQLObjectTypeNormalizedConfig, GraphQLScalarTypeNormalizedConfig, GraphQLUnionTypeNormalizedConfig } from '../type/definition.js'; +import type { GraphQLDirectiveNormalizedConfig } from '../type/directives.js'; +import type { GraphQLSchemaNormalizedConfig } from '../type/schema.js'; +/** + * The set of GraphQL Schema Elements. + */ +export declare const SchemaElementKind: { + readonly SCHEMA: "SCHEMA"; + readonly SCALAR: "SCALAR"; + readonly OBJECT: "OBJECT"; + readonly FIELD: "FIELD"; + readonly ARGUMENT: "ARGUMENT"; + readonly INTERFACE: "INTERFACE"; + readonly UNION: "UNION"; + readonly ENUM: "ENUM"; + readonly ENUM_VALUE: "ENUM_VALUE"; + readonly INPUT_OBJECT: "INPUT_OBJECT"; + readonly INPUT_FIELD: "INPUT_FIELD"; + readonly DIRECTIVE: "DIRECTIVE"; +}; +type SchemaElementKind = (typeof SchemaElementKind)[keyof typeof SchemaElementKind]; +export interface MappedSchemaContext { + getNamedType: (typeName: string) => GraphQLNamedType; + setNamedType: (type: GraphQLNamedType) => void; + getNamedTypes: () => ReadonlyArray; +} +type GraphQLScalarTypeMappedConfig = GraphQLScalarTypeNormalizedConfig; +type EnsureThunks = { + [K in keyof T]: K extends ThunkFields ? () => T[K] : T[K]; +}; +type GraphQLObjectTypeMappedConfig = EnsureThunks, 'interfaces' | 'fields'>; +type GraphQLInterfaceTypeMappedConfig = EnsureThunks, 'interfaces' | 'fields'>; +type GraphQLUnionTypeMappedConfig = EnsureThunks; +type GraphQLEnumTypeMappedConfig = EnsureThunks; +type GraphQLInputObjectTypeMappedConfig = EnsureThunks; +type ScalarTypeConfigMapper = (scalarConfig: GraphQLScalarTypeMappedConfig) => GraphQLScalarTypeMappedConfig; +type ObjectTypeConfigMapper = (objectConfig: GraphQLObjectTypeMappedConfig) => GraphQLObjectTypeMappedConfig; +type FieldConfigMapper = (fieldConfig: GraphQLFieldNormalizedConfig, parentTypeName: string) => GraphQLFieldNormalizedConfig; +type ArgumentConfigMapper = (argConfig: GraphQLArgumentNormalizedConfig, fieldOrDirectiveName: string, parentTypeName?: string) => GraphQLArgumentNormalizedConfig; +type InterfaceTypeConfigMapper = (interfaceConfig: GraphQLInterfaceTypeMappedConfig) => GraphQLInterfaceTypeMappedConfig; +type UnionTypeConfigMapper = (unionConfig: GraphQLUnionTypeMappedConfig) => GraphQLUnionTypeMappedConfig; +type EnumTypeConfigMapper = (enumConfig: GraphQLEnumTypeMappedConfig) => GraphQLEnumTypeMappedConfig; +type EnumValueConfigMapper = (enumValueConfig: GraphQLEnumValueConfig, valueName: string, enumName: string) => GraphQLEnumValueConfig; +type InputObjectTypeConfigMapper = (inputObjectConfig: GraphQLInputObjectTypeMappedConfig) => GraphQLInputObjectTypeMappedConfig; +type InputFieldConfigMapper = (inputFieldConfig: GraphQLInputFieldConfig, inputFieldName: string, inputObjectTypeName: string) => GraphQLInputFieldConfig; +type DirectiveConfigMapper = (directiveConfig: GraphQLDirectiveNormalizedConfig) => GraphQLDirectiveNormalizedConfig; +type SchemaConfigMapper = (originalSchemaConfig: GraphQLSchemaNormalizedConfig) => GraphQLSchemaNormalizedConfig; +export interface ConfigMapperMap { + [SchemaElementKind.SCALAR]?: ScalarTypeConfigMapper; + [SchemaElementKind.OBJECT]?: ObjectTypeConfigMapper; + [SchemaElementKind.FIELD]?: FieldConfigMapper; + [SchemaElementKind.ARGUMENT]?: ArgumentConfigMapper; + [SchemaElementKind.INTERFACE]?: InterfaceTypeConfigMapper; + [SchemaElementKind.UNION]?: UnionTypeConfigMapper; + [SchemaElementKind.ENUM]?: EnumTypeConfigMapper; + [SchemaElementKind.ENUM_VALUE]?: EnumValueConfigMapper; + [SchemaElementKind.INPUT_OBJECT]?: InputObjectTypeConfigMapper; + [SchemaElementKind.INPUT_FIELD]?: InputFieldConfigMapper; + [SchemaElementKind.DIRECTIVE]?: DirectiveConfigMapper; + [SchemaElementKind.SCHEMA]?: SchemaConfigMapper; +} +/** + * @internal + */ +export declare function mapSchemaConfig(schemaConfig: GraphQLSchemaNormalizedConfig, configMapperMapFn: (context: MappedSchemaContext) => ConfigMapperMap): GraphQLSchemaNormalizedConfig; +export {}; diff --git a/utilities/mapSchemaConfig.js b/utilities/mapSchemaConfig.js new file mode 100644 index 0000000000..f233db694d --- /dev/null +++ b/utilities/mapSchemaConfig.js @@ -0,0 +1,252 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SchemaElementKind = void 0; +exports.mapSchemaConfig = mapSchemaConfig; +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const definition_js_1 = require("../type/definition.js"); +const directives_js_1 = require("../type/directives.js"); +const introspection_js_1 = require("../type/introspection.js"); +const scalars_js_1 = require("../type/scalars.js"); +/** + * The set of GraphQL Schema Elements. + */ +exports.SchemaElementKind = { + SCHEMA: 'SCHEMA', + SCALAR: 'SCALAR', + OBJECT: 'OBJECT', + FIELD: 'FIELD', + ARGUMENT: 'ARGUMENT', + INTERFACE: 'INTERFACE', + UNION: 'UNION', + ENUM: 'ENUM', + ENUM_VALUE: 'ENUM_VALUE', + INPUT_OBJECT: 'INPUT_OBJECT', + INPUT_FIELD: 'INPUT_FIELD', + DIRECTIVE: 'DIRECTIVE', +}; +/** + * @internal + */ +function mapSchemaConfig(schemaConfig, configMapperMapFn) { + const configMapperMap = configMapperMapFn({ + getNamedType, + setNamedType, + getNamedTypes, + }); + const mappedTypeMap = new Map(); + for (const type of schemaConfig.types) { + const typeName = type.name; + const mappedNamedType = mapNamedType(type); + if (mappedNamedType) { + mappedTypeMap.set(typeName, mappedNamedType); + } + } + const mappedDirectives = []; + for (const directive of schemaConfig.directives) { + if ((0, directives_js_1.isSpecifiedDirective)(directive)) { + // Builtin directives cannot be mapped. + mappedDirectives.push(directive); + continue; + } + const mappedDirectiveConfig = mapDirective(directive.toConfig()); + if (mappedDirectiveConfig) { + mappedDirectives.push(new directives_js_1.GraphQLDirective(mappedDirectiveConfig)); + } + } + const mappedSchemaConfig = { + ...schemaConfig, + query: schemaConfig.query && + getNamedType(schemaConfig.query.name), + mutation: schemaConfig.mutation && + getNamedType(schemaConfig.mutation.name), + subscription: schemaConfig.subscription && + getNamedType(schemaConfig.subscription.name), + types: Array.from(mappedTypeMap.values()), + directives: mappedDirectives, + }; + const schemaMapper = configMapperMap[exports.SchemaElementKind.SCHEMA]; + return schemaMapper == null + ? mappedSchemaConfig + : schemaMapper(mappedSchemaConfig); + function getType(type) { + if ((0, definition_js_1.isListType)(type)) { + return new definition_js_1.GraphQLList(getType(type.ofType)); + } + if ((0, definition_js_1.isNonNullType)(type)) { + return new definition_js_1.GraphQLNonNull(getType(type.ofType)); + } + return getNamedType(type.name); + } + function getNamedType(typeName) { + const type = stdTypeMap.get(typeName) ?? mappedTypeMap.get(typeName); + (type !== undefined) || (0, invariant_js_1.invariant)(false, `Unknown type: "${typeName}".`); + return type; + } + function setNamedType(type) { + mappedTypeMap.set(type.name, type); + } + function getNamedTypes() { + return Array.from(mappedTypeMap.values()); + } + function mapNamedType(type) { + if ((0, introspection_js_1.isIntrospectionType)(type) || (0, scalars_js_1.isSpecifiedScalarType)(type)) { + // Builtin types cannot be mapped. + return type; + } + if ((0, definition_js_1.isScalarType)(type)) { + return mapScalarType(type); + } + if ((0, definition_js_1.isObjectType)(type)) { + return mapObjectType(type); + } + if ((0, definition_js_1.isInterfaceType)(type)) { + return mapInterfaceType(type); + } + if ((0, definition_js_1.isUnionType)(type)) { + return mapUnionType(type); + } + if ((0, definition_js_1.isEnumType)(type)) { + return mapEnumType(type); + } + if ((0, definition_js_1.isInputObjectType)(type)) { + return mapInputObjectType(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible type definition nodes have been considered. + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected type: ' + (0, inspect_js_1.inspect)(type)); + } + function mapScalarType(type) { + let mappedConfig = type.toConfig(); + const mapper = configMapperMap[exports.SchemaElementKind.SCALAR]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new definition_js_1.GraphQLScalarType(mappedConfig); + } + function mapObjectType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + interfaces: () => config.interfaces.map((iface) => getNamedType(iface.name)), + fields: () => mapFields(config.fields, type.name), + }; + const mapper = configMapperMap[exports.SchemaElementKind.OBJECT]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new definition_js_1.GraphQLObjectType(mappedConfig); + } + function mapFields(fieldMap, parentTypeName) { + const newFieldMap = Object.create(null); + for (const [fieldName, field] of Object.entries(fieldMap)) { + let mappedField = { + ...field, + type: getType(field.type), + args: mapArgs(field.args, parentTypeName, fieldName), + }; + const mapper = configMapperMap[exports.SchemaElementKind.FIELD]; + if (mapper) { + mappedField = mapper(mappedField, parentTypeName); + } + newFieldMap[fieldName] = mappedField; + } + return newFieldMap; + } + function mapArgs(argumentMap, fieldOrDirectiveName, parentTypeName) { + const newArgumentMap = Object.create(null); + for (const [argName, arg] of Object.entries(argumentMap)) { + let mappedArg = { + ...arg, + type: getType(arg.type), + }; + const mapper = configMapperMap[exports.SchemaElementKind.ARGUMENT]; + if (mapper) { + mappedArg = mapper(mappedArg, fieldOrDirectiveName, parentTypeName); + } + newArgumentMap[argName] = mappedArg; + } + return newArgumentMap; + } + function mapInterfaceType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + interfaces: () => config.interfaces.map((iface) => getNamedType(iface.name)), + fields: () => mapFields(config.fields, type.name), + }; + const mapper = configMapperMap[exports.SchemaElementKind.INTERFACE]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new definition_js_1.GraphQLInterfaceType(mappedConfig); + } + function mapUnionType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + types: () => config.types.map((memberType) => getNamedType(memberType.name)), + }; + const mapper = configMapperMap[exports.SchemaElementKind.UNION]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new definition_js_1.GraphQLUnionType(mappedConfig); + } + function mapEnumType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + values: () => { + const newEnumValues = Object.create(null); + for (const [valueName, value] of Object.entries(config.values)) { + const mappedValue = mapEnumValue(value, valueName, type.name); + newEnumValues[valueName] = mappedValue; + } + return newEnumValues; + }, + }; + const mapper = configMapperMap[exports.SchemaElementKind.ENUM]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new definition_js_1.GraphQLEnumType(mappedConfig); + } + function mapEnumValue(valueConfig, valueName, enumName) { + const mappedConfig = { ...valueConfig }; + const mapper = configMapperMap[exports.SchemaElementKind.ENUM_VALUE]; + return mapper == null + ? mappedConfig + : mapper(mappedConfig, valueName, enumName); + } + function mapInputObjectType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + fields: () => { + const newInputFieldMap = Object.create(null); + for (const [fieldName, field] of Object.entries(config.fields)) { + const mappedField = mapInputField(field, fieldName, type.name); + newInputFieldMap[fieldName] = mappedField; + } + return newInputFieldMap; + }, + }; + const mapper = configMapperMap[exports.SchemaElementKind.INPUT_OBJECT]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new definition_js_1.GraphQLInputObjectType(mappedConfig); + } + function mapInputField(inputFieldConfig, inputFieldName, inputObjectTypeName) { + const mappedConfig = { + ...inputFieldConfig, + type: getType(inputFieldConfig.type), + }; + const mapper = configMapperMap[exports.SchemaElementKind.INPUT_FIELD]; + return mapper == null + ? mappedConfig + : mapper(mappedConfig, inputFieldName, inputObjectTypeName); + } + function mapDirective(config) { + const mappedConfig = { + ...config, + args: mapArgs(config.args, config.name, undefined), + }; + const mapper = configMapperMap[exports.SchemaElementKind.DIRECTIVE]; + return mapper == null ? mappedConfig : mapper(mappedConfig); + } +} +const stdTypeMap = new Map([...scalars_js_1.specifiedScalarTypes, ...introspection_js_1.introspectionTypes].map((type) => [ + type.name, + type, +])); +//# sourceMappingURL=mapSchemaConfig.js.map \ No newline at end of file diff --git a/utilities/mapSchemaConfig.js.map b/utilities/mapSchemaConfig.js.map new file mode 100644 index 0000000000..715954c49f --- /dev/null +++ b/utilities/mapSchemaConfig.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mapSchemaConfig.js","sourceRoot":"","sources":["../../src/utilities/mapSchemaConfig.ts"],"names":[],"mappings":";;;AAoLA,0CAoRC;AAxcD,sDAAgD;AAChD,0DAAoD;AAmBpD,yDAiB+B;AAE/B,yDAA+E;AAC/E,+DAGkC;AAClC,mDAG4B;AAG5B;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,KAAK,EAAE,OAAgB;IACvB,QAAQ,EAAE,UAAmB;IAC7B,SAAS,EAAE,WAAoB;IAC/B,KAAK,EAAE,OAAgB;IACvB,IAAI,EAAE,MAAe;IACrB,UAAU,EAAE,YAAqB;IACjC,YAAY,EAAE,cAAuB;IACrC,WAAW,EAAE,aAAsB;IACnC,SAAS,EAAE,WAAoB;CACvB,CAAC;AA+GX;;GAEG;AACH,SAAgB,eAAe,CAC7B,YAA2C,EAC3C,iBAAoE;IAEpE,MAAM,eAAe,GAAG,iBAAiB,CAAC;QACxC,YAAY;QACZ,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC1D,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,eAAe,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AE,mBAAmB,CAAC,CAAC;IAChE,CAAC;IAED,SAAS,YAAY,CACnB,MAAwC;QAExC,MAAM,YAAY,GAAG;YACnB,GAAG,MAAM;YACT,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC;SACnD,CAAC;QACF,MAAM,MAAM,GAAG,eAAe,CAAC,yBAAiB,CAAC,SAAS,CAAC,CAAC;QAC5D,OAAO,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,CAAC,GAAG,iCAAoB,EAAE,GAAG,qCAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC7D,IAAI,CAAC,IAAI;IACT,IAAI;CACL,CAAC,CACH,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n GraphQLArgumentNormalizedConfig,\n GraphQLEnumTypeNormalizedConfig,\n GraphQLEnumValueConfig,\n GraphQLFieldNormalizedConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLFieldNormalizedConfigMap,\n GraphQLInputFieldConfig,\n GraphQLInputObjectTypeNormalizedConfig,\n GraphQLInterfaceTypeNormalizedConfig,\n GraphQLNamedType,\n GraphQLObjectTypeNormalizedConfig,\n GraphQLScalarTypeNormalizedConfig,\n GraphQLType,\n GraphQLUnionTypeNormalizedConfig,\n} from '../type/definition.js';\nimport {\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isListType,\n isNonNullType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from '../type/definition.js';\nimport type { GraphQLDirectiveNormalizedConfig } from '../type/directives.js';\nimport { GraphQLDirective, isSpecifiedDirective } from '../type/directives.js';\nimport {\n introspectionTypes,\n isIntrospectionType,\n} from '../type/introspection.js';\nimport {\n isSpecifiedScalarType,\n specifiedScalarTypes,\n} from '../type/scalars.js';\nimport type { GraphQLSchemaNormalizedConfig } from '../type/schema.js';\n\n/**\n * The set of GraphQL Schema Elements.\n */\nexport const SchemaElementKind = {\n SCHEMA: 'SCHEMA' as const,\n SCALAR: 'SCALAR' as const,\n OBJECT: 'OBJECT' as const,\n FIELD: 'FIELD' as const,\n ARGUMENT: 'ARGUMENT' as const,\n INTERFACE: 'INTERFACE' as const,\n UNION: 'UNION' as const,\n ENUM: 'ENUM' as const,\n ENUM_VALUE: 'ENUM_VALUE' as const,\n INPUT_OBJECT: 'INPUT_OBJECT' as const,\n INPUT_FIELD: 'INPUT_FIELD' as const,\n DIRECTIVE: 'DIRECTIVE' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\ntype SchemaElementKind =\n (typeof SchemaElementKind)[keyof typeof SchemaElementKind];\n\nexport interface MappedSchemaContext {\n getNamedType: (typeName: string) => GraphQLNamedType;\n setNamedType: (type: GraphQLNamedType) => void;\n getNamedTypes: () => ReadonlyArray;\n}\n\ntype GraphQLScalarTypeMappedConfig = GraphQLScalarTypeNormalizedConfig<\n any,\n any\n>;\n\ntype EnsureThunks = {\n [K in keyof T]: K extends ThunkFields ? () => T[K] : T[K];\n};\n\ntype GraphQLObjectTypeMappedConfig = EnsureThunks<\n GraphQLObjectTypeNormalizedConfig,\n 'interfaces' | 'fields'\n>;\ntype GraphQLInterfaceTypeMappedConfig = EnsureThunks<\n GraphQLInterfaceTypeNormalizedConfig,\n 'interfaces' | 'fields'\n>;\ntype GraphQLUnionTypeMappedConfig = EnsureThunks<\n GraphQLUnionTypeNormalizedConfig,\n 'types'\n>;\ntype GraphQLEnumTypeMappedConfig = EnsureThunks<\n GraphQLEnumTypeNormalizedConfig,\n 'values'\n>;\ntype GraphQLInputObjectTypeMappedConfig = EnsureThunks<\n GraphQLInputObjectTypeNormalizedConfig,\n 'fields'\n>;\n\ntype ScalarTypeConfigMapper = (\n scalarConfig: GraphQLScalarTypeMappedConfig,\n) => GraphQLScalarTypeMappedConfig;\n\ntype ObjectTypeConfigMapper = (\n objectConfig: GraphQLObjectTypeMappedConfig,\n) => GraphQLObjectTypeMappedConfig;\n\ntype FieldConfigMapper = (\n fieldConfig: GraphQLFieldNormalizedConfig,\n parentTypeName: string,\n) => GraphQLFieldNormalizedConfig;\n\ntype ArgumentConfigMapper = (\n argConfig: GraphQLArgumentNormalizedConfig,\n fieldOrDirectiveName: string,\n parentTypeName?: string,\n) => GraphQLArgumentNormalizedConfig;\n\ntype InterfaceTypeConfigMapper = (\n interfaceConfig: GraphQLInterfaceTypeMappedConfig,\n) => GraphQLInterfaceTypeMappedConfig;\n\ntype UnionTypeConfigMapper = (\n unionConfig: GraphQLUnionTypeMappedConfig,\n) => GraphQLUnionTypeMappedConfig;\n\ntype EnumTypeConfigMapper = (\n enumConfig: GraphQLEnumTypeMappedConfig,\n) => GraphQLEnumTypeMappedConfig;\n\ntype EnumValueConfigMapper = (\n enumValueConfig: GraphQLEnumValueConfig,\n valueName: string,\n enumName: string,\n) => GraphQLEnumValueConfig;\n\ntype InputObjectTypeConfigMapper = (\n inputObjectConfig: GraphQLInputObjectTypeMappedConfig,\n) => GraphQLInputObjectTypeMappedConfig;\n\ntype InputFieldConfigMapper = (\n inputFieldConfig: GraphQLInputFieldConfig,\n inputFieldName: string,\n inputObjectTypeName: string,\n) => GraphQLInputFieldConfig;\n\ntype DirectiveConfigMapper = (\n directiveConfig: GraphQLDirectiveNormalizedConfig,\n) => GraphQLDirectiveNormalizedConfig;\n\ntype SchemaConfigMapper = (\n originalSchemaConfig: GraphQLSchemaNormalizedConfig,\n) => GraphQLSchemaNormalizedConfig;\n\nexport interface ConfigMapperMap {\n [SchemaElementKind.SCALAR]?: ScalarTypeConfigMapper;\n [SchemaElementKind.OBJECT]?: ObjectTypeConfigMapper;\n [SchemaElementKind.FIELD]?: FieldConfigMapper;\n [SchemaElementKind.ARGUMENT]?: ArgumentConfigMapper;\n [SchemaElementKind.INTERFACE]?: InterfaceTypeConfigMapper;\n [SchemaElementKind.UNION]?: UnionTypeConfigMapper;\n [SchemaElementKind.ENUM]?: EnumTypeConfigMapper;\n [SchemaElementKind.ENUM_VALUE]?: EnumValueConfigMapper;\n [SchemaElementKind.INPUT_OBJECT]?: InputObjectTypeConfigMapper;\n [SchemaElementKind.INPUT_FIELD]?: InputFieldConfigMapper;\n [SchemaElementKind.DIRECTIVE]?: DirectiveConfigMapper;\n [SchemaElementKind.SCHEMA]?: SchemaConfigMapper;\n}\n\n/**\n * @internal\n */\nexport function mapSchemaConfig(\n schemaConfig: GraphQLSchemaNormalizedConfig,\n configMapperMapFn: (context: MappedSchemaContext) => ConfigMapperMap,\n): GraphQLSchemaNormalizedConfig {\n const configMapperMap = configMapperMapFn({\n getNamedType,\n setNamedType,\n getNamedTypes,\n });\n\n const mappedTypeMap = new Map();\n for (const type of schemaConfig.types) {\n const typeName = type.name;\n const mappedNamedType = mapNamedType(type);\n if (mappedNamedType) {\n mappedTypeMap.set(typeName, mappedNamedType);\n }\n }\n\n const mappedDirectives: Array = [];\n for (const directive of schemaConfig.directives) {\n if (isSpecifiedDirective(directive)) {\n // Builtin directives cannot be mapped.\n mappedDirectives.push(directive);\n continue;\n }\n\n const mappedDirectiveConfig = mapDirective(directive.toConfig());\n if (mappedDirectiveConfig) {\n mappedDirectives.push(new GraphQLDirective(mappedDirectiveConfig));\n }\n }\n\n const mappedSchemaConfig = {\n ...schemaConfig,\n query:\n schemaConfig.query &&\n (getNamedType(schemaConfig.query.name) as GraphQLObjectType),\n mutation:\n schemaConfig.mutation &&\n (getNamedType(schemaConfig.mutation.name) as GraphQLObjectType),\n subscription:\n schemaConfig.subscription &&\n (getNamedType(schemaConfig.subscription.name) as GraphQLObjectType),\n types: Array.from(mappedTypeMap.values()),\n directives: mappedDirectives,\n };\n\n const schemaMapper = configMapperMap[SchemaElementKind.SCHEMA];\n\n return schemaMapper == null\n ? mappedSchemaConfig\n : schemaMapper(mappedSchemaConfig);\n\n function getType(type: T): T {\n if (isListType(type)) {\n return new GraphQLList(getType(type.ofType)) as T;\n }\n if (isNonNullType(type)) {\n return new GraphQLNonNull(getType(type.ofType)) as T;\n }\n\n return getNamedType(type.name) as T;\n }\n\n function getNamedType(typeName: string): GraphQLNamedType {\n const type = stdTypeMap.get(typeName) ?? mappedTypeMap.get(typeName);\n invariant(type !== undefined, `Unknown type: \"${typeName}\".`);\n return type;\n }\n\n function setNamedType(type: GraphQLNamedType): void {\n mappedTypeMap.set(type.name, type);\n }\n\n function getNamedTypes(): ReadonlyArray {\n return Array.from(mappedTypeMap.values());\n }\n\n function mapNamedType(type: GraphQLNamedType): Maybe {\n if (isIntrospectionType(type) || isSpecifiedScalarType(type)) {\n // Builtin types cannot be mapped.\n return type;\n }\n\n if (isScalarType(type)) {\n return mapScalarType(type);\n }\n if (isObjectType(type)) {\n return mapObjectType(type);\n }\n if (isInterfaceType(type)) {\n return mapInterfaceType(type);\n }\n if (isUnionType(type)) {\n return mapUnionType(type);\n }\n if (isEnumType(type)) {\n return mapEnumType(type);\n }\n if (isInputObjectType(type)) {\n return mapInputObjectType(type);\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible type definition nodes have been considered.\n invariant(false, 'Unexpected type: ' + inspect(type));\n }\n\n function mapScalarType(type: GraphQLScalarType): GraphQLScalarType {\n let mappedConfig: Maybe = type.toConfig();\n const mapper = configMapperMap[SchemaElementKind.SCALAR];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLScalarType(mappedConfig);\n }\n\n function mapObjectType(type: GraphQLObjectType): GraphQLObjectType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n interfaces: () =>\n config.interfaces.map(\n (iface) => getNamedType(iface.name) as GraphQLInterfaceType,\n ),\n fields: () => mapFields(config.fields, type.name),\n };\n const mapper = configMapperMap[SchemaElementKind.OBJECT];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLObjectType(mappedConfig);\n }\n\n function mapFields(\n fieldMap: GraphQLFieldNormalizedConfigMap,\n parentTypeName: string,\n ): GraphQLFieldNormalizedConfigMap {\n const newFieldMap = Object.create(null);\n for (const [fieldName, field] of Object.entries(fieldMap)) {\n let mappedField = {\n ...field,\n type: getType(field.type),\n args: mapArgs(field.args, parentTypeName, fieldName),\n };\n const mapper = configMapperMap[SchemaElementKind.FIELD];\n if (mapper) {\n mappedField = mapper(mappedField, parentTypeName);\n }\n newFieldMap[fieldName] = mappedField;\n }\n return newFieldMap;\n }\n\n function mapArgs(\n argumentMap: GraphQLFieldNormalizedConfigArgumentMap,\n fieldOrDirectiveName: string,\n parentTypeName?: string,\n ): GraphQLFieldNormalizedConfigArgumentMap {\n const newArgumentMap = Object.create(null);\n\n for (const [argName, arg] of Object.entries(argumentMap)) {\n let mappedArg = {\n ...arg,\n type: getType(arg.type),\n };\n const mapper = configMapperMap[SchemaElementKind.ARGUMENT];\n if (mapper) {\n mappedArg = mapper(mappedArg, fieldOrDirectiveName, parentTypeName);\n }\n newArgumentMap[argName] = mappedArg;\n }\n\n return newArgumentMap;\n }\n\n function mapInterfaceType(type: GraphQLInterfaceType): GraphQLInterfaceType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n interfaces: () =>\n config.interfaces.map(\n (iface) => getNamedType(iface.name) as GraphQLInterfaceType,\n ),\n fields: () => mapFields(config.fields, type.name),\n };\n const mapper = configMapperMap[SchemaElementKind.INTERFACE];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLInterfaceType(mappedConfig);\n }\n\n function mapUnionType(type: GraphQLUnionType): GraphQLUnionType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n types: () =>\n config.types.map(\n (memberType) => getNamedType(memberType.name) as GraphQLObjectType,\n ),\n };\n const mapper = configMapperMap[SchemaElementKind.UNION];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLUnionType(mappedConfig);\n }\n\n function mapEnumType(type: GraphQLEnumType): GraphQLEnumType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n values: () => {\n const newEnumValues = Object.create(null);\n for (const [valueName, value] of Object.entries(config.values)) {\n const mappedValue = mapEnumValue(value, valueName, type.name);\n newEnumValues[valueName] = mappedValue;\n }\n return newEnumValues;\n },\n };\n const mapper = configMapperMap[SchemaElementKind.ENUM];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLEnumType(mappedConfig);\n }\n\n function mapEnumValue(\n valueConfig: GraphQLEnumValueConfig,\n valueName: string,\n enumName: string,\n ): GraphQLEnumValueConfig {\n const mappedConfig = { ...valueConfig };\n const mapper = configMapperMap[SchemaElementKind.ENUM_VALUE];\n return mapper == null\n ? mappedConfig\n : mapper(mappedConfig, valueName, enumName);\n }\n\n function mapInputObjectType(\n type: GraphQLInputObjectType,\n ): GraphQLInputObjectType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n fields: () => {\n const newInputFieldMap = Object.create(null);\n for (const [fieldName, field] of Object.entries(config.fields)) {\n const mappedField = mapInputField(field, fieldName, type.name);\n newInputFieldMap[fieldName] = mappedField;\n }\n return newInputFieldMap;\n },\n };\n const mapper = configMapperMap[SchemaElementKind.INPUT_OBJECT];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLInputObjectType(mappedConfig);\n }\n\n function mapInputField(\n inputFieldConfig: GraphQLInputFieldConfig,\n inputFieldName: string,\n inputObjectTypeName: string,\n ): GraphQLInputFieldConfig {\n const mappedConfig = {\n ...inputFieldConfig,\n type: getType(inputFieldConfig.type),\n };\n const mapper = configMapperMap[SchemaElementKind.INPUT_FIELD];\n return mapper == null\n ? mappedConfig\n : mapper(mappedConfig, inputFieldName, inputObjectTypeName);\n }\n\n function mapDirective(\n config: GraphQLDirectiveNormalizedConfig,\n ): Maybe {\n const mappedConfig = {\n ...config,\n args: mapArgs(config.args, config.name, undefined),\n };\n const mapper = configMapperMap[SchemaElementKind.DIRECTIVE];\n return mapper == null ? mappedConfig : mapper(mappedConfig);\n }\n}\n\nconst stdTypeMap = new Map(\n [...specifiedScalarTypes, ...introspectionTypes].map((type) => [\n type.name,\n type,\n ]),\n);\n"]} \ No newline at end of file diff --git a/utilities/mapSchemaConfig.mjs b/utilities/mapSchemaConfig.mjs new file mode 100644 index 0000000000..5d506ed160 --- /dev/null +++ b/utilities/mapSchemaConfig.mjs @@ -0,0 +1,248 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLUnionType, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, } from "../type/definition.mjs"; +import { GraphQLDirective, isSpecifiedDirective } from "../type/directives.mjs"; +import { introspectionTypes, isIntrospectionType, } from "../type/introspection.mjs"; +import { isSpecifiedScalarType, specifiedScalarTypes, } from "../type/scalars.mjs"; +/** + * The set of GraphQL Schema Elements. + */ +export const SchemaElementKind = { + SCHEMA: 'SCHEMA', + SCALAR: 'SCALAR', + OBJECT: 'OBJECT', + FIELD: 'FIELD', + ARGUMENT: 'ARGUMENT', + INTERFACE: 'INTERFACE', + UNION: 'UNION', + ENUM: 'ENUM', + ENUM_VALUE: 'ENUM_VALUE', + INPUT_OBJECT: 'INPUT_OBJECT', + INPUT_FIELD: 'INPUT_FIELD', + DIRECTIVE: 'DIRECTIVE', +}; +/** + * @internal + */ +export function mapSchemaConfig(schemaConfig, configMapperMapFn) { + const configMapperMap = configMapperMapFn({ + getNamedType, + setNamedType, + getNamedTypes, + }); + const mappedTypeMap = new Map(); + for (const type of schemaConfig.types) { + const typeName = type.name; + const mappedNamedType = mapNamedType(type); + if (mappedNamedType) { + mappedTypeMap.set(typeName, mappedNamedType); + } + } + const mappedDirectives = []; + for (const directive of schemaConfig.directives) { + if (isSpecifiedDirective(directive)) { + // Builtin directives cannot be mapped. + mappedDirectives.push(directive); + continue; + } + const mappedDirectiveConfig = mapDirective(directive.toConfig()); + if (mappedDirectiveConfig) { + mappedDirectives.push(new GraphQLDirective(mappedDirectiveConfig)); + } + } + const mappedSchemaConfig = { + ...schemaConfig, + query: schemaConfig.query && + getNamedType(schemaConfig.query.name), + mutation: schemaConfig.mutation && + getNamedType(schemaConfig.mutation.name), + subscription: schemaConfig.subscription && + getNamedType(schemaConfig.subscription.name), + types: Array.from(mappedTypeMap.values()), + directives: mappedDirectives, + }; + const schemaMapper = configMapperMap[SchemaElementKind.SCHEMA]; + return schemaMapper == null + ? mappedSchemaConfig + : schemaMapper(mappedSchemaConfig); + function getType(type) { + if (isListType(type)) { + return new GraphQLList(getType(type.ofType)); + } + if (isNonNullType(type)) { + return new GraphQLNonNull(getType(type.ofType)); + } + return getNamedType(type.name); + } + function getNamedType(typeName) { + const type = stdTypeMap.get(typeName) ?? mappedTypeMap.get(typeName); + (type !== undefined) || invariant(false, `Unknown type: "${typeName}".`); + return type; + } + function setNamedType(type) { + mappedTypeMap.set(type.name, type); + } + function getNamedTypes() { + return Array.from(mappedTypeMap.values()); + } + function mapNamedType(type) { + if (isIntrospectionType(type) || isSpecifiedScalarType(type)) { + // Builtin types cannot be mapped. + return type; + } + if (isScalarType(type)) { + return mapScalarType(type); + } + if (isObjectType(type)) { + return mapObjectType(type); + } + if (isInterfaceType(type)) { + return mapInterfaceType(type); + } + if (isUnionType(type)) { + return mapUnionType(type); + } + if (isEnumType(type)) { + return mapEnumType(type); + } + if (isInputObjectType(type)) { + return mapInputObjectType(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible type definition nodes have been considered. + (false) || invariant(false, 'Unexpected type: ' + inspect(type)); + } + function mapScalarType(type) { + let mappedConfig = type.toConfig(); + const mapper = configMapperMap[SchemaElementKind.SCALAR]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new GraphQLScalarType(mappedConfig); + } + function mapObjectType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + interfaces: () => config.interfaces.map((iface) => getNamedType(iface.name)), + fields: () => mapFields(config.fields, type.name), + }; + const mapper = configMapperMap[SchemaElementKind.OBJECT]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new GraphQLObjectType(mappedConfig); + } + function mapFields(fieldMap, parentTypeName) { + const newFieldMap = Object.create(null); + for (const [fieldName, field] of Object.entries(fieldMap)) { + let mappedField = { + ...field, + type: getType(field.type), + args: mapArgs(field.args, parentTypeName, fieldName), + }; + const mapper = configMapperMap[SchemaElementKind.FIELD]; + if (mapper) { + mappedField = mapper(mappedField, parentTypeName); + } + newFieldMap[fieldName] = mappedField; + } + return newFieldMap; + } + function mapArgs(argumentMap, fieldOrDirectiveName, parentTypeName) { + const newArgumentMap = Object.create(null); + for (const [argName, arg] of Object.entries(argumentMap)) { + let mappedArg = { + ...arg, + type: getType(arg.type), + }; + const mapper = configMapperMap[SchemaElementKind.ARGUMENT]; + if (mapper) { + mappedArg = mapper(mappedArg, fieldOrDirectiveName, parentTypeName); + } + newArgumentMap[argName] = mappedArg; + } + return newArgumentMap; + } + function mapInterfaceType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + interfaces: () => config.interfaces.map((iface) => getNamedType(iface.name)), + fields: () => mapFields(config.fields, type.name), + }; + const mapper = configMapperMap[SchemaElementKind.INTERFACE]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new GraphQLInterfaceType(mappedConfig); + } + function mapUnionType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + types: () => config.types.map((memberType) => getNamedType(memberType.name)), + }; + const mapper = configMapperMap[SchemaElementKind.UNION]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new GraphQLUnionType(mappedConfig); + } + function mapEnumType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + values: () => { + const newEnumValues = Object.create(null); + for (const [valueName, value] of Object.entries(config.values)) { + const mappedValue = mapEnumValue(value, valueName, type.name); + newEnumValues[valueName] = mappedValue; + } + return newEnumValues; + }, + }; + const mapper = configMapperMap[SchemaElementKind.ENUM]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new GraphQLEnumType(mappedConfig); + } + function mapEnumValue(valueConfig, valueName, enumName) { + const mappedConfig = { ...valueConfig }; + const mapper = configMapperMap[SchemaElementKind.ENUM_VALUE]; + return mapper == null + ? mappedConfig + : mapper(mappedConfig, valueName, enumName); + } + function mapInputObjectType(type) { + const config = type.toConfig(); + let mappedConfig = { + ...config, + fields: () => { + const newInputFieldMap = Object.create(null); + for (const [fieldName, field] of Object.entries(config.fields)) { + const mappedField = mapInputField(field, fieldName, type.name); + newInputFieldMap[fieldName] = mappedField; + } + return newInputFieldMap; + }, + }; + const mapper = configMapperMap[SchemaElementKind.INPUT_OBJECT]; + mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig); + return new GraphQLInputObjectType(mappedConfig); + } + function mapInputField(inputFieldConfig, inputFieldName, inputObjectTypeName) { + const mappedConfig = { + ...inputFieldConfig, + type: getType(inputFieldConfig.type), + }; + const mapper = configMapperMap[SchemaElementKind.INPUT_FIELD]; + return mapper == null + ? mappedConfig + : mapper(mappedConfig, inputFieldName, inputObjectTypeName); + } + function mapDirective(config) { + const mappedConfig = { + ...config, + args: mapArgs(config.args, config.name, undefined), + }; + const mapper = configMapperMap[SchemaElementKind.DIRECTIVE]; + return mapper == null ? mappedConfig : mapper(mappedConfig); + } +} +const stdTypeMap = new Map([...specifiedScalarTypes, ...introspectionTypes].map((type) => [ + type.name, + type, +])); +//# sourceMappingURL=mapSchemaConfig.js.map \ No newline at end of file diff --git a/utilities/mapSchemaConfig.mjs.map b/utilities/mapSchemaConfig.mjs.map new file mode 100644 index 0000000000..f948d1b680 --- /dev/null +++ b/utilities/mapSchemaConfig.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"mapSchemaConfig.js","sourceRoot":"","sources":["../../src/utilities/mapSchemaConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAmBpD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,+BAA8B;AAE/B,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,+BAA8B;AAC/E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,kCAAiC;AAClC,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,4BAA2B;AAG5B;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,KAAK,EAAE,OAAgB;IACvB,QAAQ,EAAE,UAAmB;IAC7B,SAAS,EAAE,WAAoB;IAC/B,KAAK,EAAE,OAAgB;IACvB,IAAI,EAAE,MAAe;IACrB,UAAU,EAAE,YAAqB;IACjC,YAAY,EAAE,cAAuB;IACrC,WAAW,EAAE,aAAsB;IACnC,SAAS,EAAE,WAAoB;CACvB,CAAC;AA+GX;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,YAA2C,EAC3C,iBAAoE;IAEpE,MAAM,eAAe,GAAG,iBAAiB,CAAC;QACxC,YAAY;QACZ,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,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AAiB,CAAC,WAAW,CAAC,CAAC;QAC9D,OAAO,MAAM,IAAI,IAAI;YACnB,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAC;IAChE,CAAC;IAED,SAAS,YAAY,CACnB,MAAwC;QAExC,MAAM,YAAY,GAAG;YACnB,GAAG,MAAM;YACT,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC;SACnD,CAAC;QACF,MAAM,MAAM,GAAG,eAAe,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC5D,OAAO,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,CAAC,GAAG,oBAAoB,EAAE,GAAG,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC7D,IAAI,CAAC,IAAI;IACT,IAAI;CACL,CAAC,CACH,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n GraphQLArgumentNormalizedConfig,\n GraphQLEnumTypeNormalizedConfig,\n GraphQLEnumValueConfig,\n GraphQLFieldNormalizedConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLFieldNormalizedConfigMap,\n GraphQLInputFieldConfig,\n GraphQLInputObjectTypeNormalizedConfig,\n GraphQLInterfaceTypeNormalizedConfig,\n GraphQLNamedType,\n GraphQLObjectTypeNormalizedConfig,\n GraphQLScalarTypeNormalizedConfig,\n GraphQLType,\n GraphQLUnionTypeNormalizedConfig,\n} from '../type/definition.js';\nimport {\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isListType,\n isNonNullType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from '../type/definition.js';\nimport type { GraphQLDirectiveNormalizedConfig } from '../type/directives.js';\nimport { GraphQLDirective, isSpecifiedDirective } from '../type/directives.js';\nimport {\n introspectionTypes,\n isIntrospectionType,\n} from '../type/introspection.js';\nimport {\n isSpecifiedScalarType,\n specifiedScalarTypes,\n} from '../type/scalars.js';\nimport type { GraphQLSchemaNormalizedConfig } from '../type/schema.js';\n\n/**\n * The set of GraphQL Schema Elements.\n */\nexport const SchemaElementKind = {\n SCHEMA: 'SCHEMA' as const,\n SCALAR: 'SCALAR' as const,\n OBJECT: 'OBJECT' as const,\n FIELD: 'FIELD' as const,\n ARGUMENT: 'ARGUMENT' as const,\n INTERFACE: 'INTERFACE' as const,\n UNION: 'UNION' as const,\n ENUM: 'ENUM' as const,\n ENUM_VALUE: 'ENUM_VALUE' as const,\n INPUT_OBJECT: 'INPUT_OBJECT' as const,\n INPUT_FIELD: 'INPUT_FIELD' as const,\n DIRECTIVE: 'DIRECTIVE' as const,\n} as const;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\ntype SchemaElementKind =\n (typeof SchemaElementKind)[keyof typeof SchemaElementKind];\n\nexport interface MappedSchemaContext {\n getNamedType: (typeName: string) => GraphQLNamedType;\n setNamedType: (type: GraphQLNamedType) => void;\n getNamedTypes: () => ReadonlyArray;\n}\n\ntype GraphQLScalarTypeMappedConfig = GraphQLScalarTypeNormalizedConfig<\n any,\n any\n>;\n\ntype EnsureThunks = {\n [K in keyof T]: K extends ThunkFields ? () => T[K] : T[K];\n};\n\ntype GraphQLObjectTypeMappedConfig = EnsureThunks<\n GraphQLObjectTypeNormalizedConfig,\n 'interfaces' | 'fields'\n>;\ntype GraphQLInterfaceTypeMappedConfig = EnsureThunks<\n GraphQLInterfaceTypeNormalizedConfig,\n 'interfaces' | 'fields'\n>;\ntype GraphQLUnionTypeMappedConfig = EnsureThunks<\n GraphQLUnionTypeNormalizedConfig,\n 'types'\n>;\ntype GraphQLEnumTypeMappedConfig = EnsureThunks<\n GraphQLEnumTypeNormalizedConfig,\n 'values'\n>;\ntype GraphQLInputObjectTypeMappedConfig = EnsureThunks<\n GraphQLInputObjectTypeNormalizedConfig,\n 'fields'\n>;\n\ntype ScalarTypeConfigMapper = (\n scalarConfig: GraphQLScalarTypeMappedConfig,\n) => GraphQLScalarTypeMappedConfig;\n\ntype ObjectTypeConfigMapper = (\n objectConfig: GraphQLObjectTypeMappedConfig,\n) => GraphQLObjectTypeMappedConfig;\n\ntype FieldConfigMapper = (\n fieldConfig: GraphQLFieldNormalizedConfig,\n parentTypeName: string,\n) => GraphQLFieldNormalizedConfig;\n\ntype ArgumentConfigMapper = (\n argConfig: GraphQLArgumentNormalizedConfig,\n fieldOrDirectiveName: string,\n parentTypeName?: string,\n) => GraphQLArgumentNormalizedConfig;\n\ntype InterfaceTypeConfigMapper = (\n interfaceConfig: GraphQLInterfaceTypeMappedConfig,\n) => GraphQLInterfaceTypeMappedConfig;\n\ntype UnionTypeConfigMapper = (\n unionConfig: GraphQLUnionTypeMappedConfig,\n) => GraphQLUnionTypeMappedConfig;\n\ntype EnumTypeConfigMapper = (\n enumConfig: GraphQLEnumTypeMappedConfig,\n) => GraphQLEnumTypeMappedConfig;\n\ntype EnumValueConfigMapper = (\n enumValueConfig: GraphQLEnumValueConfig,\n valueName: string,\n enumName: string,\n) => GraphQLEnumValueConfig;\n\ntype InputObjectTypeConfigMapper = (\n inputObjectConfig: GraphQLInputObjectTypeMappedConfig,\n) => GraphQLInputObjectTypeMappedConfig;\n\ntype InputFieldConfigMapper = (\n inputFieldConfig: GraphQLInputFieldConfig,\n inputFieldName: string,\n inputObjectTypeName: string,\n) => GraphQLInputFieldConfig;\n\ntype DirectiveConfigMapper = (\n directiveConfig: GraphQLDirectiveNormalizedConfig,\n) => GraphQLDirectiveNormalizedConfig;\n\ntype SchemaConfigMapper = (\n originalSchemaConfig: GraphQLSchemaNormalizedConfig,\n) => GraphQLSchemaNormalizedConfig;\n\nexport interface ConfigMapperMap {\n [SchemaElementKind.SCALAR]?: ScalarTypeConfigMapper;\n [SchemaElementKind.OBJECT]?: ObjectTypeConfigMapper;\n [SchemaElementKind.FIELD]?: FieldConfigMapper;\n [SchemaElementKind.ARGUMENT]?: ArgumentConfigMapper;\n [SchemaElementKind.INTERFACE]?: InterfaceTypeConfigMapper;\n [SchemaElementKind.UNION]?: UnionTypeConfigMapper;\n [SchemaElementKind.ENUM]?: EnumTypeConfigMapper;\n [SchemaElementKind.ENUM_VALUE]?: EnumValueConfigMapper;\n [SchemaElementKind.INPUT_OBJECT]?: InputObjectTypeConfigMapper;\n [SchemaElementKind.INPUT_FIELD]?: InputFieldConfigMapper;\n [SchemaElementKind.DIRECTIVE]?: DirectiveConfigMapper;\n [SchemaElementKind.SCHEMA]?: SchemaConfigMapper;\n}\n\n/**\n * @internal\n */\nexport function mapSchemaConfig(\n schemaConfig: GraphQLSchemaNormalizedConfig,\n configMapperMapFn: (context: MappedSchemaContext) => ConfigMapperMap,\n): GraphQLSchemaNormalizedConfig {\n const configMapperMap = configMapperMapFn({\n getNamedType,\n setNamedType,\n getNamedTypes,\n });\n\n const mappedTypeMap = new Map();\n for (const type of schemaConfig.types) {\n const typeName = type.name;\n const mappedNamedType = mapNamedType(type);\n if (mappedNamedType) {\n mappedTypeMap.set(typeName, mappedNamedType);\n }\n }\n\n const mappedDirectives: Array = [];\n for (const directive of schemaConfig.directives) {\n if (isSpecifiedDirective(directive)) {\n // Builtin directives cannot be mapped.\n mappedDirectives.push(directive);\n continue;\n }\n\n const mappedDirectiveConfig = mapDirective(directive.toConfig());\n if (mappedDirectiveConfig) {\n mappedDirectives.push(new GraphQLDirective(mappedDirectiveConfig));\n }\n }\n\n const mappedSchemaConfig = {\n ...schemaConfig,\n query:\n schemaConfig.query &&\n (getNamedType(schemaConfig.query.name) as GraphQLObjectType),\n mutation:\n schemaConfig.mutation &&\n (getNamedType(schemaConfig.mutation.name) as GraphQLObjectType),\n subscription:\n schemaConfig.subscription &&\n (getNamedType(schemaConfig.subscription.name) as GraphQLObjectType),\n types: Array.from(mappedTypeMap.values()),\n directives: mappedDirectives,\n };\n\n const schemaMapper = configMapperMap[SchemaElementKind.SCHEMA];\n\n return schemaMapper == null\n ? mappedSchemaConfig\n : schemaMapper(mappedSchemaConfig);\n\n function getType(type: T): T {\n if (isListType(type)) {\n return new GraphQLList(getType(type.ofType)) as T;\n }\n if (isNonNullType(type)) {\n return new GraphQLNonNull(getType(type.ofType)) as T;\n }\n\n return getNamedType(type.name) as T;\n }\n\n function getNamedType(typeName: string): GraphQLNamedType {\n const type = stdTypeMap.get(typeName) ?? mappedTypeMap.get(typeName);\n invariant(type !== undefined, `Unknown type: \"${typeName}\".`);\n return type;\n }\n\n function setNamedType(type: GraphQLNamedType): void {\n mappedTypeMap.set(type.name, type);\n }\n\n function getNamedTypes(): ReadonlyArray {\n return Array.from(mappedTypeMap.values());\n }\n\n function mapNamedType(type: GraphQLNamedType): Maybe {\n if (isIntrospectionType(type) || isSpecifiedScalarType(type)) {\n // Builtin types cannot be mapped.\n return type;\n }\n\n if (isScalarType(type)) {\n return mapScalarType(type);\n }\n if (isObjectType(type)) {\n return mapObjectType(type);\n }\n if (isInterfaceType(type)) {\n return mapInterfaceType(type);\n }\n if (isUnionType(type)) {\n return mapUnionType(type);\n }\n if (isEnumType(type)) {\n return mapEnumType(type);\n }\n if (isInputObjectType(type)) {\n return mapInputObjectType(type);\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible type definition nodes have been considered.\n invariant(false, 'Unexpected type: ' + inspect(type));\n }\n\n function mapScalarType(type: GraphQLScalarType): GraphQLScalarType {\n let mappedConfig: Maybe = type.toConfig();\n const mapper = configMapperMap[SchemaElementKind.SCALAR];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLScalarType(mappedConfig);\n }\n\n function mapObjectType(type: GraphQLObjectType): GraphQLObjectType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n interfaces: () =>\n config.interfaces.map(\n (iface) => getNamedType(iface.name) as GraphQLInterfaceType,\n ),\n fields: () => mapFields(config.fields, type.name),\n };\n const mapper = configMapperMap[SchemaElementKind.OBJECT];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLObjectType(mappedConfig);\n }\n\n function mapFields(\n fieldMap: GraphQLFieldNormalizedConfigMap,\n parentTypeName: string,\n ): GraphQLFieldNormalizedConfigMap {\n const newFieldMap = Object.create(null);\n for (const [fieldName, field] of Object.entries(fieldMap)) {\n let mappedField = {\n ...field,\n type: getType(field.type),\n args: mapArgs(field.args, parentTypeName, fieldName),\n };\n const mapper = configMapperMap[SchemaElementKind.FIELD];\n if (mapper) {\n mappedField = mapper(mappedField, parentTypeName);\n }\n newFieldMap[fieldName] = mappedField;\n }\n return newFieldMap;\n }\n\n function mapArgs(\n argumentMap: GraphQLFieldNormalizedConfigArgumentMap,\n fieldOrDirectiveName: string,\n parentTypeName?: string,\n ): GraphQLFieldNormalizedConfigArgumentMap {\n const newArgumentMap = Object.create(null);\n\n for (const [argName, arg] of Object.entries(argumentMap)) {\n let mappedArg = {\n ...arg,\n type: getType(arg.type),\n };\n const mapper = configMapperMap[SchemaElementKind.ARGUMENT];\n if (mapper) {\n mappedArg = mapper(mappedArg, fieldOrDirectiveName, parentTypeName);\n }\n newArgumentMap[argName] = mappedArg;\n }\n\n return newArgumentMap;\n }\n\n function mapInterfaceType(type: GraphQLInterfaceType): GraphQLInterfaceType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n interfaces: () =>\n config.interfaces.map(\n (iface) => getNamedType(iface.name) as GraphQLInterfaceType,\n ),\n fields: () => mapFields(config.fields, type.name),\n };\n const mapper = configMapperMap[SchemaElementKind.INTERFACE];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLInterfaceType(mappedConfig);\n }\n\n function mapUnionType(type: GraphQLUnionType): GraphQLUnionType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n types: () =>\n config.types.map(\n (memberType) => getNamedType(memberType.name) as GraphQLObjectType,\n ),\n };\n const mapper = configMapperMap[SchemaElementKind.UNION];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLUnionType(mappedConfig);\n }\n\n function mapEnumType(type: GraphQLEnumType): GraphQLEnumType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n values: () => {\n const newEnumValues = Object.create(null);\n for (const [valueName, value] of Object.entries(config.values)) {\n const mappedValue = mapEnumValue(value, valueName, type.name);\n newEnumValues[valueName] = mappedValue;\n }\n return newEnumValues;\n },\n };\n const mapper = configMapperMap[SchemaElementKind.ENUM];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLEnumType(mappedConfig);\n }\n\n function mapEnumValue(\n valueConfig: GraphQLEnumValueConfig,\n valueName: string,\n enumName: string,\n ): GraphQLEnumValueConfig {\n const mappedConfig = { ...valueConfig };\n const mapper = configMapperMap[SchemaElementKind.ENUM_VALUE];\n return mapper == null\n ? mappedConfig\n : mapper(mappedConfig, valueName, enumName);\n }\n\n function mapInputObjectType(\n type: GraphQLInputObjectType,\n ): GraphQLInputObjectType {\n const config = type.toConfig();\n let mappedConfig: Maybe = {\n ...config,\n fields: () => {\n const newInputFieldMap = Object.create(null);\n for (const [fieldName, field] of Object.entries(config.fields)) {\n const mappedField = mapInputField(field, fieldName, type.name);\n newInputFieldMap[fieldName] = mappedField;\n }\n return newInputFieldMap;\n },\n };\n const mapper = configMapperMap[SchemaElementKind.INPUT_OBJECT];\n mappedConfig = mapper == null ? mappedConfig : mapper(mappedConfig);\n return new GraphQLInputObjectType(mappedConfig);\n }\n\n function mapInputField(\n inputFieldConfig: GraphQLInputFieldConfig,\n inputFieldName: string,\n inputObjectTypeName: string,\n ): GraphQLInputFieldConfig {\n const mappedConfig = {\n ...inputFieldConfig,\n type: getType(inputFieldConfig.type),\n };\n const mapper = configMapperMap[SchemaElementKind.INPUT_FIELD];\n return mapper == null\n ? mappedConfig\n : mapper(mappedConfig, inputFieldName, inputObjectTypeName);\n }\n\n function mapDirective(\n config: GraphQLDirectiveNormalizedConfig,\n ): Maybe {\n const mappedConfig = {\n ...config,\n args: mapArgs(config.args, config.name, undefined),\n };\n const mapper = configMapperMap[SchemaElementKind.DIRECTIVE];\n return mapper == null ? mappedConfig : mapper(mappedConfig);\n }\n}\n\nconst stdTypeMap = new Map(\n [...specifiedScalarTypes, ...introspectionTypes].map((type) => [\n type.name,\n type,\n ]),\n);\n"]} \ No newline at end of file diff --git a/utilities/printSchema.d.ts b/utilities/printSchema.d.ts new file mode 100644 index 0000000000..d9facb9dfe --- /dev/null +++ b/utilities/printSchema.d.ts @@ -0,0 +1,7 @@ +import type { GraphQLNamedType } from '../type/definition.js'; +import type { GraphQLDirective } from '../type/directives.js'; +import type { GraphQLSchema } from '../type/schema.js'; +export declare function printSchema(schema: GraphQLSchema): string; +export declare function printIntrospectionSchema(schema: GraphQLSchema): string; +export declare function printType(type: GraphQLNamedType): string; +export declare function printDirective(directive: GraphQLDirective): string; diff --git a/utilities/printSchema.js b/utilities/printSchema.js new file mode 100644 index 0000000000..c4da2b4589 --- /dev/null +++ b/utilities/printSchema.js @@ -0,0 +1,229 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.printSchema = printSchema; +exports.printIntrospectionSchema = printIntrospectionSchema; +exports.printType = printType; +exports.printDirective = printDirective; +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const blockString_js_1 = require("../language/blockString.js"); +const kinds_js_1 = require("../language/kinds.js"); +const printer_js_1 = require("../language/printer.js"); +const definition_js_1 = require("../type/definition.js"); +const directives_js_1 = require("../type/directives.js"); +const introspection_js_1 = require("../type/introspection.js"); +const scalars_js_1 = require("../type/scalars.js"); +const getDefaultValueAST_js_1 = require("./getDefaultValueAST.js"); +function printSchema(schema) { + return printFilteredSchema(schema, (n) => !(0, directives_js_1.isSpecifiedDirective)(n), isDefinedType); +} +function printIntrospectionSchema(schema) { + return printFilteredSchema(schema, directives_js_1.isSpecifiedDirective, introspection_js_1.isIntrospectionType); +} +function isDefinedType(type) { + return !(0, scalars_js_1.isSpecifiedScalarType)(type) && !(0, introspection_js_1.isIntrospectionType)(type); +} +function printFilteredSchema(schema, directiveFilter, typeFilter) { + const directives = schema.getDirectives().filter(directiveFilter); + const types = Object.values(schema.getTypeMap()).filter(typeFilter); + return [ + printSchemaDefinition(schema), + ...directives.map((directive) => printDirective(directive)), + ...types.map((type) => printType(type)), + ] + .filter(Boolean) + .join('\n\n'); +} +function printSchemaDefinition(schema) { + const queryType = schema.getQueryType(); + const mutationType = schema.getMutationType(); + const subscriptionType = schema.getSubscriptionType(); + // Special case: When a schema has no root operation types, no valid schema + // definition can be printed. + if (!queryType && !mutationType && !subscriptionType) { + return; + } + // Only print a schema definition if there is a description or if it should + // not be omitted because of having default type names. + if (schema.description != null || !hasDefaultRootOperationTypes(schema)) { + return (printDescription(schema) + + 'schema {\n' + + (queryType ? ` query: ${queryType}\n` : '') + + (mutationType ? ` mutation: ${mutationType}\n` : '') + + (subscriptionType ? ` subscription: ${subscriptionType}\n` : '') + + '}'); + } +} +/** + * GraphQL schema define root types for each type of operation. These types are + * the same as any other type and can be named in any manner, however there is + * a common naming convention: + * + * ```graphql + * schema { + * query: Query + * mutation: Mutation + * subscription: Subscription + * } + * ``` + * + * When using this naming convention, the schema description can be omitted so + * long as these names are only used for operation types. + * + * Note however that if any of these default names are used elsewhere in the + * schema but not as a root operation type, the schema definition must still + * be printed to avoid ambiguity. + */ +function hasDefaultRootOperationTypes(schema) { + /* eslint-disable eqeqeq */ + return (schema.getQueryType() == schema.getType('Query') && + schema.getMutationType() == schema.getType('Mutation') && + schema.getSubscriptionType() == schema.getType('Subscription')); +} +function printType(type) { + if ((0, definition_js_1.isScalarType)(type)) { + return printScalar(type); + } + if ((0, definition_js_1.isObjectType)(type)) { + return printObject(type); + } + if ((0, definition_js_1.isInterfaceType)(type)) { + return printInterface(type); + } + if ((0, definition_js_1.isUnionType)(type)) { + return printUnion(type); + } + if ((0, definition_js_1.isEnumType)(type)) { + return printEnum(type); + } + if ((0, definition_js_1.isInputObjectType)(type)) { + return printInputObject(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected type: ' + (0, inspect_js_1.inspect)(type)); +} +function printScalar(type) { + return printDescription(type) + `scalar ${type}` + printSpecifiedByURL(type); +} +function printImplementedInterfaces(type) { + const interfaces = type.getInterfaces(); + return interfaces.length + ? ' implements ' + interfaces.map((i) => i.name).join(' & ') + : ''; +} +function printObject(type) { + return (printDescription(type) + + `type ${type}` + + printImplementedInterfaces(type) + + printFields(type)); +} +function printInterface(type) { + return (printDescription(type) + + `interface ${type}` + + printImplementedInterfaces(type) + + printFields(type)); +} +function printUnion(type) { + const types = type.getTypes(); + const possibleTypes = types.length ? ' = ' + types.join(' | ') : ''; + return printDescription(type) + `union ${type.name}` + possibleTypes; +} +function printEnum(type) { + const values = type + .getValues() + .map((value, i) => printDescription(value, ' ', !i) + + ' ' + + value.name + + printDeprecated(value.deprecationReason)); + return printDescription(type) + `enum ${type}` + printBlock(values); +} +function printInputObject(type) { + const fields = Object.values(type.getFields()).map((f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f)); + return (printDescription(type) + + `input ${type}` + + (type.isOneOf ? ' @oneOf' : '') + + printBlock(fields)); +} +function printFields(type) { + const fields = Object.values(type.getFields()).map((f, i) => printDescription(f, ' ', !i) + + ' ' + + f.name + + printArgs(f.args, ' ') + + ': ' + + String(f.type) + + printDeprecated(f.deprecationReason)); + return printBlock(fields); +} +function printBlock(items) { + return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : ''; +} +function printArgs(args, indentation = '') { + if (args.length === 0) { + return ''; + } + // If every arg does not have a description, print them on one line. + if (args.every((arg) => arg.description == null)) { + return '(' + args.map(printInputValue).join(', ') + ')'; + } + return ('(\n' + + args + .map((arg, i) => printDescription(arg, ' ' + indentation, !i) + + ' ' + + indentation + + printInputValue(arg)) + .join('\n') + + '\n' + + indentation + + ')'); +} +function printInputValue(argOrInputField) { + let argDecl = argOrInputField.name + ': ' + String(argOrInputField.type); + const defaultValueAST = (0, getDefaultValueAST_js_1.getDefaultValueAST)(argOrInputField); + if (defaultValueAST) { + argDecl += ` = ${(0, printer_js_1.print)(defaultValueAST)}`; + } + return argDecl + printDeprecated(argOrInputField.deprecationReason); +} +function printDirective(directive) { + return (printDescription(directive) + + `directive ${directive}` + + printArgs(directive.args) + + (directive.isRepeatable ? ' repeatable' : '') + + ' on ' + + directive.locations.join(' | ')); +} +function printDeprecated(reason) { + if (reason == null) { + return ''; + } + if (reason !== directives_js_1.DEFAULT_DEPRECATION_REASON) { + const astValue = (0, printer_js_1.print)({ kind: kinds_js_1.Kind.STRING, value: reason }); + return ` @deprecated(reason: ${astValue})`; + } + return ' @deprecated'; +} +function printSpecifiedByURL(scalar) { + if (scalar.specifiedByURL == null) { + return ''; + } + const astValue = (0, printer_js_1.print)({ + kind: kinds_js_1.Kind.STRING, + value: scalar.specifiedByURL, + }); + return ` @specifiedBy(url: ${astValue})`; +} +function printDescription(def, indentation = '', firstInBlock = true) { + const { description } = def; + if (description == null) { + return ''; + } + const blockString = (0, printer_js_1.print)({ + kind: kinds_js_1.Kind.STRING, + value: description, + block: (0, blockString_js_1.isPrintableAsBlockString)(description), + }); + const prefix = indentation && !firstInBlock ? '\n' + indentation : indentation; + return prefix + blockString.replaceAll('\n', '\n' + indentation) + '\n'; +} +//# sourceMappingURL=printSchema.js.map \ No newline at end of file diff --git a/utilities/printSchema.js.map b/utilities/printSchema.js.map new file mode 100644 index 0000000000..409022557f --- /dev/null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AAI,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,IAAI,CAAC;AAC1E,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport { isPrintableAsBlockString } from '../language/blockString.js';\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n} from '../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport {\n DEFAULT_DEPRECATION_REASON,\n isSpecifiedDirective,\n} from '../type/directives.js';\nimport { isIntrospectionType } from '../type/introspection.js';\nimport { isSpecifiedScalarType } from '../type/scalars.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { getDefaultValueAST } from './getDefaultValueAST.js';\n\nexport function printSchema(schema: GraphQLSchema): string {\n return printFilteredSchema(\n schema,\n (n) => !isSpecifiedDirective(n),\n isDefinedType,\n );\n}\n\nexport function printIntrospectionSchema(schema: GraphQLSchema): string {\n return printFilteredSchema(schema, isSpecifiedDirective, isIntrospectionType);\n}\n\nfunction isDefinedType(type: GraphQLNamedType): boolean {\n return !isSpecifiedScalarType(type) && !isIntrospectionType(type);\n}\n\nfunction printFilteredSchema(\n schema: GraphQLSchema,\n directiveFilter: (type: GraphQLDirective) => boolean,\n typeFilter: (type: GraphQLNamedType) => boolean,\n): string {\n const directives = schema.getDirectives().filter(directiveFilter);\n const types = Object.values(schema.getTypeMap()).filter(typeFilter);\n\n return [\n printSchemaDefinition(schema),\n ...directives.map((directive) => printDirective(directive)),\n ...types.map((type) => printType(type)),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction printSchemaDefinition(schema: GraphQLSchema): Maybe {\n const queryType = schema.getQueryType();\n const mutationType = schema.getMutationType();\n const subscriptionType = schema.getSubscriptionType();\n\n // Special case: When a schema has no root operation types, no valid schema\n // definition can be printed.\n if (!queryType && !mutationType && !subscriptionType) {\n return;\n }\n\n // Only print a schema definition if there is a description or if it should\n // not be omitted because of having default type names.\n if (schema.description != null || !hasDefaultRootOperationTypes(schema)) {\n return (\n printDescription(schema) +\n 'schema {\\n' +\n (queryType ? ` query: ${queryType}\\n` : '') +\n (mutationType ? ` mutation: ${mutationType}\\n` : '') +\n (subscriptionType ? ` subscription: ${subscriptionType}\\n` : '') +\n '}'\n );\n }\n}\n\n/**\n * GraphQL schema define root types for each type of operation. These types are\n * the same as any other type and can be named in any manner, however there is\n * a common naming convention:\n *\n * ```graphql\n * schema {\n * query: Query\n * mutation: Mutation\n * subscription: Subscription\n * }\n * ```\n *\n * When using this naming convention, the schema description can be omitted so\n * long as these names are only used for operation types.\n *\n * Note however that if any of these default names are used elsewhere in the\n * schema but not as a root operation type, the schema definition must still\n * be printed to avoid ambiguity.\n */\nfunction hasDefaultRootOperationTypes(schema: GraphQLSchema): boolean {\n /* eslint-disable eqeqeq */\n return (\n schema.getQueryType() == schema.getType('Query') &&\n schema.getMutationType() == schema.getType('Mutation') &&\n schema.getSubscriptionType() == schema.getType('Subscription')\n );\n}\n\nexport function printType(type: GraphQLNamedType): string {\n if (isScalarType(type)) {\n return printScalar(type);\n }\n if (isObjectType(type)) {\n return printObject(type);\n }\n if (isInterfaceType(type)) {\n return printInterface(type);\n }\n if (isUnionType(type)) {\n return printUnion(type);\n }\n if (isEnumType(type)) {\n return printEnum(type);\n }\n if (isInputObjectType(type)) {\n return printInputObject(type);\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered.\n invariant(false, 'Unexpected type: ' + inspect(type));\n}\n\nfunction printScalar(type: GraphQLScalarType): string {\n return printDescription(type) + `scalar ${type}` + printSpecifiedByURL(type);\n}\n\nfunction printImplementedInterfaces(\n type: GraphQLObjectType | GraphQLInterfaceType,\n): string {\n const interfaces = type.getInterfaces();\n return interfaces.length\n ? ' implements ' + interfaces.map((i) => i.name).join(' & ')\n : '';\n}\n\nfunction printObject(type: GraphQLObjectType): string {\n return (\n printDescription(type) +\n `type ${type}` +\n printImplementedInterfaces(type) +\n printFields(type)\n );\n}\n\nfunction printInterface(type: GraphQLInterfaceType): string {\n return (\n printDescription(type) +\n `interface ${type}` +\n printImplementedInterfaces(type) +\n printFields(type)\n );\n}\n\nfunction printUnion(type: GraphQLUnionType): string {\n const types = type.getTypes();\n const possibleTypes = types.length ? ' = ' + types.join(' | ') : '';\n return printDescription(type) + `union ${type.name}` + possibleTypes;\n}\n\nfunction printEnum(type: GraphQLEnumType): string {\n const values = type\n .getValues()\n .map(\n (value, i) =>\n printDescription(value, ' ', !i) +\n ' ' +\n value.name +\n printDeprecated(value.deprecationReason),\n );\n\n return printDescription(type) + `enum ${type}` + printBlock(values);\n}\n\nfunction printInputObject(type: GraphQLInputObjectType): string {\n const fields = Object.values(type.getFields()).map(\n (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f),\n );\n return (\n printDescription(type) +\n `input ${type}` +\n (type.isOneOf ? ' @oneOf' : '') +\n printBlock(fields)\n );\n}\n\nfunction printFields(type: GraphQLObjectType | GraphQLInterfaceType): string {\n const fields = Object.values(type.getFields()).map(\n (f, i) =>\n printDescription(f, ' ', !i) +\n ' ' +\n f.name +\n printArgs(f.args, ' ') +\n ': ' +\n String(f.type) +\n printDeprecated(f.deprecationReason),\n );\n return printBlock(fields);\n}\n\nfunction printBlock(items: ReadonlyArray): string {\n return items.length !== 0 ? ' {\\n' + items.join('\\n') + '\\n}' : '';\n}\n\nfunction printArgs(\n args: ReadonlyArray,\n indentation: string = '',\n): string {\n if (args.length === 0) {\n return '';\n }\n\n // If every arg does not have a description, print them on one line.\n if (args.every((arg) => arg.description == null)) {\n return '(' + args.map(printInputValue).join(', ') + ')';\n }\n\n return (\n '(\\n' +\n args\n .map(\n (arg, i) =>\n printDescription(arg, ' ' + indentation, !i) +\n ' ' +\n indentation +\n printInputValue(arg),\n )\n .join('\\n') +\n '\\n' +\n indentation +\n ')'\n );\n}\n\nfunction printInputValue(\n argOrInputField: GraphQLArgument | GraphQLInputField,\n): string {\n let argDecl = argOrInputField.name + ': ' + String(argOrInputField.type);\n const defaultValueAST = getDefaultValueAST(argOrInputField);\n if (defaultValueAST) {\n argDecl += ` = ${print(defaultValueAST)}`;\n }\n return argDecl + printDeprecated(argOrInputField.deprecationReason);\n}\n\nexport function printDirective(directive: GraphQLDirective): string {\n return (\n printDescription(directive) +\n `directive ${directive}` +\n printArgs(directive.args) +\n (directive.isRepeatable ? ' repeatable' : '') +\n ' on ' +\n directive.locations.join(' | ')\n );\n}\n\nfunction printDeprecated(reason: Maybe): string {\n if (reason == null) {\n return '';\n }\n if (reason !== DEFAULT_DEPRECATION_REASON) {\n const astValue = print({ kind: Kind.STRING, value: reason });\n return ` @deprecated(reason: ${astValue})`;\n }\n return ' @deprecated';\n}\n\nfunction printSpecifiedByURL(scalar: GraphQLScalarType): string {\n if (scalar.specifiedByURL == null) {\n return '';\n }\n const astValue = print({\n kind: Kind.STRING,\n value: scalar.specifiedByURL,\n });\n return ` @specifiedBy(url: ${astValue})`;\n}\n\nfunction printDescription(\n def: { readonly description: Maybe },\n indentation: string = '',\n firstInBlock: boolean = true,\n): string {\n const { description } = def;\n if (description == null) {\n return '';\n }\n\n const blockString = print({\n kind: Kind.STRING,\n value: description,\n block: isPrintableAsBlockString(description),\n });\n\n const prefix =\n indentation && !firstInBlock ? '\\n' + indentation : indentation;\n\n return prefix + blockString.replaceAll('\\n', '\\n' + indentation) + '\\n';\n}\n"]} \ No newline at end of file diff --git a/utilities/printSchema.mjs b/utilities/printSchema.mjs new file mode 100644 index 0000000000..8d3837f36b --- /dev/null +++ b/utilities/printSchema.mjs @@ -0,0 +1,223 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { isPrintableAsBlockString } from "../language/blockString.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { print } from "../language/printer.mjs"; +import { isEnumType, isInputObjectType, isInterfaceType, isObjectType, isScalarType, isUnionType, } from "../type/definition.mjs"; +import { DEFAULT_DEPRECATION_REASON, isSpecifiedDirective, } from "../type/directives.mjs"; +import { isIntrospectionType } from "../type/introspection.mjs"; +import { isSpecifiedScalarType } from "../type/scalars.mjs"; +import { getDefaultValueAST } from "./getDefaultValueAST.mjs"; +export function printSchema(schema) { + return printFilteredSchema(schema, (n) => !isSpecifiedDirective(n), isDefinedType); +} +export function printIntrospectionSchema(schema) { + return printFilteredSchema(schema, isSpecifiedDirective, isIntrospectionType); +} +function isDefinedType(type) { + return !isSpecifiedScalarType(type) && !isIntrospectionType(type); +} +function printFilteredSchema(schema, directiveFilter, typeFilter) { + const directives = schema.getDirectives().filter(directiveFilter); + const types = Object.values(schema.getTypeMap()).filter(typeFilter); + return [ + printSchemaDefinition(schema), + ...directives.map((directive) => printDirective(directive)), + ...types.map((type) => printType(type)), + ] + .filter(Boolean) + .join('\n\n'); +} +function printSchemaDefinition(schema) { + const queryType = schema.getQueryType(); + const mutationType = schema.getMutationType(); + const subscriptionType = schema.getSubscriptionType(); + // Special case: When a schema has no root operation types, no valid schema + // definition can be printed. + if (!queryType && !mutationType && !subscriptionType) { + return; + } + // Only print a schema definition if there is a description or if it should + // not be omitted because of having default type names. + if (schema.description != null || !hasDefaultRootOperationTypes(schema)) { + return (printDescription(schema) + + 'schema {\n' + + (queryType ? ` query: ${queryType}\n` : '') + + (mutationType ? ` mutation: ${mutationType}\n` : '') + + (subscriptionType ? ` subscription: ${subscriptionType}\n` : '') + + '}'); + } +} +/** + * GraphQL schema define root types for each type of operation. These types are + * the same as any other type and can be named in any manner, however there is + * a common naming convention: + * + * ```graphql + * schema { + * query: Query + * mutation: Mutation + * subscription: Subscription + * } + * ``` + * + * When using this naming convention, the schema description can be omitted so + * long as these names are only used for operation types. + * + * Note however that if any of these default names are used elsewhere in the + * schema but not as a root operation type, the schema definition must still + * be printed to avoid ambiguity. + */ +function hasDefaultRootOperationTypes(schema) { + /* eslint-disable eqeqeq */ + return (schema.getQueryType() == schema.getType('Query') && + schema.getMutationType() == schema.getType('Mutation') && + schema.getSubscriptionType() == schema.getType('Subscription')); +} +export function printType(type) { + if (isScalarType(type)) { + return printScalar(type); + } + if (isObjectType(type)) { + return printObject(type); + } + if (isInterfaceType(type)) { + return printInterface(type); + } + if (isUnionType(type)) { + return printUnion(type); + } + if (isEnumType(type)) { + return printEnum(type); + } + if (isInputObjectType(type)) { + return printInputObject(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + (false) || invariant(false, 'Unexpected type: ' + inspect(type)); +} +function printScalar(type) { + return printDescription(type) + `scalar ${type}` + printSpecifiedByURL(type); +} +function printImplementedInterfaces(type) { + const interfaces = type.getInterfaces(); + return interfaces.length + ? ' implements ' + interfaces.map((i) => i.name).join(' & ') + : ''; +} +function printObject(type) { + return (printDescription(type) + + `type ${type}` + + printImplementedInterfaces(type) + + printFields(type)); +} +function printInterface(type) { + return (printDescription(type) + + `interface ${type}` + + printImplementedInterfaces(type) + + printFields(type)); +} +function printUnion(type) { + const types = type.getTypes(); + const possibleTypes = types.length ? ' = ' + types.join(' | ') : ''; + return printDescription(type) + `union ${type.name}` + possibleTypes; +} +function printEnum(type) { + const values = type + .getValues() + .map((value, i) => printDescription(value, ' ', !i) + + ' ' + + value.name + + printDeprecated(value.deprecationReason)); + return printDescription(type) + `enum ${type}` + printBlock(values); +} +function printInputObject(type) { + const fields = Object.values(type.getFields()).map((f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f)); + return (printDescription(type) + + `input ${type}` + + (type.isOneOf ? ' @oneOf' : '') + + printBlock(fields)); +} +function printFields(type) { + const fields = Object.values(type.getFields()).map((f, i) => printDescription(f, ' ', !i) + + ' ' + + f.name + + printArgs(f.args, ' ') + + ': ' + + String(f.type) + + printDeprecated(f.deprecationReason)); + return printBlock(fields); +} +function printBlock(items) { + return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : ''; +} +function printArgs(args, indentation = '') { + if (args.length === 0) { + return ''; + } + // If every arg does not have a description, print them on one line. + if (args.every((arg) => arg.description == null)) { + return '(' + args.map(printInputValue).join(', ') + ')'; + } + return ('(\n' + + args + .map((arg, i) => printDescription(arg, ' ' + indentation, !i) + + ' ' + + indentation + + printInputValue(arg)) + .join('\n') + + '\n' + + indentation + + ')'); +} +function printInputValue(argOrInputField) { + let argDecl = argOrInputField.name + ': ' + String(argOrInputField.type); + const defaultValueAST = getDefaultValueAST(argOrInputField); + if (defaultValueAST) { + argDecl += ` = ${print(defaultValueAST)}`; + } + return argDecl + printDeprecated(argOrInputField.deprecationReason); +} +export function printDirective(directive) { + return (printDescription(directive) + + `directive ${directive}` + + printArgs(directive.args) + + (directive.isRepeatable ? ' repeatable' : '') + + ' on ' + + directive.locations.join(' | ')); +} +function printDeprecated(reason) { + if (reason == null) { + return ''; + } + if (reason !== DEFAULT_DEPRECATION_REASON) { + const astValue = print({ kind: Kind.STRING, value: reason }); + return ` @deprecated(reason: ${astValue})`; + } + return ' @deprecated'; +} +function printSpecifiedByURL(scalar) { + if (scalar.specifiedByURL == null) { + return ''; + } + const astValue = print({ + kind: Kind.STRING, + value: scalar.specifiedByURL, + }); + return ` @specifiedBy(url: ${astValue})`; +} +function printDescription(def, indentation = '', firstInBlock = true) { + const { description } = def; + if (description == null) { + return ''; + } + const blockString = print({ + kind: Kind.STRING, + value: description, + block: isPrintableAsBlockString(description), + }); + const prefix = indentation && !firstInBlock ? '\n' + indentation : indentation; + return prefix + blockString.replaceAll('\n', '\n' + indentation) + '\n'; +} +//# sourceMappingURL=printSchema.js.map \ No newline at end of file diff --git a/utilities/printSchema.mjs.map b/utilities/printSchema.mjs.map new file mode 100644 index 0000000000..2254b4de2b --- /dev/null +++ b/utilities/printSchema.mj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AEH,MAAM,MAAM,GACV,WAAW,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAElE,OAAO,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,IAAI,CAAC;AAC1E,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\n\nimport { isPrintableAsBlockString } from '../language/blockString.js';\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n} from '../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport {\n DEFAULT_DEPRECATION_REASON,\n isSpecifiedDirective,\n} from '../type/directives.js';\nimport { isIntrospectionType } from '../type/introspection.js';\nimport { isSpecifiedScalarType } from '../type/scalars.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport { getDefaultValueAST } from './getDefaultValueAST.js';\n\nexport function printSchema(schema: GraphQLSchema): string {\n return printFilteredSchema(\n schema,\n (n) => !isSpecifiedDirective(n),\n isDefinedType,\n );\n}\n\nexport function printIntrospectionSchema(schema: GraphQLSchema): string {\n return printFilteredSchema(schema, isSpecifiedDirective, isIntrospectionType);\n}\n\nfunction isDefinedType(type: GraphQLNamedType): boolean {\n return !isSpecifiedScalarType(type) && !isIntrospectionType(type);\n}\n\nfunction printFilteredSchema(\n schema: GraphQLSchema,\n directiveFilter: (type: GraphQLDirective) => boolean,\n typeFilter: (type: GraphQLNamedType) => boolean,\n): string {\n const directives = schema.getDirectives().filter(directiveFilter);\n const types = Object.values(schema.getTypeMap()).filter(typeFilter);\n\n return [\n printSchemaDefinition(schema),\n ...directives.map((directive) => printDirective(directive)),\n ...types.map((type) => printType(type)),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction printSchemaDefinition(schema: GraphQLSchema): Maybe {\n const queryType = schema.getQueryType();\n const mutationType = schema.getMutationType();\n const subscriptionType = schema.getSubscriptionType();\n\n // Special case: When a schema has no root operation types, no valid schema\n // definition can be printed.\n if (!queryType && !mutationType && !subscriptionType) {\n return;\n }\n\n // Only print a schema definition if there is a description or if it should\n // not be omitted because of having default type names.\n if (schema.description != null || !hasDefaultRootOperationTypes(schema)) {\n return (\n printDescription(schema) +\n 'schema {\\n' +\n (queryType ? ` query: ${queryType}\\n` : '') +\n (mutationType ? ` mutation: ${mutationType}\\n` : '') +\n (subscriptionType ? ` subscription: ${subscriptionType}\\n` : '') +\n '}'\n );\n }\n}\n\n/**\n * GraphQL schema define root types for each type of operation. These types are\n * the same as any other type and can be named in any manner, however there is\n * a common naming convention:\n *\n * ```graphql\n * schema {\n * query: Query\n * mutation: Mutation\n * subscription: Subscription\n * }\n * ```\n *\n * When using this naming convention, the schema description can be omitted so\n * long as these names are only used for operation types.\n *\n * Note however that if any of these default names are used elsewhere in the\n * schema but not as a root operation type, the schema definition must still\n * be printed to avoid ambiguity.\n */\nfunction hasDefaultRootOperationTypes(schema: GraphQLSchema): boolean {\n /* eslint-disable eqeqeq */\n return (\n schema.getQueryType() == schema.getType('Query') &&\n schema.getMutationType() == schema.getType('Mutation') &&\n schema.getSubscriptionType() == schema.getType('Subscription')\n );\n}\n\nexport function printType(type: GraphQLNamedType): string {\n if (isScalarType(type)) {\n return printScalar(type);\n }\n if (isObjectType(type)) {\n return printObject(type);\n }\n if (isInterfaceType(type)) {\n return printInterface(type);\n }\n if (isUnionType(type)) {\n return printUnion(type);\n }\n if (isEnumType(type)) {\n return printEnum(type);\n }\n if (isInputObjectType(type)) {\n return printInputObject(type);\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible types have been considered.\n invariant(false, 'Unexpected type: ' + inspect(type));\n}\n\nfunction printScalar(type: GraphQLScalarType): string {\n return printDescription(type) + `scalar ${type}` + printSpecifiedByURL(type);\n}\n\nfunction printImplementedInterfaces(\n type: GraphQLObjectType | GraphQLInterfaceType,\n): string {\n const interfaces = type.getInterfaces();\n return interfaces.length\n ? ' implements ' + interfaces.map((i) => i.name).join(' & ')\n : '';\n}\n\nfunction printObject(type: GraphQLObjectType): string {\n return (\n printDescription(type) +\n `type ${type}` +\n printImplementedInterfaces(type) +\n printFields(type)\n );\n}\n\nfunction printInterface(type: GraphQLInterfaceType): string {\n return (\n printDescription(type) +\n `interface ${type}` +\n printImplementedInterfaces(type) +\n printFields(type)\n );\n}\n\nfunction printUnion(type: GraphQLUnionType): string {\n const types = type.getTypes();\n const possibleTypes = types.length ? ' = ' + types.join(' | ') : '';\n return printDescription(type) + `union ${type.name}` + possibleTypes;\n}\n\nfunction printEnum(type: GraphQLEnumType): string {\n const values = type\n .getValues()\n .map(\n (value, i) =>\n printDescription(value, ' ', !i) +\n ' ' +\n value.name +\n printDeprecated(value.deprecationReason),\n );\n\n return printDescription(type) + `enum ${type}` + printBlock(values);\n}\n\nfunction printInputObject(type: GraphQLInputObjectType): string {\n const fields = Object.values(type.getFields()).map(\n (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f),\n );\n return (\n printDescription(type) +\n `input ${type}` +\n (type.isOneOf ? ' @oneOf' : '') +\n printBlock(fields)\n );\n}\n\nfunction printFields(type: GraphQLObjectType | GraphQLInterfaceType): string {\n const fields = Object.values(type.getFields()).map(\n (f, i) =>\n printDescription(f, ' ', !i) +\n ' ' +\n f.name +\n printArgs(f.args, ' ') +\n ': ' +\n String(f.type) +\n printDeprecated(f.deprecationReason),\n );\n return printBlock(fields);\n}\n\nfunction printBlock(items: ReadonlyArray): string {\n return items.length !== 0 ? ' {\\n' + items.join('\\n') + '\\n}' : '';\n}\n\nfunction printArgs(\n args: ReadonlyArray,\n indentation: string = '',\n): string {\n if (args.length === 0) {\n return '';\n }\n\n // If every arg does not have a description, print them on one line.\n if (args.every((arg) => arg.description == null)) {\n return '(' + args.map(printInputValue).join(', ') + ')';\n }\n\n return (\n '(\\n' +\n args\n .map(\n (arg, i) =>\n printDescription(arg, ' ' + indentation, !i) +\n ' ' +\n indentation +\n printInputValue(arg),\n )\n .join('\\n') +\n '\\n' +\n indentation +\n ')'\n );\n}\n\nfunction printInputValue(\n argOrInputField: GraphQLArgument | GraphQLInputField,\n): string {\n let argDecl = argOrInputField.name + ': ' + String(argOrInputField.type);\n const defaultValueAST = getDefaultValueAST(argOrInputField);\n if (defaultValueAST) {\n argDecl += ` = ${print(defaultValueAST)}`;\n }\n return argDecl + printDeprecated(argOrInputField.deprecationReason);\n}\n\nexport function printDirective(directive: GraphQLDirective): string {\n return (\n printDescription(directive) +\n `directive ${directive}` +\n printArgs(directive.args) +\n (directive.isRepeatable ? ' repeatable' : '') +\n ' on ' +\n directive.locations.join(' | ')\n );\n}\n\nfunction printDeprecated(reason: Maybe): string {\n if (reason == null) {\n return '';\n }\n if (reason !== DEFAULT_DEPRECATION_REASON) {\n const astValue = print({ kind: Kind.STRING, value: reason });\n return ` @deprecated(reason: ${astValue})`;\n }\n return ' @deprecated';\n}\n\nfunction printSpecifiedByURL(scalar: GraphQLScalarType): string {\n if (scalar.specifiedByURL == null) {\n return '';\n }\n const astValue = print({\n kind: Kind.STRING,\n value: scalar.specifiedByURL,\n });\n return ` @specifiedBy(url: ${astValue})`;\n}\n\nfunction printDescription(\n def: { readonly description: Maybe },\n indentation: string = '',\n firstInBlock: boolean = true,\n): string {\n const { description } = def;\n if (description == null) {\n return '';\n }\n\n const blockString = print({\n kind: Kind.STRING,\n value: description,\n block: isPrintableAsBlockString(description),\n });\n\n const prefix =\n indentation && !firstInBlock ? '\\n' + indentation : indentation;\n\n return prefix + blockString.replaceAll('\\n', '\\n' + indentation) + '\\n';\n}\n"]} \ No newline at end of file diff --git a/utilities/replaceVariables.d.ts b/utilities/replaceVariables.d.ts new file mode 100644 index 0000000000..a0381e48f1 --- /dev/null +++ b/utilities/replaceVariables.d.ts @@ -0,0 +1,13 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ConstValueNode, ValueNode } from '../language/ast.js'; +import type { FragmentVariableValues } from '../execution/collectFields.js'; +import type { VariableValues } from '../execution/values.js'; +/** + * Replaces any Variables found within an AST Value literal with literals + * supplied from a map of variable values, or removed if no variable replacement + * exists, returning a constant value. + * + * Used primarily to ensure only complete constant values are used during input + * coercion of custom scalars which accept complex literals. + */ +export declare function replaceVariables(valueNode: ValueNode, variableValues?: Maybe, fragmentVariableValues?: Maybe): ConstValueNode; diff --git a/utilities/replaceVariables.js b/utilities/replaceVariables.js new file mode 100644 index 0000000000..e878bc99d4 --- /dev/null +++ b/utilities/replaceVariables.js @@ -0,0 +1,80 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.replaceVariables = replaceVariables; +const kinds_js_1 = require("../language/kinds.js"); +const valueToLiteral_js_1 = require("./valueToLiteral.js"); +/** + * Replaces any Variables found within an AST Value literal with literals + * supplied from a map of variable values, or removed if no variable replacement + * exists, returning a constant value. + * + * Used primarily to ensure only complete constant values are used during input + * coercion of custom scalars which accept complex literals. + */ +function replaceVariables(valueNode, variableValues, fragmentVariableValues) { + switch (valueNode.kind) { + case kinds_js_1.Kind.VARIABLE: { + const varName = valueNode.name.value; + const fragmentVariableValueSource = fragmentVariableValues?.sources[varName]; + if (fragmentVariableValueSource) { + const value = fragmentVariableValueSource.value; + if (value === undefined) { + const defaultValue = fragmentVariableValueSource.signature.default; + if (defaultValue !== undefined) { + return defaultValue.literal; + } + return { kind: kinds_js_1.Kind.NULL }; + } + return replaceVariables(value, variableValues, fragmentVariableValueSource.fragmentVariableValues); + } + const variableValueSource = variableValues?.sources[varName]; + if (variableValueSource == null) { + return { kind: kinds_js_1.Kind.NULL }; + } + if (variableValueSource.value === undefined) { + const defaultValue = variableValueSource.signature.default; + if (defaultValue !== undefined) { + return defaultValue.literal; + } + } + return (0, valueToLiteral_js_1.valueToLiteral)(variableValueSource.value, variableValueSource.signature.type); + } + case kinds_js_1.Kind.OBJECT: { + const newFields = []; + for (const field of valueNode.fields) { + if (field.value.kind === kinds_js_1.Kind.VARIABLE) { + const scopedVariableSource = fragmentVariableValues?.sources[field.value.name.value] ?? + variableValues?.sources[field.value.name.value]; + if (scopedVariableSource?.value === undefined && + scopedVariableSource?.signature.default === undefined) { + continue; + } + } + const newFieldNodeValue = replaceVariables(field.value, variableValues, fragmentVariableValues); + newFields.push({ + ...field, + value: newFieldNodeValue, + }); + } + return { + ...valueNode, + fields: newFields, + }; + } + case kinds_js_1.Kind.LIST: { + const newValues = []; + for (const value of valueNode.values) { + const newItemNodeValue = replaceVariables(value, variableValues, fragmentVariableValues); + newValues.push(newItemNodeValue); + } + return { + ...valueNode, + values: newValues, + }; + } + default: { + return valueNode; + } + } +} +//# sourceMappingURL=replaceVariables.js.map \ No newline at end of file diff --git a/utilities/replaceVariables.js.map b/utilities/replaceVariables.js.map new file mode 100644 index 0000000000..bb4829ab44 --- /dev/null +++ b/utilities/replaceVariables.js.map @@ -0,0 +1 @@ +{"version":3,"file":"replaceVariables.js","sourceRoot":"","sources":["../../src/utilities/replaceVariables.ts"],"names":[],"mappings":";;AAsBA,4CA6FC;AA5GD,mDAA4C;AAK5C,2DAAqD;AAErD;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,SAAoB,EACpB,cAAsC,EACtC,sBAAsD;IAEtD,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,eAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,2BAA2B,GAC/B,sBAAsB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAE3C,I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,sBAAsB,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;wBACvD,cAAc,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAElD,IACE,oBAAoB,EAAE,KAAK,KAAK,SAAS;wBACzC,oBAAoB,EAAE,SAAS,CAAC,OAAO,KAAK,SAAS,EACrD,CAAC;wBACD,SAAS;oBACX,CAAC;gBACH,CAAC;gBACD,MAAM,iBAAiB,GAAG,gBAAgB,CACxC,KAAK,CAAC,KAAK,EACX,cAAc,EACd,sBAAsB,CACvB,CAAC;gBACF,SAAS,CAAC,IAAI,CAAC;oBACb,GAAG,KAAK;oBACR,KAAK,EAAE,iBAAiB;iBACzB,CAAC,CAAC;YACL,CAAC;YACD,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,SAAS;aACA,CAAC;QACtB,CAAC;QACD,KAAK,eAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACf,MAAM,SAAS,GAAqB,EAAE,CAAC;YACvC,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;gBACrC,MAAM,gBAAgB,GAAG,gBAAgB,CACvC,KAAK,EACL,cAAc,EACd,sBAAsB,CACvB,CAAC;gBACF,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACnC,CAAC;YACD,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,SAAS;aACA,CAAC;QACtB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n ConstValueNode,\n ObjectFieldNode,\n ValueNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { FragmentVariableValues } from '../execution/collectFields.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { valueToLiteral } from './valueToLiteral.js';\n\n/**\n * Replaces any Variables found within an AST Value literal with literals\n * supplied from a map of variable values, or removed if no variable replacement\n * exists, returning a constant value.\n *\n * Used primarily to ensure only complete constant values are used during input\n * coercion of custom scalars which accept complex literals.\n */\nexport function replaceVariables(\n valueNode: ValueNode,\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n): ConstValueNode {\n switch (valueNode.kind) {\n case Kind.VARIABLE: {\n const varName = valueNode.name.value;\n const fragmentVariableValueSource =\n fragmentVariableValues?.sources[varName];\n\n if (fragmentVariableValueSource) {\n const value = fragmentVariableValueSource.value;\n if (value === undefined) {\n const defaultValue = fragmentVariableValueSource.signature.default;\n if (defaultValue !== undefined) {\n return defaultValue.literal;\n }\n return { kind: Kind.NULL };\n }\n return replaceVariables(\n value,\n variableValues,\n fragmentVariableValueSource.fragmentVariableValues,\n );\n }\n\n const variableValueSource = variableValues?.sources[varName];\n if (variableValueSource == null) {\n return { kind: Kind.NULL };\n }\n\n if (variableValueSource.value === undefined) {\n const defaultValue = variableValueSource.signature.default;\n if (defaultValue !== undefined) {\n return defaultValue.literal;\n }\n }\n\n return valueToLiteral(\n variableValueSource.value,\n variableValueSource.signature.type,\n ) as ConstValueNode;\n }\n case Kind.OBJECT: {\n const newFields: Array = [];\n for (const field of valueNode.fields) {\n if (field.value.kind === Kind.VARIABLE) {\n const scopedVariableSource =\n fragmentVariableValues?.sources[field.value.name.value] ??\n variableValues?.sources[field.value.name.value];\n\n if (\n scopedVariableSource?.value === undefined &&\n scopedVariableSource?.signature.default === undefined\n ) {\n continue;\n }\n }\n const newFieldNodeValue = replaceVariables(\n field.value,\n variableValues,\n fragmentVariableValues,\n );\n newFields.push({\n ...field,\n value: newFieldNodeValue,\n });\n }\n return {\n ...valueNode,\n fields: newFields,\n } as ConstValueNode;\n }\n case Kind.LIST: {\n const newValues: Array = [];\n for (const value of valueNode.values) {\n const newItemNodeValue = replaceVariables(\n value,\n variableValues,\n fragmentVariableValues,\n );\n newValues.push(newItemNodeValue);\n }\n return {\n ...valueNode,\n values: newValues,\n } as ConstValueNode;\n }\n default: {\n return valueNode;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/replaceVariables.mjs b/utilities/replaceVariables.mjs new file mode 100644 index 0000000000..731281088e --- /dev/null +++ b/utilities/replaceVariables.mjs @@ -0,0 +1,77 @@ +import { Kind } from "../language/kinds.mjs"; +import { valueToLiteral } from "./valueToLiteral.mjs"; +/** + * Replaces any Variables found within an AST Value literal with literals + * supplied from a map of variable values, or removed if no variable replacement + * exists, returning a constant value. + * + * Used primarily to ensure only complete constant values are used during input + * coercion of custom scalars which accept complex literals. + */ +export function replaceVariables(valueNode, variableValues, fragmentVariableValues) { + switch (valueNode.kind) { + case Kind.VARIABLE: { + const varName = valueNode.name.value; + const fragmentVariableValueSource = fragmentVariableValues?.sources[varName]; + if (fragmentVariableValueSource) { + const value = fragmentVariableValueSource.value; + if (value === undefined) { + const defaultValue = fragmentVariableValueSource.signature.default; + if (defaultValue !== undefined) { + return defaultValue.literal; + } + return { kind: Kind.NULL }; + } + return replaceVariables(value, variableValues, fragmentVariableValueSource.fragmentVariableValues); + } + const variableValueSource = variableValues?.sources[varName]; + if (variableValueSource == null) { + return { kind: Kind.NULL }; + } + if (variableValueSource.value === undefined) { + const defaultValue = variableValueSource.signature.default; + if (defaultValue !== undefined) { + return defaultValue.literal; + } + } + return valueToLiteral(variableValueSource.value, variableValueSource.signature.type); + } + case Kind.OBJECT: { + const newFields = []; + for (const field of valueNode.fields) { + if (field.value.kind === Kind.VARIABLE) { + const scopedVariableSource = fragmentVariableValues?.sources[field.value.name.value] ?? + variableValues?.sources[field.value.name.value]; + if (scopedVariableSource?.value === undefined && + scopedVariableSource?.signature.default === undefined) { + continue; + } + } + const newFieldNodeValue = replaceVariables(field.value, variableValues, fragmentVariableValues); + newFields.push({ + ...field, + value: newFieldNodeValue, + }); + } + return { + ...valueNode, + fields: newFields, + }; + } + case Kind.LIST: { + const newValues = []; + for (const value of valueNode.values) { + const newItemNodeValue = replaceVariables(value, variableValues, fragmentVariableValues); + newValues.push(newItemNodeValue); + } + return { + ...valueNode, + values: newValues, + }; + } + default: { + return valueNode; + } + } +} +//# sourceMappingURL=replaceVariables.js.map \ No newline at end of file diff --git a/utilities/replaceVariables.mjs.map b/utilities/replaceVariables.mjs.map new file mode 100644 index 0000000000..ba043ebf71 --- /dev/null +++ b/utilities/replaceVariables.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"replaceVariables.js","sourceRoot":"","sources":["../../src/utilities/replaceVariables.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAK5C,OAAO,EAAE,cAAc,EAAE,6BAA4B;AAErD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAoB,EACpB,cAAsC,EACtC,sBAAsD;IAEtD,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,2BAA2B,GAC/B,sBAAsB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAE3C,IAAI,2BAA2B,EAAE,CAAC;gBAChC,MAAM,KAAK,GAAG,2BAA2B,CAAC,KAAK,CAAC;gBAChD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACxB,MAAM,YAAY,GAAG,2BAA2B,CAAC,SAAS,CAAC,OAAO,CAAC;oBACnE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;wBAC/B,OAAO,YAAY,CAAC,OAAO,CAAC;oBAC9B,CAAC;oBACD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;gBAC7B,CAAC;gBACD,OAAO,gBAAgB,CACrB,KAAK,EACL,cAAc,EACd,2BAA2B,CAAC,sBAAsB,CACnD,CAAC;YACJ,CAAC;YAED,MAAM,mBA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iB;iBACzB,CAAC,CAAC;YACL,CAAC;YACD,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,SAAS;aACA,CAAC;QACtB,CAAC;QACD,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACf,MAAM,SAAS,GAAqB,EAAE,CAAC;YACvC,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;gBACrC,MAAM,gBAAgB,GAAG,gBAAgB,CACvC,KAAK,EACL,cAAc,EACd,sBAAsB,CACvB,CAAC;gBACF,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACnC,CAAC;YACD,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,SAAS;aACA,CAAC;QACtB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport type {\n ConstValueNode,\n ObjectFieldNode,\n ValueNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { FragmentVariableValues } from '../execution/collectFields.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { valueToLiteral } from './valueToLiteral.js';\n\n/**\n * Replaces any Variables found within an AST Value literal with literals\n * supplied from a map of variable values, or removed if no variable replacement\n * exists, returning a constant value.\n *\n * Used primarily to ensure only complete constant values are used during input\n * coercion of custom scalars which accept complex literals.\n */\nexport function replaceVariables(\n valueNode: ValueNode,\n variableValues?: Maybe,\n fragmentVariableValues?: Maybe,\n): ConstValueNode {\n switch (valueNode.kind) {\n case Kind.VARIABLE: {\n const varName = valueNode.name.value;\n const fragmentVariableValueSource =\n fragmentVariableValues?.sources[varName];\n\n if (fragmentVariableValueSource) {\n const value = fragmentVariableValueSource.value;\n if (value === undefined) {\n const defaultValue = fragmentVariableValueSource.signature.default;\n if (defaultValue !== undefined) {\n return defaultValue.literal;\n }\n return { kind: Kind.NULL };\n }\n return replaceVariables(\n value,\n variableValues,\n fragmentVariableValueSource.fragmentVariableValues,\n );\n }\n\n const variableValueSource = variableValues?.sources[varName];\n if (variableValueSource == null) {\n return { kind: Kind.NULL };\n }\n\n if (variableValueSource.value === undefined) {\n const defaultValue = variableValueSource.signature.default;\n if (defaultValue !== undefined) {\n return defaultValue.literal;\n }\n }\n\n return valueToLiteral(\n variableValueSource.value,\n variableValueSource.signature.type,\n ) as ConstValueNode;\n }\n case Kind.OBJECT: {\n const newFields: Array = [];\n for (const field of valueNode.fields) {\n if (field.value.kind === Kind.VARIABLE) {\n const scopedVariableSource =\n fragmentVariableValues?.sources[field.value.name.value] ??\n variableValues?.sources[field.value.name.value];\n\n if (\n scopedVariableSource?.value === undefined &&\n scopedVariableSource?.signature.default === undefined\n ) {\n continue;\n }\n }\n const newFieldNodeValue = replaceVariables(\n field.value,\n variableValues,\n fragmentVariableValues,\n );\n newFields.push({\n ...field,\n value: newFieldNodeValue,\n });\n }\n return {\n ...valueNode,\n fields: newFields,\n } as ConstValueNode;\n }\n case Kind.LIST: {\n const newValues: Array = [];\n for (const value of valueNode.values) {\n const newItemNodeValue = replaceVariables(\n value,\n variableValues,\n fragmentVariableValues,\n );\n newValues.push(newItemNodeValue);\n }\n return {\n ...valueNode,\n values: newValues,\n } as ConstValueNode;\n }\n default: {\n return valueNode;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/separateOperations.d.ts b/utilities/separateOperations.d.ts new file mode 100644 index 0000000000..41ce14ab34 --- /dev/null +++ b/utilities/separateOperations.d.ts @@ -0,0 +1,9 @@ +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { DocumentNode } from '../language/ast.js'; +/** + * separateOperations accepts a single AST document which may contain many + * operations and fragments and returns a collection of AST documents each of + * which contains a single operation as well the fragment definitions it + * refers to. + */ +export declare function separateOperations(documentAST: DocumentNode): ObjMap; diff --git a/utilities/separateOperations.js b/utilities/separateOperations.js new file mode 100644 index 0000000000..7696c87c62 --- /dev/null +++ b/utilities/separateOperations.js @@ -0,0 +1,71 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.separateOperations = separateOperations; +const kinds_js_1 = require("../language/kinds.js"); +const visitor_js_1 = require("../language/visitor.js"); +/** + * separateOperations accepts a single AST document which may contain many + * operations and fragments and returns a collection of AST documents each of + * which contains a single operation as well the fragment definitions it + * refers to. + */ +function separateOperations(documentAST) { + const operations = []; + const depGraph = Object.create(null); + // Populate metadata and build a dependency graph. + for (const definitionNode of documentAST.definitions) { + switch (definitionNode.kind) { + case kinds_js_1.Kind.OPERATION_DEFINITION: + operations.push(definitionNode); + break; + case kinds_js_1.Kind.FRAGMENT_DEFINITION: + depGraph[definitionNode.name.value] = collectDependencies(definitionNode.selectionSet); + break; + default: + // ignore non-executable definitions + } + } + // For each operation, produce a new synthesized AST which includes only what + // is necessary for completing that operation. + const separatedDocumentASTs = Object.create(null); + for (const operation of operations) { + const dependencies = new Set(); + for (const fragmentName of collectDependencies(operation.selectionSet)) { + collectTransitiveDependencies(dependencies, depGraph, fragmentName); + } + // Provides the empty string for anonymous operations. + const operationName = operation.name ? operation.name.value : ''; + // The list of definition nodes to be included for this operation, sorted + // to retain the same order as the original document. + separatedDocumentASTs[operationName] = { + kind: kinds_js_1.Kind.DOCUMENT, + definitions: documentAST.definitions.filter((node) => node === operation || + (node.kind === kinds_js_1.Kind.FRAGMENT_DEFINITION && + dependencies.has(node.name.value))), + }; + } + return separatedDocumentASTs; +} +// From a dependency graph, collects a list of transitive dependencies by +// recursing through a dependency graph. +function collectTransitiveDependencies(collected, depGraph, fromName) { + if (!collected.has(fromName)) { + collected.add(fromName); + const immediateDeps = depGraph[fromName]; + if (immediateDeps !== undefined) { + for (const toName of immediateDeps) { + collectTransitiveDependencies(collected, depGraph, toName); + } + } + } +} +function collectDependencies(selectionSet) { + const dependencies = []; + (0, visitor_js_1.visit)(selectionSet, { + FragmentSpread(node) { + dependencies.push(node.name.value); + }, + }); + return dependencies; +} +//# sourceMappingURL=separateOperations.js.map \ No newline at end of file diff --git a/utilities/separateOperations.js.map b/utilities/separateOperations.js.map new file mode 100644 index 0000000000..634261b96e --- /dev/null +++ b/utilities/separateOperations.js.map @@ -0,0 +1 @@ +{"version":3,"file":"separateOperations.js","sourceRoot":"","sources":["../../src/utilities/separateOperations.ts"],"names":[],"mappings":";;AAgBA,gDAiDC;AA1DD,mDAA4C;AAC5C,uDAA+C;AAE/C;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,WAAyB;IAEzB,MAAM,UAAU,GAAmC,EAAE,CAAC;IACtD,MAAM,QAAQ,GAAa,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE/C,kDAAkD;IAClD,KAAK,MAAM,cAAc,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;QACrD,QAAQ,cAAc,CAAC,IAAI,EAAE,CAAC;YAC5B,KAAK,eAAI,CAAC,oBAAoB;gBAC5B,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,eAAI,CAAC,mBAAmB;gBAC3B,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,mBAAmB,CACvD,cAAc,CAAC,YAAY,CAC5B,CAAC;gBACF,MAAM;YACR,QAAQ;YACR,oCAAoC;QACtC,CAAC;IACH,CAAC;IAED,6EAA6E;IAC7E,8CAA8C;IAC9C,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;QAEvC,KAAK,MAAM,YAAY,IAAI,mBAAmB,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;YACvE,6BAA6B,CAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QACtE,CAAC;QAED,sDAAsD;QACtD,MAAM,aAAa,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B,CAAC","sourcesContent":["import type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type {\n DocumentNode,\n OperationDefinitionNode,\n SelectionSetNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport { visit } from '../language/visitor.js';\n\n/**\n * separateOperations accepts a single AST document which may contain many\n * operations and fragments and returns a collection of AST documents each of\n * which contains a single operation as well the fragment definitions it\n * refers to.\n */\nexport function separateOperations(\n documentAST: DocumentNode,\n): ObjMap {\n const operations: Array = [];\n const depGraph: DepGraph = Object.create(null);\n\n // Populate metadata and build a dependency graph.\n for (const definitionNode of documentAST.definitions) {\n switch (definitionNode.kind) {\n case Kind.OPERATION_DEFINITION:\n operations.push(definitionNode);\n break;\n case Kind.FRAGMENT_DEFINITION:\n depGraph[definitionNode.name.value] = collectDependencies(\n definitionNode.selectionSet,\n );\n break;\n default:\n // ignore non-executable definitions\n }\n }\n\n // For each operation, produce a new synthesized AST which includes only what\n // is necessary for completing that operation.\n const separatedDocumentASTs = Object.create(null);\n for (const operation of operations) {\n const dependencies = new Set();\n\n for (const fragmentName of collectDependencies(operation.selectionSet)) {\n collectTransitiveDependencies(dependencies, depGraph, fragmentName);\n }\n\n // Provides the empty string for anonymous operations.\n const operationName = operation.name ? operation.name.value : '';\n\n // The list of definition nodes to be included for this operation, sorted\n // to retain the same order as the original document.\n separatedDocumentASTs[operationName] = {\n kind: Kind.DOCUMENT,\n definitions: documentAST.definitions.filter(\n (node) =>\n node === operation ||\n (node.kind === Kind.FRAGMENT_DEFINITION &&\n dependencies.has(node.name.value)),\n ),\n };\n }\n\n return separatedDocumentASTs;\n}\n\ntype DepGraph = ObjMap>;\n\n// From a dependency graph, collects a list of transitive dependencies by\n// recursing through a dependency graph.\nfunction collectTransitiveDependencies(\n collected: Set,\n depGraph: DepGraph,\n fromName: string,\n): void {\n if (!collected.has(fromName)) {\n collected.add(fromName);\n\n const immediateDeps = depGraph[fromName];\n if (immediateDeps !== undefined) {\n for (const toName of immediateDeps) {\n collectTransitiveDependencies(collected, depGraph, toName);\n }\n }\n }\n}\n\nfunction collectDependencies(selectionSet: SelectionSetNode): Array {\n const dependencies: Array = [];\n\n visit(selectionSet, {\n FragmentSpread(node) {\n dependencies.push(node.name.value);\n },\n });\n return dependencies;\n}\n"]} \ No newline at end of file diff --git a/utilities/separateOperations.mjs b/utilities/separateOperations.mjs new file mode 100644 index 0000000000..4aab18dce5 --- /dev/null +++ b/utilities/separateOperations.mjs @@ -0,0 +1,68 @@ +import { Kind } from "../language/kinds.mjs"; +import { visit } from "../language/visitor.mjs"; +/** + * separateOperations accepts a single AST document which may contain many + * operations and fragments and returns a collection of AST documents each of + * which contains a single operation as well the fragment definitions it + * refers to. + */ +export function separateOperations(documentAST) { + const operations = []; + const depGraph = Object.create(null); + // Populate metadata and build a dependency graph. + for (const definitionNode of documentAST.definitions) { + switch (definitionNode.kind) { + case Kind.OPERATION_DEFINITION: + operations.push(definitionNode); + break; + case Kind.FRAGMENT_DEFINITION: + depGraph[definitionNode.name.value] = collectDependencies(definitionNode.selectionSet); + break; + default: + // ignore non-executable definitions + } + } + // For each operation, produce a new synthesized AST which includes only what + // is necessary for completing that operation. + const separatedDocumentASTs = Object.create(null); + for (const operation of operations) { + const dependencies = new Set(); + for (const fragmentName of collectDependencies(operation.selectionSet)) { + collectTransitiveDependencies(dependencies, depGraph, fragmentName); + } + // Provides the empty string for anonymous operations. + const operationName = operation.name ? operation.name.value : ''; + // The list of definition nodes to be included for this operation, sorted + // to retain the same order as the original document. + separatedDocumentASTs[operationName] = { + kind: Kind.DOCUMENT, + definitions: documentAST.definitions.filter((node) => node === operation || + (node.kind === Kind.FRAGMENT_DEFINITION && + dependencies.has(node.name.value))), + }; + } + return separatedDocumentASTs; +} +// From a dependency graph, collects a list of transitive dependencies by +// recursing through a dependency graph. +function collectTransitiveDependencies(collected, depGraph, fromName) { + if (!collected.has(fromName)) { + collected.add(fromName); + const immediateDeps = depGraph[fromName]; + if (immediateDeps !== undefined) { + for (const toName of immediateDeps) { + collectTransitiveDependencies(collected, depGraph, toName); + } + } + } +} +function collectDependencies(selectionSet) { + const dependencies = []; + visit(selectionSet, { + FragmentSpread(node) { + dependencies.push(node.name.value); + }, + }); + return dependencies; +} +//# sourceMappingURL=separateOperations.js.map \ No newline at end of file diff --git a/utilities/separateOperations.mjs.map b/utilities/separateOperations.mjs.map new file mode 100644 index 0000000000..0dd1b772ba --- /dev/null +++ b/utilities/separateOperations.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"separateOperations.js","sourceRoot":"","sources":["../../src/utilities/separateOperations.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAC5C,OAAO,EAAE,KAAK,EAAE,gCAA+B;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,WAAyB;IAEzB,MAAM,UAAU,GAAmC,EAAE,CAAC;IACtD,MAAM,QAAQ,GAAa,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE/C,kDAAkD;IAClD,KAAK,MAAM,cAAc,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;QACrD,QAAQ,cAAc,CAAC,IAAI,EAAE,CAAC;YAC5B,KAAK,IAAI,CAAC,oBAAoB;gBAC5B,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,IAAI,CAAC,mBAAmB;gBAC3B,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,mBAAmB,CACvD,cAAc,CAAC,YAAY,CAC5B,CAAC;gBACF,MAAM;YACR,QAAQ;YACR,oCAAoC;QACtC,CAAC;IACH,CAAC;IAED,6EAA6E;IAC7E,8CAA8C;IAC9C,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;QAEv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,KAAK,CAAC,YAAY,EAAE;QAClB,cAAc,CAAC,IAAI;YACjB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;KACF,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type {\n DocumentNode,\n OperationDefinitionNode,\n SelectionSetNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport { visit } from '../language/visitor.js';\n\n/**\n * separateOperations accepts a single AST document which may contain many\n * operations and fragments and returns a collection of AST documents each of\n * which contains a single operation as well the fragment definitions it\n * refers to.\n */\nexport function separateOperations(\n documentAST: DocumentNode,\n): ObjMap {\n const operations: Array = [];\n const depGraph: DepGraph = Object.create(null);\n\n // Populate metadata and build a dependency graph.\n for (const definitionNode of documentAST.definitions) {\n switch (definitionNode.kind) {\n case Kind.OPERATION_DEFINITION:\n operations.push(definitionNode);\n break;\n case Kind.FRAGMENT_DEFINITION:\n depGraph[definitionNode.name.value] = collectDependencies(\n definitionNode.selectionSet,\n );\n break;\n default:\n // ignore non-executable definitions\n }\n }\n\n // For each operation, produce a new synthesized AST which includes only what\n // is necessary for completing that operation.\n const separatedDocumentASTs = Object.create(null);\n for (const operation of operations) {\n const dependencies = new Set();\n\n for (const fragmentName of collectDependencies(operation.selectionSet)) {\n collectTransitiveDependencies(dependencies, depGraph, fragmentName);\n }\n\n // Provides the empty string for anonymous operations.\n const operationName = operation.name ? operation.name.value : '';\n\n // The list of definition nodes to be included for this operation, sorted\n // to retain the same order as the original document.\n separatedDocumentASTs[operationName] = {\n kind: Kind.DOCUMENT,\n definitions: documentAST.definitions.filter(\n (node) =>\n node === operation ||\n (node.kind === Kind.FRAGMENT_DEFINITION &&\n dependencies.has(node.name.value)),\n ),\n };\n }\n\n return separatedDocumentASTs;\n}\n\ntype DepGraph = ObjMap>;\n\n// From a dependency graph, collects a list of transitive dependencies by\n// recursing through a dependency graph.\nfunction collectTransitiveDependencies(\n collected: Set,\n depGraph: DepGraph,\n fromName: string,\n): void {\n if (!collected.has(fromName)) {\n collected.add(fromName);\n\n const immediateDeps = depGraph[fromName];\n if (immediateDeps !== undefined) {\n for (const toName of immediateDeps) {\n collectTransitiveDependencies(collected, depGraph, toName);\n }\n }\n }\n}\n\nfunction collectDependencies(selectionSet: SelectionSetNode): Array {\n const dependencies: Array = [];\n\n visit(selectionSet, {\n FragmentSpread(node) {\n dependencies.push(node.name.value);\n },\n });\n return dependencies;\n}\n"]} \ No newline at end of file diff --git a/utilities/sortValueNode.d.ts b/utilities/sortValueNode.d.ts new file mode 100644 index 0000000000..6a24a9a5d9 --- /dev/null +++ b/utilities/sortValueNode.d.ts @@ -0,0 +1,9 @@ +import type { ValueNode } from '../language/ast.js'; +/** + * Sort ValueNode. + * + * This function returns a sorted copy of the given ValueNode. + * + * @internal + */ +export declare function sortValueNode(valueNode: ValueNode): ValueNode; diff --git a/utilities/sortValueNode.js b/utilities/sortValueNode.js new file mode 100644 index 0000000000..91245b51a4 --- /dev/null +++ b/utilities/sortValueNode.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sortValueNode = sortValueNode; +const naturalCompare_js_1 = require("../jsutils/naturalCompare.js"); +const kinds_js_1 = require("../language/kinds.js"); +/** + * Sort ValueNode. + * + * This function returns a sorted copy of the given ValueNode. + * + * @internal + */ +function sortValueNode(valueNode) { + switch (valueNode.kind) { + case kinds_js_1.Kind.OBJECT: + return { + ...valueNode, + fields: sortFields(valueNode.fields), + }; + case kinds_js_1.Kind.LIST: + return { + ...valueNode, + values: valueNode.values.map(sortValueNode), + }; + case kinds_js_1.Kind.INT: + case kinds_js_1.Kind.FLOAT: + case kinds_js_1.Kind.STRING: + case kinds_js_1.Kind.BOOLEAN: + case kinds_js_1.Kind.NULL: + case kinds_js_1.Kind.ENUM: + case kinds_js_1.Kind.VARIABLE: + return valueNode; + } +} +function sortFields(fields) { + return fields + .map((fieldNode) => ({ + ...fieldNode, + value: sortValueNode(fieldNode.value), + })) + .sort((fieldA, fieldB) => (0, naturalCompare_js_1.naturalCompare)(fieldA.name.value, fieldB.name.value)); +} +//# sourceMappingURL=sortValueNode.js.map \ No newline at end of file diff --git a/utilities/sortValueNode.js.map b/utilities/sortValueNode.js.map new file mode 100644 index 0000000000..b9e13d060e --- /dev/null +++ b/utilities/sortValueNode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sortValueNode.js","sourceRoot":"","sources":["../../src/utilities/sortValueNode.ts"],"names":[],"mappings":";;AAYA,sCAqBC;AAjCD,oEAA8D;AAG9D,mDAA4C;AAE5C;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,SAAoB;IAChD,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,eAAI,CAAC,MAAM;YACd,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC;aACrC,CAAC;QACJ,KAAK,eAAI,CAAC,IAAI;YACZ,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;aAC5C,CAAC;QACJ,KAAK,eAAI,CAAC,GAAG,CAAC;QACd,KAAK,eAAI,CAAC,KAAK,CAAC;QAChB,KAAK,eAAI,CAAC,MAAM,CAAC;QACjB,KAAK,eAAI,CAAC,OAAO,CAAC;QAClB,KAAK,eAAI,CAAC,IAAI,CAAC;QACf,KAAK,eAAI,CAAC,IAAI,CAAC;QACf,KAAK,eAAI,CAAC,QAAQ;YAChB,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CACjB,MAAsC;IAEtC,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACnB,GAAG,SAAS;QACZ,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC;KACtC,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CACvB,IAAA,kCAAc,EAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CACrD,CAAC;AACN,CAAC","sourcesContent":["import { naturalCompare } from '../jsutils/naturalCompare.js';\n\nimport type { ObjectFieldNode, ValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Sort ValueNode.\n *\n * This function returns a sorted copy of the given ValueNode.\n *\n * @internal\n */\nexport function sortValueNode(valueNode: ValueNode): ValueNode {\n switch (valueNode.kind) {\n case Kind.OBJECT:\n return {\n ...valueNode,\n fields: sortFields(valueNode.fields),\n };\n case Kind.LIST:\n return {\n ...valueNode,\n values: valueNode.values.map(sortValueNode),\n };\n case Kind.INT:\n case Kind.FLOAT:\n case Kind.STRING:\n case Kind.BOOLEAN:\n case Kind.NULL:\n case Kind.ENUM:\n case Kind.VARIABLE:\n return valueNode;\n }\n}\n\nfunction sortFields(\n fields: ReadonlyArray,\n): Array {\n return fields\n .map((fieldNode) => ({\n ...fieldNode,\n value: sortValueNode(fieldNode.value),\n }))\n .sort((fieldA, fieldB) =>\n naturalCompare(fieldA.name.value, fieldB.name.value),\n );\n}\n"]} \ No newline at end of file diff --git a/utilities/sortValueNode.mjs b/utilities/sortValueNode.mjs new file mode 100644 index 0000000000..22167cddaa --- /dev/null +++ b/utilities/sortValueNode.mjs @@ -0,0 +1,40 @@ +import { naturalCompare } from "../jsutils/naturalCompare.mjs"; +import { Kind } from "../language/kinds.mjs"; +/** + * Sort ValueNode. + * + * This function returns a sorted copy of the given ValueNode. + * + * @internal + */ +export function sortValueNode(valueNode) { + switch (valueNode.kind) { + case Kind.OBJECT: + return { + ...valueNode, + fields: sortFields(valueNode.fields), + }; + case Kind.LIST: + return { + ...valueNode, + values: valueNode.values.map(sortValueNode), + }; + case Kind.INT: + case Kind.FLOAT: + case Kind.STRING: + case Kind.BOOLEAN: + case Kind.NULL: + case Kind.ENUM: + case Kind.VARIABLE: + return valueNode; + } +} +function sortFields(fields) { + return fields + .map((fieldNode) => ({ + ...fieldNode, + value: sortValueNode(fieldNode.value), + })) + .sort((fieldA, fieldB) => naturalCompare(fieldA.name.value, fieldB.name.value)); +} +//# sourceMappingURL=sortValueNode.js.map \ No newline at end of file diff --git a/utilities/sortValueNode.mjs.map b/utilities/sortValueNode.mjs.map new file mode 100644 index 0000000000..725d23ad4e --- /dev/null +++ b/utilities/sortValueNode.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"sortValueNode.js","sourceRoot":"","sources":["../../src/utilities/sortValueNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAG9D,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,SAAoB;IAChD,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,IAAI,CAAC,MAAM;YACd,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC;aACrC,CAAC;QACJ,KAAK,IAAI,CAAC,IAAI;YACZ,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;aAC5C,CAAC;QACJ,KAAK,IAAI,CAAC,GAAG,CAAC;QACd,KAAK,IAAI,CAAC,KAAK,CAAC;QAChB,KAAK,IAAI,CAAC,MAAM,CAAC;QACjB,KAAK,IAAI,CAAC,OAAO,CAAC;QAClB,KAAK,IAAI,CAAC,IAAI,CAAC;QACf,KAAK,IAAI,CAAC,IAAI,CAAC;QACf,KAAK,IAAI,CAAC,QAAQ;YAChB,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CACjB,MAAsC;IAEtC,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACnB,GAAG,SAAS;QACZ,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC;KACtC,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CACvB,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CACrD,CAAC;AACN,CAAC","sourcesContent":["import { naturalCompare } from '../jsutils/naturalCompare.js';\n\nimport type { ObjectFieldNode, ValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Sort ValueNode.\n *\n * This function returns a sorted copy of the given ValueNode.\n *\n * @internal\n */\nexport function sortValueNode(valueNode: ValueNode): ValueNode {\n switch (valueNode.kind) {\n case Kind.OBJECT:\n return {\n ...valueNode,\n fields: sortFields(valueNode.fields),\n };\n case Kind.LIST:\n return {\n ...valueNode,\n values: valueNode.values.map(sortValueNode),\n };\n case Kind.INT:\n case Kind.FLOAT:\n case Kind.STRING:\n case Kind.BOOLEAN:\n case Kind.NULL:\n case Kind.ENUM:\n case Kind.VARIABLE:\n return valueNode;\n }\n}\n\nfunction sortFields(\n fields: ReadonlyArray,\n): Array {\n return fields\n .map((fieldNode) => ({\n ...fieldNode,\n value: sortValueNode(fieldNode.value),\n }))\n .sort((fieldA, fieldB) =>\n naturalCompare(fieldA.name.value, fieldB.name.value),\n );\n}\n"]} \ No newline at end of file diff --git a/utilities/stripIgnoredCharacters.d.ts b/utilities/stripIgnoredCharacters.d.ts new file mode 100644 index 0000000000..6ecf0878eb --- /dev/null +++ b/utilities/stripIgnoredCharacters.d.ts @@ -0,0 +1,62 @@ +import { Source } from '../language/source.js'; +/** + * Strips characters that are not significant to the validity or execution + * of a GraphQL document: + * - UnicodeBOM + * - WhiteSpace + * - LineTerminator + * - Comment + * - Comma + * - BlockString indentation + * + * Note: It is required to have a delimiter character between neighboring + * non-punctuator tokens and this function always uses single space as delimiter. + * + * It is guaranteed that both input and output documents if parsed would result + * in the exact same AST except for nodes location. + * + * Warning: It is guaranteed that this function will always produce stable results. + * However, it's not guaranteed that it will stay the same between different + * releases due to bugfixes or changes in the GraphQL specification. + * + * Query example: + * + * ```graphql + * query SomeQuery($foo: String!, $bar: String) { + * someField(foo: $foo, bar: $bar) { + * a + * b { + * c + * d + * } + * } + * } + * ``` + * + * Becomes: + * + * ```graphql + * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} + * ``` + * + * SDL example: + * + * ```graphql + * """ + * Type description + * """ + * type Foo { + * """ + * Field description + * """ + * bar: String + * } + * ``` + * + * Becomes: + * + * ```graphql + * """Type description""" type Foo{"""Field description""" bar:String} + * ``` + */ +export declare function stripIgnoredCharacters(source: string | Source): string; diff --git a/utilities/stripIgnoredCharacters.js b/utilities/stripIgnoredCharacters.js new file mode 100644 index 0000000000..c69a330a55 --- /dev/null +++ b/utilities/stripIgnoredCharacters.js @@ -0,0 +1,99 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.stripIgnoredCharacters = stripIgnoredCharacters; +const blockString_js_1 = require("../language/blockString.js"); +const lexer_js_1 = require("../language/lexer.js"); +const source_js_1 = require("../language/source.js"); +const tokenKind_js_1 = require("../language/tokenKind.js"); +/** + * Strips characters that are not significant to the validity or execution + * of a GraphQL document: + * - UnicodeBOM + * - WhiteSpace + * - LineTerminator + * - Comment + * - Comma + * - BlockString indentation + * + * Note: It is required to have a delimiter character between neighboring + * non-punctuator tokens and this function always uses single space as delimiter. + * + * It is guaranteed that both input and output documents if parsed would result + * in the exact same AST except for nodes location. + * + * Warning: It is guaranteed that this function will always produce stable results. + * However, it's not guaranteed that it will stay the same between different + * releases due to bugfixes or changes in the GraphQL specification. + * + * Query example: + * + * ```graphql + * query SomeQuery($foo: String!, $bar: String) { + * someField(foo: $foo, bar: $bar) { + * a + * b { + * c + * d + * } + * } + * } + * ``` + * + * Becomes: + * + * ```graphql + * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} + * ``` + * + * SDL example: + * + * ```graphql + * """ + * Type description + * """ + * type Foo { + * """ + * Field description + * """ + * bar: String + * } + * ``` + * + * Becomes: + * + * ```graphql + * """Type description""" type Foo{"""Field description""" bar:String} + * ``` + */ +function stripIgnoredCharacters(source) { + const sourceObj = (0, source_js_1.isSource)(source) ? source : new source_js_1.Source(source); + const body = sourceObj.body; + const lexer = new lexer_js_1.Lexer(sourceObj); + let strippedBody = ''; + let wasLastAddedTokenNonPunctuator = false; + while (lexer.advance().kind !== tokenKind_js_1.TokenKind.EOF) { + const currentToken = lexer.token; + const tokenKind = currentToken.kind; + /** + * Every two non-punctuator tokens should have space between them. + * Also prevent case of non-punctuator token following by spread resulting + * in invalid token (e.g. `1...` is invalid Float token). + */ + const isNonPunctuator = !(0, lexer_js_1.isPunctuatorTokenKind)(currentToken.kind); + if (wasLastAddedTokenNonPunctuator) { + if (isNonPunctuator || currentToken.kind === tokenKind_js_1.TokenKind.SPREAD) { + strippedBody += ' '; + } + } + const tokenBody = body.slice(currentToken.start, currentToken.end); + if (tokenKind === tokenKind_js_1.TokenKind.BLOCK_STRING) { + strippedBody += (0, blockString_js_1.printBlockString)(currentToken.value, { minimize: true }); + } + else { + strippedBody += tokenBody; + } + wasLastAddedTokenNonPunctuator = isNonPunctuator; + } + return strippedBody; +} +//# sourceMappingURL=stripIgnoredCharacters.js.map \ No newline at end of file diff --git a/utilities/stripIgnoredCharacters.js.map b/utilities/stripIgnoredCharacters.js.map new file mode 100644 index 0000000000..eb502c8193 --- /dev/null +++ b/utilities/stripIgnoredCharacters.js.map @@ -0,0 +1 @@ +{"version":3,"file":"stripIgnoredCharacters.js","sourceRoot":"","sources":["../../src/utilities/stripIgnoredCharacters.ts"],"names":[],"mappings":";;AAiEA,wDAmCC;AApGD,+DAA8D;AAC9D,mDAAoE;AACpE,qDAAyD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C;QAED,8BAA8B,GAAG,eAAe,CAAC;IACnD,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { printBlockString } from '../language/blockString.js';\nimport { isPunctuatorTokenKind, Lexer } from '../language/lexer.js';\nimport { isSource, Source } from '../language/source.js';\nimport { TokenKind } from '../language/tokenKind.js';\n\n/**\n * Strips characters that are not significant to the validity or execution\n * of a GraphQL document:\n * - UnicodeBOM\n * - WhiteSpace\n * - LineTerminator\n * - Comment\n * - Comma\n * - BlockString indentation\n *\n * Note: It is required to have a delimiter character between neighboring\n * non-punctuator tokens and this function always uses single space as delimiter.\n *\n * It is guaranteed that both input and output documents if parsed would result\n * in the exact same AST except for nodes location.\n *\n * Warning: It is guaranteed that this function will always produce stable results.\n * However, it's not guaranteed that it will stay the same between different\n * releases due to bugfixes or changes in the GraphQL specification.\n *\n * Query example:\n *\n * ```graphql\n * query SomeQuery($foo: String!, $bar: String) {\n * someField(foo: $foo, bar: $bar) {\n * a\n * b {\n * c\n * d\n * }\n * }\n * }\n * ```\n *\n * Becomes:\n *\n * ```graphql\n * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}\n * ```\n *\n * SDL example:\n *\n * ```graphql\n * \"\"\"\n * Type description\n * \"\"\"\n * type Foo {\n * \"\"\"\n * Field description\n * \"\"\"\n * bar: String\n * }\n * ```\n *\n * Becomes:\n *\n * ```graphql\n * \"\"\"Type description\"\"\" type Foo{\"\"\"Field description\"\"\" bar:String}\n * ```\n */\nexport function stripIgnoredCharacters(source: string | Source): string {\n const sourceObj = isSource(source) ? source : new Source(source);\n\n const body = sourceObj.body;\n const lexer = new Lexer(sourceObj);\n let strippedBody = '';\n\n let wasLastAddedTokenNonPunctuator = false;\n while (lexer.advance().kind !== TokenKind.EOF) {\n const currentToken = lexer.token;\n const tokenKind = currentToken.kind;\n\n /**\n * Every two non-punctuator tokens should have space between them.\n * Also prevent case of non-punctuator token following by spread resulting\n * in invalid token (e.g. `1...` is invalid Float token).\n */\n const isNonPunctuator = !isPunctuatorTokenKind(currentToken.kind);\n if (wasLastAddedTokenNonPunctuator) {\n if (isNonPunctuator || currentToken.kind === TokenKind.SPREAD) {\n strippedBody += ' ';\n }\n }\n\n const tokenBody = body.slice(currentToken.start, currentToken.end);\n if (tokenKind === TokenKind.BLOCK_STRING) {\n strippedBody += printBlockString(currentToken.value, { minimize: true });\n } else {\n strippedBody += tokenBody;\n }\n\n wasLastAddedTokenNonPunctuator = isNonPunctuator;\n }\n\n return strippedBody;\n}\n"]} \ No newline at end of file diff --git a/utilities/stripIgnoredCharacters.mjs b/utilities/stripIgnoredCharacters.mjs new file mode 100644 index 0000000000..c69f0b5ab2 --- /dev/null +++ b/utilities/stripIgnoredCharacters.mjs @@ -0,0 +1,96 @@ +import { printBlockString } from "../language/blockString.mjs"; +import { isPunctuatorTokenKind, Lexer } from "../language/lexer.mjs"; +import { isSource, Source } from "../language/source.mjs"; +import { TokenKind } from "../language/tokenKind.mjs"; +/** + * Strips characters that are not significant to the validity or execution + * of a GraphQL document: + * - UnicodeBOM + * - WhiteSpace + * - LineTerminator + * - Comment + * - Comma + * - BlockString indentation + * + * Note: It is required to have a delimiter character between neighboring + * non-punctuator tokens and this function always uses single space as delimiter. + * + * It is guaranteed that both input and output documents if parsed would result + * in the exact same AST except for nodes location. + * + * Warning: It is guaranteed that this function will always produce stable results. + * However, it's not guaranteed that it will stay the same between different + * releases due to bugfixes or changes in the GraphQL specification. + * + * Query example: + * + * ```graphql + * query SomeQuery($foo: String!, $bar: String) { + * someField(foo: $foo, bar: $bar) { + * a + * b { + * c + * d + * } + * } + * } + * ``` + * + * Becomes: + * + * ```graphql + * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} + * ``` + * + * SDL example: + * + * ```graphql + * """ + * Type description + * """ + * type Foo { + * """ + * Field description + * """ + * bar: String + * } + * ``` + * + * Becomes: + * + * ```graphql + * """Type description""" type Foo{"""Field description""" bar:String} + * ``` + */ +export function stripIgnoredCharacters(source) { + const sourceObj = isSource(source) ? source : new Source(source); + const body = sourceObj.body; + const lexer = new Lexer(sourceObj); + let strippedBody = ''; + let wasLastAddedTokenNonPunctuator = false; + while (lexer.advance().kind !== TokenKind.EOF) { + const currentToken = lexer.token; + const tokenKind = currentToken.kind; + /** + * Every two non-punctuator tokens should have space between them. + * Also prevent case of non-punctuator token following by spread resulting + * in invalid token (e.g. `1...` is invalid Float token). + */ + const isNonPunctuator = !isPunctuatorTokenKind(currentToken.kind); + if (wasLastAddedTokenNonPunctuator) { + if (isNonPunctuator || currentToken.kind === TokenKind.SPREAD) { + strippedBody += ' '; + } + } + const tokenBody = body.slice(currentToken.start, currentToken.end); + if (tokenKind === TokenKind.BLOCK_STRING) { + strippedBody += printBlockString(currentToken.value, { minimize: true }); + } + else { + strippedBody += tokenBody; + } + wasLastAddedTokenNonPunctuator = isNonPunctuator; + } + return strippedBody; +} +//# sourceMappingURL=stripIgnoredCharacters.js.map \ No newline at end of file diff --git a/utilities/stripIgnoredCharacters.mjs.map b/utilities/stripIgnoredCharacters.mjs.map new file mode 100644 index 0000000000..7b25233ba1 --- /dev/null +++ b/utilities/stripIgnoredCharacters.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"stripIgnoredCharacters.js","sourceRoot":"","sources":["../../src/utilities/stripIgnoredCharacters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oCAAmC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,8BAA6B;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,+BAA8B;AACzD,OAAO,EAAE,SAAS,EAAE,kCAAiC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAuB;IAC5D,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjE,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,YAAY,GAAG,EAAE,CAAC;IAEtB,IAAI,8BAA8B,GAAG,KAAK,CAAC;IAC3C,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,GAAG,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;QACjC,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC;QAEpC;;;;WAIG;QACH,MAAM,eAAe,GAAG,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAClE,IAAI,8BAA8B,EAAE,CAAC;YACnC,IAAI,eAAe,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;gBAC9D,YAAY,IAAI,GAAG,CAAC;YACtB,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;QACnE,IAAI,SAAS,KAAK,SAAS,CAAC,YAAY,EAAE,CAAC;YACzC,YAAY,IAAI,gBAAgB,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC;aAAM,CAAC;YACN,YAAY,IAAI,SAAS,CAAC;QAC5B,CAAC;QAED,8BAA8B,GAAG,eAAe,CAAC;IACnD,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { printBlockString } from '../language/blockString.js';\nimport { isPunctuatorTokenKind, Lexer } from '../language/lexer.js';\nimport { isSource, Source } from '../language/source.js';\nimport { TokenKind } from '../language/tokenKind.js';\n\n/**\n * Strips characters that are not significant to the validity or execution\n * of a GraphQL document:\n * - UnicodeBOM\n * - WhiteSpace\n * - LineTerminator\n * - Comment\n * - Comma\n * - BlockString indentation\n *\n * Note: It is required to have a delimiter character between neighboring\n * non-punctuator tokens and this function always uses single space as delimiter.\n *\n * It is guaranteed that both input and output documents if parsed would result\n * in the exact same AST except for nodes location.\n *\n * Warning: It is guaranteed that this function will always produce stable results.\n * However, it's not guaranteed that it will stay the same between different\n * releases due to bugfixes or changes in the GraphQL specification.\n *\n * Query example:\n *\n * ```graphql\n * query SomeQuery($foo: String!, $bar: String) {\n * someField(foo: $foo, bar: $bar) {\n * a\n * b {\n * c\n * d\n * }\n * }\n * }\n * ```\n *\n * Becomes:\n *\n * ```graphql\n * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}\n * ```\n *\n * SDL example:\n *\n * ```graphql\n * \"\"\"\n * Type description\n * \"\"\"\n * type Foo {\n * \"\"\"\n * Field description\n * \"\"\"\n * bar: String\n * }\n * ```\n *\n * Becomes:\n *\n * ```graphql\n * \"\"\"Type description\"\"\" type Foo{\"\"\"Field description\"\"\" bar:String}\n * ```\n */\nexport function stripIgnoredCharacters(source: string | Source): string {\n const sourceObj = isSource(source) ? source : new Source(source);\n\n const body = sourceObj.body;\n const lexer = new Lexer(sourceObj);\n let strippedBody = '';\n\n let wasLastAddedTokenNonPunctuator = false;\n while (lexer.advance().kind !== TokenKind.EOF) {\n const currentToken = lexer.token;\n const tokenKind = currentToken.kind;\n\n /**\n * Every two non-punctuator tokens should have space between them.\n * Also prevent case of non-punctuator token following by spread resulting\n * in invalid token (e.g. `1...` is invalid Float token).\n */\n const isNonPunctuator = !isPunctuatorTokenKind(currentToken.kind);\n if (wasLastAddedTokenNonPunctuator) {\n if (isNonPunctuator || currentToken.kind === TokenKind.SPREAD) {\n strippedBody += ' ';\n }\n }\n\n const tokenBody = body.slice(currentToken.start, currentToken.end);\n if (tokenKind === TokenKind.BLOCK_STRING) {\n strippedBody += printBlockString(currentToken.value, { minimize: true });\n } else {\n strippedBody += tokenBody;\n }\n\n wasLastAddedTokenNonPunctuator = isNonPunctuator;\n }\n\n return strippedBody;\n}\n"]} \ No newline at end of file diff --git a/utilities/typeComparators.d.ts b/utilities/typeComparators.d.ts new file mode 100644 index 0000000000..5e128ddf5e --- /dev/null +++ b/utilities/typeComparators.d.ts @@ -0,0 +1,21 @@ +import type { GraphQLCompositeType, GraphQLType } from '../type/definition.js'; +import type { GraphQLSchema } from '../type/schema.js'; +/** + * Provided two types, return true if the types are equal (invariant). + */ +export declare function isEqualType(typeA: GraphQLType, typeB: GraphQLType): boolean; +/** + * Provided a type and a super type, return true if the first type is either + * equal or a subset of the second super type (covariant). + */ +export declare function isTypeSubTypeOf(schema: GraphQLSchema, maybeSubType: GraphQLType, superType: GraphQLType): boolean; +/** + * Provided two composite types, determine if they "overlap". Two composite + * types overlap when the Sets of possible concrete types for each intersect. + * + * This is often used to determine if a fragment of a given type could possibly + * be visited in a context of another type. + * + * This function is commutative. + */ +export declare function doTypesOverlap(schema: GraphQLSchema, typeA: GraphQLCompositeType, typeB: GraphQLCompositeType): boolean; diff --git a/utilities/typeComparators.js b/utilities/typeComparators.js new file mode 100644 index 0000000000..cc12953d82 --- /dev/null +++ b/utilities/typeComparators.js @@ -0,0 +1,95 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isEqualType = isEqualType; +exports.isTypeSubTypeOf = isTypeSubTypeOf; +exports.doTypesOverlap = doTypesOverlap; +const definition_js_1 = require("../type/definition.js"); +/** + * Provided two types, return true if the types are equal (invariant). + */ +function isEqualType(typeA, typeB) { + // Equivalent types are equal. + if (typeA === typeB) { + return true; + } + // If either type is non-null, the other must also be non-null. + if ((0, definition_js_1.isNonNullType)(typeA) && (0, definition_js_1.isNonNullType)(typeB)) { + return isEqualType(typeA.ofType, typeB.ofType); + } + // If either type is a list, the other must also be a list. + if ((0, definition_js_1.isListType)(typeA) && (0, definition_js_1.isListType)(typeB)) { + return isEqualType(typeA.ofType, typeB.ofType); + } + // Otherwise the types are not equal. + return false; +} +/** + * Provided a type and a super type, return true if the first type is either + * equal or a subset of the second super type (covariant). + */ +function isTypeSubTypeOf(schema, maybeSubType, superType) { + // Equivalent type is a valid subtype + if (maybeSubType === superType) { + return true; + } + // If superType is non-null, maybeSubType must also be non-null. + if ((0, definition_js_1.isNonNullType)(superType)) { + if ((0, definition_js_1.isNonNullType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + return false; + } + if ((0, definition_js_1.isNonNullType)(maybeSubType)) { + // If superType is nullable, maybeSubType may be non-null or nullable. + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); + } + // If superType type is a list, maybeSubType type must also be a list. + if ((0, definition_js_1.isListType)(superType)) { + if ((0, definition_js_1.isListType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + return false; + } + if ((0, definition_js_1.isListType)(maybeSubType)) { + // If superType is not a list, maybeSubType must also be not a list. + return false; + } + // If superType type is an abstract type, check if it is super type of maybeSubType. + // Otherwise, the child type is not a valid subtype of the parent type. + return ((0, definition_js_1.isAbstractType)(superType) && + ((0, definition_js_1.isInterfaceType)(maybeSubType) || (0, definition_js_1.isObjectType)(maybeSubType)) && + schema.isSubType(superType, maybeSubType)); +} +/** + * Provided two composite types, determine if they "overlap". Two composite + * types overlap when the Sets of possible concrete types for each intersect. + * + * This is often used to determine if a fragment of a given type could possibly + * be visited in a context of another type. + * + * This function is commutative. + */ +function doTypesOverlap(schema, typeA, typeB) { + // Equivalent types overlap + if (typeA === typeB) { + return true; + } + if ((0, definition_js_1.isAbstractType)(typeA)) { + if ((0, definition_js_1.isAbstractType)(typeB)) { + // If both types are abstract, then determine if there is any intersection + // between possible concrete types of each. + return schema + .getPossibleTypes(typeA) + .some((type) => schema.isSubType(typeB, type)); + } + // Determine if the latter type is a possible concrete type of the former. + return schema.isSubType(typeA, typeB); + } + if ((0, definition_js_1.isAbstractType)(typeB)) { + // Determine if the former type is a possible concrete type of the latter. + return schema.isSubType(typeB, typeA); + } + // Otherwise the types do not overlap. + return false; +} +//# sourceMappingURL=typeComparators.js.map \ No newline at end of file diff --git a/utilities/typeComparators.js.map b/utilities/typeComparators.js.map new file mode 100644 index 0000000000..0b7a289afd --- /dev/null +++ b/utilities/typeComparators.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typeComparators.js","sourceRoot":"","sources":["../../src/utilities/typeComparators.ts"],"names":[],"mappings":";;AAaA,kCAkBC;AAMD,0CAyCC;AAWD,wCA6BC;AArHD,yDAM+B;AAG/B;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAkB,EAAE,KAAkB;IAChE,8BAA8B;IAC9B,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+DAA+D;IAC/D,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,2DAA2D;IAC3D,IAAI,IAAA,0BAAU,EAAC,KAAK,CAAC,IAAI,IAAA,0BAAU,EAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,qCAAqC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAC7B,MAAqB,EACrB,YAAyB,EACzB,SAAsB;IAEtB,qCAAqC;IACrC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gEAAgE;IAChE,IAAI,IAAA,6BAAa,EAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,IAAI,IAAA,6BAAa,EA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YAC1E,2CAA2C;YAC3C,OAAO,MAAM;iBACV,gBAAgB,CAAC,KAAK,CAAC;iBACvB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,0EAA0E;QAC1E,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,IAAA,8BAAc,EAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,0EAA0E;QAC1E,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,sCAAsC;IACtC,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { GraphQLCompositeType, GraphQLType } from '../type/definition.js';\nimport {\n isAbstractType,\n isInterfaceType,\n isListType,\n isNonNullType,\n isObjectType,\n} from '../type/definition.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\n/**\n * Provided two types, return true if the types are equal (invariant).\n */\nexport function isEqualType(typeA: GraphQLType, typeB: GraphQLType): boolean {\n // Equivalent types are equal.\n if (typeA === typeB) {\n return true;\n }\n\n // If either type is non-null, the other must also be non-null.\n if (isNonNullType(typeA) && isNonNullType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n }\n\n // If either type is a list, the other must also be a list.\n if (isListType(typeA) && isListType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n }\n\n // Otherwise the types are not equal.\n return false;\n}\n\n/**\n * Provided a type and a super type, return true if the first type is either\n * equal or a subset of the second super type (covariant).\n */\nexport function isTypeSubTypeOf(\n schema: GraphQLSchema,\n maybeSubType: GraphQLType,\n superType: GraphQLType,\n): boolean {\n // Equivalent type is a valid subtype\n if (maybeSubType === superType) {\n return true;\n }\n\n // If superType is non-null, maybeSubType must also be non-null.\n if (isNonNullType(superType)) {\n if (isNonNullType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n return false;\n }\n if (isNonNullType(maybeSubType)) {\n // If superType is nullable, maybeSubType may be non-null or nullable.\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);\n }\n\n // If superType type is a list, maybeSubType type must also be a list.\n if (isListType(superType)) {\n if (isListType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n return false;\n }\n if (isListType(maybeSubType)) {\n // If superType is not a list, maybeSubType must also be not a list.\n return false;\n }\n\n // If superType type is an abstract type, check if it is super type of maybeSubType.\n // Otherwise, the child type is not a valid subtype of the parent type.\n return (\n isAbstractType(superType) &&\n (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) &&\n schema.isSubType(superType, maybeSubType)\n );\n}\n\n/**\n * Provided two composite types, determine if they \"overlap\". Two composite\n * types overlap when the Sets of possible concrete types for each intersect.\n *\n * This is often used to determine if a fragment of a given type could possibly\n * be visited in a context of another type.\n *\n * This function is commutative.\n */\nexport function doTypesOverlap(\n schema: GraphQLSchema,\n typeA: GraphQLCompositeType,\n typeB: GraphQLCompositeType,\n): boolean {\n // Equivalent types overlap\n if (typeA === typeB) {\n return true;\n }\n\n if (isAbstractType(typeA)) {\n if (isAbstractType(typeB)) {\n // If both types are abstract, then determine if there is any intersection\n // between possible concrete types of each.\n return schema\n .getPossibleTypes(typeA)\n .some((type) => schema.isSubType(typeB, type));\n }\n // Determine if the latter type is a possible concrete type of the former.\n return schema.isSubType(typeA, typeB);\n }\n\n if (isAbstractType(typeB)) {\n // Determine if the former type is a possible concrete type of the latter.\n return schema.isSubType(typeB, typeA);\n }\n\n // Otherwise the types do not overlap.\n return false;\n}\n"]} \ No newline at end of file diff --git a/utilities/typeComparators.mjs b/utilities/typeComparators.mjs new file mode 100644 index 0000000000..6b1caa16c5 --- /dev/null +++ b/utilities/typeComparators.mjs @@ -0,0 +1,90 @@ +import { isAbstractType, isInterfaceType, isListType, isNonNullType, isObjectType, } from "../type/definition.mjs"; +/** + * Provided two types, return true if the types are equal (invariant). + */ +export function isEqualType(typeA, typeB) { + // Equivalent types are equal. + if (typeA === typeB) { + return true; + } + // If either type is non-null, the other must also be non-null. + if (isNonNullType(typeA) && isNonNullType(typeB)) { + return isEqualType(typeA.ofType, typeB.ofType); + } + // If either type is a list, the other must also be a list. + if (isListType(typeA) && isListType(typeB)) { + return isEqualType(typeA.ofType, typeB.ofType); + } + // Otherwise the types are not equal. + return false; +} +/** + * Provided a type and a super type, return true if the first type is either + * equal or a subset of the second super type (covariant). + */ +export function isTypeSubTypeOf(schema, maybeSubType, superType) { + // Equivalent type is a valid subtype + if (maybeSubType === superType) { + return true; + } + // If superType is non-null, maybeSubType must also be non-null. + if (isNonNullType(superType)) { + if (isNonNullType(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + return false; + } + if (isNonNullType(maybeSubType)) { + // If superType is nullable, maybeSubType may be non-null or nullable. + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); + } + // If superType type is a list, maybeSubType type must also be a list. + if (isListType(superType)) { + if (isListType(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + return false; + } + if (isListType(maybeSubType)) { + // If superType is not a list, maybeSubType must also be not a list. + return false; + } + // If superType type is an abstract type, check if it is super type of maybeSubType. + // Otherwise, the child type is not a valid subtype of the parent type. + return (isAbstractType(superType) && + (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) && + schema.isSubType(superType, maybeSubType)); +} +/** + * Provided two composite types, determine if they "overlap". Two composite + * types overlap when the Sets of possible concrete types for each intersect. + * + * This is often used to determine if a fragment of a given type could possibly + * be visited in a context of another type. + * + * This function is commutative. + */ +export function doTypesOverlap(schema, typeA, typeB) { + // Equivalent types overlap + if (typeA === typeB) { + return true; + } + if (isAbstractType(typeA)) { + if (isAbstractType(typeB)) { + // If both types are abstract, then determine if there is any intersection + // between possible concrete types of each. + return schema + .getPossibleTypes(typeA) + .some((type) => schema.isSubType(typeB, type)); + } + // Determine if the latter type is a possible concrete type of the former. + return schema.isSubType(typeA, typeB); + } + if (isAbstractType(typeB)) { + // Determine if the former type is a possible concrete type of the latter. + return schema.isSubType(typeB, typeA); + } + // Otherwise the types do not overlap. + return false; +} +//# sourceMappingURL=typeComparators.js.map \ No newline at end of file diff --git a/utilities/typeComparators.mjs.map b/utilities/typeComparators.mjs.map new file mode 100644 index 0000000000..46b226a118 --- /dev/null +++ b/utilities/typeComparators.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"typeComparators.js","sourceRoot":"","sources":["../../src/utilities/typeComparators.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,aAAa,EACb,YAAY,GACb,+BAA8B;AAG/B;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAkB,EAAE,KAAkB;IAChE,8BAA8B;IAC9B,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+DAA+D;IAC/D,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,2DAA2D;IAC3D,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,qCAAqC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAqB,EACrB,YAAyB,EACzB,SAAsB;IAEtB,qCAAqC;IACrC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,g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;YAC1B,0EAA0E;YAC1E,2CAA2C;YAC3C,OAAO,MAAM;iBACV,gBAAgB,CAAC,KAAK,CAAC;iBACvB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,0EAA0E;QAC1E,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,0EAA0E;QAC1E,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,sCAAsC;IACtC,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { GraphQLCompositeType, GraphQLType } from '../type/definition.js';\nimport {\n isAbstractType,\n isInterfaceType,\n isListType,\n isNonNullType,\n isObjectType,\n} from '../type/definition.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\n/**\n * Provided two types, return true if the types are equal (invariant).\n */\nexport function isEqualType(typeA: GraphQLType, typeB: GraphQLType): boolean {\n // Equivalent types are equal.\n if (typeA === typeB) {\n return true;\n }\n\n // If either type is non-null, the other must also be non-null.\n if (isNonNullType(typeA) && isNonNullType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n }\n\n // If either type is a list, the other must also be a list.\n if (isListType(typeA) && isListType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n }\n\n // Otherwise the types are not equal.\n return false;\n}\n\n/**\n * Provided a type and a super type, return true if the first type is either\n * equal or a subset of the second super type (covariant).\n */\nexport function isTypeSubTypeOf(\n schema: GraphQLSchema,\n maybeSubType: GraphQLType,\n superType: GraphQLType,\n): boolean {\n // Equivalent type is a valid subtype\n if (maybeSubType === superType) {\n return true;\n }\n\n // If superType is non-null, maybeSubType must also be non-null.\n if (isNonNullType(superType)) {\n if (isNonNullType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n return false;\n }\n if (isNonNullType(maybeSubType)) {\n // If superType is nullable, maybeSubType may be non-null or nullable.\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);\n }\n\n // If superType type is a list, maybeSubType type must also be a list.\n if (isListType(superType)) {\n if (isListType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n return false;\n }\n if (isListType(maybeSubType)) {\n // If superType is not a list, maybeSubType must also be not a list.\n return false;\n }\n\n // If superType type is an abstract type, check if it is super type of maybeSubType.\n // Otherwise, the child type is not a valid subtype of the parent type.\n return (\n isAbstractType(superType) &&\n (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) &&\n schema.isSubType(superType, maybeSubType)\n );\n}\n\n/**\n * Provided two composite types, determine if they \"overlap\". Two composite\n * types overlap when the Sets of possible concrete types for each intersect.\n *\n * This is often used to determine if a fragment of a given type could possibly\n * be visited in a context of another type.\n *\n * This function is commutative.\n */\nexport function doTypesOverlap(\n schema: GraphQLSchema,\n typeA: GraphQLCompositeType,\n typeB: GraphQLCompositeType,\n): boolean {\n // Equivalent types overlap\n if (typeA === typeB) {\n return true;\n }\n\n if (isAbstractType(typeA)) {\n if (isAbstractType(typeB)) {\n // If both types are abstract, then determine if there is any intersection\n // between possible concrete types of each.\n return schema\n .getPossibleTypes(typeA)\n .some((type) => schema.isSubType(typeB, type));\n }\n // Determine if the latter type is a possible concrete type of the former.\n return schema.isSubType(typeA, typeB);\n }\n\n if (isAbstractType(typeB)) {\n // Determine if the former type is a possible concrete type of the latter.\n return schema.isSubType(typeB, typeA);\n }\n\n // Otherwise the types do not overlap.\n return false;\n}\n"]} \ No newline at end of file diff --git a/utilities/typeFromAST.d.ts b/utilities/typeFromAST.d.ts new file mode 100644 index 0000000000..24cae19a23 --- /dev/null +++ b/utilities/typeFromAST.d.ts @@ -0,0 +1,15 @@ +import type { ListTypeNode, NamedTypeNode, NonNullTypeNode, TypeNode } from '../language/ast.js'; +import type { GraphQLNamedType, GraphQLType } from '../type/definition.js'; +import { GraphQLList, GraphQLNonNull } from '../type/definition.js'; +import type { GraphQLSchema } from '../type/schema.js'; +/** + * Given a Schema and an AST node describing a type, return a GraphQLType + * definition which applies to that type. For example, if provided the parsed + * AST node for `[User]`, a GraphQLList instance will be returned, containing + * the type called "User" found in the schema. If a type called "User" is not + * found in the schema, then undefined will be returned. + */ +export declare function typeFromAST(schema: GraphQLSchema, typeNode: NamedTypeNode): GraphQLNamedType | undefined; +export declare function typeFromAST(schema: GraphQLSchema, typeNode: ListTypeNode): GraphQLList | undefined; +export declare function typeFromAST(schema: GraphQLSchema, typeNode: NonNullTypeNode): GraphQLNonNull | undefined; +export declare function typeFromAST(schema: GraphQLSchema, typeNode: TypeNode): GraphQLType | undefined; diff --git a/utilities/typeFromAST.js b/utilities/typeFromAST.js new file mode 100644 index 0000000000..25a713ce3d --- /dev/null +++ b/utilities/typeFromAST.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.typeFromAST = typeFromAST; +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +function typeFromAST(schema, typeNode) { + switch (typeNode.kind) { + case kinds_js_1.Kind.LIST_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new definition_js_1.GraphQLList(innerType); + } + case kinds_js_1.Kind.NON_NULL_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new definition_js_1.GraphQLNonNull(innerType); + } + case kinds_js_1.Kind.NAMED_TYPE: + return schema.getType(typeNode.name.value); + } +} +//# sourceMappingURL=typeFromAST.js.map \ No newline at end of file diff --git a/utilities/typeFromAST.js.map b/utilities/typeFromAST.js.map new file mode 100644 index 0000000000..779372d729 --- /dev/null +++ b/utilities/typeFromAST.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typeFromAST.js","sourceRoot":"","sources":["../../src/utilities/typeFromAST.ts"],"names":[],"mappings":";;AAmCA,kCAgBC;AA7CD,mDAA4C;AAG5C,yDAAoE;AA0BpE,SAAgB,WAAW,CACzB,MAAqB,EACrB,QAAkB;IAElB,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,eAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YACpB,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,SAAS,IAAI,IAAI,2BAAW,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;QACD,KAAK,eAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACxB,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,SAAS,IAAI,IAAI,8BAAc,CAAC,SAAS,CAAC,CAAC;QACpD,CAAC;QACD,KAAK,eAAI,CAAC,UAAU;YAClB,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC","sourcesContent":["import type {\n ListTypeNode,\n NamedTypeNode,\n NonNullTypeNode,\n TypeNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLNamedType, GraphQLType } from '../type/definition.js';\nimport { GraphQLList, GraphQLNonNull } from '../type/definition.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\n/**\n * Given a Schema and an AST node describing a type, return a GraphQLType\n * definition which applies to that type. For example, if provided the parsed\n * AST node for `[User]`, a GraphQLList instance will be returned, containing\n * the type called \"User\" found in the schema. If a type called \"User\" is not\n * found in the schema, then undefined will be returned.\n */\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: NamedTypeNode,\n): GraphQLNamedType | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: ListTypeNode,\n): GraphQLList | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: NonNullTypeNode,\n): GraphQLNonNull | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: TypeNode,\n): GraphQLType | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: TypeNode,\n): GraphQLType | undefined {\n switch (typeNode.kind) {\n case Kind.LIST_TYPE: {\n const innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLList(innerType);\n }\n case Kind.NON_NULL_TYPE: {\n const innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLNonNull(innerType);\n }\n case Kind.NAMED_TYPE:\n return schema.getType(typeNode.name.value);\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/typeFromAST.mjs b/utilities/typeFromAST.mjs new file mode 100644 index 0000000000..3df3deff75 --- /dev/null +++ b/utilities/typeFromAST.mjs @@ -0,0 +1,17 @@ +import { Kind } from "../language/kinds.mjs"; +import { GraphQLList, GraphQLNonNull } from "../type/definition.mjs"; +export function typeFromAST(schema, typeNode) { + switch (typeNode.kind) { + case Kind.LIST_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new GraphQLList(innerType); + } + case Kind.NON_NULL_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new GraphQLNonNull(innerType); + } + case Kind.NAMED_TYPE: + return schema.getType(typeNode.name.value); + } +} +//# sourceMappingURL=typeFromAST.js.map \ No newline at end of file diff --git a/utilities/typeFromAST.mjs.map b/utilities/typeFromAST.mjs.map new file mode 100644 index 0000000000..4fe9b6df1d --- /dev/null +++ b/utilities/typeFromAST.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"typeFromAST.js","sourceRoot":"","sources":["../../src/utilities/typeFromAST.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAG5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,+BAA8B;AA0BpE,MAAM,UAAU,WAAW,CACzB,MAAqB,EACrB,QAAkB;IAElB,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YACpB,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,SAAS,IAAI,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;QACD,KAAK,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACxB,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,SAAS,IAAI,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;QACpD,CAAC;QACD,KAAK,IAAI,CAAC,UAAU;YAClB,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC","sourcesContent":["import type {\n ListTypeNode,\n NamedTypeNode,\n NonNullTypeNode,\n TypeNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLNamedType, GraphQLType } from '../type/definition.js';\nimport { GraphQLList, GraphQLNonNull } from '../type/definition.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\n/**\n * Given a Schema and an AST node describing a type, return a GraphQLType\n * definition which applies to that type. For example, if provided the parsed\n * AST node for `[User]`, a GraphQLList instance will be returned, containing\n * the type called \"User\" found in the schema. If a type called \"User\" is not\n * found in the schema, then undefined will be returned.\n */\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: NamedTypeNode,\n): GraphQLNamedType | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: ListTypeNode,\n): GraphQLList | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: NonNullTypeNode,\n): GraphQLNonNull | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: TypeNode,\n): GraphQLType | undefined;\nexport function typeFromAST(\n schema: GraphQLSchema,\n typeNode: TypeNode,\n): GraphQLType | undefined {\n switch (typeNode.kind) {\n case Kind.LIST_TYPE: {\n const innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLList(innerType);\n }\n case Kind.NON_NULL_TYPE: {\n const innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLNonNull(innerType);\n }\n case Kind.NAMED_TYPE:\n return schema.getType(typeNode.name.value);\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/typedQueryDocumentNode.d.ts b/utilities/typedQueryDocumentNode.d.ts new file mode 100644 index 0000000000..94ded8f335 --- /dev/null +++ b/utilities/typedQueryDocumentNode.d.ts @@ -0,0 +1,17 @@ +import type { DocumentNode, ExecutableDefinitionNode } from '../language/ast.js'; +/** + * Wrapper type that contains DocumentNode and types that can be deduced from it. + */ +export interface TypedQueryDocumentNode extends DocumentNode { + readonly definitions: ReadonlyArray; + /** + * This type is used to ensure that the variables you pass in to the query are assignable to Variables + * and that the Result is assignable to whatever you pass your result to. The method is never actually + * implemented, but the type is valid because we list it as optional + */ + __ensureTypesOfVariablesAndResultMatching?: (variables: TRequestVariables) => TResponseData; +} diff --git a/utilities/typedQueryDocumentNode.js b/utilities/typedQueryDocumentNode.js new file mode 100644 index 0000000000..44dd2a4452 --- /dev/null +++ b/utilities/typedQueryDocumentNode.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=typedQueryDocumentNode.js.map \ No newline at end of file diff --git a/utilities/typedQueryDocumentNode.js.map b/utilities/typedQueryDocumentNode.js.map new file mode 100644 index 0000000000..44405901b6 --- /dev/null +++ b/utilities/typedQueryDocumentNode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typedQueryDocumentNode.js","sourceRoot":"","sources":["../../src/utilities/typedQueryDocumentNode.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DocumentNode,\n ExecutableDefinitionNode,\n} from '../language/ast.js';\n/**\n * Wrapper type that contains DocumentNode and types that can be deduced from it.\n */\nexport interface TypedQueryDocumentNode<\n TResponseData = { [key: string]: any },\n TRequestVariables = { [key: string]: any },\n> extends DocumentNode {\n readonly definitions: ReadonlyArray;\n // FIXME: remove once TS implements proper way to enforce nominal typing\n /**\n * This type is used to ensure that the variables you pass in to the query are assignable to Variables\n * and that the Result is assignable to whatever you pass your result to. The method is never actually\n * implemented, but the type is valid because we list it as optional\n */\n __ensureTypesOfVariablesAndResultMatching?: (\n variables: TRequestVariables,\n ) => TResponseData;\n}\n"]} \ No newline at end of file diff --git a/utilities/typedQueryDocumentNode.mjs b/utilities/typedQueryDocumentNode.mjs new file mode 100644 index 0000000000..4e9ff8c556 --- /dev/null +++ b/utilities/typedQueryDocumentNode.mjs @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=typedQueryDocumentNode.js.map \ No newline at end of file diff --git a/utilities/typedQueryDocumentNode.mjs.map b/utilities/typedQueryDocumentNode.mjs.map new file mode 100644 index 0000000000..44405901b6 --- /dev/null +++ b/utilities/typedQueryDocumentNode.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"typedQueryDocumentNode.js","sourceRoot":"","sources":["../../src/utilities/typedQueryDocumentNode.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DocumentNode,\n ExecutableDefinitionNode,\n} from '../language/ast.js';\n/**\n * Wrapper type that contains DocumentNode and types that can be deduced from it.\n */\nexport interface TypedQueryDocumentNode<\n TResponseData = { [key: string]: any },\n TRequestVariables = { [key: string]: any },\n> extends DocumentNode {\n readonly definitions: ReadonlyArray;\n // FIXME: remove once TS implements proper way to enforce nominal typing\n /**\n * This type is used to ensure that the variables you pass in to the query are assignable to Variables\n * and that the Result is assignable to whatever you pass your result to. The method is never actually\n * implemented, but the type is valid because we list it as optional\n */\n __ensureTypesOfVariablesAndResultMatching?: (\n variables: TRequestVariables,\n ) => TResponseData;\n}\n"]} \ No newline at end of file diff --git a/utilities/validateInputValue.d.ts b/utilities/validateInputValue.d.ts new file mode 100644 index 0000000000..4b70e01fb6 --- /dev/null +++ b/utilities/validateInputValue.d.ts @@ -0,0 +1,19 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import { GraphQLError } from '../error/GraphQLError.js'; +import type { ValueNode } from '../language/ast.js'; +import type { GraphQLInputType } from '../type/definition.js'; +import type { FragmentVariableValues } from '../execution/collectFields.js'; +import type { VariableValues } from '../execution/values.js'; +/** + * Validate that the provided input value is allowed for this type, collecting + * all errors via a callback function. + */ +export declare function validateInputValue(inputValue: unknown, type: GraphQLInputType, onError: (error: GraphQLError, path: ReadonlyArray) => void, hideSuggestions?: Maybe): void; +/** + * Validate that the provided input literal is allowed for this type, collecting + * all errors via a callback function. + * + * If variable values are not provided, the literal is validated statically + * (not assuming that those variables are missing runtime values). + */ +export declare function validateInputLiteral(valueNode: ValueNode, type: GraphQLInputType, onError: (error: GraphQLError, path: ReadonlyArray) => void, variables?: Maybe, fragmentVariableValues?: Maybe, hideSuggestions?: Maybe): void; diff --git a/utilities/validateInputValue.js b/utilities/validateInputValue.js new file mode 100644 index 0000000000..4576694fb9 --- /dev/null +++ b/utilities/validateInputValue.js @@ -0,0 +1,265 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateInputValue = validateInputValue; +exports.validateInputLiteral = validateInputLiteral; +const didYouMean_js_1 = require("../jsutils/didYouMean.js"); +const inspect_js_1 = require("../jsutils/inspect.js"); +const isIterableObject_js_1 = require("../jsutils/isIterableObject.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const keyMap_js_1 = require("../jsutils/keyMap.js"); +const Path_js_1 = require("../jsutils/Path.js"); +const suggestionList_js_1 = require("../jsutils/suggestionList.js"); +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const kinds_js_1 = require("../language/kinds.js"); +const printer_js_1 = require("../language/printer.js"); +const definition_js_1 = require("../type/definition.js"); +const replaceVariables_js_1 = require("./replaceVariables.js"); +/** + * Validate that the provided input value is allowed for this type, collecting + * all errors via a callback function. + */ +function validateInputValue(inputValue, type, onError, hideSuggestions) { + return validateInputValueImpl(inputValue, type, onError, hideSuggestions, undefined); +} +function validateInputValueImpl(inputValue, type, onError, hideSuggestions, path) { + if ((0, definition_js_1.isNonNullType)(type)) { + if (inputValue === undefined) { + reportInvalidValue(onError, `Expected a value of non-null type "${type}" to be provided.`, path); + return; + } + if (inputValue === null) { + reportInvalidValue(onError, `Expected value of non-null type "${type}" not to be null.`, path); + return; + } + return validateInputValueImpl(inputValue, type.ofType, onError, hideSuggestions, path); + } + if (inputValue == null) { + return; + } + if ((0, definition_js_1.isListType)(type)) { + if (!(0, isIterableObject_js_1.isIterableObject)(inputValue)) { + // Lists accept a non-list value as a list of one. + validateInputValueImpl(inputValue, type.ofType, onError, hideSuggestions, path); + } + else { + let index = 0; + for (const itemValue of inputValue) { + validateInputValueImpl(itemValue, type.ofType, onError, hideSuggestions, (0, Path_js_1.addPath)(path, index++, undefined)); + } + } + } + else if ((0, definition_js_1.isInputObjectType)(type)) { + if (!(0, isObjectLike_js_1.isObjectLike)(inputValue)) { + reportInvalidValue(onError, `Expected value of type "${type}" to be an object, found: ${(0, inspect_js_1.inspect)(inputValue)}.`, path); + return; + } + const fieldDefs = type.getFields(); + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; + if (fieldValue === undefined) { + if ((0, definition_js_1.isRequiredInputField)(field)) { + reportInvalidValue(onError, `Expected value of type "${type}" to include required field "${field.name}", found: ${(0, inspect_js_1.inspect)(inputValue)}.`, path); + } + } + else { + validateInputValueImpl(fieldValue, field.type, onError, hideSuggestions, (0, Path_js_1.addPath)(path, field.name, type.name)); + } + } + const fields = Object.keys(inputValue); + // Ensure every provided field is defined. + for (const fieldName of fields) { + if (!Object.hasOwn(fieldDefs, fieldName)) { + const suggestion = hideSuggestions + ? '' + : (0, didYouMean_js_1.didYouMean)((0, suggestionList_js_1.suggestionList)(fieldName, Object.keys(fieldDefs))); + reportInvalidValue(onError, `Expected value of type "${type}" not to include unknown field "${fieldName}"${suggestion ? `.${suggestion} Found` : ', found'}: ${(0, inspect_js_1.inspect)(inputValue)}.`, path); + } + } + if (type.isOneOf) { + if (fields.length !== 1) { + reportInvalidValue(onError, `Exactly one key must be specified for OneOf type "${type}".`, path); + } + const field = fields[0]; + const value = inputValue[field]; + if (value === null) { + reportInvalidValue(onError, `Field "${field}" for OneOf type "${type}" must be non-null.`, path); + } + } + } + else { + (0, definition_js_1.assertLeafType)(type); + let result; + let caughtError; + try { + result = type.coerceInputValue(inputValue, hideSuggestions); + } + catch (error) { + if (error instanceof GraphQLError_js_1.GraphQLError) { + onError(error, (0, Path_js_1.pathToArray)(path)); + return; + } + caughtError = error; + } + if (result === undefined) { + reportInvalidValue(onError, `Expected value of type "${type}"${caughtError != null + ? `, but encountered error "${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}"; found` + : ', found'}: ${(0, inspect_js_1.inspect)(inputValue)}.`, path, caughtError); + } + } +} +function reportInvalidValue(onError, message, path, originalError) { + onError(new GraphQLError_js_1.GraphQLError(message, { originalError }), (0, Path_js_1.pathToArray)(path)); +} +/** + * Validate that the provided input literal is allowed for this type, collecting + * all errors via a callback function. + * + * If variable values are not provided, the literal is validated statically + * (not assuming that those variables are missing runtime values). + */ +// eslint-disable-next-line @typescript-eslint/max-params +function validateInputLiteral(valueNode, type, onError, variables, fragmentVariableValues, hideSuggestions) { + const context = { + static: !variables && !fragmentVariableValues, + onError, + variables, + fragmentVariableValues, + }; + return validateInputLiteralImpl(context, valueNode, type, hideSuggestions, undefined); +} +function validateInputLiteralImpl(context, valueNode, type, hideSuggestions, path) { + if (valueNode.kind === kinds_js_1.Kind.VARIABLE) { + if (context.static) { + // If no variable values are provided, this is being validated statically, + // and cannot yet produce any validation errors for variables. + return; + } + const scopedVariableValues = getScopedVariableValues(context, valueNode); + const value = scopedVariableValues?.coerced[valueNode.name.value]; + if ((0, definition_js_1.isNonNullType)(type)) { + if (value === undefined) { + reportInvalidLiteral(context.onError, `Expected variable "$${valueNode.name.value}" provided to type "${type}" to provide a runtime value.`, valueNode, path); + } + else if (value === null) { + reportInvalidLiteral(context.onError, `Expected variable "$${valueNode.name.value}" provided to non-null type "${type}" not to be null.`, valueNode, path); + } + } + // Note: This does no further checking that this variable is correct. + // This assumes this variable usage has already been validated. + return; + } + if ((0, definition_js_1.isNonNullType)(type)) { + if (valueNode.kind === kinds_js_1.Kind.NULL) { + reportInvalidLiteral(context.onError, `Expected value of non-null type "${type}" not to be null.`, valueNode, path); + return; + } + return validateInputLiteralImpl(context, valueNode, type.ofType, hideSuggestions, path); + } + if (valueNode.kind === kinds_js_1.Kind.NULL) { + return; + } + if ((0, definition_js_1.isListType)(type)) { + if (valueNode.kind !== kinds_js_1.Kind.LIST) { + // Lists accept a non-list value as a list of one. + validateInputLiteralImpl(context, valueNode, type.ofType, hideSuggestions, path); + } + else { + let index = 0; + for (const itemNode of valueNode.values) { + validateInputLiteralImpl(context, itemNode, type.ofType, hideSuggestions, (0, Path_js_1.addPath)(path, index++, undefined)); + } + } + } + else if ((0, definition_js_1.isInputObjectType)(type)) { + if (valueNode.kind !== kinds_js_1.Kind.OBJECT) { + reportInvalidLiteral(context.onError, `Expected value of type "${type}" to be an object, found: ${(0, printer_js_1.print)(valueNode)}.`, valueNode, path); + return; + } + const fieldDefs = type.getFields(); + const fieldNodes = (0, keyMap_js_1.keyMap)(valueNode.fields, (field) => field.name.value); + for (const field of Object.values(fieldDefs)) { + const fieldNode = fieldNodes[field.name]; + if (fieldNode === undefined) { + if ((0, definition_js_1.isRequiredInputField)(field)) { + reportInvalidLiteral(context.onError, `Expected value of type "${type}" to include required field "${field.name}", found: ${(0, printer_js_1.print)(valueNode)}.`, valueNode, path); + } + } + else { + const fieldValueNode = fieldNode.value; + if (fieldValueNode.kind === kinds_js_1.Kind.VARIABLE && !context.static) { + const scopedVariableValues = getScopedVariableValues(context, fieldValueNode); + const variableName = fieldValueNode.name.value; + const value = scopedVariableValues?.coerced[variableName]; + if (type.isOneOf) { + if (value === undefined) { + reportInvalidLiteral(context.onError, `Expected variable "$${variableName}" provided to field "${field.name}" for OneOf Input Object type "${type}" to provide a runtime value.`, valueNode, path); + } + else if (value === null) { + reportInvalidLiteral(context.onError, `Expected variable "$${variableName}" provided to field "${field.name}" for OneOf Input Object type "${type}" not to be null.`, valueNode, path); + } + } + else if (value === undefined && !(0, definition_js_1.isRequiredInputField)(field)) { + continue; + } + } + validateInputLiteralImpl(context, fieldValueNode, field.type, hideSuggestions, (0, Path_js_1.addPath)(path, field.name, type.name)); + } + } + const fields = valueNode.fields; + // Ensure every provided field is defined. + for (const fieldNode of fields) { + const fieldName = fieldNode.name.value; + if (!Object.hasOwn(fieldDefs, fieldName)) { + const suggestion = hideSuggestions + ? '' + : (0, didYouMean_js_1.didYouMean)((0, suggestionList_js_1.suggestionList)(fieldName, Object.keys(fieldDefs))); + reportInvalidLiteral(context.onError, `Expected value of type "${type}" not to include unknown field "${fieldName}"${suggestion ? `.${suggestion} Found` : ', found'}: ${(0, printer_js_1.print)(valueNode)}.`, fieldNode, path); + } + } + if (type.isOneOf) { + const isNotExactlyOneField = fields.length !== 1; + if (isNotExactlyOneField) { + reportInvalidLiteral(context.onError, `OneOf Input Object "${type}" must specify exactly one key.`, valueNode, path); + return; + } + const fieldValueNode = fields[0].value; + if (fieldValueNode.kind === kinds_js_1.Kind.NULL) { + const fieldName = fields[0].name.value; + reportInvalidLiteral(context.onError, `Field "${type}.${fieldName}" used for OneOf Input Object must be non-null.`, valueNode, (0, Path_js_1.addPath)(path, fieldName, undefined)); + } + } + } + else { + (0, definition_js_1.assertLeafType)(type); + let result; + let caughtError; + try { + result = type.coerceInputLiteral + ? type.coerceInputLiteral((0, replaceVariables_js_1.replaceVariables)(valueNode, context.variables, context.fragmentVariableValues), hideSuggestions) + : type.parseLiteral(valueNode, undefined, hideSuggestions); + } + catch (error) { + if (error instanceof GraphQLError_js_1.GraphQLError) { + context.onError(error, (0, Path_js_1.pathToArray)(path)); + return; + } + caughtError = error; + } + if (result === undefined) { + reportInvalidLiteral(context.onError, `Expected value of type "${type}"${caughtError != null + ? `, but encountered error "${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}"; found` + : ', found'}: ${(0, printer_js_1.print)(valueNode)}.`, valueNode, path, caughtError); + } + } +} +function getScopedVariableValues(context, valueNode) { + const variableName = valueNode.name.value; + const { fragmentVariableValues, variables } = context; + return fragmentVariableValues?.sources[variableName] + ? fragmentVariableValues + : variables; +} +function reportInvalidLiteral(onError, message, valueNode, path, originalError) { + onError(new GraphQLError_js_1.GraphQLError(message, { nodes: valueNode, originalError }), (0, Path_js_1.pathToArray)(path)); +} +//# sourceMappingURL=validateInputValue.js.map \ No newline at end of file diff --git a/utilities/validateInputValue.js.map b/utilities/validateInputValue.js.map new file mode 100644 index 0000000000..d23cb0ccb9 --- /dev/null +++ b/utilities/validateInputValue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validateInputValue.js","sourceRoot":"","sources":["../../src/utilities/validateInputValue.ts"],"names":[],"mappings":";;AAkCA,gDAaC;AAsLD,oDAqBC;AA1PD,4DAAsD;AACtD,sDAAgD;AAChD,wEAAkE;AAClE,gEAA0D;AAC1D,oDAA8C;AAG9C,gDAA0D;AAC1D,oEAA8D;AAE9D,8DAAwD;AAGxD,mDAA4C;AAC5C,uDAA+C;AAG/C,yDAM+B;AAK/B,+DAAyD;AAEzD;;;GAGG;AACH,SAAgB,kBAAkB,CAChC,UAAmB,EACnB,IAAsB,EACtB,OAA4E,EAC5E,eAAgC;IAEhC,OAAO,sBAAsB,CAC3B,UAAU,EACV,IAAI,EACJ,OAAO,EACP,eAAe,EACf,SAAS,CACV,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,UAAmB,EACnB,IAAsB,EACtB,OAA4E,EAC5E,eAA+B,EAC/B,IAAsB;IAEtB,IAAI,IAAA,6BAAa,EAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B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,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,EAC9D,IAAA,qBAAW,EAAC,IAAI,CAAC,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { didYouMean } from '../jsutils/didYouMean.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyMap } from '../jsutils/keyMap.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { Path } from '../jsutils/Path.js';\nimport { addPath, pathToArray } from '../jsutils/Path.js';\nimport { suggestionList } from '../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type { ASTNode, ValueNode, VariableNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n assertLeafType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isRequiredInputField,\n} from '../type/definition.js';\n\nimport type { FragmentVariableValues } from '../execution/collectFields.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { replaceVariables } from './replaceVariables.js';\n\n/**\n * Validate that the provided input value is allowed for this type, collecting\n * all errors via a callback function.\n */\nexport function validateInputValue(\n inputValue: unknown,\n type: GraphQLInputType,\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n hideSuggestions?: Maybe,\n): void {\n return validateInputValueImpl(\n inputValue,\n type,\n onError,\n hideSuggestions,\n undefined,\n );\n}\n\nfunction validateInputValueImpl(\n inputValue: unknown,\n type: GraphQLInputType,\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n hideSuggestions: Maybe,\n path: Path | undefined,\n): void {\n if (isNonNullType(type)) {\n if (inputValue === undefined) {\n reportInvalidValue(\n onError,\n `Expected a value of non-null type \"${type}\" to be provided.`,\n path,\n );\n return;\n }\n if (inputValue === null) {\n reportInvalidValue(\n onError,\n `Expected value of non-null type \"${type}\" not to be null.`,\n path,\n );\n return;\n }\n return validateInputValueImpl(\n inputValue,\n type.ofType,\n onError,\n hideSuggestions,\n path,\n );\n }\n\n if (inputValue == null) {\n return;\n }\n\n if (isListType(type)) {\n if (!isIterableObject(inputValue)) {\n // Lists accept a non-list value as a list of one.\n validateInputValueImpl(\n inputValue,\n type.ofType,\n onError,\n hideSuggestions,\n path,\n );\n } else {\n let index = 0;\n for (const itemValue of inputValue) {\n validateInputValueImpl(\n itemValue,\n type.ofType,\n onError,\n hideSuggestions,\n addPath(path, index++, undefined),\n );\n }\n }\n } else if (isInputObjectType(type)) {\n if (!isObjectLike(inputValue)) {\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\" to be an object, found: ${inspect(\n inputValue,\n )}.`,\n path,\n );\n return;\n }\n\n const fieldDefs = type.getFields();\n\n for (const field of Object.values(fieldDefs)) {\n const fieldValue = inputValue[field.name];\n if (fieldValue === undefined) {\n if (isRequiredInputField(field)) {\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\" to include required field \"${\n field.name\n }\", found: ${inspect(inputValue)}.`,\n path,\n );\n }\n } else {\n validateInputValueImpl(\n fieldValue,\n field.type,\n onError,\n hideSuggestions,\n addPath(path, field.name, type.name),\n );\n }\n }\n\n const fields = Object.keys(inputValue);\n // Ensure every provided field is defined.\n for (const fieldName of fields) {\n if (!Object.hasOwn(fieldDefs, fieldName)) {\n const suggestion = hideSuggestions\n ? ''\n : didYouMean(suggestionList(fieldName, Object.keys(fieldDefs)));\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\" not to include unknown field \"${fieldName}\"${\n suggestion ? `.${suggestion} Found` : ', found'\n }: ${inspect(inputValue)}.`,\n path,\n );\n }\n }\n\n if (type.isOneOf) {\n if (fields.length !== 1) {\n reportInvalidValue(\n onError,\n `Exactly one key must be specified for OneOf type \"${type}\".`,\n path,\n );\n }\n\n const field = fields[0];\n const value = inputValue[field];\n if (value === null) {\n reportInvalidValue(\n onError,\n `Field \"${field}\" for OneOf type \"${type}\" must be non-null.`,\n path,\n );\n }\n }\n } else {\n assertLeafType(type);\n\n let result;\n let caughtError;\n\n try {\n result = type.coerceInputValue(inputValue, hideSuggestions);\n } catch (error) {\n if (error instanceof GraphQLError) {\n onError(error, pathToArray(path));\n return;\n }\n caughtError = error;\n }\n\n if (result === undefined) {\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\"${\n caughtError != null\n ? `, but encountered error \"${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}\"; found`\n : ', found'\n }: ${inspect(inputValue)}.`,\n path,\n caughtError,\n );\n }\n }\n}\n\nfunction reportInvalidValue(\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n message: string,\n path: Path | undefined,\n originalError?: GraphQLError,\n): void {\n onError(new GraphQLError(message, { originalError }), pathToArray(path));\n}\n\n/**\n * Validate that the provided input literal is allowed for this type, collecting\n * all errors via a callback function.\n *\n * If variable values are not provided, the literal is validated statically\n * (not assuming that those variables are missing runtime values).\n */\n// eslint-disable-next-line @typescript-eslint/max-params\nexport function validateInputLiteral(\n valueNode: ValueNode,\n type: GraphQLInputType,\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n variables?: Maybe,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): void {\n const context: ValidationContext = {\n static: !variables && !fragmentVariableValues,\n onError,\n variables,\n fragmentVariableValues,\n };\n return validateInputLiteralImpl(\n context,\n valueNode,\n type,\n hideSuggestions,\n undefined,\n );\n}\n\ninterface ValidationContext {\n static: boolean;\n onError: (error: GraphQLError, path: ReadonlyArray) => void;\n variables?: Maybe;\n fragmentVariableValues?: Maybe;\n}\n\nfunction validateInputLiteralImpl(\n context: ValidationContext,\n valueNode: ValueNode,\n type: GraphQLInputType,\n hideSuggestions: Maybe,\n path: Path | undefined,\n): void {\n if (valueNode.kind === Kind.VARIABLE) {\n if (context.static) {\n // If no variable values are provided, this is being validated statically,\n // and cannot yet produce any validation errors for variables.\n return;\n }\n const scopedVariableValues = getScopedVariableValues(context, valueNode);\n const value = scopedVariableValues?.coerced[valueNode.name.value];\n if (isNonNullType(type)) {\n if (value === undefined) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${valueNode.name.value}\" provided to type \"${type}\" to provide a runtime value.`,\n valueNode,\n path,\n );\n } else if (value === null) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${valueNode.name.value}\" provided to non-null type \"${type}\" not to be null.`,\n valueNode,\n path,\n );\n }\n }\n // Note: This does no further checking that this variable is correct.\n // This assumes this variable usage has already been validated.\n return;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of non-null type \"${type}\" not to be null.`,\n valueNode,\n path,\n );\n return;\n }\n return validateInputLiteralImpl(\n context,\n valueNode,\n type.ofType,\n hideSuggestions,\n path,\n );\n }\n\n if (valueNode.kind === Kind.NULL) {\n return;\n }\n\n if (isListType(type)) {\n if (valueNode.kind !== Kind.LIST) {\n // Lists accept a non-list value as a list of one.\n validateInputLiteralImpl(\n context,\n valueNode,\n type.ofType,\n hideSuggestions,\n path,\n );\n } else {\n let index = 0;\n for (const itemNode of valueNode.values) {\n validateInputLiteralImpl(\n context,\n itemNode,\n type.ofType,\n hideSuggestions,\n addPath(path, index++, undefined),\n );\n }\n }\n } else if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\" to be an object, found: ${print(\n valueNode,\n )}.`,\n valueNode,\n path,\n );\n return;\n }\n\n const fieldDefs = type.getFields();\n const fieldNodes = keyMap(valueNode.fields, (field) => field.name.value);\n\n for (const field of Object.values(fieldDefs)) {\n const fieldNode = fieldNodes[field.name];\n if (fieldNode === undefined) {\n if (isRequiredInputField(field)) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\" to include required field \"${\n field.name\n }\", found: ${print(valueNode)}.`,\n valueNode,\n path,\n );\n }\n } else {\n const fieldValueNode = fieldNode.value;\n if (fieldValueNode.kind === Kind.VARIABLE && !context.static) {\n const scopedVariableValues = getScopedVariableValues(\n context,\n fieldValueNode,\n );\n const variableName = fieldValueNode.name.value;\n const value = scopedVariableValues?.coerced[variableName];\n if (type.isOneOf) {\n if (value === undefined) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${variableName}\" provided to field \"${field.name}\" for OneOf Input Object type \"${type}\" to provide a runtime value.`,\n valueNode,\n path,\n );\n } else if (value === null) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${variableName}\" provided to field \"${field.name}\" for OneOf Input Object type \"${type}\" not to be null.`,\n valueNode,\n path,\n );\n }\n } else if (value === undefined && !isRequiredInputField(field)) {\n continue;\n }\n }\n\n validateInputLiteralImpl(\n context,\n fieldValueNode,\n field.type,\n hideSuggestions,\n addPath(path, field.name, type.name),\n );\n }\n }\n\n const fields = valueNode.fields;\n // Ensure every provided field is defined.\n for (const fieldNode of fields) {\n const fieldName = fieldNode.name.value;\n if (!Object.hasOwn(fieldDefs, fieldName)) {\n const suggestion = hideSuggestions\n ? ''\n : didYouMean(suggestionList(fieldName, Object.keys(fieldDefs)));\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\" not to include unknown field \"${fieldName}\"${\n suggestion ? `.${suggestion} Found` : ', found'\n }: ${print(valueNode)}.`,\n fieldNode,\n path,\n );\n }\n }\n\n if (type.isOneOf) {\n const isNotExactlyOneField = fields.length !== 1;\n if (isNotExactlyOneField) {\n reportInvalidLiteral(\n context.onError,\n `OneOf Input Object \"${type}\" must specify exactly one key.`,\n valueNode,\n path,\n );\n return;\n }\n\n const fieldValueNode = fields[0].value;\n if (fieldValueNode.kind === Kind.NULL) {\n const fieldName = fields[0].name.value;\n reportInvalidLiteral(\n context.onError,\n `Field \"${type}.${fieldName}\" used for OneOf Input Object must be non-null.`,\n valueNode,\n addPath(path, fieldName, undefined),\n );\n }\n }\n } else {\n assertLeafType(type);\n\n let result;\n let caughtError;\n try {\n result = type.coerceInputLiteral\n ? type.coerceInputLiteral(\n replaceVariables(\n valueNode,\n context.variables,\n context.fragmentVariableValues,\n ),\n hideSuggestions,\n )\n : type.parseLiteral(valueNode, undefined, hideSuggestions);\n } catch (error) {\n if (error instanceof GraphQLError) {\n context.onError(error, pathToArray(path));\n return;\n }\n caughtError = error;\n }\n\n if (result === undefined) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\"${\n caughtError != null\n ? `, but encountered error \"${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}\"; found`\n : ', found'\n }: ${print(valueNode)}.`,\n valueNode,\n path,\n caughtError,\n );\n }\n }\n}\n\nfunction getScopedVariableValues(\n context: ValidationContext,\n valueNode: VariableNode,\n): Maybe {\n const variableName = valueNode.name.value;\n const { fragmentVariableValues, variables } = context;\n return fragmentVariableValues?.sources[variableName]\n ? fragmentVariableValues\n : variables;\n}\n\nfunction reportInvalidLiteral(\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n message: string,\n valueNode: ASTNode,\n path: Path | undefined,\n originalError?: GraphQLError,\n): void {\n onError(\n new GraphQLError(message, { nodes: valueNode, originalError }),\n pathToArray(path),\n );\n}\n"]} \ No newline at end of file diff --git a/utilities/validateInputValue.mjs b/utilities/validateInputValue.mjs new file mode 100644 index 0000000000..34723e8ba8 --- /dev/null +++ b/utilities/validateInputValue.mjs @@ -0,0 +1,261 @@ +import { didYouMean } from "../jsutils/didYouMean.mjs"; +import { inspect } from "../jsutils/inspect.mjs"; +import { isIterableObject } from "../jsutils/isIterableObject.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { keyMap } from "../jsutils/keyMap.mjs"; +import { addPath, pathToArray } from "../jsutils/Path.mjs"; +import { suggestionList } from "../jsutils/suggestionList.mjs"; +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { print } from "../language/printer.mjs"; +import { assertLeafType, isInputObjectType, isListType, isNonNullType, isRequiredInputField, } from "../type/definition.mjs"; +import { replaceVariables } from "./replaceVariables.mjs"; +/** + * Validate that the provided input value is allowed for this type, collecting + * all errors via a callback function. + */ +export function validateInputValue(inputValue, type, onError, hideSuggestions) { + return validateInputValueImpl(inputValue, type, onError, hideSuggestions, undefined); +} +function validateInputValueImpl(inputValue, type, onError, hideSuggestions, path) { + if (isNonNullType(type)) { + if (inputValue === undefined) { + reportInvalidValue(onError, `Expected a value of non-null type "${type}" to be provided.`, path); + return; + } + if (inputValue === null) { + reportInvalidValue(onError, `Expected value of non-null type "${type}" not to be null.`, path); + return; + } + return validateInputValueImpl(inputValue, type.ofType, onError, hideSuggestions, path); + } + if (inputValue == null) { + return; + } + if (isListType(type)) { + if (!isIterableObject(inputValue)) { + // Lists accept a non-list value as a list of one. + validateInputValueImpl(inputValue, type.ofType, onError, hideSuggestions, path); + } + else { + let index = 0; + for (const itemValue of inputValue) { + validateInputValueImpl(itemValue, type.ofType, onError, hideSuggestions, addPath(path, index++, undefined)); + } + } + } + else if (isInputObjectType(type)) { + if (!isObjectLike(inputValue)) { + reportInvalidValue(onError, `Expected value of type "${type}" to be an object, found: ${inspect(inputValue)}.`, path); + return; + } + const fieldDefs = type.getFields(); + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; + if (fieldValue === undefined) { + if (isRequiredInputField(field)) { + reportInvalidValue(onError, `Expected value of type "${type}" to include required field "${field.name}", found: ${inspect(inputValue)}.`, path); + } + } + else { + validateInputValueImpl(fieldValue, field.type, onError, hideSuggestions, addPath(path, field.name, type.name)); + } + } + const fields = Object.keys(inputValue); + // Ensure every provided field is defined. + for (const fieldName of fields) { + if (!Object.hasOwn(fieldDefs, fieldName)) { + const suggestion = hideSuggestions + ? '' + : didYouMean(suggestionList(fieldName, Object.keys(fieldDefs))); + reportInvalidValue(onError, `Expected value of type "${type}" not to include unknown field "${fieldName}"${suggestion ? `.${suggestion} Found` : ', found'}: ${inspect(inputValue)}.`, path); + } + } + if (type.isOneOf) { + if (fields.length !== 1) { + reportInvalidValue(onError, `Exactly one key must be specified for OneOf type "${type}".`, path); + } + const field = fields[0]; + const value = inputValue[field]; + if (value === null) { + reportInvalidValue(onError, `Field "${field}" for OneOf type "${type}" must be non-null.`, path); + } + } + } + else { + assertLeafType(type); + let result; + let caughtError; + try { + result = type.coerceInputValue(inputValue, hideSuggestions); + } + catch (error) { + if (error instanceof GraphQLError) { + onError(error, pathToArray(path)); + return; + } + caughtError = error; + } + if (result === undefined) { + reportInvalidValue(onError, `Expected value of type "${type}"${caughtError != null + ? `, but encountered error "${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}"; found` + : ', found'}: ${inspect(inputValue)}.`, path, caughtError); + } + } +} +function reportInvalidValue(onError, message, path, originalError) { + onError(new GraphQLError(message, { originalError }), pathToArray(path)); +} +/** + * Validate that the provided input literal is allowed for this type, collecting + * all errors via a callback function. + * + * If variable values are not provided, the literal is validated statically + * (not assuming that those variables are missing runtime values). + */ +// eslint-disable-next-line @typescript-eslint/max-params +export function validateInputLiteral(valueNode, type, onError, variables, fragmentVariableValues, hideSuggestions) { + const context = { + static: !variables && !fragmentVariableValues, + onError, + variables, + fragmentVariableValues, + }; + return validateInputLiteralImpl(context, valueNode, type, hideSuggestions, undefined); +} +function validateInputLiteralImpl(context, valueNode, type, hideSuggestions, path) { + if (valueNode.kind === Kind.VARIABLE) { + if (context.static) { + // If no variable values are provided, this is being validated statically, + // and cannot yet produce any validation errors for variables. + return; + } + const scopedVariableValues = getScopedVariableValues(context, valueNode); + const value = scopedVariableValues?.coerced[valueNode.name.value]; + if (isNonNullType(type)) { + if (value === undefined) { + reportInvalidLiteral(context.onError, `Expected variable "$${valueNode.name.value}" provided to type "${type}" to provide a runtime value.`, valueNode, path); + } + else if (value === null) { + reportInvalidLiteral(context.onError, `Expected variable "$${valueNode.name.value}" provided to non-null type "${type}" not to be null.`, valueNode, path); + } + } + // Note: This does no further checking that this variable is correct. + // This assumes this variable usage has already been validated. + return; + } + if (isNonNullType(type)) { + if (valueNode.kind === Kind.NULL) { + reportInvalidLiteral(context.onError, `Expected value of non-null type "${type}" not to be null.`, valueNode, path); + return; + } + return validateInputLiteralImpl(context, valueNode, type.ofType, hideSuggestions, path); + } + if (valueNode.kind === Kind.NULL) { + return; + } + if (isListType(type)) { + if (valueNode.kind !== Kind.LIST) { + // Lists accept a non-list value as a list of one. + validateInputLiteralImpl(context, valueNode, type.ofType, hideSuggestions, path); + } + else { + let index = 0; + for (const itemNode of valueNode.values) { + validateInputLiteralImpl(context, itemNode, type.ofType, hideSuggestions, addPath(path, index++, undefined)); + } + } + } + else if (isInputObjectType(type)) { + if (valueNode.kind !== Kind.OBJECT) { + reportInvalidLiteral(context.onError, `Expected value of type "${type}" to be an object, found: ${print(valueNode)}.`, valueNode, path); + return; + } + const fieldDefs = type.getFields(); + const fieldNodes = keyMap(valueNode.fields, (field) => field.name.value); + for (const field of Object.values(fieldDefs)) { + const fieldNode = fieldNodes[field.name]; + if (fieldNode === undefined) { + if (isRequiredInputField(field)) { + reportInvalidLiteral(context.onError, `Expected value of type "${type}" to include required field "${field.name}", found: ${print(valueNode)}.`, valueNode, path); + } + } + else { + const fieldValueNode = fieldNode.value; + if (fieldValueNode.kind === Kind.VARIABLE && !context.static) { + const scopedVariableValues = getScopedVariableValues(context, fieldValueNode); + const variableName = fieldValueNode.name.value; + const value = scopedVariableValues?.coerced[variableName]; + if (type.isOneOf) { + if (value === undefined) { + reportInvalidLiteral(context.onError, `Expected variable "$${variableName}" provided to field "${field.name}" for OneOf Input Object type "${type}" to provide a runtime value.`, valueNode, path); + } + else if (value === null) { + reportInvalidLiteral(context.onError, `Expected variable "$${variableName}" provided to field "${field.name}" for OneOf Input Object type "${type}" not to be null.`, valueNode, path); + } + } + else if (value === undefined && !isRequiredInputField(field)) { + continue; + } + } + validateInputLiteralImpl(context, fieldValueNode, field.type, hideSuggestions, addPath(path, field.name, type.name)); + } + } + const fields = valueNode.fields; + // Ensure every provided field is defined. + for (const fieldNode of fields) { + const fieldName = fieldNode.name.value; + if (!Object.hasOwn(fieldDefs, fieldName)) { + const suggestion = hideSuggestions + ? '' + : didYouMean(suggestionList(fieldName, Object.keys(fieldDefs))); + reportInvalidLiteral(context.onError, `Expected value of type "${type}" not to include unknown field "${fieldName}"${suggestion ? `.${suggestion} Found` : ', found'}: ${print(valueNode)}.`, fieldNode, path); + } + } + if (type.isOneOf) { + const isNotExactlyOneField = fields.length !== 1; + if (isNotExactlyOneField) { + reportInvalidLiteral(context.onError, `OneOf Input Object "${type}" must specify exactly one key.`, valueNode, path); + return; + } + const fieldValueNode = fields[0].value; + if (fieldValueNode.kind === Kind.NULL) { + const fieldName = fields[0].name.value; + reportInvalidLiteral(context.onError, `Field "${type}.${fieldName}" used for OneOf Input Object must be non-null.`, valueNode, addPath(path, fieldName, undefined)); + } + } + } + else { + assertLeafType(type); + let result; + let caughtError; + try { + result = type.coerceInputLiteral + ? type.coerceInputLiteral(replaceVariables(valueNode, context.variables, context.fragmentVariableValues), hideSuggestions) + : type.parseLiteral(valueNode, undefined, hideSuggestions); + } + catch (error) { + if (error instanceof GraphQLError) { + context.onError(error, pathToArray(path)); + return; + } + caughtError = error; + } + if (result === undefined) { + reportInvalidLiteral(context.onError, `Expected value of type "${type}"${caughtError != null + ? `, but encountered error "${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}"; found` + : ', found'}: ${print(valueNode)}.`, valueNode, path, caughtError); + } + } +} +function getScopedVariableValues(context, valueNode) { + const variableName = valueNode.name.value; + const { fragmentVariableValues, variables } = context; + return fragmentVariableValues?.sources[variableName] + ? fragmentVariableValues + : variables; +} +function reportInvalidLiteral(onError, message, valueNode, path, originalError) { + onError(new GraphQLError(message, { nodes: valueNode, originalError }), pathToArray(path)); +} +//# sourceMappingURL=validateInputValue.js.map \ No newline at end of file diff --git a/utilities/validateInputValue.mjs.map b/utilities/validateInputValue.mjs.map new file mode 100644 index 0000000000..87a8911049 --- /dev/null +++ b/utilities/validateInputValue.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"validateInputValue.js","sourceRoot":"","sources":["../../src/utilities/validateInputValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kCAAiC;AACtD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,gBAAgB,EAAE,wCAAuC;AAClE,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,MAAM,EAAE,8BAA6B;AAG9C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,4BAA2B;AAC1D,OAAO,EAAE,cAAc,EAAE,sCAAqC;AAE9D,OAAO,EAAE,YAAY,EAAE,kCAAiC;AAGxD,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAC5C,OAAO,EAAE,KAAK,EAAE,gCAA+B;AAG/C,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,oBAAoB,GACrB,+BAA8B;AAK/B,OAAO,EAAE,gBAAgB,EAAE,+BAA8B;AAEzD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAmB,EACnB,IAAsB,EACtB,OAA4E,EAC5E,eAAgC;IAEhC,OAAO,sBAAsB,CAC3B,UAAU,EACV,IAAI,EACJ,OAAO,EACP,eAAe,EACf,SAAS,CACV,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,UAAmB,EACnB,IAAsB,EACtB,OAA4E,EAC5E,eAA+B,EAC/B,IAAsB;IAEtB,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,kBAAkB,CAChB,OAAO,EACP,sCAAsC,IAAI,mBAAmB,EAC7D,IAAI,CACL,CAAC;YACF,OAAO;QACT,CAAC;QACD,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACxB,kBAAkB,CAChB,OAAO,EACP,oCAAoC,IAAI,mBAAmB,EAC3D,IAAI,CACL,CAAC;YACF,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AA2B,IAAI,IAC7B,WAAW,IAAI,IAAI;gBACjB,CAAC,CAAC,4BAA4B,WAAW,CAAC,OAAO,IAAI,IAAI,IAAI,WAAW,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,UAAU;gBACrI,CAAC,CAAC,SACN,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,EACxB,SAAS,EACT,IAAI,EACJ,WAAW,CACZ,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,OAA0B,EAC1B,SAAuB;IAEvB,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;IAC1C,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACtD,OAAO,sBAAsB,EAAE,OAAO,CAAC,YAAY,CAAC;QAClD,CAAC,CAAC,sBAAsB;QACxB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,oBAAoB,CAC3B,OAA4E,EAC5E,OAAe,EACf,SAAkB,EAClB,IAAsB,EACtB,aAA4B;IAE5B,OAAO,CACL,IAAI,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,EAC9D,WAAW,CAAC,IAAI,CAAC,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { didYouMean } from '../jsutils/didYouMean.js';\nimport { inspect } from '../jsutils/inspect.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\nimport { keyMap } from '../jsutils/keyMap.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { Path } from '../jsutils/Path.js';\nimport { addPath, pathToArray } from '../jsutils/Path.js';\nimport { suggestionList } from '../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type { ASTNode, ValueNode, VariableNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport { print } from '../language/printer.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n assertLeafType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isRequiredInputField,\n} from '../type/definition.js';\n\nimport type { FragmentVariableValues } from '../execution/collectFields.js';\nimport type { VariableValues } from '../execution/values.js';\n\nimport { replaceVariables } from './replaceVariables.js';\n\n/**\n * Validate that the provided input value is allowed for this type, collecting\n * all errors via a callback function.\n */\nexport function validateInputValue(\n inputValue: unknown,\n type: GraphQLInputType,\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n hideSuggestions?: Maybe,\n): void {\n return validateInputValueImpl(\n inputValue,\n type,\n onError,\n hideSuggestions,\n undefined,\n );\n}\n\nfunction validateInputValueImpl(\n inputValue: unknown,\n type: GraphQLInputType,\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n hideSuggestions: Maybe,\n path: Path | undefined,\n): void {\n if (isNonNullType(type)) {\n if (inputValue === undefined) {\n reportInvalidValue(\n onError,\n `Expected a value of non-null type \"${type}\" to be provided.`,\n path,\n );\n return;\n }\n if (inputValue === null) {\n reportInvalidValue(\n onError,\n `Expected value of non-null type \"${type}\" not to be null.`,\n path,\n );\n return;\n }\n return validateInputValueImpl(\n inputValue,\n type.ofType,\n onError,\n hideSuggestions,\n path,\n );\n }\n\n if (inputValue == null) {\n return;\n }\n\n if (isListType(type)) {\n if (!isIterableObject(inputValue)) {\n // Lists accept a non-list value as a list of one.\n validateInputValueImpl(\n inputValue,\n type.ofType,\n onError,\n hideSuggestions,\n path,\n );\n } else {\n let index = 0;\n for (const itemValue of inputValue) {\n validateInputValueImpl(\n itemValue,\n type.ofType,\n onError,\n hideSuggestions,\n addPath(path, index++, undefined),\n );\n }\n }\n } else if (isInputObjectType(type)) {\n if (!isObjectLike(inputValue)) {\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\" to be an object, found: ${inspect(\n inputValue,\n )}.`,\n path,\n );\n return;\n }\n\n const fieldDefs = type.getFields();\n\n for (const field of Object.values(fieldDefs)) {\n const fieldValue = inputValue[field.name];\n if (fieldValue === undefined) {\n if (isRequiredInputField(field)) {\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\" to include required field \"${\n field.name\n }\", found: ${inspect(inputValue)}.`,\n path,\n );\n }\n } else {\n validateInputValueImpl(\n fieldValue,\n field.type,\n onError,\n hideSuggestions,\n addPath(path, field.name, type.name),\n );\n }\n }\n\n const fields = Object.keys(inputValue);\n // Ensure every provided field is defined.\n for (const fieldName of fields) {\n if (!Object.hasOwn(fieldDefs, fieldName)) {\n const suggestion = hideSuggestions\n ? ''\n : didYouMean(suggestionList(fieldName, Object.keys(fieldDefs)));\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\" not to include unknown field \"${fieldName}\"${\n suggestion ? `.${suggestion} Found` : ', found'\n }: ${inspect(inputValue)}.`,\n path,\n );\n }\n }\n\n if (type.isOneOf) {\n if (fields.length !== 1) {\n reportInvalidValue(\n onError,\n `Exactly one key must be specified for OneOf type \"${type}\".`,\n path,\n );\n }\n\n const field = fields[0];\n const value = inputValue[field];\n if (value === null) {\n reportInvalidValue(\n onError,\n `Field \"${field}\" for OneOf type \"${type}\" must be non-null.`,\n path,\n );\n }\n }\n } else {\n assertLeafType(type);\n\n let result;\n let caughtError;\n\n try {\n result = type.coerceInputValue(inputValue, hideSuggestions);\n } catch (error) {\n if (error instanceof GraphQLError) {\n onError(error, pathToArray(path));\n return;\n }\n caughtError = error;\n }\n\n if (result === undefined) {\n reportInvalidValue(\n onError,\n `Expected value of type \"${type}\"${\n caughtError != null\n ? `, but encountered error \"${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}\"; found`\n : ', found'\n }: ${inspect(inputValue)}.`,\n path,\n caughtError,\n );\n }\n }\n}\n\nfunction reportInvalidValue(\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n message: string,\n path: Path | undefined,\n originalError?: GraphQLError,\n): void {\n onError(new GraphQLError(message, { originalError }), pathToArray(path));\n}\n\n/**\n * Validate that the provided input literal is allowed for this type, collecting\n * all errors via a callback function.\n *\n * If variable values are not provided, the literal is validated statically\n * (not assuming that those variables are missing runtime values).\n */\n// eslint-disable-next-line @typescript-eslint/max-params\nexport function validateInputLiteral(\n valueNode: ValueNode,\n type: GraphQLInputType,\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n variables?: Maybe,\n fragmentVariableValues?: Maybe,\n hideSuggestions?: Maybe,\n): void {\n const context: ValidationContext = {\n static: !variables && !fragmentVariableValues,\n onError,\n variables,\n fragmentVariableValues,\n };\n return validateInputLiteralImpl(\n context,\n valueNode,\n type,\n hideSuggestions,\n undefined,\n );\n}\n\ninterface ValidationContext {\n static: boolean;\n onError: (error: GraphQLError, path: ReadonlyArray) => void;\n variables?: Maybe;\n fragmentVariableValues?: Maybe;\n}\n\nfunction validateInputLiteralImpl(\n context: ValidationContext,\n valueNode: ValueNode,\n type: GraphQLInputType,\n hideSuggestions: Maybe,\n path: Path | undefined,\n): void {\n if (valueNode.kind === Kind.VARIABLE) {\n if (context.static) {\n // If no variable values are provided, this is being validated statically,\n // and cannot yet produce any validation errors for variables.\n return;\n }\n const scopedVariableValues = getScopedVariableValues(context, valueNode);\n const value = scopedVariableValues?.coerced[valueNode.name.value];\n if (isNonNullType(type)) {\n if (value === undefined) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${valueNode.name.value}\" provided to type \"${type}\" to provide a runtime value.`,\n valueNode,\n path,\n );\n } else if (value === null) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${valueNode.name.value}\" provided to non-null type \"${type}\" not to be null.`,\n valueNode,\n path,\n );\n }\n }\n // Note: This does no further checking that this variable is correct.\n // This assumes this variable usage has already been validated.\n return;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of non-null type \"${type}\" not to be null.`,\n valueNode,\n path,\n );\n return;\n }\n return validateInputLiteralImpl(\n context,\n valueNode,\n type.ofType,\n hideSuggestions,\n path,\n );\n }\n\n if (valueNode.kind === Kind.NULL) {\n return;\n }\n\n if (isListType(type)) {\n if (valueNode.kind !== Kind.LIST) {\n // Lists accept a non-list value as a list of one.\n validateInputLiteralImpl(\n context,\n valueNode,\n type.ofType,\n hideSuggestions,\n path,\n );\n } else {\n let index = 0;\n for (const itemNode of valueNode.values) {\n validateInputLiteralImpl(\n context,\n itemNode,\n type.ofType,\n hideSuggestions,\n addPath(path, index++, undefined),\n );\n }\n }\n } else if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\" to be an object, found: ${print(\n valueNode,\n )}.`,\n valueNode,\n path,\n );\n return;\n }\n\n const fieldDefs = type.getFields();\n const fieldNodes = keyMap(valueNode.fields, (field) => field.name.value);\n\n for (const field of Object.values(fieldDefs)) {\n const fieldNode = fieldNodes[field.name];\n if (fieldNode === undefined) {\n if (isRequiredInputField(field)) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\" to include required field \"${\n field.name\n }\", found: ${print(valueNode)}.`,\n valueNode,\n path,\n );\n }\n } else {\n const fieldValueNode = fieldNode.value;\n if (fieldValueNode.kind === Kind.VARIABLE && !context.static) {\n const scopedVariableValues = getScopedVariableValues(\n context,\n fieldValueNode,\n );\n const variableName = fieldValueNode.name.value;\n const value = scopedVariableValues?.coerced[variableName];\n if (type.isOneOf) {\n if (value === undefined) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${variableName}\" provided to field \"${field.name}\" for OneOf Input Object type \"${type}\" to provide a runtime value.`,\n valueNode,\n path,\n );\n } else if (value === null) {\n reportInvalidLiteral(\n context.onError,\n `Expected variable \"$${variableName}\" provided to field \"${field.name}\" for OneOf Input Object type \"${type}\" not to be null.`,\n valueNode,\n path,\n );\n }\n } else if (value === undefined && !isRequiredInputField(field)) {\n continue;\n }\n }\n\n validateInputLiteralImpl(\n context,\n fieldValueNode,\n field.type,\n hideSuggestions,\n addPath(path, field.name, type.name),\n );\n }\n }\n\n const fields = valueNode.fields;\n // Ensure every provided field is defined.\n for (const fieldNode of fields) {\n const fieldName = fieldNode.name.value;\n if (!Object.hasOwn(fieldDefs, fieldName)) {\n const suggestion = hideSuggestions\n ? ''\n : didYouMean(suggestionList(fieldName, Object.keys(fieldDefs)));\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\" not to include unknown field \"${fieldName}\"${\n suggestion ? `.${suggestion} Found` : ', found'\n }: ${print(valueNode)}.`,\n fieldNode,\n path,\n );\n }\n }\n\n if (type.isOneOf) {\n const isNotExactlyOneField = fields.length !== 1;\n if (isNotExactlyOneField) {\n reportInvalidLiteral(\n context.onError,\n `OneOf Input Object \"${type}\" must specify exactly one key.`,\n valueNode,\n path,\n );\n return;\n }\n\n const fieldValueNode = fields[0].value;\n if (fieldValueNode.kind === Kind.NULL) {\n const fieldName = fields[0].name.value;\n reportInvalidLiteral(\n context.onError,\n `Field \"${type}.${fieldName}\" used for OneOf Input Object must be non-null.`,\n valueNode,\n addPath(path, fieldName, undefined),\n );\n }\n }\n } else {\n assertLeafType(type);\n\n let result;\n let caughtError;\n try {\n result = type.coerceInputLiteral\n ? type.coerceInputLiteral(\n replaceVariables(\n valueNode,\n context.variables,\n context.fragmentVariableValues,\n ),\n hideSuggestions,\n )\n : type.parseLiteral(valueNode, undefined, hideSuggestions);\n } catch (error) {\n if (error instanceof GraphQLError) {\n context.onError(error, pathToArray(path));\n return;\n }\n caughtError = error;\n }\n\n if (result === undefined) {\n reportInvalidLiteral(\n context.onError,\n `Expected value of type \"${type}\"${\n caughtError != null\n ? `, but encountered error \"${caughtError.message != null && caughtError.message !== '' ? caughtError.message : caughtError}\"; found`\n : ', found'\n }: ${print(valueNode)}.`,\n valueNode,\n path,\n caughtError,\n );\n }\n }\n}\n\nfunction getScopedVariableValues(\n context: ValidationContext,\n valueNode: VariableNode,\n): Maybe {\n const variableName = valueNode.name.value;\n const { fragmentVariableValues, variables } = context;\n return fragmentVariableValues?.sources[variableName]\n ? fragmentVariableValues\n : variables;\n}\n\nfunction reportInvalidLiteral(\n onError: (error: GraphQLError, path: ReadonlyArray) => void,\n message: string,\n valueNode: ASTNode,\n path: Path | undefined,\n originalError?: GraphQLError,\n): void {\n onError(\n new GraphQLError(message, { nodes: valueNode, originalError }),\n pathToArray(path),\n );\n}\n"]} \ No newline at end of file diff --git a/utilities/valueFromAST.d.ts b/utilities/valueFromAST.d.ts new file mode 100644 index 0000000000..0e10f1b057 --- /dev/null +++ b/utilities/valueFromAST.d.ts @@ -0,0 +1,26 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { ValueNode } from '../language/ast.js'; +import type { GraphQLInputType } from '../type/definition.js'; +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * A GraphQL type must be provided, which will be used to interpret different + * GraphQL Value literals. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + * + * | GraphQL Value | JSON Value | + * | -------------------- | ------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String | String | + * | Int / Float | Number | + * | Enum Value | Unknown | + * | NullValue | null | + * + * @deprecated use `coerceInputLiteral()` instead - will be removed in v18 + */ +export declare function valueFromAST(valueNode: Maybe, type: GraphQLInputType, variables?: Maybe>): unknown; diff --git a/utilities/valueFromAST.js b/utilities/valueFromAST.js new file mode 100644 index 0000000000..e19e0c0589 --- /dev/null +++ b/utilities/valueFromAST.js @@ -0,0 +1,149 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.valueFromAST = valueFromAST; +const inspect_js_1 = require("../jsutils/inspect.js"); +const invariant_js_1 = require("../jsutils/invariant.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * A GraphQL type must be provided, which will be used to interpret different + * GraphQL Value literals. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + * + * | GraphQL Value | JSON Value | + * | -------------------- | ------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String | String | + * | Int / Float | Number | + * | Enum Value | Unknown | + * | NullValue | null | + * + * @deprecated use `coerceInputLiteral()` instead - will be removed in v18 + */ +function valueFromAST(valueNode, type, variables) { + if (!valueNode) { + // When there is no node, then there is also no value. + // Importantly, this is different from returning the value null. + return; + } + if (valueNode.kind === kinds_js_1.Kind.VARIABLE) { + const variableName = valueNode.name.value; + const variableValue = variables?.[variableName]; + if (variableValue === undefined) { + // No valid return value. + return; + } + if (variableValue === null && (0, definition_js_1.isNonNullType)(type)) { + return; // Invalid: intentionally return no value. + } + // Note: This does no further checking that this variable is correct. + // This assumes that this query has been validated and the variable + // usage here is of the correct type. + return variableValue; + } + if ((0, definition_js_1.isNonNullType)(type)) { + if (valueNode.kind === kinds_js_1.Kind.NULL) { + return; // Invalid: intentionally return no value. + } + return valueFromAST(valueNode, type.ofType, variables); + } + if (valueNode.kind === kinds_js_1.Kind.NULL) { + // This is explicitly returning the value null. + return null; + } + if ((0, definition_js_1.isListType)(type)) { + const itemType = type.ofType; + if (valueNode.kind === kinds_js_1.Kind.LIST) { + const coercedValues = []; + for (const itemNode of valueNode.values) { + if (isMissingVariable(itemNode, variables)) { + // If an array contains a missing variable, it is either coerced to + // null or if the item type is non-null, it considered invalid. + if ((0, definition_js_1.isNonNullType)(itemType)) { + return; // Invalid: intentionally return no value. + } + coercedValues.push(null); + } + else { + const itemValue = valueFromAST(itemNode, itemType, variables); + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValues.push(itemValue); + } + } + return coercedValues; + } + const coercedValue = valueFromAST(valueNode, itemType, variables); + if (coercedValue === undefined) { + return; // Invalid: intentionally return no value. + } + return [coercedValue]; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + if (valueNode.kind !== kinds_js_1.Kind.OBJECT) { + return; // Invalid: intentionally return no value. + } + const coercedObj = Object.create(null); + const fieldNodes = new Map(valueNode.fields.map((field) => [field.name.value, field])); + for (const field of Object.values(type.getFields())) { + const fieldNode = fieldNodes.get(field.name); + if (fieldNode == null || isMissingVariable(fieldNode.value, variables)) { + if (field.defaultValue !== undefined) { + coercedObj[field.name] = field.defaultValue; + } + else if ((0, definition_js_1.isNonNullType)(field.type)) { + return; // Invalid: intentionally return no value. + } + continue; + } + const fieldValue = valueFromAST(fieldNode.value, field.type, variables); + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + coercedObj[field.name] = fieldValue; + } + if (type.isOneOf) { + const keys = Object.keys(coercedObj); + if (keys.length !== 1) { + return; // Invalid: not exactly one key, intentionally return no value. + } + if (coercedObj[keys[0]] === null) { + return; // Invalid: value not non-null, intentionally return no value. + } + } + return coercedObj; + } + if ((0, definition_js_1.isLeafType)(type)) { + // Scalars and Enums fulfill parsing a literal value via parseLiteral(). + // Invalid values represent a failure to parse correctly, in which case + // no value is returned. + let result; + try { + result = type.parseLiteral(valueNode, variables); + } + catch (_error) { + return; // Invalid: intentionally return no value. + } + if (result === undefined) { + return; // Invalid: intentionally return no value. + } + return result; + } + /* c8 ignore next 3 */ + // Not reachable, all possible input types have been considered. + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected input type: ' + (0, inspect_js_1.inspect)(type)); +} +// Returns true if the provided valueNode is a variable which is not defined +// in the set of variables. +function isMissingVariable(valueNode, variables) { + return (valueNode.kind === kinds_js_1.Kind.VARIABLE && + (variables == null || variables[valueNode.name.value] === undefined)); +} +//# sourceMappingURL=valueFromAST.js.map \ No newline at end of file diff --git a/utilities/valueFromAST.js.map b/utilities/valueFromAST.js.map new file mode 100644 index 0000000000..3704fe86ef --- /dev/null +++ b/utilities/valueFromAST.js.map @@ -0,0 +1 @@ +{"version":3,"file":"valueFromAST.js","sourceRoot":"","sources":["../../src/utilities/valueFromAST.ts"],"names":[],"mappings":";;AAqCA,oCA6HC;AAlKD,sDAAgD;AA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AE,CAAC;QACrB,wEAAwE;QACxE,uEAAuE;QACvE,wBAAwB;QACxB,IAAI,MAAM,CAAC;QACX,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,OAAO,CAAC,0CAA0C;QACpD,CAAC;QACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,CAAC,0CAA0C;QACpD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,sBAAsB;IACtB,gEAAgE;IAChE,CAAU,KAAK,SAAf,wBAAS,SAAQ,yBAAyB,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,EAAE;AAC9D,CAAC;AAED,4EAA4E;AAC5E,2BAA2B;AAC3B,SAAS,iBAAiB,CACxB,SAAoB,EACpB,SAAiC;IAEjC,OAAO,CACL,SAAS,CAAC,IAAI,KAAK,eAAI,CAAC,QAAQ;QAChC,CAAC,SAAS,IAAI,IAAI,IAAI,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type { ValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n isInputObjectType,\n isLeafType,\n isListType,\n isNonNullType,\n} from '../type/definition.js';\n\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * GraphQL Value literals.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n *\n * | GraphQL Value | JSON Value |\n * | -------------------- | ------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String | String |\n * | Int / Float | Number |\n * | Enum Value | Unknown |\n * | NullValue | null |\n *\n * @deprecated use `coerceInputLiteral()` instead - will be removed in v18\n */\nexport function valueFromAST(\n valueNode: Maybe,\n type: GraphQLInputType,\n variables?: Maybe>,\n): unknown {\n if (!valueNode) {\n // When there is no node, then there is also no value.\n // Importantly, this is different from returning the value null.\n return;\n }\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n const variableValue = variables?.[variableName];\n if (variableValue === undefined) {\n // No valid return value.\n return;\n }\n if (variableValue === null && isNonNullType(type)) {\n return; // Invalid: intentionally return no value.\n }\n // Note: This does no further checking that this variable is correct.\n // This assumes that this query has been validated and the variable\n // usage here is of the correct type.\n return variableValue;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n return valueFromAST(valueNode, type.ofType, variables);\n }\n\n if (valueNode.kind === Kind.NULL) {\n // This is explicitly returning the value null.\n return null;\n }\n\n if (isListType(type)) {\n const itemType = type.ofType;\n if (valueNode.kind === Kind.LIST) {\n const coercedValues = [];\n for (const itemNode of valueNode.values) {\n if (isMissingVariable(itemNode, variables)) {\n // If an array contains a missing variable, it is either coerced to\n // null or if the item type is non-null, it considered invalid.\n if (isNonNullType(itemType)) {\n return; // Invalid: intentionally return no value.\n }\n coercedValues.push(null);\n } else {\n const itemValue = valueFromAST(itemNode, itemType, variables);\n if (itemValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValues.push(itemValue);\n }\n }\n return coercedValues;\n }\n const coercedValue = valueFromAST(valueNode, itemType, variables);\n if (coercedValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return [coercedValue];\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n const coercedObj = Object.create(null);\n const fieldNodes = new Map(\n valueNode.fields.map((field) => [field.name.value, field]),\n );\n for (const field of Object.values(type.getFields())) {\n const fieldNode = fieldNodes.get(field.name);\n if (fieldNode == null || isMissingVariable(fieldNode.value, variables)) {\n if (field.defaultValue !== undefined) {\n coercedObj[field.name] = field.defaultValue;\n } else if (isNonNullType(field.type)) {\n return; // Invalid: intentionally return no value.\n }\n continue;\n }\n const fieldValue = valueFromAST(fieldNode.value, field.type, variables);\n if (fieldValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedObj[field.name] = fieldValue;\n }\n\n if (type.isOneOf) {\n const keys = Object.keys(coercedObj);\n if (keys.length !== 1) {\n return; // Invalid: not exactly one key, intentionally return no value.\n }\n\n if (coercedObj[keys[0]] === null) {\n return; // Invalid: value not non-null, intentionally return no value.\n }\n }\n\n return coercedObj;\n }\n\n if (isLeafType(type)) {\n // Scalars and Enums fulfill parsing a literal value via parseLiteral().\n // Invalid values represent a failure to parse correctly, in which case\n // no value is returned.\n let result;\n try {\n result = type.parseLiteral(valueNode, variables);\n } catch (_error) {\n return; // Invalid: intentionally return no value.\n }\n if (result === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return result;\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible input types have been considered.\n invariant(false, 'Unexpected input type: ' + inspect(type));\n}\n\n// Returns true if the provided valueNode is a variable which is not defined\n// in the set of variables.\nfunction isMissingVariable(\n valueNode: ValueNode,\n variables: Maybe>,\n): boolean {\n return (\n valueNode.kind === Kind.VARIABLE &&\n (variables == null || variables[valueNode.name.value] === undefined)\n );\n}\n"]} \ No newline at end of file diff --git a/utilities/valueFromAST.mjs b/utilities/valueFromAST.mjs new file mode 100644 index 0000000000..f480cb44ac --- /dev/null +++ b/utilities/valueFromAST.mjs @@ -0,0 +1,146 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { invariant } from "../jsutils/invariant.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { isInputObjectType, isLeafType, isListType, isNonNullType, } from "../type/definition.mjs"; +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * A GraphQL type must be provided, which will be used to interpret different + * GraphQL Value literals. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + * + * | GraphQL Value | JSON Value | + * | -------------------- | ------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String | String | + * | Int / Float | Number | + * | Enum Value | Unknown | + * | NullValue | null | + * + * @deprecated use `coerceInputLiteral()` instead - will be removed in v18 + */ +export function valueFromAST(valueNode, type, variables) { + if (!valueNode) { + // When there is no node, then there is also no value. + // Importantly, this is different from returning the value null. + return; + } + if (valueNode.kind === Kind.VARIABLE) { + const variableName = valueNode.name.value; + const variableValue = variables?.[variableName]; + if (variableValue === undefined) { + // No valid return value. + return; + } + if (variableValue === null && isNonNullType(type)) { + return; // Invalid: intentionally return no value. + } + // Note: This does no further checking that this variable is correct. + // This assumes that this query has been validated and the variable + // usage here is of the correct type. + return variableValue; + } + if (isNonNullType(type)) { + if (valueNode.kind === Kind.NULL) { + return; // Invalid: intentionally return no value. + } + return valueFromAST(valueNode, type.ofType, variables); + } + if (valueNode.kind === Kind.NULL) { + // This is explicitly returning the value null. + return null; + } + if (isListType(type)) { + const itemType = type.ofType; + if (valueNode.kind === Kind.LIST) { + const coercedValues = []; + for (const itemNode of valueNode.values) { + if (isMissingVariable(itemNode, variables)) { + // If an array contains a missing variable, it is either coerced to + // null or if the item type is non-null, it considered invalid. + if (isNonNullType(itemType)) { + return; // Invalid: intentionally return no value. + } + coercedValues.push(null); + } + else { + const itemValue = valueFromAST(itemNode, itemType, variables); + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + coercedValues.push(itemValue); + } + } + return coercedValues; + } + const coercedValue = valueFromAST(valueNode, itemType, variables); + if (coercedValue === undefined) { + return; // Invalid: intentionally return no value. + } + return [coercedValue]; + } + if (isInputObjectType(type)) { + if (valueNode.kind !== Kind.OBJECT) { + return; // Invalid: intentionally return no value. + } + const coercedObj = Object.create(null); + const fieldNodes = new Map(valueNode.fields.map((field) => [field.name.value, field])); + for (const field of Object.values(type.getFields())) { + const fieldNode = fieldNodes.get(field.name); + if (fieldNode == null || isMissingVariable(fieldNode.value, variables)) { + if (field.defaultValue !== undefined) { + coercedObj[field.name] = field.defaultValue; + } + else if (isNonNullType(field.type)) { + return; // Invalid: intentionally return no value. + } + continue; + } + const fieldValue = valueFromAST(fieldNode.value, field.type, variables); + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + coercedObj[field.name] = fieldValue; + } + if (type.isOneOf) { + const keys = Object.keys(coercedObj); + if (keys.length !== 1) { + return; // Invalid: not exactly one key, intentionally return no value. + } + if (coercedObj[keys[0]] === null) { + return; // Invalid: value not non-null, intentionally return no value. + } + } + return coercedObj; + } + if (isLeafType(type)) { + // Scalars and Enums fulfill parsing a literal value via parseLiteral(). + // Invalid values represent a failure to parse correctly, in which case + // no value is returned. + let result; + try { + result = type.parseLiteral(valueNode, variables); + } + catch (_error) { + return; // Invalid: intentionally return no value. + } + if (result === undefined) { + return; // Invalid: intentionally return no value. + } + return result; + } + /* c8 ignore next 3 */ + // Not reachable, all possible input types have been considered. + (false) || invariant(false, 'Unexpected input type: ' + inspect(type)); +} +// Returns true if the provided valueNode is a variable which is not defined +// in the set of variables. +function isMissingVariable(valueNode, variables) { + return (valueNode.kind === Kind.VARIABLE && + (variables == null || variables[valueNode.name.value] === undefined)); +} +//# sourceMappingURL=valueFromAST.js.map \ No newline at end of file diff --git a/utilities/valueFromAST.mjs.map b/utilities/valueFromAST.mjs.map new file mode 100644 index 0000000000..3df7310993 --- /dev/null +++ b/utilities/valueFromAST.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"valueFromAST.js","sourceRoot":"","sources":["../../src/utilities/valueFromAST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAKpD,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAG5C,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,aAA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AAC;QACX,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,OAAO,CAAC,0CAA0C;QACpD,CAAC;QACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,CAAC,0CAA0C;QACpD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,sBAAsB;IACtB,gEAAgE;IAChE,CAAU,KAAK,KAAf,SAAS,QAAQ,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE;AAC9D,CAAC;AAED,4EAA4E;AAC5E,2BAA2B;AAC3B,SAAS,iBAAiB,CACxB,SAAoB,EACpB,SAAiC;IAEjC,OAAO,CACL,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ;QAChC,CAAC,SAAS,IAAI,IAAI,IAAI,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { invariant } from '../jsutils/invariant.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type { ValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n isInputObjectType,\n isLeafType,\n isListType,\n isNonNullType,\n} from '../type/definition.js';\n\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * GraphQL Value literals.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n *\n * | GraphQL Value | JSON Value |\n * | -------------------- | ------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String | String |\n * | Int / Float | Number |\n * | Enum Value | Unknown |\n * | NullValue | null |\n *\n * @deprecated use `coerceInputLiteral()` instead - will be removed in v18\n */\nexport function valueFromAST(\n valueNode: Maybe,\n type: GraphQLInputType,\n variables?: Maybe>,\n): unknown {\n if (!valueNode) {\n // When there is no node, then there is also no value.\n // Importantly, this is different from returning the value null.\n return;\n }\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n const variableValue = variables?.[variableName];\n if (variableValue === undefined) {\n // No valid return value.\n return;\n }\n if (variableValue === null && isNonNullType(type)) {\n return; // Invalid: intentionally return no value.\n }\n // Note: This does no further checking that this variable is correct.\n // This assumes that this query has been validated and the variable\n // usage here is of the correct type.\n return variableValue;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n return valueFromAST(valueNode, type.ofType, variables);\n }\n\n if (valueNode.kind === Kind.NULL) {\n // This is explicitly returning the value null.\n return null;\n }\n\n if (isListType(type)) {\n const itemType = type.ofType;\n if (valueNode.kind === Kind.LIST) {\n const coercedValues = [];\n for (const itemNode of valueNode.values) {\n if (isMissingVariable(itemNode, variables)) {\n // If an array contains a missing variable, it is either coerced to\n // null or if the item type is non-null, it considered invalid.\n if (isNonNullType(itemType)) {\n return; // Invalid: intentionally return no value.\n }\n coercedValues.push(null);\n } else {\n const itemValue = valueFromAST(itemNode, itemType, variables);\n if (itemValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedValues.push(itemValue);\n }\n }\n return coercedValues;\n }\n const coercedValue = valueFromAST(valueNode, itemType, variables);\n if (coercedValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return [coercedValue];\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n const coercedObj = Object.create(null);\n const fieldNodes = new Map(\n valueNode.fields.map((field) => [field.name.value, field]),\n );\n for (const field of Object.values(type.getFields())) {\n const fieldNode = fieldNodes.get(field.name);\n if (fieldNode == null || isMissingVariable(fieldNode.value, variables)) {\n if (field.defaultValue !== undefined) {\n coercedObj[field.name] = field.defaultValue;\n } else if (isNonNullType(field.type)) {\n return; // Invalid: intentionally return no value.\n }\n continue;\n }\n const fieldValue = valueFromAST(fieldNode.value, field.type, variables);\n if (fieldValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n coercedObj[field.name] = fieldValue;\n }\n\n if (type.isOneOf) {\n const keys = Object.keys(coercedObj);\n if (keys.length !== 1) {\n return; // Invalid: not exactly one key, intentionally return no value.\n }\n\n if (coercedObj[keys[0]] === null) {\n return; // Invalid: value not non-null, intentionally return no value.\n }\n }\n\n return coercedObj;\n }\n\n if (isLeafType(type)) {\n // Scalars and Enums fulfill parsing a literal value via parseLiteral().\n // Invalid values represent a failure to parse correctly, in which case\n // no value is returned.\n let result;\n try {\n result = type.parseLiteral(valueNode, variables);\n } catch (_error) {\n return; // Invalid: intentionally return no value.\n }\n if (result === undefined) {\n return; // Invalid: intentionally return no value.\n }\n return result;\n }\n /* c8 ignore next 3 */\n // Not reachable, all possible input types have been considered.\n invariant(false, 'Unexpected input type: ' + inspect(type));\n}\n\n// Returns true if the provided valueNode is a variable which is not defined\n// in the set of variables.\nfunction isMissingVariable(\n valueNode: ValueNode,\n variables: Maybe>,\n): boolean {\n return (\n valueNode.kind === Kind.VARIABLE &&\n (variables == null || variables[valueNode.name.value] === undefined)\n );\n}\n"]} \ No newline at end of file diff --git a/utilities/valueFromASTUntyped.d.ts b/utilities/valueFromASTUntyped.d.ts new file mode 100644 index 0000000000..5deb013088 --- /dev/null +++ b/utilities/valueFromASTUntyped.d.ts @@ -0,0 +1,20 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { ObjMap } from '../jsutils/ObjMap.js'; +import type { ValueNode } from '../language/ast.js'; +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * No type is provided. The resulting JavaScript value will reflect the + * provided GraphQL value AST. + * + * | GraphQL Value | JavaScript Value | + * | -------------------- | ---------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String / Enum | String | + * | Int / Float | Number | + * | Null | null | + * + */ +export declare function valueFromASTUntyped(valueNode: ValueNode, variables?: Maybe>): unknown; diff --git a/utilities/valueFromASTUntyped.js b/utilities/valueFromASTUntyped.js new file mode 100644 index 0000000000..8639c72b79 --- /dev/null +++ b/utilities/valueFromASTUntyped.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.valueFromASTUntyped = valueFromASTUntyped; +const keyValMap_js_1 = require("../jsutils/keyValMap.js"); +const kinds_js_1 = require("../language/kinds.js"); +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * No type is provided. The resulting JavaScript value will reflect the + * provided GraphQL value AST. + * + * | GraphQL Value | JavaScript Value | + * | -------------------- | ---------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String / Enum | String | + * | Int / Float | Number | + * | Null | null | + * + */ +function valueFromASTUntyped(valueNode, variables) { + switch (valueNode.kind) { + case kinds_js_1.Kind.NULL: + return null; + case kinds_js_1.Kind.INT: + return parseInt(valueNode.value, 10); + case kinds_js_1.Kind.FLOAT: + return parseFloat(valueNode.value); + case kinds_js_1.Kind.STRING: + case kinds_js_1.Kind.ENUM: + case kinds_js_1.Kind.BOOLEAN: + return valueNode.value; + case kinds_js_1.Kind.LIST: + return valueNode.values.map((node) => valueFromASTUntyped(node, variables)); + case kinds_js_1.Kind.OBJECT: + return (0, keyValMap_js_1.keyValMap)(valueNode.fields, (field) => field.name.value, (field) => valueFromASTUntyped(field.value, variables)); + case kinds_js_1.Kind.VARIABLE: + return variables?.[valueNode.name.value]; + } +} +//# sourceMappingURL=valueFromASTUntyped.js.map \ No newline at end of file diff --git a/utilities/valueFromASTUntyped.js.map b/utilities/valueFromASTUntyped.js.map new file mode 100644 index 0000000000..81dc8c30a8 --- /dev/null +++ b/utilities/valueFromASTUntyped.js.map @@ -0,0 +1 @@ +{"version":3,"file":"valueFromASTUntyped.js","sourceRoot":"","sources":["../../src/utilities/valueFromASTUntyped.ts"],"names":[],"mappings":";;AAuBA,kDA4BC;AAnDD,0DAAoD;AAKpD,mDAA4C;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CACjC,SAAoB,EACpB,SAAkC;IAElC,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,eAAI,CAAC,IAAI;YACZ,OAAO,IAAI,CAAC;QACd,KAAK,eAAI,CAAC,GAAG;YACX,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvC,KAAK,eAAI,CAAC,KAAK;YACb,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,eAAI,CAAC,MAAM,CAAC;QACjB,KAAK,eAAI,CAAC,IAAI,CAAC;QACf,KAAK,eAAI,CAAC,OAAO;YACf,OAAO,SAAS,CAAC,KAAK,CAAC;QACzB,KAAK,eAAI,CAAC,IAAI;YACZ,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACnC,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CACrC,CAAC;QACJ,KAAK,eAAI,CAAC,MAAM;YACd,OAAO,IAAA,wBAAS,EACd,SAAS,CAAC,MAAM,EAChB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CACvD,CAAC;QACJ,KAAK,eAAI,CAAC,QAAQ;YAChB,OAAO,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC","sourcesContent":["import { keyValMap } from '../jsutils/keyValMap.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type { ValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * No type is provided. The resulting JavaScript value will reflect the\n * provided GraphQL value AST.\n *\n * | GraphQL Value | JavaScript Value |\n * | -------------------- | ---------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String / Enum | String |\n * | Int / Float | Number |\n * | Null | null |\n *\n */\nexport function valueFromASTUntyped(\n valueNode: ValueNode,\n variables?: Maybe>,\n): unknown {\n switch (valueNode.kind) {\n case Kind.NULL:\n return null;\n case Kind.INT:\n return parseInt(valueNode.value, 10);\n case Kind.FLOAT:\n return parseFloat(valueNode.value);\n case Kind.STRING:\n case Kind.ENUM:\n case Kind.BOOLEAN:\n return valueNode.value;\n case Kind.LIST:\n return valueNode.values.map((node) =>\n valueFromASTUntyped(node, variables),\n );\n case Kind.OBJECT:\n return keyValMap(\n valueNode.fields,\n (field) => field.name.value,\n (field) => valueFromASTUntyped(field.value, variables),\n );\n case Kind.VARIABLE:\n return variables?.[valueNode.name.value];\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/valueFromASTUntyped.mjs b/utilities/valueFromASTUntyped.mjs new file mode 100644 index 0000000000..05c4b574a2 --- /dev/null +++ b/utilities/valueFromASTUntyped.mjs @@ -0,0 +1,39 @@ +import { keyValMap } from "../jsutils/keyValMap.mjs"; +import { Kind } from "../language/kinds.mjs"; +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * No type is provided. The resulting JavaScript value will reflect the + * provided GraphQL value AST. + * + * | GraphQL Value | JavaScript Value | + * | -------------------- | ---------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String / Enum | String | + * | Int / Float | Number | + * | Null | null | + * + */ +export function valueFromASTUntyped(valueNode, variables) { + switch (valueNode.kind) { + case Kind.NULL: + return null; + case Kind.INT: + return parseInt(valueNode.value, 10); + case Kind.FLOAT: + return parseFloat(valueNode.value); + case Kind.STRING: + case Kind.ENUM: + case Kind.BOOLEAN: + return valueNode.value; + case Kind.LIST: + return valueNode.values.map((node) => valueFromASTUntyped(node, variables)); + case Kind.OBJECT: + return keyValMap(valueNode.fields, (field) => field.name.value, (field) => valueFromASTUntyped(field.value, variables)); + case Kind.VARIABLE: + return variables?.[valueNode.name.value]; + } +} +//# sourceMappingURL=valueFromASTUntyped.js.map \ No newline at end of file diff --git a/utilities/valueFromASTUntyped.mjs.map b/utilities/valueFromASTUntyped.mjs.map new file mode 100644 index 0000000000..34a9f0b661 --- /dev/null +++ b/utilities/valueFromASTUntyped.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"valueFromASTUntyped.js","sourceRoot":"","sources":["../../src/utilities/valueFromASTUntyped.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAKpD,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAoB,EACpB,SAAkC;IAElC,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,IAAI,CAAC,IAAI;YACZ,OAAO,IAAI,CAAC;QACd,KAAK,IAAI,CAAC,GAAG;YACX,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvC,KAAK,IAAI,CAAC,KAAK;YACb,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,IAAI,CAAC,MAAM,CAAC;QACjB,KAAK,IAAI,CAAC,IAAI,CAAC;QACf,KAAK,IAAI,CAAC,OAAO;YACf,OAAO,SAAS,CAAC,KAAK,CAAC;QACzB,KAAK,IAAI,CAAC,IAAI;YACZ,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACnC,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CACrC,CAAC;QACJ,KAAK,IAAI,CAAC,MAAM;YACd,OAAO,SAAS,CACd,SAAS,CAAC,MAAM,EAChB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CACvD,CAAC;QACJ,KAAK,IAAI,CAAC,QAAQ;YAChB,OAAO,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC","sourcesContent":["import { keyValMap } from '../jsutils/keyValMap.js';\nimport type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type { ValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * No type is provided. The resulting JavaScript value will reflect the\n * provided GraphQL value AST.\n *\n * | GraphQL Value | JavaScript Value |\n * | -------------------- | ---------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String / Enum | String |\n * | Int / Float | Number |\n * | Null | null |\n *\n */\nexport function valueFromASTUntyped(\n valueNode: ValueNode,\n variables?: Maybe>,\n): unknown {\n switch (valueNode.kind) {\n case Kind.NULL:\n return null;\n case Kind.INT:\n return parseInt(valueNode.value, 10);\n case Kind.FLOAT:\n return parseFloat(valueNode.value);\n case Kind.STRING:\n case Kind.ENUM:\n case Kind.BOOLEAN:\n return valueNode.value;\n case Kind.LIST:\n return valueNode.values.map((node) =>\n valueFromASTUntyped(node, variables),\n );\n case Kind.OBJECT:\n return keyValMap(\n valueNode.fields,\n (field) => field.name.value,\n (field) => valueFromASTUntyped(field.value, variables),\n );\n case Kind.VARIABLE:\n return variables?.[valueNode.name.value];\n }\n}\n"]} \ No newline at end of file diff --git a/utilities/valueToLiteral.d.ts b/utilities/valueToLiteral.d.ts new file mode 100644 index 0000000000..f9154e9cbd --- /dev/null +++ b/utilities/valueToLiteral.d.ts @@ -0,0 +1,30 @@ +import type { ConstValueNode } from '../language/ast.js'; +import type { GraphQLInputType } from '../type/definition.js'; +/** + * Produces a GraphQL Value AST given a JavaScript value and a GraphQL type. + * + * Scalar types are converted by calling the `valueToLiteral` method on that + * type, otherwise the default scalar `valueToLiteral` method is used, defined + * below. + * + * The provided value is an non-coerced "input" value. This function does not + * perform any coercion, however it does perform validation. Provided values + * which are invalid for the given type will result in an `undefined` return + * value. + */ +export declare function valueToLiteral(value: unknown, type: GraphQLInputType): ConstValueNode | undefined; +/** + * The default implementation to convert scalar values to literals. + * + * | JavaScript Value | GraphQL Value | + * | ----------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String | + * | Number | Int / Float | + * | null / undefined | Null | + * + * @internal + */ +export declare function defaultScalarValueToLiteral(value: unknown): ConstValueNode; diff --git a/utilities/valueToLiteral.js b/utilities/valueToLiteral.js new file mode 100644 index 0000000000..616081d491 --- /dev/null +++ b/utilities/valueToLiteral.js @@ -0,0 +1,150 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.valueToLiteral = valueToLiteral; +exports.defaultScalarValueToLiteral = defaultScalarValueToLiteral; +const inspect_js_1 = require("../jsutils/inspect.js"); +const isIterableObject_js_1 = require("../jsutils/isIterableObject.js"); +const isObjectLike_js_1 = require("../jsutils/isObjectLike.js"); +const kinds_js_1 = require("../language/kinds.js"); +const definition_js_1 = require("../type/definition.js"); +/** + * Produces a GraphQL Value AST given a JavaScript value and a GraphQL type. + * + * Scalar types are converted by calling the `valueToLiteral` method on that + * type, otherwise the default scalar `valueToLiteral` method is used, defined + * below. + * + * The provided value is an non-coerced "input" value. This function does not + * perform any coercion, however it does perform validation. Provided values + * which are invalid for the given type will result in an `undefined` return + * value. + */ +function valueToLiteral(value, type) { + if ((0, definition_js_1.isNonNullType)(type)) { + if (value == null) { + return; // Invalid: intentionally return no value. + } + return valueToLiteral(value, type.ofType); + } + // Like JSON, a null literal is produced for both null and undefined. + if (value == null) { + return { kind: kinds_js_1.Kind.NULL }; + } + if ((0, definition_js_1.isListType)(type)) { + if (!(0, isIterableObject_js_1.isIterableObject)(value)) { + return valueToLiteral(value, type.ofType); + } + const values = []; + for (const itemValue of value) { + const itemNode = valueToLiteral(itemValue, type.ofType); + if (!itemNode) { + return; // Invalid: intentionally return no value. + } + values.push(itemNode); + } + return { kind: kinds_js_1.Kind.LIST, values }; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + if (!(0, isObjectLike_js_1.isObjectLike)(value)) { + return; // Invalid: intentionally return no value. + } + const fields = []; + const fieldDefs = type.getFields(); + const hasUndefinedField = Object.keys(value).some((name) => !Object.hasOwn(fieldDefs, name)); + if (hasUndefinedField) { + return; // Invalid: intentionally return no value. + } + for (const field of Object.values(type.getFields())) { + const fieldValue = value[field.name]; + if (fieldValue === undefined) { + if ((0, definition_js_1.isRequiredInputField)(field)) { + return; // Invalid: intentionally return no value. + } + } + else { + const fieldNode = valueToLiteral(value[field.name], field.type); + if (!fieldNode) { + return; // Invalid: intentionally return no value. + } + fields.push({ + kind: kinds_js_1.Kind.OBJECT_FIELD, + name: { kind: kinds_js_1.Kind.NAME, value: field.name }, + value: fieldNode, + }); + } + } + return { kind: kinds_js_1.Kind.OBJECT, fields }; + } + const leafType = (0, definition_js_1.assertLeafType)(type); + if (leafType.valueToLiteral) { + try { + return leafType.valueToLiteral(value); + } + catch (_error) { + return; // Invalid: intentionally ignore error and return no value. + } + } + return defaultScalarValueToLiteral(value); +} +/** + * The default implementation to convert scalar values to literals. + * + * | JavaScript Value | GraphQL Value | + * | ----------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String | + * | Number | Int / Float | + * | null / undefined | Null | + * + * @internal + */ +function defaultScalarValueToLiteral(value) { + // Like JSON, a null literal is produced for both null and undefined. + if (value == null) { + return { kind: kinds_js_1.Kind.NULL }; + } + // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check + switch (typeof value) { + case 'boolean': + return { kind: kinds_js_1.Kind.BOOLEAN, value }; + case 'string': + return { kind: kinds_js_1.Kind.STRING, value, block: false }; + case 'number': { + if (!Number.isFinite(value)) { + // Like JSON, a null literal is produced for non-finite values. + return { kind: kinds_js_1.Kind.NULL }; + } + const stringValue = String(value); + // Will parse as an IntValue. + return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue) + ? { kind: kinds_js_1.Kind.INT, value: stringValue } + : { kind: kinds_js_1.Kind.FLOAT, value: stringValue }; + } + case 'object': { + if ((0, isIterableObject_js_1.isIterableObject)(value)) { + return { + kind: kinds_js_1.Kind.LIST, + values: Array.from(value, defaultScalarValueToLiteral), + }; + } + const objValue = value; + const fields = []; + for (const fieldName of Object.keys(objValue)) { + const fieldValue = objValue[fieldName]; + // Like JSON, undefined fields are not included in the literal result. + if (fieldValue !== undefined) { + fields.push({ + kind: kinds_js_1.Kind.OBJECT_FIELD, + name: { kind: kinds_js_1.Kind.NAME, value: fieldName }, + value: defaultScalarValueToLiteral(fieldValue), + }); + } + } + return { kind: kinds_js_1.Kind.OBJECT, fields }; + } + } + throw new TypeError(`Cannot convert value to AST: ${(0, inspect_js_1.inspect)(value)}.`); +} +//# sourceMappingURL=valueToLiteral.js.map \ No newline at end of file diff --git a/utilities/valueToLiteral.js.map b/utilities/valueToLiteral.js.map new file mode 100644 index 0000000000..6ea6d37816 --- /dev/null +++ b/utilities/valueToLiteral.js.map @@ -0,0 +1 @@ +{"version":3,"file":"valueToLiteral.js","sourceRoot":"","sources":["../../src/utilities/valueToLiteral.ts"],"names":[],"mappings":";;AA4BA,wCA2EC;AAgBD,kEAgDC;AAvKD,sDAAgD;AAChD,wEAAkE;AAClE,gEAA0D;AAG1D,mDAA4C;AAG5C,yDAM+B;AAE/B;;;;;;;;;;;GAWG;AACH,SAAgB,cAAc,CAC5B,KAAc,EACd,IAAsB;IAEtB,IAAI,IAAA,6BAAa,EAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAI,KAAK,IAAI,I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,GAAG,KAAoC,CAAC;YACtD,MAAM,MAAM,GAAgC,EAAE,CAAC;YAC/C,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9C,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACvC,sEAAsE;gBACtE,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;oBAC7B,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,eAAI,CAAC,YAAY;wBACvB,IAAI,EAAE,EAAE,IAAI,EAAE,eAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;wBAC3C,KAAK,EAAE,2BAA2B,CAAC,UAAU,CAAC;qBAC/C,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,eAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAED,MAAM,IAAI,SAAS,CAAC,gCAAgC,IAAA,oBAAO,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\n\nimport type { ConstObjectFieldNode, ConstValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n assertLeafType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isRequiredInputField,\n} from '../type/definition.js';\n\n/**\n * Produces a GraphQL Value AST given a JavaScript value and a GraphQL type.\n *\n * Scalar types are converted by calling the `valueToLiteral` method on that\n * type, otherwise the default scalar `valueToLiteral` method is used, defined\n * below.\n *\n * The provided value is an non-coerced \"input\" value. This function does not\n * perform any coercion, however it does perform validation. Provided values\n * which are invalid for the given type will result in an `undefined` return\n * value.\n */\nexport function valueToLiteral(\n value: unknown,\n type: GraphQLInputType,\n): ConstValueNode | undefined {\n if (isNonNullType(type)) {\n if (value == null) {\n return; // Invalid: intentionally return no value.\n }\n return valueToLiteral(value, type.ofType);\n }\n\n // Like JSON, a null literal is produced for both null and undefined.\n if (value == null) {\n return { kind: Kind.NULL };\n }\n\n if (isListType(type)) {\n if (!isIterableObject(value)) {\n return valueToLiteral(value, type.ofType);\n }\n const values: Array = [];\n for (const itemValue of value) {\n const itemNode = valueToLiteral(itemValue, type.ofType);\n if (!itemNode) {\n return; // Invalid: intentionally return no value.\n }\n values.push(itemNode);\n }\n return { kind: Kind.LIST, values };\n }\n\n if (isInputObjectType(type)) {\n if (!isObjectLike(value)) {\n return; // Invalid: intentionally return no value.\n }\n const fields: Array = [];\n const fieldDefs = type.getFields();\n const hasUndefinedField = Object.keys(value).some(\n (name) => !Object.hasOwn(fieldDefs, name),\n );\n if (hasUndefinedField) {\n return; // Invalid: intentionally return no value.\n }\n for (const field of Object.values(type.getFields())) {\n const fieldValue = value[field.name];\n if (fieldValue === undefined) {\n if (isRequiredInputField(field)) {\n return; // Invalid: intentionally return no value.\n }\n } else {\n const fieldNode = valueToLiteral(value[field.name], field.type);\n if (!fieldNode) {\n return; // Invalid: intentionally return no value.\n }\n fields.push({\n kind: Kind.OBJECT_FIELD,\n name: { kind: Kind.NAME, value: field.name },\n value: fieldNode,\n });\n }\n }\n return { kind: Kind.OBJECT, fields };\n }\n\n const leafType = assertLeafType(type);\n\n if (leafType.valueToLiteral) {\n try {\n return leafType.valueToLiteral(value);\n } catch (_error) {\n return; // Invalid: intentionally ignore error and return no value.\n }\n }\n\n return defaultScalarValueToLiteral(value);\n}\n\n/**\n * The default implementation to convert scalar values to literals.\n *\n * | JavaScript Value | GraphQL Value |\n * | ----------------- | -------------------- |\n * | Object | Input Object |\n * | Array | List |\n * | Boolean | Boolean |\n * | String | String |\n * | Number | Int / Float |\n * | null / undefined | Null |\n *\n * @internal\n */\nexport function defaultScalarValueToLiteral(value: unknown): ConstValueNode {\n // Like JSON, a null literal is produced for both null and undefined.\n if (value == null) {\n return { kind: Kind.NULL };\n }\n\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (typeof value) {\n case 'boolean':\n return { kind: Kind.BOOLEAN, value };\n case 'string':\n return { kind: Kind.STRING, value, block: false };\n case 'number': {\n if (!Number.isFinite(value)) {\n // Like JSON, a null literal is produced for non-finite values.\n return { kind: Kind.NULL };\n }\n const stringValue = String(value);\n // Will parse as an IntValue.\n return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue)\n ? { kind: Kind.INT, value: stringValue }\n : { kind: Kind.FLOAT, value: stringValue };\n }\n case 'object': {\n if (isIterableObject(value)) {\n return {\n kind: Kind.LIST,\n values: Array.from(value, defaultScalarValueToLiteral),\n };\n }\n const objValue = value as { [prop: string]: unknown };\n const fields: Array = [];\n for (const fieldName of Object.keys(objValue)) {\n const fieldValue = objValue[fieldName];\n // Like JSON, undefined fields are not included in the literal result.\n if (fieldValue !== undefined) {\n fields.push({\n kind: Kind.OBJECT_FIELD,\n name: { kind: Kind.NAME, value: fieldName },\n value: defaultScalarValueToLiteral(fieldValue),\n });\n }\n }\n return { kind: Kind.OBJECT, fields };\n }\n }\n\n throw new TypeError(`Cannot convert value to AST: ${inspect(value)}.`);\n}\n"]} \ No newline at end of file diff --git a/utilities/valueToLiteral.mjs b/utilities/valueToLiteral.mjs new file mode 100644 index 0000000000..af0a9ad7bb --- /dev/null +++ b/utilities/valueToLiteral.mjs @@ -0,0 +1,146 @@ +import { inspect } from "../jsutils/inspect.mjs"; +import { isIterableObject } from "../jsutils/isIterableObject.mjs"; +import { isObjectLike } from "../jsutils/isObjectLike.mjs"; +import { Kind } from "../language/kinds.mjs"; +import { assertLeafType, isInputObjectType, isListType, isNonNullType, isRequiredInputField, } from "../type/definition.mjs"; +/** + * Produces a GraphQL Value AST given a JavaScript value and a GraphQL type. + * + * Scalar types are converted by calling the `valueToLiteral` method on that + * type, otherwise the default scalar `valueToLiteral` method is used, defined + * below. + * + * The provided value is an non-coerced "input" value. This function does not + * perform any coercion, however it does perform validation. Provided values + * which are invalid for the given type will result in an `undefined` return + * value. + */ +export function valueToLiteral(value, type) { + if (isNonNullType(type)) { + if (value == null) { + return; // Invalid: intentionally return no value. + } + return valueToLiteral(value, type.ofType); + } + // Like JSON, a null literal is produced for both null and undefined. + if (value == null) { + return { kind: Kind.NULL }; + } + if (isListType(type)) { + if (!isIterableObject(value)) { + return valueToLiteral(value, type.ofType); + } + const values = []; + for (const itemValue of value) { + const itemNode = valueToLiteral(itemValue, type.ofType); + if (!itemNode) { + return; // Invalid: intentionally return no value. + } + values.push(itemNode); + } + return { kind: Kind.LIST, values }; + } + if (isInputObjectType(type)) { + if (!isObjectLike(value)) { + return; // Invalid: intentionally return no value. + } + const fields = []; + const fieldDefs = type.getFields(); + const hasUndefinedField = Object.keys(value).some((name) => !Object.hasOwn(fieldDefs, name)); + if (hasUndefinedField) { + return; // Invalid: intentionally return no value. + } + for (const field of Object.values(type.getFields())) { + const fieldValue = value[field.name]; + if (fieldValue === undefined) { + if (isRequiredInputField(field)) { + return; // Invalid: intentionally return no value. + } + } + else { + const fieldNode = valueToLiteral(value[field.name], field.type); + if (!fieldNode) { + return; // Invalid: intentionally return no value. + } + fields.push({ + kind: Kind.OBJECT_FIELD, + name: { kind: Kind.NAME, value: field.name }, + value: fieldNode, + }); + } + } + return { kind: Kind.OBJECT, fields }; + } + const leafType = assertLeafType(type); + if (leafType.valueToLiteral) { + try { + return leafType.valueToLiteral(value); + } + catch (_error) { + return; // Invalid: intentionally ignore error and return no value. + } + } + return defaultScalarValueToLiteral(value); +} +/** + * The default implementation to convert scalar values to literals. + * + * | JavaScript Value | GraphQL Value | + * | ----------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String | + * | Number | Int / Float | + * | null / undefined | Null | + * + * @internal + */ +export function defaultScalarValueToLiteral(value) { + // Like JSON, a null literal is produced for both null and undefined. + if (value == null) { + return { kind: Kind.NULL }; + } + // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check + switch (typeof value) { + case 'boolean': + return { kind: Kind.BOOLEAN, value }; + case 'string': + return { kind: Kind.STRING, value, block: false }; + case 'number': { + if (!Number.isFinite(value)) { + // Like JSON, a null literal is produced for non-finite values. + return { kind: Kind.NULL }; + } + const stringValue = String(value); + // Will parse as an IntValue. + return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue) + ? { kind: Kind.INT, value: stringValue } + : { kind: Kind.FLOAT, value: stringValue }; + } + case 'object': { + if (isIterableObject(value)) { + return { + kind: Kind.LIST, + values: Array.from(value, defaultScalarValueToLiteral), + }; + } + const objValue = value; + const fields = []; + for (const fieldName of Object.keys(objValue)) { + const fieldValue = objValue[fieldName]; + // Like JSON, undefined fields are not included in the literal result. + if (fieldValue !== undefined) { + fields.push({ + kind: Kind.OBJECT_FIELD, + name: { kind: Kind.NAME, value: fieldName }, + value: defaultScalarValueToLiteral(fieldValue), + }); + } + } + return { kind: Kind.OBJECT, fields }; + } + } + throw new TypeError(`Cannot convert value to AST: ${inspect(value)}.`); +} +//# sourceMappingURL=valueToLiteral.js.map \ No newline at end of file diff --git a/utilities/valueToLiteral.mjs.map b/utilities/valueToLiteral.mjs.map new file mode 100644 index 0000000000..48e6504110 --- /dev/null +++ b/utilities/valueToLiteral.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"valueToLiteral.js","sourceRoot":"","sources":["../../src/utilities/valueToLiteral.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,gBAAgB,EAAE,wCAAuC;AAClE,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAG1D,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAG5C,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,oBAAoB,GACrB,+BAA8B;AAE/B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAc,EACd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;iBACvD,CAAC;YACJ,CAAC;YACD,MAAM,QAAQ,GAAG,KAAoC,CAAC;YACtD,MAAM,MAAM,GAAgC,EAAE,CAAC;YAC/C,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9C,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACvC,sEAAsE;gBACtE,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;oBAC7B,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,IAAI,CAAC,YAAY;wBACvB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;wBAC3C,KAAK,EAAE,2BAA2B,CAAC,UAAU,CAAC;qBAC/C,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAED,MAAM,IAAI,SAAS,CAAC,gCAAgC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { inspect } from '../jsutils/inspect.js';\nimport { isIterableObject } from '../jsutils/isIterableObject.js';\nimport { isObjectLike } from '../jsutils/isObjectLike.js';\n\nimport type { ConstObjectFieldNode, ConstValueNode } from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\n\nimport type { GraphQLInputType } from '../type/definition.js';\nimport {\n assertLeafType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isRequiredInputField,\n} from '../type/definition.js';\n\n/**\n * Produces a GraphQL Value AST given a JavaScript value and a GraphQL type.\n *\n * Scalar types are converted by calling the `valueToLiteral` method on that\n * type, otherwise the default scalar `valueToLiteral` method is used, defined\n * below.\n *\n * The provided value is an non-coerced \"input\" value. This function does not\n * perform any coercion, however it does perform validation. Provided values\n * which are invalid for the given type will result in an `undefined` return\n * value.\n */\nexport function valueToLiteral(\n value: unknown,\n type: GraphQLInputType,\n): ConstValueNode | undefined {\n if (isNonNullType(type)) {\n if (value == null) {\n return; // Invalid: intentionally return no value.\n }\n return valueToLiteral(value, type.ofType);\n }\n\n // Like JSON, a null literal is produced for both null and undefined.\n if (value == null) {\n return { kind: Kind.NULL };\n }\n\n if (isListType(type)) {\n if (!isIterableObject(value)) {\n return valueToLiteral(value, type.ofType);\n }\n const values: Array = [];\n for (const itemValue of value) {\n const itemNode = valueToLiteral(itemValue, type.ofType);\n if (!itemNode) {\n return; // Invalid: intentionally return no value.\n }\n values.push(itemNode);\n }\n return { kind: Kind.LIST, values };\n }\n\n if (isInputObjectType(type)) {\n if (!isObjectLike(value)) {\n return; // Invalid: intentionally return no value.\n }\n const fields: Array = [];\n const fieldDefs = type.getFields();\n const hasUndefinedField = Object.keys(value).some(\n (name) => !Object.hasOwn(fieldDefs, name),\n );\n if (hasUndefinedField) {\n return; // Invalid: intentionally return no value.\n }\n for (const field of Object.values(type.getFields())) {\n const fieldValue = value[field.name];\n if (fieldValue === undefined) {\n if (isRequiredInputField(field)) {\n return; // Invalid: intentionally return no value.\n }\n } else {\n const fieldNode = valueToLiteral(value[field.name], field.type);\n if (!fieldNode) {\n return; // Invalid: intentionally return no value.\n }\n fields.push({\n kind: Kind.OBJECT_FIELD,\n name: { kind: Kind.NAME, value: field.name },\n value: fieldNode,\n });\n }\n }\n return { kind: Kind.OBJECT, fields };\n }\n\n const leafType = assertLeafType(type);\n\n if (leafType.valueToLiteral) {\n try {\n return leafType.valueToLiteral(value);\n } catch (_error) {\n return; // Invalid: intentionally ignore error and return no value.\n }\n }\n\n return defaultScalarValueToLiteral(value);\n}\n\n/**\n * The default implementation to convert scalar values to literals.\n *\n * | JavaScript Value | GraphQL Value |\n * | ----------------- | -------------------- |\n * | Object | Input Object |\n * | Array | List |\n * | Boolean | Boolean |\n * | String | String |\n * | Number | Int / Float |\n * | null / undefined | Null |\n *\n * @internal\n */\nexport function defaultScalarValueToLiteral(value: unknown): ConstValueNode {\n // Like JSON, a null literal is produced for both null and undefined.\n if (value == null) {\n return { kind: Kind.NULL };\n }\n\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (typeof value) {\n case 'boolean':\n return { kind: Kind.BOOLEAN, value };\n case 'string':\n return { kind: Kind.STRING, value, block: false };\n case 'number': {\n if (!Number.isFinite(value)) {\n // Like JSON, a null literal is produced for non-finite values.\n return { kind: Kind.NULL };\n }\n const stringValue = String(value);\n // Will parse as an IntValue.\n return /^-?(?:0|[1-9][0-9]*)$/.test(stringValue)\n ? { kind: Kind.INT, value: stringValue }\n : { kind: Kind.FLOAT, value: stringValue };\n }\n case 'object': {\n if (isIterableObject(value)) {\n return {\n kind: Kind.LIST,\n values: Array.from(value, defaultScalarValueToLiteral),\n };\n }\n const objValue = value as { [prop: string]: unknown };\n const fields: Array = [];\n for (const fieldName of Object.keys(objValue)) {\n const fieldValue = objValue[fieldName];\n // Like JSON, undefined fields are not included in the literal result.\n if (fieldValue !== undefined) {\n fields.push({\n kind: Kind.OBJECT_FIELD,\n name: { kind: Kind.NAME, value: fieldName },\n value: defaultScalarValueToLiteral(fieldValue),\n });\n }\n }\n return { kind: Kind.OBJECT, fields };\n }\n }\n\n throw new TypeError(`Cannot convert value to AST: ${inspect(value)}.`);\n}\n"]} \ No newline at end of file diff --git a/validation/ValidationContext.d.ts b/validation/ValidationContext.d.ts new file mode 100644 index 0000000000..86412823a8 --- /dev/null +++ b/validation/ValidationContext.d.ts @@ -0,0 +1,70 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import type { GraphQLError } from '../error/GraphQLError.js'; +import type { DocumentNode, FragmentDefinitionNode, FragmentSpreadNode, OperationDefinitionNode, SelectionSetNode, VariableDefinitionNode, VariableNode } from '../language/ast.js'; +import type { ASTVisitor } from '../language/visitor.js'; +import type { GraphQLArgument, GraphQLCompositeType, GraphQLEnumValue, GraphQLField, GraphQLInputType, GraphQLOutputType } from '../type/definition.js'; +import type { GraphQLDirective } from '../type/directives.js'; +import type { GraphQLSchema } from '../type/schema.js'; +import type { FragmentSignature } from '../utilities/TypeInfo.js'; +import { TypeInfo } from '../utilities/TypeInfo.js'; +type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode; +interface VariableUsage { + readonly node: VariableNode; + readonly type: Maybe; + readonly parentType: Maybe; + readonly defaultValue: unknown; + readonly fragmentVariableDefinition: Maybe; +} +/** + * An instance of this class is passed as the "this" context to all validators, + * allowing access to commonly useful contextual information from within a + * validation rule. + */ +export declare class ASTValidationContext { + private _ast; + private _onError; + private _fragments; + private _fragmentSpreads; + private _recursivelyReferencedFragments; + constructor(ast: DocumentNode, onError: (error: GraphQLError) => void); + get [Symbol.toStringTag](): string; + reportError(error: GraphQLError): void; + getDocument(): DocumentNode; + getFragment(name: string): Maybe; + getFragmentSpreads(node: SelectionSetNode): ReadonlyArray; + getRecursivelyReferencedFragments(operation: OperationDefinitionNode): ReadonlyArray; +} +export type ASTValidationRule = (context: ASTValidationContext) => ASTVisitor; +export declare class SDLValidationContext extends ASTValidationContext { + private _schema; + constructor(ast: DocumentNode, schema: Maybe, onError: (error: GraphQLError) => void); + get hideSuggestions(): boolean; + get [Symbol.toStringTag](): string; + getSchema(): Maybe; +} +export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor; +export declare class ValidationContext extends ASTValidationContext { + private _schema; + private _typeInfo; + private _variableUsages; + private _recursiveVariableUsages; + private _hideSuggestions; + constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo, onError: (error: GraphQLError) => void, hideSuggestions?: Maybe); + get [Symbol.toStringTag](): string; + get hideSuggestions(): boolean; + getSchema(): GraphQLSchema; + getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray; + getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray; + getType(): Maybe; + getParentType(): Maybe; + getInputType(): Maybe; + getParentInputType(): Maybe; + getFieldDef(): Maybe>; + getDirective(): Maybe; + getArgument(): Maybe; + getFragmentSignature(): Maybe; + getFragmentSignatureByName(): (fragmentName: string) => Maybe; + getEnumValue(): Maybe; +} +export type ValidationRule = (context: ValidationContext) => ASTVisitor; +export {}; diff --git a/validation/ValidationContext.js b/validation/ValidationContext.js new file mode 100644 index 0000000000..4b6897b684 --- /dev/null +++ b/validation/ValidationContext.js @@ -0,0 +1,206 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ValidationContext = exports.SDLValidationContext = exports.ASTValidationContext = void 0; +const kinds_js_1 = require("../language/kinds.js"); +const visitor_js_1 = require("../language/visitor.js"); +const TypeInfo_js_1 = require("../utilities/TypeInfo.js"); +/** + * An instance of this class is passed as the "this" context to all validators, + * allowing access to commonly useful contextual information from within a + * validation rule. + */ +class ASTValidationContext { + constructor(ast, onError) { + this._ast = ast; + this._fragments = undefined; + this._fragmentSpreads = new Map(); + this._recursivelyReferencedFragments = new Map(); + this._onError = onError; + } + get [Symbol.toStringTag]() { + return 'ASTValidationContext'; + } + reportError(error) { + this._onError(error); + } + getDocument() { + return this._ast; + } + getFragment(name) { + let fragments; + if (this._fragments) { + fragments = this._fragments; + } + else { + fragments = Object.create(null); + for (const defNode of this.getDocument().definitions) { + if (defNode.kind === kinds_js_1.Kind.FRAGMENT_DEFINITION) { + fragments[defNode.name.value] = defNode; + } + } + this._fragments = fragments; + } + return fragments[name]; + } + getFragmentSpreads(node) { + let spreads = this._fragmentSpreads.get(node); + if (!spreads) { + spreads = []; + const setsToVisit = [node]; + let set; + while ((set = setsToVisit.pop())) { + for (const selection of set.selections) { + if (selection.kind === kinds_js_1.Kind.FRAGMENT_SPREAD) { + spreads.push(selection); + } + else if (selection.selectionSet) { + setsToVisit.push(selection.selectionSet); + } + } + } + this._fragmentSpreads.set(node, spreads); + } + return spreads; + } + getRecursivelyReferencedFragments(operation) { + let fragments = this._recursivelyReferencedFragments.get(operation); + if (!fragments) { + fragments = []; + const collectedNames = new Set(); + const nodesToVisit = [operation.selectionSet]; + let node; + while ((node = nodesToVisit.pop())) { + for (const spread of this.getFragmentSpreads(node)) { + const fragName = spread.name.value; + if (!collectedNames.has(fragName)) { + collectedNames.add(fragName); + const fragment = this.getFragment(fragName); + if (fragment) { + fragments.push(fragment); + nodesToVisit.push(fragment.selectionSet); + } + } + } + } + this._recursivelyReferencedFragments.set(operation, fragments); + } + return fragments; + } +} +exports.ASTValidationContext = ASTValidationContext; +class SDLValidationContext extends ASTValidationContext { + constructor(ast, schema, onError) { + super(ast, onError); + this._schema = schema; + } + get hideSuggestions() { + return false; + } + get [Symbol.toStringTag]() { + return 'SDLValidationContext'; + } + getSchema() { + return this._schema; + } +} +exports.SDLValidationContext = SDLValidationContext; +class ValidationContext extends ASTValidationContext { + constructor(schema, ast, typeInfo, onError, hideSuggestions) { + super(ast, onError); + this._schema = schema; + this._typeInfo = typeInfo; + this._variableUsages = new Map(); + this._recursiveVariableUsages = new Map(); + this._hideSuggestions = hideSuggestions ?? false; + } + get [Symbol.toStringTag]() { + return 'ValidationContext'; + } + get hideSuggestions() { + return this._hideSuggestions; + } + getSchema() { + return this._schema; + } + getVariableUsages(node) { + let usages = this._variableUsages.get(node); + if (!usages) { + const newUsages = []; + const typeInfo = new TypeInfo_js_1.TypeInfo(this._schema, undefined, this._typeInfo.getFragmentSignatureByName()); + const fragmentDefinition = node.kind === kinds_js_1.Kind.FRAGMENT_DEFINITION ? node : undefined; + (0, visitor_js_1.visit)(node, (0, TypeInfo_js_1.visitWithTypeInfo)(typeInfo, { + VariableDefinition: () => false, + Variable(variable) { + let fragmentVariableDefinition; + if (fragmentDefinition) { + const fragmentSignature = typeInfo.getFragmentSignatureByName()(fragmentDefinition.name.value); + fragmentVariableDefinition = + fragmentSignature?.variableDefinitions.get(variable.name.value); + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + parentType: typeInfo.getParentInputType(), + defaultValue: undefined, // fragment variables have a variable default but no location default, which is what this default value represents + fragmentVariableDefinition, + }); + } + else { + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + parentType: typeInfo.getParentInputType(), + defaultValue: typeInfo.getDefaultValue(), + fragmentVariableDefinition: undefined, + }); + } + }, + })); + usages = newUsages; + this._variableUsages.set(node, usages); + } + return usages; + } + getRecursiveVariableUsages(operation) { + let usages = this._recursiveVariableUsages.get(operation); + if (!usages) { + usages = this.getVariableUsages(operation); + for (const frag of this.getRecursivelyReferencedFragments(operation)) { + usages = usages.concat(this.getVariableUsages(frag)); + } + this._recursiveVariableUsages.set(operation, usages); + } + return usages; + } + getType() { + return this._typeInfo.getType(); + } + getParentType() { + return this._typeInfo.getParentType(); + } + getInputType() { + return this._typeInfo.getInputType(); + } + getParentInputType() { + return this._typeInfo.getParentInputType(); + } + getFieldDef() { + return this._typeInfo.getFieldDef(); + } + getDirective() { + return this._typeInfo.getDirective(); + } + getArgument() { + return this._typeInfo.getArgument(); + } + getFragmentSignature() { + return this._typeInfo.getFragmentSignature(); + } + getFragmentSignatureByName() { + return this._typeInfo.getFragmentSignatureByName(); + } + getEnumValue() { + return this._typeInfo.getEnumValue(); + } +} +exports.ValidationContext = ValidationContext; +//# sourceMappingURL=ValidationContext.js.map \ No newline at end of file diff --git a/validation/ValidationContext.js.map b/validation/ValidationContext.js.map new file mode 100644 index 0000000000..f32cdfbc48 --- /dev/null +++ b/validation/ValidationContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ValidationContext.js","sourceRoot":"","sources":["../../src/validation/ValidationContext.ts"],"names":[],"mappings":";;;AAcA,mDAA4C;AAE5C,uDAA+C;AAc/C,0DAAuE;AAWvE;;;;GAIG;AACH,MAAa,oBAAoB;IAU/B,YAAY,GAAiB,EAAE,OAAsC;QACnE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,+BAA+B,GAAG,IAAI,GAAG,EAAE,CAAC;QACjD,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,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,oBAAoB,EAAE,CAAC;IAC/C,CAAC;IAED,0BAA0B;QAGxB,OAAO,IAAI,CAAC,SAAS,CAAC,0BAA0B,EAAE,CAAC;IACrD,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;CACF;AAjJD,8CAiJC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n DocumentNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n OperationDefinitionNode,\n SelectionSetNode,\n VariableDefinitionNode,\n VariableNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport type { ASTVisitor } from '../language/visitor.js';\nimport { visit } from '../language/visitor.js';\n\nimport type {\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLEnumValue,\n GraphQLField,\n GraphQLInputType,\n GraphQLOutputType,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport type { FragmentSignature } from '../utilities/TypeInfo.js';\nimport { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo.js';\n\ntype NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;\ninterface VariableUsage {\n readonly node: VariableNode;\n readonly type: Maybe;\n readonly parentType: Maybe;\n readonly defaultValue: unknown;\n readonly fragmentVariableDefinition: Maybe;\n}\n\n/**\n * An instance of this class is passed as the \"this\" context to all validators,\n * allowing access to commonly useful contextual information from within a\n * validation rule.\n */\nexport class ASTValidationContext {\n private _ast: DocumentNode;\n private _onError: (error: GraphQLError) => void;\n private _fragments: ObjMap | undefined;\n private _fragmentSpreads: Map>;\n private _recursivelyReferencedFragments: Map<\n OperationDefinitionNode,\n Array\n >;\n\n constructor(ast: DocumentNode, onError: (error: GraphQLError) => void) {\n this._ast = ast;\n this._fragments = undefined;\n this._fragmentSpreads = new Map();\n this._recursivelyReferencedFragments = new Map();\n this._onError = onError;\n }\n\n get [Symbol.toStringTag]() {\n return 'ASTValidationContext';\n }\n\n reportError(error: GraphQLError): void {\n this._onError(error);\n }\n\n getDocument(): DocumentNode {\n return this._ast;\n }\n\n getFragment(name: string): Maybe {\n let fragments: ObjMap;\n if (this._fragments) {\n fragments = this._fragments;\n } else {\n fragments = Object.create(null);\n for (const defNode of this.getDocument().definitions) {\n if (defNode.kind === Kind.FRAGMENT_DEFINITION) {\n fragments[defNode.name.value] = defNode;\n }\n }\n this._fragments = fragments;\n }\n return fragments[name];\n }\n\n getFragmentSpreads(\n node: SelectionSetNode,\n ): ReadonlyArray {\n let spreads = this._fragmentSpreads.get(node);\n if (!spreads) {\n spreads = [];\n const setsToVisit: Array = [node];\n let set: SelectionSetNode | undefined;\n while ((set = setsToVisit.pop())) {\n for (const selection of set.selections) {\n if (selection.kind === Kind.FRAGMENT_SPREAD) {\n spreads.push(selection);\n } else if (selection.selectionSet) {\n setsToVisit.push(selection.selectionSet);\n }\n }\n }\n this._fragmentSpreads.set(node, spreads);\n }\n return spreads;\n }\n\n getRecursivelyReferencedFragments(\n operation: OperationDefinitionNode,\n ): ReadonlyArray {\n let fragments = this._recursivelyReferencedFragments.get(operation);\n if (!fragments) {\n fragments = [];\n const collectedNames = new Set();\n const nodesToVisit: Array = [operation.selectionSet];\n let node: SelectionSetNode | undefined;\n while ((node = nodesToVisit.pop())) {\n for (const spread of this.getFragmentSpreads(node)) {\n const fragName = spread.name.value;\n if (!collectedNames.has(fragName)) {\n collectedNames.add(fragName);\n const fragment = this.getFragment(fragName);\n if (fragment) {\n fragments.push(fragment);\n nodesToVisit.push(fragment.selectionSet);\n }\n }\n }\n }\n this._recursivelyReferencedFragments.set(operation, fragments);\n }\n return fragments;\n }\n}\n\nexport type ASTValidationRule = (context: ASTValidationContext) => ASTVisitor;\n\nexport class SDLValidationContext extends ASTValidationContext {\n private _schema: Maybe;\n\n constructor(\n ast: DocumentNode,\n schema: Maybe,\n onError: (error: GraphQLError) => void,\n ) {\n super(ast, onError);\n this._schema = schema;\n }\n\n get hideSuggestions() {\n return false;\n }\n\n override get [Symbol.toStringTag]() {\n return 'SDLValidationContext';\n }\n\n getSchema(): Maybe {\n return this._schema;\n }\n}\n\nexport type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;\n\nexport class ValidationContext extends ASTValidationContext {\n private _schema: GraphQLSchema;\n private _typeInfo: TypeInfo;\n private _variableUsages: Map<\n NodeWithSelectionSet,\n ReadonlyArray\n >;\n\n private _recursiveVariableUsages: Map<\n OperationDefinitionNode,\n ReadonlyArray\n >;\n private _hideSuggestions: boolean;\n\n constructor(\n schema: GraphQLSchema,\n ast: DocumentNode,\n typeInfo: TypeInfo,\n onError: (error: GraphQLError) => void,\n hideSuggestions?: Maybe,\n ) {\n super(ast, onError);\n this._schema = schema;\n this._typeInfo = typeInfo;\n this._variableUsages = new Map();\n this._recursiveVariableUsages = new Map();\n this._hideSuggestions = hideSuggestions ?? false;\n }\n\n override get [Symbol.toStringTag]() {\n return 'ValidationContext';\n }\n\n get hideSuggestions() {\n return this._hideSuggestions;\n }\n\n getSchema(): GraphQLSchema {\n return this._schema;\n }\n\n getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray {\n let usages = this._variableUsages.get(node);\n if (!usages) {\n const newUsages: Array = [];\n const typeInfo = new TypeInfo(\n this._schema,\n undefined,\n this._typeInfo.getFragmentSignatureByName(),\n );\n const fragmentDefinition =\n node.kind === Kind.FRAGMENT_DEFINITION ? node : undefined;\n visit(\n node,\n visitWithTypeInfo(typeInfo, {\n VariableDefinition: () => false,\n Variable(variable) {\n let fragmentVariableDefinition;\n if (fragmentDefinition) {\n const fragmentSignature = typeInfo.getFragmentSignatureByName()(\n fragmentDefinition.name.value,\n );\n\n fragmentVariableDefinition =\n fragmentSignature?.variableDefinitions.get(variable.name.value);\n newUsages.push({\n node: variable,\n type: typeInfo.getInputType(),\n parentType: typeInfo.getParentInputType(),\n defaultValue: undefined, // fragment variables have a variable default but no location default, which is what this default value represents\n fragmentVariableDefinition,\n });\n } else {\n newUsages.push({\n node: variable,\n type: typeInfo.getInputType(),\n parentType: typeInfo.getParentInputType(),\n defaultValue: typeInfo.getDefaultValue(),\n fragmentVariableDefinition: undefined,\n });\n }\n },\n }),\n );\n usages = newUsages;\n this._variableUsages.set(node, usages);\n }\n return usages;\n }\n\n getRecursiveVariableUsages(\n operation: OperationDefinitionNode,\n ): ReadonlyArray {\n let usages = this._recursiveVariableUsages.get(operation);\n if (!usages) {\n usages = this.getVariableUsages(operation);\n for (const frag of this.getRecursivelyReferencedFragments(operation)) {\n usages = usages.concat(this.getVariableUsages(frag));\n }\n this._recursiveVariableUsages.set(operation, usages);\n }\n return usages;\n }\n\n getType(): Maybe {\n return this._typeInfo.getType();\n }\n\n getParentType(): Maybe {\n return this._typeInfo.getParentType();\n }\n\n getInputType(): Maybe {\n return this._typeInfo.getInputType();\n }\n\n getParentInputType(): Maybe {\n return this._typeInfo.getParentInputType();\n }\n\n getFieldDef(): Maybe> {\n return this._typeInfo.getFieldDef();\n }\n\n getDirective(): Maybe {\n return this._typeInfo.getDirective();\n }\n\n getArgument(): Maybe {\n return this._typeInfo.getArgument();\n }\n\n getFragmentSignature(): Maybe {\n return this._typeInfo.getFragmentSignature();\n }\n\n getFragmentSignatureByName(): (\n fragmentName: string,\n ) => Maybe {\n return this._typeInfo.getFragmentSignatureByName();\n }\n\n getEnumValue(): Maybe {\n return this._typeInfo.getEnumValue();\n }\n}\n\nexport type ValidationRule = (context: ValidationContext) => ASTVisitor;\n"]} \ No newline at end of file diff --git a/validation/ValidationContext.mjs b/validation/ValidationContext.mjs new file mode 100644 index 0000000000..4b72b927cb --- /dev/null +++ b/validation/ValidationContext.mjs @@ -0,0 +1,200 @@ +import { Kind } from "../language/kinds.mjs"; +import { visit } from "../language/visitor.mjs"; +import { TypeInfo, visitWithTypeInfo } from "../utilities/TypeInfo.mjs"; +/** + * An instance of this class is passed as the "this" context to all validators, + * allowing access to commonly useful contextual information from within a + * validation rule. + */ +export class ASTValidationContext { + constructor(ast, onError) { + this._ast = ast; + this._fragments = undefined; + this._fragmentSpreads = new Map(); + this._recursivelyReferencedFragments = new Map(); + this._onError = onError; + } + get [Symbol.toStringTag]() { + return 'ASTValidationContext'; + } + reportError(error) { + this._onError(error); + } + getDocument() { + return this._ast; + } + getFragment(name) { + let fragments; + if (this._fragments) { + fragments = this._fragments; + } + else { + fragments = Object.create(null); + for (const defNode of this.getDocument().definitions) { + if (defNode.kind === Kind.FRAGMENT_DEFINITION) { + fragments[defNode.name.value] = defNode; + } + } + this._fragments = fragments; + } + return fragments[name]; + } + getFragmentSpreads(node) { + let spreads = this._fragmentSpreads.get(node); + if (!spreads) { + spreads = []; + const setsToVisit = [node]; + let set; + while ((set = setsToVisit.pop())) { + for (const selection of set.selections) { + if (selection.kind === Kind.FRAGMENT_SPREAD) { + spreads.push(selection); + } + else if (selection.selectionSet) { + setsToVisit.push(selection.selectionSet); + } + } + } + this._fragmentSpreads.set(node, spreads); + } + return spreads; + } + getRecursivelyReferencedFragments(operation) { + let fragments = this._recursivelyReferencedFragments.get(operation); + if (!fragments) { + fragments = []; + const collectedNames = new Set(); + const nodesToVisit = [operation.selectionSet]; + let node; + while ((node = nodesToVisit.pop())) { + for (const spread of this.getFragmentSpreads(node)) { + const fragName = spread.name.value; + if (!collectedNames.has(fragName)) { + collectedNames.add(fragName); + const fragment = this.getFragment(fragName); + if (fragment) { + fragments.push(fragment); + nodesToVisit.push(fragment.selectionSet); + } + } + } + } + this._recursivelyReferencedFragments.set(operation, fragments); + } + return fragments; + } +} +export class SDLValidationContext extends ASTValidationContext { + constructor(ast, schema, onError) { + super(ast, onError); + this._schema = schema; + } + get hideSuggestions() { + return false; + } + get [Symbol.toStringTag]() { + return 'SDLValidationContext'; + } + getSchema() { + return this._schema; + } +} +export class ValidationContext extends ASTValidationContext { + constructor(schema, ast, typeInfo, onError, hideSuggestions) { + super(ast, onError); + this._schema = schema; + this._typeInfo = typeInfo; + this._variableUsages = new Map(); + this._recursiveVariableUsages = new Map(); + this._hideSuggestions = hideSuggestions ?? false; + } + get [Symbol.toStringTag]() { + return 'ValidationContext'; + } + get hideSuggestions() { + return this._hideSuggestions; + } + getSchema() { + return this._schema; + } + getVariableUsages(node) { + let usages = this._variableUsages.get(node); + if (!usages) { + const newUsages = []; + const typeInfo = new TypeInfo(this._schema, undefined, this._typeInfo.getFragmentSignatureByName()); + const fragmentDefinition = node.kind === Kind.FRAGMENT_DEFINITION ? node : undefined; + visit(node, visitWithTypeInfo(typeInfo, { + VariableDefinition: () => false, + Variable(variable) { + let fragmentVariableDefinition; + if (fragmentDefinition) { + const fragmentSignature = typeInfo.getFragmentSignatureByName()(fragmentDefinition.name.value); + fragmentVariableDefinition = + fragmentSignature?.variableDefinitions.get(variable.name.value); + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + parentType: typeInfo.getParentInputType(), + defaultValue: undefined, // fragment variables have a variable default but no location default, which is what this default value represents + fragmentVariableDefinition, + }); + } + else { + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + parentType: typeInfo.getParentInputType(), + defaultValue: typeInfo.getDefaultValue(), + fragmentVariableDefinition: undefined, + }); + } + }, + })); + usages = newUsages; + this._variableUsages.set(node, usages); + } + return usages; + } + getRecursiveVariableUsages(operation) { + let usages = this._recursiveVariableUsages.get(operation); + if (!usages) { + usages = this.getVariableUsages(operation); + for (const frag of this.getRecursivelyReferencedFragments(operation)) { + usages = usages.concat(this.getVariableUsages(frag)); + } + this._recursiveVariableUsages.set(operation, usages); + } + return usages; + } + getType() { + return this._typeInfo.getType(); + } + getParentType() { + return this._typeInfo.getParentType(); + } + getInputType() { + return this._typeInfo.getInputType(); + } + getParentInputType() { + return this._typeInfo.getParentInputType(); + } + getFieldDef() { + return this._typeInfo.getFieldDef(); + } + getDirective() { + return this._typeInfo.getDirective(); + } + getArgument() { + return this._typeInfo.getArgument(); + } + getFragmentSignature() { + return this._typeInfo.getFragmentSignature(); + } + getFragmentSignatureByName() { + return this._typeInfo.getFragmentSignatureByName(); + } + getEnumValue() { + return this._typeInfo.getEnumValue(); + } +} +//# sourceMappingURL=ValidationContext.js.map \ No newline at end of file diff --git a/validation/ValidationContext.mjs.map b/validation/ValidationContext.mjs.map new file mode 100644 index 0000000000..2790efbf62 --- /dev/null +++ b/validation/ValidationContext.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ValidationContext.js","sourceRoot":"","sources":["../../src/validation/ValidationContext.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C,OAAO,EAAE,KAAK,EAAE,gCAA+B;AAc/C,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kCAAiC;AAWvE;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAU/B,YAAY,GAAiB,EAAE,OAAsC;QACnE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,+BAA+B,GAAG,IAAI,GAAG,EAAE,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,sBAAsB,CAAC;IAChC,CAAC;IAED,WAAW,CAAC,KAAmB;QAC7B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,WA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ACV,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;CACF","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\nimport type { ObjMap } from '../jsutils/ObjMap.js';\n\nimport type { GraphQLError } from '../error/GraphQLError.js';\n\nimport type {\n DocumentNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n OperationDefinitionNode,\n SelectionSetNode,\n VariableDefinitionNode,\n VariableNode,\n} from '../language/ast.js';\nimport { Kind } from '../language/kinds.js';\nimport type { ASTVisitor } from '../language/visitor.js';\nimport { visit } from '../language/visitor.js';\n\nimport type {\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLEnumValue,\n GraphQLField,\n GraphQLInputType,\n GraphQLOutputType,\n} from '../type/definition.js';\nimport type { GraphQLDirective } from '../type/directives.js';\nimport type { GraphQLSchema } from '../type/schema.js';\n\nimport type { FragmentSignature } from '../utilities/TypeInfo.js';\nimport { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo.js';\n\ntype NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;\ninterface VariableUsage {\n readonly node: VariableNode;\n readonly type: Maybe;\n readonly parentType: Maybe;\n readonly defaultValue: unknown;\n readonly fragmentVariableDefinition: Maybe;\n}\n\n/**\n * An instance of this class is passed as the \"this\" context to all validators,\n * allowing access to commonly useful contextual information from within a\n * validation rule.\n */\nexport class ASTValidationContext {\n private _ast: DocumentNode;\n private _onError: (error: GraphQLError) => void;\n private _fragments: ObjMap | undefined;\n private _fragmentSpreads: Map>;\n private _recursivelyReferencedFragments: Map<\n OperationDefinitionNode,\n Array\n >;\n\n constructor(ast: DocumentNode, onError: (error: GraphQLError) => void) {\n this._ast = ast;\n this._fragments = undefined;\n this._fragmentSpreads = new Map();\n this._recursivelyReferencedFragments = new Map();\n this._onError = onError;\n }\n\n get [Symbol.toStringTag]() {\n return 'ASTValidationContext';\n }\n\n reportError(error: GraphQLError): void {\n this._onError(error);\n }\n\n getDocument(): DocumentNode {\n return this._ast;\n }\n\n getFragment(name: string): Maybe {\n let fragments: ObjMap;\n if (this._fragments) {\n fragments = this._fragments;\n } else {\n fragments = Object.create(null);\n for (const defNode of this.getDocument().definitions) {\n if (defNode.kind === Kind.FRAGMENT_DEFINITION) {\n fragments[defNode.name.value] = defNode;\n }\n }\n this._fragments = fragments;\n }\n return fragments[name];\n }\n\n getFragmentSpreads(\n node: SelectionSetNode,\n ): ReadonlyArray {\n let spreads = this._fragmentSpreads.get(node);\n if (!spreads) {\n spreads = [];\n const setsToVisit: Array = [node];\n let set: SelectionSetNode | undefined;\n while ((set = setsToVisit.pop())) {\n for (const selection of set.selections) {\n if (selection.kind === Kind.FRAGMENT_SPREAD) {\n spreads.push(selection);\n } else if (selection.selectionSet) {\n setsToVisit.push(selection.selectionSet);\n }\n }\n }\n this._fragmentSpreads.set(node, spreads);\n }\n return spreads;\n }\n\n getRecursivelyReferencedFragments(\n operation: OperationDefinitionNode,\n ): ReadonlyArray {\n let fragments = this._recursivelyReferencedFragments.get(operation);\n if (!fragments) {\n fragments = [];\n const collectedNames = new Set();\n const nodesToVisit: Array = [operation.selectionSet];\n let node: SelectionSetNode | undefined;\n while ((node = nodesToVisit.pop())) {\n for (const spread of this.getFragmentSpreads(node)) {\n const fragName = spread.name.value;\n if (!collectedNames.has(fragName)) {\n collectedNames.add(fragName);\n const fragment = this.getFragment(fragName);\n if (fragment) {\n fragments.push(fragment);\n nodesToVisit.push(fragment.selectionSet);\n }\n }\n }\n }\n this._recursivelyReferencedFragments.set(operation, fragments);\n }\n return fragments;\n }\n}\n\nexport type ASTValidationRule = (context: ASTValidationContext) => ASTVisitor;\n\nexport class SDLValidationContext extends ASTValidationContext {\n private _schema: Maybe;\n\n constructor(\n ast: DocumentNode,\n schema: Maybe,\n onError: (error: GraphQLError) => void,\n ) {\n super(ast, onError);\n this._schema = schema;\n }\n\n get hideSuggestions() {\n return false;\n }\n\n override get [Symbol.toStringTag]() {\n return 'SDLValidationContext';\n }\n\n getSchema(): Maybe {\n return this._schema;\n }\n}\n\nexport type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;\n\nexport class ValidationContext extends ASTValidationContext {\n private _schema: GraphQLSchema;\n private _typeInfo: TypeInfo;\n private _variableUsages: Map<\n NodeWithSelectionSet,\n ReadonlyArray\n >;\n\n private _recursiveVariableUsages: Map<\n OperationDefinitionNode,\n ReadonlyArray\n >;\n private _hideSuggestions: boolean;\n\n constructor(\n schema: GraphQLSchema,\n ast: DocumentNode,\n typeInfo: TypeInfo,\n onError: (error: GraphQLError) => void,\n hideSuggestions?: Maybe,\n ) {\n super(ast, onError);\n this._schema = schema;\n this._typeInfo = typeInfo;\n this._variableUsages = new Map();\n this._recursiveVariableUsages = new Map();\n this._hideSuggestions = hideSuggestions ?? false;\n }\n\n override get [Symbol.toStringTag]() {\n return 'ValidationContext';\n }\n\n get hideSuggestions() {\n return this._hideSuggestions;\n }\n\n getSchema(): GraphQLSchema {\n return this._schema;\n }\n\n getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray {\n let usages = this._variableUsages.get(node);\n if (!usages) {\n const newUsages: Array = [];\n const typeInfo = new TypeInfo(\n this._schema,\n undefined,\n this._typeInfo.getFragmentSignatureByName(),\n );\n const fragmentDefinition =\n node.kind === Kind.FRAGMENT_DEFINITION ? node : undefined;\n visit(\n node,\n visitWithTypeInfo(typeInfo, {\n VariableDefinition: () => false,\n Variable(variable) {\n let fragmentVariableDefinition;\n if (fragmentDefinition) {\n const fragmentSignature = typeInfo.getFragmentSignatureByName()(\n fragmentDefinition.name.value,\n );\n\n fragmentVariableDefinition =\n fragmentSignature?.variableDefinitions.get(variable.name.value);\n newUsages.push({\n node: variable,\n type: typeInfo.getInputType(),\n parentType: typeInfo.getParentInputType(),\n defaultValue: undefined, // fragment variables have a variable default but no location default, which is what this default value represents\n fragmentVariableDefinition,\n });\n } else {\n newUsages.push({\n node: variable,\n type: typeInfo.getInputType(),\n parentType: typeInfo.getParentInputType(),\n defaultValue: typeInfo.getDefaultValue(),\n fragmentVariableDefinition: undefined,\n });\n }\n },\n }),\n );\n usages = newUsages;\n this._variableUsages.set(node, usages);\n }\n return usages;\n }\n\n getRecursiveVariableUsages(\n operation: OperationDefinitionNode,\n ): ReadonlyArray {\n let usages = this._recursiveVariableUsages.get(operation);\n if (!usages) {\n usages = this.getVariableUsages(operation);\n for (const frag of this.getRecursivelyReferencedFragments(operation)) {\n usages = usages.concat(this.getVariableUsages(frag));\n }\n this._recursiveVariableUsages.set(operation, usages);\n }\n return usages;\n }\n\n getType(): Maybe {\n return this._typeInfo.getType();\n }\n\n getParentType(): Maybe {\n return this._typeInfo.getParentType();\n }\n\n getInputType(): Maybe {\n return this._typeInfo.getInputType();\n }\n\n getParentInputType(): Maybe {\n return this._typeInfo.getParentInputType();\n }\n\n getFieldDef(): Maybe> {\n return this._typeInfo.getFieldDef();\n }\n\n getDirective(): Maybe {\n return this._typeInfo.getDirective();\n }\n\n getArgument(): Maybe {\n return this._typeInfo.getArgument();\n }\n\n getFragmentSignature(): Maybe {\n return this._typeInfo.getFragmentSignature();\n }\n\n getFragmentSignatureByName(): (\n fragmentName: string,\n ) => Maybe {\n return this._typeInfo.getFragmentSignatureByName();\n }\n\n getEnumValue(): Maybe {\n return this._typeInfo.getEnumValue();\n }\n}\n\nexport type ValidationRule = (context: ValidationContext) => ASTVisitor;\n"]} \ No newline at end of file diff --git a/validation/index.d.ts b/validation/index.d.ts new file mode 100644 index 0000000000..b87660f85a --- /dev/null +++ b/validation/index.d.ts @@ -0,0 +1,46 @@ +export { validate } from './validate.js'; +export { ValidationContext } from './ValidationContext.js'; +export type { ValidationRule } from './ValidationContext.js'; +export { specifiedRules, recommendedRules } from './specifiedRules.js'; +export { DeferStreamDirectiveLabelRule } from './rules/DeferStreamDirectiveLabelRule.js'; +export { DeferStreamDirectiveOnRootFieldRule } from './rules/DeferStreamDirectiveOnRootFieldRule.js'; +export { DeferStreamDirectiveOnValidOperationsRule } from './rules/DeferStreamDirectiveOnValidOperationsRule.js'; +export { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule.js'; +export { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule.js'; +export { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule.js'; +export { KnownArgumentNamesRule } from './rules/KnownArgumentNamesRule.js'; +export { KnownDirectivesRule } from './rules/KnownDirectivesRule.js'; +export { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule.js'; +export { KnownOperationTypesRule } from './rules/KnownOperationTypesRule.js'; +export { KnownTypeNamesRule } from './rules/KnownTypeNamesRule.js'; +export { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule.js'; +export { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule.js'; +export { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule.js'; +export { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule.js'; +export { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule.js'; +export { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule.js'; +export { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule.js'; +export { ProvidedRequiredArgumentsRule } from './rules/ProvidedRequiredArgumentsRule.js'; +export { ScalarLeafsRule } from './rules/ScalarLeafsRule.js'; +export { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule.js'; +export { StreamDirectiveOnListFieldRule } from './rules/StreamDirectiveOnListFieldRule.js'; +export { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule.js'; +export { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule.js'; +export { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule.js'; +export { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule.js'; +export { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule.js'; +export { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule.js'; +export { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule.js'; +export { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule.js'; +export { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule.js'; +export { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule.js'; +export { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule.js'; +export { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule.js'; +export { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule.js'; +export { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule.js'; +export { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule.js'; +export { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule.js'; +export { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule.js'; +export { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule.js'; +export { NoDeprecatedCustomRule } from './rules/custom/NoDeprecatedCustomRule.js'; +export { NoSchemaIntrospectionCustomRule } from './rules/custom/NoSchemaIntrospectionCustomRule.js'; diff --git a/validation/index.js b/validation/index.js new file mode 100644 index 0000000000..29a8f80988 --- /dev/null +++ b/validation/index.js @@ -0,0 +1,129 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NoSchemaIntrospectionCustomRule = exports.NoDeprecatedCustomRule = exports.PossibleTypeExtensionsRule = exports.UniqueDirectiveNamesRule = exports.UniqueArgumentDefinitionNamesRule = exports.UniqueFieldDefinitionNamesRule = exports.UniqueEnumValueNamesRule = exports.UniqueTypeNamesRule = exports.UniqueOperationTypesRule = exports.LoneSchemaDefinitionRule = exports.MaxIntrospectionDepthRule = exports.VariablesInAllowedPositionRule = exports.VariablesAreInputTypesRule = exports.ValuesOfCorrectTypeRule = exports.UniqueVariableNamesRule = exports.UniqueOperationNamesRule = exports.UniqueInputFieldNamesRule = exports.UniqueFragmentNamesRule = exports.UniqueDirectivesPerLocationRule = exports.UniqueArgumentNamesRule = exports.StreamDirectiveOnListFieldRule = exports.SingleFieldSubscriptionsRule = exports.ScalarLeafsRule = exports.ProvidedRequiredArgumentsRule = exports.PossibleFragmentSpreadsRule = exports.OverlappingFieldsCanBeMergedRule = exports.NoUnusedVariablesRule = exports.NoUnusedFragmentsRule = exports.NoUndefinedVariablesRule = exports.NoFragmentCyclesRule = exports.LoneAnonymousOperationRule = exports.KnownTypeNamesRule = exports.KnownOperationTypesRule = exports.KnownFragmentNamesRule = exports.KnownDirectivesRule = exports.KnownArgumentNamesRule = exports.FragmentsOnCompositeTypesRule = exports.FieldsOnCorrectTypeRule = exports.ExecutableDefinitionsRule = exports.DeferStreamDirectiveOnValidOperationsRule = exports.DeferStreamDirectiveOnRootFieldRule = exports.DeferStreamDirectiveLabelRule = exports.recommendedRules = exports.specifiedRules = exports.ValidationContext = exports.validate = void 0; +var validate_js_1 = require("./validate.js"); +Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_js_1.validate; } }); +var ValidationContext_js_1 = require("./ValidationContext.js"); +Object.defineProperty(exports, "ValidationContext", { enumerable: true, get: function () { return ValidationContext_js_1.ValidationContext; } }); +// All validation rules in the GraphQL Specification. +var specifiedRules_js_1 = require("./specifiedRules.js"); +Object.defineProperty(exports, "specifiedRules", { enumerable: true, get: function () { return specifiedRules_js_1.specifiedRules; } }); +Object.defineProperty(exports, "recommendedRules", { enumerable: true, get: function () { return specifiedRules_js_1.recommendedRules; } }); +// Spec Section: "Defer And Stream Directive Labels Are Unique" +var DeferStreamDirectiveLabelRule_js_1 = require("./rules/DeferStreamDirectiveLabelRule.js"); +Object.defineProperty(exports, "DeferStreamDirectiveLabelRule", { enumerable: true, get: function () { return DeferStreamDirectiveLabelRule_js_1.DeferStreamDirectiveLabelRule; } }); +// Spec Section: "Defer And Stream Directives Are Used On Valid Root Field" +var DeferStreamDirectiveOnRootFieldRule_js_1 = require("./rules/DeferStreamDirectiveOnRootFieldRule.js"); +Object.defineProperty(exports, "DeferStreamDirectiveOnRootFieldRule", { enumerable: true, get: function () { return DeferStreamDirectiveOnRootFieldRule_js_1.DeferStreamDirectiveOnRootFieldRule; } }); +// Spec Section: "Defer And Stream Directives Are Used On Valid Operations" +var DeferStreamDirectiveOnValidOperationsRule_js_1 = require("./rules/DeferStreamDirectiveOnValidOperationsRule.js"); +Object.defineProperty(exports, "DeferStreamDirectiveOnValidOperationsRule", { enumerable: true, get: function () { return DeferStreamDirectiveOnValidOperationsRule_js_1.DeferStreamDirectiveOnValidOperationsRule; } }); +// Spec Section: "Executable Definitions" +var ExecutableDefinitionsRule_js_1 = require("./rules/ExecutableDefinitionsRule.js"); +Object.defineProperty(exports, "ExecutableDefinitionsRule", { enumerable: true, get: function () { return ExecutableDefinitionsRule_js_1.ExecutableDefinitionsRule; } }); +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +var FieldsOnCorrectTypeRule_js_1 = require("./rules/FieldsOnCorrectTypeRule.js"); +Object.defineProperty(exports, "FieldsOnCorrectTypeRule", { enumerable: true, get: function () { return FieldsOnCorrectTypeRule_js_1.FieldsOnCorrectTypeRule; } }); +// Spec Section: "Fragments on Composite Types" +var FragmentsOnCompositeTypesRule_js_1 = require("./rules/FragmentsOnCompositeTypesRule.js"); +Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", { enumerable: true, get: function () { return FragmentsOnCompositeTypesRule_js_1.FragmentsOnCompositeTypesRule; } }); +// Spec Section: "Argument Names" +var KnownArgumentNamesRule_js_1 = require("./rules/KnownArgumentNamesRule.js"); +Object.defineProperty(exports, "KnownArgumentNamesRule", { enumerable: true, get: function () { return KnownArgumentNamesRule_js_1.KnownArgumentNamesRule; } }); +// Spec Section: "Directives Are Defined" +var KnownDirectivesRule_js_1 = require("./rules/KnownDirectivesRule.js"); +Object.defineProperty(exports, "KnownDirectivesRule", { enumerable: true, get: function () { return KnownDirectivesRule_js_1.KnownDirectivesRule; } }); +// Spec Section: "Fragment spread target defined" +var KnownFragmentNamesRule_js_1 = require("./rules/KnownFragmentNamesRule.js"); +Object.defineProperty(exports, "KnownFragmentNamesRule", { enumerable: true, get: function () { return KnownFragmentNamesRule_js_1.KnownFragmentNamesRule; } }); +// Spec Section: "Operation Type Existence" +var KnownOperationTypesRule_js_1 = require("./rules/KnownOperationTypesRule.js"); +Object.defineProperty(exports, "KnownOperationTypesRule", { enumerable: true, get: function () { return KnownOperationTypesRule_js_1.KnownOperationTypesRule; } }); +// Spec Section: "Fragment Spread Type Existence" +var KnownTypeNamesRule_js_1 = require("./rules/KnownTypeNamesRule.js"); +Object.defineProperty(exports, "KnownTypeNamesRule", { enumerable: true, get: function () { return KnownTypeNamesRule_js_1.KnownTypeNamesRule; } }); +// Spec Section: "Lone Anonymous Operation" +var LoneAnonymousOperationRule_js_1 = require("./rules/LoneAnonymousOperationRule.js"); +Object.defineProperty(exports, "LoneAnonymousOperationRule", { enumerable: true, get: function () { return LoneAnonymousOperationRule_js_1.LoneAnonymousOperationRule; } }); +// Spec Section: "Fragments must not form cycles" +var NoFragmentCyclesRule_js_1 = require("./rules/NoFragmentCyclesRule.js"); +Object.defineProperty(exports, "NoFragmentCyclesRule", { enumerable: true, get: function () { return NoFragmentCyclesRule_js_1.NoFragmentCyclesRule; } }); +// Spec Section: "All Variable Used Defined" +var NoUndefinedVariablesRule_js_1 = require("./rules/NoUndefinedVariablesRule.js"); +Object.defineProperty(exports, "NoUndefinedVariablesRule", { enumerable: true, get: function () { return NoUndefinedVariablesRule_js_1.NoUndefinedVariablesRule; } }); +// Spec Section: "Fragments must be used" +var NoUnusedFragmentsRule_js_1 = require("./rules/NoUnusedFragmentsRule.js"); +Object.defineProperty(exports, "NoUnusedFragmentsRule", { enumerable: true, get: function () { return NoUnusedFragmentsRule_js_1.NoUnusedFragmentsRule; } }); +// Spec Section: "All Variables Used" +var NoUnusedVariablesRule_js_1 = require("./rules/NoUnusedVariablesRule.js"); +Object.defineProperty(exports, "NoUnusedVariablesRule", { enumerable: true, get: function () { return NoUnusedVariablesRule_js_1.NoUnusedVariablesRule; } }); +// Spec Section: "Field Selection Merging" +var OverlappingFieldsCanBeMergedRule_js_1 = require("./rules/OverlappingFieldsCanBeMergedRule.js"); +Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", { enumerable: true, get: function () { return OverlappingFieldsCanBeMergedRule_js_1.OverlappingFieldsCanBeMergedRule; } }); +// Spec Section: "Fragment spread is possible" +var PossibleFragmentSpreadsRule_js_1 = require("./rules/PossibleFragmentSpreadsRule.js"); +Object.defineProperty(exports, "PossibleFragmentSpreadsRule", { enumerable: true, get: function () { return PossibleFragmentSpreadsRule_js_1.PossibleFragmentSpreadsRule; } }); +// Spec Section: "Argument Optionality" +var ProvidedRequiredArgumentsRule_js_1 = require("./rules/ProvidedRequiredArgumentsRule.js"); +Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", { enumerable: true, get: function () { return ProvidedRequiredArgumentsRule_js_1.ProvidedRequiredArgumentsRule; } }); +// Spec Section: "Leaf Field Selections" +var ScalarLeafsRule_js_1 = require("./rules/ScalarLeafsRule.js"); +Object.defineProperty(exports, "ScalarLeafsRule", { enumerable: true, get: function () { return ScalarLeafsRule_js_1.ScalarLeafsRule; } }); +// Spec Section: "Subscriptions with Single Root Field" +var SingleFieldSubscriptionsRule_js_1 = require("./rules/SingleFieldSubscriptionsRule.js"); +Object.defineProperty(exports, "SingleFieldSubscriptionsRule", { enumerable: true, get: function () { return SingleFieldSubscriptionsRule_js_1.SingleFieldSubscriptionsRule; } }); +// Spec Section: "Stream Directives Are Used On List Fields" +var StreamDirectiveOnListFieldRule_js_1 = require("./rules/StreamDirectiveOnListFieldRule.js"); +Object.defineProperty(exports, "StreamDirectiveOnListFieldRule", { enumerable: true, get: function () { return StreamDirectiveOnListFieldRule_js_1.StreamDirectiveOnListFieldRule; } }); +// Spec Section: "Argument Uniqueness" +var UniqueArgumentNamesRule_js_1 = require("./rules/UniqueArgumentNamesRule.js"); +Object.defineProperty(exports, "UniqueArgumentNamesRule", { enumerable: true, get: function () { return UniqueArgumentNamesRule_js_1.UniqueArgumentNamesRule; } }); +// Spec Section: "Directives Are Unique Per Location" +var UniqueDirectivesPerLocationRule_js_1 = require("./rules/UniqueDirectivesPerLocationRule.js"); +Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", { enumerable: true, get: function () { return UniqueDirectivesPerLocationRule_js_1.UniqueDirectivesPerLocationRule; } }); +// Spec Section: "Fragment Name Uniqueness" +var UniqueFragmentNamesRule_js_1 = require("./rules/UniqueFragmentNamesRule.js"); +Object.defineProperty(exports, "UniqueFragmentNamesRule", { enumerable: true, get: function () { return UniqueFragmentNamesRule_js_1.UniqueFragmentNamesRule; } }); +// Spec Section: "Input Object Field Uniqueness" +var UniqueInputFieldNamesRule_js_1 = require("./rules/UniqueInputFieldNamesRule.js"); +Object.defineProperty(exports, "UniqueInputFieldNamesRule", { enumerable: true, get: function () { return UniqueInputFieldNamesRule_js_1.UniqueInputFieldNamesRule; } }); +// Spec Section: "Operation Name Uniqueness" +var UniqueOperationNamesRule_js_1 = require("./rules/UniqueOperationNamesRule.js"); +Object.defineProperty(exports, "UniqueOperationNamesRule", { enumerable: true, get: function () { return UniqueOperationNamesRule_js_1.UniqueOperationNamesRule; } }); +// Spec Section: "Variable Uniqueness" +var UniqueVariableNamesRule_js_1 = require("./rules/UniqueVariableNamesRule.js"); +Object.defineProperty(exports, "UniqueVariableNamesRule", { enumerable: true, get: function () { return UniqueVariableNamesRule_js_1.UniqueVariableNamesRule; } }); +// Spec Section: "Values Type Correctness" +var ValuesOfCorrectTypeRule_js_1 = require("./rules/ValuesOfCorrectTypeRule.js"); +Object.defineProperty(exports, "ValuesOfCorrectTypeRule", { enumerable: true, get: function () { return ValuesOfCorrectTypeRule_js_1.ValuesOfCorrectTypeRule; } }); +// Spec Section: "Variables are Input Types" +var VariablesAreInputTypesRule_js_1 = require("./rules/VariablesAreInputTypesRule.js"); +Object.defineProperty(exports, "VariablesAreInputTypesRule", { enumerable: true, get: function () { return VariablesAreInputTypesRule_js_1.VariablesAreInputTypesRule; } }); +// Spec Section: "All Variable Usages Are Allowed" +var VariablesInAllowedPositionRule_js_1 = require("./rules/VariablesInAllowedPositionRule.js"); +Object.defineProperty(exports, "VariablesInAllowedPositionRule", { enumerable: true, get: function () { return VariablesInAllowedPositionRule_js_1.VariablesInAllowedPositionRule; } }); +var MaxIntrospectionDepthRule_js_1 = require("./rules/MaxIntrospectionDepthRule.js"); +Object.defineProperty(exports, "MaxIntrospectionDepthRule", { enumerable: true, get: function () { return MaxIntrospectionDepthRule_js_1.MaxIntrospectionDepthRule; } }); +// SDL-specific validation rules +var LoneSchemaDefinitionRule_js_1 = require("./rules/LoneSchemaDefinitionRule.js"); +Object.defineProperty(exports, "LoneSchemaDefinitionRule", { enumerable: true, get: function () { return LoneSchemaDefinitionRule_js_1.LoneSchemaDefinitionRule; } }); +var UniqueOperationTypesRule_js_1 = require("./rules/UniqueOperationTypesRule.js"); +Object.defineProperty(exports, "UniqueOperationTypesRule", { enumerable: true, get: function () { return UniqueOperationTypesRule_js_1.UniqueOperationTypesRule; } }); +var UniqueTypeNamesRule_js_1 = require("./rules/UniqueTypeNamesRule.js"); +Object.defineProperty(exports, "UniqueTypeNamesRule", { enumerable: true, get: function () { return UniqueTypeNamesRule_js_1.UniqueTypeNamesRule; } }); +var UniqueEnumValueNamesRule_js_1 = require("./rules/UniqueEnumValueNamesRule.js"); +Object.defineProperty(exports, "UniqueEnumValueNamesRule", { enumerable: true, get: function () { return UniqueEnumValueNamesRule_js_1.UniqueEnumValueNamesRule; } }); +var UniqueFieldDefinitionNamesRule_js_1 = require("./rules/UniqueFieldDefinitionNamesRule.js"); +Object.defineProperty(exports, "UniqueFieldDefinitionNamesRule", { enumerable: true, get: function () { return UniqueFieldDefinitionNamesRule_js_1.UniqueFieldDefinitionNamesRule; } }); +var UniqueArgumentDefinitionNamesRule_js_1 = require("./rules/UniqueArgumentDefinitionNamesRule.js"); +Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", { enumerable: true, get: function () { return UniqueArgumentDefinitionNamesRule_js_1.UniqueArgumentDefinitionNamesRule; } }); +var UniqueDirectiveNamesRule_js_1 = require("./rules/UniqueDirectiveNamesRule.js"); +Object.defineProperty(exports, "UniqueDirectiveNamesRule", { enumerable: true, get: function () { return UniqueDirectiveNamesRule_js_1.UniqueDirectiveNamesRule; } }); +var PossibleTypeExtensionsRule_js_1 = require("./rules/PossibleTypeExtensionsRule.js"); +Object.defineProperty(exports, "PossibleTypeExtensionsRule", { enumerable: true, get: function () { return PossibleTypeExtensionsRule_js_1.PossibleTypeExtensionsRule; } }); +// Optional rules not defined by the GraphQL Specification +var NoDeprecatedCustomRule_js_1 = require("./rules/custom/NoDeprecatedCustomRule.js"); +Object.defineProperty(exports, "NoDeprecatedCustomRule", { enumerable: true, get: function () { return NoDeprecatedCustomRule_js_1.NoDeprecatedCustomRule; } }); +var NoSchemaIntrospectionCustomRule_js_1 = require("./rules/custom/NoSchemaIntrospectionCustomRule.js"); +Object.defineProperty(exports, "NoSchemaIntrospectionCustomRule", { enumerable: true, get: function () { return NoSchemaIntrospectionCustomRule_js_1.NoSchemaIntrospectionCustomRule; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/validation/index.js.map b/validation/index.js.map new file mode 100644 index 0000000000..38e381bd69 --- /dev/null +++ b/validation/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AAEjB,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAG1B,qDAAqD;AACrD,yDAAuE;AAA9D,mHAAA,cAAc,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAEzC,+DAA+D;AAC/D,6FAAyF;AAAhF,iJAAA,6BAA6B,OAAA;AAEtC,2EAA2E;AAC3E,yGAAqG;AAA5F,6JAAA,mCAAmC,OAAA;AAE5C,2EA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,qDAAqD;AACrD,iGAA6F;AAApF,qJAAA,+BAA+B,OAAA;AAExC,2CAA2C;AAC3C,iFAA6E;AAApE,qIAAA,uBAAuB,OAAA;AAEhC,gDAAgD;AAChD,qFAAiF;AAAxE,yIAAA,yBAAyB,OAAA;AAElC,4CAA4C;AAC5C,mFAA+E;AAAtE,uIAAA,wBAAwB,OAAA;AAEjC,sCAAsC;AACtC,iFAA6E;AAApE,qIAAA,uBAAuB,OAAA;AAEhC,0CAA0C;AAC1C,iFAA6E;AAApE,qIAAA,uBAAuB,OAAA;AAEhC,4CAA4C;AAC5C,uFAAmF;AAA1E,2IAAA,0BAA0B,OAAA;AAEnC,kDAAkD;AAClD,+FAA2F;AAAlF,mJAAA,8BAA8B,OAAA;AAEvC,qFAAiF;AAAxE,yIAAA,yBAAyB,OAAA;AAElC,gCAAgC;AAChC,mFAA+E;AAAtE,uIAAA,wBAAwB,OAAA;AACjC,mFAA+E;AAAtE,uIAAA,wBAAwB,OAAA;AACjC,yEAAqE;AAA5D,6HAAA,mBAAmB,OAAA;AAC5B,mFAA+E;AAAtE,uIAAA,wBAAwB,OAAA;AACjC,+FAA2F;AAAlF,mJAAA,8BAA8B,OAAA;AACvC,qGAAiG;AAAxF,yJAAA,iCAAiC,OAAA;AAC1C,mFAA+E;AAAtE,uIAAA,wBAAwB,OAAA;AACjC,uFAAmF;AAA1E,2IAAA,0BAA0B,OAAA;AAEnC,0DAA0D;AAC1D,sFAAkF;AAAzE,mIAAA,sBAAsB,OAAA;AAC/B,wGAAoG;AAA3F,qJAAA,+BAA+B,OAAA","sourcesContent":["export { validate } from './validate.js';\n\nexport { ValidationContext } from './ValidationContext.js';\nexport type { ValidationRule } from './ValidationContext.js';\n\n// All validation rules in the GraphQL Specification.\nexport { specifiedRules, recommendedRules } from './specifiedRules.js';\n\n// Spec Section: \"Defer And Stream Directive Labels Are Unique\"\nexport { DeferStreamDirectiveLabelRule } from './rules/DeferStreamDirectiveLabelRule.js';\n\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Root Field\"\nexport { DeferStreamDirectiveOnRootFieldRule } from './rules/DeferStreamDirectiveOnRootFieldRule.js';\n\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Operations\"\nexport { DeferStreamDirectiveOnValidOperationsRule } from './rules/DeferStreamDirectiveOnValidOperationsRule.js';\n\n// Spec Section: \"Executable Definitions\"\nexport { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule.js';\n\n// Spec Section: \"Field Selections on Objects, Interfaces, and Unions Types\"\nexport { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule.js';\n\n// Spec Section: \"Fragments on Composite Types\"\nexport { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule.js';\n\n// Spec Section: \"Argument Names\"\nexport { KnownArgumentNamesRule } from './rules/KnownArgumentNamesRule.js';\n\n// Spec Section: \"Directives Are Defined\"\nexport { KnownDirectivesRule } from './rules/KnownDirectivesRule.js';\n\n// Spec Section: \"Fragment spread target defined\"\nexport { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule.js';\n\n// Spec Section: \"Operation Type Existence\"\nexport { KnownOperationTypesRule } from './rules/KnownOperationTypesRule.js';\n\n// Spec Section: \"Fragment Spread Type Existence\"\nexport { KnownTypeNamesRule } from './rules/KnownTypeNamesRule.js';\n\n// Spec Section: \"Lone Anonymous Operation\"\nexport { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule.js';\n\n// Spec Section: \"Fragments must not form cycles\"\nexport { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule.js';\n\n// Spec Section: \"All Variable Used Defined\"\nexport { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule.js';\n\n// Spec Section: \"Fragments must be used\"\nexport { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule.js';\n\n// Spec Section: \"All Variables Used\"\nexport { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule.js';\n\n// Spec Section: \"Field Selection Merging\"\nexport { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule.js';\n\n// Spec Section: \"Fragment spread is possible\"\nexport { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule.js';\n\n// Spec Section: \"Argument Optionality\"\nexport { ProvidedRequiredArgumentsRule } from './rules/ProvidedRequiredArgumentsRule.js';\n\n// Spec Section: \"Leaf Field Selections\"\nexport { ScalarLeafsRule } from './rules/ScalarLeafsRule.js';\n\n// Spec Section: \"Subscriptions with Single Root Field\"\nexport { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule.js';\n\n// Spec Section: \"Stream Directives Are Used On List Fields\"\nexport { StreamDirectiveOnListFieldRule } from './rules/StreamDirectiveOnListFieldRule.js';\n\n// Spec Section: \"Argument Uniqueness\"\nexport { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule.js';\n\n// Spec Section: \"Directives Are Unique Per Location\"\nexport { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule.js';\n\n// Spec Section: \"Fragment Name Uniqueness\"\nexport { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule.js';\n\n// Spec Section: \"Input Object Field Uniqueness\"\nexport { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule.js';\n\n// Spec Section: \"Operation Name Uniqueness\"\nexport { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule.js';\n\n// Spec Section: \"Variable Uniqueness\"\nexport { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule.js';\n\n// Spec Section: \"Values Type Correctness\"\nexport { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule.js';\n\n// Spec Section: \"Variables are Input Types\"\nexport { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule.js';\n\n// Spec Section: \"All Variable Usages Are Allowed\"\nexport { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule.js';\n\nexport { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule.js';\n\n// SDL-specific validation rules\nexport { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule.js';\nexport { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule.js';\nexport { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule.js';\nexport { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule.js';\nexport { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule.js';\nexport { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule.js';\nexport { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule.js';\nexport { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule.js';\n\n// Optional rules not defined by the GraphQL Specification\nexport { NoDeprecatedCustomRule } from './rules/custom/NoDeprecatedCustomRule.js';\nexport { NoSchemaIntrospectionCustomRule } from './rules/custom/NoSchemaIntrospectionCustomRule.js';\n"]} \ No newline at end of file diff --git a/validation/index.mjs b/validation/index.mjs new file mode 100644 index 0000000000..2e83aa1d49 --- /dev/null +++ b/validation/index.mjs @@ -0,0 +1,80 @@ +export { validate } from "./validate.mjs"; +export { ValidationContext } from "./ValidationContext.mjs"; +// All validation rules in the GraphQL Specification. +export { specifiedRules, recommendedRules } from "./specifiedRules.mjs"; +// Spec Section: "Defer And Stream Directive Labels Are Unique" +export { DeferStreamDirectiveLabelRule } from "./rules/DeferStreamDirectiveLabelRule.mjs"; +// Spec Section: "Defer And Stream Directives Are Used On Valid Root Field" +export { DeferStreamDirectiveOnRootFieldRule } from "./rules/DeferStreamDirectiveOnRootFieldRule.mjs"; +// Spec Section: "Defer And Stream Directives Are Used On Valid Operations" +export { DeferStreamDirectiveOnValidOperationsRule } from "./rules/DeferStreamDirectiveOnValidOperationsRule.mjs"; +// Spec Section: "Executable Definitions" +export { ExecutableDefinitionsRule } from "./rules/ExecutableDefinitionsRule.mjs"; +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +export { FieldsOnCorrectTypeRule } from "./rules/FieldsOnCorrectTypeRule.mjs"; +// Spec Section: "Fragments on Composite Types" +export { FragmentsOnCompositeTypesRule } from "./rules/FragmentsOnCompositeTypesRule.mjs"; +// Spec Section: "Argument Names" +export { KnownArgumentNamesRule } from "./rules/KnownArgumentNamesRule.mjs"; +// Spec Section: "Directives Are Defined" +export { KnownDirectivesRule } from "./rules/KnownDirectivesRule.mjs"; +// Spec Section: "Fragment spread target defined" +export { KnownFragmentNamesRule } from "./rules/KnownFragmentNamesRule.mjs"; +// Spec Section: "Operation Type Existence" +export { KnownOperationTypesRule } from "./rules/KnownOperationTypesRule.mjs"; +// Spec Section: "Fragment Spread Type Existence" +export { KnownTypeNamesRule } from "./rules/KnownTypeNamesRule.mjs"; +// Spec Section: "Lone Anonymous Operation" +export { LoneAnonymousOperationRule } from "./rules/LoneAnonymousOperationRule.mjs"; +// Spec Section: "Fragments must not form cycles" +export { NoFragmentCyclesRule } from "./rules/NoFragmentCyclesRule.mjs"; +// Spec Section: "All Variable Used Defined" +export { NoUndefinedVariablesRule } from "./rules/NoUndefinedVariablesRule.mjs"; +// Spec Section: "Fragments must be used" +export { NoUnusedFragmentsRule } from "./rules/NoUnusedFragmentsRule.mjs"; +// Spec Section: "All Variables Used" +export { NoUnusedVariablesRule } from "./rules/NoUnusedVariablesRule.mjs"; +// Spec Section: "Field Selection Merging" +export { OverlappingFieldsCanBeMergedRule } from "./rules/OverlappingFieldsCanBeMergedRule.mjs"; +// Spec Section: "Fragment spread is possible" +export { PossibleFragmentSpreadsRule } from "./rules/PossibleFragmentSpreadsRule.mjs"; +// Spec Section: "Argument Optionality" +export { ProvidedRequiredArgumentsRule } from "./rules/ProvidedRequiredArgumentsRule.mjs"; +// Spec Section: "Leaf Field Selections" +export { ScalarLeafsRule } from "./rules/ScalarLeafsRule.mjs"; +// Spec Section: "Subscriptions with Single Root Field" +export { SingleFieldSubscriptionsRule } from "./rules/SingleFieldSubscriptionsRule.mjs"; +// Spec Section: "Stream Directives Are Used On List Fields" +export { StreamDirectiveOnListFieldRule } from "./rules/StreamDirectiveOnListFieldRule.mjs"; +// Spec Section: "Argument Uniqueness" +export { UniqueArgumentNamesRule } from "./rules/UniqueArgumentNamesRule.mjs"; +// Spec Section: "Directives Are Unique Per Location" +export { UniqueDirectivesPerLocationRule } from "./rules/UniqueDirectivesPerLocationRule.mjs"; +// Spec Section: "Fragment Name Uniqueness" +export { UniqueFragmentNamesRule } from "./rules/UniqueFragmentNamesRule.mjs"; +// Spec Section: "Input Object Field Uniqueness" +export { UniqueInputFieldNamesRule } from "./rules/UniqueInputFieldNamesRule.mjs"; +// Spec Section: "Operation Name Uniqueness" +export { UniqueOperationNamesRule } from "./rules/UniqueOperationNamesRule.mjs"; +// Spec Section: "Variable Uniqueness" +export { UniqueVariableNamesRule } from "./rules/UniqueVariableNamesRule.mjs"; +// Spec Section: "Values Type Correctness" +export { ValuesOfCorrectTypeRule } from "./rules/ValuesOfCorrectTypeRule.mjs"; +// Spec Section: "Variables are Input Types" +export { VariablesAreInputTypesRule } from "./rules/VariablesAreInputTypesRule.mjs"; +// Spec Section: "All Variable Usages Are Allowed" +export { VariablesInAllowedPositionRule } from "./rules/VariablesInAllowedPositionRule.mjs"; +export { MaxIntrospectionDepthRule } from "./rules/MaxIntrospectionDepthRule.mjs"; +// SDL-specific validation rules +export { LoneSchemaDefinitionRule } from "./rules/LoneSchemaDefinitionRule.mjs"; +export { UniqueOperationTypesRule } from "./rules/UniqueOperationTypesRule.mjs"; +export { UniqueTypeNamesRule } from "./rules/UniqueTypeNamesRule.mjs"; +export { UniqueEnumValueNamesRule } from "./rules/UniqueEnumValueNamesRule.mjs"; +export { UniqueFieldDefinitionNamesRule } from "./rules/UniqueFieldDefinitionNamesRule.mjs"; +export { UniqueArgumentDefinitionNamesRule } from "./rules/UniqueArgumentDefinitionNamesRule.mjs"; +export { UniqueDirectiveNamesRule } from "./rules/UniqueDirectiveNamesRule.mjs"; +export { PossibleTypeExtensionsRule } from "./rules/PossibleTypeExtensionsRule.mjs"; +// Optional rules not defined by the GraphQL Specification +export { NoDeprecatedCustomRule } from "./rules/custom/NoDeprecatedCustomRule.mjs"; +export { NoSchemaIntrospectionCustomRule } from "./rules/custom/NoSchemaIntrospectionCustomRule.mjs"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/validation/index.mjs.map b/validation/index.mjs.map new file mode 100644 index 0000000000..d0831fc578 --- /dev/null +++ b/validation/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,uBAAsB;AAEzC,OAAO,EAAE,iBAAiB,EAAE,gCAA+B;AAG3D,qDAAqD;AACrD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,6BAA4B;AAEvE,+DAA+D;AAC/D,OAAO,EAAE,6BAA6B,EAAE,kDAAiD;AAEzF,2EAA2E;AAC3E,OAAO,EAAE,mCAAmC,EAAE,wDAAuD;AAErG,2EAA2E;AAC3E,OAAO,EAAE,yCAAyC,EAAE,8DAA6D;AAEjH,yCAAyC;AACzC,OAAO,EAAE,yBAAyB,EAAE,8CAA6C;AAEjF,4EAA4E;AAC5E,OAAO,EAAE,uBAAuB,EAAE,4CAA2C;AAE7E,+CAA+C;AAC/C,OAAO,EAAE,6BAA6B,EAAE,kDAAiD;AAEzF,iCAAiC;AACjC,OAAO,EAAE,sBAAsB,EAAE,2CAA0C;AAE3E,yCAAyC;AACzC,OAAO,EAAE,mBAAmB,EAAE,wCAAuC;AAErE,iDAAiD;AACjD,OAAO,EAAE,sBAAsB,EAAE,2CAA0C;AAE3E,2CAA2C;AAC3C,OAAO,EAAE,uBAAuB,EAAE,4CAA2C;AAE7E,iDAAiD;AACjD,OAAO,EAAE,kBAAkB,EAAE,uCAAsC;AAEnE,2CAA2C;AAC3C,OAAO,EAAE,0BAA0B,EAAE,+CAA8C;AAEnF,iDAAiD;AACjD,OAAO,EAA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AACrE,OAAO,EAAE,wBAAwB,EAAE,6CAA4C;AAC/E,OAAO,EAAE,8BAA8B,EAAE,mDAAkD;AAC3F,OAAO,EAAE,iCAAiC,EAAE,sDAAqD;AACjG,OAAO,EAAE,wBAAwB,EAAE,6CAA4C;AAC/E,OAAO,EAAE,0BAA0B,EAAE,+CAA8C;AAEnF,0DAA0D;AAC1D,OAAO,EAAE,sBAAsB,EAAE,kDAAiD;AAClF,OAAO,EAAE,+BAA+B,EAAE,2DAA0D","sourcesContent":["export { validate } from './validate.js';\n\nexport { ValidationContext } from './ValidationContext.js';\nexport type { ValidationRule } from './ValidationContext.js';\n\n// All validation rules in the GraphQL Specification.\nexport { specifiedRules, recommendedRules } from './specifiedRules.js';\n\n// Spec Section: \"Defer And Stream Directive Labels Are Unique\"\nexport { DeferStreamDirectiveLabelRule } from './rules/DeferStreamDirectiveLabelRule.js';\n\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Root Field\"\nexport { DeferStreamDirectiveOnRootFieldRule } from './rules/DeferStreamDirectiveOnRootFieldRule.js';\n\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Operations\"\nexport { DeferStreamDirectiveOnValidOperationsRule } from './rules/DeferStreamDirectiveOnValidOperationsRule.js';\n\n// Spec Section: \"Executable Definitions\"\nexport { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule.js';\n\n// Spec Section: \"Field Selections on Objects, Interfaces, and Unions Types\"\nexport { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule.js';\n\n// Spec Section: \"Fragments on Composite Types\"\nexport { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule.js';\n\n// Spec Section: \"Argument Names\"\nexport { KnownArgumentNamesRule } from './rules/KnownArgumentNamesRule.js';\n\n// Spec Section: \"Directives Are Defined\"\nexport { KnownDirectivesRule } from './rules/KnownDirectivesRule.js';\n\n// Spec Section: \"Fragment spread target defined\"\nexport { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule.js';\n\n// Spec Section: \"Operation Type Existence\"\nexport { KnownOperationTypesRule } from './rules/KnownOperationTypesRule.js';\n\n// Spec Section: \"Fragment Spread Type Existence\"\nexport { KnownTypeNamesRule } from './rules/KnownTypeNamesRule.js';\n\n// Spec Section: \"Lone Anonymous Operation\"\nexport { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule.js';\n\n// Spec Section: \"Fragments must not form cycles\"\nexport { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule.js';\n\n// Spec Section: \"All Variable Used Defined\"\nexport { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule.js';\n\n// Spec Section: \"Fragments must be used\"\nexport { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule.js';\n\n// Spec Section: \"All Variables Used\"\nexport { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule.js';\n\n// Spec Section: \"Field Selection Merging\"\nexport { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule.js';\n\n// Spec Section: \"Fragment spread is possible\"\nexport { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule.js';\n\n// Spec Section: \"Argument Optionality\"\nexport { ProvidedRequiredArgumentsRule } from './rules/ProvidedRequiredArgumentsRule.js';\n\n// Spec Section: \"Leaf Field Selections\"\nexport { ScalarLeafsRule } from './rules/ScalarLeafsRule.js';\n\n// Spec Section: \"Subscriptions with Single Root Field\"\nexport { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule.js';\n\n// Spec Section: \"Stream Directives Are Used On List Fields\"\nexport { StreamDirectiveOnListFieldRule } from './rules/StreamDirectiveOnListFieldRule.js';\n\n// Spec Section: \"Argument Uniqueness\"\nexport { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule.js';\n\n// Spec Section: \"Directives Are Unique Per Location\"\nexport { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule.js';\n\n// Spec Section: \"Fragment Name Uniqueness\"\nexport { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule.js';\n\n// Spec Section: \"Input Object Field Uniqueness\"\nexport { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule.js';\n\n// Spec Section: \"Operation Name Uniqueness\"\nexport { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule.js';\n\n// Spec Section: \"Variable Uniqueness\"\nexport { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule.js';\n\n// Spec Section: \"Values Type Correctness\"\nexport { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule.js';\n\n// Spec Section: \"Variables are Input Types\"\nexport { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule.js';\n\n// Spec Section: \"All Variable Usages Are Allowed\"\nexport { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule.js';\n\nexport { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule.js';\n\n// SDL-specific validation rules\nexport { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule.js';\nexport { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule.js';\nexport { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule.js';\nexport { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule.js';\nexport { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule.js';\nexport { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule.js';\nexport { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule.js';\nexport { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule.js';\n\n// Optional rules not defined by the GraphQL Specification\nexport { NoDeprecatedCustomRule } from './rules/custom/NoDeprecatedCustomRule.js';\nexport { NoSchemaIntrospectionCustomRule } from './rules/custom/NoSchemaIntrospectionCustomRule.js';\n"]} \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveLabelRule.d.ts b/validation/rules/DeferStreamDirectiveLabelRule.d.ts new file mode 100644 index 0000000000..8c1b4243aa --- /dev/null +++ b/validation/rules/DeferStreamDirectiveLabelRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Defer and stream directive labels are unique + * + * A GraphQL document is only valid if defer and stream directives' label argument is static and unique. + */ +export declare function DeferStreamDirectiveLabelRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/DeferStreamDirectiveLabelRule.js b/validation/rules/DeferStreamDirectiveLabelRule.js new file mode 100644 index 0000000000..646007d9d7 --- /dev/null +++ b/validation/rules/DeferStreamDirectiveLabelRule.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeferStreamDirectiveLabelRule = DeferStreamDirectiveLabelRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const directives_js_1 = require("../../type/directives.js"); +/** + * Defer and stream directive labels are unique + * + * A GraphQL document is only valid if defer and stream directives' label argument is static and unique. + */ +function DeferStreamDirectiveLabelRule(context) { + const knownLabels = new Map(); + return { + Directive(node) { + if (node.name.value === directives_js_1.GraphQLDeferDirective.name || + node.name.value === directives_js_1.GraphQLStreamDirective.name) { + const labelArgument = node.arguments?.find((arg) => arg.name.value === 'label'); + const labelValue = labelArgument?.value; + if (!labelValue) { + return; + } + if (labelValue.kind !== kinds_js_1.Kind.STRING) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Argument "@${node.name.value}(label:)" must be a static string.`, { nodes: node })); + return; + } + const knownLabel = knownLabels.get(labelValue.value); + if (knownLabel != null) { + context.reportError(new GraphQLError_js_1.GraphQLError('Value for arguments "defer(label:)" and "stream(label:)" must be unique across all Defer/Stream directive usages.', { nodes: [knownLabel, node] })); + } + else { + knownLabels.set(labelValue.value, node); + } + } + }, + }; +} +//# sourceMappingURL=DeferStreamDirectiveLabelRule.js.map \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveLabelRule.js.map b/validation/rules/DeferStreamDirectiveLabelRule.js.map new file mode 100644 index 0000000000..ed1eb00c6d --- /dev/null +++ b/validation/rules/DeferStreamDirectiveLabelRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DeferStreamDirectiveLabelRule.js","sourceRoot":"","sources":["../../../src/validation/rules/DeferStreamDirectiveLabelRule.ts"],"names":[],"mappings":";;AAkBA,sEAyCC;AA3DD,iEAA2D;AAG3D,sDAA+C;AAG/C,4DAGkC;AAIlC;;;;GAIG;AACH,SAAgB,6BAA6B,CAC3C,OAA0B;IAE1B,MAAM,WAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;IACrD,OAAO;QACL,SAAS,CAAC,IAAI;YACZ,IACE,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,qCAAqB,CAAC,IAAI;gBAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,sCAAsB,CAAC,IAAI,EAC/C,CAAC;gBACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CACxC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,CACpC,CAAC;gBACF,MAAM,UAAU,GAAG,aAAa,EAAE,KAAK,CAAC;gBACxC,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,OAAO;gBACT,CAAC;gBACD,IAAI,UAAU,CAAC,IAAI,KAAK,eAAI,CAAC,MAAM,EAAE,CAAC;oBACpC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,cAAc,IAAI,CAAC,IAAI,CAAC,KAAK,oCAAoC,EACjE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;oBACF,OAAO;gBACT,CAAC;gBAED,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBACrD,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;oBACvB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,mHAAmH,EACnH,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAC9B,CACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport {\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n} from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Defer and stream directive labels are unique\n *\n * A GraphQL document is only valid if defer and stream directives' label argument is static and unique.\n */\nexport function DeferStreamDirectiveLabelRule(\n context: ValidationContext,\n): ASTVisitor {\n const knownLabels = new Map();\n return {\n Directive(node) {\n if (\n node.name.value === GraphQLDeferDirective.name ||\n node.name.value === GraphQLStreamDirective.name\n ) {\n const labelArgument = node.arguments?.find(\n (arg) => arg.name.value === 'label',\n );\n const labelValue = labelArgument?.value;\n if (!labelValue) {\n return;\n }\n if (labelValue.kind !== Kind.STRING) {\n context.reportError(\n new GraphQLError(\n `Argument \"@${node.name.value}(label:)\" must be a static string.`,\n { nodes: node },\n ),\n );\n return;\n }\n\n const knownLabel = knownLabels.get(labelValue.value);\n if (knownLabel != null) {\n context.reportError(\n new GraphQLError(\n 'Value for arguments \"defer(label:)\" and \"stream(label:)\" must be unique across all Defer/Stream directive usages.',\n { nodes: [knownLabel, node] },\n ),\n );\n } else {\n knownLabels.set(labelValue.value, node);\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveLabelRule.mjs b/validation/rules/DeferStreamDirectiveLabelRule.mjs new file mode 100644 index 0000000000..35993db328 --- /dev/null +++ b/validation/rules/DeferStreamDirectiveLabelRule.mjs @@ -0,0 +1,35 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { GraphQLDeferDirective, GraphQLStreamDirective, } from "../../type/directives.mjs"; +/** + * Defer and stream directive labels are unique + * + * A GraphQL document is only valid if defer and stream directives' label argument is static and unique. + */ +export function DeferStreamDirectiveLabelRule(context) { + const knownLabels = new Map(); + return { + Directive(node) { + if (node.name.value === GraphQLDeferDirective.name || + node.name.value === GraphQLStreamDirective.name) { + const labelArgument = node.arguments?.find((arg) => arg.name.value === 'label'); + const labelValue = labelArgument?.value; + if (!labelValue) { + return; + } + if (labelValue.kind !== Kind.STRING) { + context.reportError(new GraphQLError(`Argument "@${node.name.value}(label:)" must be a static string.`, { nodes: node })); + return; + } + const knownLabel = knownLabels.get(labelValue.value); + if (knownLabel != null) { + context.reportError(new GraphQLError('Value for arguments "defer(label:)" and "stream(label:)" must be unique across all Defer/Stream directive usages.', { nodes: [knownLabel, node] })); + } + else { + knownLabels.set(labelValue.value, node); + } + } + }, + }; +} +//# sourceMappingURL=DeferStreamDirectiveLabelRule.js.map \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveLabelRule.mjs.map b/validation/rules/DeferStreamDirectiveLabelRule.mjs.map new file mode 100644 index 0000000000..80af2098df --- /dev/null +++ b/validation/rules/DeferStreamDirectiveLabelRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"DeferStreamDirectiveLabelRule.js","sourceRoot":"","sources":["../../../src/validation/rules/DeferStreamDirectiveLabelRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAG/C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,kCAAiC;AAIlC;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAA0B;IAE1B,MAAM,WAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;IACrD,OAAO;QACL,SAAS,CAAC,IAAI;YACZ,IACE,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,IAAI;gBAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,sBAAsB,CAAC,IAAI,EAC/C,CAAC;gBACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CACxC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,CACpC,CAAC;gBACF,MAAM,UAAU,GAAG,aAAa,EAAE,KAAK,CAAC;gBACxC,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,OAAO;gBACT,CAAC;gBACD,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;oBACpC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,cAAc,IAAI,CAAC,IAAI,CAAC,KAAK,oCAAoC,EACjE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;oBACF,OAAO;gBACT,CAAC;gBAED,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBACrD,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;oBACvB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,mHAAmH,EACnH,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAC9B,CACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport {\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n} from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Defer and stream directive labels are unique\n *\n * A GraphQL document is only valid if defer and stream directives' label argument is static and unique.\n */\nexport function DeferStreamDirectiveLabelRule(\n context: ValidationContext,\n): ASTVisitor {\n const knownLabels = new Map();\n return {\n Directive(node) {\n if (\n node.name.value === GraphQLDeferDirective.name ||\n node.name.value === GraphQLStreamDirective.name\n ) {\n const labelArgument = node.arguments?.find(\n (arg) => arg.name.value === 'label',\n );\n const labelValue = labelArgument?.value;\n if (!labelValue) {\n return;\n }\n if (labelValue.kind !== Kind.STRING) {\n context.reportError(\n new GraphQLError(\n `Argument \"@${node.name.value}(label:)\" must be a static string.`,\n { nodes: node },\n ),\n );\n return;\n }\n\n const knownLabel = knownLabels.get(labelValue.value);\n if (knownLabel != null) {\n context.reportError(\n new GraphQLError(\n 'Value for arguments \"defer(label:)\" and \"stream(label:)\" must be unique across all Defer/Stream directive usages.',\n { nodes: [knownLabel, node] },\n ),\n );\n } else {\n knownLabels.set(labelValue.value, node);\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts b/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts new file mode 100644 index 0000000000..bf674350fb --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Defer and stream directives are used on valid root field + * + * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. + */ +export declare function DeferStreamDirectiveOnRootFieldRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/DeferStreamDirectiveOnRootFieldRule.js b/validation/rules/DeferStreamDirectiveOnRootFieldRule.js new file mode 100644 index 0000000000..81024d2312 --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnRootFieldRule.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeferStreamDirectiveOnRootFieldRule = DeferStreamDirectiveOnRootFieldRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const directives_js_1 = require("../../type/directives.js"); +/** + * Defer and stream directives are used on valid root field + * + * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. + */ +function DeferStreamDirectiveOnRootFieldRule(context) { + return { + Directive(node) { + const mutationType = context.getSchema().getMutationType(); + const subscriptionType = context.getSchema().getSubscriptionType(); + const parentType = context.getParentType(); + if (parentType && node.name.value === directives_js_1.GraphQLDeferDirective.name) { + if (mutationType && parentType === mutationType) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Defer directive cannot be used on root mutation type "${parentType}".`, { nodes: node })); + } + if (subscriptionType && parentType === subscriptionType) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Defer directive cannot be used on root subscription type "${parentType}".`, { nodes: node })); + } + } + if (parentType && node.name.value === directives_js_1.GraphQLStreamDirective.name) { + if (mutationType && parentType === mutationType) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Stream directive cannot be used on root mutation type "${parentType}".`, { nodes: node })); + } + if (subscriptionType && parentType === subscriptionType) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Stream directive cannot be used on root subscription type "${parentType}".`, { nodes: node })); + } + } + }, + }; +} +//# sourceMappingURL=DeferStreamDirectiveOnRootFieldRule.js.map \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map b/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map new file mode 100644 index 0000000000..7634971b6f --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DeferStreamDirectiveOnRootFieldRule.js","sourceRoot":"","sources":["../../../src/validation/rules/DeferStreamDirectiveOnRootFieldRule.ts"],"names":[],"mappings":";;AAgBA,kFA8CC;AA9DD,iEAA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,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport {\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n} from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Defer and stream directives are used on valid root field\n *\n * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types.\n */\nexport function DeferStreamDirectiveOnRootFieldRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Directive(node) {\n const mutationType = context.getSchema().getMutationType();\n const subscriptionType = context.getSchema().getSubscriptionType();\n const parentType = context.getParentType();\n if (parentType && node.name.value === GraphQLDeferDirective.name) {\n if (mutationType && parentType === mutationType) {\n context.reportError(\n new GraphQLError(\n `Defer directive cannot be used on root mutation type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n if (subscriptionType && parentType === subscriptionType) {\n context.reportError(\n new GraphQLError(\n `Defer directive cannot be used on root subscription type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n }\n if (parentType && node.name.value === GraphQLStreamDirective.name) {\n if (mutationType && parentType === mutationType) {\n context.reportError(\n new GraphQLError(\n `Stream directive cannot be used on root mutation type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n if (subscriptionType && parentType === subscriptionType) {\n context.reportError(\n new GraphQLError(\n `Stream directive cannot be used on root subscription type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs b/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs new file mode 100644 index 0000000000..eca974ce7e --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs @@ -0,0 +1,33 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { GraphQLDeferDirective, GraphQLStreamDirective, } from "../../type/directives.mjs"; +/** + * Defer and stream directives are used on valid root field + * + * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. + */ +export function DeferStreamDirectiveOnRootFieldRule(context) { + return { + Directive(node) { + const mutationType = context.getSchema().getMutationType(); + const subscriptionType = context.getSchema().getSubscriptionType(); + const parentType = context.getParentType(); + if (parentType && node.name.value === GraphQLDeferDirective.name) { + if (mutationType && parentType === mutationType) { + context.reportError(new GraphQLError(`Defer directive cannot be used on root mutation type "${parentType}".`, { nodes: node })); + } + if (subscriptionType && parentType === subscriptionType) { + context.reportError(new GraphQLError(`Defer directive cannot be used on root subscription type "${parentType}".`, { nodes: node })); + } + } + if (parentType && node.name.value === GraphQLStreamDirective.name) { + if (mutationType && parentType === mutationType) { + context.reportError(new GraphQLError(`Stream directive cannot be used on root mutation type "${parentType}".`, { nodes: node })); + } + if (subscriptionType && parentType === subscriptionType) { + context.reportError(new GraphQLError(`Stream directive cannot be used on root subscription type "${parentType}".`, { nodes: node })); + } + } + }, + }; +} +//# sourceMappingURL=DeferStreamDirectiveOnRootFieldRule.js.map \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map b/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map new file mode 100644 index 0000000000..966dd9cbae --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"DeferStreamDirectiveOnRootFieldRule.js","sourceRoot":"","sources":["../../../src/validation/rules/DeferStreamDirectiveOnRootFieldRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAI3D,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,kCAAiC;AAIlC;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CACjD,OAA0B;IAE1B,OAAO;QACL,SAAS,CAAC,IAAI;YACZ,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,eAAe,EAAE,CAAC;YAC3D,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,mBAAmB,EAAE,CAAC;YACnE,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;YAC3C,IAAI,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,IAAI,EAAE,CAAC;gBACjE,IAAI,YAAY,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;oBAChD,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yDAAyD,UAAU,IAAI,EACvE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;gBACD,IAAI,gBAAgB,IAAI,UAAU,KAAK,gBAAgB,EAAE,CAAC;oBACxD,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,6DAA6D,UAAU,IAAI,EAC3E,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,IAAI,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,sBAAsB,CAAC,IAAI,EAAE,CAAC;gBAClE,IAAI,YAAY,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;oBAChD,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,0DAA0D,UAAU,IAAI,EACxE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;gBACD,IAAI,gBAAgB,IAAI,UAAU,KAAK,gBAAgB,EAAE,CAAC;oBACxD,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,8DAA8D,UAAU,IAAI,EAC5E,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport {\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n} from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Defer and stream directives are used on valid root field\n *\n * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types.\n */\nexport function DeferStreamDirectiveOnRootFieldRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Directive(node) {\n const mutationType = context.getSchema().getMutationType();\n const subscriptionType = context.getSchema().getSubscriptionType();\n const parentType = context.getParentType();\n if (parentType && node.name.value === GraphQLDeferDirective.name) {\n if (mutationType && parentType === mutationType) {\n context.reportError(\n new GraphQLError(\n `Defer directive cannot be used on root mutation type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n if (subscriptionType && parentType === subscriptionType) {\n context.reportError(\n new GraphQLError(\n `Defer directive cannot be used on root subscription type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n }\n if (parentType && node.name.value === GraphQLStreamDirective.name) {\n if (mutationType && parentType === mutationType) {\n context.reportError(\n new GraphQLError(\n `Stream directive cannot be used on root mutation type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n if (subscriptionType && parentType === subscriptionType) {\n context.reportError(\n new GraphQLError(\n `Stream directive cannot be used on root subscription type \"${parentType}\".`,\n { nodes: node },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts new file mode 100644 index 0000000000..a5f801f45a --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Defer And Stream Directives Are Used On Valid Operations + * + * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. + */ +export declare function DeferStreamDirectiveOnValidOperationsRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js new file mode 100644 index 0000000000..e4990af76f --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js @@ -0,0 +1,59 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeferStreamDirectiveOnValidOperationsRule = DeferStreamDirectiveOnValidOperationsRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const ast_js_1 = require("../../language/ast.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const directives_js_1 = require("../../type/directives.js"); +function ifArgumentCanBeFalse(node) { + const ifArgument = node.arguments?.find((arg) => arg.name.value === 'if'); + if (!ifArgument) { + return false; + } + if (ifArgument.value.kind === kinds_js_1.Kind.BOOLEAN) { + if (ifArgument.value.value) { + return false; + } + } + else if (ifArgument.value.kind !== kinds_js_1.Kind.VARIABLE) { + return false; + } + return true; +} +/** + * Defer And Stream Directives Are Used On Valid Operations + * + * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. + */ +function DeferStreamDirectiveOnValidOperationsRule(context) { + const fragmentsUsedOnSubscriptions = new Set(); + return { + OperationDefinition(operation) { + if (operation.operation === ast_js_1.OperationTypeNode.SUBSCRIPTION) { + for (const fragment of context.getRecursivelyReferencedFragments(operation)) { + fragmentsUsedOnSubscriptions.add(fragment.name.value); + } + } + }, + Directive(node, _key, _parent, _path, ancestors) { + const definitionNode = ancestors[2]; + if ('kind' in definitionNode && + ((definitionNode.kind === kinds_js_1.Kind.FRAGMENT_DEFINITION && + fragmentsUsedOnSubscriptions.has(definitionNode.name.value)) || + (definitionNode.kind === kinds_js_1.Kind.OPERATION_DEFINITION && + definitionNode.operation === ast_js_1.OperationTypeNode.SUBSCRIPTION))) { + if (node.name.value === directives_js_1.GraphQLDeferDirective.name) { + if (!ifArgumentCanBeFalse(node)) { + context.reportError(new GraphQLError_js_1.GraphQLError('Defer directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.', { nodes: node })); + } + } + else if (node.name.value === directives_js_1.GraphQLStreamDirective.name) { + if (!ifArgumentCanBeFalse(node)) { + context.reportError(new GraphQLError_js_1.GraphQLError('Stream directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.', { nodes: node })); + } + } + } + }, + }; +} +//# sourceMappingURL=DeferStreamDirectiveOnValidOperationsRule.js.map \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map new file mode 100644 index 0000000000..6dff079ba5 --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DeferStreamDirectiveOnValidOperationsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/DeferStreamDirectiveOnValidOperationsRule.ts"],"names":[],"mappings":";;AAkCA,8FA+CC;AAjFD,iEAA2D;AAG3D,kDAA0D;AAC1D,sDAA+C;AAG/C,4DAGkC;AAIlC,SAAS,oBAAoB,CAAC,IAAmB;IAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;IAC1E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,eAAI,CAAC,OAAO,EAAE,CAAC;QAC3C,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;SAAM,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,eAAI,CAAC,QAAQ,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAA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,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,uHAAuH,EACvH,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport { OperationTypeNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport {\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n} from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\nfunction ifArgumentCanBeFalse(node: DirectiveNode): boolean {\n const ifArgument = node.arguments?.find((arg) => arg.name.value === 'if');\n if (!ifArgument) {\n return false;\n }\n if (ifArgument.value.kind === Kind.BOOLEAN) {\n if (ifArgument.value.value) {\n return false;\n }\n } else if (ifArgument.value.kind !== Kind.VARIABLE) {\n return false;\n }\n return true;\n}\n\n/**\n * Defer And Stream Directives Are Used On Valid Operations\n *\n * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types.\n */\nexport function DeferStreamDirectiveOnValidOperationsRule(\n context: ValidationContext,\n): ASTVisitor {\n const fragmentsUsedOnSubscriptions = new Set();\n\n return {\n OperationDefinition(operation) {\n if (operation.operation === OperationTypeNode.SUBSCRIPTION) {\n for (const fragment of context.getRecursivelyReferencedFragments(\n operation,\n )) {\n fragmentsUsedOnSubscriptions.add(fragment.name.value);\n }\n }\n },\n Directive(node, _key, _parent, _path, ancestors) {\n const definitionNode = ancestors[2];\n\n if (\n 'kind' in definitionNode &&\n ((definitionNode.kind === Kind.FRAGMENT_DEFINITION &&\n fragmentsUsedOnSubscriptions.has(definitionNode.name.value)) ||\n (definitionNode.kind === Kind.OPERATION_DEFINITION &&\n definitionNode.operation === OperationTypeNode.SUBSCRIPTION))\n ) {\n if (node.name.value === GraphQLDeferDirective.name) {\n if (!ifArgumentCanBeFalse(node)) {\n context.reportError(\n new GraphQLError(\n 'Defer directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.',\n { nodes: node },\n ),\n );\n }\n } else if (node.name.value === GraphQLStreamDirective.name) {\n if (!ifArgumentCanBeFalse(node)) {\n context.reportError(\n new GraphQLError(\n 'Stream directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.',\n { nodes: node },\n ),\n );\n }\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs new file mode 100644 index 0000000000..b8f3f84bdd --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs @@ -0,0 +1,56 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { OperationTypeNode } from "../../language/ast.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { GraphQLDeferDirective, GraphQLStreamDirective, } from "../../type/directives.mjs"; +function ifArgumentCanBeFalse(node) { + const ifArgument = node.arguments?.find((arg) => arg.name.value === 'if'); + if (!ifArgument) { + return false; + } + if (ifArgument.value.kind === Kind.BOOLEAN) { + if (ifArgument.value.value) { + return false; + } + } + else if (ifArgument.value.kind !== Kind.VARIABLE) { + return false; + } + return true; +} +/** + * Defer And Stream Directives Are Used On Valid Operations + * + * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. + */ +export function DeferStreamDirectiveOnValidOperationsRule(context) { + const fragmentsUsedOnSubscriptions = new Set(); + return { + OperationDefinition(operation) { + if (operation.operation === OperationTypeNode.SUBSCRIPTION) { + for (const fragment of context.getRecursivelyReferencedFragments(operation)) { + fragmentsUsedOnSubscriptions.add(fragment.name.value); + } + } + }, + Directive(node, _key, _parent, _path, ancestors) { + const definitionNode = ancestors[2]; + if ('kind' in definitionNode && + ((definitionNode.kind === Kind.FRAGMENT_DEFINITION && + fragmentsUsedOnSubscriptions.has(definitionNode.name.value)) || + (definitionNode.kind === Kind.OPERATION_DEFINITION && + definitionNode.operation === OperationTypeNode.SUBSCRIPTION))) { + if (node.name.value === GraphQLDeferDirective.name) { + if (!ifArgumentCanBeFalse(node)) { + context.reportError(new GraphQLError('Defer directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.', { nodes: node })); + } + } + else if (node.name.value === GraphQLStreamDirective.name) { + if (!ifArgumentCanBeFalse(node)) { + context.reportError(new GraphQLError('Stream directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.', { nodes: node })); + } + } + } + }, + }; +} +//# sourceMappingURL=DeferStreamDirectiveOnValidOperationsRule.js.map \ No newline at end of file diff --git a/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map new file mode 100644 index 0000000000..e67490957c --- /dev/null +++ b/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"DeferStreamDirectiveOnValidOperationsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/DeferStreamDirectiveOnValidOperationsRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,+BAA8B;AAC1D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAG/C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,kCAAiC;AAIlC,SAAS,oBAAoB,CAAC,IAAmB;IAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;IAC1E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3C,IAAI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C,WAAW,CACjB,IAAI,YAAY,CACd,qHAAqH,EACrH,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC;qBAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,sBAAsB,CAAC,IAAI,EAAE,CAAC;oBAC3D,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;wBAChC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,uHAAuH,EACvH,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport { OperationTypeNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport {\n GraphQLDeferDirective,\n GraphQLStreamDirective,\n} from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\nfunction ifArgumentCanBeFalse(node: DirectiveNode): boolean {\n const ifArgument = node.arguments?.find((arg) => arg.name.value === 'if');\n if (!ifArgument) {\n return false;\n }\n if (ifArgument.value.kind === Kind.BOOLEAN) {\n if (ifArgument.value.value) {\n return false;\n }\n } else if (ifArgument.value.kind !== Kind.VARIABLE) {\n return false;\n }\n return true;\n}\n\n/**\n * Defer And Stream Directives Are Used On Valid Operations\n *\n * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types.\n */\nexport function DeferStreamDirectiveOnValidOperationsRule(\n context: ValidationContext,\n): ASTVisitor {\n const fragmentsUsedOnSubscriptions = new Set();\n\n return {\n OperationDefinition(operation) {\n if (operation.operation === OperationTypeNode.SUBSCRIPTION) {\n for (const fragment of context.getRecursivelyReferencedFragments(\n operation,\n )) {\n fragmentsUsedOnSubscriptions.add(fragment.name.value);\n }\n }\n },\n Directive(node, _key, _parent, _path, ancestors) {\n const definitionNode = ancestors[2];\n\n if (\n 'kind' in definitionNode &&\n ((definitionNode.kind === Kind.FRAGMENT_DEFINITION &&\n fragmentsUsedOnSubscriptions.has(definitionNode.name.value)) ||\n (definitionNode.kind === Kind.OPERATION_DEFINITION &&\n definitionNode.operation === OperationTypeNode.SUBSCRIPTION))\n ) {\n if (node.name.value === GraphQLDeferDirective.name) {\n if (!ifArgumentCanBeFalse(node)) {\n context.reportError(\n new GraphQLError(\n 'Defer directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.',\n { nodes: node },\n ),\n );\n }\n } else if (node.name.value === GraphQLStreamDirective.name) {\n if (!ifArgumentCanBeFalse(node)) {\n context.reportError(\n new GraphQLError(\n 'Stream directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.',\n { nodes: node },\n ),\n );\n }\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ExecutableDefinitionsRule.d.ts b/validation/rules/ExecutableDefinitionsRule.d.ts new file mode 100644 index 0000000000..f0bcfd1e63 --- /dev/null +++ b/validation/rules/ExecutableDefinitionsRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * Executable definitions + * + * A GraphQL document is only valid for execution if all definitions are either + * operation or fragment definitions. + * + * See https://spec.graphql.org/draft/#sec-Executable-Definitions + */ +export declare function ExecutableDefinitionsRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/ExecutableDefinitionsRule.js b/validation/rules/ExecutableDefinitionsRule.js new file mode 100644 index 0000000000..7dd26de300 --- /dev/null +++ b/validation/rules/ExecutableDefinitionsRule.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ExecutableDefinitionsRule = ExecutableDefinitionsRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const predicates_js_1 = require("../../language/predicates.js"); +/** + * Executable definitions + * + * A GraphQL document is only valid for execution if all definitions are either + * operation or fragment definitions. + * + * See https://spec.graphql.org/draft/#sec-Executable-Definitions + */ +function ExecutableDefinitionsRule(context) { + return { + Document(node) { + for (const definition of node.definitions) { + if (!(0, predicates_js_1.isExecutableDefinitionNode)(definition)) { + const defName = definition.kind === kinds_js_1.Kind.SCHEMA_DEFINITION || + definition.kind === kinds_js_1.Kind.SCHEMA_EXTENSION + ? 'schema' + : '"' + definition.name.value + '"'; + context.reportError(new GraphQLError_js_1.GraphQLError(`The ${defName} definition is not executable.`, { + nodes: definition, + })); + } + } + return false; + }, + }; +} +//# sourceMappingURL=ExecutableDefinitionsRule.js.map \ No newline at end of file diff --git a/validation/rules/ExecutableDefinitionsRule.js.map b/validation/rules/ExecutableDefinitionsRule.js.map new file mode 100644 index 0000000000..e64302cc13 --- /dev/null +++ b/validation/rules/ExecutableDefinitionsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ExecutableDefinitionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ExecutableDefinitionsRule.ts"],"names":[],"mappings":";;AAgBA,8DAsBC;AAtCD,iEAA2D;AAE3D,sDAA+C;AAC/C,gEAA0E;AAK1E;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CACvC,OAA6B;IAE7B,OAAO;QACL,QAAQ,CAAC,IAAI;YACX,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC1C,IAAI,CAAC,IAAA,0CAA0B,EAAC,UAAU,CAAC,EAAE,CAAC;oBAC5C,MAAM,OAAO,GACX,UAAU,CAAC,IAAI,KAAK,eAAI,CAAC,iBAAiB;wBAC1C,UAAU,CAAC,IAAI,KAAK,eAAI,CAAC,gBAAgB;wBACvC,CAAC,CAAC,QAAQ;wBACV,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;oBACxC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CAAC,OAAO,OAAO,gCAAgC,EAAE;wBAC/D,KAAK,EAAE,UAAU;qBAClB,CAAC,CACH,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { Kind } from '../../language/kinds.js';\nimport { isExecutableDefinitionNode } from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Executable definitions\n *\n * A GraphQL document is only valid for execution if all definitions are either\n * operation or fragment definitions.\n *\n * See https://spec.graphql.org/draft/#sec-Executable-Definitions\n */\nexport function ExecutableDefinitionsRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n Document(node) {\n for (const definition of node.definitions) {\n if (!isExecutableDefinitionNode(definition)) {\n const defName =\n definition.kind === Kind.SCHEMA_DEFINITION ||\n definition.kind === Kind.SCHEMA_EXTENSION\n ? 'schema'\n : '\"' + definition.name.value + '\"';\n context.reportError(\n new GraphQLError(`The ${defName} definition is not executable.`, {\n nodes: definition,\n }),\n );\n }\n }\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ExecutableDefinitionsRule.mjs b/validation/rules/ExecutableDefinitionsRule.mjs new file mode 100644 index 0000000000..94d2969c7e --- /dev/null +++ b/validation/rules/ExecutableDefinitionsRule.mjs @@ -0,0 +1,30 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { isExecutableDefinitionNode } from "../../language/predicates.mjs"; +/** + * Executable definitions + * + * A GraphQL document is only valid for execution if all definitions are either + * operation or fragment definitions. + * + * See https://spec.graphql.org/draft/#sec-Executable-Definitions + */ +export function ExecutableDefinitionsRule(context) { + return { + Document(node) { + for (const definition of node.definitions) { + if (!isExecutableDefinitionNode(definition)) { + const defName = definition.kind === Kind.SCHEMA_DEFINITION || + definition.kind === Kind.SCHEMA_EXTENSION + ? 'schema' + : '"' + definition.name.value + '"'; + context.reportError(new GraphQLError(`The ${defName} definition is not executable.`, { + nodes: definition, + })); + } + } + return false; + }, + }; +} +//# sourceMappingURL=ExecutableDefinitionsRule.js.map \ No newline at end of file diff --git a/validation/rules/ExecutableDefinitionsRule.mjs.map b/validation/rules/ExecutableDefinitionsRule.mjs.map new file mode 100644 index 0000000000..932dfdff2a --- /dev/null +++ b/validation/rules/ExecutableDefinitionsRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ExecutableDefinitionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ExecutableDefinitionsRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAE3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,sCAAqC;AAK1E;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAA6B;IAE7B,OAAO;QACL,QAAQ,CAAC,IAAI;YACX,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC1C,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC5C,MAAM,OAAO,GACX,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,iBAAiB;wBAC1C,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,gBAAgB;wBACvC,CAAC,CAAC,QAAQ;wBACV,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;oBACxC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CAAC,OAAO,OAAO,gCAAgC,EAAE;wBAC/D,KAAK,EAAE,UAAU;qBAClB,CAAC,CACH,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { Kind } from '../../language/kinds.js';\nimport { isExecutableDefinitionNode } from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Executable definitions\n *\n * A GraphQL document is only valid for execution if all definitions are either\n * operation or fragment definitions.\n *\n * See https://spec.graphql.org/draft/#sec-Executable-Definitions\n */\nexport function ExecutableDefinitionsRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n Document(node) {\n for (const definition of node.definitions) {\n if (!isExecutableDefinitionNode(definition)) {\n const defName =\n definition.kind === Kind.SCHEMA_DEFINITION ||\n definition.kind === Kind.SCHEMA_EXTENSION\n ? 'schema'\n : '\"' + definition.name.value + '\"';\n context.reportError(\n new GraphQLError(`The ${defName} definition is not executable.`, {\n nodes: definition,\n }),\n );\n }\n }\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/FieldsOnCorrectTypeRule.d.ts b/validation/rules/FieldsOnCorrectTypeRule.d.ts new file mode 100644 index 0000000000..b98f1ee432 --- /dev/null +++ b/validation/rules/FieldsOnCorrectTypeRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + * + * See https://spec.graphql.org/draft/#sec-Field-Selections + */ +export declare function FieldsOnCorrectTypeRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/FieldsOnCorrectTypeRule.js b/validation/rules/FieldsOnCorrectTypeRule.js new file mode 100644 index 0000000000..70160af2c9 --- /dev/null +++ b/validation/rules/FieldsOnCorrectTypeRule.js @@ -0,0 +1,104 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.FieldsOnCorrectTypeRule = FieldsOnCorrectTypeRule; +const didYouMean_js_1 = require("../../jsutils/didYouMean.js"); +const naturalCompare_js_1 = require("../../jsutils/naturalCompare.js"); +const suggestionList_js_1 = require("../../jsutils/suggestionList.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const definition_js_1 = require("../../type/definition.js"); +/** + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + * + * See https://spec.graphql.org/draft/#sec-Field-Selections + */ +function FieldsOnCorrectTypeRule(context) { + return { + Field(node) { + const type = context.getParentType(); + if (type) { + const fieldDef = context.getFieldDef(); + if (!fieldDef) { + // This field doesn't exist, lets look for suggestions. + const schema = context.getSchema(); + const fieldName = node.name.value; + // First determine if there are any suggested types to condition on. + let suggestion = (0, didYouMean_js_1.didYouMean)('to use an inline fragment on', context.hideSuggestions + ? [] + : getSuggestedTypeNames(schema, type, fieldName)); + // If there are no suggested types, then perhaps this was a typo? + if (suggestion === '') { + suggestion = (0, didYouMean_js_1.didYouMean)(context.hideSuggestions + ? [] + : getSuggestedFieldNames(type, fieldName)); + } + // Report an error, including helpful suggestions. + context.reportError(new GraphQLError_js_1.GraphQLError(`Cannot query field "${fieldName}" on type "${type}".` + + suggestion, { nodes: node })); + } + } + }, + }; +} +/** + * Go through all of the implementations of type, as well as the interfaces that + * they implement. If any of those types include the provided field, suggest them, + * sorted by how often the type is referenced. + */ +function getSuggestedTypeNames(schema, type, fieldName) { + if (!(0, definition_js_1.isAbstractType)(type)) { + // Must be an Object type, which does not have possible fields. + return []; + } + const suggestedTypes = new Set(); + const usageCount = Object.create(null); + for (const possibleType of schema.getPossibleTypes(type)) { + if (possibleType.getFields()[fieldName] == null) { + continue; + } + // This object type defines this field. + suggestedTypes.add(possibleType); + usageCount[possibleType.name] = 1; + for (const possibleInterface of possibleType.getInterfaces()) { + if (possibleInterface.getFields()[fieldName] == null) { + continue; + } + // This interface type defines this field. + suggestedTypes.add(possibleInterface); + usageCount[possibleInterface.name] = + (usageCount[possibleInterface.name] ?? 0) + 1; + } + } + return [...suggestedTypes] + .sort((typeA, typeB) => { + // Suggest both interface and object types based on how common they are. + const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; + if (usageCountDiff !== 0) { + return usageCountDiff; + } + // Suggest super types first followed by subtypes + if ((0, definition_js_1.isInterfaceType)(typeA) && schema.isSubType(typeA, typeB)) { + return -1; + } + if ((0, definition_js_1.isInterfaceType)(typeB) && schema.isSubType(typeB, typeA)) { + return 1; + } + return (0, naturalCompare_js_1.naturalCompare)(typeA.name, typeB.name); + }) + .map((x) => x.name); +} +/** + * For the field name provided, determine if there are any similar field names + * that may be the result of a typo. + */ +function getSuggestedFieldNames(type, fieldName) { + if ((0, definition_js_1.isObjectType)(type) || (0, definition_js_1.isInterfaceType)(type)) { + const possibleFieldNames = Object.keys(type.getFields()); + return (0, suggestionList_js_1.suggestionList)(fieldName, possibleFieldNames); + } + // Otherwise, must be a Union type, which does not define fields. + return []; +} +//# sourceMappingURL=FieldsOnCorrectTypeRule.js.map \ No newline at end of file diff --git a/validation/rules/FieldsOnCorrectTypeRule.js.map b/validation/rules/FieldsOnCorrectTypeRule.js.map new file mode 100644 index 0000000000..2f52d495f7 --- /dev/null +++ b/validation/rules/FieldsOnCorrectTypeRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FieldsOnCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/FieldsOnCorrectTypeRule.ts"],"names":[],"mappings":";;AA+BA,0DA0CC;AAzED,+DAAyD;AACzD,uEAAiE;AACjE,uEAAiE;AAEjE,iEAA2D;AAU3D,4DAIkC;AAKlC;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,OAA0B;IAE1B,OAAO;QACL,KAAK,CAAC,IAAe;YACnB,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;YACrC,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;gBACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,uDAAu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,CAAC;SACD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAC7B,IAAuB,EACvB,SAAiB;IAEjB,IAAI,IAAA,4BAAY,EAAC,IAAI,CAAC,IAAI,IAAA,+BAAe,EAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QACzD,OAAO,IAAA,kCAAc,EAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACvD,CAAC;IACD,iEAAiE;IACjE,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { naturalCompare } from '../../jsutils/naturalCompare.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FieldNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type {\n GraphQLInterfaceType,\n GraphQLObjectType,\n GraphQLOutputType,\n} from '../../type/definition.js';\nimport {\n isAbstractType,\n isInterfaceType,\n isObjectType,\n} from '../../type/definition.js';\nimport type { GraphQLSchema } from '../../type/schema.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Fields on correct type\n *\n * A GraphQL document is only valid if all fields selected are defined by the\n * parent type, or are an allowed meta field such as __typename.\n *\n * See https://spec.graphql.org/draft/#sec-Field-Selections\n */\nexport function FieldsOnCorrectTypeRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Field(node: FieldNode) {\n const type = context.getParentType();\n if (type) {\n const fieldDef = context.getFieldDef();\n if (!fieldDef) {\n // This field doesn't exist, lets look for suggestions.\n const schema = context.getSchema();\n const fieldName = node.name.value;\n\n // First determine if there are any suggested types to condition on.\n let suggestion = didYouMean(\n 'to use an inline fragment on',\n context.hideSuggestions\n ? []\n : getSuggestedTypeNames(schema, type, fieldName),\n );\n\n // If there are no suggested types, then perhaps this was a typo?\n if (suggestion === '') {\n suggestion = didYouMean(\n context.hideSuggestions\n ? []\n : getSuggestedFieldNames(type, fieldName),\n );\n }\n\n // Report an error, including helpful suggestions.\n context.reportError(\n new GraphQLError(\n `Cannot query field \"${fieldName}\" on type \"${type}\".` +\n suggestion,\n { nodes: node },\n ),\n );\n }\n }\n },\n };\n}\n\n/**\n * Go through all of the implementations of type, as well as the interfaces that\n * they implement. If any of those types include the provided field, suggest them,\n * sorted by how often the type is referenced.\n */\nfunction getSuggestedTypeNames(\n schema: GraphQLSchema,\n type: GraphQLOutputType,\n fieldName: string,\n): Array {\n if (!isAbstractType(type)) {\n // Must be an Object type, which does not have possible fields.\n return [];\n }\n\n const suggestedTypes = new Set();\n const usageCount = Object.create(null);\n for (const possibleType of schema.getPossibleTypes(type)) {\n if (possibleType.getFields()[fieldName] == null) {\n continue;\n }\n\n // This object type defines this field.\n suggestedTypes.add(possibleType);\n usageCount[possibleType.name] = 1;\n\n for (const possibleInterface of possibleType.getInterfaces()) {\n if (possibleInterface.getFields()[fieldName] == null) {\n continue;\n }\n\n // This interface type defines this field.\n suggestedTypes.add(possibleInterface);\n usageCount[possibleInterface.name] =\n (usageCount[possibleInterface.name] ?? 0) + 1;\n }\n }\n\n return [...suggestedTypes]\n .sort((typeA, typeB) => {\n // Suggest both interface and object types based on how common they are.\n const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name];\n if (usageCountDiff !== 0) {\n return usageCountDiff;\n }\n\n // Suggest super types first followed by subtypes\n if (isInterfaceType(typeA) && schema.isSubType(typeA, typeB)) {\n return -1;\n }\n if (isInterfaceType(typeB) && schema.isSubType(typeB, typeA)) {\n return 1;\n }\n\n return naturalCompare(typeA.name, typeB.name);\n })\n .map((x) => x.name);\n}\n\n/**\n * For the field name provided, determine if there are any similar field names\n * that may be the result of a typo.\n */\nfunction getSuggestedFieldNames(\n type: GraphQLOutputType,\n fieldName: string,\n): Array {\n if (isObjectType(type) || isInterfaceType(type)) {\n const possibleFieldNames = Object.keys(type.getFields());\n return suggestionList(fieldName, possibleFieldNames);\n }\n // Otherwise, must be a Union type, which does not define fields.\n return [];\n}\n"]} \ No newline at end of file diff --git a/validation/rules/FieldsOnCorrectTypeRule.mjs b/validation/rules/FieldsOnCorrectTypeRule.mjs new file mode 100644 index 0000000000..7ced3a831a --- /dev/null +++ b/validation/rules/FieldsOnCorrectTypeRule.mjs @@ -0,0 +1,101 @@ +import { didYouMean } from "../../jsutils/didYouMean.mjs"; +import { naturalCompare } from "../../jsutils/naturalCompare.mjs"; +import { suggestionList } from "../../jsutils/suggestionList.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { isAbstractType, isInterfaceType, isObjectType, } from "../../type/definition.mjs"; +/** + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + * + * See https://spec.graphql.org/draft/#sec-Field-Selections + */ +export function FieldsOnCorrectTypeRule(context) { + return { + Field(node) { + const type = context.getParentType(); + if (type) { + const fieldDef = context.getFieldDef(); + if (!fieldDef) { + // This field doesn't exist, lets look for suggestions. + const schema = context.getSchema(); + const fieldName = node.name.value; + // First determine if there are any suggested types to condition on. + let suggestion = didYouMean('to use an inline fragment on', context.hideSuggestions + ? [] + : getSuggestedTypeNames(schema, type, fieldName)); + // If there are no suggested types, then perhaps this was a typo? + if (suggestion === '') { + suggestion = didYouMean(context.hideSuggestions + ? [] + : getSuggestedFieldNames(type, fieldName)); + } + // Report an error, including helpful suggestions. + context.reportError(new GraphQLError(`Cannot query field "${fieldName}" on type "${type}".` + + suggestion, { nodes: node })); + } + } + }, + }; +} +/** + * Go through all of the implementations of type, as well as the interfaces that + * they implement. If any of those types include the provided field, suggest them, + * sorted by how often the type is referenced. + */ +function getSuggestedTypeNames(schema, type, fieldName) { + if (!isAbstractType(type)) { + // Must be an Object type, which does not have possible fields. + return []; + } + const suggestedTypes = new Set(); + const usageCount = Object.create(null); + for (const possibleType of schema.getPossibleTypes(type)) { + if (possibleType.getFields()[fieldName] == null) { + continue; + } + // This object type defines this field. + suggestedTypes.add(possibleType); + usageCount[possibleType.name] = 1; + for (const possibleInterface of possibleType.getInterfaces()) { + if (possibleInterface.getFields()[fieldName] == null) { + continue; + } + // This interface type defines this field. + suggestedTypes.add(possibleInterface); + usageCount[possibleInterface.name] = + (usageCount[possibleInterface.name] ?? 0) + 1; + } + } + return [...suggestedTypes] + .sort((typeA, typeB) => { + // Suggest both interface and object types based on how common they are. + const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; + if (usageCountDiff !== 0) { + return usageCountDiff; + } + // Suggest super types first followed by subtypes + if (isInterfaceType(typeA) && schema.isSubType(typeA, typeB)) { + return -1; + } + if (isInterfaceType(typeB) && schema.isSubType(typeB, typeA)) { + return 1; + } + return naturalCompare(typeA.name, typeB.name); + }) + .map((x) => x.name); +} +/** + * For the field name provided, determine if there are any similar field names + * that may be the result of a typo. + */ +function getSuggestedFieldNames(type, fieldName) { + if (isObjectType(type) || isInterfaceType(type)) { + const possibleFieldNames = Object.keys(type.getFields()); + return suggestionList(fieldName, possibleFieldNames); + } + // Otherwise, must be a Union type, which does not define fields. + return []; +} +//# sourceMappingURL=FieldsOnCorrectTypeRule.js.map \ No newline at end of file diff --git a/validation/rules/FieldsOnCorrectTypeRule.mjs.map b/validation/rules/FieldsOnCorrectTypeRule.mjs.map new file mode 100644 index 0000000000..247f635ef3 --- /dev/null +++ b/validation/rules/FieldsOnCorrectTypeRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"FieldsOnCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/FieldsOnCorrectTypeRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qCAAoC;AACzD,OAAO,EAAE,cAAc,EAAE,yCAAwC;AACjE,OAAO,EAAE,cAAc,EAAE,yCAAwC;AAEjE,OA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,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;YAC7D,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;QACD,IAAI,eAAe,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;YAC7D,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAC7B,IAAuB,EACvB,SAAiB;IAEjB,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QACzD,OAAO,cAAc,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACvD,CAAC;IACD,iEAAiE;IACjE,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { naturalCompare } from '../../jsutils/naturalCompare.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FieldNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type {\n GraphQLInterfaceType,\n GraphQLObjectType,\n GraphQLOutputType,\n} from '../../type/definition.js';\nimport {\n isAbstractType,\n isInterfaceType,\n isObjectType,\n} from '../../type/definition.js';\nimport type { GraphQLSchema } from '../../type/schema.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Fields on correct type\n *\n * A GraphQL document is only valid if all fields selected are defined by the\n * parent type, or are an allowed meta field such as __typename.\n *\n * See https://spec.graphql.org/draft/#sec-Field-Selections\n */\nexport function FieldsOnCorrectTypeRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Field(node: FieldNode) {\n const type = context.getParentType();\n if (type) {\n const fieldDef = context.getFieldDef();\n if (!fieldDef) {\n // This field doesn't exist, lets look for suggestions.\n const schema = context.getSchema();\n const fieldName = node.name.value;\n\n // First determine if there are any suggested types to condition on.\n let suggestion = didYouMean(\n 'to use an inline fragment on',\n context.hideSuggestions\n ? []\n : getSuggestedTypeNames(schema, type, fieldName),\n );\n\n // If there are no suggested types, then perhaps this was a typo?\n if (suggestion === '') {\n suggestion = didYouMean(\n context.hideSuggestions\n ? []\n : getSuggestedFieldNames(type, fieldName),\n );\n }\n\n // Report an error, including helpful suggestions.\n context.reportError(\n new GraphQLError(\n `Cannot query field \"${fieldName}\" on type \"${type}\".` +\n suggestion,\n { nodes: node },\n ),\n );\n }\n }\n },\n };\n}\n\n/**\n * Go through all of the implementations of type, as well as the interfaces that\n * they implement. If any of those types include the provided field, suggest them,\n * sorted by how often the type is referenced.\n */\nfunction getSuggestedTypeNames(\n schema: GraphQLSchema,\n type: GraphQLOutputType,\n fieldName: string,\n): Array {\n if (!isAbstractType(type)) {\n // Must be an Object type, which does not have possible fields.\n return [];\n }\n\n const suggestedTypes = new Set();\n const usageCount = Object.create(null);\n for (const possibleType of schema.getPossibleTypes(type)) {\n if (possibleType.getFields()[fieldName] == null) {\n continue;\n }\n\n // This object type defines this field.\n suggestedTypes.add(possibleType);\n usageCount[possibleType.name] = 1;\n\n for (const possibleInterface of possibleType.getInterfaces()) {\n if (possibleInterface.getFields()[fieldName] == null) {\n continue;\n }\n\n // This interface type defines this field.\n suggestedTypes.add(possibleInterface);\n usageCount[possibleInterface.name] =\n (usageCount[possibleInterface.name] ?? 0) + 1;\n }\n }\n\n return [...suggestedTypes]\n .sort((typeA, typeB) => {\n // Suggest both interface and object types based on how common they are.\n const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name];\n if (usageCountDiff !== 0) {\n return usageCountDiff;\n }\n\n // Suggest super types first followed by subtypes\n if (isInterfaceType(typeA) && schema.isSubType(typeA, typeB)) {\n return -1;\n }\n if (isInterfaceType(typeB) && schema.isSubType(typeB, typeA)) {\n return 1;\n }\n\n return naturalCompare(typeA.name, typeB.name);\n })\n .map((x) => x.name);\n}\n\n/**\n * For the field name provided, determine if there are any similar field names\n * that may be the result of a typo.\n */\nfunction getSuggestedFieldNames(\n type: GraphQLOutputType,\n fieldName: string,\n): Array {\n if (isObjectType(type) || isInterfaceType(type)) {\n const possibleFieldNames = Object.keys(type.getFields());\n return suggestionList(fieldName, possibleFieldNames);\n }\n // Otherwise, must be a Union type, which does not define fields.\n return [];\n}\n"]} \ No newline at end of file diff --git a/validation/rules/FragmentsOnCompositeTypesRule.d.ts b/validation/rules/FragmentsOnCompositeTypesRule.d.ts new file mode 100644 index 0000000000..d40b93ad69 --- /dev/null +++ b/validation/rules/FragmentsOnCompositeTypesRule.d.ts @@ -0,0 +1,12 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Fragments on composite type + * + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. + * + * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types + */ +export declare function FragmentsOnCompositeTypesRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/FragmentsOnCompositeTypesRule.js b/validation/rules/FragmentsOnCompositeTypesRule.js new file mode 100644 index 0000000000..6c610024f0 --- /dev/null +++ b/validation/rules/FragmentsOnCompositeTypesRule.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.FragmentsOnCompositeTypesRule = FragmentsOnCompositeTypesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const printer_js_1 = require("../../language/printer.js"); +const definition_js_1 = require("../../type/definition.js"); +const typeFromAST_js_1 = require("../../utilities/typeFromAST.js"); +/** + * Fragments on composite type + * + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. + * + * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types + */ +function FragmentsOnCompositeTypesRule(context) { + return { + InlineFragment(node) { + const typeCondition = node.typeCondition; + if (typeCondition) { + const type = (0, typeFromAST_js_1.typeFromAST)(context.getSchema(), typeCondition); + if (type && !(0, definition_js_1.isCompositeType)(type)) { + const typeStr = (0, printer_js_1.print)(typeCondition); + context.reportError(new GraphQLError_js_1.GraphQLError(`Fragment cannot condition on non composite type "${typeStr}".`, { nodes: typeCondition })); + } + } + }, + FragmentDefinition(node) { + const type = (0, typeFromAST_js_1.typeFromAST)(context.getSchema(), node.typeCondition); + if (type && !(0, definition_js_1.isCompositeType)(type)) { + const typeStr = (0, printer_js_1.print)(node.typeCondition); + context.reportError(new GraphQLError_js_1.GraphQLError(`Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, { nodes: node.typeCondition })); + } + }, + }; +} +//# sourceMappingURL=FragmentsOnCompositeTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/FragmentsOnCompositeTypesRule.js.map b/validation/rules/FragmentsOnCompositeTypesRule.js.map new file mode 100644 index 0000000000..4df46e5218 --- /dev/null +++ b/validation/rules/FragmentsOnCompositeTypesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FragmentsOnCompositeTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/FragmentsOnCompositeTypesRule.ts"],"names":[],"mappings":";;AAoBA,sEAgCC;AApDD,iEAA2D;AAE3D,0DAAkD;AAGlD,4DAA2D;AAE3D,mEAA6D;AAI7D;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CAC3C,OAA0B;IAE1B,OAAO;QACL,cAAc,CAAC,IAAI;YACjB,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;YACzC,IAAI,aAAa,EAAE,CAAC;gBAClB,MAAM,IAAI,GAAG,IAAA,4BAAW,EAAC,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;gBAC7D,IAAI,IAAI,IAAI,CAAC,IAAA,+BAAe,EAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,MAAM,OAAO,GAAG,IAAA,kBAAK,EAAC,aAAa,CAAC,CAAC;oBACrC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,oDAAoD,OAAO,IAAI,EAC/D,EAAE,KAAK,EAAE,aAAa,EAAE,CACzB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,kBAAkB,CAAC,IAAI;YACrB,MAAM,IAAI,GAAG,IAAA,4BAAW,EAAC,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAClE,IAAI,IAAI,IAAI,CAAC,IAAA,+BAAe,EAAC,IAAI,CAAC,EAAE,CAAC;gBACnC,MAAM,OAAO,GAAG,IAAA,kBAAK,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAC1C,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,aAAa,IAAI,CAAC,IAAI,CAAC,KAAK,6CAA6C,OAAO,IAAI,EACpF,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,CAC9B,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isCompositeType } from '../../type/definition.js';\n\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Fragments on composite type\n *\n * Fragments use a type condition to determine if they apply, since fragments\n * can only be spread into a composite type (object, interface, or union), the\n * type condition must also be a composite type.\n *\n * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types\n */\nexport function FragmentsOnCompositeTypesRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n InlineFragment(node) {\n const typeCondition = node.typeCondition;\n if (typeCondition) {\n const type = typeFromAST(context.getSchema(), typeCondition);\n if (type && !isCompositeType(type)) {\n const typeStr = print(typeCondition);\n context.reportError(\n new GraphQLError(\n `Fragment cannot condition on non composite type \"${typeStr}\".`,\n { nodes: typeCondition },\n ),\n );\n }\n }\n },\n FragmentDefinition(node) {\n const type = typeFromAST(context.getSchema(), node.typeCondition);\n if (type && !isCompositeType(type)) {\n const typeStr = print(node.typeCondition);\n context.reportError(\n new GraphQLError(\n `Fragment \"${node.name.value}\" cannot condition on non composite type \"${typeStr}\".`,\n { nodes: node.typeCondition },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/FragmentsOnCompositeTypesRule.mjs b/validation/rules/FragmentsOnCompositeTypesRule.mjs new file mode 100644 index 0000000000..1c71241f0c --- /dev/null +++ b/validation/rules/FragmentsOnCompositeTypesRule.mjs @@ -0,0 +1,35 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { print } from "../../language/printer.mjs"; +import { isCompositeType } from "../../type/definition.mjs"; +import { typeFromAST } from "../../utilities/typeFromAST.mjs"; +/** + * Fragments on composite type + * + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. + * + * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types + */ +export function FragmentsOnCompositeTypesRule(context) { + return { + InlineFragment(node) { + const typeCondition = node.typeCondition; + if (typeCondition) { + const type = typeFromAST(context.getSchema(), typeCondition); + if (type && !isCompositeType(type)) { + const typeStr = print(typeCondition); + context.reportError(new GraphQLError(`Fragment cannot condition on non composite type "${typeStr}".`, { nodes: typeCondition })); + } + } + }, + FragmentDefinition(node) { + const type = typeFromAST(context.getSchema(), node.typeCondition); + if (type && !isCompositeType(type)) { + const typeStr = print(node.typeCondition); + context.reportError(new GraphQLError(`Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, { nodes: node.typeCondition })); + } + }, + }; +} +//# sourceMappingURL=FragmentsOnCompositeTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/FragmentsOnCompositeTypesRule.mjs.map b/validation/rules/FragmentsOnCompositeTypesRule.mjs.map new file mode 100644 index 0000000000..3391d4b5ac --- /dev/null +++ b/validation/rules/FragmentsOnCompositeTypesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"FragmentsOnCompositeTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/FragmentsOnCompositeTypesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAE3D,OAAO,EAAE,KAAK,EAAE,mCAAkC;AAGlD,OAAO,EAAE,eAAe,EAAE,kCAAiC;AAE3D,OAAO,EAAE,WAAW,EAAE,wCAAuC;AAI7D;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAA0B;IAE1B,OAAO;QACL,cAAc,CAAC,IAAI;YACjB,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;YACzC,IAAI,aAAa,EAAE,CAAC;gBAClB,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;gBAC7D,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;oBACrC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,oDAAoD,OAAO,IAAI,EAC/D,EAAE,KAAK,EAAE,aAAa,EAAE,CACzB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,kBAAkB,CAAC,IAAI;YACrB,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAClE,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAC1C,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,IAAI,CAAC,IAAI,CAAC,KAAK,6CAA6C,OAAO,IAAI,EACpF,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,CAC9B,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isCompositeType } from '../../type/definition.js';\n\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Fragments on composite type\n *\n * Fragments use a type condition to determine if they apply, since fragments\n * can only be spread into a composite type (object, interface, or union), the\n * type condition must also be a composite type.\n *\n * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types\n */\nexport function FragmentsOnCompositeTypesRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n InlineFragment(node) {\n const typeCondition = node.typeCondition;\n if (typeCondition) {\n const type = typeFromAST(context.getSchema(), typeCondition);\n if (type && !isCompositeType(type)) {\n const typeStr = print(typeCondition);\n context.reportError(\n new GraphQLError(\n `Fragment cannot condition on non composite type \"${typeStr}\".`,\n { nodes: typeCondition },\n ),\n );\n }\n }\n },\n FragmentDefinition(node) {\n const type = typeFromAST(context.getSchema(), node.typeCondition);\n if (type && !isCompositeType(type)) {\n const typeStr = print(node.typeCondition);\n context.reportError(\n new GraphQLError(\n `Fragment \"${node.name.value}\" cannot condition on non composite type \"${typeStr}\".`,\n { nodes: node.typeCondition },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownArgumentNamesRule.d.ts b/validation/rules/KnownArgumentNamesRule.d.ts new file mode 100644 index 0000000000..88e1538bb5 --- /dev/null +++ b/validation/rules/KnownArgumentNamesRule.d.ts @@ -0,0 +1,16 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext, ValidationContext } from '../ValidationContext.js'; +/** + * Known argument names + * + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations + */ +export declare function KnownArgumentNamesRule(context: ValidationContext): ASTVisitor; +/** + * @internal + */ +export declare function KnownArgumentNamesOnDirectivesRule(context: ValidationContext | SDLValidationContext): ASTVisitor; diff --git a/validation/rules/KnownArgumentNamesRule.js b/validation/rules/KnownArgumentNamesRule.js new file mode 100644 index 0000000000..8f0af306c1 --- /dev/null +++ b/validation/rules/KnownArgumentNamesRule.js @@ -0,0 +1,88 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KnownArgumentNamesRule = KnownArgumentNamesRule; +exports.KnownArgumentNamesOnDirectivesRule = KnownArgumentNamesOnDirectivesRule; +const didYouMean_js_1 = require("../../jsutils/didYouMean.js"); +const suggestionList_js_1 = require("../../jsutils/suggestionList.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const directives_js_1 = require("../../type/directives.js"); +/** + * Known argument names + * + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations + */ +function KnownArgumentNamesRule(context) { + return { + // eslint-disable-next-line new-cap + ...KnownArgumentNamesOnDirectivesRule(context), + FragmentArgument(argNode) { + const fragmentSignature = context.getFragmentSignature(); + if (fragmentSignature) { + const varDef = fragmentSignature.variableDefinitions.get(argNode.name.value); + if (!varDef) { + const argName = argNode.name.value; + const suggestions = context.hideSuggestions + ? [] + : (0, suggestionList_js_1.suggestionList)(argName, Array.from(fragmentSignature.variableDefinitions.values()).map((varSignature) => varSignature.variable.name.value)); + context.reportError(new GraphQLError_js_1.GraphQLError(`Unknown argument "${argName}" on fragment "${fragmentSignature.definition.name.value}".` + + (0, didYouMean_js_1.didYouMean)(suggestions), { nodes: argNode })); + } + } + }, + Argument(argNode) { + const argDef = context.getArgument(); + const fieldDef = context.getFieldDef(); + if (!argDef && fieldDef) { + const argName = argNode.name.value; + const suggestions = context.hideSuggestions + ? [] + : (0, suggestionList_js_1.suggestionList)(argName, fieldDef.args.map((arg) => arg.name)); + context.reportError(new GraphQLError_js_1.GraphQLError(`Unknown argument "${argName}" on field "${fieldDef}".` + + (0, didYouMean_js_1.didYouMean)(suggestions), { nodes: argNode })); + } + }, + }; +} +/** + * @internal + */ +function KnownArgumentNamesOnDirectivesRule(context) { + const directiveArgs = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : directives_js_1.specifiedDirectives; + for (const directive of definedDirectives) { + directiveArgs.set(directive.name, directive.args.map((arg) => arg.name)); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === kinds_js_1.Kind.DIRECTIVE_DEFINITION) { + const argsNodes = def.arguments ?? []; + directiveArgs.set(def.name.value, argsNodes.map((arg) => arg.name.value)); + } + } + return { + Directive(directiveNode) { + const directiveName = directiveNode.name.value; + const knownArgs = directiveArgs.get(directiveName); + if (directiveNode.arguments != null && knownArgs != null) { + for (const argNode of directiveNode.arguments) { + const argName = argNode.name.value; + if (!knownArgs.includes(argName)) { + const suggestions = (0, suggestionList_js_1.suggestionList)(argName, knownArgs); + context.reportError(new GraphQLError_js_1.GraphQLError(`Unknown argument "${argName}" on directive "@${directiveName}".` + + (context.hideSuggestions ? '' : (0, didYouMean_js_1.didYouMean)(suggestions)), { nodes: argNode })); + } + } + } + return false; + }, + }; +} +//# sourceMappingURL=KnownArgumentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownArgumentNamesRule.js.map b/validation/rules/KnownArgumentNamesRule.js.map new file mode 100644 index 0000000000..adfa2d22b5 --- /dev/null +++ b/validation/rules/KnownArgumentNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownArgumentNamesRule.ts"],"names":[],"mappings":";;AAwBA,wDAoDC;AAKD,gFAoDC;AArID,+DAAyD;AACzD,uEAAiE;AAEjE,iEAA2D;AAE3D,sDAA+C;AAG/C,4DAA+D;AAO/D;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CAAC,OAA0B;IAC/D,OAAO;QACL,mCAAmC;QACnC,GAAG,kCAAkC,CAAC,OAAO,CAAC;QAC9C,gBAAgB,CAAC,OAAO;YACtB,MAAM,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;YACzD,IAAI,iBAAiB,EAAE,CAAC;gBACtB,MAAM,MAAM,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,CACtD,OAAO,CAAC,IAAI,CAAC,KAAK,CACnB,CAAC;gBACF,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;oBACnC,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe;wBACzC,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC,IAAA,kCAAc,EACZ,OAAO,EACP,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAC5D,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CACnD,CACF,CAAC;oBACN,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,qBAAqB,OAAO,kBAAkB,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI;wBACvF,IAAA,0BAAU,EAAC,WAAW,CAAC,EACzB,EAAE,KAAK,EAAE,O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AAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Known argument names\n *\n * A GraphQL field is only valid if all supplied arguments are defined by\n * that field.\n *\n * See https://spec.graphql.org/draft/#sec-Argument-Names\n * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations\n */\nexport function KnownArgumentNamesRule(context: ValidationContext): ASTVisitor {\n return {\n // eslint-disable-next-line new-cap\n ...KnownArgumentNamesOnDirectivesRule(context),\n FragmentArgument(argNode) {\n const fragmentSignature = context.getFragmentSignature();\n if (fragmentSignature) {\n const varDef = fragmentSignature.variableDefinitions.get(\n argNode.name.value,\n );\n if (!varDef) {\n const argName = argNode.name.value;\n const suggestions = context.hideSuggestions\n ? []\n : suggestionList(\n argName,\n Array.from(fragmentSignature.variableDefinitions.values()).map(\n (varSignature) => varSignature.variable.name.value,\n ),\n );\n context.reportError(\n new GraphQLError(\n `Unknown argument \"${argName}\" on fragment \"${fragmentSignature.definition.name.value}\".` +\n didYouMean(suggestions),\n { nodes: argNode },\n ),\n );\n }\n }\n },\n Argument(argNode) {\n const argDef = context.getArgument();\n const fieldDef = context.getFieldDef();\n\n if (!argDef && fieldDef) {\n const argName = argNode.name.value;\n const suggestions = context.hideSuggestions\n ? []\n : suggestionList(\n argName,\n fieldDef.args.map((arg) => arg.name),\n );\n context.reportError(\n new GraphQLError(\n `Unknown argument \"${argName}\" on field \"${fieldDef}\".` +\n didYouMean(suggestions),\n { nodes: argNode },\n ),\n );\n }\n },\n };\n}\n\n/**\n * @internal\n */\nexport function KnownArgumentNamesOnDirectivesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const directiveArgs = new Map>();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n directiveArgs.set(\n directive.name,\n directive.args.map((arg) => arg.name),\n );\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n const argsNodes = def.arguments ?? [];\n\n directiveArgs.set(\n def.name.value,\n argsNodes.map((arg) => arg.name.value),\n );\n }\n }\n\n return {\n Directive(directiveNode) {\n const directiveName = directiveNode.name.value;\n const knownArgs = directiveArgs.get(directiveName);\n\n if (directiveNode.arguments != null && knownArgs != null) {\n for (const argNode of directiveNode.arguments) {\n const argName = argNode.name.value;\n if (!knownArgs.includes(argName)) {\n const suggestions = suggestionList(argName, knownArgs);\n context.reportError(\n new GraphQLError(\n `Unknown argument \"${argName}\" on directive \"@${directiveName}\".` +\n (context.hideSuggestions ? '' : didYouMean(suggestions)),\n { nodes: argNode },\n ),\n );\n }\n }\n }\n\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownArgumentNamesRule.mjs b/validation/rules/KnownArgumentNamesRule.mjs new file mode 100644 index 0000000000..a52d4865ea --- /dev/null +++ b/validation/rules/KnownArgumentNamesRule.mjs @@ -0,0 +1,84 @@ +import { didYouMean } from "../../jsutils/didYouMean.mjs"; +import { suggestionList } from "../../jsutils/suggestionList.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { specifiedDirectives } from "../../type/directives.mjs"; +/** + * Known argument names + * + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations + */ +export function KnownArgumentNamesRule(context) { + return { + // eslint-disable-next-line new-cap + ...KnownArgumentNamesOnDirectivesRule(context), + FragmentArgument(argNode) { + const fragmentSignature = context.getFragmentSignature(); + if (fragmentSignature) { + const varDef = fragmentSignature.variableDefinitions.get(argNode.name.value); + if (!varDef) { + const argName = argNode.name.value; + const suggestions = context.hideSuggestions + ? [] + : suggestionList(argName, Array.from(fragmentSignature.variableDefinitions.values()).map((varSignature) => varSignature.variable.name.value)); + context.reportError(new GraphQLError(`Unknown argument "${argName}" on fragment "${fragmentSignature.definition.name.value}".` + + didYouMean(suggestions), { nodes: argNode })); + } + } + }, + Argument(argNode) { + const argDef = context.getArgument(); + const fieldDef = context.getFieldDef(); + if (!argDef && fieldDef) { + const argName = argNode.name.value; + const suggestions = context.hideSuggestions + ? [] + : suggestionList(argName, fieldDef.args.map((arg) => arg.name)); + context.reportError(new GraphQLError(`Unknown argument "${argName}" on field "${fieldDef}".` + + didYouMean(suggestions), { nodes: argNode })); + } + }, + }; +} +/** + * @internal + */ +export function KnownArgumentNamesOnDirectivesRule(context) { + const directiveArgs = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : specifiedDirectives; + for (const directive of definedDirectives) { + directiveArgs.set(directive.name, directive.args.map((arg) => arg.name)); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === Kind.DIRECTIVE_DEFINITION) { + const argsNodes = def.arguments ?? []; + directiveArgs.set(def.name.value, argsNodes.map((arg) => arg.name.value)); + } + } + return { + Directive(directiveNode) { + const directiveName = directiveNode.name.value; + const knownArgs = directiveArgs.get(directiveName); + if (directiveNode.arguments != null && knownArgs != null) { + for (const argNode of directiveNode.arguments) { + const argName = argNode.name.value; + if (!knownArgs.includes(argName)) { + const suggestions = suggestionList(argName, knownArgs); + context.reportError(new GraphQLError(`Unknown argument "${argName}" on directive "@${directiveName}".` + + (context.hideSuggestions ? '' : didYouMean(suggestions)), { nodes: argNode })); + } + } + } + return false; + }, + }; +} +//# sourceMappingURL=KnownArgumentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownArgumentNamesRule.mjs.map b/validation/rules/KnownArgumentNamesRule.mjs.map new file mode 100644 index 0000000000..1cdf2a5f3e --- /dev/null +++ b/validation/rules/KnownArgumentNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownArgumentNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qCAAoC;AACzD,OAAO,EAAE,cAAc,EAAE,yCAAwC;AAEjE,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAE3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAG/C,OAAO,EAAE,mBAAmB,EAAE,kCAAiC;AAO/D;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA0B;IAC/D,OAAO;QACL,mCAAmC;QACnC,GAAG,kCAAkC,CAAC,OAAO,CAAC;QAC9C,gBAAgB,CAAC,OAAO;YACtB,MAAM,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;YACzD,IAAI,iBAAiB,EAAE,CAAC;gBACtB,MAAM,MAAM,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,CACtD,OAAO,CAAC,IAAI,CAAC,KAAK,CACnB,CAAC;gBACF,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;oBACnC,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe;wBACzC,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC,cAAc,CACZ,OAAO,EACP,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAC5D,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CACnD,CACF,CAAC;oBACN,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,qBAAqB,OAAO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,KAAK,EAAE,OAAO,EAAE,CACnB,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Known argument names\n *\n * A GraphQL field is only valid if all supplied arguments are defined by\n * that field.\n *\n * See https://spec.graphql.org/draft/#sec-Argument-Names\n * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations\n */\nexport function KnownArgumentNamesRule(context: ValidationContext): ASTVisitor {\n return {\n // eslint-disable-next-line new-cap\n ...KnownArgumentNamesOnDirectivesRule(context),\n FragmentArgument(argNode) {\n const fragmentSignature = context.getFragmentSignature();\n if (fragmentSignature) {\n const varDef = fragmentSignature.variableDefinitions.get(\n argNode.name.value,\n );\n if (!varDef) {\n const argName = argNode.name.value;\n const suggestions = context.hideSuggestions\n ? []\n : suggestionList(\n argName,\n Array.from(fragmentSignature.variableDefinitions.values()).map(\n (varSignature) => varSignature.variable.name.value,\n ),\n );\n context.reportError(\n new GraphQLError(\n `Unknown argument \"${argName}\" on fragment \"${fragmentSignature.definition.name.value}\".` +\n didYouMean(suggestions),\n { nodes: argNode },\n ),\n );\n }\n }\n },\n Argument(argNode) {\n const argDef = context.getArgument();\n const fieldDef = context.getFieldDef();\n\n if (!argDef && fieldDef) {\n const argName = argNode.name.value;\n const suggestions = context.hideSuggestions\n ? []\n : suggestionList(\n argName,\n fieldDef.args.map((arg) => arg.name),\n );\n context.reportError(\n new GraphQLError(\n `Unknown argument \"${argName}\" on field \"${fieldDef}\".` +\n didYouMean(suggestions),\n { nodes: argNode },\n ),\n );\n }\n },\n };\n}\n\n/**\n * @internal\n */\nexport function KnownArgumentNamesOnDirectivesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const directiveArgs = new Map>();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n directiveArgs.set(\n directive.name,\n directive.args.map((arg) => arg.name),\n );\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n const argsNodes = def.arguments ?? [];\n\n directiveArgs.set(\n def.name.value,\n argsNodes.map((arg) => arg.name.value),\n );\n }\n }\n\n return {\n Directive(directiveNode) {\n const directiveName = directiveNode.name.value;\n const knownArgs = directiveArgs.get(directiveName);\n\n if (directiveNode.arguments != null && knownArgs != null) {\n for (const argNode of directiveNode.arguments) {\n const argName = argNode.name.value;\n if (!knownArgs.includes(argName)) {\n const suggestions = suggestionList(argName, knownArgs);\n context.reportError(\n new GraphQLError(\n `Unknown argument \"${argName}\" on directive \"@${directiveName}\".` +\n (context.hideSuggestions ? '' : didYouMean(suggestions)),\n { nodes: argNode },\n ),\n );\n }\n }\n }\n\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownDirectivesRule.d.ts b/validation/rules/KnownDirectivesRule.d.ts new file mode 100644 index 0000000000..92528aae66 --- /dev/null +++ b/validation/rules/KnownDirectivesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext, ValidationContext } from '../ValidationContext.js'; +/** + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined + */ +export declare function KnownDirectivesRule(context: ValidationContext | SDLValidationContext): ASTVisitor; diff --git a/validation/rules/KnownDirectivesRule.js b/validation/rules/KnownDirectivesRule.js new file mode 100644 index 0000000000..557b03f62c --- /dev/null +++ b/validation/rules/KnownDirectivesRule.js @@ -0,0 +1,118 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KnownDirectivesRule = KnownDirectivesRule; +const inspect_js_1 = require("../../jsutils/inspect.js"); +const invariant_js_1 = require("../../jsutils/invariant.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const ast_js_1 = require("../../language/ast.js"); +const directiveLocation_js_1 = require("../../language/directiveLocation.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const directives_js_1 = require("../../type/directives.js"); +/** + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined + */ +function KnownDirectivesRule(context) { + const locationsMap = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : directives_js_1.specifiedDirectives; + for (const directive of definedDirectives) { + locationsMap.set(directive.name, directive.locations); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === kinds_js_1.Kind.DIRECTIVE_DEFINITION) { + locationsMap.set(def.name.value, def.locations.map((name) => name.value)); + } + } + return { + Directive(node, _key, _parent, _path, ancestors) { + const name = node.name.value; + const locations = locationsMap.get(name); + if (locations == null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Unknown directive "@${name}".`, { nodes: node })); + return; + } + const candidateLocation = getDirectiveLocationForASTPath(ancestors); + if (candidateLocation != null && !locations.includes(candidateLocation)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Directive "@${name}" may not be used on ${candidateLocation}.`, { nodes: node })); + } + }, + }; +} +function getDirectiveLocationForASTPath(ancestors) { + const appliedTo = ancestors.at(-1); + (appliedTo != null && 'kind' in appliedTo) || (0, invariant_js_1.invariant)(false); + switch (appliedTo.kind) { + case kinds_js_1.Kind.OPERATION_DEFINITION: + return getDirectiveLocationForOperation(appliedTo.operation); + case kinds_js_1.Kind.FIELD: + return directiveLocation_js_1.DirectiveLocation.FIELD; + case kinds_js_1.Kind.FRAGMENT_SPREAD: + return directiveLocation_js_1.DirectiveLocation.FRAGMENT_SPREAD; + case kinds_js_1.Kind.INLINE_FRAGMENT: + return directiveLocation_js_1.DirectiveLocation.INLINE_FRAGMENT; + case kinds_js_1.Kind.FRAGMENT_DEFINITION: + return directiveLocation_js_1.DirectiveLocation.FRAGMENT_DEFINITION; + case kinds_js_1.Kind.VARIABLE_DEFINITION: { + const parentNode = ancestors[ancestors.length - 3]; + ('kind' in parentNode) || (0, invariant_js_1.invariant)(false); + return parentNode.kind === kinds_js_1.Kind.OPERATION_DEFINITION + ? directiveLocation_js_1.DirectiveLocation.VARIABLE_DEFINITION + : directiveLocation_js_1.DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION; + } + case kinds_js_1.Kind.SCHEMA_DEFINITION: + case kinds_js_1.Kind.SCHEMA_EXTENSION: + return directiveLocation_js_1.DirectiveLocation.SCHEMA; + case kinds_js_1.Kind.SCALAR_TYPE_DEFINITION: + case kinds_js_1.Kind.SCALAR_TYPE_EXTENSION: + return directiveLocation_js_1.DirectiveLocation.SCALAR; + case kinds_js_1.Kind.OBJECT_TYPE_DEFINITION: + case kinds_js_1.Kind.OBJECT_TYPE_EXTENSION: + return directiveLocation_js_1.DirectiveLocation.OBJECT; + case kinds_js_1.Kind.FIELD_DEFINITION: + return directiveLocation_js_1.DirectiveLocation.FIELD_DEFINITION; + case kinds_js_1.Kind.INTERFACE_TYPE_DEFINITION: + case kinds_js_1.Kind.INTERFACE_TYPE_EXTENSION: + return directiveLocation_js_1.DirectiveLocation.INTERFACE; + case kinds_js_1.Kind.UNION_TYPE_DEFINITION: + case kinds_js_1.Kind.UNION_TYPE_EXTENSION: + return directiveLocation_js_1.DirectiveLocation.UNION; + case kinds_js_1.Kind.ENUM_TYPE_DEFINITION: + case kinds_js_1.Kind.ENUM_TYPE_EXTENSION: + return directiveLocation_js_1.DirectiveLocation.ENUM; + case kinds_js_1.Kind.ENUM_VALUE_DEFINITION: + return directiveLocation_js_1.DirectiveLocation.ENUM_VALUE; + case kinds_js_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: + case kinds_js_1.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return directiveLocation_js_1.DirectiveLocation.INPUT_OBJECT; + case kinds_js_1.Kind.INPUT_VALUE_DEFINITION: { + const parentNode = ancestors.at(-3); + (parentNode != null && 'kind' in parentNode) || (0, invariant_js_1.invariant)(false); + return parentNode.kind === kinds_js_1.Kind.INPUT_OBJECT_TYPE_DEFINITION + ? directiveLocation_js_1.DirectiveLocation.INPUT_FIELD_DEFINITION + : directiveLocation_js_1.DirectiveLocation.ARGUMENT_DEFINITION; + } + // Not reachable, all possible types have been considered. + /* c8 ignore next 2 */ + default: + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected kind: ' + (0, inspect_js_1.inspect)(appliedTo.kind)); + } +} +function getDirectiveLocationForOperation(operation) { + switch (operation) { + case ast_js_1.OperationTypeNode.QUERY: + return directiveLocation_js_1.DirectiveLocation.QUERY; + case ast_js_1.OperationTypeNode.MUTATION: + return directiveLocation_js_1.DirectiveLocation.MUTATION; + case ast_js_1.OperationTypeNode.SUBSCRIPTION: + return directiveLocation_js_1.DirectiveLocation.SUBSCRIPTION; + } +} +//# sourceMappingURL=KnownDirectivesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownDirectivesRule.js.map b/validation/rules/KnownDirectivesRule.js.map new file mode 100644 index 0000000000..41a4462e1d --- /dev/null +++ b/validation/rules/KnownDirectivesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownDirectivesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownDirectivesRule.ts"],"names":[],"mappings":";;AA0BA,kDA8CC;AAxED,yDAAmD;AACnD,6DAAuD;AAEvD,iEAA2D;AAG3D,kDAA0D;AAC1D,8EAAwE;AACxE,sDAA+C;AAG/C,4DAA+D;AAO/D;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,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AAC;QACD,0DAA0D;QAC1D,sBAAsB;QACtB;YACE,CAAU,KAAK,SAAf,wBAAS,SAAQ,mBAAmB,GAAG,IAAA,oBAAO,EAAC,SAAS,CAAC,IAAI,CAAC,EAAE;IACpE,CAAC;AACH,CAAC;AAED,SAAS,gCAAgC,CACvC,SAA4B;IAE5B,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,0BAAiB,CAAC,KAAK;YAC1B,OAAO,wCAAiB,CAAC,KAAK,CAAC;QACjC,KAAK,0BAAiB,CAAC,QAAQ;YAC7B,OAAO,wCAAiB,CAAC,QAAQ,CAAC;QACpC,KAAK,0BAAiB,CAAC,YAAY;YACjC,OAAO,wCAAiB,CAAC,YAAY,CAAC;IAC1C,CAAC;AACH,CAAC","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\nimport { invariant } from '../../jsutils/invariant.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTNode } from '../../language/ast.js';\nimport { OperationTypeNode } from '../../language/ast.js';\nimport { DirectiveLocation } from '../../language/directiveLocation.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Known directives\n *\n * A GraphQL document is only valid if all `@directives` are known by the\n * schema and legally positioned.\n *\n * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined\n */\nexport function KnownDirectivesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const locationsMap = new Map>();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n locationsMap.set(directive.name, directive.locations);\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n locationsMap.set(\n def.name.value,\n def.locations.map((name) => name.value),\n );\n }\n }\n\n return {\n Directive(node, _key, _parent, _path, ancestors) {\n const name = node.name.value;\n const locations = locationsMap.get(name);\n\n if (locations == null) {\n context.reportError(\n new GraphQLError(`Unknown directive \"@${name}\".`, { nodes: node }),\n );\n return;\n }\n\n const candidateLocation = getDirectiveLocationForASTPath(ancestors);\n if (candidateLocation != null && !locations.includes(candidateLocation)) {\n context.reportError(\n new GraphQLError(\n `Directive \"@${name}\" may not be used on ${candidateLocation}.`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n\nfunction getDirectiveLocationForASTPath(\n ancestors: ReadonlyArray>,\n): DirectiveLocation | undefined {\n const appliedTo = ancestors.at(-1);\n invariant(appliedTo != null && 'kind' in appliedTo);\n\n switch (appliedTo.kind) {\n case Kind.OPERATION_DEFINITION:\n return getDirectiveLocationForOperation(appliedTo.operation);\n case Kind.FIELD:\n return DirectiveLocation.FIELD;\n case Kind.FRAGMENT_SPREAD:\n return DirectiveLocation.FRAGMENT_SPREAD;\n case Kind.INLINE_FRAGMENT:\n return DirectiveLocation.INLINE_FRAGMENT;\n case Kind.FRAGMENT_DEFINITION:\n return DirectiveLocation.FRAGMENT_DEFINITION;\n case Kind.VARIABLE_DEFINITION: {\n const parentNode = ancestors[ancestors.length - 3];\n invariant('kind' in parentNode);\n return parentNode.kind === Kind.OPERATION_DEFINITION\n ? DirectiveLocation.VARIABLE_DEFINITION\n : DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION;\n }\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n return DirectiveLocation.SCHEMA;\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION:\n return DirectiveLocation.SCALAR;\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.OBJECT;\n case Kind.FIELD_DEFINITION:\n return DirectiveLocation.FIELD_DEFINITION;\n case Kind.INTERFACE_TYPE_DEFINITION:\n case Kind.INTERFACE_TYPE_EXTENSION:\n return DirectiveLocation.INTERFACE;\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION:\n return DirectiveLocation.UNION;\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION:\n return DirectiveLocation.ENUM;\n case Kind.ENUM_VALUE_DEFINITION:\n return DirectiveLocation.ENUM_VALUE;\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.INPUT_OBJECT;\n case Kind.INPUT_VALUE_DEFINITION: {\n const parentNode = ancestors.at(-3);\n invariant(parentNode != null && 'kind' in parentNode);\n return parentNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION\n ? DirectiveLocation.INPUT_FIELD_DEFINITION\n : DirectiveLocation.ARGUMENT_DEFINITION;\n }\n // Not reachable, all possible types have been considered.\n /* c8 ignore next 2 */\n default:\n invariant(false, 'Unexpected kind: ' + inspect(appliedTo.kind));\n }\n}\n\nfunction getDirectiveLocationForOperation(\n operation: OperationTypeNode,\n): DirectiveLocation {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return DirectiveLocation.QUERY;\n case OperationTypeNode.MUTATION:\n return DirectiveLocation.MUTATION;\n case OperationTypeNode.SUBSCRIPTION:\n return DirectiveLocation.SUBSCRIPTION;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownDirectivesRule.mjs b/validation/rules/KnownDirectivesRule.mjs new file mode 100644 index 0000000000..d178da5c5b --- /dev/null +++ b/validation/rules/KnownDirectivesRule.mjs @@ -0,0 +1,115 @@ +import { inspect } from "../../jsutils/inspect.mjs"; +import { invariant } from "../../jsutils/invariant.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { OperationTypeNode } from "../../language/ast.mjs"; +import { DirectiveLocation } from "../../language/directiveLocation.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { specifiedDirectives } from "../../type/directives.mjs"; +/** + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined + */ +export function KnownDirectivesRule(context) { + const locationsMap = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : specifiedDirectives; + for (const directive of definedDirectives) { + locationsMap.set(directive.name, directive.locations); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === Kind.DIRECTIVE_DEFINITION) { + locationsMap.set(def.name.value, def.locations.map((name) => name.value)); + } + } + return { + Directive(node, _key, _parent, _path, ancestors) { + const name = node.name.value; + const locations = locationsMap.get(name); + if (locations == null) { + context.reportError(new GraphQLError(`Unknown directive "@${name}".`, { nodes: node })); + return; + } + const candidateLocation = getDirectiveLocationForASTPath(ancestors); + if (candidateLocation != null && !locations.includes(candidateLocation)) { + context.reportError(new GraphQLError(`Directive "@${name}" may not be used on ${candidateLocation}.`, { nodes: node })); + } + }, + }; +} +function getDirectiveLocationForASTPath(ancestors) { + const appliedTo = ancestors.at(-1); + (appliedTo != null && 'kind' in appliedTo) || invariant(false); + switch (appliedTo.kind) { + case Kind.OPERATION_DEFINITION: + return getDirectiveLocationForOperation(appliedTo.operation); + case Kind.FIELD: + return DirectiveLocation.FIELD; + case Kind.FRAGMENT_SPREAD: + return DirectiveLocation.FRAGMENT_SPREAD; + case Kind.INLINE_FRAGMENT: + return DirectiveLocation.INLINE_FRAGMENT; + case Kind.FRAGMENT_DEFINITION: + return DirectiveLocation.FRAGMENT_DEFINITION; + case Kind.VARIABLE_DEFINITION: { + const parentNode = ancestors[ancestors.length - 3]; + ('kind' in parentNode) || invariant(false); + return parentNode.kind === Kind.OPERATION_DEFINITION + ? DirectiveLocation.VARIABLE_DEFINITION + : DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION; + } + case Kind.SCHEMA_DEFINITION: + case Kind.SCHEMA_EXTENSION: + return DirectiveLocation.SCHEMA; + case Kind.SCALAR_TYPE_DEFINITION: + case Kind.SCALAR_TYPE_EXTENSION: + return DirectiveLocation.SCALAR; + case Kind.OBJECT_TYPE_DEFINITION: + case Kind.OBJECT_TYPE_EXTENSION: + return DirectiveLocation.OBJECT; + case Kind.FIELD_DEFINITION: + return DirectiveLocation.FIELD_DEFINITION; + case Kind.INTERFACE_TYPE_DEFINITION: + case Kind.INTERFACE_TYPE_EXTENSION: + return DirectiveLocation.INTERFACE; + case Kind.UNION_TYPE_DEFINITION: + case Kind.UNION_TYPE_EXTENSION: + return DirectiveLocation.UNION; + case Kind.ENUM_TYPE_DEFINITION: + case Kind.ENUM_TYPE_EXTENSION: + return DirectiveLocation.ENUM; + case Kind.ENUM_VALUE_DEFINITION: + return DirectiveLocation.ENUM_VALUE; + case Kind.INPUT_OBJECT_TYPE_DEFINITION: + case Kind.INPUT_OBJECT_TYPE_EXTENSION: + return DirectiveLocation.INPUT_OBJECT; + case Kind.INPUT_VALUE_DEFINITION: { + const parentNode = ancestors.at(-3); + (parentNode != null && 'kind' in parentNode) || invariant(false); + return parentNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION + ? DirectiveLocation.INPUT_FIELD_DEFINITION + : DirectiveLocation.ARGUMENT_DEFINITION; + } + // Not reachable, all possible types have been considered. + /* c8 ignore next 2 */ + default: + (false) || invariant(false, 'Unexpected kind: ' + inspect(appliedTo.kind)); + } +} +function getDirectiveLocationForOperation(operation) { + switch (operation) { + case OperationTypeNode.QUERY: + return DirectiveLocation.QUERY; + case OperationTypeNode.MUTATION: + return DirectiveLocation.MUTATION; + case OperationTypeNode.SUBSCRIPTION: + return DirectiveLocation.SUBSCRIPTION; + } +} +//# sourceMappingURL=KnownDirectivesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownDirectivesRule.mjs.map b/validation/rules/KnownDirectivesRule.mjs.map new file mode 100644 index 0000000000..e47167214f --- /dev/null +++ b/validation/rules/KnownDirectivesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownDirectivesRule.js","sour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AAO,iBAAiB,CAAC,YAAY,CAAC;QACxC,KAAK,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;YACjC,MAAM,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,CAAU,UAAU,IAAI,IAAI,IAAI,MAAM,IAAI,UAAU,KAApD,SAAS,QAA6C;YACtD,OAAO,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,4BAA4B;gBAC1D,CAAC,CAAC,iBAAiB,CAAC,sBAAsB;gBAC1C,CAAC,CAAC,iBAAiB,CAAC,mBAAmB,CAAC;QAC5C,CAAC;QACD,0DAA0D;QAC1D,sBAAsB;QACtB;YACE,CAAU,KAAK,KAAf,SAAS,QAAQ,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;IACpE,CAAC;AACH,CAAC;AAED,SAAS,gCAAgC,CACvC,SAA4B;IAE5B,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,iBAAiB,CAAC,KAAK;YAC1B,OAAO,iBAAiB,CAAC,KAAK,CAAC;QACjC,KAAK,iBAAiB,CAAC,QAAQ;YAC7B,OAAO,iBAAiB,CAAC,QAAQ,CAAC;QACpC,KAAK,iBAAiB,CAAC,YAAY;YACjC,OAAO,iBAAiB,CAAC,YAAY,CAAC;IAC1C,CAAC;AACH,CAAC","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\nimport { invariant } from '../../jsutils/invariant.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTNode } from '../../language/ast.js';\nimport { OperationTypeNode } from '../../language/ast.js';\nimport { DirectiveLocation } from '../../language/directiveLocation.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Known directives\n *\n * A GraphQL document is only valid if all `@directives` are known by the\n * schema and legally positioned.\n *\n * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined\n */\nexport function KnownDirectivesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const locationsMap = new Map>();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n locationsMap.set(directive.name, directive.locations);\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n locationsMap.set(\n def.name.value,\n def.locations.map((name) => name.value),\n );\n }\n }\n\n return {\n Directive(node, _key, _parent, _path, ancestors) {\n const name = node.name.value;\n const locations = locationsMap.get(name);\n\n if (locations == null) {\n context.reportError(\n new GraphQLError(`Unknown directive \"@${name}\".`, { nodes: node }),\n );\n return;\n }\n\n const candidateLocation = getDirectiveLocationForASTPath(ancestors);\n if (candidateLocation != null && !locations.includes(candidateLocation)) {\n context.reportError(\n new GraphQLError(\n `Directive \"@${name}\" may not be used on ${candidateLocation}.`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n\nfunction getDirectiveLocationForASTPath(\n ancestors: ReadonlyArray>,\n): DirectiveLocation | undefined {\n const appliedTo = ancestors.at(-1);\n invariant(appliedTo != null && 'kind' in appliedTo);\n\n switch (appliedTo.kind) {\n case Kind.OPERATION_DEFINITION:\n return getDirectiveLocationForOperation(appliedTo.operation);\n case Kind.FIELD:\n return DirectiveLocation.FIELD;\n case Kind.FRAGMENT_SPREAD:\n return DirectiveLocation.FRAGMENT_SPREAD;\n case Kind.INLINE_FRAGMENT:\n return DirectiveLocation.INLINE_FRAGMENT;\n case Kind.FRAGMENT_DEFINITION:\n return DirectiveLocation.FRAGMENT_DEFINITION;\n case Kind.VARIABLE_DEFINITION: {\n const parentNode = ancestors[ancestors.length - 3];\n invariant('kind' in parentNode);\n return parentNode.kind === Kind.OPERATION_DEFINITION\n ? DirectiveLocation.VARIABLE_DEFINITION\n : DirectiveLocation.FRAGMENT_VARIABLE_DEFINITION;\n }\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n return DirectiveLocation.SCHEMA;\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION:\n return DirectiveLocation.SCALAR;\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.OBJECT;\n case Kind.FIELD_DEFINITION:\n return DirectiveLocation.FIELD_DEFINITION;\n case Kind.INTERFACE_TYPE_DEFINITION:\n case Kind.INTERFACE_TYPE_EXTENSION:\n return DirectiveLocation.INTERFACE;\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION:\n return DirectiveLocation.UNION;\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION:\n return DirectiveLocation.ENUM;\n case Kind.ENUM_VALUE_DEFINITION:\n return DirectiveLocation.ENUM_VALUE;\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.INPUT_OBJECT;\n case Kind.INPUT_VALUE_DEFINITION: {\n const parentNode = ancestors.at(-3);\n invariant(parentNode != null && 'kind' in parentNode);\n return parentNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION\n ? DirectiveLocation.INPUT_FIELD_DEFINITION\n : DirectiveLocation.ARGUMENT_DEFINITION;\n }\n // Not reachable, all possible types have been considered.\n /* c8 ignore next 2 */\n default:\n invariant(false, 'Unexpected kind: ' + inspect(appliedTo.kind));\n }\n}\n\nfunction getDirectiveLocationForOperation(\n operation: OperationTypeNode,\n): DirectiveLocation {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return DirectiveLocation.QUERY;\n case OperationTypeNode.MUTATION:\n return DirectiveLocation.MUTATION;\n case OperationTypeNode.SUBSCRIPTION:\n return DirectiveLocation.SUBSCRIPTION;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownFragmentNamesRule.d.ts b/validation/rules/KnownFragmentNamesRule.d.ts new file mode 100644 index 0000000000..5eb39f6252 --- /dev/null +++ b/validation/rules/KnownFragmentNamesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined + */ +export declare function KnownFragmentNamesRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/KnownFragmentNamesRule.js b/validation/rules/KnownFragmentNamesRule.js new file mode 100644 index 0000000000..5da03fe0b6 --- /dev/null +++ b/validation/rules/KnownFragmentNamesRule.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KnownFragmentNamesRule = KnownFragmentNamesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined + */ +function KnownFragmentNamesRule(context) { + return { + FragmentSpread(node) { + const fragmentName = node.name.value; + const fragment = context.getFragment(fragmentName); + if (!fragment) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Unknown fragment "${fragmentName}".`, { + nodes: node.name, + })); + } + }, + }; +} +//# sourceMappingURL=KnownFragmentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownFragmentNamesRule.js.map b/validation/rules/KnownFragmentNamesRule.js.map new file mode 100644 index 0000000000..160af2cf8e --- /dev/null +++ b/validation/rules/KnownFragmentNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownFragmentNamesRule.ts"],"names":[],"mappings":";;AAcA,wDAcC;AA5BD,iEAA2D;AAM3D;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAA0B;IAC/D,OAAO;QACL,cAAc,CAAC,IAAI;YACjB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CAAC,qBAAqB,YAAY,IAAI,EAAE;oBACtD,KAAK,EAAE,IAAI,CAAC,IAAI;iBACjB,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Known fragment names\n *\n * A GraphQL document is only valid if all `...Fragment` fragment spreads refer\n * to fragments defined in the same document.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined\n */\nexport function KnownFragmentNamesRule(context: ValidationContext): ASTVisitor {\n return {\n FragmentSpread(node) {\n const fragmentName = node.name.value;\n const fragment = context.getFragment(fragmentName);\n if (!fragment) {\n context.reportError(\n new GraphQLError(`Unknown fragment \"${fragmentName}\".`, {\n nodes: node.name,\n }),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownFragmentNamesRule.mjs b/validation/rules/KnownFragmentNamesRule.mjs new file mode 100644 index 0000000000..b0b4ff9a40 --- /dev/null +++ b/validation/rules/KnownFragmentNamesRule.mjs @@ -0,0 +1,23 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined + */ +export function KnownFragmentNamesRule(context) { + return { + FragmentSpread(node) { + const fragmentName = node.name.value; + const fragment = context.getFragment(fragmentName); + if (!fragment) { + context.reportError(new GraphQLError(`Unknown fragment "${fragmentName}".`, { + nodes: node.name, + })); + } + }, + }; +} +//# sourceMappingURL=KnownFragmentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownFragmentNamesRule.mjs.map b/validation/rules/KnownFragmentNamesRule.mjs.map new file mode 100644 index 0000000000..b742b57aa6 --- /dev/null +++ b/validation/rules/KnownFragmentNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownFragmentNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA0B;IAC/D,OAAO;QACL,cAAc,CAAC,IAAI;YACjB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CAAC,qBAAqB,YAAY,IAAI,EAAE;oBACtD,KAAK,EAAE,IAAI,CAAC,IAAI;iBACjB,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Known fragment names\n *\n * A GraphQL document is only valid if all `...Fragment` fragment spreads refer\n * to fragments defined in the same document.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined\n */\nexport function KnownFragmentNamesRule(context: ValidationContext): ASTVisitor {\n return {\n FragmentSpread(node) {\n const fragmentName = node.name.value;\n const fragment = context.getFragment(fragmentName);\n if (!fragment) {\n context.reportError(\n new GraphQLError(`Unknown fragment \"${fragmentName}\".`, {\n nodes: node.name,\n }),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownOperationTypesRule.d.ts b/validation/rules/KnownOperationTypesRule.d.ts new file mode 100644 index 0000000000..00f524185a --- /dev/null +++ b/validation/rules/KnownOperationTypesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Known Operation Types + * + * A GraphQL document is only valid if when it contains an operation, + * the root type for the operation exists within the schema. + * + * See https://spec.graphql.org/draft/#sec-Operation-Type-Existence + */ +export declare function KnownOperationTypesRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/KnownOperationTypesRule.js b/validation/rules/KnownOperationTypesRule.js new file mode 100644 index 0000000000..2377fdf5fd --- /dev/null +++ b/validation/rules/KnownOperationTypesRule.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KnownOperationTypesRule = KnownOperationTypesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Known Operation Types + * + * A GraphQL document is only valid if when it contains an operation, + * the root type for the operation exists within the schema. + * + * See https://spec.graphql.org/draft/#sec-Operation-Type-Existence + */ +function KnownOperationTypesRule(context) { + const schema = context.getSchema(); + return { + OperationDefinition(node) { + const operation = node.operation; + if (!schema.getRootType(operation)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`The ${operation} operation is not supported by the schema.`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=KnownOperationTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownOperationTypesRule.js.map b/validation/rules/KnownOperationTypesRule.js.map new file mode 100644 index 0000000000..da8429c578 --- /dev/null +++ b/validation/rules/KnownOperationTypesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownOperationTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownOperationTypesRule.ts"],"names":[],"mappings":";;AAcA,0DAiBC;AA/BD,iEAA2D;AAM3D;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,OAA0B;IAE1B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;gBACnC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,OAAO,SAAS,4CAA4C,EAC5D,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Known Operation Types\n *\n * A GraphQL document is only valid if when it contains an operation,\n * the root type for the operation exists within the schema.\n *\n * See https://spec.graphql.org/draft/#sec-Operation-Type-Existence\n */\nexport function KnownOperationTypesRule(\n context: ValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n return {\n OperationDefinition(node) {\n const operation = node.operation;\n if (!schema.getRootType(operation)) {\n context.reportError(\n new GraphQLError(\n `The ${operation} operation is not supported by the schema.`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownOperationTypesRule.mjs b/validation/rules/KnownOperationTypesRule.mjs new file mode 100644 index 0000000000..a43dfb760b --- /dev/null +++ b/validation/rules/KnownOperationTypesRule.mjs @@ -0,0 +1,21 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Known Operation Types + * + * A GraphQL document is only valid if when it contains an operation, + * the root type for the operation exists within the schema. + * + * See https://spec.graphql.org/draft/#sec-Operation-Type-Existence + */ +export function KnownOperationTypesRule(context) { + const schema = context.getSchema(); + return { + OperationDefinition(node) { + const operation = node.operation; + if (!schema.getRootType(operation)) { + context.reportError(new GraphQLError(`The ${operation} operation is not supported by the schema.`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=KnownOperationTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownOperationTypesRule.mjs.map b/validation/rules/KnownOperationTypesRule.mjs.map new file mode 100644 index 0000000000..b56cf7c446 --- /dev/null +++ b/validation/rules/KnownOperationTypesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownOperationTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownOperationTypesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAA0B;IAE1B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;gBACnC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,OAAO,SAAS,4CAA4C,EAC5D,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Known Operation Types\n *\n * A GraphQL document is only valid if when it contains an operation,\n * the root type for the operation exists within the schema.\n *\n * See https://spec.graphql.org/draft/#sec-Operation-Type-Existence\n */\nexport function KnownOperationTypesRule(\n context: ValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n return {\n OperationDefinition(node) {\n const operation = node.operation;\n if (!schema.getRootType(operation)) {\n context.reportError(\n new GraphQLError(\n `The ${operation} operation is not supported by the schema.`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownTypeNamesRule.d.ts b/validation/rules/KnownTypeNamesRule.d.ts new file mode 100644 index 0000000000..fc7b1a694a --- /dev/null +++ b/validation/rules/KnownTypeNamesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext, ValidationContext } from '../ValidationContext.js'; +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + */ +export declare function KnownTypeNamesRule(context: ValidationContext | SDLValidationContext): ASTVisitor; diff --git a/validation/rules/KnownTypeNamesRule.js b/validation/rules/KnownTypeNamesRule.js new file mode 100644 index 0000000000..ffe415ed7c --- /dev/null +++ b/validation/rules/KnownTypeNamesRule.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KnownTypeNamesRule = KnownTypeNamesRule; +const didYouMean_js_1 = require("../../jsutils/didYouMean.js"); +const suggestionList_js_1 = require("../../jsutils/suggestionList.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const predicates_js_1 = require("../../language/predicates.js"); +const introspection_js_1 = require("../../type/introspection.js"); +const scalars_js_1 = require("../../type/scalars.js"); +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + */ +function KnownTypeNamesRule(context) { + const { definitions } = context.getDocument(); + const existingTypesMap = context.getSchema()?.getTypeMap() ?? {}; + const typeNames = new Set([ + ...Object.keys(existingTypesMap), + ...definitions.filter(predicates_js_1.isTypeDefinitionNode).map((def) => def.name.value), + ]); + return { + NamedType(node, _1, parent, _2, ancestors) { + const typeName = node.name.value; + if (!typeNames.has(typeName)) { + const definitionNode = ancestors[2] ?? parent; + const isSDL = definitionNode != null && isSDLNode(definitionNode); + if (isSDL && standardTypeNames.has(typeName)) { + return; + } + const suggestedTypes = context.hideSuggestions + ? [] + : (0, suggestionList_js_1.suggestionList)(typeName, isSDL ? [...standardTypeNames, ...typeNames] : [...typeNames]); + context.reportError(new GraphQLError_js_1.GraphQLError(`Unknown type "${typeName}".` + (0, didYouMean_js_1.didYouMean)(suggestedTypes), { nodes: node })); + } + }, + }; +} +const standardTypeNames = new Set([...scalars_js_1.specifiedScalarTypes, ...introspection_js_1.introspectionTypes].map((type) => type.name)); +function isSDLNode(value) { + return ('kind' in value && + ((0, predicates_js_1.isTypeSystemDefinitionNode)(value) || (0, predicates_js_1.isTypeSystemExtensionNode)(value))); +} +//# sourceMappingURL=KnownTypeNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownTypeNamesRule.js.map b/validation/rules/KnownTypeNamesRule.js.map new file mode 100644 index 0000000000..e4f5fc4755 --- /dev/null +++ b/validation/rules/KnownTypeNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownTypeNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownTypeNamesRule.ts"],"names":[],"mappings":";;AA6BA,gDAoCC;AAjED,+DAAyD;AACzD,uEAAiE;AAEjE,iEAA2D;AAG3D,gEAIsC;AAGtC,kEAAiE;AACjE,sDAA6D;AAO7D;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,OAAiD;IAEjD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAEjE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;QACxB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAChC,GAAG,WAAW,CAAC,MAAM,CAAC,oCAAoB,CAAC,CAAC,GAAG,CAAC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AAI,KAAK;QACf,CAAC,IAAA,0CAA0B,EAAC,KAAK,CAAC,IAAI,IAAA,yCAAyB,EAAC,KAAK,CAAC,CAAC,CACxE,CAAC;AACJ,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTNode } from '../../language/ast.js';\nimport {\n isTypeDefinitionNode,\n isTypeSystemDefinitionNode,\n isTypeSystemExtensionNode,\n} from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { introspectionTypes } from '../../type/introspection.js';\nimport { specifiedScalarTypes } from '../../type/scalars.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Known type names\n *\n * A GraphQL document is only valid if referenced types (specifically\n * variable definitions and fragment conditions) are defined by the type schema.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence\n */\nexport function KnownTypeNamesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const { definitions } = context.getDocument();\n const existingTypesMap = context.getSchema()?.getTypeMap() ?? {};\n\n const typeNames = new Set([\n ...Object.keys(existingTypesMap),\n ...definitions.filter(isTypeDefinitionNode).map((def) => def.name.value),\n ]);\n\n return {\n NamedType(node, _1, parent, _2, ancestors) {\n const typeName = node.name.value;\n if (!typeNames.has(typeName)) {\n const definitionNode = ancestors[2] ?? parent;\n const isSDL = definitionNode != null && isSDLNode(definitionNode);\n if (isSDL && standardTypeNames.has(typeName)) {\n return;\n }\n\n const suggestedTypes = context.hideSuggestions\n ? []\n : suggestionList(\n typeName,\n isSDL ? [...standardTypeNames, ...typeNames] : [...typeNames],\n );\n context.reportError(\n new GraphQLError(\n `Unknown type \"${typeName}\".` + didYouMean(suggestedTypes),\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n\nconst standardTypeNames = new Set(\n [...specifiedScalarTypes, ...introspectionTypes].map((type) => type.name),\n);\n\nfunction isSDLNode(value: ASTNode | ReadonlyArray): boolean {\n return (\n 'kind' in value &&\n (isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value))\n );\n}\n"]} \ No newline at end of file diff --git a/validation/rules/KnownTypeNamesRule.mjs b/validation/rules/KnownTypeNamesRule.mjs new file mode 100644 index 0000000000..1333b1076b --- /dev/null +++ b/validation/rules/KnownTypeNamesRule.mjs @@ -0,0 +1,44 @@ +import { didYouMean } from "../../jsutils/didYouMean.mjs"; +import { suggestionList } from "../../jsutils/suggestionList.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { isTypeDefinitionNode, isTypeSystemDefinitionNode, isTypeSystemExtensionNode, } from "../../language/predicates.mjs"; +import { introspectionTypes } from "../../type/introspection.mjs"; +import { specifiedScalarTypes } from "../../type/scalars.mjs"; +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + */ +export function KnownTypeNamesRule(context) { + const { definitions } = context.getDocument(); + const existingTypesMap = context.getSchema()?.getTypeMap() ?? {}; + const typeNames = new Set([ + ...Object.keys(existingTypesMap), + ...definitions.filter(isTypeDefinitionNode).map((def) => def.name.value), + ]); + return { + NamedType(node, _1, parent, _2, ancestors) { + const typeName = node.name.value; + if (!typeNames.has(typeName)) { + const definitionNode = ancestors[2] ?? parent; + const isSDL = definitionNode != null && isSDLNode(definitionNode); + if (isSDL && standardTypeNames.has(typeName)) { + return; + } + const suggestedTypes = context.hideSuggestions + ? [] + : suggestionList(typeName, isSDL ? [...standardTypeNames, ...typeNames] : [...typeNames]); + context.reportError(new GraphQLError(`Unknown type "${typeName}".` + didYouMean(suggestedTypes), { nodes: node })); + } + }, + }; +} +const standardTypeNames = new Set([...specifiedScalarTypes, ...introspectionTypes].map((type) => type.name)); +function isSDLNode(value) { + return ('kind' in value && + (isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value))); +} +//# sourceMappingURL=KnownTypeNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/KnownTypeNamesRule.mjs.map b/validation/rules/KnownTypeNamesRule.mjs.map new file mode 100644 index 0000000000..0ec8e3fcb8 --- /dev/null +++ b/validation/rules/KnownTypeNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"KnownTypeNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/KnownTypeNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qCAAoC;AACzD,OAAO,EAAE,cAAc,EAAE,yCAAwC;AAEjE,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,GAC1B,sCAAqC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,qCAAoC;AACjE,OAAO,EAAE,oBAAoB,EAAE,+BAA8B;AAO7D;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiD;IAEjD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAEjE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;QACxB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAChC,GAAG,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;KACzE,CAAC,CAAC;IAEH,OAAO;QACL,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS;YACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YACjC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC7B,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;gBAC9C,MAAM,KAAK,GAAG,cAAc,IAAI,IAAI,IAAI,SAAS,CAAC,cAAc,CAAC,CAAC;gBAClE,IAAI,KAAK,IAAI,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC7C,OAAO;gBACT,CAAC;gBAED,MAAM,cAAc,GAAG,OAAO,CAAC,eAAe;oBAC5C,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC,cAAc,CACZ,QAAQ,EACR,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAC9D,CAAC;gBACN,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,iBAAiB,QAAQ,IAAI,GAAG,UAAU,CAAC,cAAc,CAAC,EAC1D,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,CAAC,GAAG,oBAAoB,EAAE,GAAG,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAC1E,CAAC;AAEF,SAAS,SAAS,CAAC,KAAuC;IACxD,OAAO,CACL,MAAM,IAAI,KAAK;QACf,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI,yBAAyB,CAAC,KAAK,CAAC,CAAC,CACxE,CAAC;AACJ,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTNode } from '../../language/ast.js';\nimport {\n isTypeDefinitionNode,\n isTypeSystemDefinitionNode,\n isTypeSystemExtensionNode,\n} from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { introspectionTypes } from '../../type/introspection.js';\nimport { specifiedScalarTypes } from '../../type/scalars.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Known type names\n *\n * A GraphQL document is only valid if referenced types (specifically\n * variable definitions and fragment conditions) are defined by the type schema.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence\n */\nexport function KnownTypeNamesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const { definitions } = context.getDocument();\n const existingTypesMap = context.getSchema()?.getTypeMap() ?? {};\n\n const typeNames = new Set([\n ...Object.keys(existingTypesMap),\n ...definitions.filter(isTypeDefinitionNode).map((def) => def.name.value),\n ]);\n\n return {\n NamedType(node, _1, parent, _2, ancestors) {\n const typeName = node.name.value;\n if (!typeNames.has(typeName)) {\n const definitionNode = ancestors[2] ?? parent;\n const isSDL = definitionNode != null && isSDLNode(definitionNode);\n if (isSDL && standardTypeNames.has(typeName)) {\n return;\n }\n\n const suggestedTypes = context.hideSuggestions\n ? []\n : suggestionList(\n typeName,\n isSDL ? [...standardTypeNames, ...typeNames] : [...typeNames],\n );\n context.reportError(\n new GraphQLError(\n `Unknown type \"${typeName}\".` + didYouMean(suggestedTypes),\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n\nconst standardTypeNames = new Set(\n [...specifiedScalarTypes, ...introspectionTypes].map((type) => type.name),\n);\n\nfunction isSDLNode(value: ASTNode | ReadonlyArray): boolean {\n return (\n 'kind' in value &&\n (isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value))\n );\n}\n"]} \ No newline at end of file diff --git a/validation/rules/LoneAnonymousOperationRule.d.ts b/validation/rules/LoneAnonymousOperationRule.d.ts new file mode 100644 index 0000000000..6171732997 --- /dev/null +++ b/validation/rules/LoneAnonymousOperationRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + * + * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation + */ +export declare function LoneAnonymousOperationRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/LoneAnonymousOperationRule.js b/validation/rules/LoneAnonymousOperationRule.js new file mode 100644 index 0000000000..52b5308e97 --- /dev/null +++ b/validation/rules/LoneAnonymousOperationRule.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LoneAnonymousOperationRule = LoneAnonymousOperationRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + * + * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation + */ +function LoneAnonymousOperationRule(context) { + let operationCount = 0; + return { + Document(node) { + operationCount = node.definitions.filter((definition) => definition.kind === kinds_js_1.Kind.OPERATION_DEFINITION).length; + }, + OperationDefinition(node) { + if (!node.name && operationCount > 1) { + context.reportError(new GraphQLError_js_1.GraphQLError('This anonymous operation must be the only defined operation.', { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=LoneAnonymousOperationRule.js.map \ No newline at end of file diff --git a/validation/rules/LoneAnonymousOperationRule.js.map b/validation/rules/LoneAnonymousOperationRule.js.map new file mode 100644 index 0000000000..06b5fcc1c1 --- /dev/null +++ b/validation/rules/LoneAnonymousOperationRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LoneAnonymousOperationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/LoneAnonymousOperationRule.ts"],"names":[],"mappings":";;AAeA,gEAqBC;AApCD,iEAA2D;AAE3D,sDAA+C;AAK/C;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CACxC,OAA6B;IAE7B,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,OAAO;QACL,QAAQ,CAAC,IAAI;YACX,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CACtC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,eAAI,CAAC,oBAAoB,CAC9D,CAAC,MAAM,CAAC;QACX,CAAC;QACD,mBAAmB,CAAC,IAAI;YACtB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;gBACrC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,8DAA8D,EAC9D,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Lone anonymous operation\n *\n * A GraphQL document is only valid if when it contains an anonymous operation\n * (the query short-hand) that it contains only that one operation definition.\n *\n * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation\n */\nexport function LoneAnonymousOperationRule(\n context: ASTValidationContext,\n): ASTVisitor {\n let operationCount = 0;\n return {\n Document(node) {\n operationCount = node.definitions.filter(\n (definition) => definition.kind === Kind.OPERATION_DEFINITION,\n ).length;\n },\n OperationDefinition(node) {\n if (!node.name && operationCount > 1) {\n context.reportError(\n new GraphQLError(\n 'This anonymous operation must be the only defined operation.',\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/LoneAnonymousOperationRule.mjs b/validation/rules/LoneAnonymousOperationRule.mjs new file mode 100644 index 0000000000..68a5f71d5b --- /dev/null +++ b/validation/rules/LoneAnonymousOperationRule.mjs @@ -0,0 +1,24 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + * + * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation + */ +export function LoneAnonymousOperationRule(context) { + let operationCount = 0; + return { + Document(node) { + operationCount = node.definitions.filter((definition) => definition.kind === Kind.OPERATION_DEFINITION).length; + }, + OperationDefinition(node) { + if (!node.name && operationCount > 1) { + context.reportError(new GraphQLError('This anonymous operation must be the only defined operation.', { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=LoneAnonymousOperationRule.js.map \ No newline at end of file diff --git a/validation/rules/LoneAnonymousOperationRule.mjs.map b/validation/rules/LoneAnonymousOperationRule.mjs.map new file mode 100644 index 0000000000..2b8e8aab50 --- /dev/null +++ b/validation/rules/LoneAnonymousOperationRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"LoneAnonymousOperationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/LoneAnonymousOperationRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAE3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAK/C;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA6B;IAE7B,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,OAAO;QACL,QAAQ,CAAC,IAAI;YACX,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CACtC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,oBAAoB,CAC9D,CAAC,MAAM,CAAC;QACX,CAAC;QACD,mBAAmB,CAAC,IAAI;YACtB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;gBACrC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,8DAA8D,EAC9D,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Lone anonymous operation\n *\n * A GraphQL document is only valid if when it contains an anonymous operation\n * (the query short-hand) that it contains only that one operation definition.\n *\n * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation\n */\nexport function LoneAnonymousOperationRule(\n context: ASTValidationContext,\n): ASTVisitor {\n let operationCount = 0;\n return {\n Document(node) {\n operationCount = node.definitions.filter(\n (definition) => definition.kind === Kind.OPERATION_DEFINITION,\n ).length;\n },\n OperationDefinition(node) {\n if (!node.name && operationCount > 1) {\n context.reportError(\n new GraphQLError(\n 'This anonymous operation must be the only defined operation.',\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/LoneSchemaDefinitionRule.d.ts b/validation/rules/LoneSchemaDefinitionRule.d.ts new file mode 100644 index 0000000000..e4438e11f0 --- /dev/null +++ b/validation/rules/LoneSchemaDefinitionRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Lone Schema definition + * + * A GraphQL document is only valid if it contains only one schema definition. + */ +export declare function LoneSchemaDefinitionRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/LoneSchemaDefinitionRule.js b/validation/rules/LoneSchemaDefinitionRule.js new file mode 100644 index 0000000000..9df3b32e04 --- /dev/null +++ b/validation/rules/LoneSchemaDefinitionRule.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LoneSchemaDefinitionRule = LoneSchemaDefinitionRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Lone Schema definition + * + * A GraphQL document is only valid if it contains only one schema definition. + */ +function LoneSchemaDefinitionRule(context) { + const oldSchema = context.getSchema(); + const alreadyDefined = oldSchema?.astNode ?? + oldSchema?.getQueryType() ?? + oldSchema?.getMutationType() ?? + oldSchema?.getSubscriptionType(); + let schemaDefinitionsCount = 0; + return { + SchemaDefinition(node) { + if (alreadyDefined) { + context.reportError(new GraphQLError_js_1.GraphQLError('Cannot define a new schema within a schema extension.', { nodes: node })); + return; + } + if (schemaDefinitionsCount > 0) { + context.reportError(new GraphQLError_js_1.GraphQLError('Must provide only one schema definition.', { + nodes: node, + })); + } + ++schemaDefinitionsCount; + }, + }; +} +//# sourceMappingURL=LoneSchemaDefinitionRule.js.map \ No newline at end of file diff --git a/validation/rules/LoneSchemaDefinitionRule.js.map b/validation/rules/LoneSchemaDefinitionRule.js.map new file mode 100644 index 0000000000..7ae9ad2310 --- /dev/null +++ b/validation/rules/LoneSchemaDefinitionRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LoneSchemaDefinitionRule.js","sourceRoot":"","sources":["../../../src/validation/rules/LoneSchemaDefinitionRule.ts"],"names":[],"mappings":";;AAWA,4DAiCC;AA5CD,iEAA2D;AAM3D;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACtC,MAAM,cAAc,GAClB,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,YAAY,EAAE;QACzB,SAAS,EAAE,eAAe,EAAE;QAC5B,SAAS,EAAE,mBAAmB,EAAE,CAAC;IAEnC,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,OAAO;QACL,gBAAgB,CAAC,IAAI;YACnB,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,uDAAuD,EACvD,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACF,OAAO;YACT,CAAC;YAED,IAAI,sBAAsB,GAAG,CAAC,EAAE,CAAC;gBAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CAAC,0CAA0C,EAAE;oBAC3D,KAAK,EAAE,IAAI;iBACZ,CAAC,CACH,CAAC;YACJ,CAAC;YACD,EAAE,sBAAsB,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Lone Schema definition\n *\n * A GraphQL document is only valid if it contains only one schema definition.\n */\nexport function LoneSchemaDefinitionRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const oldSchema = context.getSchema();\n const alreadyDefined =\n oldSchema?.astNode ??\n oldSchema?.getQueryType() ??\n oldSchema?.getMutationType() ??\n oldSchema?.getSubscriptionType();\n\n let schemaDefinitionsCount = 0;\n return {\n SchemaDefinition(node) {\n if (alreadyDefined) {\n context.reportError(\n new GraphQLError(\n 'Cannot define a new schema within a schema extension.',\n { nodes: node },\n ),\n );\n return;\n }\n\n if (schemaDefinitionsCount > 0) {\n context.reportError(\n new GraphQLError('Must provide only one schema definition.', {\n nodes: node,\n }),\n );\n }\n ++schemaDefinitionsCount;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/LoneSchemaDefinitionRule.mjs b/validation/rules/LoneSchemaDefinitionRule.mjs new file mode 100644 index 0000000000..aea76993d2 --- /dev/null +++ b/validation/rules/LoneSchemaDefinitionRule.mjs @@ -0,0 +1,29 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Lone Schema definition + * + * A GraphQL document is only valid if it contains only one schema definition. + */ +export function LoneSchemaDefinitionRule(context) { + const oldSchema = context.getSchema(); + const alreadyDefined = oldSchema?.astNode ?? + oldSchema?.getQueryType() ?? + oldSchema?.getMutationType() ?? + oldSchema?.getSubscriptionType(); + let schemaDefinitionsCount = 0; + return { + SchemaDefinition(node) { + if (alreadyDefined) { + context.reportError(new GraphQLError('Cannot define a new schema within a schema extension.', { nodes: node })); + return; + } + if (schemaDefinitionsCount > 0) { + context.reportError(new GraphQLError('Must provide only one schema definition.', { + nodes: node, + })); + } + ++schemaDefinitionsCount; + }, + }; +} +//# sourceMappingURL=LoneSchemaDefinitionRule.js.map \ No newline at end of file diff --git a/validation/rules/LoneSchemaDefinitionRule.mjs.map b/validation/rules/LoneSchemaDefinitionRule.mjs.map new file mode 100644 index 0000000000..7c099bad98 --- /dev/null +++ b/validation/rules/LoneSchemaDefinitionRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"LoneSchemaDefinitionRule.js","sourceRoot":"","sources":["../../../src/validation/rules/LoneSchemaDefinitionRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACtC,MAAM,cAAc,GAClB,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,YAAY,EAAE;QACzB,SAAS,EAAE,eAAe,EAAE;QAC5B,SAAS,EAAE,mBAAmB,EAAE,CAAC;IAEnC,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,OAAO;QACL,gBAAgB,CAAC,IAAI;YACnB,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,uDAAuD,EACvD,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACF,OAAO;YACT,CAAC;YAED,IAAI,sBAAsB,GAAG,CAAC,EAAE,CAAC;gBAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CAAC,0CAA0C,EAAE;oBAC3D,KAAK,EAAE,IAAI;iBACZ,CAAC,CACH,CAAC;YACJ,CAAC;YACD,EAAE,sBAAsB,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Lone Schema definition\n *\n * A GraphQL document is only valid if it contains only one schema definition.\n */\nexport function LoneSchemaDefinitionRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const oldSchema = context.getSchema();\n const alreadyDefined =\n oldSchema?.astNode ??\n oldSchema?.getQueryType() ??\n oldSchema?.getMutationType() ??\n oldSchema?.getSubscriptionType();\n\n let schemaDefinitionsCount = 0;\n return {\n SchemaDefinition(node) {\n if (alreadyDefined) {\n context.reportError(\n new GraphQLError(\n 'Cannot define a new schema within a schema extension.',\n { nodes: node },\n ),\n );\n return;\n }\n\n if (schemaDefinitionsCount > 0) {\n context.reportError(\n new GraphQLError('Must provide only one schema definition.', {\n nodes: node,\n }),\n );\n }\n ++schemaDefinitionsCount;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/MaxIntrospectionDepthRule.d.ts b/validation/rules/MaxIntrospectionDepthRule.d.ts new file mode 100644 index 0000000000..0ec5427175 --- /dev/null +++ b/validation/rules/MaxIntrospectionDepthRule.d.ts @@ -0,0 +1,3 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +export declare function MaxIntrospectionDepthRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/MaxIntrospectionDepthRule.js b/validation/rules/MaxIntrospectionDepthRule.js new file mode 100644 index 0000000000..1b0ad53499 --- /dev/null +++ b/validation/rules/MaxIntrospectionDepthRule.js @@ -0,0 +1,73 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MaxIntrospectionDepthRule = MaxIntrospectionDepthRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const MAX_LISTS_DEPTH = 3; +function MaxIntrospectionDepthRule(context) { + /** + * Counts the depth of list fields in "__Type" recursively and + * returns `true` if the limit has been reached. + */ + function checkDepth(node, visitedFragments = Object.create(null), depth = 0) { + if (node.kind === kinds_js_1.Kind.FRAGMENT_SPREAD) { + const fragmentName = node.name.value; + if (visitedFragments[fragmentName] === true) { + // Fragment cycles are handled by `NoFragmentCyclesRule`. + return false; + } + const fragment = context.getFragment(fragmentName); + if (!fragment) { + // Missing fragments checks are handled by the `KnownFragmentNamesRule`. + return false; + } + // Rather than following an immutable programming pattern which has + // significant memory and garbage collection overhead, we've opted to + // take a mutable approach for efficiency's sake. Importantly visiting a + // fragment twice is fine, so long as you don't do one visit inside the + // other. + try { + visitedFragments[fragmentName] = true; + return checkDepth(fragment, visitedFragments, depth); + } + finally { + visitedFragments[fragmentName] = undefined; + } + } + if (node.kind === kinds_js_1.Kind.FIELD && + // check all introspection lists + // TODO: instead of relying on field names, check whether the type is a list + (node.name.value === 'fields' || + node.name.value === 'interfaces' || + node.name.value === 'possibleTypes' || + node.name.value === 'inputFields')) { + // eslint-disable-next-line no-param-reassign + depth++; + if (depth >= MAX_LISTS_DEPTH) { + return true; + } + } + // handles fields and inline fragments + if ('selectionSet' in node && node.selectionSet) { + for (const child of node.selectionSet.selections) { + if (checkDepth(child, visitedFragments, depth)) { + return true; + } + } + } + return false; + } + return { + Field(node) { + if (node.name.value === '__schema' || node.name.value === '__type') { + if (checkDepth(node)) { + context.reportError(new GraphQLError_js_1.GraphQLError('Maximum introspection depth exceeded', { + nodes: [node], + })); + return false; + } + } + }, + }; +} +//# sourceMappingURL=MaxIntrospectionDepthRule.js.map \ No newline at end of file diff --git a/validation/rules/MaxIntrospectionDepthRule.js.map b/validation/rules/MaxIntrospectionDepthRule.js.map new file mode 100644 index 0000000000..35be940522 --- /dev/null +++ b/validation/rules/MaxIntrospectionDepthRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MaxIntrospectionDepthRule.js","sourceRoot":"","sources":["../../../src/validation/rules/MaxIntrospectionDepthRule.ts"],"names":[],"mappings":";;AAUA,8DAiFC;AA3F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;YAC7C,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,IAAI,eAAe,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,sCAAsC;QACtC,IAAI,cAAc,IAAI,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAChD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;gBACjD,IAAI,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;oBAC/C,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,KAAK,CAAC,IAAI;YACR,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACnE,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;oBACrB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CAAC,sCAAsC,EAAE;wBACvD,KAAK,EAAE,CAAC,IAAI,CAAC;qBACd,CAAC,CACH,CAAC;oBACF,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\nconst MAX_LISTS_DEPTH = 3;\n\nexport function MaxIntrospectionDepthRule(\n context: ValidationContext,\n): ASTVisitor {\n /**\n * Counts the depth of list fields in \"__Type\" recursively and\n * returns `true` if the limit has been reached.\n */\n function checkDepth(\n node: ASTNode,\n visitedFragments: {\n [fragmentName: string]: true | undefined;\n } = Object.create(null),\n depth: number = 0,\n ): boolean {\n if (node.kind === Kind.FRAGMENT_SPREAD) {\n const fragmentName = node.name.value;\n if (visitedFragments[fragmentName] === true) {\n // Fragment cycles are handled by `NoFragmentCyclesRule`.\n return false;\n }\n const fragment = context.getFragment(fragmentName);\n if (!fragment) {\n // Missing fragments checks are handled by the `KnownFragmentNamesRule`.\n return false;\n }\n\n // Rather than following an immutable programming pattern which has\n // significant memory and garbage collection overhead, we've opted to\n // take a mutable approach for efficiency's sake. Importantly visiting a\n // fragment twice is fine, so long as you don't do one visit inside the\n // other.\n try {\n visitedFragments[fragmentName] = true;\n return checkDepth(fragment, visitedFragments, depth);\n } finally {\n visitedFragments[fragmentName] = undefined;\n }\n }\n\n if (\n node.kind === Kind.FIELD &&\n // check all introspection lists\n // TODO: instead of relying on field names, check whether the type is a list\n (node.name.value === 'fields' ||\n node.name.value === 'interfaces' ||\n node.name.value === 'possibleTypes' ||\n node.name.value === 'inputFields')\n ) {\n // eslint-disable-next-line no-param-reassign\n depth++;\n if (depth >= MAX_LISTS_DEPTH) {\n return true;\n }\n }\n\n // handles fields and inline fragments\n if ('selectionSet' in node && node.selectionSet) {\n for (const child of node.selectionSet.selections) {\n if (checkDepth(child, visitedFragments, depth)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n return {\n Field(node) {\n if (node.name.value === '__schema' || node.name.value === '__type') {\n if (checkDepth(node)) {\n context.reportError(\n new GraphQLError('Maximum introspection depth exceeded', {\n nodes: [node],\n }),\n );\n return false;\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/MaxIntrospectionDepthRule.mjs b/validation/rules/MaxIntrospectionDepthRule.mjs new file mode 100644 index 0000000000..e31f838d93 --- /dev/null +++ b/validation/rules/MaxIntrospectionDepthRule.mjs @@ -0,0 +1,70 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +const MAX_LISTS_DEPTH = 3; +export function MaxIntrospectionDepthRule(context) { + /** + * Counts the depth of list fields in "__Type" recursively and + * returns `true` if the limit has been reached. + */ + function checkDepth(node, visitedFragments = Object.create(null), depth = 0) { + if (node.kind === Kind.FRAGMENT_SPREAD) { + const fragmentName = node.name.value; + if (visitedFragments[fragmentName] === true) { + // Fragment cycles are handled by `NoFragmentCyclesRule`. + return false; + } + const fragment = context.getFragment(fragmentName); + if (!fragment) { + // Missing fragments checks are handled by the `KnownFragmentNamesRule`. + return false; + } + // Rather than following an immutable programming pattern which has + // significant memory and garbage collection overhead, we've opted to + // take a mutable approach for efficiency's sake. Importantly visiting a + // fragment twice is fine, so long as you don't do one visit inside the + // other. + try { + visitedFragments[fragmentName] = true; + return checkDepth(fragment, visitedFragments, depth); + } + finally { + visitedFragments[fragmentName] = undefined; + } + } + if (node.kind === Kind.FIELD && + // check all introspection lists + // TODO: instead of relying on field names, check whether the type is a list + (node.name.value === 'fields' || + node.name.value === 'interfaces' || + node.name.value === 'possibleTypes' || + node.name.value === 'inputFields')) { + // eslint-disable-next-line no-param-reassign + depth++; + if (depth >= MAX_LISTS_DEPTH) { + return true; + } + } + // handles fields and inline fragments + if ('selectionSet' in node && node.selectionSet) { + for (const child of node.selectionSet.selections) { + if (checkDepth(child, visitedFragments, depth)) { + return true; + } + } + } + return false; + } + return { + Field(node) { + if (node.name.value === '__schema' || node.name.value === '__type') { + if (checkDepth(node)) { + context.reportError(new GraphQLError('Maximum introspection depth exceeded', { + nodes: [node], + })); + return false; + } + } + }, + }; +} +//# sourceMappingURL=MaxIntrospectionDepthRule.js.map \ No newline at end of file diff --git a/validation/rules/MaxIntrospectionDepthRule.mjs.map b/validation/rules/MaxIntrospectionDepthRule.mjs.map new file mode 100644 index 0000000000..4c78037fa7 --- /dev/null +++ b/validation/rules/MaxIntrospectionDepthRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"MaxIntrospectionDepthRule.js","sourceRoot":"","sources":["../../../src/validation/rules/MaxIntrospectionDepthRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;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CAAC;YACD,6CAA6C;YAC7C,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,IAAI,eAAe,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,sCAAsC;QACtC,IAAI,cAAc,IAAI,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAChD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;gBACjD,IAAI,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;oBAC/C,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,KAAK,CAAC,IAAI;YACR,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACnE,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;oBACrB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CAAC,sCAAsC,EAAE;wBACvD,KAAK,EAAE,CAAC,IAAI,CAAC;qBACd,CAAC,CACH,CAAC;oBACF,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\nconst MAX_LISTS_DEPTH = 3;\n\nexport function MaxIntrospectionDepthRule(\n context: ValidationContext,\n): ASTVisitor {\n /**\n * Counts the depth of list fields in \"__Type\" recursively and\n * returns `true` if the limit has been reached.\n */\n function checkDepth(\n node: ASTNode,\n visitedFragments: {\n [fragmentName: string]: true | undefined;\n } = Object.create(null),\n depth: number = 0,\n ): boolean {\n if (node.kind === Kind.FRAGMENT_SPREAD) {\n const fragmentName = node.name.value;\n if (visitedFragments[fragmentName] === true) {\n // Fragment cycles are handled by `NoFragmentCyclesRule`.\n return false;\n }\n const fragment = context.getFragment(fragmentName);\n if (!fragment) {\n // Missing fragments checks are handled by the `KnownFragmentNamesRule`.\n return false;\n }\n\n // Rather than following an immutable programming pattern which has\n // significant memory and garbage collection overhead, we've opted to\n // take a mutable approach for efficiency's sake. Importantly visiting a\n // fragment twice is fine, so long as you don't do one visit inside the\n // other.\n try {\n visitedFragments[fragmentName] = true;\n return checkDepth(fragment, visitedFragments, depth);\n } finally {\n visitedFragments[fragmentName] = undefined;\n }\n }\n\n if (\n node.kind === Kind.FIELD &&\n // check all introspection lists\n // TODO: instead of relying on field names, check whether the type is a list\n (node.name.value === 'fields' ||\n node.name.value === 'interfaces' ||\n node.name.value === 'possibleTypes' ||\n node.name.value === 'inputFields')\n ) {\n // eslint-disable-next-line no-param-reassign\n depth++;\n if (depth >= MAX_LISTS_DEPTH) {\n return true;\n }\n }\n\n // handles fields and inline fragments\n if ('selectionSet' in node && node.selectionSet) {\n for (const child of node.selectionSet.selections) {\n if (checkDepth(child, visitedFragments, depth)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n return {\n Field(node) {\n if (node.name.value === '__schema' || node.name.value === '__type') {\n if (checkDepth(node)) {\n context.reportError(\n new GraphQLError('Maximum introspection depth exceeded', {\n nodes: [node],\n }),\n );\n return false;\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoFragmentCyclesRule.d.ts b/validation/rules/NoFragmentCyclesRule.d.ts new file mode 100644 index 0000000000..a6ce92bfc5 --- /dev/null +++ b/validation/rules/NoFragmentCyclesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * No fragment cycles + * + * The graph of fragment spreads must not form any cycles including spreading itself. + * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles + */ +export declare function NoFragmentCyclesRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/NoFragmentCyclesRule.js b/validation/rules/NoFragmentCyclesRule.js new file mode 100644 index 0000000000..b42c0590de --- /dev/null +++ b/validation/rules/NoFragmentCyclesRule.js @@ -0,0 +1,66 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NoFragmentCyclesRule = NoFragmentCyclesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * No fragment cycles + * + * The graph of fragment spreads must not form any cycles including spreading itself. + * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles + */ +function NoFragmentCyclesRule(context) { + // Tracks already visited fragments to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFrags = new Set(); + // Array of AST nodes used to produce meaningful errors + const spreadPath = []; + // Position in the spread path + const spreadPathIndexByName = Object.create(null); + return { + OperationDefinition: () => false, + FragmentDefinition(node) { + detectCycleRecursive(node); + return false; + }, + }; + // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + function detectCycleRecursive(fragment) { + if (visitedFrags.has(fragment.name.value)) { + return; + } + const fragmentName = fragment.name.value; + visitedFrags.add(fragmentName); + const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); + if (spreadNodes.length === 0) { + return; + } + spreadPathIndexByName[fragmentName] = spreadPath.length; + for (const spreadNode of spreadNodes) { + const spreadName = spreadNode.name.value; + const cycleIndex = spreadPathIndexByName[spreadName]; + spreadPath.push(spreadNode); + if (cycleIndex === undefined) { + const spreadFragment = context.getFragment(spreadName); + if (spreadFragment) { + detectCycleRecursive(spreadFragment); + } + } + else { + const cyclePath = spreadPath.slice(cycleIndex); + const viaPath = cyclePath + .slice(0, -1) + .map((s) => '"' + s.name.value + '"') + .join(', '); + context.reportError(new GraphQLError_js_1.GraphQLError(`Cannot spread fragment "${spreadName}" within itself` + + (viaPath !== '' ? ` via ${viaPath}.` : '.'), { nodes: cyclePath })); + } + spreadPath.pop(); + } + spreadPathIndexByName[fragmentName] = undefined; + } +} +//# sourceMappingURL=NoFragmentCyclesRule.js.map \ No newline at end of file diff --git a/validation/rules/NoFragmentCyclesRule.js.map b/validation/rules/NoFragmentCyclesRule.js.map new file mode 100644 index 0000000000..e90639f07c --- /dev/null +++ b/validation/rules/NoFragmentCyclesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NoFragmentCyclesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoFragmentCyclesRule.ts"],"names":[],"mappings":";;AAoBA,oDAqEC;AAvFD,iEAA2D;AAU3D;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAClC,OAA6B;IAE7B,8EAA8E;IAC9E,gCAAgC;IAChC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IAEvC,uDAAuD;IACvD,MAAM,UAAU,GAA8B,EAAE,CAAC;IAEjD,8BAA8B;IAC9B,MAAM,qBAAqB,GAA+B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE9E,OAAO;QACL,mBAAmB,EAAE,GAAG,EAAE,CAAC,KAAK;QAChC,kBAAkB,CAAC,IAAI;YACrB,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IAEF,mDAAmD;IACnD,wEAAwE;IACxE,yCAAyC;IACzC,SAAS,oBAAoB,CAAC,QAAgC;QAC5D,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QACzC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC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nB,CAAC;QAED,qBAAqB,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IAClD,CAAC;AACH,CAAC","sourcesContent":["import type { ObjMap } from '../../jsutils/ObjMap.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n FragmentDefinitionNode,\n FragmentSpreadNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * No fragment cycles\n *\n * The graph of fragment spreads must not form any cycles including spreading itself.\n * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles\n */\nexport function NoFragmentCyclesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n // Tracks already visited fragments to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedFrags = new Set();\n\n // Array of AST nodes used to produce meaningful errors\n const spreadPath: Array = [];\n\n // Position in the spread path\n const spreadPathIndexByName: ObjMap = Object.create(null);\n\n return {\n OperationDefinition: () => false,\n FragmentDefinition(node) {\n detectCycleRecursive(node);\n return false;\n },\n };\n\n // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n function detectCycleRecursive(fragment: FragmentDefinitionNode): void {\n if (visitedFrags.has(fragment.name.value)) {\n return;\n }\n\n const fragmentName = fragment.name.value;\n visitedFrags.add(fragmentName);\n\n const spreadNodes = context.getFragmentSpreads(fragment.selectionSet);\n if (spreadNodes.length === 0) {\n return;\n }\n\n spreadPathIndexByName[fragmentName] = spreadPath.length;\n\n for (const spreadNode of spreadNodes) {\n const spreadName = spreadNode.name.value;\n const cycleIndex = spreadPathIndexByName[spreadName];\n\n spreadPath.push(spreadNode);\n if (cycleIndex === undefined) {\n const spreadFragment = context.getFragment(spreadName);\n if (spreadFragment) {\n detectCycleRecursive(spreadFragment);\n }\n } else {\n const cyclePath = spreadPath.slice(cycleIndex);\n const viaPath = cyclePath\n .slice(0, -1)\n .map((s) => '\"' + s.name.value + '\"')\n .join(', ');\n\n context.reportError(\n new GraphQLError(\n `Cannot spread fragment \"${spreadName}\" within itself` +\n (viaPath !== '' ? ` via ${viaPath}.` : '.'),\n { nodes: cyclePath },\n ),\n );\n }\n spreadPath.pop();\n }\n\n spreadPathIndexByName[fragmentName] = undefined;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoFragmentCyclesRule.mjs b/validation/rules/NoFragmentCyclesRule.mjs new file mode 100644 index 0000000000..eaf02f2256 --- /dev/null +++ b/validation/rules/NoFragmentCyclesRule.mjs @@ -0,0 +1,63 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * No fragment cycles + * + * The graph of fragment spreads must not form any cycles including spreading itself. + * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles + */ +export function NoFragmentCyclesRule(context) { + // Tracks already visited fragments to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFrags = new Set(); + // Array of AST nodes used to produce meaningful errors + const spreadPath = []; + // Position in the spread path + const spreadPathIndexByName = Object.create(null); + return { + OperationDefinition: () => false, + FragmentDefinition(node) { + detectCycleRecursive(node); + return false; + }, + }; + // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + function detectCycleRecursive(fragment) { + if (visitedFrags.has(fragment.name.value)) { + return; + } + const fragmentName = fragment.name.value; + visitedFrags.add(fragmentName); + const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); + if (spreadNodes.length === 0) { + return; + } + spreadPathIndexByName[fragmentName] = spreadPath.length; + for (const spreadNode of spreadNodes) { + const spreadName = spreadNode.name.value; + const cycleIndex = spreadPathIndexByName[spreadName]; + spreadPath.push(spreadNode); + if (cycleIndex === undefined) { + const spreadFragment = context.getFragment(spreadName); + if (spreadFragment) { + detectCycleRecursive(spreadFragment); + } + } + else { + const cyclePath = spreadPath.slice(cycleIndex); + const viaPath = cyclePath + .slice(0, -1) + .map((s) => '"' + s.name.value + '"') + .join(', '); + context.reportError(new GraphQLError(`Cannot spread fragment "${spreadName}" within itself` + + (viaPath !== '' ? ` via ${viaPath}.` : '.'), { nodes: cyclePath })); + } + spreadPath.pop(); + } + spreadPathIndexByName[fragmentName] = undefined; + } +} +//# sourceMappingURL=NoFragmentCyclesRule.js.map \ No newline at end of file diff --git a/validation/rules/NoFragmentCyclesRule.mjs.map b/validation/rules/NoFragmentCyclesRule.mjs.map new file mode 100644 index 0000000000..936c20435c --- /dev/null +++ b/validation/rules/NoFragmentCyclesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"NoFragmentCyclesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoFragmentCyclesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAU3D;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAA6B;IAE7B,8EAA8E;IAC9E,gCAAgC;IAChC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IAEvC,uDAAuD;IACvD,MAAM,UAAU,GAA8B,EAAE,CAAC;IAEjD,8BAA8B;IAC9B,MAAM,qBAAqB,GAA+B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE9E,OAAO;QACL,mBAAmB,EAAE,GAAG,EAAE,CAAC,KAAK;QAChC,kBAAkB,CAAC,IAAI;YACrB,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IAEF,mDAAmD;IACnD,wEAAwE;IACxE,yCAAyC;IACzC,SAAS,oBAAoB,CAAC,QAAgC;QAC5D,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,MAAM,YAAY,GAAG,QAAQ,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AE,CACrB,CACF,CAAC;YACJ,CAAC;YACD,UAAU,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,qBAAqB,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IAClD,CAAC;AACH,CAAC","sourcesContent":["import type { ObjMap } from '../../jsutils/ObjMap.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n FragmentDefinitionNode,\n FragmentSpreadNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * No fragment cycles\n *\n * The graph of fragment spreads must not form any cycles including spreading itself.\n * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles\n */\nexport function NoFragmentCyclesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n // Tracks already visited fragments to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedFrags = new Set();\n\n // Array of AST nodes used to produce meaningful errors\n const spreadPath: Array = [];\n\n // Position in the spread path\n const spreadPathIndexByName: ObjMap = Object.create(null);\n\n return {\n OperationDefinition: () => false,\n FragmentDefinition(node) {\n detectCycleRecursive(node);\n return false;\n },\n };\n\n // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n function detectCycleRecursive(fragment: FragmentDefinitionNode): void {\n if (visitedFrags.has(fragment.name.value)) {\n return;\n }\n\n const fragmentName = fragment.name.value;\n visitedFrags.add(fragmentName);\n\n const spreadNodes = context.getFragmentSpreads(fragment.selectionSet);\n if (spreadNodes.length === 0) {\n return;\n }\n\n spreadPathIndexByName[fragmentName] = spreadPath.length;\n\n for (const spreadNode of spreadNodes) {\n const spreadName = spreadNode.name.value;\n const cycleIndex = spreadPathIndexByName[spreadName];\n\n spreadPath.push(spreadNode);\n if (cycleIndex === undefined) {\n const spreadFragment = context.getFragment(spreadName);\n if (spreadFragment) {\n detectCycleRecursive(spreadFragment);\n }\n } else {\n const cyclePath = spreadPath.slice(cycleIndex);\n const viaPath = cyclePath\n .slice(0, -1)\n .map((s) => '\"' + s.name.value + '\"')\n .join(', ');\n\n context.reportError(\n new GraphQLError(\n `Cannot spread fragment \"${spreadName}\" within itself` +\n (viaPath !== '' ? ` via ${viaPath}.` : '.'),\n { nodes: cyclePath },\n ),\n );\n }\n spreadPath.pop();\n }\n\n spreadPathIndexByName[fragmentName] = undefined;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoUndefinedVariablesRule.d.ts b/validation/rules/NoUndefinedVariablesRule.d.ts new file mode 100644 index 0000000000..3d9ba8e343 --- /dev/null +++ b/validation/rules/NoUndefinedVariablesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * No undefined variables + * + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined + */ +export declare function NoUndefinedVariablesRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/NoUndefinedVariablesRule.js b/validation/rules/NoUndefinedVariablesRule.js new file mode 100644 index 0000000000..271911ff0c --- /dev/null +++ b/validation/rules/NoUndefinedVariablesRule.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NoUndefinedVariablesRule = NoUndefinedVariablesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * No undefined variables + * + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined + */ +function NoUndefinedVariablesRule(context) { + return { + OperationDefinition(operation) { + const variableNameDefined = new Set(operation.variableDefinitions?.map((node) => node.variable.name.value)); + const usages = context.getRecursiveVariableUsages(operation); + for (const { node, fragmentVariableDefinition } of usages) { + if (fragmentVariableDefinition) { + continue; + } + const varName = node.name.value; + if (!variableNameDefined.has(varName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(operation.name + ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` + : `Variable "$${varName}" is not defined.`, { nodes: [node, operation] })); + } + } + }, + }; +} +//# sourceMappingURL=NoUndefinedVariablesRule.js.map \ No newline at end of file diff --git a/validation/rules/NoUndefinedVariablesRule.js.map b/validation/rules/NoUndefinedVariablesRule.js.map new file mode 100644 index 0000000000..6fdfa0ee4a --- /dev/null +++ b/validation/rules/NoUndefinedVariablesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NoUndefinedVariablesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoUndefinedVariablesRule.ts"],"names":[],"mappings":";;AAcA,4DA4BC;AA1CD,iEAA2D;AAM3D;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CACtC,OAA0B;IAE1B,OAAO;QACL,mBAAmB,CAAC,SAAS;YAC3B,MAAM,mBAAmB,GAAG,IAAI,GAAG,CACjC,SAAS,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CACvE,CAAC;YAEF,MAAM,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;YAC7D,KAAK,MAAM,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI,MAAM,EAAE,CAAC;gBAC1D,IAAI,0BAA0B,EAAE,CAAC;oBAC/B,SAAS;gBACX,CAAC;gBACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;gBAChC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;oBACtC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,SAAS,CAAC,IAAI;wBACZ,CAAC,CAAC,cAAc,OAAO,kCAAkC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI;wBACjF,CAAC,CAAC,cAAc,OAAO,mBAAmB,EAC5C,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAC7B,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * No undefined variables\n *\n * A GraphQL operation is only valid if all variables encountered, both directly\n * and via fragment spreads, are defined by that operation.\n *\n * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined\n */\nexport function NoUndefinedVariablesRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(operation) {\n const variableNameDefined = new Set(\n operation.variableDefinitions?.map((node) => node.variable.name.value),\n );\n\n const usages = context.getRecursiveVariableUsages(operation);\n for (const { node, fragmentVariableDefinition } of usages) {\n if (fragmentVariableDefinition) {\n continue;\n }\n const varName = node.name.value;\n if (!variableNameDefined.has(varName)) {\n context.reportError(\n new GraphQLError(\n operation.name\n ? `Variable \"$${varName}\" is not defined by operation \"${operation.name.value}\".`\n : `Variable \"$${varName}\" is not defined.`,\n { nodes: [node, operation] },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoUndefinedVariablesRule.mjs b/validation/rules/NoUndefinedVariablesRule.mjs new file mode 100644 index 0000000000..25fd6f4d39 --- /dev/null +++ b/validation/rules/NoUndefinedVariablesRule.mjs @@ -0,0 +1,29 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * No undefined variables + * + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined + */ +export function NoUndefinedVariablesRule(context) { + return { + OperationDefinition(operation) { + const variableNameDefined = new Set(operation.variableDefinitions?.map((node) => node.variable.name.value)); + const usages = context.getRecursiveVariableUsages(operation); + for (const { node, fragmentVariableDefinition } of usages) { + if (fragmentVariableDefinition) { + continue; + } + const varName = node.name.value; + if (!variableNameDefined.has(varName)) { + context.reportError(new GraphQLError(operation.name + ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` + : `Variable "$${varName}" is not defined.`, { nodes: [node, operation] })); + } + } + }, + }; +} +//# sourceMappingURL=NoUndefinedVariablesRule.js.map \ No newline at end of file diff --git a/validation/rules/NoUndefinedVariablesRule.mjs.map b/validation/rules/NoUndefinedVariablesRule.mjs.map new file mode 100644 index 0000000000..97257f0d83 --- /dev/null +++ b/validation/rules/NoUndefinedVariablesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"NoUndefinedVariablesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoUndefinedVariablesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA0B;IAE1B,OAAO;QACL,mBAAmB,CAAC,SAAS;YAC3B,MAAM,mBAAmB,GAAG,IAAI,GAAG,CACjC,SAAS,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CACvE,CAAC;YAEF,MAAM,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;YAC7D,KAAK,MAAM,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI,MAAM,EAAE,CAAC;gBAC1D,IAAI,0BAA0B,EAAE,CAAC;oBAC/B,SAAS;gBACX,CAAC;gBACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;gBAChC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;oBACtC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,SAAS,CAAC,IAAI;wBACZ,CAAC,CAAC,cAAc,OAAO,kCAAkC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI;wBACjF,CAAC,CAAC,cAAc,OAAO,mBAAmB,EAC5C,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAC7B,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * No undefined variables\n *\n * A GraphQL operation is only valid if all variables encountered, both directly\n * and via fragment spreads, are defined by that operation.\n *\n * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined\n */\nexport function NoUndefinedVariablesRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(operation) {\n const variableNameDefined = new Set(\n operation.variableDefinitions?.map((node) => node.variable.name.value),\n );\n\n const usages = context.getRecursiveVariableUsages(operation);\n for (const { node, fragmentVariableDefinition } of usages) {\n if (fragmentVariableDefinition) {\n continue;\n }\n const varName = node.name.value;\n if (!variableNameDefined.has(varName)) {\n context.reportError(\n new GraphQLError(\n operation.name\n ? `Variable \"$${varName}\" is not defined by operation \"${operation.name.value}\".`\n : `Variable \"$${varName}\" is not defined.`,\n { nodes: [node, operation] },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoUnusedFragmentsRule.d.ts b/validation/rules/NoUnusedFragmentsRule.d.ts new file mode 100644 index 0000000000..5d10842104 --- /dev/null +++ b/validation/rules/NoUnusedFragmentsRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * No unused fragments + * + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. + * + * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used + */ +export declare function NoUnusedFragmentsRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/NoUnusedFragmentsRule.js b/validation/rules/NoUnusedFragmentsRule.js new file mode 100644 index 0000000000..29271f0542 --- /dev/null +++ b/validation/rules/NoUnusedFragmentsRule.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NoUnusedFragmentsRule = NoUnusedFragmentsRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * No unused fragments + * + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. + * + * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used + */ +function NoUnusedFragmentsRule(context) { + const fragmentNameUsed = new Set(); + const fragmentDefs = []; + return { + OperationDefinition(operation) { + for (const fragment of context.getRecursivelyReferencedFragments(operation)) { + fragmentNameUsed.add(fragment.name.value); + } + return false; + }, + FragmentDefinition(node) { + fragmentDefs.push(node); + return false; + }, + Document: { + leave() { + for (const fragmentDef of fragmentDefs) { + const fragName = fragmentDef.name.value; + if (!fragmentNameUsed.has(fragName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Fragment "${fragName}" is never used.`, { + nodes: fragmentDef, + })); + } + } + }, + }, + }; +} +//# sourceMappingURL=NoUnusedFragmentsRule.js.map \ No newline at end of file diff --git a/validation/rules/NoUnusedFragmentsRule.js.map b/validation/rules/NoUnusedFragmentsRule.js.map new file mode 100644 index 0000000000..d4c40f7db2 --- /dev/null +++ b/validation/rules/NoUnusedFragmentsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NoUnusedFragmentsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoUnusedFragmentsRule.ts"],"names":[],"mappings":";;AAeA,sDAkCC;AAjDD,iEAA2D;AAO3D;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,OAA6B;IAE7B,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3C,MAAM,YAAY,GAAkC,EAAE,CAAC;IAEvD,OAAO;QACL,mBAAmB,CAAC,SAAS;YAC3B,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,iCAAiC,CAC9D,SAAS,CACV,EAAE,CAAC;gBACF,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5C,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,kBAAkB,CAAC,IAAI;YACrB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,QAAQ,EAAE;YACR,KAAK;gBACH,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;oBACvC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;oBACxC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACpC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CAAC,aAAa,QAAQ,kBAAkB,EAAE;4BACxD,KAAK,EAAE,WAAW;yBACnB,CAAC,CACH,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FragmentDefinitionNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * No unused fragments\n *\n * A GraphQL document is only valid if all fragment definitions are spread\n * within operations, or spread within other fragments spread within operations.\n *\n * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used\n */\nexport function NoUnusedFragmentsRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const fragmentNameUsed = new Set();\n const fragmentDefs: Array = [];\n\n return {\n OperationDefinition(operation) {\n for (const fragment of context.getRecursivelyReferencedFragments(\n operation,\n )) {\n fragmentNameUsed.add(fragment.name.value);\n }\n return false;\n },\n FragmentDefinition(node) {\n fragmentDefs.push(node);\n return false;\n },\n Document: {\n leave() {\n for (const fragmentDef of fragmentDefs) {\n const fragName = fragmentDef.name.value;\n if (!fragmentNameUsed.has(fragName)) {\n context.reportError(\n new GraphQLError(`Fragment \"${fragName}\" is never used.`, {\n nodes: fragmentDef,\n }),\n );\n }\n }\n },\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoUnusedFragmentsRule.mjs b/validation/rules/NoUnusedFragmentsRule.mjs new file mode 100644 index 0000000000..95e9eb8601 --- /dev/null +++ b/validation/rules/NoUnusedFragmentsRule.mjs @@ -0,0 +1,38 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * No unused fragments + * + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. + * + * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used + */ +export function NoUnusedFragmentsRule(context) { + const fragmentNameUsed = new Set(); + const fragmentDefs = []; + return { + OperationDefinition(operation) { + for (const fragment of context.getRecursivelyReferencedFragments(operation)) { + fragmentNameUsed.add(fragment.name.value); + } + return false; + }, + FragmentDefinition(node) { + fragmentDefs.push(node); + return false; + }, + Document: { + leave() { + for (const fragmentDef of fragmentDefs) { + const fragName = fragmentDef.name.value; + if (!fragmentNameUsed.has(fragName)) { + context.reportError(new GraphQLError(`Fragment "${fragName}" is never used.`, { + nodes: fragmentDef, + })); + } + } + }, + }, + }; +} +//# sourceMappingURL=NoUnusedFragmentsRule.js.map \ No newline at end of file diff --git a/validation/rules/NoUnusedFragmentsRule.mjs.map b/validation/rules/NoUnusedFragmentsRule.mjs.map new file mode 100644 index 0000000000..8ede497861 --- /dev/null +++ b/validation/rules/NoUnusedFragmentsRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"NoUnusedFragmentsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoUnusedFragmentsRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAO3D;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA6B;IAE7B,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3C,MAAM,YAAY,GAAkC,EAAE,CAAC;IAEvD,OAAO;QACL,mBAAmB,CAAC,SAAS;YAC3B,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,iCAAiC,CAC9D,SAAS,CACV,EAAE,CAAC;gBACF,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5C,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,kBAAkB,CAAC,IAAI;YACrB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,QAAQ,EAAE;YACR,KAAK;gBACH,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;oBACvC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;oBACxC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACpC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CAAC,aAAa,QAAQ,kBAAkB,EAAE;4BACxD,KAAK,EAAE,WAAW;yBACnB,CAAC,CACH,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FragmentDefinitionNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * No unused fragments\n *\n * A GraphQL document is only valid if all fragment definitions are spread\n * within operations, or spread within other fragments spread within operations.\n *\n * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used\n */\nexport function NoUnusedFragmentsRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const fragmentNameUsed = new Set();\n const fragmentDefs: Array = [];\n\n return {\n OperationDefinition(operation) {\n for (const fragment of context.getRecursivelyReferencedFragments(\n operation,\n )) {\n fragmentNameUsed.add(fragment.name.value);\n }\n return false;\n },\n FragmentDefinition(node) {\n fragmentDefs.push(node);\n return false;\n },\n Document: {\n leave() {\n for (const fragmentDef of fragmentDefs) {\n const fragName = fragmentDef.name.value;\n if (!fragmentNameUsed.has(fragName)) {\n context.reportError(\n new GraphQLError(`Fragment \"${fragName}\" is never used.`, {\n nodes: fragmentDef,\n }),\n );\n }\n }\n },\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoUnusedVariablesRule.d.ts b/validation/rules/NoUnusedVariablesRule.d.ts new file mode 100644 index 0000000000..136793e879 --- /dev/null +++ b/validation/rules/NoUnusedVariablesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + * + * See https://spec.graphql.org/draft/#sec-All-Variables-Used + */ +export declare function NoUnusedVariablesRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/NoUnusedVariablesRule.js b/validation/rules/NoUnusedVariablesRule.js new file mode 100644 index 0000000000..8eb0f10bdb --- /dev/null +++ b/validation/rules/NoUnusedVariablesRule.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NoUnusedVariablesRule = NoUnusedVariablesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + * + * See https://spec.graphql.org/draft/#sec-All-Variables-Used + */ +function NoUnusedVariablesRule(context) { + return { + FragmentDefinition(fragment) { + const usages = context.getVariableUsages(fragment); + const argumentNameUsed = new Set(usages.map(({ node }) => node.name.value)); + const variableDefinitions = fragment.variableDefinitions ?? []; + for (const varDef of variableDefinitions) { + const argName = varDef.variable.name.value; + if (!argumentNameUsed.has(argName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Variable "$${argName}" is never used in fragment "${fragment.name.value}".`, { nodes: varDef })); + } + } + }, + OperationDefinition(operation) { + const usages = context.getRecursiveVariableUsages(operation); + const operationVariableNameUsed = new Set(); + for (const { node, fragmentVariableDefinition } of usages) { + const varName = node.name.value; + if (!fragmentVariableDefinition) { + operationVariableNameUsed.add(varName); + } + } + const variableDefinitions = operation.variableDefinitions ?? []; + for (const variableDef of variableDefinitions) { + const variableName = variableDef.variable.name.value; + if (!operationVariableNameUsed.has(variableName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(operation.name + ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` + : `Variable "$${variableName}" is never used.`, { nodes: variableDef })); + } + } + }, + }; +} +//# sourceMappingURL=NoUnusedVariablesRule.js.map \ No newline at end of file diff --git a/validation/rules/NoUnusedVariablesRule.js.map b/validation/rules/NoUnusedVariablesRule.js.map new file mode 100644 index 0000000000..b5e131d23c --- /dev/null +++ b/validation/rules/NoUnusedVariablesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NoUnusedVariablesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoUnusedVariablesRule.ts"],"names":[],"mappings":";;AAcA,sDA8CC;AA5DD,iEAA2D;AAM3D;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CAAC,OAA0B;IAC9D,OAAO;QACL,kBAAkB,CAAC,QAAQ;YACzB,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YACnD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAC1C,CAAC;YACF,MAAM,mB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AC,KAAK,IAAI;wBACrF,CAAC,CAAC,cAAc,YAAY,kBAAkB,EAChD,EAAE,KAAK,EAAE,WAAW,EAAE,CACvB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * No unused variables\n *\n * A GraphQL operation is only valid if all variables defined by an operation\n * are used, either directly or within a spread fragment.\n *\n * See https://spec.graphql.org/draft/#sec-All-Variables-Used\n */\nexport function NoUnusedVariablesRule(context: ValidationContext): ASTVisitor {\n return {\n FragmentDefinition(fragment) {\n const usages = context.getVariableUsages(fragment);\n const argumentNameUsed = new Set(\n usages.map(({ node }) => node.name.value),\n );\n const variableDefinitions = fragment.variableDefinitions ?? [];\n for (const varDef of variableDefinitions) {\n const argName = varDef.variable.name.value;\n if (!argumentNameUsed.has(argName)) {\n context.reportError(\n new GraphQLError(\n `Variable \"$${argName}\" is never used in fragment \"${fragment.name.value}\".`,\n { nodes: varDef },\n ),\n );\n }\n }\n },\n OperationDefinition(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n const operationVariableNameUsed = new Set();\n for (const { node, fragmentVariableDefinition } of usages) {\n const varName = node.name.value;\n if (!fragmentVariableDefinition) {\n operationVariableNameUsed.add(varName);\n }\n }\n\n const variableDefinitions = operation.variableDefinitions ?? [];\n for (const variableDef of variableDefinitions) {\n const variableName = variableDef.variable.name.value;\n if (!operationVariableNameUsed.has(variableName)) {\n context.reportError(\n new GraphQLError(\n operation.name\n ? `Variable \"$${variableName}\" is never used in operation \"${operation.name.value}\".`\n : `Variable \"$${variableName}\" is never used.`,\n { nodes: variableDef },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/NoUnusedVariablesRule.mjs b/validation/rules/NoUnusedVariablesRule.mjs new file mode 100644 index 0000000000..ecfb3a148d --- /dev/null +++ b/validation/rules/NoUnusedVariablesRule.mjs @@ -0,0 +1,44 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + * + * See https://spec.graphql.org/draft/#sec-All-Variables-Used + */ +export function NoUnusedVariablesRule(context) { + return { + FragmentDefinition(fragment) { + const usages = context.getVariableUsages(fragment); + const argumentNameUsed = new Set(usages.map(({ node }) => node.name.value)); + const variableDefinitions = fragment.variableDefinitions ?? []; + for (const varDef of variableDefinitions) { + const argName = varDef.variable.name.value; + if (!argumentNameUsed.has(argName)) { + context.reportError(new GraphQLError(`Variable "$${argName}" is never used in fragment "${fragment.name.value}".`, { nodes: varDef })); + } + } + }, + OperationDefinition(operation) { + const usages = context.getRecursiveVariableUsages(operation); + const operationVariableNameUsed = new Set(); + for (const { node, fragmentVariableDefinition } of usages) { + const varName = node.name.value; + if (!fragmentVariableDefinition) { + operationVariableNameUsed.add(varName); + } + } + const variableDefinitions = operation.variableDefinitions ?? []; + for (const variableDef of variableDefinitions) { + const variableName = variableDef.variable.name.value; + if (!operationVariableNameUsed.has(variableName)) { + context.reportError(new GraphQLError(operation.name + ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` + : `Variable "$${variableName}" is never used.`, { nodes: variableDef })); + } + } + }, + }; +} +//# sourceMappingURL=NoUnusedVariablesRule.js.map \ No newline at end of file diff --git a/validation/rules/NoUnusedVariablesRule.mjs.map b/validation/rules/NoUnusedVariablesRule.mjs.map new file mode 100644 index 0000000000..2d42fa1ed0 --- /dev/null +++ b/validation/rules/NoUnusedVariablesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"NoUnusedVariablesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/NoUnusedVariablesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,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I,mBAAmB,EAAE,CAAC;gBAC9C,MAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;gBACrD,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;oBACjD,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,SAAS,CAAC,IAAI;wBACZ,CAAC,CAAC,cAAc,YAAY,iCAAiC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI;wBACrF,CAAC,CAAC,cAAc,YAAY,kBAAkB,EAChD,EAAE,KAAK,EAAE,WAAW,EAAE,CACvB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * No unused variables\n *\n * A GraphQL operation is only valid if all variables defined by an operation\n * are used, either directly or within a spread fragment.\n *\n * See https://spec.graphql.org/draft/#sec-All-Variables-Used\n */\nexport function NoUnusedVariablesRule(context: ValidationContext): ASTVisitor {\n return {\n FragmentDefinition(fragment) {\n const usages = context.getVariableUsages(fragment);\n const argumentNameUsed = new Set(\n usages.map(({ node }) => node.name.value),\n );\n const variableDefinitions = fragment.variableDefinitions ?? [];\n for (const varDef of variableDefinitions) {\n const argName = varDef.variable.name.value;\n if (!argumentNameUsed.has(argName)) {\n context.reportError(\n new GraphQLError(\n `Variable \"$${argName}\" is never used in fragment \"${fragment.name.value}\".`,\n { nodes: varDef },\n ),\n );\n }\n }\n },\n OperationDefinition(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n const operationVariableNameUsed = new Set();\n for (const { node, fragmentVariableDefinition } of usages) {\n const varName = node.name.value;\n if (!fragmentVariableDefinition) {\n operationVariableNameUsed.add(varName);\n }\n }\n\n const variableDefinitions = operation.variableDefinitions ?? [];\n for (const variableDef of variableDefinitions) {\n const variableName = variableDef.variable.name.value;\n if (!operationVariableNameUsed.has(variableName)) {\n context.reportError(\n new GraphQLError(\n operation.name\n ? `Variable \"$${variableName}\" is never used in operation \"${operation.name.value}\".`\n : `Variable \"$${variableName}\" is never used.`,\n { nodes: variableDef },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts b/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts new file mode 100644 index 0000000000..7eff5e3831 --- /dev/null +++ b/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts @@ -0,0 +1,12 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Overlapping fields can be merged + * + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. + * + * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging + */ +export declare function OverlappingFieldsCanBeMergedRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/OverlappingFieldsCanBeMergedRule.js b/validation/rules/OverlappingFieldsCanBeMergedRule.js new file mode 100644 index 0000000000..674fd8a1d1 --- /dev/null +++ b/validation/rules/OverlappingFieldsCanBeMergedRule.js @@ -0,0 +1,596 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OverlappingFieldsCanBeMergedRule = OverlappingFieldsCanBeMergedRule; +const inspect_js_1 = require("../../jsutils/inspect.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const printer_js_1 = require("../../language/printer.js"); +const definition_js_1 = require("../../type/definition.js"); +const sortValueNode_js_1 = require("../../utilities/sortValueNode.js"); +const typeFromAST_js_1 = require("../../utilities/typeFromAST.js"); +/* eslint-disable @typescript-eslint/max-params */ +// This file contains a lot of such errors but we plan to refactor it anyway +// so just disable it for entire file. +function reasonMessage(reason) { + if (Array.isArray(reason)) { + return reason + .map(([responseName, subReason]) => `subfields "${responseName}" conflict because ` + + reasonMessage(subReason)) + .join(' and '); + } + return reason; +} +/** + * Overlapping fields can be merged + * + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. + * + * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging + */ +function OverlappingFieldsCanBeMergedRule(context) { + // A memoization for when fields and a fragment or two fragments are compared + // "between" each other for conflicts. Comparisons made be made many times, + // so memoizing this can dramatically improve the performance of this validator. + const comparedFieldsAndFragmentPairs = new OrderedPairSet(); + const comparedFragmentPairs = new PairSet(); + // A cache for the "field map" and list of fragment spreads found in any given + // selection set. Selection sets may be asked for this information multiple + // times, so this improves the performance of this validator. + const cachedFieldsAndFragmentSpreads = new Map(); + return { + SelectionSet(selectionSet) { + const conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, context.getParentType(), selectionSet); + for (const [[responseName, reason], fields1, fields2] of conflicts) { + const reasonMsg = reasonMessage(reason); + context.reportError(new GraphQLError_js_1.GraphQLError(`Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, { nodes: fields1.concat(fields2) })); + } + }, + }; +} +/** + * Algorithm: + * + * Conflicts occur when two fields exist in a query which will produce the same + * response name, but represent differing values, thus creating a conflict. + * The algorithm below finds all conflicts via making a series of comparisons + * between fields. In order to compare as few fields as possible, this makes + * a series of comparisons "within" sets of fields and "between" sets of fields. + * + * Given any selection set, a collection produces both a set of fields by + * also including all inline fragments, as well as a list of fragments + * referenced by fragment spreads. + * + * A) Each selection set represented in the document first compares "within" its + * collected set of fields, finding any conflicts between every pair of + * overlapping fields. + * Note: This is the *only time* that a the fields "within" a set are compared + * to each other. After this only fields "between" sets are compared. + * + * B) Also, if any fragment is referenced in a selection set, then a + * comparison is made "between" the original set of fields and the + * referenced fragment. + * + * C) Also, if multiple fragments are referenced, then comparisons + * are made "between" each referenced fragment. + * + * D) When comparing "between" a set of fields and a referenced fragment, first + * a comparison is made between each field in the original set of fields and + * each field in the the referenced set of fields. + * + * E) Also, if any fragment is referenced in the referenced selection set, + * then a comparison is made "between" the original set of fields and the + * referenced fragment (recursively referring to step D). + * + * F) When comparing "between" two fragments, first a comparison is made between + * each field in the first referenced set of fields and each field in the the + * second referenced set of fields. + * + * G) Also, any fragments referenced by the first must be compared to the + * second, and any fragments referenced by the second must be compared to the + * first (recursively referring to step F). + * + * H) When comparing two fields, if both have selection sets, then a comparison + * is made "between" both selection sets, first comparing the set of fields in + * the first selection set with the set of fields in the second. + * + * I) Also, if any fragment is referenced in either selection set, then a + * comparison is made "between" the other set of fields and the + * referenced fragment. + * + * J) Also, if two fragments are referenced in both selection sets, then a + * comparison is made "between" the two fragments. + * + */ +// Find all conflicts found "within" a selection set, including those found +// via spreading in fragments. Called when visiting each SelectionSet in the +// GraphQL Document. +function findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentType, selectionSet) { + const conflicts = []; + const [fieldMap, fragmentSpreads] = getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType, selectionSet, undefined); + // (A) Find find all conflicts "within" the fields and f of this selection set. + // Note: this is the *only place* `collectConflictsWithin` is called. + collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, fieldMap); + if (fragmentSpreads.length !== 0) { + // (B) Then collect conflicts between these fields and those represented by + // each spread found. + for (let i = 0; i < fragmentSpreads.length; i++) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, false, fieldMap, fragmentSpreads[i]); + // (C) Then compare this fragment with all other fragments found in this + // selection set to collect conflicts between fragments spread together. + // This compares each item in the list of fragment spreads to every other + // item in that same list (except for itself). + for (let j = i + 1; j < fragmentSpreads.length; j++) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, false, fragmentSpreads[i], fragmentSpreads[j]); + } + } + } + return conflicts; +} +// Collect all conflicts found between a set of fields and a fragment reference +// including via spreading in any nested fragments. +function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentSpread) { + // Memoize so the fields and fragments are not compared for conflicts more + // than once. + if (comparedFieldsAndFragmentPairs.has(fieldMap, fragmentSpread.key, areMutuallyExclusive)) { + return; + } + comparedFieldsAndFragmentPairs.add(fieldMap, fragmentSpread.key, areMutuallyExclusive); + const fragment = context.getFragment(fragmentSpread.node.name.value); + if (!fragment) { + return; + } + const [fieldMap2, referencedFragmentSpreads] = getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment, fragmentSpread.varMap); + // Do not compare a fragment's fieldMap to itself. + if (fieldMap === fieldMap2) { + return; + } + // (D) First collect any conflicts between the provided collection of fields + // and the collection of fields represented by the given fragment. + collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap, undefined, fieldMap2, fragmentSpread.varMap); + // (E) Then collect any conflicts between the provided collection of fields + // and any fragment names found in the given fragment. + for (const referencedFragmentSpread of referencedFragmentSpreads) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap, referencedFragmentSpread); + } +} +// Collect all conflicts found between two fragments, including via spreading in +// any nested fragments. +function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fragmentSpread1, fragmentSpread2) { + // No need to compare a fragment to itself. + if (fragmentSpread1.key === fragmentSpread2.key) { + return; + } + if (fragmentSpread1.node.name.value === fragmentSpread2.node.name.value) { + if (!sameArguments(fragmentSpread1.node.arguments, fragmentSpread1.varMap, fragmentSpread2.node.arguments, fragmentSpread2.varMap)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Spreads "${fragmentSpread1.node.name.value}" conflict because ${fragmentSpread1.key} and ${fragmentSpread2.key} have different fragment arguments.`, { nodes: [fragmentSpread1.node, fragmentSpread2.node] })); + return; + } + } + // Memoize so two fragments are not compared for conflicts more than once. + if (comparedFragmentPairs.has(fragmentSpread1.key, fragmentSpread2.key, areMutuallyExclusive)) { + return; + } + comparedFragmentPairs.add(fragmentSpread1.key, fragmentSpread2.key, areMutuallyExclusive); + const fragment1 = context.getFragment(fragmentSpread1.node.name.value); + const fragment2 = context.getFragment(fragmentSpread2.node.name.value); + if (!fragment1 || !fragment2) { + return; + } + const [fieldMap1, referencedFragmentSpreads1] = getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment1, fragmentSpread1.varMap); + const [fieldMap2, referencedFragmentSpreads2] = getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment2, fragmentSpread2.varMap); + // (F) First, collect all conflicts between these two collections of fields + // (not including any nested fragments). + collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentSpread1.varMap, fieldMap2, fragmentSpread2.varMap); + // (G) Then collect conflicts between the first fragment and any nested + // fragments spread in the second fragment. + for (const referencedFragmentSpread2 of referencedFragmentSpreads2) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fragmentSpread1, referencedFragmentSpread2); + } + // (G) Then collect conflicts between the second fragment and any nested + // fragments spread in the first fragment. + for (const referencedFragmentSpread1 of referencedFragmentSpreads1) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, referencedFragmentSpread1, fragmentSpread2); + } +} +// Find all conflicts found between two selection sets, including those found +// via spreading in fragments. Called when determining if conflicts exist +// between the sub-fields of two overlapping fields. +function findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, parentType1, selectionSet1, varMap1, parentType2, selectionSet2, varMap2) { + const conflicts = []; + const [fieldMap1, fragmentSpreads1] = getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType1, selectionSet1, varMap1); + const [fieldMap2, fragmentSpreads2] = getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType2, selectionSet2, varMap2); + // (H) First, collect all conflicts between these two collections of field. + collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, varMap1, fieldMap2, varMap2); + // (I) Then collect conflicts between the first collection of fields and + // those referenced by each fragment name associated with the second. + for (const fragmentSpread2 of fragmentSpreads2) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentSpread2); + } + // (I) Then collect conflicts between the second collection of fields and + // those referenced by each fragment name associated with the first. + for (const fragmentSpread1 of fragmentSpreads1) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap2, fragmentSpread1); + } + // (J) Also collect conflicts between any fragment spreads by the first and + // fragment spreads by the second. This compares each item in the first set of + // spreads to each item in the second set of spreads. + for (const fragmentSpread1 of fragmentSpreads1) { + for (const fragmentSpread2 of fragmentSpreads2) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fragmentSpread1, fragmentSpread2); + } + } + return conflicts; +} +// Collect all Conflicts "within" one collection of fields. +function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, fieldMap) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For every response name, if there are multiple fields, they + // must be compared to find a potential conflict. + for (const [responseName, fields] of fieldMap.entries()) { + // This compares every field in the list to every other field in this list + // (except to itself). If the list only has one item, nothing needs to + // be compared. + if (fields.length > 1) { + for (let i = 0; i < fields.length; i++) { + for (let j = i + 1; j < fields.length; j++) { + const conflict = findConflict(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, false, // within one collection is never mutually exclusive + responseName, fields[i], undefined, fields[j], undefined); + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} +// Collect all Conflicts between two collections of fields. This is similar to, +// but different from the `collectConflictsWithin` function above. This check +// assumes that `collectConflictsWithin` has already been called on each +// provided collection of fields. This is true because this validator traverses +// each individual selection set. +function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, fieldMap1, varMap1, fieldMap2, varMap2) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For any response name which appears in both provided field + // maps, each field from the first field map must be compared to every field + // in the second field map to find potential conflicts. + for (const [responseName, fields1] of fieldMap1.entries()) { + const fields2 = fieldMap2.get(responseName); + if (fields2 != null) { + for (const field1 of fields1) { + for (const field2 of fields2) { + const conflict = findConflict(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, varMap1, field2, varMap2); + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} +// Determines if there is a conflict between two particular fields, including +// comparing their sub-fields. +function findConflict(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, varMap1, field2, varMap2) { + const [parentType1, node1, def1] = field1; + const [parentType2, node2, def2] = field2; + // If it is known that two fields could not possibly apply at the same + // time, due to the parent types, then it is safe to permit them to diverge + // in aliased field or arguments used as they will not present any ambiguity + // by differing. + // It is known that two parent types could never overlap if they are + // different Object types. Interface or Union types might overlap - if not + // in the current state of the schema, then perhaps in some future version, + // thus may not safely diverge. + const areMutuallyExclusive = parentFieldsAreMutuallyExclusive || + (parentType1 !== parentType2 && + (0, definition_js_1.isObjectType)(parentType1) && + (0, definition_js_1.isObjectType)(parentType2)); + if (!areMutuallyExclusive) { + // Two aliases must refer to the same field. + const name1 = node1.name.value; + const name2 = node2.name.value; + if (name1 !== name2) { + return [ + [responseName, `"${name1}" and "${name2}" are different fields`], + [node1], + [node2], + ]; + } + // Two field calls must have the same arguments. + if (!sameArguments(node1.arguments, varMap1, node2.arguments, varMap2)) { + return [ + [responseName, 'they have differing arguments'], + [node1], + [node2], + ]; + } + } + const directives1 = node1.directives ?? []; + const directives2 = node2.directives ?? []; + const overlappingStreamReason = hasNoOverlappingStreams(directives1, varMap1, directives2, varMap2); + if (overlappingStreamReason !== undefined) { + return [[responseName, overlappingStreamReason], [node1], [node2]]; + } + // The return type for each field. + const type1 = def1?.type; + const type2 = def2?.type; + if (type1 && type2 && doTypesConflict(type1, type2)) { + return [ + [ + responseName, + `they return conflicting types "${(0, inspect_js_1.inspect)(type1)}" and "${(0, inspect_js_1.inspect)(type2)}"`, + ], + [node1], + [node2], + ]; + } + // Collect and compare sub-fields. Use the same "visited fragment spreads" list + // for both collections so fields in a fragment reference are never + // compared to themselves. + const selectionSet1 = node1.selectionSet; + const selectionSet2 = node2.selectionSet; + if (selectionSet1 && selectionSet2) { + const conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, (0, definition_js_1.getNamedType)(type1), selectionSet1, varMap1, (0, definition_js_1.getNamedType)(type2), selectionSet2, varMap2); + return subfieldConflicts(conflicts, responseName, node1, node2); + } +} +function sameArguments(args1, varMap1, args2, varMap2) { + if (args1 === undefined || args1.length === 0) { + return args2 === undefined || args2.length === 0; + } + if (args2 === undefined || args2.length === 0) { + return false; + } + if (args1.length !== args2.length) { + return false; + } + const values2 = new Map(args2.map(({ name, value }) => [ + name.value, + varMap2 === undefined ? value : replaceFragmentVariables(value, varMap2), + ])); + return args1.every((arg1) => { + let value1 = arg1.value; + if (varMap1) { + value1 = replaceFragmentVariables(value1, varMap1); + } + const value2 = values2.get(arg1.name.value); + if (value2 === undefined) { + return false; + } + return stringifyValue(value1) === stringifyValue(value2); + }); +} +function replaceFragmentVariables(valueNode, varMap) { + switch (valueNode.kind) { + case kinds_js_1.Kind.VARIABLE: + return varMap.get(valueNode.name.value) ?? valueNode; + case kinds_js_1.Kind.LIST: + return { + ...valueNode, + values: valueNode.values.map((node) => replaceFragmentVariables(node, varMap)), + }; + case kinds_js_1.Kind.OBJECT: + return { + ...valueNode, + fields: valueNode.fields.map((field) => ({ + ...field, + value: replaceFragmentVariables(field.value, varMap), + })), + }; + default: { + return valueNode; + } + } +} +function stringifyValue(value) { + return (0, printer_js_1.print)((0, sortValueNode_js_1.sortValueNode)(value)); +} +function getStreamDirective(directives) { + return directives.find((directive) => directive.name.value === 'stream'); +} +function hasNoOverlappingStreams(directives1, varMap1, directives2, varMap2) { + const stream1 = getStreamDirective(directives1); + const stream2 = getStreamDirective(directives2); + if (!stream1 && !stream2) { + // both fields do not have streams + return; + } + else if (stream1 && stream2) { + // check if both fields have equivalent streams + if (sameArguments(stream1.arguments, varMap1, stream2.arguments, varMap2)) { + // This was allowed in previous alpha versions of `graphql-js`. + return 'they have overlapping stream directives. See https://github.com/graphql/defer-stream-wg/discussions/100'; + } + return 'they have overlapping stream directives'; + } + // fields have a mix of stream and no stream + return 'they have overlapping stream directives'; +} +// Two types conflict if both types could not apply to a value simultaneously. +// Composite types are ignored as their individual field types will be compared +// later recursively. However List and Non-Null types must match. +function doTypesConflict(type1, type2) { + if ((0, definition_js_1.isListType)(type1)) { + return (0, definition_js_1.isListType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + if ((0, definition_js_1.isListType)(type2)) { + return true; + } + if ((0, definition_js_1.isNonNullType)(type1)) { + return (0, definition_js_1.isNonNullType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + if ((0, definition_js_1.isNonNullType)(type2)) { + return true; + } + if ((0, definition_js_1.isLeafType)(type1) || (0, definition_js_1.isLeafType)(type2)) { + return type1 !== type2; + } + return false; +} +// Given a selection set, return the collection of fields (a mapping of response +// name to field nodes and definitions) as well as a list of fragment spreads +// referenced via fragment spreads. +function getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType, selectionSet, varMap) { + const cached = cachedFieldsAndFragmentSpreads.get(selectionSet); + if (cached) { + return cached; + } + const nodeAndDefs = new Map(); + const fragmentSpreads = new Map(); + _collectFieldsAndFragmentSpreads(context, parentType, selectionSet, nodeAndDefs, fragmentSpreads, varMap); + const result = [ + nodeAndDefs, + Array.from(fragmentSpreads.values()), + ]; + cachedFieldsAndFragmentSpreads.set(selectionSet, result); + return result; +} +// Given a reference to a fragment, return the represented collection of fields +// as well as a list of nested fragment spreads referenced via fragment spreads. +function getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment, varMap) { + // Short-circuit building a type from the node if possible. + const cached = cachedFieldsAndFragmentSpreads.get(fragment.selectionSet); + if (cached) { + return cached; + } + const fragmentType = (0, typeFromAST_js_1.typeFromAST)(context.getSchema(), fragment.typeCondition); + return getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragmentType, fragment.selectionSet, varMap); +} +function _collectFieldsAndFragmentSpreads(context, parentType, selectionSet, nodeAndDefs, fragmentSpreads, varMap) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case kinds_js_1.Kind.FIELD: { + const fieldName = selection.name.value; + let fieldDef; + if ((0, definition_js_1.isObjectType)(parentType) || (0, definition_js_1.isInterfaceType)(parentType)) { + fieldDef = parentType.getFields()[fieldName]; + } + const responseName = selection.alias + ? selection.alias.value + : fieldName; + let nodeAndDefsList = nodeAndDefs.get(responseName); + if (nodeAndDefsList == null) { + nodeAndDefsList = []; + nodeAndDefs.set(responseName, nodeAndDefsList); + } + nodeAndDefsList.push([parentType, selection, fieldDef]); + break; + } + case kinds_js_1.Kind.FRAGMENT_SPREAD: { + const fragmentSpread = getFragmentSpread(context, selection, varMap); + fragmentSpreads.set(fragmentSpread.key, fragmentSpread); + break; + } + case kinds_js_1.Kind.INLINE_FRAGMENT: { + const typeCondition = selection.typeCondition; + const inlineFragmentType = typeCondition + ? (0, typeFromAST_js_1.typeFromAST)(context.getSchema(), typeCondition) + : parentType; + _collectFieldsAndFragmentSpreads(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentSpreads, varMap); + break; + } + } + } +} +function getFragmentSpread(context, fragmentSpreadNode, varMap) { + let key = ''; + const newVarMap = new Map(); + const fragmentSignature = context.getFragmentSignatureByName()(fragmentSpreadNode.name.value); + const argMap = new Map(); + if (fragmentSpreadNode.arguments) { + for (const arg of fragmentSpreadNode.arguments) { + argMap.set(arg.name.value, arg.value); + } + } + if (fragmentSignature?.variableDefinitions) { + key += fragmentSpreadNode.name.value + '('; + for (const [varName, variable] of fragmentSignature.variableDefinitions) { + const value = argMap.get(varName); + if (value) { + key += varName + ': ' + (0, printer_js_1.print)((0, sortValueNode_js_1.sortValueNode)(value)); + } + const arg = argMap.get(varName); + if (arg !== undefined) { + newVarMap.set(varName, varMap !== undefined ? replaceFragmentVariables(arg, varMap) : arg); + } + else if (variable.defaultValue) { + newVarMap.set(varName, variable.defaultValue); + } + } + key += ')'; + } + return { + key, + node: fragmentSpreadNode, + varMap: newVarMap.size > 0 ? newVarMap : undefined, + }; +} +// Given a series of Conflicts which occurred between two sub-fields, generate +// a single Conflict. +function subfieldConflicts(conflicts, responseName, node1, node2) { + if (conflicts.length > 0) { + return [ + [responseName, conflicts.map(([reason]) => reason)], + [node1, ...conflicts.map(([, fields1]) => fields1).flat()], + [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], + ]; + } +} +/** + * A way to keep track of pairs of things where the ordering of the pair + * matters. + * + * Provides a third argument for has/set to allow flagging the pair as + * weakly or strongly present within the collection. + */ +class OrderedPairSet { + constructor() { + this._data = new Map(); + } + has(a, b, weaklyPresent) { + const result = this._data.get(a)?.get(b); + if (result === undefined) { + return false; + } + return weaklyPresent ? true : weaklyPresent === result; + } + add(a, b, weaklyPresent) { + const map = this._data.get(a); + if (map === undefined) { + this._data.set(a, new Map([[b, weaklyPresent]])); + } + else { + map.set(b, weaklyPresent); + } + } +} +/** + * A way to keep track of pairs of similar things when the ordering of the pair + * does not matter. + */ +class PairSet { + constructor() { + this._orderedPairSet = new OrderedPairSet(); + } + has(a, b, weaklyPresent) { + return a < b + ? this._orderedPairSet.has(a, b, weaklyPresent) + : this._orderedPairSet.has(b, a, weaklyPresent); + } + add(a, b, weaklyPresent) { + if (a < b) { + this._orderedPairSet.add(a, b, weaklyPresent); + } + else { + this._orderedPairSet.add(b, a, weaklyPresent); + } + } +} +//# sourceMappingURL=OverlappingFieldsCanBeMergedRule.js.map \ No newline at end of file diff --git a/validation/rules/OverlappingFieldsCanBeMergedRule.js.map b/validation/rules/OverlappingFieldsCanBeMergedRule.js.map new file mode 100644 index 0000000000..cf343191e4 --- /dev/null +++ b/validation/rules/OverlappingFieldsCanBeMergedRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OverlappingFieldsCanBeMergedRule.js","sourceRoot":"","sources":["../../../src/validation/rules/OverlappingFieldsCanBeMergedRule.ts"],"names":[],"mappings":";;AAgEA,4EAsCC;AAtGD,yDAAmD;AAGnD,iEAA2D;AAY3D,sDAA+C;AAC/C,0DAAkD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":["import { inspect } from '../../jsutils/inspect.js';\nimport type { Maybe } from '../../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n ArgumentNode,\n DirectiveNode,\n FieldNode,\n FragmentArgumentNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n SelectionSetNode,\n ValueNode,\n} from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type {\n GraphQLField,\n GraphQLNamedType,\n GraphQLOutputType,\n} from '../../type/definition.js';\nimport {\n getNamedType,\n isInterfaceType,\n isLeafType,\n isListType,\n isNonNullType,\n isObjectType,\n} from '../../type/definition.js';\n\nimport { sortValueNode } from '../../utilities/sortValueNode.js';\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/* eslint-disable @typescript-eslint/max-params */\n// This file contains a lot of such errors but we plan to refactor it anyway\n// so just disable it for entire file.\n\nfunction reasonMessage(reason: ConflictReasonMessage): string {\n if (Array.isArray(reason)) {\n return reason\n .map(\n ([responseName, subReason]) =>\n `subfields \"${responseName}\" conflict because ` +\n reasonMessage(subReason),\n )\n .join(' and ');\n }\n return reason;\n}\n\n/**\n * Overlapping fields can be merged\n *\n * A selection set is only valid if all fields (including spreading any\n * fragments) either correspond to distinct response names or can be merged\n * without ambiguity.\n *\n * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging\n */\nexport function OverlappingFieldsCanBeMergedRule(\n context: ValidationContext,\n): ASTVisitor {\n // A memoization for when fields and a fragment or two fragments are compared\n // \"between\" each other for conflicts. Comparisons made be made many times,\n // so memoizing this can dramatically improve the performance of this validator.\n const comparedFieldsAndFragmentPairs = new OrderedPairSet<\n NodeAndDefCollection,\n string\n >();\n const comparedFragmentPairs = new PairSet();\n\n // A cache for the \"field map\" and list of fragment spreads found in any given\n // selection set. Selection sets may be asked for this information multiple\n // times, so this improves the performance of this validator.\n const cachedFieldsAndFragmentSpreads = new Map();\n\n return {\n SelectionSet(selectionSet) {\n const conflicts = findConflictsWithinSelectionSet(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n context.getParentType(),\n selectionSet,\n );\n for (const [[responseName, reason], fields1, fields2] of conflicts) {\n const reasonMsg = reasonMessage(reason);\n context.reportError(\n new GraphQLError(\n `Fields \"${responseName}\" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`,\n { nodes: fields1.concat(fields2) },\n ),\n );\n }\n },\n };\n}\n\ntype Conflict = [ConflictReason, Array, Array];\n// Field name and reason.\ntype ConflictReason = [string, ConflictReasonMessage];\n// Reason is a string, or a nested list of conflicts.\ntype ConflictReasonMessage = string | Array;\n// Tuple defining a field node in a context.\ntype NodeAndDef = [\n Maybe,\n FieldNode,\n Maybe>,\n];\n// Map of array of those.\ntype NodeAndDefCollection = Map>;\ninterface FragmentSpread {\n key: string;\n node: FragmentSpreadNode;\n varMap: Map | undefined;\n}\ntype FragmentSpreads = ReadonlyArray;\ntype FieldsAndFragmentSpreads = readonly [\n NodeAndDefCollection,\n FragmentSpreads,\n];\n\n/**\n * Algorithm:\n *\n * Conflicts occur when two fields exist in a query which will produce the same\n * response name, but represent differing values, thus creating a conflict.\n * The algorithm below finds all conflicts via making a series of comparisons\n * between fields. In order to compare as few fields as possible, this makes\n * a series of comparisons \"within\" sets of fields and \"between\" sets of fields.\n *\n * Given any selection set, a collection produces both a set of fields by\n * also including all inline fragments, as well as a list of fragments\n * referenced by fragment spreads.\n *\n * A) Each selection set represented in the document first compares \"within\" its\n * collected set of fields, finding any conflicts between every pair of\n * overlapping fields.\n * Note: This is the *only time* that a the fields \"within\" a set are compared\n * to each other. After this only fields \"between\" sets are compared.\n *\n * B) Also, if any fragment is referenced in a selection set, then a\n * comparison is made \"between\" the original set of fields and the\n * referenced fragment.\n *\n * C) Also, if multiple fragments are referenced, then comparisons\n * are made \"between\" each referenced fragment.\n *\n * D) When comparing \"between\" a set of fields and a referenced fragment, first\n * a comparison is made between each field in the original set of fields and\n * each field in the the referenced set of fields.\n *\n * E) Also, if any fragment is referenced in the referenced selection set,\n * then a comparison is made \"between\" the original set of fields and the\n * referenced fragment (recursively referring to step D).\n *\n * F) When comparing \"between\" two fragments, first a comparison is made between\n * each field in the first referenced set of fields and each field in the the\n * second referenced set of fields.\n *\n * G) Also, any fragments referenced by the first must be compared to the\n * second, and any fragments referenced by the second must be compared to the\n * first (recursively referring to step F).\n *\n * H) When comparing two fields, if both have selection sets, then a comparison\n * is made \"between\" both selection sets, first comparing the set of fields in\n * the first selection set with the set of fields in the second.\n *\n * I) Also, if any fragment is referenced in either selection set, then a\n * comparison is made \"between\" the other set of fields and the\n * referenced fragment.\n *\n * J) Also, if two fragments are referenced in both selection sets, then a\n * comparison is made \"between\" the two fragments.\n *\n */\n\n// Find all conflicts found \"within\" a selection set, including those found\n// via spreading in fragments. Called when visiting each SelectionSet in the\n// GraphQL Document.\nfunction findConflictsWithinSelectionSet(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n parentType: Maybe,\n selectionSet: SelectionSetNode,\n): Array {\n const conflicts: Array = [];\n\n const [fieldMap, fragmentSpreads] = getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n parentType,\n selectionSet,\n undefined,\n );\n\n // (A) Find find all conflicts \"within\" the fields and f of this selection set.\n // Note: this is the *only place* `collectConflictsWithin` is called.\n collectConflictsWithin(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n fieldMap,\n );\n\n if (fragmentSpreads.length !== 0) {\n // (B) Then collect conflicts between these fields and those represented by\n // each spread found.\n for (let i = 0; i < fragmentSpreads.length; i++) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n false,\n fieldMap,\n fragmentSpreads[i],\n );\n // (C) Then compare this fragment with all other fragments found in this\n // selection set to collect conflicts between fragments spread together.\n // This compares each item in the list of fragment spreads to every other\n // item in that same list (except for itself).\n for (let j = i + 1; j < fragmentSpreads.length; j++) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n false,\n fragmentSpreads[i],\n fragmentSpreads[j],\n );\n }\n }\n }\n return conflicts;\n}\n\n// Collect all conflicts found between a set of fields and a fragment reference\n// including via spreading in any nested fragments.\nfunction collectConflictsBetweenFieldsAndFragment(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n areMutuallyExclusive: boolean,\n fieldMap: NodeAndDefCollection,\n fragmentSpread: FragmentSpread,\n): void {\n // Memoize so the fields and fragments are not compared for conflicts more\n // than once.\n if (\n comparedFieldsAndFragmentPairs.has(\n fieldMap,\n fragmentSpread.key,\n areMutuallyExclusive,\n )\n ) {\n return;\n }\n comparedFieldsAndFragmentPairs.add(\n fieldMap,\n fragmentSpread.key,\n areMutuallyExclusive,\n );\n\n const fragment = context.getFragment(fragmentSpread.node.name.value);\n if (!fragment) {\n return;\n }\n\n const [fieldMap2, referencedFragmentSpreads] =\n getReferencedFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragment,\n fragmentSpread.varMap,\n );\n\n // Do not compare a fragment's fieldMap to itself.\n if (fieldMap === fieldMap2) {\n return;\n }\n\n // (D) First collect any conflicts between the provided collection of fields\n // and the collection of fields represented by the given fragment.\n collectConflictsBetween(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap,\n undefined,\n fieldMap2,\n fragmentSpread.varMap,\n );\n\n // (E) Then collect any conflicts between the provided collection of fields\n // and any fragment names found in the given fragment.\n for (const referencedFragmentSpread of referencedFragmentSpreads) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap,\n referencedFragmentSpread,\n );\n }\n}\n\n// Collect all conflicts found between two fragments, including via spreading in\n// any nested fragments.\nfunction collectConflictsBetweenFragments(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n areMutuallyExclusive: boolean,\n fragmentSpread1: FragmentSpread,\n fragmentSpread2: FragmentSpread,\n): void {\n // No need to compare a fragment to itself.\n if (fragmentSpread1.key === fragmentSpread2.key) {\n return;\n }\n\n if (fragmentSpread1.node.name.value === fragmentSpread2.node.name.value) {\n if (\n !sameArguments(\n fragmentSpread1.node.arguments,\n fragmentSpread1.varMap,\n fragmentSpread2.node.arguments,\n fragmentSpread2.varMap,\n )\n ) {\n context.reportError(\n new GraphQLError(\n `Spreads \"${fragmentSpread1.node.name.value}\" conflict because ${fragmentSpread1.key} and ${fragmentSpread2.key} have different fragment arguments.`,\n { nodes: [fragmentSpread1.node, fragmentSpread2.node] },\n ),\n );\n return;\n }\n }\n\n // Memoize so two fragments are not compared for conflicts more than once.\n if (\n comparedFragmentPairs.has(\n fragmentSpread1.key,\n fragmentSpread2.key,\n areMutuallyExclusive,\n )\n ) {\n return;\n }\n comparedFragmentPairs.add(\n fragmentSpread1.key,\n fragmentSpread2.key,\n areMutuallyExclusive,\n );\n\n const fragment1 = context.getFragment(fragmentSpread1.node.name.value);\n const fragment2 = context.getFragment(fragmentSpread2.node.name.value);\n if (!fragment1 || !fragment2) {\n return;\n }\n\n const [fieldMap1, referencedFragmentSpreads1] =\n getReferencedFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragment1,\n fragmentSpread1.varMap,\n );\n const [fieldMap2, referencedFragmentSpreads2] =\n getReferencedFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragment2,\n fragmentSpread2.varMap,\n );\n\n // (F) First, collect all conflicts between these two collections of fields\n // (not including any nested fragments).\n collectConflictsBetween(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap1,\n fragmentSpread1.varMap,\n fieldMap2,\n fragmentSpread2.varMap,\n );\n\n // (G) Then collect conflicts between the first fragment and any nested\n // fragments spread in the second fragment.\n for (const referencedFragmentSpread2 of referencedFragmentSpreads2) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fragmentSpread1,\n referencedFragmentSpread2,\n );\n }\n\n // (G) Then collect conflicts between the second fragment and any nested\n // fragments spread in the first fragment.\n for (const referencedFragmentSpread1 of referencedFragmentSpreads1) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n referencedFragmentSpread1,\n fragmentSpread2,\n );\n }\n}\n\n// Find all conflicts found between two selection sets, including those found\n// via spreading in fragments. Called when determining if conflicts exist\n// between the sub-fields of two overlapping fields.\nfunction findConflictsBetweenSubSelectionSets(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n areMutuallyExclusive: boolean,\n parentType1: Maybe,\n selectionSet1: SelectionSetNode,\n varMap1: Map | undefined,\n parentType2: Maybe,\n selectionSet2: SelectionSetNode,\n varMap2: Map | undefined,\n): Array {\n const conflicts: Array = [];\n\n const [fieldMap1, fragmentSpreads1] = getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n parentType1,\n selectionSet1,\n varMap1,\n );\n const [fieldMap2, fragmentSpreads2] = getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n parentType2,\n selectionSet2,\n varMap2,\n );\n\n // (H) First, collect all conflicts between these two collections of field.\n collectConflictsBetween(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap1,\n varMap1,\n fieldMap2,\n varMap2,\n );\n\n // (I) Then collect conflicts between the first collection of fields and\n // those referenced by each fragment name associated with the second.\n for (const fragmentSpread2 of fragmentSpreads2) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap1,\n fragmentSpread2,\n );\n }\n\n // (I) Then collect conflicts between the second collection of fields and\n // those referenced by each fragment name associated with the first.\n for (const fragmentSpread1 of fragmentSpreads1) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap2,\n fragmentSpread1,\n );\n }\n\n // (J) Also collect conflicts between any fragment spreads by the first and\n // fragment spreads by the second. This compares each item in the first set of\n // spreads to each item in the second set of spreads.\n for (const fragmentSpread1 of fragmentSpreads1) {\n for (const fragmentSpread2 of fragmentSpreads2) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fragmentSpread1,\n fragmentSpread2,\n );\n }\n }\n return conflicts;\n}\n\n// Collect all Conflicts \"within\" one collection of fields.\nfunction collectConflictsWithin(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n fieldMap: NodeAndDefCollection,\n): void {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For every response name, if there are multiple fields, they\n // must be compared to find a potential conflict.\n for (const [responseName, fields] of fieldMap.entries()) {\n // This compares every field in the list to every other field in this list\n // (except to itself). If the list only has one item, nothing needs to\n // be compared.\n if (fields.length > 1) {\n for (let i = 0; i < fields.length; i++) {\n for (let j = i + 1; j < fields.length; j++) {\n const conflict = findConflict(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n false, // within one collection is never mutually exclusive\n responseName,\n fields[i],\n undefined,\n fields[j],\n undefined,\n );\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n}\n\n// Collect all Conflicts between two collections of fields. This is similar to,\n// but different from the `collectConflictsWithin` function above. This check\n// assumes that `collectConflictsWithin` has already been called on each\n// provided collection of fields. This is true because this validator traverses\n// each individual selection set.\nfunction collectConflictsBetween(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n parentFieldsAreMutuallyExclusive: boolean,\n fieldMap1: NodeAndDefCollection,\n varMap1: Map | undefined,\n fieldMap2: NodeAndDefCollection,\n varMap2: Map | undefined,\n): void {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For any response name which appears in both provided field\n // maps, each field from the first field map must be compared to every field\n // in the second field map to find potential conflicts.\n for (const [responseName, fields1] of fieldMap1.entries()) {\n const fields2 = fieldMap2.get(responseName);\n if (fields2 != null) {\n for (const field1 of fields1) {\n for (const field2 of fields2) {\n const conflict = findConflict(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n parentFieldsAreMutuallyExclusive,\n responseName,\n field1,\n varMap1,\n field2,\n varMap2,\n );\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n}\n\n// Determines if there is a conflict between two particular fields, including\n// comparing their sub-fields.\nfunction findConflict(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n parentFieldsAreMutuallyExclusive: boolean,\n responseName: string,\n field1: NodeAndDef,\n varMap1: Map | undefined,\n field2: NodeAndDef,\n varMap2: Map | undefined,\n): Maybe {\n const [parentType1, node1, def1] = field1;\n const [parentType2, node2, def2] = field2;\n\n // If it is known that two fields could not possibly apply at the same\n // time, due to the parent types, then it is safe to permit them to diverge\n // in aliased field or arguments used as they will not present any ambiguity\n // by differing.\n // It is known that two parent types could never overlap if they are\n // different Object types. Interface or Union types might overlap - if not\n // in the current state of the schema, then perhaps in some future version,\n // thus may not safely diverge.\n const areMutuallyExclusive =\n parentFieldsAreMutuallyExclusive ||\n (parentType1 !== parentType2 &&\n isObjectType(parentType1) &&\n isObjectType(parentType2));\n\n if (!areMutuallyExclusive) {\n // Two aliases must refer to the same field.\n const name1 = node1.name.value;\n const name2 = node2.name.value;\n if (name1 !== name2) {\n return [\n [responseName, `\"${name1}\" and \"${name2}\" are different fields`],\n [node1],\n [node2],\n ];\n }\n\n // Two field calls must have the same arguments.\n if (!sameArguments(node1.arguments, varMap1, node2.arguments, varMap2)) {\n return [\n [responseName, 'they have differing arguments'],\n [node1],\n [node2],\n ];\n }\n }\n\n const directives1 = node1.directives ?? [];\n const directives2 = node2.directives ?? [];\n const overlappingStreamReason = hasNoOverlappingStreams(\n directives1,\n varMap1,\n directives2,\n varMap2,\n );\n if (overlappingStreamReason !== undefined) {\n return [[responseName, overlappingStreamReason], [node1], [node2]];\n }\n\n // The return type for each field.\n const type1 = def1?.type;\n const type2 = def2?.type;\n\n if (type1 && type2 && doTypesConflict(type1, type2)) {\n return [\n [\n responseName,\n `they return conflicting types \"${inspect(type1)}\" and \"${inspect(\n type2,\n )}\"`,\n ],\n [node1],\n [node2],\n ];\n }\n\n // Collect and compare sub-fields. Use the same \"visited fragment spreads\" list\n // for both collections so fields in a fragment reference are never\n // compared to themselves.\n const selectionSet1 = node1.selectionSet;\n const selectionSet2 = node2.selectionSet;\n if (selectionSet1 && selectionSet2) {\n const conflicts = findConflictsBetweenSubSelectionSets(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n getNamedType(type1),\n selectionSet1,\n varMap1,\n getNamedType(type2),\n selectionSet2,\n varMap2,\n );\n return subfieldConflicts(conflicts, responseName, node1, node2);\n }\n}\n\nfunction sameArguments(\n args1: ReadonlyArray | undefined,\n varMap1: Map | undefined,\n args2: ReadonlyArray | undefined,\n varMap2: Map | undefined,\n): boolean {\n if (args1 === undefined || args1.length === 0) {\n return args2 === undefined || args2.length === 0;\n }\n if (args2 === undefined || args2.length === 0) {\n return false;\n }\n\n if (args1.length !== args2.length) {\n return false;\n }\n\n const values2 = new Map(\n args2.map(({ name, value }) => [\n name.value,\n varMap2 === undefined ? value : replaceFragmentVariables(value, varMap2),\n ]),\n );\n return args1.every((arg1) => {\n let value1 = arg1.value;\n if (varMap1) {\n value1 = replaceFragmentVariables(value1, varMap1);\n }\n const value2 = values2.get(arg1.name.value);\n if (value2 === undefined) {\n return false;\n }\n\n return stringifyValue(value1) === stringifyValue(value2);\n });\n}\n\nfunction replaceFragmentVariables(\n valueNode: ValueNode,\n varMap: ReadonlyMap,\n): ValueNode {\n switch (valueNode.kind) {\n case Kind.VARIABLE:\n return varMap.get(valueNode.name.value) ?? valueNode;\n case Kind.LIST:\n return {\n ...valueNode,\n values: valueNode.values.map((node) =>\n replaceFragmentVariables(node, varMap),\n ),\n };\n case Kind.OBJECT:\n return {\n ...valueNode,\n fields: valueNode.fields.map((field) => ({\n ...field,\n value: replaceFragmentVariables(field.value, varMap),\n })),\n };\n default: {\n return valueNode;\n }\n }\n}\n\nfunction stringifyValue(value: ValueNode): string | null {\n return print(sortValueNode(value));\n}\n\nfunction getStreamDirective(\n directives: ReadonlyArray,\n): DirectiveNode | undefined {\n return directives.find((directive) => directive.name.value === 'stream');\n}\n\nfunction hasNoOverlappingStreams(\n directives1: ReadonlyArray,\n varMap1: Map | undefined,\n directives2: ReadonlyArray,\n varMap2: Map | undefined,\n): string | undefined {\n const stream1 = getStreamDirective(directives1);\n const stream2 = getStreamDirective(directives2);\n if (!stream1 && !stream2) {\n // both fields do not have streams\n return;\n } else if (stream1 && stream2) {\n // check if both fields have equivalent streams\n if (sameArguments(stream1.arguments, varMap1, stream2.arguments, varMap2)) {\n // This was allowed in previous alpha versions of `graphql-js`.\n return 'they have overlapping stream directives. See https://github.com/graphql/defer-stream-wg/discussions/100';\n }\n return 'they have overlapping stream directives';\n }\n // fields have a mix of stream and no stream\n return 'they have overlapping stream directives';\n}\n\n// Two types conflict if both types could not apply to a value simultaneously.\n// Composite types are ignored as their individual field types will be compared\n// later recursively. However List and Non-Null types must match.\nfunction doTypesConflict(\n type1: GraphQLOutputType,\n type2: GraphQLOutputType,\n): boolean {\n if (isListType(type1)) {\n return isListType(type2)\n ? doTypesConflict(type1.ofType, type2.ofType)\n : true;\n }\n if (isListType(type2)) {\n return true;\n }\n if (isNonNullType(type1)) {\n return isNonNullType(type2)\n ? doTypesConflict(type1.ofType, type2.ofType)\n : true;\n }\n if (isNonNullType(type2)) {\n return true;\n }\n if (isLeafType(type1) || isLeafType(type2)) {\n return type1 !== type2;\n }\n return false;\n}\n\n// Given a selection set, return the collection of fields (a mapping of response\n// name to field nodes and definitions) as well as a list of fragment spreads\n// referenced via fragment spreads.\nfunction getFieldsAndFragmentSpreads(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n parentType: Maybe,\n selectionSet: SelectionSetNode,\n varMap: Map | undefined,\n): FieldsAndFragmentSpreads {\n const cached = cachedFieldsAndFragmentSpreads.get(selectionSet);\n if (cached) {\n return cached;\n }\n const nodeAndDefs: NodeAndDefCollection = new Map();\n const fragmentSpreads = new Map();\n _collectFieldsAndFragmentSpreads(\n context,\n parentType,\n selectionSet,\n nodeAndDefs,\n fragmentSpreads,\n varMap,\n );\n const result: FieldsAndFragmentSpreads = [\n nodeAndDefs,\n Array.from(fragmentSpreads.values()),\n ];\n cachedFieldsAndFragmentSpreads.set(selectionSet, result);\n return result;\n}\n\n// Given a reference to a fragment, return the represented collection of fields\n// as well as a list of nested fragment spreads referenced via fragment spreads.\nfunction getReferencedFieldsAndFragmentSpreads(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n fragment: FragmentDefinitionNode,\n varMap: Map | undefined,\n) {\n // Short-circuit building a type from the node if possible.\n const cached = cachedFieldsAndFragmentSpreads.get(fragment.selectionSet);\n if (cached) {\n return cached;\n }\n\n const fragmentType = typeFromAST(context.getSchema(), fragment.typeCondition);\n return getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragmentType,\n fragment.selectionSet,\n varMap,\n );\n}\n\nfunction _collectFieldsAndFragmentSpreads(\n context: ValidationContext,\n parentType: Maybe,\n selectionSet: SelectionSetNode,\n nodeAndDefs: NodeAndDefCollection,\n fragmentSpreads: Map,\n varMap: Map | undefined,\n): void {\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n const fieldName = selection.name.value;\n let fieldDef;\n if (isObjectType(parentType) || isInterfaceType(parentType)) {\n fieldDef = parentType.getFields()[fieldName];\n }\n const responseName = selection.alias\n ? selection.alias.value\n : fieldName;\n\n let nodeAndDefsList = nodeAndDefs.get(responseName);\n if (nodeAndDefsList == null) {\n nodeAndDefsList = [];\n nodeAndDefs.set(responseName, nodeAndDefsList);\n }\n nodeAndDefsList.push([parentType, selection, fieldDef]);\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragmentSpread = getFragmentSpread(context, selection, varMap);\n fragmentSpreads.set(fragmentSpread.key, fragmentSpread);\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n const typeCondition = selection.typeCondition;\n const inlineFragmentType = typeCondition\n ? typeFromAST(context.getSchema(), typeCondition)\n : parentType;\n _collectFieldsAndFragmentSpreads(\n context,\n inlineFragmentType,\n selection.selectionSet,\n nodeAndDefs,\n fragmentSpreads,\n varMap,\n );\n break;\n }\n }\n }\n}\n\nfunction getFragmentSpread(\n context: ValidationContext,\n fragmentSpreadNode: FragmentSpreadNode,\n varMap: Map | undefined,\n): FragmentSpread {\n let key = '';\n const newVarMap = new Map();\n const fragmentSignature = context.getFragmentSignatureByName()(\n fragmentSpreadNode.name.value,\n );\n const argMap = new Map();\n if (fragmentSpreadNode.arguments) {\n for (const arg of fragmentSpreadNode.arguments) {\n argMap.set(arg.name.value, arg.value);\n }\n }\n if (fragmentSignature?.variableDefinitions) {\n key += fragmentSpreadNode.name.value + '(';\n for (const [varName, variable] of fragmentSignature.variableDefinitions) {\n const value = argMap.get(varName);\n if (value) {\n key += varName + ': ' + print(sortValueNode(value));\n }\n const arg = argMap.get(varName);\n if (arg !== undefined) {\n newVarMap.set(\n varName,\n varMap !== undefined ? replaceFragmentVariables(arg, varMap) : arg,\n );\n } else if (variable.defaultValue) {\n newVarMap.set(varName, variable.defaultValue);\n }\n }\n key += ')';\n }\n return {\n key,\n node: fragmentSpreadNode,\n varMap: newVarMap.size > 0 ? newVarMap : undefined,\n };\n}\n\n// Given a series of Conflicts which occurred between two sub-fields, generate\n// a single Conflict.\nfunction subfieldConflicts(\n conflicts: ReadonlyArray,\n responseName: string,\n node1: FieldNode,\n node2: FieldNode,\n): Maybe {\n if (conflicts.length > 0) {\n return [\n [responseName, conflicts.map(([reason]) => reason)],\n [node1, ...conflicts.map(([, fields1]) => fields1).flat()],\n [node2, ...conflicts.map(([, , fields2]) => fields2).flat()],\n ];\n }\n}\n\n/**\n * A way to keep track of pairs of things where the ordering of the pair\n * matters.\n *\n * Provides a third argument for has/set to allow flagging the pair as\n * weakly or strongly present within the collection.\n */\nclass OrderedPairSet {\n _data: Map>;\n\n constructor() {\n this._data = new Map();\n }\n\n has(a: T, b: U, weaklyPresent: boolean): boolean {\n const result = this._data.get(a)?.get(b);\n if (result === undefined) {\n return false;\n }\n\n return weaklyPresent ? true : weaklyPresent === result;\n }\n\n add(a: T, b: U, weaklyPresent: boolean): void {\n const map = this._data.get(a);\n if (map === undefined) {\n this._data.set(a, new Map([[b, weaklyPresent]]));\n } else {\n map.set(b, weaklyPresent);\n }\n }\n}\n\n/**\n * A way to keep track of pairs of similar things when the ordering of the pair\n * does not matter.\n */\nclass PairSet {\n _orderedPairSet: OrderedPairSet;\n\n constructor() {\n this._orderedPairSet = new OrderedPairSet();\n }\n\n has(a: T, b: T, weaklyPresent: boolean): boolean {\n return a < b\n ? this._orderedPairSet.has(a, b, weaklyPresent)\n : this._orderedPairSet.has(b, a, weaklyPresent);\n }\n\n add(a: T, b: T, weaklyPresent: boolean): void {\n if (a < b) {\n this._orderedPairSet.add(a, b, weaklyPresent);\n } else {\n this._orderedPairSet.add(b, a, weaklyPresent);\n }\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/OverlappingFieldsCanBeMergedRule.mjs b/validation/rules/OverlappingFieldsCanBeMergedRule.mjs new file mode 100644 index 0000000000..2ba3178155 --- /dev/null +++ b/validation/rules/OverlappingFieldsCanBeMergedRule.mjs @@ -0,0 +1,593 @@ +import { inspect } from "../../jsutils/inspect.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { print } from "../../language/printer.mjs"; +import { getNamedType, isInterfaceType, isLeafType, isListType, isNonNullType, isObjectType, } from "../../type/definition.mjs"; +import { sortValueNode } from "../../utilities/sortValueNode.mjs"; +import { typeFromAST } from "../../utilities/typeFromAST.mjs"; +/* eslint-disable @typescript-eslint/max-params */ +// This file contains a lot of such errors but we plan to refactor it anyway +// so just disable it for entire file. +function reasonMessage(reason) { + if (Array.isArray(reason)) { + return reason + .map(([responseName, subReason]) => `subfields "${responseName}" conflict because ` + + reasonMessage(subReason)) + .join(' and '); + } + return reason; +} +/** + * Overlapping fields can be merged + * + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. + * + * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging + */ +export function OverlappingFieldsCanBeMergedRule(context) { + // A memoization for when fields and a fragment or two fragments are compared + // "between" each other for conflicts. Comparisons made be made many times, + // so memoizing this can dramatically improve the performance of this validator. + const comparedFieldsAndFragmentPairs = new OrderedPairSet(); + const comparedFragmentPairs = new PairSet(); + // A cache for the "field map" and list of fragment spreads found in any given + // selection set. Selection sets may be asked for this information multiple + // times, so this improves the performance of this validator. + const cachedFieldsAndFragmentSpreads = new Map(); + return { + SelectionSet(selectionSet) { + const conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, context.getParentType(), selectionSet); + for (const [[responseName, reason], fields1, fields2] of conflicts) { + const reasonMsg = reasonMessage(reason); + context.reportError(new GraphQLError(`Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, { nodes: fields1.concat(fields2) })); + } + }, + }; +} +/** + * Algorithm: + * + * Conflicts occur when two fields exist in a query which will produce the same + * response name, but represent differing values, thus creating a conflict. + * The algorithm below finds all conflicts via making a series of comparisons + * between fields. In order to compare as few fields as possible, this makes + * a series of comparisons "within" sets of fields and "between" sets of fields. + * + * Given any selection set, a collection produces both a set of fields by + * also including all inline fragments, as well as a list of fragments + * referenced by fragment spreads. + * + * A) Each selection set represented in the document first compares "within" its + * collected set of fields, finding any conflicts between every pair of + * overlapping fields. + * Note: This is the *only time* that a the fields "within" a set are compared + * to each other. After this only fields "between" sets are compared. + * + * B) Also, if any fragment is referenced in a selection set, then a + * comparison is made "between" the original set of fields and the + * referenced fragment. + * + * C) Also, if multiple fragments are referenced, then comparisons + * are made "between" each referenced fragment. + * + * D) When comparing "between" a set of fields and a referenced fragment, first + * a comparison is made between each field in the original set of fields and + * each field in the the referenced set of fields. + * + * E) Also, if any fragment is referenced in the referenced selection set, + * then a comparison is made "between" the original set of fields and the + * referenced fragment (recursively referring to step D). + * + * F) When comparing "between" two fragments, first a comparison is made between + * each field in the first referenced set of fields and each field in the the + * second referenced set of fields. + * + * G) Also, any fragments referenced by the first must be compared to the + * second, and any fragments referenced by the second must be compared to the + * first (recursively referring to step F). + * + * H) When comparing two fields, if both have selection sets, then a comparison + * is made "between" both selection sets, first comparing the set of fields in + * the first selection set with the set of fields in the second. + * + * I) Also, if any fragment is referenced in either selection set, then a + * comparison is made "between" the other set of fields and the + * referenced fragment. + * + * J) Also, if two fragments are referenced in both selection sets, then a + * comparison is made "between" the two fragments. + * + */ +// Find all conflicts found "within" a selection set, including those found +// via spreading in fragments. Called when visiting each SelectionSet in the +// GraphQL Document. +function findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentType, selectionSet) { + const conflicts = []; + const [fieldMap, fragmentSpreads] = getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType, selectionSet, undefined); + // (A) Find find all conflicts "within" the fields and f of this selection set. + // Note: this is the *only place* `collectConflictsWithin` is called. + collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, fieldMap); + if (fragmentSpreads.length !== 0) { + // (B) Then collect conflicts between these fields and those represented by + // each spread found. + for (let i = 0; i < fragmentSpreads.length; i++) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, false, fieldMap, fragmentSpreads[i]); + // (C) Then compare this fragment with all other fragments found in this + // selection set to collect conflicts between fragments spread together. + // This compares each item in the list of fragment spreads to every other + // item in that same list (except for itself). + for (let j = i + 1; j < fragmentSpreads.length; j++) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, false, fragmentSpreads[i], fragmentSpreads[j]); + } + } + } + return conflicts; +} +// Collect all conflicts found between a set of fields and a fragment reference +// including via spreading in any nested fragments. +function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentSpread) { + // Memoize so the fields and fragments are not compared for conflicts more + // than once. + if (comparedFieldsAndFragmentPairs.has(fieldMap, fragmentSpread.key, areMutuallyExclusive)) { + return; + } + comparedFieldsAndFragmentPairs.add(fieldMap, fragmentSpread.key, areMutuallyExclusive); + const fragment = context.getFragment(fragmentSpread.node.name.value); + if (!fragment) { + return; + } + const [fieldMap2, referencedFragmentSpreads] = getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment, fragmentSpread.varMap); + // Do not compare a fragment's fieldMap to itself. + if (fieldMap === fieldMap2) { + return; + } + // (D) First collect any conflicts between the provided collection of fields + // and the collection of fields represented by the given fragment. + collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap, undefined, fieldMap2, fragmentSpread.varMap); + // (E) Then collect any conflicts between the provided collection of fields + // and any fragment names found in the given fragment. + for (const referencedFragmentSpread of referencedFragmentSpreads) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap, referencedFragmentSpread); + } +} +// Collect all conflicts found between two fragments, including via spreading in +// any nested fragments. +function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fragmentSpread1, fragmentSpread2) { + // No need to compare a fragment to itself. + if (fragmentSpread1.key === fragmentSpread2.key) { + return; + } + if (fragmentSpread1.node.name.value === fragmentSpread2.node.name.value) { + if (!sameArguments(fragmentSpread1.node.arguments, fragmentSpread1.varMap, fragmentSpread2.node.arguments, fragmentSpread2.varMap)) { + context.reportError(new GraphQLError(`Spreads "${fragmentSpread1.node.name.value}" conflict because ${fragmentSpread1.key} and ${fragmentSpread2.key} have different fragment arguments.`, { nodes: [fragmentSpread1.node, fragmentSpread2.node] })); + return; + } + } + // Memoize so two fragments are not compared for conflicts more than once. + if (comparedFragmentPairs.has(fragmentSpread1.key, fragmentSpread2.key, areMutuallyExclusive)) { + return; + } + comparedFragmentPairs.add(fragmentSpread1.key, fragmentSpread2.key, areMutuallyExclusive); + const fragment1 = context.getFragment(fragmentSpread1.node.name.value); + const fragment2 = context.getFragment(fragmentSpread2.node.name.value); + if (!fragment1 || !fragment2) { + return; + } + const [fieldMap1, referencedFragmentSpreads1] = getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment1, fragmentSpread1.varMap); + const [fieldMap2, referencedFragmentSpreads2] = getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment2, fragmentSpread2.varMap); + // (F) First, collect all conflicts between these two collections of fields + // (not including any nested fragments). + collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentSpread1.varMap, fieldMap2, fragmentSpread2.varMap); + // (G) Then collect conflicts between the first fragment and any nested + // fragments spread in the second fragment. + for (const referencedFragmentSpread2 of referencedFragmentSpreads2) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fragmentSpread1, referencedFragmentSpread2); + } + // (G) Then collect conflicts between the second fragment and any nested + // fragments spread in the first fragment. + for (const referencedFragmentSpread1 of referencedFragmentSpreads1) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, referencedFragmentSpread1, fragmentSpread2); + } +} +// Find all conflicts found between two selection sets, including those found +// via spreading in fragments. Called when determining if conflicts exist +// between the sub-fields of two overlapping fields. +function findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, parentType1, selectionSet1, varMap1, parentType2, selectionSet2, varMap2) { + const conflicts = []; + const [fieldMap1, fragmentSpreads1] = getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType1, selectionSet1, varMap1); + const [fieldMap2, fragmentSpreads2] = getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType2, selectionSet2, varMap2); + // (H) First, collect all conflicts between these two collections of field. + collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, varMap1, fieldMap2, varMap2); + // (I) Then collect conflicts between the first collection of fields and + // those referenced by each fragment name associated with the second. + for (const fragmentSpread2 of fragmentSpreads2) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentSpread2); + } + // (I) Then collect conflicts between the second collection of fields and + // those referenced by each fragment name associated with the first. + for (const fragmentSpread1 of fragmentSpreads1) { + collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fieldMap2, fragmentSpread1); + } + // (J) Also collect conflicts between any fragment spreads by the first and + // fragment spreads by the second. This compares each item in the first set of + // spreads to each item in the second set of spreads. + for (const fragmentSpread1 of fragmentSpreads1) { + for (const fragmentSpread2 of fragmentSpreads2) { + collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, fragmentSpread1, fragmentSpread2); + } + } + return conflicts; +} +// Collect all Conflicts "within" one collection of fields. +function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, fieldMap) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For every response name, if there are multiple fields, they + // must be compared to find a potential conflict. + for (const [responseName, fields] of fieldMap.entries()) { + // This compares every field in the list to every other field in this list + // (except to itself). If the list only has one item, nothing needs to + // be compared. + if (fields.length > 1) { + for (let i = 0; i < fields.length; i++) { + for (let j = i + 1; j < fields.length; j++) { + const conflict = findConflict(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, false, // within one collection is never mutually exclusive + responseName, fields[i], undefined, fields[j], undefined); + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} +// Collect all Conflicts between two collections of fields. This is similar to, +// but different from the `collectConflictsWithin` function above. This check +// assumes that `collectConflictsWithin` has already been called on each +// provided collection of fields. This is true because this validator traverses +// each individual selection set. +function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, fieldMap1, varMap1, fieldMap2, varMap2) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For any response name which appears in both provided field + // maps, each field from the first field map must be compared to every field + // in the second field map to find potential conflicts. + for (const [responseName, fields1] of fieldMap1.entries()) { + const fields2 = fieldMap2.get(responseName); + if (fields2 != null) { + for (const field1 of fields1) { + for (const field2 of fields2) { + const conflict = findConflict(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, varMap1, field2, varMap2); + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} +// Determines if there is a conflict between two particular fields, including +// comparing their sub-fields. +function findConflict(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, varMap1, field2, varMap2) { + const [parentType1, node1, def1] = field1; + const [parentType2, node2, def2] = field2; + // If it is known that two fields could not possibly apply at the same + // time, due to the parent types, then it is safe to permit them to diverge + // in aliased field or arguments used as they will not present any ambiguity + // by differing. + // It is known that two parent types could never overlap if they are + // different Object types. Interface or Union types might overlap - if not + // in the current state of the schema, then perhaps in some future version, + // thus may not safely diverge. + const areMutuallyExclusive = parentFieldsAreMutuallyExclusive || + (parentType1 !== parentType2 && + isObjectType(parentType1) && + isObjectType(parentType2)); + if (!areMutuallyExclusive) { + // Two aliases must refer to the same field. + const name1 = node1.name.value; + const name2 = node2.name.value; + if (name1 !== name2) { + return [ + [responseName, `"${name1}" and "${name2}" are different fields`], + [node1], + [node2], + ]; + } + // Two field calls must have the same arguments. + if (!sameArguments(node1.arguments, varMap1, node2.arguments, varMap2)) { + return [ + [responseName, 'they have differing arguments'], + [node1], + [node2], + ]; + } + } + const directives1 = node1.directives ?? []; + const directives2 = node2.directives ?? []; + const overlappingStreamReason = hasNoOverlappingStreams(directives1, varMap1, directives2, varMap2); + if (overlappingStreamReason !== undefined) { + return [[responseName, overlappingStreamReason], [node1], [node2]]; + } + // The return type for each field. + const type1 = def1?.type; + const type2 = def2?.type; + if (type1 && type2 && doTypesConflict(type1, type2)) { + return [ + [ + responseName, + `they return conflicting types "${inspect(type1)}" and "${inspect(type2)}"`, + ], + [node1], + [node2], + ]; + } + // Collect and compare sub-fields. Use the same "visited fragment spreads" list + // for both collections so fields in a fragment reference are never + // compared to themselves. + const selectionSet1 = node1.selectionSet; + const selectionSet2 = node2.selectionSet; + if (selectionSet1 && selectionSet2) { + const conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentSpreads, comparedFieldsAndFragmentPairs, comparedFragmentPairs, areMutuallyExclusive, getNamedType(type1), selectionSet1, varMap1, getNamedType(type2), selectionSet2, varMap2); + return subfieldConflicts(conflicts, responseName, node1, node2); + } +} +function sameArguments(args1, varMap1, args2, varMap2) { + if (args1 === undefined || args1.length === 0) { + return args2 === undefined || args2.length === 0; + } + if (args2 === undefined || args2.length === 0) { + return false; + } + if (args1.length !== args2.length) { + return false; + } + const values2 = new Map(args2.map(({ name, value }) => [ + name.value, + varMap2 === undefined ? value : replaceFragmentVariables(value, varMap2), + ])); + return args1.every((arg1) => { + let value1 = arg1.value; + if (varMap1) { + value1 = replaceFragmentVariables(value1, varMap1); + } + const value2 = values2.get(arg1.name.value); + if (value2 === undefined) { + return false; + } + return stringifyValue(value1) === stringifyValue(value2); + }); +} +function replaceFragmentVariables(valueNode, varMap) { + switch (valueNode.kind) { + case Kind.VARIABLE: + return varMap.get(valueNode.name.value) ?? valueNode; + case Kind.LIST: + return { + ...valueNode, + values: valueNode.values.map((node) => replaceFragmentVariables(node, varMap)), + }; + case Kind.OBJECT: + return { + ...valueNode, + fields: valueNode.fields.map((field) => ({ + ...field, + value: replaceFragmentVariables(field.value, varMap), + })), + }; + default: { + return valueNode; + } + } +} +function stringifyValue(value) { + return print(sortValueNode(value)); +} +function getStreamDirective(directives) { + return directives.find((directive) => directive.name.value === 'stream'); +} +function hasNoOverlappingStreams(directives1, varMap1, directives2, varMap2) { + const stream1 = getStreamDirective(directives1); + const stream2 = getStreamDirective(directives2); + if (!stream1 && !stream2) { + // both fields do not have streams + return; + } + else if (stream1 && stream2) { + // check if both fields have equivalent streams + if (sameArguments(stream1.arguments, varMap1, stream2.arguments, varMap2)) { + // This was allowed in previous alpha versions of `graphql-js`. + return 'they have overlapping stream directives. See https://github.com/graphql/defer-stream-wg/discussions/100'; + } + return 'they have overlapping stream directives'; + } + // fields have a mix of stream and no stream + return 'they have overlapping stream directives'; +} +// Two types conflict if both types could not apply to a value simultaneously. +// Composite types are ignored as their individual field types will be compared +// later recursively. However List and Non-Null types must match. +function doTypesConflict(type1, type2) { + if (isListType(type1)) { + return isListType(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + if (isListType(type2)) { + return true; + } + if (isNonNullType(type1)) { + return isNonNullType(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + if (isNonNullType(type2)) { + return true; + } + if (isLeafType(type1) || isLeafType(type2)) { + return type1 !== type2; + } + return false; +} +// Given a selection set, return the collection of fields (a mapping of response +// name to field nodes and definitions) as well as a list of fragment spreads +// referenced via fragment spreads. +function getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, parentType, selectionSet, varMap) { + const cached = cachedFieldsAndFragmentSpreads.get(selectionSet); + if (cached) { + return cached; + } + const nodeAndDefs = new Map(); + const fragmentSpreads = new Map(); + _collectFieldsAndFragmentSpreads(context, parentType, selectionSet, nodeAndDefs, fragmentSpreads, varMap); + const result = [ + nodeAndDefs, + Array.from(fragmentSpreads.values()), + ]; + cachedFieldsAndFragmentSpreads.set(selectionSet, result); + return result; +} +// Given a reference to a fragment, return the represented collection of fields +// as well as a list of nested fragment spreads referenced via fragment spreads. +function getReferencedFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragment, varMap) { + // Short-circuit building a type from the node if possible. + const cached = cachedFieldsAndFragmentSpreads.get(fragment.selectionSet); + if (cached) { + return cached; + } + const fragmentType = typeFromAST(context.getSchema(), fragment.typeCondition); + return getFieldsAndFragmentSpreads(context, cachedFieldsAndFragmentSpreads, fragmentType, fragment.selectionSet, varMap); +} +function _collectFieldsAndFragmentSpreads(context, parentType, selectionSet, nodeAndDefs, fragmentSpreads, varMap) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case Kind.FIELD: { + const fieldName = selection.name.value; + let fieldDef; + if (isObjectType(parentType) || isInterfaceType(parentType)) { + fieldDef = parentType.getFields()[fieldName]; + } + const responseName = selection.alias + ? selection.alias.value + : fieldName; + let nodeAndDefsList = nodeAndDefs.get(responseName); + if (nodeAndDefsList == null) { + nodeAndDefsList = []; + nodeAndDefs.set(responseName, nodeAndDefsList); + } + nodeAndDefsList.push([parentType, selection, fieldDef]); + break; + } + case Kind.FRAGMENT_SPREAD: { + const fragmentSpread = getFragmentSpread(context, selection, varMap); + fragmentSpreads.set(fragmentSpread.key, fragmentSpread); + break; + } + case Kind.INLINE_FRAGMENT: { + const typeCondition = selection.typeCondition; + const inlineFragmentType = typeCondition + ? typeFromAST(context.getSchema(), typeCondition) + : parentType; + _collectFieldsAndFragmentSpreads(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentSpreads, varMap); + break; + } + } + } +} +function getFragmentSpread(context, fragmentSpreadNode, varMap) { + let key = ''; + const newVarMap = new Map(); + const fragmentSignature = context.getFragmentSignatureByName()(fragmentSpreadNode.name.value); + const argMap = new Map(); + if (fragmentSpreadNode.arguments) { + for (const arg of fragmentSpreadNode.arguments) { + argMap.set(arg.name.value, arg.value); + } + } + if (fragmentSignature?.variableDefinitions) { + key += fragmentSpreadNode.name.value + '('; + for (const [varName, variable] of fragmentSignature.variableDefinitions) { + const value = argMap.get(varName); + if (value) { + key += varName + ': ' + print(sortValueNode(value)); + } + const arg = argMap.get(varName); + if (arg !== undefined) { + newVarMap.set(varName, varMap !== undefined ? replaceFragmentVariables(arg, varMap) : arg); + } + else if (variable.defaultValue) { + newVarMap.set(varName, variable.defaultValue); + } + } + key += ')'; + } + return { + key, + node: fragmentSpreadNode, + varMap: newVarMap.size > 0 ? newVarMap : undefined, + }; +} +// Given a series of Conflicts which occurred between two sub-fields, generate +// a single Conflict. +function subfieldConflicts(conflicts, responseName, node1, node2) { + if (conflicts.length > 0) { + return [ + [responseName, conflicts.map(([reason]) => reason)], + [node1, ...conflicts.map(([, fields1]) => fields1).flat()], + [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], + ]; + } +} +/** + * A way to keep track of pairs of things where the ordering of the pair + * matters. + * + * Provides a third argument for has/set to allow flagging the pair as + * weakly or strongly present within the collection. + */ +class OrderedPairSet { + constructor() { + this._data = new Map(); + } + has(a, b, weaklyPresent) { + const result = this._data.get(a)?.get(b); + if (result === undefined) { + return false; + } + return weaklyPresent ? true : weaklyPresent === result; + } + add(a, b, weaklyPresent) { + const map = this._data.get(a); + if (map === undefined) { + this._data.set(a, new Map([[b, weaklyPresent]])); + } + else { + map.set(b, weaklyPresent); + } + } +} +/** + * A way to keep track of pairs of similar things when the ordering of the pair + * does not matter. + */ +class PairSet { + constructor() { + this._orderedPairSet = new OrderedPairSet(); + } + has(a, b, weaklyPresent) { + return a < b + ? this._orderedPairSet.has(a, b, weaklyPresent) + : this._orderedPairSet.has(b, a, weaklyPresent); + } + add(a, b, weaklyPresent) { + if (a < b) { + this._orderedPairSet.add(a, b, weaklyPresent); + } + else { + this._orderedPairSet.add(b, a, weaklyPresent); + } + } +} +//# sourceMappingURL=OverlappingFieldsCanBeMergedRule.js.map \ No newline at end of file diff --git a/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map b/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map new file mode 100644 index 0000000000..4a93fa75a0 --- /dev/null +++ b/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"OverlappingFieldsCanBeMergedRule.js","sourceRoot":"","sources":["../../../src/validation/rules/OverlappingFieldsCanBeMergedRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAGnD,OAAO,EAAE,YAAY,EAAE,qCA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AAa,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\nimport type { Maybe } from '../../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n ArgumentNode,\n DirectiveNode,\n FieldNode,\n FragmentArgumentNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n SelectionSetNode,\n ValueNode,\n} from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type {\n GraphQLField,\n GraphQLNamedType,\n GraphQLOutputType,\n} from '../../type/definition.js';\nimport {\n getNamedType,\n isInterfaceType,\n isLeafType,\n isListType,\n isNonNullType,\n isObjectType,\n} from '../../type/definition.js';\n\nimport { sortValueNode } from '../../utilities/sortValueNode.js';\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/* eslint-disable @typescript-eslint/max-params */\n// This file contains a lot of such errors but we plan to refactor it anyway\n// so just disable it for entire file.\n\nfunction reasonMessage(reason: ConflictReasonMessage): string {\n if (Array.isArray(reason)) {\n return reason\n .map(\n ([responseName, subReason]) =>\n `subfields \"${responseName}\" conflict because ` +\n reasonMessage(subReason),\n )\n .join(' and ');\n }\n return reason;\n}\n\n/**\n * Overlapping fields can be merged\n *\n * A selection set is only valid if all fields (including spreading any\n * fragments) either correspond to distinct response names or can be merged\n * without ambiguity.\n *\n * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging\n */\nexport function OverlappingFieldsCanBeMergedRule(\n context: ValidationContext,\n): ASTVisitor {\n // A memoization for when fields and a fragment or two fragments are compared\n // \"between\" each other for conflicts. Comparisons made be made many times,\n // so memoizing this can dramatically improve the performance of this validator.\n const comparedFieldsAndFragmentPairs = new OrderedPairSet<\n NodeAndDefCollection,\n string\n >();\n const comparedFragmentPairs = new PairSet();\n\n // A cache for the \"field map\" and list of fragment spreads found in any given\n // selection set. Selection sets may be asked for this information multiple\n // times, so this improves the performance of this validator.\n const cachedFieldsAndFragmentSpreads = new Map();\n\n return {\n SelectionSet(selectionSet) {\n const conflicts = findConflictsWithinSelectionSet(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n context.getParentType(),\n selectionSet,\n );\n for (const [[responseName, reason], fields1, fields2] of conflicts) {\n const reasonMsg = reasonMessage(reason);\n context.reportError(\n new GraphQLError(\n `Fields \"${responseName}\" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`,\n { nodes: fields1.concat(fields2) },\n ),\n );\n }\n },\n };\n}\n\ntype Conflict = [ConflictReason, Array, Array];\n// Field name and reason.\ntype ConflictReason = [string, ConflictReasonMessage];\n// Reason is a string, or a nested list of conflicts.\ntype ConflictReasonMessage = string | Array;\n// Tuple defining a field node in a context.\ntype NodeAndDef = [\n Maybe,\n FieldNode,\n Maybe>,\n];\n// Map of array of those.\ntype NodeAndDefCollection = Map>;\ninterface FragmentSpread {\n key: string;\n node: FragmentSpreadNode;\n varMap: Map | undefined;\n}\ntype FragmentSpreads = ReadonlyArray;\ntype FieldsAndFragmentSpreads = readonly [\n NodeAndDefCollection,\n FragmentSpreads,\n];\n\n/**\n * Algorithm:\n *\n * Conflicts occur when two fields exist in a query which will produce the same\n * response name, but represent differing values, thus creating a conflict.\n * The algorithm below finds all conflicts via making a series of comparisons\n * between fields. In order to compare as few fields as possible, this makes\n * a series of comparisons \"within\" sets of fields and \"between\" sets of fields.\n *\n * Given any selection set, a collection produces both a set of fields by\n * also including all inline fragments, as well as a list of fragments\n * referenced by fragment spreads.\n *\n * A) Each selection set represented in the document first compares \"within\" its\n * collected set of fields, finding any conflicts between every pair of\n * overlapping fields.\n * Note: This is the *only time* that a the fields \"within\" a set are compared\n * to each other. After this only fields \"between\" sets are compared.\n *\n * B) Also, if any fragment is referenced in a selection set, then a\n * comparison is made \"between\" the original set of fields and the\n * referenced fragment.\n *\n * C) Also, if multiple fragments are referenced, then comparisons\n * are made \"between\" each referenced fragment.\n *\n * D) When comparing \"between\" a set of fields and a referenced fragment, first\n * a comparison is made between each field in the original set of fields and\n * each field in the the referenced set of fields.\n *\n * E) Also, if any fragment is referenced in the referenced selection set,\n * then a comparison is made \"between\" the original set of fields and the\n * referenced fragment (recursively referring to step D).\n *\n * F) When comparing \"between\" two fragments, first a comparison is made between\n * each field in the first referenced set of fields and each field in the the\n * second referenced set of fields.\n *\n * G) Also, any fragments referenced by the first must be compared to the\n * second, and any fragments referenced by the second must be compared to the\n * first (recursively referring to step F).\n *\n * H) When comparing two fields, if both have selection sets, then a comparison\n * is made \"between\" both selection sets, first comparing the set of fields in\n * the first selection set with the set of fields in the second.\n *\n * I) Also, if any fragment is referenced in either selection set, then a\n * comparison is made \"between\" the other set of fields and the\n * referenced fragment.\n *\n * J) Also, if two fragments are referenced in both selection sets, then a\n * comparison is made \"between\" the two fragments.\n *\n */\n\n// Find all conflicts found \"within\" a selection set, including those found\n// via spreading in fragments. Called when visiting each SelectionSet in the\n// GraphQL Document.\nfunction findConflictsWithinSelectionSet(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n parentType: Maybe,\n selectionSet: SelectionSetNode,\n): Array {\n const conflicts: Array = [];\n\n const [fieldMap, fragmentSpreads] = getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n parentType,\n selectionSet,\n undefined,\n );\n\n // (A) Find find all conflicts \"within\" the fields and f of this selection set.\n // Note: this is the *only place* `collectConflictsWithin` is called.\n collectConflictsWithin(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n fieldMap,\n );\n\n if (fragmentSpreads.length !== 0) {\n // (B) Then collect conflicts between these fields and those represented by\n // each spread found.\n for (let i = 0; i < fragmentSpreads.length; i++) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n false,\n fieldMap,\n fragmentSpreads[i],\n );\n // (C) Then compare this fragment with all other fragments found in this\n // selection set to collect conflicts between fragments spread together.\n // This compares each item in the list of fragment spreads to every other\n // item in that same list (except for itself).\n for (let j = i + 1; j < fragmentSpreads.length; j++) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n false,\n fragmentSpreads[i],\n fragmentSpreads[j],\n );\n }\n }\n }\n return conflicts;\n}\n\n// Collect all conflicts found between a set of fields and a fragment reference\n// including via spreading in any nested fragments.\nfunction collectConflictsBetweenFieldsAndFragment(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n areMutuallyExclusive: boolean,\n fieldMap: NodeAndDefCollection,\n fragmentSpread: FragmentSpread,\n): void {\n // Memoize so the fields and fragments are not compared for conflicts more\n // than once.\n if (\n comparedFieldsAndFragmentPairs.has(\n fieldMap,\n fragmentSpread.key,\n areMutuallyExclusive,\n )\n ) {\n return;\n }\n comparedFieldsAndFragmentPairs.add(\n fieldMap,\n fragmentSpread.key,\n areMutuallyExclusive,\n );\n\n const fragment = context.getFragment(fragmentSpread.node.name.value);\n if (!fragment) {\n return;\n }\n\n const [fieldMap2, referencedFragmentSpreads] =\n getReferencedFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragment,\n fragmentSpread.varMap,\n );\n\n // Do not compare a fragment's fieldMap to itself.\n if (fieldMap === fieldMap2) {\n return;\n }\n\n // (D) First collect any conflicts between the provided collection of fields\n // and the collection of fields represented by the given fragment.\n collectConflictsBetween(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap,\n undefined,\n fieldMap2,\n fragmentSpread.varMap,\n );\n\n // (E) Then collect any conflicts between the provided collection of fields\n // and any fragment names found in the given fragment.\n for (const referencedFragmentSpread of referencedFragmentSpreads) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap,\n referencedFragmentSpread,\n );\n }\n}\n\n// Collect all conflicts found between two fragments, including via spreading in\n// any nested fragments.\nfunction collectConflictsBetweenFragments(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n areMutuallyExclusive: boolean,\n fragmentSpread1: FragmentSpread,\n fragmentSpread2: FragmentSpread,\n): void {\n // No need to compare a fragment to itself.\n if (fragmentSpread1.key === fragmentSpread2.key) {\n return;\n }\n\n if (fragmentSpread1.node.name.value === fragmentSpread2.node.name.value) {\n if (\n !sameArguments(\n fragmentSpread1.node.arguments,\n fragmentSpread1.varMap,\n fragmentSpread2.node.arguments,\n fragmentSpread2.varMap,\n )\n ) {\n context.reportError(\n new GraphQLError(\n `Spreads \"${fragmentSpread1.node.name.value}\" conflict because ${fragmentSpread1.key} and ${fragmentSpread2.key} have different fragment arguments.`,\n { nodes: [fragmentSpread1.node, fragmentSpread2.node] },\n ),\n );\n return;\n }\n }\n\n // Memoize so two fragments are not compared for conflicts more than once.\n if (\n comparedFragmentPairs.has(\n fragmentSpread1.key,\n fragmentSpread2.key,\n areMutuallyExclusive,\n )\n ) {\n return;\n }\n comparedFragmentPairs.add(\n fragmentSpread1.key,\n fragmentSpread2.key,\n areMutuallyExclusive,\n );\n\n const fragment1 = context.getFragment(fragmentSpread1.node.name.value);\n const fragment2 = context.getFragment(fragmentSpread2.node.name.value);\n if (!fragment1 || !fragment2) {\n return;\n }\n\n const [fieldMap1, referencedFragmentSpreads1] =\n getReferencedFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragment1,\n fragmentSpread1.varMap,\n );\n const [fieldMap2, referencedFragmentSpreads2] =\n getReferencedFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragment2,\n fragmentSpread2.varMap,\n );\n\n // (F) First, collect all conflicts between these two collections of fields\n // (not including any nested fragments).\n collectConflictsBetween(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap1,\n fragmentSpread1.varMap,\n fieldMap2,\n fragmentSpread2.varMap,\n );\n\n // (G) Then collect conflicts between the first fragment and any nested\n // fragments spread in the second fragment.\n for (const referencedFragmentSpread2 of referencedFragmentSpreads2) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fragmentSpread1,\n referencedFragmentSpread2,\n );\n }\n\n // (G) Then collect conflicts between the second fragment and any nested\n // fragments spread in the first fragment.\n for (const referencedFragmentSpread1 of referencedFragmentSpreads1) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n referencedFragmentSpread1,\n fragmentSpread2,\n );\n }\n}\n\n// Find all conflicts found between two selection sets, including those found\n// via spreading in fragments. Called when determining if conflicts exist\n// between the sub-fields of two overlapping fields.\nfunction findConflictsBetweenSubSelectionSets(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n areMutuallyExclusive: boolean,\n parentType1: Maybe,\n selectionSet1: SelectionSetNode,\n varMap1: Map | undefined,\n parentType2: Maybe,\n selectionSet2: SelectionSetNode,\n varMap2: Map | undefined,\n): Array {\n const conflicts: Array = [];\n\n const [fieldMap1, fragmentSpreads1] = getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n parentType1,\n selectionSet1,\n varMap1,\n );\n const [fieldMap2, fragmentSpreads2] = getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n parentType2,\n selectionSet2,\n varMap2,\n );\n\n // (H) First, collect all conflicts between these two collections of field.\n collectConflictsBetween(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap1,\n varMap1,\n fieldMap2,\n varMap2,\n );\n\n // (I) Then collect conflicts between the first collection of fields and\n // those referenced by each fragment name associated with the second.\n for (const fragmentSpread2 of fragmentSpreads2) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap1,\n fragmentSpread2,\n );\n }\n\n // (I) Then collect conflicts between the second collection of fields and\n // those referenced by each fragment name associated with the first.\n for (const fragmentSpread1 of fragmentSpreads1) {\n collectConflictsBetweenFieldsAndFragment(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fieldMap2,\n fragmentSpread1,\n );\n }\n\n // (J) Also collect conflicts between any fragment spreads by the first and\n // fragment spreads by the second. This compares each item in the first set of\n // spreads to each item in the second set of spreads.\n for (const fragmentSpread1 of fragmentSpreads1) {\n for (const fragmentSpread2 of fragmentSpreads2) {\n collectConflictsBetweenFragments(\n context,\n conflicts,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n fragmentSpread1,\n fragmentSpread2,\n );\n }\n }\n return conflicts;\n}\n\n// Collect all Conflicts \"within\" one collection of fields.\nfunction collectConflictsWithin(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n fieldMap: NodeAndDefCollection,\n): void {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For every response name, if there are multiple fields, they\n // must be compared to find a potential conflict.\n for (const [responseName, fields] of fieldMap.entries()) {\n // This compares every field in the list to every other field in this list\n // (except to itself). If the list only has one item, nothing needs to\n // be compared.\n if (fields.length > 1) {\n for (let i = 0; i < fields.length; i++) {\n for (let j = i + 1; j < fields.length; j++) {\n const conflict = findConflict(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n false, // within one collection is never mutually exclusive\n responseName,\n fields[i],\n undefined,\n fields[j],\n undefined,\n );\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n}\n\n// Collect all Conflicts between two collections of fields. This is similar to,\n// but different from the `collectConflictsWithin` function above. This check\n// assumes that `collectConflictsWithin` has already been called on each\n// provided collection of fields. This is true because this validator traverses\n// each individual selection set.\nfunction collectConflictsBetween(\n context: ValidationContext,\n conflicts: Array,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n parentFieldsAreMutuallyExclusive: boolean,\n fieldMap1: NodeAndDefCollection,\n varMap1: Map | undefined,\n fieldMap2: NodeAndDefCollection,\n varMap2: Map | undefined,\n): void {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For any response name which appears in both provided field\n // maps, each field from the first field map must be compared to every field\n // in the second field map to find potential conflicts.\n for (const [responseName, fields1] of fieldMap1.entries()) {\n const fields2 = fieldMap2.get(responseName);\n if (fields2 != null) {\n for (const field1 of fields1) {\n for (const field2 of fields2) {\n const conflict = findConflict(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n parentFieldsAreMutuallyExclusive,\n responseName,\n field1,\n varMap1,\n field2,\n varMap2,\n );\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n}\n\n// Determines if there is a conflict between two particular fields, including\n// comparing their sub-fields.\nfunction findConflict(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n comparedFieldsAndFragmentPairs: OrderedPairSet,\n comparedFragmentPairs: PairSet,\n parentFieldsAreMutuallyExclusive: boolean,\n responseName: string,\n field1: NodeAndDef,\n varMap1: Map | undefined,\n field2: NodeAndDef,\n varMap2: Map | undefined,\n): Maybe {\n const [parentType1, node1, def1] = field1;\n const [parentType2, node2, def2] = field2;\n\n // If it is known that two fields could not possibly apply at the same\n // time, due to the parent types, then it is safe to permit them to diverge\n // in aliased field or arguments used as they will not present any ambiguity\n // by differing.\n // It is known that two parent types could never overlap if they are\n // different Object types. Interface or Union types might overlap - if not\n // in the current state of the schema, then perhaps in some future version,\n // thus may not safely diverge.\n const areMutuallyExclusive =\n parentFieldsAreMutuallyExclusive ||\n (parentType1 !== parentType2 &&\n isObjectType(parentType1) &&\n isObjectType(parentType2));\n\n if (!areMutuallyExclusive) {\n // Two aliases must refer to the same field.\n const name1 = node1.name.value;\n const name2 = node2.name.value;\n if (name1 !== name2) {\n return [\n [responseName, `\"${name1}\" and \"${name2}\" are different fields`],\n [node1],\n [node2],\n ];\n }\n\n // Two field calls must have the same arguments.\n if (!sameArguments(node1.arguments, varMap1, node2.arguments, varMap2)) {\n return [\n [responseName, 'they have differing arguments'],\n [node1],\n [node2],\n ];\n }\n }\n\n const directives1 = node1.directives ?? [];\n const directives2 = node2.directives ?? [];\n const overlappingStreamReason = hasNoOverlappingStreams(\n directives1,\n varMap1,\n directives2,\n varMap2,\n );\n if (overlappingStreamReason !== undefined) {\n return [[responseName, overlappingStreamReason], [node1], [node2]];\n }\n\n // The return type for each field.\n const type1 = def1?.type;\n const type2 = def2?.type;\n\n if (type1 && type2 && doTypesConflict(type1, type2)) {\n return [\n [\n responseName,\n `they return conflicting types \"${inspect(type1)}\" and \"${inspect(\n type2,\n )}\"`,\n ],\n [node1],\n [node2],\n ];\n }\n\n // Collect and compare sub-fields. Use the same \"visited fragment spreads\" list\n // for both collections so fields in a fragment reference are never\n // compared to themselves.\n const selectionSet1 = node1.selectionSet;\n const selectionSet2 = node2.selectionSet;\n if (selectionSet1 && selectionSet2) {\n const conflicts = findConflictsBetweenSubSelectionSets(\n context,\n cachedFieldsAndFragmentSpreads,\n comparedFieldsAndFragmentPairs,\n comparedFragmentPairs,\n areMutuallyExclusive,\n getNamedType(type1),\n selectionSet1,\n varMap1,\n getNamedType(type2),\n selectionSet2,\n varMap2,\n );\n return subfieldConflicts(conflicts, responseName, node1, node2);\n }\n}\n\nfunction sameArguments(\n args1: ReadonlyArray | undefined,\n varMap1: Map | undefined,\n args2: ReadonlyArray | undefined,\n varMap2: Map | undefined,\n): boolean {\n if (args1 === undefined || args1.length === 0) {\n return args2 === undefined || args2.length === 0;\n }\n if (args2 === undefined || args2.length === 0) {\n return false;\n }\n\n if (args1.length !== args2.length) {\n return false;\n }\n\n const values2 = new Map(\n args2.map(({ name, value }) => [\n name.value,\n varMap2 === undefined ? value : replaceFragmentVariables(value, varMap2),\n ]),\n );\n return args1.every((arg1) => {\n let value1 = arg1.value;\n if (varMap1) {\n value1 = replaceFragmentVariables(value1, varMap1);\n }\n const value2 = values2.get(arg1.name.value);\n if (value2 === undefined) {\n return false;\n }\n\n return stringifyValue(value1) === stringifyValue(value2);\n });\n}\n\nfunction replaceFragmentVariables(\n valueNode: ValueNode,\n varMap: ReadonlyMap,\n): ValueNode {\n switch (valueNode.kind) {\n case Kind.VARIABLE:\n return varMap.get(valueNode.name.value) ?? valueNode;\n case Kind.LIST:\n return {\n ...valueNode,\n values: valueNode.values.map((node) =>\n replaceFragmentVariables(node, varMap),\n ),\n };\n case Kind.OBJECT:\n return {\n ...valueNode,\n fields: valueNode.fields.map((field) => ({\n ...field,\n value: replaceFragmentVariables(field.value, varMap),\n })),\n };\n default: {\n return valueNode;\n }\n }\n}\n\nfunction stringifyValue(value: ValueNode): string | null {\n return print(sortValueNode(value));\n}\n\nfunction getStreamDirective(\n directives: ReadonlyArray,\n): DirectiveNode | undefined {\n return directives.find((directive) => directive.name.value === 'stream');\n}\n\nfunction hasNoOverlappingStreams(\n directives1: ReadonlyArray,\n varMap1: Map | undefined,\n directives2: ReadonlyArray,\n varMap2: Map | undefined,\n): string | undefined {\n const stream1 = getStreamDirective(directives1);\n const stream2 = getStreamDirective(directives2);\n if (!stream1 && !stream2) {\n // both fields do not have streams\n return;\n } else if (stream1 && stream2) {\n // check if both fields have equivalent streams\n if (sameArguments(stream1.arguments, varMap1, stream2.arguments, varMap2)) {\n // This was allowed in previous alpha versions of `graphql-js`.\n return 'they have overlapping stream directives. See https://github.com/graphql/defer-stream-wg/discussions/100';\n }\n return 'they have overlapping stream directives';\n }\n // fields have a mix of stream and no stream\n return 'they have overlapping stream directives';\n}\n\n// Two types conflict if both types could not apply to a value simultaneously.\n// Composite types are ignored as their individual field types will be compared\n// later recursively. However List and Non-Null types must match.\nfunction doTypesConflict(\n type1: GraphQLOutputType,\n type2: GraphQLOutputType,\n): boolean {\n if (isListType(type1)) {\n return isListType(type2)\n ? doTypesConflict(type1.ofType, type2.ofType)\n : true;\n }\n if (isListType(type2)) {\n return true;\n }\n if (isNonNullType(type1)) {\n return isNonNullType(type2)\n ? doTypesConflict(type1.ofType, type2.ofType)\n : true;\n }\n if (isNonNullType(type2)) {\n return true;\n }\n if (isLeafType(type1) || isLeafType(type2)) {\n return type1 !== type2;\n }\n return false;\n}\n\n// Given a selection set, return the collection of fields (a mapping of response\n// name to field nodes and definitions) as well as a list of fragment spreads\n// referenced via fragment spreads.\nfunction getFieldsAndFragmentSpreads(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n parentType: Maybe,\n selectionSet: SelectionSetNode,\n varMap: Map | undefined,\n): FieldsAndFragmentSpreads {\n const cached = cachedFieldsAndFragmentSpreads.get(selectionSet);\n if (cached) {\n return cached;\n }\n const nodeAndDefs: NodeAndDefCollection = new Map();\n const fragmentSpreads = new Map();\n _collectFieldsAndFragmentSpreads(\n context,\n parentType,\n selectionSet,\n nodeAndDefs,\n fragmentSpreads,\n varMap,\n );\n const result: FieldsAndFragmentSpreads = [\n nodeAndDefs,\n Array.from(fragmentSpreads.values()),\n ];\n cachedFieldsAndFragmentSpreads.set(selectionSet, result);\n return result;\n}\n\n// Given a reference to a fragment, return the represented collection of fields\n// as well as a list of nested fragment spreads referenced via fragment spreads.\nfunction getReferencedFieldsAndFragmentSpreads(\n context: ValidationContext,\n cachedFieldsAndFragmentSpreads: Map<\n SelectionSetNode,\n FieldsAndFragmentSpreads\n >,\n fragment: FragmentDefinitionNode,\n varMap: Map | undefined,\n) {\n // Short-circuit building a type from the node if possible.\n const cached = cachedFieldsAndFragmentSpreads.get(fragment.selectionSet);\n if (cached) {\n return cached;\n }\n\n const fragmentType = typeFromAST(context.getSchema(), fragment.typeCondition);\n return getFieldsAndFragmentSpreads(\n context,\n cachedFieldsAndFragmentSpreads,\n fragmentType,\n fragment.selectionSet,\n varMap,\n );\n}\n\nfunction _collectFieldsAndFragmentSpreads(\n context: ValidationContext,\n parentType: Maybe,\n selectionSet: SelectionSetNode,\n nodeAndDefs: NodeAndDefCollection,\n fragmentSpreads: Map,\n varMap: Map | undefined,\n): void {\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n const fieldName = selection.name.value;\n let fieldDef;\n if (isObjectType(parentType) || isInterfaceType(parentType)) {\n fieldDef = parentType.getFields()[fieldName];\n }\n const responseName = selection.alias\n ? selection.alias.value\n : fieldName;\n\n let nodeAndDefsList = nodeAndDefs.get(responseName);\n if (nodeAndDefsList == null) {\n nodeAndDefsList = [];\n nodeAndDefs.set(responseName, nodeAndDefsList);\n }\n nodeAndDefsList.push([parentType, selection, fieldDef]);\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragmentSpread = getFragmentSpread(context, selection, varMap);\n fragmentSpreads.set(fragmentSpread.key, fragmentSpread);\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n const typeCondition = selection.typeCondition;\n const inlineFragmentType = typeCondition\n ? typeFromAST(context.getSchema(), typeCondition)\n : parentType;\n _collectFieldsAndFragmentSpreads(\n context,\n inlineFragmentType,\n selection.selectionSet,\n nodeAndDefs,\n fragmentSpreads,\n varMap,\n );\n break;\n }\n }\n }\n}\n\nfunction getFragmentSpread(\n context: ValidationContext,\n fragmentSpreadNode: FragmentSpreadNode,\n varMap: Map | undefined,\n): FragmentSpread {\n let key = '';\n const newVarMap = new Map();\n const fragmentSignature = context.getFragmentSignatureByName()(\n fragmentSpreadNode.name.value,\n );\n const argMap = new Map();\n if (fragmentSpreadNode.arguments) {\n for (const arg of fragmentSpreadNode.arguments) {\n argMap.set(arg.name.value, arg.value);\n }\n }\n if (fragmentSignature?.variableDefinitions) {\n key += fragmentSpreadNode.name.value + '(';\n for (const [varName, variable] of fragmentSignature.variableDefinitions) {\n const value = argMap.get(varName);\n if (value) {\n key += varName + ': ' + print(sortValueNode(value));\n }\n const arg = argMap.get(varName);\n if (arg !== undefined) {\n newVarMap.set(\n varName,\n varMap !== undefined ? replaceFragmentVariables(arg, varMap) : arg,\n );\n } else if (variable.defaultValue) {\n newVarMap.set(varName, variable.defaultValue);\n }\n }\n key += ')';\n }\n return {\n key,\n node: fragmentSpreadNode,\n varMap: newVarMap.size > 0 ? newVarMap : undefined,\n };\n}\n\n// Given a series of Conflicts which occurred between two sub-fields, generate\n// a single Conflict.\nfunction subfieldConflicts(\n conflicts: ReadonlyArray,\n responseName: string,\n node1: FieldNode,\n node2: FieldNode,\n): Maybe {\n if (conflicts.length > 0) {\n return [\n [responseName, conflicts.map(([reason]) => reason)],\n [node1, ...conflicts.map(([, fields1]) => fields1).flat()],\n [node2, ...conflicts.map(([, , fields2]) => fields2).flat()],\n ];\n }\n}\n\n/**\n * A way to keep track of pairs of things where the ordering of the pair\n * matters.\n *\n * Provides a third argument for has/set to allow flagging the pair as\n * weakly or strongly present within the collection.\n */\nclass OrderedPairSet {\n _data: Map>;\n\n constructor() {\n this._data = new Map();\n }\n\n has(a: T, b: U, weaklyPresent: boolean): boolean {\n const result = this._data.get(a)?.get(b);\n if (result === undefined) {\n return false;\n }\n\n return weaklyPresent ? true : weaklyPresent === result;\n }\n\n add(a: T, b: U, weaklyPresent: boolean): void {\n const map = this._data.get(a);\n if (map === undefined) {\n this._data.set(a, new Map([[b, weaklyPresent]]));\n } else {\n map.set(b, weaklyPresent);\n }\n }\n}\n\n/**\n * A way to keep track of pairs of similar things when the ordering of the pair\n * does not matter.\n */\nclass PairSet {\n _orderedPairSet: OrderedPairSet;\n\n constructor() {\n this._orderedPairSet = new OrderedPairSet();\n }\n\n has(a: T, b: T, weaklyPresent: boolean): boolean {\n return a < b\n ? this._orderedPairSet.has(a, b, weaklyPresent)\n : this._orderedPairSet.has(b, a, weaklyPresent);\n }\n\n add(a: T, b: T, weaklyPresent: boolean): void {\n if (a < b) {\n this._orderedPairSet.add(a, b, weaklyPresent);\n } else {\n this._orderedPairSet.add(b, a, weaklyPresent);\n }\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/PossibleFragmentSpreadsRule.d.ts b/validation/rules/PossibleFragmentSpreadsRule.d.ts new file mode 100644 index 0000000000..5f26daf06c --- /dev/null +++ b/validation/rules/PossibleFragmentSpreadsRule.d.ts @@ -0,0 +1,10 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Possible fragment spread + * + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. + */ +export declare function PossibleFragmentSpreadsRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/PossibleFragmentSpreadsRule.js b/validation/rules/PossibleFragmentSpreadsRule.js new file mode 100644 index 0000000000..bceed3fdd1 --- /dev/null +++ b/validation/rules/PossibleFragmentSpreadsRule.js @@ -0,0 +1,52 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PossibleFragmentSpreadsRule = PossibleFragmentSpreadsRule; +const inspect_js_1 = require("../../jsutils/inspect.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const definition_js_1 = require("../../type/definition.js"); +const typeComparators_js_1 = require("../../utilities/typeComparators.js"); +const typeFromAST_js_1 = require("../../utilities/typeFromAST.js"); +/** + * Possible fragment spread + * + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. + */ +function PossibleFragmentSpreadsRule(context) { + return { + InlineFragment(node) { + const fragType = context.getType(); + const parentType = context.getParentType(); + if ((0, definition_js_1.isCompositeType)(fragType) && + (0, definition_js_1.isCompositeType)(parentType) && + !(0, typeComparators_js_1.doTypesOverlap)(context.getSchema(), fragType, parentType)) { + const parentTypeStr = (0, inspect_js_1.inspect)(parentType); + const fragTypeStr = (0, inspect_js_1.inspect)(fragType); + context.reportError(new GraphQLError_js_1.GraphQLError(`Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, { nodes: node })); + } + }, + FragmentSpread(node) { + const fragName = node.name.value; + const fragType = getFragmentType(context, fragName); + const parentType = context.getParentType(); + if (fragType && + parentType && + !(0, typeComparators_js_1.doTypesOverlap)(context.getSchema(), fragType, parentType)) { + const parentTypeStr = (0, inspect_js_1.inspect)(parentType); + const fragTypeStr = (0, inspect_js_1.inspect)(fragType); + context.reportError(new GraphQLError_js_1.GraphQLError(`Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, { nodes: node })); + } + }, + }; +} +function getFragmentType(context, name) { + const frag = context.getFragment(name); + if (frag) { + const type = (0, typeFromAST_js_1.typeFromAST)(context.getSchema(), frag.typeCondition); + if ((0, definition_js_1.isCompositeType)(type)) { + return type; + } + } +} +//# sourceMappingURL=PossibleFragmentSpreadsRule.js.map \ No newline at end of file diff --git a/validation/rules/PossibleFragmentSpreadsRule.js.map b/validation/rules/PossibleFragmentSpreadsRule.js.map new file mode 100644 index 0000000000..acd4bb613f --- /dev/null +++ b/validation/rules/PossibleFragmentSpreadsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PossibleFragmentSpreadsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/PossibleFragmentSpreadsRule.ts"],"names":[],"mappings":";;AAsBA,kEA0CC;AAhED,yDAAmD;AAGnD,iEAA2D;AAK3D,4DAA2D;AAE3D,2EAAoE;AACpE,mEAA6D;AAI7D;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,OAA0B;IAE1B,OAAO;QACL,cAAc,CAAC,IAAI;YACjB,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;YAC3C,IACE,IAAA,+BAAe,EAAC,QAAQ,CAAC;gBACzB,IAAA,+BAAe,EAAC,UAAU,CAAC;gBAC3B,CAAC,IAAA,mCAAc,EAAC,OAAO,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,EAC1D,CAAC;gBACD,MAAM,aAAa,GAAG,IAAA,oBAAO,EAAC,UAAU,CAAC,CAAC;gBAC1C,MAAM,WAAW,GAAG,IAAA,oBAAO,EAAC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js';\nimport type { Maybe } from '../../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLCompositeType } from '../../type/definition.js';\nimport { isCompositeType } from '../../type/definition.js';\n\nimport { doTypesOverlap } from '../../utilities/typeComparators.js';\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Possible fragment spread\n *\n * A fragment spread is only valid if the type condition could ever possibly\n * be true: if there is a non-empty intersection of the possible parent types,\n * and possible types which pass the type condition.\n */\nexport function PossibleFragmentSpreadsRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n InlineFragment(node) {\n const fragType = context.getType();\n const parentType = context.getParentType();\n if (\n isCompositeType(fragType) &&\n isCompositeType(parentType) &&\n !doTypesOverlap(context.getSchema(), fragType, parentType)\n ) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(\n new GraphQLError(\n `Fragment cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`,\n { nodes: node },\n ),\n );\n }\n },\n FragmentSpread(node) {\n const fragName = node.name.value;\n const fragType = getFragmentType(context, fragName);\n const parentType = context.getParentType();\n if (\n fragType &&\n parentType &&\n !doTypesOverlap(context.getSchema(), fragType, parentType)\n ) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(\n new GraphQLError(\n `Fragment \"${fragName}\" cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n\nfunction getFragmentType(\n context: ValidationContext,\n name: string,\n): Maybe {\n const frag = context.getFragment(name);\n if (frag) {\n const type = typeFromAST(context.getSchema(), frag.typeCondition);\n if (isCompositeType(type)) {\n return type;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/PossibleFragmentSpreadsRule.mjs b/validation/rules/PossibleFragmentSpreadsRule.mjs new file mode 100644 index 0000000000..117f070a1d --- /dev/null +++ b/validation/rules/PossibleFragmentSpreadsRule.mjs @@ -0,0 +1,49 @@ +import { inspect } from "../../jsutils/inspect.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { isCompositeType } from "../../type/definition.mjs"; +import { doTypesOverlap } from "../../utilities/typeComparators.mjs"; +import { typeFromAST } from "../../utilities/typeFromAST.mjs"; +/** + * Possible fragment spread + * + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. + */ +export function PossibleFragmentSpreadsRule(context) { + return { + InlineFragment(node) { + const fragType = context.getType(); + const parentType = context.getParentType(); + if (isCompositeType(fragType) && + isCompositeType(parentType) && + !doTypesOverlap(context.getSchema(), fragType, parentType)) { + const parentTypeStr = inspect(parentType); + const fragTypeStr = inspect(fragType); + context.reportError(new GraphQLError(`Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, { nodes: node })); + } + }, + FragmentSpread(node) { + const fragName = node.name.value; + const fragType = getFragmentType(context, fragName); + const parentType = context.getParentType(); + if (fragType && + parentType && + !doTypesOverlap(context.getSchema(), fragType, parentType)) { + const parentTypeStr = inspect(parentType); + const fragTypeStr = inspect(fragType); + context.reportError(new GraphQLError(`Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, { nodes: node })); + } + }, + }; +} +function getFragmentType(context, name) { + const frag = context.getFragment(name); + if (frag) { + const type = typeFromAST(context.getSchema(), frag.typeCondition); + if (isCompositeType(type)) { + return type; + } + } +} +//# sourceMappingURL=PossibleFragmentSpreadsRule.js.map \ No newline at end of file diff --git a/validation/rules/PossibleFragmentSpreadsRule.mjs.map b/validation/rules/PossibleFragmentSpreadsRule.mjs.map new file mode 100644 index 0000000000..f756d15a87 --- /dev/null +++ b/validation/rules/PossibleFragmentSpreadsRule.mjs.map @@ -0,0 +1 @@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Q,EAAE,UAAU,CAAC,EAC1D,CAAC;gBACD,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACtC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,QAAQ,+CAA+C,aAAa,2BAA2B,WAAW,IAAI,EAC3H,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CACtB,OAA0B,EAC1B,IAAY;IAEZ,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAClE,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\nimport type { Maybe } from '../../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLCompositeType } from '../../type/definition.js';\nimport { isCompositeType } from '../../type/definition.js';\n\nimport { doTypesOverlap } from '../../utilities/typeComparators.js';\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Possible fragment spread\n *\n * A fragment spread is only valid if the type condition could ever possibly\n * be true: if there is a non-empty intersection of the possible parent types,\n * and possible types which pass the type condition.\n */\nexport function PossibleFragmentSpreadsRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n InlineFragment(node) {\n const fragType = context.getType();\n const parentType = context.getParentType();\n if (\n isCompositeType(fragType) &&\n isCompositeType(parentType) &&\n !doTypesOverlap(context.getSchema(), fragType, parentType)\n ) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(\n new GraphQLError(\n `Fragment cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`,\n { nodes: node },\n ),\n );\n }\n },\n FragmentSpread(node) {\n const fragName = node.name.value;\n const fragType = getFragmentType(context, fragName);\n const parentType = context.getParentType();\n if (\n fragType &&\n parentType &&\n !doTypesOverlap(context.getSchema(), fragType, parentType)\n ) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(\n new GraphQLError(\n `Fragment \"${fragName}\" cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n\nfunction getFragmentType(\n context: ValidationContext,\n name: string,\n): Maybe {\n const frag = context.getFragment(name);\n if (frag) {\n const type = typeFromAST(context.getSchema(), frag.typeCondition);\n if (isCompositeType(type)) {\n return type;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/PossibleTypeExtensionsRule.d.ts b/validation/rules/PossibleTypeExtensionsRule.d.ts new file mode 100644 index 0000000000..0bd47bebee --- /dev/null +++ b/validation/rules/PossibleTypeExtensionsRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Possible type extension + * + * A type extension is only valid if the type is defined and has the same kind. + */ +export declare function PossibleTypeExtensionsRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/PossibleTypeExtensionsRule.js b/validation/rules/PossibleTypeExtensionsRule.js new file mode 100644 index 0000000000..332e4dde95 --- /dev/null +++ b/validation/rules/PossibleTypeExtensionsRule.js @@ -0,0 +1,113 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PossibleTypeExtensionsRule = PossibleTypeExtensionsRule; +const didYouMean_js_1 = require("../../jsutils/didYouMean.js"); +const inspect_js_1 = require("../../jsutils/inspect.js"); +const invariant_js_1 = require("../../jsutils/invariant.js"); +const suggestionList_js_1 = require("../../jsutils/suggestionList.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const predicates_js_1 = require("../../language/predicates.js"); +const definition_js_1 = require("../../type/definition.js"); +/** + * Possible type extension + * + * A type extension is only valid if the type is defined and has the same kind. + */ +function PossibleTypeExtensionsRule(context) { + const schema = context.getSchema(); + const definedTypes = new Map(); + for (const def of context.getDocument().definitions) { + if ((0, predicates_js_1.isTypeDefinitionNode)(def)) { + definedTypes.set(def.name.value, def); + } + } + return { + ScalarTypeExtension: checkExtension, + ObjectTypeExtension: checkExtension, + InterfaceTypeExtension: checkExtension, + UnionTypeExtension: checkExtension, + EnumTypeExtension: checkExtension, + InputObjectTypeExtension: checkExtension, + }; + function checkExtension(node) { + const typeName = node.name.value; + const defNode = definedTypes.get(typeName); + const existingType = schema?.getType(typeName); + let expectedKind; + if (defNode != null) { + expectedKind = defKindToExtKind[defNode.kind]; + } + else if (existingType) { + expectedKind = typeToExtKind(existingType); + } + if (expectedKind != null) { + if (expectedKind !== node.kind) { + const kindStr = extensionKindToTypeName(node.kind); + context.reportError(new GraphQLError_js_1.GraphQLError(`Cannot extend non-${kindStr} type "${typeName}".`, { + nodes: defNode ? [defNode, node] : node, + })); + } + } + else { + const allTypeNames = [ + ...definedTypes.keys(), + ...Object.keys(schema?.getTypeMap() ?? {}), + ]; + context.reportError(new GraphQLError_js_1.GraphQLError(`Cannot extend type "${typeName}" because it is not defined.` + + (0, didYouMean_js_1.didYouMean)((0, suggestionList_js_1.suggestionList)(typeName, allTypeNames)), { nodes: node.name })); + } + } +} +const defKindToExtKind = { + [kinds_js_1.Kind.SCALAR_TYPE_DEFINITION]: kinds_js_1.Kind.SCALAR_TYPE_EXTENSION, + [kinds_js_1.Kind.OBJECT_TYPE_DEFINITION]: kinds_js_1.Kind.OBJECT_TYPE_EXTENSION, + [kinds_js_1.Kind.INTERFACE_TYPE_DEFINITION]: kinds_js_1.Kind.INTERFACE_TYPE_EXTENSION, + [kinds_js_1.Kind.UNION_TYPE_DEFINITION]: kinds_js_1.Kind.UNION_TYPE_EXTENSION, + [kinds_js_1.Kind.ENUM_TYPE_DEFINITION]: kinds_js_1.Kind.ENUM_TYPE_EXTENSION, + [kinds_js_1.Kind.INPUT_OBJECT_TYPE_DEFINITION]: kinds_js_1.Kind.INPUT_OBJECT_TYPE_EXTENSION, +}; +function typeToExtKind(type) { + if ((0, definition_js_1.isScalarType)(type)) { + return kinds_js_1.Kind.SCALAR_TYPE_EXTENSION; + } + if ((0, definition_js_1.isObjectType)(type)) { + return kinds_js_1.Kind.OBJECT_TYPE_EXTENSION; + } + if ((0, definition_js_1.isInterfaceType)(type)) { + return kinds_js_1.Kind.INTERFACE_TYPE_EXTENSION; + } + if ((0, definition_js_1.isUnionType)(type)) { + return kinds_js_1.Kind.UNION_TYPE_EXTENSION; + } + if ((0, definition_js_1.isEnumType)(type)) { + return kinds_js_1.Kind.ENUM_TYPE_EXTENSION; + } + if ((0, definition_js_1.isInputObjectType)(type)) { + return kinds_js_1.Kind.INPUT_OBJECT_TYPE_EXTENSION; + } + /* c8 ignore next 3 */ + // Not reachable. All possible types have been considered + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected type: ' + (0, inspect_js_1.inspect)(type)); +} +function extensionKindToTypeName(kind) { + switch (kind) { + case kinds_js_1.Kind.SCALAR_TYPE_EXTENSION: + return 'scalar'; + case kinds_js_1.Kind.OBJECT_TYPE_EXTENSION: + return 'object'; + case kinds_js_1.Kind.INTERFACE_TYPE_EXTENSION: + return 'interface'; + case kinds_js_1.Kind.UNION_TYPE_EXTENSION: + return 'union'; + case kinds_js_1.Kind.ENUM_TYPE_EXTENSION: + return 'enum'; + case kinds_js_1.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return 'input object'; + // Not reachable. All possible types have been considered + /* c8 ignore next 2 */ + default: + (false) || (0, invariant_js_1.invariant)(false, 'Unexpected kind: ' + (0, inspect_js_1.inspect)(kind)); + } +} +//# sourceMappingURL=PossibleTypeExtensionsRule.js.map \ No newline at end of file diff --git a/validation/rules/PossibleTypeExtensionsRule.js.map b/validation/rules/PossibleTypeExtensionsRule.js.map new file mode 100644 index 0000000000..a2a3210d8b --- /dev/null +++ b/validation/rules/PossibleTypeExtensionsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PossibleTypeExtensionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/PossibleTypeExtensionsRule.ts"],"names":[],"mappings":";;AAgCA,gEAyDC;AAzFD,+DAAyD;AACzD,yDAAmD;AACnD,6DAAuD;AACvD,uEAAiE;AAEjE,iEAA2D;AAM3D,sDAA+C;AAC/C,gEAAoE;AAIpE,4DAOkC;AAIlC;;;;GAIG;AACH,SAAgB,0BAA0B,CACxC,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,IAAI,GAAG,EAA8B,CAAC;IAE3D,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,CAAC;QACpD,IAAI,IAAA,oCAAoB,EAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO;QACL,mBAAmB,EAAE,cAAc;QACnC,mBAAmB,EAAE,cAAc;QACnC,sBAAsB,EAAE,cAAc;QACtC,kBAAkB,EAAE,cAAc;QAClC,iBAAiB,EAAE,cAAc;QACjC,wBAAwB,EAAE,cAAc;KACzC,CAAC;IAEF,SAAS,cAAc,CAAC,IAAuB;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QACjC,MAAM,OAAO,GAAG,YAAY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AC,qBAAqB;YAC7B,OAAO,QAAQ,CAAC;QAClB,KAAK,eAAI,CAAC,qBAAqB;YAC7B,OAAO,QAAQ,CAAC;QAClB,KAAK,eAAI,CAAC,wBAAwB;YAChC,OAAO,WAAW,CAAC;QACrB,KAAK,eAAI,CAAC,oBAAoB;YAC5B,OAAO,OAAO,CAAC;QACjB,KAAK,eAAI,CAAC,mBAAmB;YAC3B,OAAO,MAAM,CAAC;QAChB,KAAK,eAAI,CAAC,2BAA2B;YACnC,OAAO,cAAc,CAAC;QACxB,yDAAyD;QACzD,sBAAsB;QACtB;YACE,CAAU,KAAK,SAAf,wBAAS,SAAQ,mBAAmB,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,EAAE;IAC1D,CAAC;AACH,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { inspect } from '../../jsutils/inspect.js';\nimport { invariant } from '../../jsutils/invariant.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n TypeDefinitionNode,\n TypeExtensionNode,\n} from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport { isTypeDefinitionNode } from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLNamedType } from '../../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from '../../type/definition.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Possible type extension\n *\n * A type extension is only valid if the type is defined and has the same kind.\n */\nexport function PossibleTypeExtensionsRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const definedTypes = new Map();\n\n for (const def of context.getDocument().definitions) {\n if (isTypeDefinitionNode(def)) {\n definedTypes.set(def.name.value, def);\n }\n }\n\n return {\n ScalarTypeExtension: checkExtension,\n ObjectTypeExtension: checkExtension,\n InterfaceTypeExtension: checkExtension,\n UnionTypeExtension: checkExtension,\n EnumTypeExtension: checkExtension,\n InputObjectTypeExtension: checkExtension,\n };\n\n function checkExtension(node: TypeExtensionNode): void {\n const typeName = node.name.value;\n const defNode = definedTypes.get(typeName);\n const existingType = schema?.getType(typeName);\n\n let expectedKind: Kind | undefined;\n if (defNode != null) {\n expectedKind = defKindToExtKind[defNode.kind];\n } else if (existingType) {\n expectedKind = typeToExtKind(existingType);\n }\n\n if (expectedKind != null) {\n if (expectedKind !== node.kind) {\n const kindStr = extensionKindToTypeName(node.kind);\n context.reportError(\n new GraphQLError(`Cannot extend non-${kindStr} type \"${typeName}\".`, {\n nodes: defNode ? [defNode, node] : node,\n }),\n );\n }\n } else {\n const allTypeNames = [\n ...definedTypes.keys(),\n ...Object.keys(schema?.getTypeMap() ?? {}),\n ];\n\n context.reportError(\n new GraphQLError(\n `Cannot extend type \"${typeName}\" because it is not defined.` +\n didYouMean(suggestionList(typeName, allTypeNames)),\n { nodes: node.name },\n ),\n );\n }\n }\n}\n\nconst defKindToExtKind = {\n [Kind.SCALAR_TYPE_DEFINITION]: Kind.SCALAR_TYPE_EXTENSION,\n [Kind.OBJECT_TYPE_DEFINITION]: Kind.OBJECT_TYPE_EXTENSION,\n [Kind.INTERFACE_TYPE_DEFINITION]: Kind.INTERFACE_TYPE_EXTENSION,\n [Kind.UNION_TYPE_DEFINITION]: Kind.UNION_TYPE_EXTENSION,\n [Kind.ENUM_TYPE_DEFINITION]: Kind.ENUM_TYPE_EXTENSION,\n [Kind.INPUT_OBJECT_TYPE_DEFINITION]: Kind.INPUT_OBJECT_TYPE_EXTENSION,\n} as const;\n\nfunction typeToExtKind(type: GraphQLNamedType): Kind {\n if (isScalarType(type)) {\n return Kind.SCALAR_TYPE_EXTENSION;\n }\n if (isObjectType(type)) {\n return Kind.OBJECT_TYPE_EXTENSION;\n }\n if (isInterfaceType(type)) {\n return Kind.INTERFACE_TYPE_EXTENSION;\n }\n if (isUnionType(type)) {\n return Kind.UNION_TYPE_EXTENSION;\n }\n if (isEnumType(type)) {\n return Kind.ENUM_TYPE_EXTENSION;\n }\n if (isInputObjectType(type)) {\n return Kind.INPUT_OBJECT_TYPE_EXTENSION;\n }\n /* c8 ignore next 3 */\n // Not reachable. All possible types have been considered\n invariant(false, 'Unexpected type: ' + inspect(type));\n}\n\nfunction extensionKindToTypeName(kind: Kind): string {\n switch (kind) {\n case Kind.SCALAR_TYPE_EXTENSION:\n return 'scalar';\n case Kind.OBJECT_TYPE_EXTENSION:\n return 'object';\n case Kind.INTERFACE_TYPE_EXTENSION:\n return 'interface';\n case Kind.UNION_TYPE_EXTENSION:\n return 'union';\n case Kind.ENUM_TYPE_EXTENSION:\n return 'enum';\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return 'input object';\n // Not reachable. All possible types have been considered\n /* c8 ignore next 2 */\n default:\n invariant(false, 'Unexpected kind: ' + inspect(kind));\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/PossibleTypeExtensionsRule.mjs b/validation/rules/PossibleTypeExtensionsRule.mjs new file mode 100644 index 0000000000..38ae998478 --- /dev/null +++ b/validation/rules/PossibleTypeExtensionsRule.mjs @@ -0,0 +1,110 @@ +import { didYouMean } from "../../jsutils/didYouMean.mjs"; +import { inspect } from "../../jsutils/inspect.mjs"; +import { invariant } from "../../jsutils/invariant.mjs"; +import { suggestionList } from "../../jsutils/suggestionList.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { isTypeDefinitionNode } from "../../language/predicates.mjs"; +import { isEnumType, isInputObjectType, isInterfaceType, isObjectType, isScalarType, isUnionType, } from "../../type/definition.mjs"; +/** + * Possible type extension + * + * A type extension is only valid if the type is defined and has the same kind. + */ +export function PossibleTypeExtensionsRule(context) { + const schema = context.getSchema(); + const definedTypes = new Map(); + for (const def of context.getDocument().definitions) { + if (isTypeDefinitionNode(def)) { + definedTypes.set(def.name.value, def); + } + } + return { + ScalarTypeExtension: checkExtension, + ObjectTypeExtension: checkExtension, + InterfaceTypeExtension: checkExtension, + UnionTypeExtension: checkExtension, + EnumTypeExtension: checkExtension, + InputObjectTypeExtension: checkExtension, + }; + function checkExtension(node) { + const typeName = node.name.value; + const defNode = definedTypes.get(typeName); + const existingType = schema?.getType(typeName); + let expectedKind; + if (defNode != null) { + expectedKind = defKindToExtKind[defNode.kind]; + } + else if (existingType) { + expectedKind = typeToExtKind(existingType); + } + if (expectedKind != null) { + if (expectedKind !== node.kind) { + const kindStr = extensionKindToTypeName(node.kind); + context.reportError(new GraphQLError(`Cannot extend non-${kindStr} type "${typeName}".`, { + nodes: defNode ? [defNode, node] : node, + })); + } + } + else { + const allTypeNames = [ + ...definedTypes.keys(), + ...Object.keys(schema?.getTypeMap() ?? {}), + ]; + context.reportError(new GraphQLError(`Cannot extend type "${typeName}" because it is not defined.` + + didYouMean(suggestionList(typeName, allTypeNames)), { nodes: node.name })); + } + } +} +const defKindToExtKind = { + [Kind.SCALAR_TYPE_DEFINITION]: Kind.SCALAR_TYPE_EXTENSION, + [Kind.OBJECT_TYPE_DEFINITION]: Kind.OBJECT_TYPE_EXTENSION, + [Kind.INTERFACE_TYPE_DEFINITION]: Kind.INTERFACE_TYPE_EXTENSION, + [Kind.UNION_TYPE_DEFINITION]: Kind.UNION_TYPE_EXTENSION, + [Kind.ENUM_TYPE_DEFINITION]: Kind.ENUM_TYPE_EXTENSION, + [Kind.INPUT_OBJECT_TYPE_DEFINITION]: Kind.INPUT_OBJECT_TYPE_EXTENSION, +}; +function typeToExtKind(type) { + if (isScalarType(type)) { + return Kind.SCALAR_TYPE_EXTENSION; + } + if (isObjectType(type)) { + return Kind.OBJECT_TYPE_EXTENSION; + } + if (isInterfaceType(type)) { + return Kind.INTERFACE_TYPE_EXTENSION; + } + if (isUnionType(type)) { + return Kind.UNION_TYPE_EXTENSION; + } + if (isEnumType(type)) { + return Kind.ENUM_TYPE_EXTENSION; + } + if (isInputObjectType(type)) { + return Kind.INPUT_OBJECT_TYPE_EXTENSION; + } + /* c8 ignore next 3 */ + // Not reachable. All possible types have been considered + (false) || invariant(false, 'Unexpected type: ' + inspect(type)); +} +function extensionKindToTypeName(kind) { + switch (kind) { + case Kind.SCALAR_TYPE_EXTENSION: + return 'scalar'; + case Kind.OBJECT_TYPE_EXTENSION: + return 'object'; + case Kind.INTERFACE_TYPE_EXTENSION: + return 'interface'; + case Kind.UNION_TYPE_EXTENSION: + return 'union'; + case Kind.ENUM_TYPE_EXTENSION: + return 'enum'; + case Kind.INPUT_OBJECT_TYPE_EXTENSION: + return 'input object'; + // Not reachable. All possible types have been considered + /* c8 ignore next 2 */ + default: + (false) || invariant(false, 'Unexpected kind: ' + inspect(kind)); + } +} +//# sourceMappingURL=PossibleTypeExtensionsRule.js.map \ No newline at end of file diff --git a/validation/rules/PossibleTypeExtensionsRule.mjs.map b/validation/rules/PossibleTypeExtensionsRule.mjs.map new file mode 100644 index 0000000000..efb94cc4e1 --- /dev/null +++ b/validation/rules/PossibleTypeExtensionsRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"PossibleTypeExtensionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/PossibleTypeExtensionsRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qCAAoC;AACzD,OAAO,EAAE,OAAO,EAAE,kCAAiC;AACnD,OAAO,EAAE,SAAS,EAAE,oCAAmC;AACvD,OAAO,EAAE,cAAc,EAAE,yCAAwC;AAEjE,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,sCAAqC;AAIpE,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,kCAAiC;AAIlC;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAA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BAAwB,CAAC;IACvC,CAAC;IACD,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IACD,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC1C,CAAC;IACD,sBAAsB;IACtB,yDAAyD;IACzD,CAAU,KAAK,KAAf,SAAS,QAAQ,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE;AACxD,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAU;IACzC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,IAAI,CAAC,qBAAqB;YAC7B,OAAO,QAAQ,CAAC;QAClB,KAAK,IAAI,CAAC,qBAAqB;YAC7B,OAAO,QAAQ,CAAC;QAClB,KAAK,IAAI,CAAC,wBAAwB;YAChC,OAAO,WAAW,CAAC;QACrB,KAAK,IAAI,CAAC,oBAAoB;YAC5B,OAAO,OAAO,CAAC;QACjB,KAAK,IAAI,CAAC,mBAAmB;YAC3B,OAAO,MAAM,CAAC;QAChB,KAAK,IAAI,CAAC,2BAA2B;YACnC,OAAO,cAAc,CAAC;QACxB,yDAAyD;QACzD,sBAAsB;QACtB;YACE,CAAU,KAAK,KAAf,SAAS,QAAQ,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE;IAC1D,CAAC;AACH,CAAC","sourcesContent":["import { didYouMean } from '../../jsutils/didYouMean.js';\nimport { inspect } from '../../jsutils/inspect.js';\nimport { invariant } from '../../jsutils/invariant.js';\nimport { suggestionList } from '../../jsutils/suggestionList.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n TypeDefinitionNode,\n TypeExtensionNode,\n} from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport { isTypeDefinitionNode } from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLNamedType } from '../../type/definition.js';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from '../../type/definition.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Possible type extension\n *\n * A type extension is only valid if the type is defined and has the same kind.\n */\nexport function PossibleTypeExtensionsRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const definedTypes = new Map();\n\n for (const def of context.getDocument().definitions) {\n if (isTypeDefinitionNode(def)) {\n definedTypes.set(def.name.value, def);\n }\n }\n\n return {\n ScalarTypeExtension: checkExtension,\n ObjectTypeExtension: checkExtension,\n InterfaceTypeExtension: checkExtension,\n UnionTypeExtension: checkExtension,\n EnumTypeExtension: checkExtension,\n InputObjectTypeExtension: checkExtension,\n };\n\n function checkExtension(node: TypeExtensionNode): void {\n const typeName = node.name.value;\n const defNode = definedTypes.get(typeName);\n const existingType = schema?.getType(typeName);\n\n let expectedKind: Kind | undefined;\n if (defNode != null) {\n expectedKind = defKindToExtKind[defNode.kind];\n } else if (existingType) {\n expectedKind = typeToExtKind(existingType);\n }\n\n if (expectedKind != null) {\n if (expectedKind !== node.kind) {\n const kindStr = extensionKindToTypeName(node.kind);\n context.reportError(\n new GraphQLError(`Cannot extend non-${kindStr} type \"${typeName}\".`, {\n nodes: defNode ? [defNode, node] : node,\n }),\n );\n }\n } else {\n const allTypeNames = [\n ...definedTypes.keys(),\n ...Object.keys(schema?.getTypeMap() ?? {}),\n ];\n\n context.reportError(\n new GraphQLError(\n `Cannot extend type \"${typeName}\" because it is not defined.` +\n didYouMean(suggestionList(typeName, allTypeNames)),\n { nodes: node.name },\n ),\n );\n }\n }\n}\n\nconst defKindToExtKind = {\n [Kind.SCALAR_TYPE_DEFINITION]: Kind.SCALAR_TYPE_EXTENSION,\n [Kind.OBJECT_TYPE_DEFINITION]: Kind.OBJECT_TYPE_EXTENSION,\n [Kind.INTERFACE_TYPE_DEFINITION]: Kind.INTERFACE_TYPE_EXTENSION,\n [Kind.UNION_TYPE_DEFINITION]: Kind.UNION_TYPE_EXTENSION,\n [Kind.ENUM_TYPE_DEFINITION]: Kind.ENUM_TYPE_EXTENSION,\n [Kind.INPUT_OBJECT_TYPE_DEFINITION]: Kind.INPUT_OBJECT_TYPE_EXTENSION,\n} as const;\n\nfunction typeToExtKind(type: GraphQLNamedType): Kind {\n if (isScalarType(type)) {\n return Kind.SCALAR_TYPE_EXTENSION;\n }\n if (isObjectType(type)) {\n return Kind.OBJECT_TYPE_EXTENSION;\n }\n if (isInterfaceType(type)) {\n return Kind.INTERFACE_TYPE_EXTENSION;\n }\n if (isUnionType(type)) {\n return Kind.UNION_TYPE_EXTENSION;\n }\n if (isEnumType(type)) {\n return Kind.ENUM_TYPE_EXTENSION;\n }\n if (isInputObjectType(type)) {\n return Kind.INPUT_OBJECT_TYPE_EXTENSION;\n }\n /* c8 ignore next 3 */\n // Not reachable. All possible types have been considered\n invariant(false, 'Unexpected type: ' + inspect(type));\n}\n\nfunction extensionKindToTypeName(kind: Kind): string {\n switch (kind) {\n case Kind.SCALAR_TYPE_EXTENSION:\n return 'scalar';\n case Kind.OBJECT_TYPE_EXTENSION:\n return 'object';\n case Kind.INTERFACE_TYPE_EXTENSION:\n return 'interface';\n case Kind.UNION_TYPE_EXTENSION:\n return 'union';\n case Kind.ENUM_TYPE_EXTENSION:\n return 'enum';\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return 'input object';\n // Not reachable. All possible types have been considered\n /* c8 ignore next 2 */\n default:\n invariant(false, 'Unexpected kind: ' + inspect(kind));\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ProvidedRequiredArgumentsRule.d.ts b/validation/rules/ProvidedRequiredArgumentsRule.d.ts new file mode 100644 index 0000000000..5cf32323a7 --- /dev/null +++ b/validation/rules/ProvidedRequiredArgumentsRule.d.ts @@ -0,0 +1,13 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext, ValidationContext } from '../ValidationContext.js'; +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. + */ +export declare function ProvidedRequiredArgumentsRule(context: ValidationContext): ASTVisitor; +/** + * @internal + */ +export declare function ProvidedRequiredArgumentsOnDirectivesRule(context: ValidationContext | SDLValidationContext): ASTVisitor; diff --git a/validation/rules/ProvidedRequiredArgumentsRule.js b/validation/rules/ProvidedRequiredArgumentsRule.js new file mode 100644 index 0000000000..b4be64d83d --- /dev/null +++ b/validation/rules/ProvidedRequiredArgumentsRule.js @@ -0,0 +1,101 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ProvidedRequiredArgumentsRule = ProvidedRequiredArgumentsRule; +exports.ProvidedRequiredArgumentsOnDirectivesRule = ProvidedRequiredArgumentsOnDirectivesRule; +const inspect_js_1 = require("../../jsutils/inspect.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const printer_js_1 = require("../../language/printer.js"); +const definition_js_1 = require("../../type/definition.js"); +const directives_js_1 = require("../../type/directives.js"); +const typeFromAST_js_1 = require("../../utilities/typeFromAST.js"); +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. + */ +function ProvidedRequiredArgumentsRule(context) { + return { + // eslint-disable-next-line new-cap + ...ProvidedRequiredArgumentsOnDirectivesRule(context), + Field: { + // Validate on leave to allow for deeper errors to appear first. + leave(fieldNode) { + const fieldDef = context.getFieldDef(); + if (!fieldDef) { + return false; + } + const providedArgs = new Set(fieldNode.arguments?.map((arg) => arg.name.value)); + for (const argDef of fieldDef.args) { + if (!providedArgs.has(argDef.name) && (0, definition_js_1.isRequiredArgument)(argDef)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Argument "${argDef}" of type "${argDef.type}" is required, but it was not provided.`, { nodes: fieldNode })); + } + } + }, + }, + FragmentSpread: { + // Validate on leave to allow for deeper errors to appear first. + leave(spreadNode) { + const fragmentSignature = context.getFragmentSignature(); + if (!fragmentSignature) { + return false; + } + const providedArgs = new Set(spreadNode.arguments?.map((arg) => arg.name.value)); + for (const [varName, variableDefinition,] of fragmentSignature.variableDefinitions) { + if (!providedArgs.has(varName) && + isRequiredArgumentNode(variableDefinition)) { + const type = (0, typeFromAST_js_1.typeFromAST)(context.getSchema(), variableDefinition.type); + const argTypeStr = (0, inspect_js_1.inspect)(type); + context.reportError(new GraphQLError_js_1.GraphQLError(`Fragment "${spreadNode.name.value}" argument "${varName}" of type "${argTypeStr}" is required, but it was not provided.`, { nodes: spreadNode })); + } + } + }, + }, + }; +} +/** + * @internal + */ +function ProvidedRequiredArgumentsOnDirectivesRule(context) { + const requiredArgsMap = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema?.getDirectives() ?? directives_js_1.specifiedDirectives; + for (const directive of definedDirectives) { + requiredArgsMap.set(directive.name, new Map(directive.args.filter(definition_js_1.isRequiredArgument).map((arg) => [arg.name, arg]))); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === kinds_js_1.Kind.DIRECTIVE_DEFINITION) { + const argNodes = def.arguments ?? []; + requiredArgsMap.set(def.name.value, new Map(argNodes + .filter(isRequiredArgumentNode) + .map((arg) => [arg.name.value, arg]))); + } + } + return { + Directive: { + // Validate on leave to allow for deeper errors to appear first. + leave(directiveNode) { + const directiveName = directiveNode.name.value; + const requiredArgs = requiredArgsMap.get(directiveName); + if (requiredArgs != null) { + const argNodes = directiveNode.arguments ?? []; + const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); + for (const [argName, argDef] of requiredArgs.entries()) { + if (!argNodeMap.has(argName)) { + const argType = (0, definition_js_1.isType)(argDef.type) + ? (0, inspect_js_1.inspect)(argDef.type) + : (0, printer_js_1.print)(argDef.type); + context.reportError(new GraphQLError_js_1.GraphQLError(`Argument "@${directiveName}(${argName}:)" of type "${argType}" is required, but it was not provided.`, { nodes: directiveNode })); + } + } + } + }, + }, + }; +} +function isRequiredArgumentNode(arg) { + return arg.type.kind === kinds_js_1.Kind.NON_NULL_TYPE && arg.defaultValue == null; +} +//# sourceMappingURL=ProvidedRequiredArgumentsRule.js.map \ No newline at end of file diff --git a/validation/rules/ProvidedRequiredArgumentsRule.js.map b/validation/rules/ProvidedRequiredArgumentsRule.js.map new file mode 100644 index 0000000000..86094c753b --- /dev/null +++ b/validation/rules/ProvidedRequiredArgumentsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ProvidedRequiredArgumentsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ProvidedRequiredArgumentsRule.ts"],"names":[],"mappings":";;AA6BA,sEAgEC;AAKD,8FA6DC;AA/JD,yDAAmD;AAEnD,iEAA2D;AAM3D,sDAA+C;AAC/C,0DAAkD;AAIlD,4DAAsE;AACtE,4DAA+D;AAE/D,mEAA6D;AAO7D;;;;;GAKG;AACH,SAAgB,6BAA6B,CAC3C,OAA0B;IAE1B,OAAO;QACL,mCAAmC;QACnC,GAAG,yCAAyC,CAAC,OAAO,CAAC;QACrD,KAAK,EAAE;YACL,gEAAgE;YAChE,KAAK,CAAC,SAAS;gBACb,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;gBACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,OAAO,KAAK,CAAC;gBACf,CAAC;gBAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAC1B,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAClD,CAAC;gBACF,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;oBACnC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAA,kCAAkB,EAAC,MAA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,SAAS,IAAI,EAAE,CAAC;oBAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;oBAClE,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC;wBACvD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;4BAC7B,MAAM,OAAO,GAAG,IAAA,sBAAM,EAAC,MAAM,CAAC,IAAI,CAAC;gCACjC,CAAC,CAAC,IAAA,oBAAO,EAAC,MAAM,CAAC,IAAI,CAAC;gCACtB,CAAC,CAAC,IAAA,kBAAK,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;4BACvB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,cAAc,aAAa,IAAI,OAAO,gBAAgB,OAAO,yCAAyC,EACtG,EAAE,KAAK,EAAE,aAAa,EAAE,CACzB,CACF,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,GAAsD;IAEtD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,eAAI,CAAC,aAAa,IAAI,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC;AAC1E,CAAC","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n InputValueDefinitionNode,\n VariableDefinitionNode,\n} from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLArgument } from '../../type/definition.js';\nimport { isRequiredArgument, isType } from '../../type/definition.js';\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Provided required arguments\n *\n * A field or directive is only valid if all required (non-null without a\n * default value) field arguments have been provided.\n */\nexport function ProvidedRequiredArgumentsRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n // eslint-disable-next-line new-cap\n ...ProvidedRequiredArgumentsOnDirectivesRule(context),\n Field: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(fieldNode) {\n const fieldDef = context.getFieldDef();\n if (!fieldDef) {\n return false;\n }\n\n const providedArgs = new Set(\n fieldNode.arguments?.map((arg) => arg.name.value),\n );\n for (const argDef of fieldDef.args) {\n if (!providedArgs.has(argDef.name) && isRequiredArgument(argDef)) {\n context.reportError(\n new GraphQLError(\n `Argument \"${argDef}\" of type \"${argDef.type}\" is required, but it was not provided.`,\n { nodes: fieldNode },\n ),\n );\n }\n }\n },\n },\n FragmentSpread: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(spreadNode) {\n const fragmentSignature = context.getFragmentSignature();\n if (!fragmentSignature) {\n return false;\n }\n\n const providedArgs = new Set(\n spreadNode.arguments?.map((arg) => arg.name.value),\n );\n for (const [\n varName,\n variableDefinition,\n ] of fragmentSignature.variableDefinitions) {\n if (\n !providedArgs.has(varName) &&\n isRequiredArgumentNode(variableDefinition)\n ) {\n const type = typeFromAST(\n context.getSchema(),\n variableDefinition.type,\n );\n const argTypeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Fragment \"${spreadNode.name.value}\" argument \"${varName}\" of type \"${argTypeStr}\" is required, but it was not provided.`,\n { nodes: spreadNode },\n ),\n );\n }\n }\n },\n },\n };\n}\n\n/**\n * @internal\n */\nexport function ProvidedRequiredArgumentsOnDirectivesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const requiredArgsMap = new Map<\n string,\n Map\n >();\n\n const schema = context.getSchema();\n const definedDirectives = schema?.getDirectives() ?? specifiedDirectives;\n for (const directive of definedDirectives) {\n requiredArgsMap.set(\n directive.name,\n new Map(\n directive.args.filter(isRequiredArgument).map((arg) => [arg.name, arg]),\n ),\n );\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n const argNodes = def.arguments ?? [];\n\n requiredArgsMap.set(\n def.name.value,\n new Map(\n argNodes\n .filter(isRequiredArgumentNode)\n .map((arg) => [arg.name.value, arg]),\n ),\n );\n }\n }\n\n return {\n Directive: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(directiveNode) {\n const directiveName = directiveNode.name.value;\n const requiredArgs = requiredArgsMap.get(directiveName);\n if (requiredArgs != null) {\n const argNodes = directiveNode.arguments ?? [];\n const argNodeMap = new Set(argNodes.map((arg) => arg.name.value));\n for (const [argName, argDef] of requiredArgs.entries()) {\n if (!argNodeMap.has(argName)) {\n const argType = isType(argDef.type)\n ? inspect(argDef.type)\n : print(argDef.type);\n context.reportError(\n new GraphQLError(\n `Argument \"@${directiveName}(${argName}:)\" of type \"${argType}\" is required, but it was not provided.`,\n { nodes: directiveNode },\n ),\n );\n }\n }\n }\n },\n },\n };\n}\n\nfunction isRequiredArgumentNode(\n arg: InputValueDefinitionNode | VariableDefinitionNode,\n): boolean {\n return arg.type.kind === Kind.NON_NULL_TYPE && arg.defaultValue == null;\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ProvidedRequiredArgumentsRule.mjs b/validation/rules/ProvidedRequiredArgumentsRule.mjs new file mode 100644 index 0000000000..6663df423d --- /dev/null +++ b/validation/rules/ProvidedRequiredArgumentsRule.mjs @@ -0,0 +1,97 @@ +import { inspect } from "../../jsutils/inspect.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { print } from "../../language/printer.mjs"; +import { isRequiredArgument, isType } from "../../type/definition.mjs"; +import { specifiedDirectives } from "../../type/directives.mjs"; +import { typeFromAST } from "../../utilities/typeFromAST.mjs"; +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. + */ +export function ProvidedRequiredArgumentsRule(context) { + return { + // eslint-disable-next-line new-cap + ...ProvidedRequiredArgumentsOnDirectivesRule(context), + Field: { + // Validate on leave to allow for deeper errors to appear first. + leave(fieldNode) { + const fieldDef = context.getFieldDef(); + if (!fieldDef) { + return false; + } + const providedArgs = new Set(fieldNode.arguments?.map((arg) => arg.name.value)); + for (const argDef of fieldDef.args) { + if (!providedArgs.has(argDef.name) && isRequiredArgument(argDef)) { + context.reportError(new GraphQLError(`Argument "${argDef}" of type "${argDef.type}" is required, but it was not provided.`, { nodes: fieldNode })); + } + } + }, + }, + FragmentSpread: { + // Validate on leave to allow for deeper errors to appear first. + leave(spreadNode) { + const fragmentSignature = context.getFragmentSignature(); + if (!fragmentSignature) { + return false; + } + const providedArgs = new Set(spreadNode.arguments?.map((arg) => arg.name.value)); + for (const [varName, variableDefinition,] of fragmentSignature.variableDefinitions) { + if (!providedArgs.has(varName) && + isRequiredArgumentNode(variableDefinition)) { + const type = typeFromAST(context.getSchema(), variableDefinition.type); + const argTypeStr = inspect(type); + context.reportError(new GraphQLError(`Fragment "${spreadNode.name.value}" argument "${varName}" of type "${argTypeStr}" is required, but it was not provided.`, { nodes: spreadNode })); + } + } + }, + }, + }; +} +/** + * @internal + */ +export function ProvidedRequiredArgumentsOnDirectivesRule(context) { + const requiredArgsMap = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema?.getDirectives() ?? specifiedDirectives; + for (const directive of definedDirectives) { + requiredArgsMap.set(directive.name, new Map(directive.args.filter(isRequiredArgument).map((arg) => [arg.name, arg]))); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === Kind.DIRECTIVE_DEFINITION) { + const argNodes = def.arguments ?? []; + requiredArgsMap.set(def.name.value, new Map(argNodes + .filter(isRequiredArgumentNode) + .map((arg) => [arg.name.value, arg]))); + } + } + return { + Directive: { + // Validate on leave to allow for deeper errors to appear first. + leave(directiveNode) { + const directiveName = directiveNode.name.value; + const requiredArgs = requiredArgsMap.get(directiveName); + if (requiredArgs != null) { + const argNodes = directiveNode.arguments ?? []; + const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); + for (const [argName, argDef] of requiredArgs.entries()) { + if (!argNodeMap.has(argName)) { + const argType = isType(argDef.type) + ? inspect(argDef.type) + : print(argDef.type); + context.reportError(new GraphQLError(`Argument "@${directiveName}(${argName}:)" of type "${argType}" is required, but it was not provided.`, { nodes: directiveNode })); + } + } + } + }, + }, + }; +} +function isRequiredArgumentNode(arg) { + return arg.type.kind === Kind.NON_NULL_TYPE && arg.defaultValue == null; +} +//# sourceMappingURL=ProvidedRequiredArgumentsRule.js.map \ No newline at end of file diff --git a/validation/rules/ProvidedRequiredArgumentsRule.mjs.map b/validation/rules/ProvidedRequiredArgumentsRule.mjs.map new file mode 100644 index 0000000000..93883a2710 --- /dev/null +++ b/validation/rules/ProvidedRequiredArgumentsRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ProvidedRequiredArgumentsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ProvidedRequiredArgumentsRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAEnD,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAC/C,OAAO,EAAE,KAAK,EAAE,mCAAkC;AAIlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,kCAAiC;AACtE,OAAO,EAAE,mBAAmB,EAAE,kCAAiC;AAE/D,OAAO,EAAE,WAAW,EAAE,wCAAuC;AAO7D;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAA0B;IAE1B,OAAO;QACL,mCAAmC;QACnC,GAAG,yCAAyC,CAAC,OAAO,CAAC;QACrD,KAAK,EAAE;YACL,gEAAgE;YAChE,KAAK,CAAC,SAAS;gBACb,MAAM,QAA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AAI,CAAC,aAAa,IAAI,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC;AAC1E,CAAC","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n InputValueDefinitionNode,\n VariableDefinitionNode,\n} from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLArgument } from '../../type/definition.js';\nimport { isRequiredArgument, isType } from '../../type/definition.js';\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Provided required arguments\n *\n * A field or directive is only valid if all required (non-null without a\n * default value) field arguments have been provided.\n */\nexport function ProvidedRequiredArgumentsRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n // eslint-disable-next-line new-cap\n ...ProvidedRequiredArgumentsOnDirectivesRule(context),\n Field: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(fieldNode) {\n const fieldDef = context.getFieldDef();\n if (!fieldDef) {\n return false;\n }\n\n const providedArgs = new Set(\n fieldNode.arguments?.map((arg) => arg.name.value),\n );\n for (const argDef of fieldDef.args) {\n if (!providedArgs.has(argDef.name) && isRequiredArgument(argDef)) {\n context.reportError(\n new GraphQLError(\n `Argument \"${argDef}\" of type \"${argDef.type}\" is required, but it was not provided.`,\n { nodes: fieldNode },\n ),\n );\n }\n }\n },\n },\n FragmentSpread: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(spreadNode) {\n const fragmentSignature = context.getFragmentSignature();\n if (!fragmentSignature) {\n return false;\n }\n\n const providedArgs = new Set(\n spreadNode.arguments?.map((arg) => arg.name.value),\n );\n for (const [\n varName,\n variableDefinition,\n ] of fragmentSignature.variableDefinitions) {\n if (\n !providedArgs.has(varName) &&\n isRequiredArgumentNode(variableDefinition)\n ) {\n const type = typeFromAST(\n context.getSchema(),\n variableDefinition.type,\n );\n const argTypeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Fragment \"${spreadNode.name.value}\" argument \"${varName}\" of type \"${argTypeStr}\" is required, but it was not provided.`,\n { nodes: spreadNode },\n ),\n );\n }\n }\n },\n },\n };\n}\n\n/**\n * @internal\n */\nexport function ProvidedRequiredArgumentsOnDirectivesRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const requiredArgsMap = new Map<\n string,\n Map\n >();\n\n const schema = context.getSchema();\n const definedDirectives = schema?.getDirectives() ?? specifiedDirectives;\n for (const directive of definedDirectives) {\n requiredArgsMap.set(\n directive.name,\n new Map(\n directive.args.filter(isRequiredArgument).map((arg) => [arg.name, arg]),\n ),\n );\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n const argNodes = def.arguments ?? [];\n\n requiredArgsMap.set(\n def.name.value,\n new Map(\n argNodes\n .filter(isRequiredArgumentNode)\n .map((arg) => [arg.name.value, arg]),\n ),\n );\n }\n }\n\n return {\n Directive: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(directiveNode) {\n const directiveName = directiveNode.name.value;\n const requiredArgs = requiredArgsMap.get(directiveName);\n if (requiredArgs != null) {\n const argNodes = directiveNode.arguments ?? [];\n const argNodeMap = new Set(argNodes.map((arg) => arg.name.value));\n for (const [argName, argDef] of requiredArgs.entries()) {\n if (!argNodeMap.has(argName)) {\n const argType = isType(argDef.type)\n ? inspect(argDef.type)\n : print(argDef.type);\n context.reportError(\n new GraphQLError(\n `Argument \"@${directiveName}(${argName}:)\" of type \"${argType}\" is required, but it was not provided.`,\n { nodes: directiveNode },\n ),\n );\n }\n }\n }\n },\n },\n };\n}\n\nfunction isRequiredArgumentNode(\n arg: InputValueDefinitionNode | VariableDefinitionNode,\n): boolean {\n return arg.type.kind === Kind.NON_NULL_TYPE && arg.defaultValue == null;\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ScalarLeafsRule.d.ts b/validation/rules/ScalarLeafsRule.d.ts new file mode 100644 index 0000000000..03b73080a3 --- /dev/null +++ b/validation/rules/ScalarLeafsRule.d.ts @@ -0,0 +1,9 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Scalar leafs + * + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. + */ +export declare function ScalarLeafsRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/ScalarLeafsRule.js b/validation/rules/ScalarLeafsRule.js new file mode 100644 index 0000000000..85341d129e --- /dev/null +++ b/validation/rules/ScalarLeafsRule.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ScalarLeafsRule = ScalarLeafsRule; +const inspect_js_1 = require("../../jsutils/inspect.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const definition_js_1 = require("../../type/definition.js"); +/** + * Scalar leafs + * + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. + */ +function ScalarLeafsRule(context) { + return { + Field(node) { + const type = context.getType(); + const selectionSet = node.selectionSet; + if (type) { + if ((0, definition_js_1.isLeafType)((0, definition_js_1.getNamedType)(type))) { + if (selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, inspect_js_1.inspect)(type); + context.reportError(new GraphQLError_js_1.GraphQLError(`Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, { nodes: selectionSet })); + } + } + else if (!selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, inspect_js_1.inspect)(type); + context.reportError(new GraphQLError_js_1.GraphQLError(`Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, { nodes: node })); + } + else if (selectionSet.selections.length === 0) { + const fieldName = node.name.value; + const typeStr = (0, inspect_js_1.inspect)(type); + context.reportError(new GraphQLError_js_1.GraphQLError(`Field "${fieldName}" of type "${typeStr}" must have at least one field selected.`, { nodes: node })); + } + } + }, + }; +} +//# sourceMappingURL=ScalarLeafsRule.js.map \ No newline at end of file diff --git a/validation/rules/ScalarLeafsRule.js.map b/validation/rules/ScalarLeafsRule.js.map new file mode 100644 index 0000000000..66a3ab8db9 --- /dev/null +++ b/validation/rules/ScalarLeafsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ScalarLeafsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ScalarLeafsRule.ts"],"names":[],"mappings":";;AAiBA,0CAuCC;AAxDD,yDAAmD;AAEnD,iEAA2D;AAK3D,4DAAoE;AAIpE;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,OAA0B;IACxD,OAAO;QACL,KAAK,CAAC,IAAe;YACnB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;YACvC,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,IAAA,0BAAU,EAAC,IAAA,4BAAY,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC;oBACnC,IAAI,YAAY,EAAE,CAAC;wBACjB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;wBAClC,MAAM,OAAO,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,CAAC;wBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,UAAU,SAAS,2CAA2C,OAAO,qBAAqB,EAC1F,EAAE,KAAK,EAAE,YAAY,EAAE,CACxB,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC;qBAAM,IAAI,CAAC,YAAY,EAAE,CAAC;oBACzB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;oBAClC,MAAM,OAAO,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,CAAC;oBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,UAAU,SAAS,cAAc,OAAO,uDAAuD,SAAS,YAAY,EACpH,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;qBAAM,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAChD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;oBAClC,MAAM,OAAO,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,CAAC;oBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,UAAU,SAAS,cAAc,OAAO,0CAA0C,EAClF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FieldNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { getNamedType, isLeafType } from '../../type/definition.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Scalar leafs\n *\n * A GraphQL document is valid only if all leaf fields (fields without\n * sub selections) are of scalar or enum types.\n */\nexport function ScalarLeafsRule(context: ValidationContext): ASTVisitor {\n return {\n Field(node: FieldNode) {\n const type = context.getType();\n const selectionSet = node.selectionSet;\n if (type) {\n if (isLeafType(getNamedType(type))) {\n if (selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Field \"${fieldName}\" must not have a selection since type \"${typeStr}\" has no subfields.`,\n { nodes: selectionSet },\n ),\n );\n }\n } else if (!selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Field \"${fieldName}\" of type \"${typeStr}\" must have a selection of subfields. Did you mean \"${fieldName} { ... }\"?`,\n { nodes: node },\n ),\n );\n } else if (selectionSet.selections.length === 0) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Field \"${fieldName}\" of type \"${typeStr}\" must have at least one field selected.`,\n { nodes: node },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ScalarLeafsRule.mjs b/validation/rules/ScalarLeafsRule.mjs new file mode 100644 index 0000000000..ce9403094f --- /dev/null +++ b/validation/rules/ScalarLeafsRule.mjs @@ -0,0 +1,37 @@ +import { inspect } from "../../jsutils/inspect.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { getNamedType, isLeafType } from "../../type/definition.mjs"; +/** + * Scalar leafs + * + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. + */ +export function ScalarLeafsRule(context) { + return { + Field(node) { + const type = context.getType(); + const selectionSet = node.selectionSet; + if (type) { + if (isLeafType(getNamedType(type))) { + if (selectionSet) { + const fieldName = node.name.value; + const typeStr = inspect(type); + context.reportError(new GraphQLError(`Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, { nodes: selectionSet })); + } + } + else if (!selectionSet) { + const fieldName = node.name.value; + const typeStr = inspect(type); + context.reportError(new GraphQLError(`Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, { nodes: node })); + } + else if (selectionSet.selections.length === 0) { + const fieldName = node.name.value; + const typeStr = inspect(type); + context.reportError(new GraphQLError(`Field "${fieldName}" of type "${typeStr}" must have at least one field selected.`, { nodes: node })); + } + } + }, + }; +} +//# sourceMappingURL=ScalarLeafsRule.js.map \ No newline at end of file diff --git a/validation/rules/ScalarLeafsRule.mjs.map b/validation/rules/ScalarLeafsRule.mjs.map new file mode 100644 index 0000000000..324b083037 --- /dev/null +++ b/validation/rules/ScalarLeafsRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ScalarLeafsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ScalarLeafsRule.ts"],"names":[],"mappings":"AAAA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OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,UAAU,SAAS,cAAc,OAAO,0CAA0C,EAClF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { inspect } from '../../jsutils/inspect.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FieldNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { getNamedType, isLeafType } from '../../type/definition.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Scalar leafs\n *\n * A GraphQL document is valid only if all leaf fields (fields without\n * sub selections) are of scalar or enum types.\n */\nexport function ScalarLeafsRule(context: ValidationContext): ASTVisitor {\n return {\n Field(node: FieldNode) {\n const type = context.getType();\n const selectionSet = node.selectionSet;\n if (type) {\n if (isLeafType(getNamedType(type))) {\n if (selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Field \"${fieldName}\" must not have a selection since type \"${typeStr}\" has no subfields.`,\n { nodes: selectionSet },\n ),\n );\n }\n } else if (!selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Field \"${fieldName}\" of type \"${typeStr}\" must have a selection of subfields. Did you mean \"${fieldName} { ... }\"?`,\n { nodes: node },\n ),\n );\n } else if (selectionSet.selections.length === 0) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(\n new GraphQLError(\n `Field \"${fieldName}\" of type \"${typeStr}\" must have at least one field selected.`,\n { nodes: node },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/SingleFieldSubscriptionsRule.d.ts b/validation/rules/SingleFieldSubscriptionsRule.d.ts new file mode 100644 index 0000000000..08d410505d --- /dev/null +++ b/validation/rules/SingleFieldSubscriptionsRule.d.ts @@ -0,0 +1,12 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Subscriptions must only include a non-introspection field. + * + * A GraphQL subscription is valid only if it contains a single root field and + * that root field is not an introspection field. `@skip` and `@include` + * directives are forbidden. + * + * See https://spec.graphql.org/draft/#sec-Single-root-field + */ +export declare function SingleFieldSubscriptionsRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/SingleFieldSubscriptionsRule.js b/validation/rules/SingleFieldSubscriptionsRule.js new file mode 100644 index 0000000000..f34130fda5 --- /dev/null +++ b/validation/rules/SingleFieldSubscriptionsRule.js @@ -0,0 +1,63 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SingleFieldSubscriptionsRule = SingleFieldSubscriptionsRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const collectFields_js_1 = require("../../execution/collectFields.js"); +function toNodes(fieldDetailsList) { + return fieldDetailsList.map((fieldDetails) => fieldDetails.node); +} +/** + * Subscriptions must only include a non-introspection field. + * + * A GraphQL subscription is valid only if it contains a single root field and + * that root field is not an introspection field. `@skip` and `@include` + * directives are forbidden. + * + * See https://spec.graphql.org/draft/#sec-Single-root-field + */ +function SingleFieldSubscriptionsRule(context) { + return { + OperationDefinition(node) { + if (node.operation === 'subscription') { + const schema = context.getSchema(); + const subscriptionType = schema.getSubscriptionType(); + if (subscriptionType) { + const operationName = node.name ? node.name.value : null; + const variableValues = Object.create(null); + const document = context.getDocument(); + const fragments = Object.create(null); + for (const definition of document.definitions) { + if (definition.kind === kinds_js_1.Kind.FRAGMENT_DEFINITION) { + fragments[definition.name.value] = { definition }; + } + } + const { groupedFieldSet, forbiddenDirectiveInstances } = (0, collectFields_js_1.collectFields)(schema, fragments, variableValues, subscriptionType, node.selectionSet, context.hideSuggestions, true); + if (forbiddenDirectiveInstances.length > 0) { + context.reportError(new GraphQLError_js_1.GraphQLError(operationName != null + ? `Subscription "${operationName}" must not use \`@skip\` or \`@include\` directives in the top level selection.` + : 'Anonymous Subscription must not use `@skip` or `@include` directives in the top level selection.', { nodes: forbiddenDirectiveInstances })); + return; + } + if (groupedFieldSet.size > 1) { + const fieldDetailsLists = [...groupedFieldSet.values()]; + const extraFieldDetailsLists = fieldDetailsLists.slice(1); + const extraFieldSelections = extraFieldDetailsLists.flatMap((fieldDetailsList) => toNodes(fieldDetailsList)); + context.reportError(new GraphQLError_js_1.GraphQLError(operationName != null + ? `Subscription "${operationName}" must select only one top level field.` + : 'Anonymous Subscription must select only one top level field.', { nodes: extraFieldSelections })); + } + for (const fieldDetailsList of groupedFieldSet.values()) { + const fieldName = toNodes(fieldDetailsList)[0].name.value; + if (fieldName.startsWith('__')) { + context.reportError(new GraphQLError_js_1.GraphQLError(operationName != null + ? `Subscription "${operationName}" must not select an introspection top level field.` + : 'Anonymous Subscription must not select an introspection top level field.', { nodes: toNodes(fieldDetailsList) })); + } + } + } + } + }, + }; +} +//# sourceMappingURL=SingleFieldSubscriptionsRule.js.map \ No newline at end of file diff --git a/validation/rules/SingleFieldSubscriptionsRule.js.map b/validation/rules/SingleFieldSubscriptionsRule.js.map new file mode 100644 index 0000000000..5a4aad0ee1 --- /dev/null +++ b/validation/rules/SingleFieldSubscriptionsRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SingleFieldSubscriptionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/SingleFieldSubscriptionsRule.ts"],"names":[],"mappings":";;AA8BA,oEAuEC;AAnGD,iEAA2D;AAG3D,sDAA+C;AAO/C,uEAAiE;AAKjE,SAAS,OAAO,CAAC,gBAAkC;IACjD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,4BAA4B,CAC1C,OAA0B;IAE1B,OAAO;QACL,mBAAmB,CAAC,IAA6B;YAC/C,IAAI,IAAI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I,GAAG,CAAC,EAAE,CAAC;wBAC7B,MAAM,iBAAiB,GAAG,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;wBACxD,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBAC1D,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,OAAO,CACzD,CAAC,gBAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAChD,CAAC;wBACF,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,aAAa,IAAI,IAAI;4BACnB,CAAC,CAAC,iBAAiB,aAAa,yCAAyC;4BACzE,CAAC,CAAC,8DAA8D,EAClE,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAChC,CACF,CAAC;oBACJ,CAAC;oBACD,KAAK,MAAM,gBAAgB,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;wBACxD,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;wBAC1D,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;4BAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,aAAa,IAAI,IAAI;gCACnB,CAAC,CAAC,iBAAiB,aAAa,qDAAqD;gCACrF,CAAC,CAAC,0EAA0E,EAC9E,EAAE,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,CACrC,CACF,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { ObjMap } from '../../jsutils/ObjMap.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FieldNode, OperationDefinitionNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type {\n FieldDetailsList,\n FragmentDetails,\n} from '../../execution/collectFields.js';\nimport { collectFields } from '../../execution/collectFields.js';\nimport type { VariableValues } from '../../execution/values.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\nfunction toNodes(fieldDetailsList: FieldDetailsList): ReadonlyArray {\n return fieldDetailsList.map((fieldDetails) => fieldDetails.node);\n}\n\n/**\n * Subscriptions must only include a non-introspection field.\n *\n * A GraphQL subscription is valid only if it contains a single root field and\n * that root field is not an introspection field. `@skip` and `@include`\n * directives are forbidden.\n *\n * See https://spec.graphql.org/draft/#sec-Single-root-field\n */\nexport function SingleFieldSubscriptionsRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(node: OperationDefinitionNode) {\n if (node.operation === 'subscription') {\n const schema = context.getSchema();\n const subscriptionType = schema.getSubscriptionType();\n if (subscriptionType) {\n const operationName = node.name ? node.name.value : null;\n const variableValues: VariableValues = Object.create(null);\n const document = context.getDocument();\n const fragments: ObjMap = Object.create(null);\n for (const definition of document.definitions) {\n if (definition.kind === Kind.FRAGMENT_DEFINITION) {\n fragments[definition.name.value] = { definition };\n }\n }\n const { groupedFieldSet, forbiddenDirectiveInstances } =\n collectFields(\n schema,\n fragments,\n variableValues,\n subscriptionType,\n node.selectionSet,\n context.hideSuggestions,\n true,\n );\n if (forbiddenDirectiveInstances.length > 0) {\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must not use \\`@skip\\` or \\`@include\\` directives in the top level selection.`\n : 'Anonymous Subscription must not use `@skip` or `@include` directives in the top level selection.',\n { nodes: forbiddenDirectiveInstances },\n ),\n );\n return;\n }\n if (groupedFieldSet.size > 1) {\n const fieldDetailsLists = [...groupedFieldSet.values()];\n const extraFieldDetailsLists = fieldDetailsLists.slice(1);\n const extraFieldSelections = extraFieldDetailsLists.flatMap(\n (fieldDetailsList) => toNodes(fieldDetailsList),\n );\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must select only one top level field.`\n : 'Anonymous Subscription must select only one top level field.',\n { nodes: extraFieldSelections },\n ),\n );\n }\n for (const fieldDetailsList of groupedFieldSet.values()) {\n const fieldName = toNodes(fieldDetailsList)[0].name.value;\n if (fieldName.startsWith('__')) {\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must not select an introspection top level field.`\n : 'Anonymous Subscription must not select an introspection top level field.',\n { nodes: toNodes(fieldDetailsList) },\n ),\n );\n }\n }\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/SingleFieldSubscriptionsRule.mjs b/validation/rules/SingleFieldSubscriptionsRule.mjs new file mode 100644 index 0000000000..cbb2490374 --- /dev/null +++ b/validation/rules/SingleFieldSubscriptionsRule.mjs @@ -0,0 +1,60 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { collectFields } from "../../execution/collectFields.mjs"; +function toNodes(fieldDetailsList) { + return fieldDetailsList.map((fieldDetails) => fieldDetails.node); +} +/** + * Subscriptions must only include a non-introspection field. + * + * A GraphQL subscription is valid only if it contains a single root field and + * that root field is not an introspection field. `@skip` and `@include` + * directives are forbidden. + * + * See https://spec.graphql.org/draft/#sec-Single-root-field + */ +export function SingleFieldSubscriptionsRule(context) { + return { + OperationDefinition(node) { + if (node.operation === 'subscription') { + const schema = context.getSchema(); + const subscriptionType = schema.getSubscriptionType(); + if (subscriptionType) { + const operationName = node.name ? node.name.value : null; + const variableValues = Object.create(null); + const document = context.getDocument(); + const fragments = Object.create(null); + for (const definition of document.definitions) { + if (definition.kind === Kind.FRAGMENT_DEFINITION) { + fragments[definition.name.value] = { definition }; + } + } + const { groupedFieldSet, forbiddenDirectiveInstances } = collectFields(schema, fragments, variableValues, subscriptionType, node.selectionSet, context.hideSuggestions, true); + if (forbiddenDirectiveInstances.length > 0) { + context.reportError(new GraphQLError(operationName != null + ? `Subscription "${operationName}" must not use \`@skip\` or \`@include\` directives in the top level selection.` + : 'Anonymous Subscription must not use `@skip` or `@include` directives in the top level selection.', { nodes: forbiddenDirectiveInstances })); + return; + } + if (groupedFieldSet.size > 1) { + const fieldDetailsLists = [...groupedFieldSet.values()]; + const extraFieldDetailsLists = fieldDetailsLists.slice(1); + const extraFieldSelections = extraFieldDetailsLists.flatMap((fieldDetailsList) => toNodes(fieldDetailsList)); + context.reportError(new GraphQLError(operationName != null + ? `Subscription "${operationName}" must select only one top level field.` + : 'Anonymous Subscription must select only one top level field.', { nodes: extraFieldSelections })); + } + for (const fieldDetailsList of groupedFieldSet.values()) { + const fieldName = toNodes(fieldDetailsList)[0].name.value; + if (fieldName.startsWith('__')) { + context.reportError(new GraphQLError(operationName != null + ? `Subscription "${operationName}" must not select an introspection top level field.` + : 'Anonymous Subscription must not select an introspection top level field.', { nodes: toNodes(fieldDetailsList) })); + } + } + } + } + }, + }; +} +//# sourceMappingURL=SingleFieldSubscriptionsRule.js.map \ No newline at end of file diff --git a/validation/rules/SingleFieldSubscriptionsRule.mjs.map b/validation/rules/SingleFieldSubscriptionsRule.mjs.map new file mode 100644 index 0000000000..13beaee4d0 --- /dev/null +++ b/validation/rules/SingleFieldSubscriptionsRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"SingleFieldSubscriptionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/SingleFieldSubscriptionsRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAO/C,OAAO,EAAE,aAAa,EAAE,0CAAyC;AAKjE,SAAS,OAAO,CAAC,gBAAkC;IACjD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA0B;IAE1B,OAAO;QACL,mBAAmB,CAAC,IAA6B;YAC/C,IAAI,IAAI,CAAC,SAA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,CAAC;wBAC7B,MAAM,iBAAiB,GAAG,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;wBACxD,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBAC1D,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,OAAO,CACzD,CAAC,gBAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAChD,CAAC;wBACF,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,IAAI,IAAI;4BACnB,CAAC,CAAC,iBAAiB,aAAa,yCAAyC;4BACzE,CAAC,CAAC,8DAA8D,EAClE,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAChC,CACF,CAAC;oBACJ,CAAC;oBACD,KAAK,MAAM,gBAAgB,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;wBACxD,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;wBAC1D,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;4BAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,IAAI,IAAI;gCACnB,CAAC,CAAC,iBAAiB,aAAa,qDAAqD;gCACrF,CAAC,CAAC,0EAA0E,EAC9E,EAAE,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,CACrC,CACF,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { ObjMap } from '../../jsutils/ObjMap.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { FieldNode, OperationDefinitionNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type {\n FieldDetailsList,\n FragmentDetails,\n} from '../../execution/collectFields.js';\nimport { collectFields } from '../../execution/collectFields.js';\nimport type { VariableValues } from '../../execution/values.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\nfunction toNodes(fieldDetailsList: FieldDetailsList): ReadonlyArray {\n return fieldDetailsList.map((fieldDetails) => fieldDetails.node);\n}\n\n/**\n * Subscriptions must only include a non-introspection field.\n *\n * A GraphQL subscription is valid only if it contains a single root field and\n * that root field is not an introspection field. `@skip` and `@include`\n * directives are forbidden.\n *\n * See https://spec.graphql.org/draft/#sec-Single-root-field\n */\nexport function SingleFieldSubscriptionsRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(node: OperationDefinitionNode) {\n if (node.operation === 'subscription') {\n const schema = context.getSchema();\n const subscriptionType = schema.getSubscriptionType();\n if (subscriptionType) {\n const operationName = node.name ? node.name.value : null;\n const variableValues: VariableValues = Object.create(null);\n const document = context.getDocument();\n const fragments: ObjMap = Object.create(null);\n for (const definition of document.definitions) {\n if (definition.kind === Kind.FRAGMENT_DEFINITION) {\n fragments[definition.name.value] = { definition };\n }\n }\n const { groupedFieldSet, forbiddenDirectiveInstances } =\n collectFields(\n schema,\n fragments,\n variableValues,\n subscriptionType,\n node.selectionSet,\n context.hideSuggestions,\n true,\n );\n if (forbiddenDirectiveInstances.length > 0) {\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must not use \\`@skip\\` or \\`@include\\` directives in the top level selection.`\n : 'Anonymous Subscription must not use `@skip` or `@include` directives in the top level selection.',\n { nodes: forbiddenDirectiveInstances },\n ),\n );\n return;\n }\n if (groupedFieldSet.size > 1) {\n const fieldDetailsLists = [...groupedFieldSet.values()];\n const extraFieldDetailsLists = fieldDetailsLists.slice(1);\n const extraFieldSelections = extraFieldDetailsLists.flatMap(\n (fieldDetailsList) => toNodes(fieldDetailsList),\n );\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must select only one top level field.`\n : 'Anonymous Subscription must select only one top level field.',\n { nodes: extraFieldSelections },\n ),\n );\n }\n for (const fieldDetailsList of groupedFieldSet.values()) {\n const fieldName = toNodes(fieldDetailsList)[0].name.value;\n if (fieldName.startsWith('__')) {\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must not select an introspection top level field.`\n : 'Anonymous Subscription must not select an introspection top level field.',\n { nodes: toNodes(fieldDetailsList) },\n ),\n );\n }\n }\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/StreamDirectiveOnListFieldRule.d.ts b/validation/rules/StreamDirectiveOnListFieldRule.d.ts new file mode 100644 index 0000000000..9d9cce7156 --- /dev/null +++ b/validation/rules/StreamDirectiveOnListFieldRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Stream directives are used on list fields + * + * A GraphQL document is only valid if stream directives are used on list fields. + */ +export declare function StreamDirectiveOnListFieldRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/StreamDirectiveOnListFieldRule.js b/validation/rules/StreamDirectiveOnListFieldRule.js new file mode 100644 index 0000000000..3aa168d642 --- /dev/null +++ b/validation/rules/StreamDirectiveOnListFieldRule.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StreamDirectiveOnListFieldRule = StreamDirectiveOnListFieldRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const definition_js_1 = require("../../type/definition.js"); +const directives_js_1 = require("../../type/directives.js"); +/** + * Stream directives are used on list fields + * + * A GraphQL document is only valid if stream directives are used on list fields. + */ +function StreamDirectiveOnListFieldRule(context) { + return { + Directive(node) { + const fieldDef = context.getFieldDef(); + const parentType = context.getParentType(); + if (fieldDef && + parentType && + node.name.value === directives_js_1.GraphQLStreamDirective.name && + !((0, definition_js_1.isListType)(fieldDef.type) || + ((0, definition_js_1.isWrappingType)(fieldDef.type) && (0, definition_js_1.isListType)(fieldDef.type.ofType)))) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Directive "@stream" cannot be used on non-list field "${parentType}.${fieldDef.name}".`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=StreamDirectiveOnListFieldRule.js.map \ No newline at end of file diff --git a/validation/rules/StreamDirectiveOnListFieldRule.js.map b/validation/rules/StreamDirectiveOnListFieldRule.js.map new file mode 100644 index 0000000000..0b0ec33825 --- /dev/null +++ b/validation/rules/StreamDirectiveOnListFieldRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StreamDirectiveOnListFieldRule.js","sourceRoot":"","sources":["../../../src/validation/rules/StreamDirectiveOnListFieldRule.ts"],"names":[],"mappings":";;AAeA,wEAyBC;AAxCD,iEAA2D;AAK3D,4DAAsE;AACtE,4DAAkE;AAIlE;;;;GAIG;AACH,SAAgB,8BAA8B,CAC5C,OAA0B;IAE1B,OAAO;QACL,SAAS,CAAC,IAAmB;YAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;YAC3C,IACE,QAAQ;gBACR,UAAU;gBACV,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,sCAAsB,CAAC,IAAI;gBAC/C,CAAC,CACC,IAAA,0BAAU,EAAC,QAAQ,CAAC,IAAI,CAAC;oBACzB,CAAC,IAAA,8BAAc,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAA,0BAAU,EAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CACpE,EACD,CAAC;gBACD,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,yDAAyD,UAAU,IAAI,QAAQ,CAAC,IAAI,IAAI,EACxF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isListType, isWrappingType } from '../../type/definition.js';\nimport { GraphQLStreamDirective } from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Stream directives are used on list fields\n *\n * A GraphQL document is only valid if stream directives are used on list fields.\n */\nexport function StreamDirectiveOnListFieldRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Directive(node: DirectiveNode) {\n const fieldDef = context.getFieldDef();\n const parentType = context.getParentType();\n if (\n fieldDef &&\n parentType &&\n node.name.value === GraphQLStreamDirective.name &&\n !(\n isListType(fieldDef.type) ||\n (isWrappingType(fieldDef.type) && isListType(fieldDef.type.ofType))\n )\n ) {\n context.reportError(\n new GraphQLError(\n `Directive \"@stream\" cannot be used on non-list field \"${parentType}.${fieldDef.name}\".`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/StreamDirectiveOnListFieldRule.mjs b/validation/rules/StreamDirectiveOnListFieldRule.mjs new file mode 100644 index 0000000000..56983a5518 --- /dev/null +++ b/validation/rules/StreamDirectiveOnListFieldRule.mjs @@ -0,0 +1,24 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { isListType, isWrappingType } from "../../type/definition.mjs"; +import { GraphQLStreamDirective } from "../../type/directives.mjs"; +/** + * Stream directives are used on list fields + * + * A GraphQL document is only valid if stream directives are used on list fields. + */ +export function StreamDirectiveOnListFieldRule(context) { + return { + Directive(node) { + const fieldDef = context.getFieldDef(); + const parentType = context.getParentType(); + if (fieldDef && + parentType && + node.name.value === GraphQLStreamDirective.name && + !(isListType(fieldDef.type) || + (isWrappingType(fieldDef.type) && isListType(fieldDef.type.ofType)))) { + context.reportError(new GraphQLError(`Directive "@stream" cannot be used on non-list field "${parentType}.${fieldDef.name}".`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=StreamDirectiveOnListFieldRule.js.map \ No newline at end of file diff --git a/validation/rules/StreamDirectiveOnListFieldRule.mjs.map b/validation/rules/StreamDirectiveOnListFieldRule.mjs.map new file mode 100644 index 0000000000..8c3b517a6f --- /dev/null +++ b/validation/rules/StreamDirectiveOnListFieldRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"StreamDirectiveOnListFieldRule.js","sourceRoot":"","sources":["../../../src/validation/rules/StreamDirectiveOnListFieldRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAK3D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kCAAiC;AACtE,OAAO,EAAE,sBAAsB,EAAE,kCAAiC;AAIlE;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAA0B;IAE1B,OAAO;QACL,SAAS,CAAC,IAAmB;YAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;YAC3C,IACE,QAAQ;gBACR,UAAU;gBACV,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,sBAAsB,CAAC,IAAI;gBAC/C,CAAC,CACC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACzB,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CACpE,EACD,CAAC;gBACD,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yDAAyD,UAAU,IAAI,QAAQ,CAAC,IAAI,IAAI,EACxF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isListType, isWrappingType } from '../../type/definition.js';\nimport { GraphQLStreamDirective } from '../../type/directives.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Stream directives are used on list fields\n *\n * A GraphQL document is only valid if stream directives are used on list fields.\n */\nexport function StreamDirectiveOnListFieldRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Directive(node: DirectiveNode) {\n const fieldDef = context.getFieldDef();\n const parentType = context.getParentType();\n if (\n fieldDef &&\n parentType &&\n node.name.value === GraphQLStreamDirective.name &&\n !(\n isListType(fieldDef.type) ||\n (isWrappingType(fieldDef.type) && isListType(fieldDef.type.ofType))\n )\n ) {\n context.reportError(\n new GraphQLError(\n `Directive \"@stream\" cannot be used on non-list field \"${parentType}.${fieldDef.name}\".`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts b/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts new file mode 100644 index 0000000000..1277ff6045 --- /dev/null +++ b/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts @@ -0,0 +1,9 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Unique argument definition names + * + * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. + * A GraphQL Directive is only valid if all its arguments are uniquely named. + */ +export declare function UniqueArgumentDefinitionNamesRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueArgumentDefinitionNamesRule.js b/validation/rules/UniqueArgumentDefinitionNamesRule.js new file mode 100644 index 0000000000..0b424f0d3c --- /dev/null +++ b/validation/rules/UniqueArgumentDefinitionNamesRule.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueArgumentDefinitionNamesRule = UniqueArgumentDefinitionNamesRule; +const groupBy_js_1 = require("../../jsutils/groupBy.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique argument definition names + * + * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. + * A GraphQL Directive is only valid if all its arguments are uniquely named. + */ +function UniqueArgumentDefinitionNamesRule(context) { + return { + DirectiveDefinition(directiveNode) { + const argumentNodes = directiveNode.arguments ?? []; + return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); + }, + InterfaceTypeDefinition: checkArgUniquenessPerField, + InterfaceTypeExtension: checkArgUniquenessPerField, + ObjectTypeDefinition: checkArgUniquenessPerField, + ObjectTypeExtension: checkArgUniquenessPerField, + }; + function checkArgUniquenessPerField(typeNode) { + const typeName = typeNode.name.value; + const fieldNodes = typeNode.fields ?? []; + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + const argumentNodes = fieldDef.arguments ?? []; + checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); + } + return false; + } + function checkArgUniqueness(parentName, argumentNodes) { + const seenArgs = (0, groupBy_js_1.groupBy)(argumentNodes, (arg) => arg.name.value); + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Argument "${parentName}(${argName}:)" can only be defined once.`, { nodes: argNodes.map((node) => node.name) })); + } + } + return false; + } +} +//# sourceMappingURL=UniqueArgumentDefinitionNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueArgumentDefinitionNamesRule.js.map b/validation/rules/UniqueArgumentDefinitionNamesRule.js.map new file mode 100644 index 0000000000..d2f0976ea1 --- /dev/null +++ b/validation/rules/UniqueArgumentDefinitionNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueArgumentDefinitionNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueArgumentDefinitionNamesRule.ts"],"names":[],"mappings":";;AAmBA,8EAqDC;AAxED,yDAAmD;AAEnD,iEAA2D;AAW3D;;;;;GAKG;AACH,SAAgB,iCAAiC,CAC/C,OAA6B;IAE7B,OAAO;QACL,mBAAmB,CAAC,aAAa;YAC/B,MAAM,aAAa,GAAG,aAAa,CAAC,SAAS,IAA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ACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { groupBy } from '../../jsutils/groupBy.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n FieldDefinitionNode,\n InputValueDefinitionNode,\n NameNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique argument definition names\n *\n * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments.\n * A GraphQL Directive is only valid if all its arguments are uniquely named.\n */\nexport function UniqueArgumentDefinitionNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n return {\n DirectiveDefinition(directiveNode) {\n const argumentNodes = directiveNode.arguments ?? [];\n\n return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes);\n },\n InterfaceTypeDefinition: checkArgUniquenessPerField,\n InterfaceTypeExtension: checkArgUniquenessPerField,\n ObjectTypeDefinition: checkArgUniquenessPerField,\n ObjectTypeExtension: checkArgUniquenessPerField,\n };\n\n function checkArgUniquenessPerField(typeNode: {\n readonly name: NameNode;\n readonly fields?: ReadonlyArray | undefined;\n }) {\n const typeName = typeNode.name.value;\n\n const fieldNodes = typeNode.fields ?? [];\n\n for (const fieldDef of fieldNodes) {\n const fieldName = fieldDef.name.value;\n\n const argumentNodes = fieldDef.arguments ?? [];\n\n checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes);\n }\n\n return false;\n }\n\n function checkArgUniqueness(\n parentName: string,\n argumentNodes: ReadonlyArray,\n ) {\n const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value);\n\n for (const [argName, argNodes] of seenArgs) {\n if (argNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `Argument \"${parentName}(${argName}:)\" can only be defined once.`,\n { nodes: argNodes.map((node) => node.name) },\n ),\n );\n }\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueArgumentDefinitionNamesRule.mjs b/validation/rules/UniqueArgumentDefinitionNamesRule.mjs new file mode 100644 index 0000000000..d1b8298560 --- /dev/null +++ b/validation/rules/UniqueArgumentDefinitionNamesRule.mjs @@ -0,0 +1,40 @@ +import { groupBy } from "../../jsutils/groupBy.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique argument definition names + * + * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. + * A GraphQL Directive is only valid if all its arguments are uniquely named. + */ +export function UniqueArgumentDefinitionNamesRule(context) { + return { + DirectiveDefinition(directiveNode) { + const argumentNodes = directiveNode.arguments ?? []; + return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); + }, + InterfaceTypeDefinition: checkArgUniquenessPerField, + InterfaceTypeExtension: checkArgUniquenessPerField, + ObjectTypeDefinition: checkArgUniquenessPerField, + ObjectTypeExtension: checkArgUniquenessPerField, + }; + function checkArgUniquenessPerField(typeNode) { + const typeName = typeNode.name.value; + const fieldNodes = typeNode.fields ?? []; + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + const argumentNodes = fieldDef.arguments ?? []; + checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); + } + return false; + } + function checkArgUniqueness(parentName, argumentNodes) { + const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value); + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError(new GraphQLError(`Argument "${parentName}(${argName}:)" can only be defined once.`, { nodes: argNodes.map((node) => node.name) })); + } + } + return false; + } +} +//# sourceMappingURL=UniqueArgumentDefinitionNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueArgumentDefinitionNamesRule.mjs.map b/validation/rules/UniqueArgumentDefinitionNamesRule.mjs.map new file mode 100644 index 0000000000..a7e9ff4a80 --- /dev/null +++ b/validation/rules/UniqueArgumentDefinitionNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueArgumentDefinitionNamesRule.js","sourceRoot":"","sources":["../../../src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AQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,UAAU,IAAI,OAAO,+BAA+B,EACjE,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7C,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { groupBy } from '../../jsutils/groupBy.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n FieldDefinitionNode,\n InputValueDefinitionNode,\n NameNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique argument definition names\n *\n * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments.\n * A GraphQL Directive is only valid if all its arguments are uniquely named.\n */\nexport function UniqueArgumentDefinitionNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n return {\n DirectiveDefinition(directiveNode) {\n const argumentNodes = directiveNode.arguments ?? [];\n\n return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes);\n },\n InterfaceTypeDefinition: checkArgUniquenessPerField,\n InterfaceTypeExtension: checkArgUniquenessPerField,\n ObjectTypeDefinition: checkArgUniquenessPerField,\n ObjectTypeExtension: checkArgUniquenessPerField,\n };\n\n function checkArgUniquenessPerField(typeNode: {\n readonly name: NameNode;\n readonly fields?: ReadonlyArray | undefined;\n }) {\n const typeName = typeNode.name.value;\n\n const fieldNodes = typeNode.fields ?? [];\n\n for (const fieldDef of fieldNodes) {\n const fieldName = fieldDef.name.value;\n\n const argumentNodes = fieldDef.arguments ?? [];\n\n checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes);\n }\n\n return false;\n }\n\n function checkArgUniqueness(\n parentName: string,\n argumentNodes: ReadonlyArray,\n ) {\n const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value);\n\n for (const [argName, argNodes] of seenArgs) {\n if (argNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `Argument \"${parentName}(${argName}:)\" can only be defined once.`,\n { nodes: argNodes.map((node) => node.name) },\n ),\n );\n }\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueArgumentNamesRule.d.ts b/validation/rules/UniqueArgumentNamesRule.d.ts new file mode 100644 index 0000000000..d116c0b9b5 --- /dev/null +++ b/validation/rules/UniqueArgumentNamesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + */ +export declare function UniqueArgumentNamesRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueArgumentNamesRule.js b/validation/rules/UniqueArgumentNamesRule.js new file mode 100644 index 0000000000..9d7637a8e0 --- /dev/null +++ b/validation/rules/UniqueArgumentNamesRule.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueArgumentNamesRule = UniqueArgumentNamesRule; +const groupBy_js_1 = require("../../jsutils/groupBy.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + */ +function UniqueArgumentNamesRule(context) { + return { + Field: checkArgUniqueness, + Directive: checkArgUniqueness, + }; + function checkArgUniqueness(parentNode) { + const argumentNodes = parentNode.arguments ?? []; + const seenArgs = (0, groupBy_js_1.groupBy)(argumentNodes, (arg) => arg.name.value); + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one argument named "${argName}".`, { nodes: argNodes.map((node) => node.name) })); + } + } + } +} +//# sourceMappingURL=UniqueArgumentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueArgumentNamesRule.js.map b/validation/rules/UniqueArgumentNamesRule.js.map new file mode 100644 index 0000000000..cbbff46451 --- /dev/null +++ b/validation/rules/UniqueArgumentNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueArgumentNamesRule.ts"],"names":[],"mappings":";;AAiBA,0DA0BC;AA3CD,yDAAmD;AAEnD,iEAA2D;AAO3D;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,KAAK,EAAE,kBAAkB;QACzB,SAAS,EAAE,kBAAkB;KAC9B,CAAC;IAEF,SAAS,kBAAkB,CAAC,UAE3B;QACC,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,IAAI,EAAE,CAAC;QAEjD,MAAM,QAAQ,GAAG,IAAA,oBAAO,EAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEjE,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC;YAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,yCAAyC,OAAO,IAAI,EACpD,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7C,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { groupBy } from '../../jsutils/groupBy.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ArgumentNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique argument names\n *\n * A GraphQL field or directive is only valid if all supplied arguments are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Argument-Names\n */\nexport function UniqueArgumentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n Field: checkArgUniqueness,\n Directive: checkArgUniqueness,\n };\n\n function checkArgUniqueness(parentNode: {\n arguments?: ReadonlyArray | undefined;\n }) {\n const argumentNodes = parentNode.arguments ?? [];\n\n const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value);\n\n for (const [argName, argNodes] of seenArgs) {\n if (argNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one argument named \"${argName}\".`,\n { nodes: argNodes.map((node) => node.name) },\n ),\n );\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueArgumentNamesRule.mjs b/validation/rules/UniqueArgumentNamesRule.mjs new file mode 100644 index 0000000000..ba7df5e7a2 --- /dev/null +++ b/validation/rules/UniqueArgumentNamesRule.mjs @@ -0,0 +1,26 @@ +import { groupBy } from "../../jsutils/groupBy.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + */ +export function UniqueArgumentNamesRule(context) { + return { + Field: checkArgUniqueness, + Directive: checkArgUniqueness, + }; + function checkArgUniqueness(parentNode) { + const argumentNodes = parentNode.arguments ?? []; + const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value); + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError(new GraphQLError(`There can be only one argument named "${argName}".`, { nodes: argNodes.map((node) => node.name) })); + } + } + } +} +//# sourceMappingURL=UniqueArgumentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueArgumentNamesRule.mjs.map b/validation/rules/UniqueArgumentNamesRule.mjs.map new file mode 100644 index 0000000000..766a9c0f75 --- /dev/null +++ b/validation/rules/UniqueArgumentNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueArgumentNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAEnD,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAO3D;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,KAAK,EAAE,kBAAkB;QACzB,SAAS,EAAE,kBAAkB;KAC9B,CAAC;IAEF,SAAS,kBAAkB,CAAC,UAE3B;QACC,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,IAAI,EAAE,CAAC;QAEjD,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEjE,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC;YAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yCAAyC,OAAO,IAAI,EACpD,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7C,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { groupBy } from '../../jsutils/groupBy.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ArgumentNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique argument names\n *\n * A GraphQL field or directive is only valid if all supplied arguments are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Argument-Names\n */\nexport function UniqueArgumentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n Field: checkArgUniqueness,\n Directive: checkArgUniqueness,\n };\n\n function checkArgUniqueness(parentNode: {\n arguments?: ReadonlyArray | undefined;\n }) {\n const argumentNodes = parentNode.arguments ?? [];\n\n const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value);\n\n for (const [argName, argNodes] of seenArgs) {\n if (argNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one argument named \"${argName}\".`,\n { nodes: argNodes.map((node) => node.name) },\n ),\n );\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueDirectiveNamesRule.d.ts b/validation/rules/UniqueDirectiveNamesRule.d.ts new file mode 100644 index 0000000000..67ba8f4804 --- /dev/null +++ b/validation/rules/UniqueDirectiveNamesRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +export declare function UniqueDirectiveNamesRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueDirectiveNamesRule.js b/validation/rules/UniqueDirectiveNamesRule.js new file mode 100644 index 0000000000..2a4f5e47da --- /dev/null +++ b/validation/rules/UniqueDirectiveNamesRule.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueDirectiveNamesRule = UniqueDirectiveNamesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +function UniqueDirectiveNamesRule(context) { + const knownDirectiveNames = new Map(); + const schema = context.getSchema(); + return { + DirectiveDefinition(node) { + const directiveName = node.name.value; + if (schema?.getDirective(directiveName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, { nodes: node.name })); + return; + } + const knownName = knownDirectiveNames.get(directiveName); + if (knownName) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one directive named "@${directiveName}".`, { nodes: [knownName, node.name] })); + } + else { + knownDirectiveNames.set(directiveName, node.name); + } + return false; + }, + }; +} +//# sourceMappingURL=UniqueDirectiveNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueDirectiveNamesRule.js.map b/validation/rules/UniqueDirectiveNamesRule.js.map new file mode 100644 index 0000000000..55bc4ea872 --- /dev/null +++ b/validation/rules/UniqueDirectiveNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueDirectiveNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectiveNamesRule.ts"],"names":[],"mappings":";;AAYA,4DAmCC;AA/CD,iEAA2D;AAO3D;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEnC,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAEtC,IAAI,MAAM,EAAE,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,eAAe,aAAa,yDAAyD,EACrF,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CACrB,CACF,CAAC;gBACF,OAAO;YACT,CAAC;YAED,MAAM,SAAS,GAAG,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACzD,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,2CAA2C,aAAa,IAAI,EAC5D,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAClC,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,mBAAmB,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACpD,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique directive names\n *\n * A GraphQL document is only valid if all defined directives have unique names.\n */\nexport function UniqueDirectiveNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const knownDirectiveNames = new Map();\n const schema = context.getSchema();\n\n return {\n DirectiveDefinition(node) {\n const directiveName = node.name.value;\n\n if (schema?.getDirective(directiveName)) {\n context.reportError(\n new GraphQLError(\n `Directive \"@${directiveName}\" already exists in the schema. It cannot be redefined.`,\n { nodes: node.name },\n ),\n );\n return;\n }\n\n const knownName = knownDirectiveNames.get(directiveName);\n if (knownName) {\n context.reportError(\n new GraphQLError(\n `There can be only one directive named \"@${directiveName}\".`,\n { nodes: [knownName, node.name] },\n ),\n );\n } else {\n knownDirectiveNames.set(directiveName, node.name);\n }\n\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueDirectiveNamesRule.mjs b/validation/rules/UniqueDirectiveNamesRule.mjs new file mode 100644 index 0000000000..f2d932d04e --- /dev/null +++ b/validation/rules/UniqueDirectiveNamesRule.mjs @@ -0,0 +1,28 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +export function UniqueDirectiveNamesRule(context) { + const knownDirectiveNames = new Map(); + const schema = context.getSchema(); + return { + DirectiveDefinition(node) { + const directiveName = node.name.value; + if (schema?.getDirective(directiveName)) { + context.reportError(new GraphQLError(`Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, { nodes: node.name })); + return; + } + const knownName = knownDirectiveNames.get(directiveName); + if (knownName) { + context.reportError(new GraphQLError(`There can be only one directive named "@${directiveName}".`, { nodes: [knownName, node.name] })); + } + else { + knownDirectiveNames.set(directiveName, node.name); + } + return false; + }, + }; +} +//# sourceMappingURL=UniqueDirectiveNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueDirectiveNamesRule.mjs.map b/validation/rules/UniqueDirectiveNamesRule.mjs.map new file mode 100644 index 0000000000..86f64fb6ac --- /dev/null +++ b/validation/rules/UniqueDirectiveNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueDirectiveNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectiveNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAO3D;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEnC,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAEtC,IAAI,MAAM,EAAE,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,eAAe,aAAa,yDAAyD,EACrF,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CACrB,CACF,CAAC;gBACF,OAAO;YACT,CAAC;YAED,MAAM,SAAS,GAAG,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACzD,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,2CAA2C,aAAa,IAAI,EAC5D,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAClC,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,mBAAmB,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACpD,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique directive names\n *\n * A GraphQL document is only valid if all defined directives have unique names.\n */\nexport function UniqueDirectiveNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const knownDirectiveNames = new Map();\n const schema = context.getSchema();\n\n return {\n DirectiveDefinition(node) {\n const directiveName = node.name.value;\n\n if (schema?.getDirective(directiveName)) {\n context.reportError(\n new GraphQLError(\n `Directive \"@${directiveName}\" already exists in the schema. It cannot be redefined.`,\n { nodes: node.name },\n ),\n );\n return;\n }\n\n const knownName = knownDirectiveNames.get(directiveName);\n if (knownName) {\n context.reportError(\n new GraphQLError(\n `There can be only one directive named \"@${directiveName}\".`,\n { nodes: [knownName, node.name] },\n ),\n );\n } else {\n knownDirectiveNames.set(directiveName, node.name);\n }\n\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueDirectivesPerLocationRule.d.ts b/validation/rules/UniqueDirectivesPerLocationRule.d.ts new file mode 100644 index 0000000000..d1ed4dde3c --- /dev/null +++ b/validation/rules/UniqueDirectivesPerLocationRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext, ValidationContext } from '../ValidationContext.js'; +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all non-repeatable directives at + * a given location are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + */ +export declare function UniqueDirectivesPerLocationRule(context: ValidationContext | SDLValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueDirectivesPerLocationRule.js b/validation/rules/UniqueDirectivesPerLocationRule.js new file mode 100644 index 0000000000..a60960ff22 --- /dev/null +++ b/validation/rules/UniqueDirectivesPerLocationRule.js @@ -0,0 +1,72 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueDirectivesPerLocationRule = UniqueDirectivesPerLocationRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const predicates_js_1 = require("../../language/predicates.js"); +const directives_js_1 = require("../../type/directives.js"); +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all non-repeatable directives at + * a given location are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + */ +function UniqueDirectivesPerLocationRule(context) { + const uniqueDirectiveMap = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : directives_js_1.specifiedDirectives; + for (const directive of definedDirectives) { + uniqueDirectiveMap.set(directive.name, !directive.isRepeatable); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === kinds_js_1.Kind.DIRECTIVE_DEFINITION) { + uniqueDirectiveMap.set(def.name.value, !def.repeatable); + } + } + const schemaDirectives = new Map(); + const typeDirectivesMap = new Map(); + return { + // Many different AST nodes may contain directives. Rather than listing + // them all, just listen for entering any node, and check to see if it + // defines any directives. + enter(node) { + if (!('directives' in node) || !node.directives) { + return; + } + let seenDirectives; + if (node.kind === kinds_js_1.Kind.SCHEMA_DEFINITION || + node.kind === kinds_js_1.Kind.SCHEMA_EXTENSION) { + seenDirectives = schemaDirectives; + } + else if ((0, predicates_js_1.isTypeDefinitionNode)(node) || (0, predicates_js_1.isTypeExtensionNode)(node)) { + const typeName = node.name.value; + seenDirectives = typeDirectivesMap.get(typeName); + if (seenDirectives === undefined) { + seenDirectives = new Map(); + typeDirectivesMap.set(typeName, seenDirectives); + } + } + else { + seenDirectives = new Map(); + } + for (const directive of node.directives) { + const directiveName = directive.name.value; + if (uniqueDirectiveMap.get(directiveName) === true) { + const seenDirective = seenDirectives.get(directiveName); + if (seenDirective != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`The directive "@${directiveName}" can only be used once at this location.`, { nodes: [seenDirective, directive] })); + } + else { + seenDirectives.set(directiveName, directive); + } + } + } + }, + }; +} +//# sourceMappingURL=UniqueDirectivesPerLocationRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueDirectivesPerLocationRule.js.map b/validation/rules/UniqueDirectivesPerLocationRule.js.map new file mode 100644 index 0000000000..398d15c169 --- /dev/null +++ b/validation/rules/UniqueDirectivesPerLocationRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueDirectivesPerLocationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectivesPerLocationRule.ts"],"names":[],"mappings":";;AAyBA,0EAoEC;AA7FD,iEAA2D;AAG3D,sDAA+C;AAC/C,gEAGsC;AAGtC,4DAA+D;AAO/D;;;;;;;GAOG;AACH,SAAgB,+BAA+B,CAC7C,OAAiD;IAEjD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEtD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,iBAAiB,GAAG,MAAM;QAC9B,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE;QACxB,CAAC,CAAC,mCAAmB,CAAC;IACxB,KAAK,MAAM,SAAS,IAAI,iBAAiB,EAAE,CAAC;QAC1C,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC;IACzD,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;QACjC,IAAI,GAAG,CAAC,IAAI,KAAK,eAAI,CAAC,oBAAoB,EAAE,CAAC;YAC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,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC;oBACnD,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;oBACxD,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;wBAC1B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,mBAAmB,aAAa,2CAA2C,EAC3E,EAAE,KAAK,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,CACtC,CACF,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;oBAC/C,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport {\n isTypeDefinitionNode,\n isTypeExtensionNode,\n} from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Unique directive names per location\n *\n * A GraphQL document is only valid if all non-repeatable directives at\n * a given location are uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location\n */\nexport function UniqueDirectivesPerLocationRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const uniqueDirectiveMap = new Map();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n uniqueDirectiveMap.set(directive.name, !directive.isRepeatable);\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n uniqueDirectiveMap.set(def.name.value, !def.repeatable);\n }\n }\n\n const schemaDirectives = new Map();\n const typeDirectivesMap = new Map>();\n\n return {\n // Many different AST nodes may contain directives. Rather than listing\n // them all, just listen for entering any node, and check to see if it\n // defines any directives.\n enter(node) {\n if (!('directives' in node) || !node.directives) {\n return;\n }\n\n let seenDirectives;\n if (\n node.kind === Kind.SCHEMA_DEFINITION ||\n node.kind === Kind.SCHEMA_EXTENSION\n ) {\n seenDirectives = schemaDirectives;\n } else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {\n const typeName = node.name.value;\n seenDirectives = typeDirectivesMap.get(typeName);\n if (seenDirectives === undefined) {\n seenDirectives = new Map();\n typeDirectivesMap.set(typeName, seenDirectives);\n }\n } else {\n seenDirectives = new Map();\n }\n\n for (const directive of node.directives) {\n const directiveName = directive.name.value;\n\n if (uniqueDirectiveMap.get(directiveName) === true) {\n const seenDirective = seenDirectives.get(directiveName);\n if (seenDirective != null) {\n context.reportError(\n new GraphQLError(\n `The directive \"@${directiveName}\" can only be used once at this location.`,\n { nodes: [seenDirective, directive] },\n ),\n );\n } else {\n seenDirectives.set(directiveName, directive);\n }\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueDirectivesPerLocationRule.mjs b/validation/rules/UniqueDirectivesPerLocationRule.mjs new file mode 100644 index 0000000000..d63792f599 --- /dev/null +++ b/validation/rules/UniqueDirectivesPerLocationRule.mjs @@ -0,0 +1,69 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { isTypeDefinitionNode, isTypeExtensionNode, } from "../../language/predicates.mjs"; +import { specifiedDirectives } from "../../type/directives.mjs"; +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all non-repeatable directives at + * a given location are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + */ +export function UniqueDirectivesPerLocationRule(context) { + const uniqueDirectiveMap = new Map(); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : specifiedDirectives; + for (const directive of definedDirectives) { + uniqueDirectiveMap.set(directive.name, !directive.isRepeatable); + } + const astDefinitions = context.getDocument().definitions; + for (const def of astDefinitions) { + if (def.kind === Kind.DIRECTIVE_DEFINITION) { + uniqueDirectiveMap.set(def.name.value, !def.repeatable); + } + } + const schemaDirectives = new Map(); + const typeDirectivesMap = new Map(); + return { + // Many different AST nodes may contain directives. Rather than listing + // them all, just listen for entering any node, and check to see if it + // defines any directives. + enter(node) { + if (!('directives' in node) || !node.directives) { + return; + } + let seenDirectives; + if (node.kind === Kind.SCHEMA_DEFINITION || + node.kind === Kind.SCHEMA_EXTENSION) { + seenDirectives = schemaDirectives; + } + else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) { + const typeName = node.name.value; + seenDirectives = typeDirectivesMap.get(typeName); + if (seenDirectives === undefined) { + seenDirectives = new Map(); + typeDirectivesMap.set(typeName, seenDirectives); + } + } + else { + seenDirectives = new Map(); + } + for (const directive of node.directives) { + const directiveName = directive.name.value; + if (uniqueDirectiveMap.get(directiveName) === true) { + const seenDirective = seenDirectives.get(directiveName); + if (seenDirective != null) { + context.reportError(new GraphQLError(`The directive "@${directiveName}" can only be used once at this location.`, { nodes: [seenDirective, directive] })); + } + else { + seenDirectives.set(directiveName, directive); + } + } + } + }, + }; +} +//# sourceMappingURL=UniqueDirectivesPerLocationRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueDirectivesPerLocationRule.mjs.map b/validation/rules/UniqueDirectivesPerLocationRule.mjs.map new file mode 100644 index 0000000000..a79ff2d6aa --- /dev/null +++ b/validation/rules/UniqueDirectivesPerLocationRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueDirectivesPerLocationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectivesPerLocationRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAC/C,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,sCAAqC;AAGtC,OAAO,EAA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B,CAAC;YACpC,CAAC;iBAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;gBACjC,cAAc,GAAG,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACjD,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;oBACjC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;oBAC3B,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;YAC7B,CAAC;YAED,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACxC,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;gBAE3C,IAAI,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC;oBACnD,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;oBACxD,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;wBAC1B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,mBAAmB,aAAa,2CAA2C,EAC3E,EAAE,KAAK,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,CACtC,CACF,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;oBAC/C,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { DirectiveNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport {\n isTypeDefinitionNode,\n isTypeExtensionNode,\n} from '../../language/predicates.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { specifiedDirectives } from '../../type/directives.js';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.js';\n\n/**\n * Unique directive names per location\n *\n * A GraphQL document is only valid if all non-repeatable directives at\n * a given location are uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location\n */\nexport function UniqueDirectivesPerLocationRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const uniqueDirectiveMap = new Map();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n uniqueDirectiveMap.set(directive.name, !directive.isRepeatable);\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n uniqueDirectiveMap.set(def.name.value, !def.repeatable);\n }\n }\n\n const schemaDirectives = new Map();\n const typeDirectivesMap = new Map>();\n\n return {\n // Many different AST nodes may contain directives. Rather than listing\n // them all, just listen for entering any node, and check to see if it\n // defines any directives.\n enter(node) {\n if (!('directives' in node) || !node.directives) {\n return;\n }\n\n let seenDirectives;\n if (\n node.kind === Kind.SCHEMA_DEFINITION ||\n node.kind === Kind.SCHEMA_EXTENSION\n ) {\n seenDirectives = schemaDirectives;\n } else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {\n const typeName = node.name.value;\n seenDirectives = typeDirectivesMap.get(typeName);\n if (seenDirectives === undefined) {\n seenDirectives = new Map();\n typeDirectivesMap.set(typeName, seenDirectives);\n }\n } else {\n seenDirectives = new Map();\n }\n\n for (const directive of node.directives) {\n const directiveName = directive.name.value;\n\n if (uniqueDirectiveMap.get(directiveName) === true) {\n const seenDirective = seenDirectives.get(directiveName);\n if (seenDirective != null) {\n context.reportError(\n new GraphQLError(\n `The directive \"@${directiveName}\" can only be used once at this location.`,\n { nodes: [seenDirective, directive] },\n ),\n );\n } else {\n seenDirectives.set(directiveName, directive);\n }\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueEnumValueNamesRule.d.ts b/validation/rules/UniqueEnumValueNamesRule.d.ts new file mode 100644 index 0000000000..20bbfb4329 --- /dev/null +++ b/validation/rules/UniqueEnumValueNamesRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. + */ +export declare function UniqueEnumValueNamesRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueEnumValueNamesRule.js b/validation/rules/UniqueEnumValueNamesRule.js new file mode 100644 index 0000000000..40304a52c0 --- /dev/null +++ b/validation/rules/UniqueEnumValueNamesRule.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueEnumValueNamesRule = UniqueEnumValueNamesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const definition_js_1 = require("../../type/definition.js"); +/** + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. + */ +function UniqueEnumValueNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownValueNames = new Map(); + return { + EnumTypeDefinition: checkValueUniqueness, + EnumTypeExtension: checkValueUniqueness, + }; + function checkValueUniqueness(node) { + const typeName = node.name.value; + let valueNames = knownValueNames.get(typeName); + if (valueNames == null) { + valueNames = new Map(); + knownValueNames.set(typeName, valueNames); + } + const valueNodes = node.values ?? []; + for (const valueDef of valueNodes) { + const valueName = valueDef.name.value; + const existingType = existingTypeMap[typeName]; + if ((0, definition_js_1.isEnumType)(existingType) && existingType.getValue(valueName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, { nodes: valueDef.name })); + continue; + } + const knownValueName = valueNames.get(valueName); + if (knownValueName != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Enum value "${typeName}.${valueName}" can only be defined once.`, { nodes: [knownValueName, valueDef.name] })); + } + else { + valueNames.set(valueName, valueDef.name); + } + } + return false; + } +} +//# sourceMappingURL=UniqueEnumValueNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueEnumValueNamesRule.js.map b/validation/rules/UniqueEnumValueNamesRule.js.map new file mode 100644 index 0000000000..5e0ba4ac59 --- /dev/null +++ b/validation/rules/UniqueEnumValueNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueEnumValueNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueEnumValueNamesRule.ts"],"names":[],"mappings":";;AAkBA,4DAsDC;AAxED,iEAA2D;AAS3D,4DAAsD;AAItD;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiC,CAAC;IAEjE,OAAO;QACL,kBAAkB,EAAE,oBAAoB;QACxC,iBAAiB,EAAE,oBAAoB;KACxC,CAAC;IAEF,SAAS,oBAAoB,CAC3B,IAAoD;QAEpD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAEjC,IAAI,UAAU,GAAG,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;YACvB,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAErC,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;YAClC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;YAEtC,MAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,IAAA,0BAAU,EAAC,YAAY,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBACjE,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,eAAe,QAAQ,IAAI,SAAS,mFAAmF,EACvH,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,CACzB,CACF,CAAC;gBACF,SAAS;YACX,CAAC;YAED,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACjD,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;gBAC3B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,eAAe,QAAQ,IAAI,SAAS,6BAA6B,EACjE,EAAE,KAAK,EAAE,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAC3C,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n NameNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isEnumType } from '../../type/definition.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique enum value names\n *\n * A GraphQL enum type is only valid if all its values are uniquely named.\n */\nexport function UniqueEnumValueNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownValueNames = new Map>();\n\n return {\n EnumTypeDefinition: checkValueUniqueness,\n EnumTypeExtension: checkValueUniqueness,\n };\n\n function checkValueUniqueness(\n node: EnumTypeDefinitionNode | EnumTypeExtensionNode,\n ) {\n const typeName = node.name.value;\n\n let valueNames = knownValueNames.get(typeName);\n if (valueNames == null) {\n valueNames = new Map();\n knownValueNames.set(typeName, valueNames);\n }\n\n const valueNodes = node.values ?? [];\n\n for (const valueDef of valueNodes) {\n const valueName = valueDef.name.value;\n\n const existingType = existingTypeMap[typeName];\n if (isEnumType(existingType) && existingType.getValue(valueName)) {\n context.reportError(\n new GraphQLError(\n `Enum value \"${typeName}.${valueName}\" already exists in the schema. It cannot also be defined in this type extension.`,\n { nodes: valueDef.name },\n ),\n );\n continue;\n }\n\n const knownValueName = valueNames.get(valueName);\n if (knownValueName != null) {\n context.reportError(\n new GraphQLError(\n `Enum value \"${typeName}.${valueName}\" can only be defined once.`,\n { nodes: [knownValueName, valueDef.name] },\n ),\n );\n } else {\n valueNames.set(valueName, valueDef.name);\n }\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueEnumValueNamesRule.mjs b/validation/rules/UniqueEnumValueNamesRule.mjs new file mode 100644 index 0000000000..13365e82d7 --- /dev/null +++ b/validation/rules/UniqueEnumValueNamesRule.mjs @@ -0,0 +1,42 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { isEnumType } from "../../type/definition.mjs"; +/** + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. + */ +export function UniqueEnumValueNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownValueNames = new Map(); + return { + EnumTypeDefinition: checkValueUniqueness, + EnumTypeExtension: checkValueUniqueness, + }; + function checkValueUniqueness(node) { + const typeName = node.name.value; + let valueNames = knownValueNames.get(typeName); + if (valueNames == null) { + valueNames = new Map(); + knownValueNames.set(typeName, valueNames); + } + const valueNodes = node.values ?? []; + for (const valueDef of valueNodes) { + const valueName = valueDef.name.value; + const existingType = existingTypeMap[typeName]; + if (isEnumType(existingType) && existingType.getValue(valueName)) { + context.reportError(new GraphQLError(`Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, { nodes: valueDef.name })); + continue; + } + const knownValueName = valueNames.get(valueName); + if (knownValueName != null) { + context.reportError(new GraphQLError(`Enum value "${typeName}.${valueName}" can only be defined once.`, { nodes: [knownValueName, valueDef.name] })); + } + else { + valueNames.set(valueName, valueDef.name); + } + } + return false; + } +} +//# sourceMappingURL=UniqueEnumValueNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueEnumValueNamesRule.mjs.map b/validation/rules/UniqueEnumValueNamesRule.mjs.map new file mode 100644 index 0000000000..ac159480f7 --- /dev/null +++ b/validation/rules/UniqueEnumValueNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueEnumValueNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueEnumValueNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAS3D,OAAO,EAAE,UAAU,EAAE,kCAAiC;AAItD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiC,CAAC;IAEjE,OAAO;QACL,kBAAkB,EAAE,oBAAoB;QACxC,iBAAiB,EAAE,oBAAoB;KACxC,CAAC;IAEF,SAAS,oBAAoB,CAC3B,IAAoD;QAEpD,MAAM,QAAQ,GAA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/GraphQLError.js';\n\nimport type {\n EnumTypeDefinitionNode,\n EnumTypeExtensionNode,\n NameNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isEnumType } from '../../type/definition.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique enum value names\n *\n * A GraphQL enum type is only valid if all its values are uniquely named.\n */\nexport function UniqueEnumValueNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownValueNames = new Map>();\n\n return {\n EnumTypeDefinition: checkValueUniqueness,\n EnumTypeExtension: checkValueUniqueness,\n };\n\n function checkValueUniqueness(\n node: EnumTypeDefinitionNode | EnumTypeExtensionNode,\n ) {\n const typeName = node.name.value;\n\n let valueNames = knownValueNames.get(typeName);\n if (valueNames == null) {\n valueNames = new Map();\n knownValueNames.set(typeName, valueNames);\n }\n\n const valueNodes = node.values ?? [];\n\n for (const valueDef of valueNodes) {\n const valueName = valueDef.name.value;\n\n const existingType = existingTypeMap[typeName];\n if (isEnumType(existingType) && existingType.getValue(valueName)) {\n context.reportError(\n new GraphQLError(\n `Enum value \"${typeName}.${valueName}\" already exists in the schema. It cannot also be defined in this type extension.`,\n { nodes: valueDef.name },\n ),\n );\n continue;\n }\n\n const knownValueName = valueNames.get(valueName);\n if (knownValueName != null) {\n context.reportError(\n new GraphQLError(\n `Enum value \"${typeName}.${valueName}\" can only be defined once.`,\n { nodes: [knownValueName, valueDef.name] },\n ),\n );\n } else {\n valueNames.set(valueName, valueDef.name);\n }\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueFieldDefinitionNamesRule.d.ts b/validation/rules/UniqueFieldDefinitionNamesRule.d.ts new file mode 100644 index 0000000000..075ad178be --- /dev/null +++ b/validation/rules/UniqueFieldDefinitionNamesRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Unique field definition names + * + * A GraphQL complex type is only valid if all its fields are uniquely named. + */ +export declare function UniqueFieldDefinitionNamesRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueFieldDefinitionNamesRule.js b/validation/rules/UniqueFieldDefinitionNamesRule.js new file mode 100644 index 0000000000..53fed8a4e3 --- /dev/null +++ b/validation/rules/UniqueFieldDefinitionNamesRule.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueFieldDefinitionNamesRule = UniqueFieldDefinitionNamesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const definition_js_1 = require("../../type/definition.js"); +/** + * Unique field definition names + * + * A GraphQL complex type is only valid if all its fields are uniquely named. + */ +function UniqueFieldDefinitionNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownFieldNames = new Map(); + return { + InputObjectTypeDefinition: checkFieldUniqueness, + InputObjectTypeExtension: checkFieldUniqueness, + InterfaceTypeDefinition: checkFieldUniqueness, + InterfaceTypeExtension: checkFieldUniqueness, + ObjectTypeDefinition: checkFieldUniqueness, + ObjectTypeExtension: checkFieldUniqueness, + }; + function checkFieldUniqueness(node) { + const typeName = node.name.value; + let fieldNames = knownFieldNames.get(typeName); + if (fieldNames == null) { + fieldNames = new Map(); + knownFieldNames.set(typeName, fieldNames); + } + const fieldNodes = node.fields ?? []; + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + if (hasField(existingTypeMap[typeName], fieldName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, { nodes: fieldDef.name })); + continue; + } + const knownFieldName = fieldNames.get(fieldName); + if (knownFieldName != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Field "${typeName}.${fieldName}" can only be defined once.`, { nodes: [knownFieldName, fieldDef.name] })); + } + else { + fieldNames.set(fieldName, fieldDef.name); + } + } + return false; + } +} +function hasField(type, fieldName) { + if ((0, definition_js_1.isObjectType)(type) || (0, definition_js_1.isInterfaceType)(type) || (0, definition_js_1.isInputObjectType)(type)) { + return type.getFields()[fieldName] != null; + } + return false; +} +//# sourceMappingURL=UniqueFieldDefinitionNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueFieldDefinitionNamesRule.js.map b/validation/rules/UniqueFieldDefinitionNamesRule.js.map new file mode 100644 index 0000000000..c17b21a711 --- /dev/null +++ b/validation/rules/UniqueFieldDefinitionNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueFieldDefinitionNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFieldDefinitionNamesRule.ts"],"names":[],"mappings":";;AAuBA,wEA4DC;AAnFD,iEAA2D;AAU3D,4DAIkC;AAIlC;;;;GAIG;AACH,SAAgB,8BAA8B,CAC5C,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiC,CAAC;IAEjE,OAAO;QACL,yBAAyB,EAAE,oBAAoB;QAC/C,wBAAwB,EAAE,oBAAoB;QAC9C,uBAAuB,EAAE,oBAAoB;QAC7C,sBAAsB,EAAE,oBAAoB;QAC5C,oBAAoB,EAAE,oBAAoB;QAC1C,mBAAmB,EAAE,oBAAoB;KAC1C,CAAC;IAEF,SAAS,oBAAoB,CAAC,IAK7B;QACC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAEjC,IAAI,UAAU,GAAG,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,UAAU,IAAI,IAAI,EA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IAAI,IAAI,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n FieldDefinitionNode,\n InputValueDefinitionNode,\n NameNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLNamedType } from '../../type/definition.js';\nimport {\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n} from '../../type/definition.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique field definition names\n *\n * A GraphQL complex type is only valid if all its fields are uniquely named.\n */\nexport function UniqueFieldDefinitionNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownFieldNames = new Map>();\n\n return {\n InputObjectTypeDefinition: checkFieldUniqueness,\n InputObjectTypeExtension: checkFieldUniqueness,\n InterfaceTypeDefinition: checkFieldUniqueness,\n InterfaceTypeExtension: checkFieldUniqueness,\n ObjectTypeDefinition: checkFieldUniqueness,\n ObjectTypeExtension: checkFieldUniqueness,\n };\n\n function checkFieldUniqueness(node: {\n readonly name: NameNode;\n readonly fields?:\n | ReadonlyArray\n | undefined;\n }) {\n const typeName = node.name.value;\n\n let fieldNames = knownFieldNames.get(typeName);\n if (fieldNames == null) {\n fieldNames = new Map();\n knownFieldNames.set(typeName, fieldNames);\n }\n\n const fieldNodes = node.fields ?? [];\n\n for (const fieldDef of fieldNodes) {\n const fieldName = fieldDef.name.value;\n\n if (hasField(existingTypeMap[typeName], fieldName)) {\n context.reportError(\n new GraphQLError(\n `Field \"${typeName}.${fieldName}\" already exists in the schema. It cannot also be defined in this type extension.`,\n { nodes: fieldDef.name },\n ),\n );\n continue;\n }\n\n const knownFieldName = fieldNames.get(fieldName);\n if (knownFieldName != null) {\n context.reportError(\n new GraphQLError(\n `Field \"${typeName}.${fieldName}\" can only be defined once.`,\n { nodes: [knownFieldName, fieldDef.name] },\n ),\n );\n } else {\n fieldNames.set(fieldName, fieldDef.name);\n }\n }\n\n return false;\n }\n}\n\nfunction hasField(type: GraphQLNamedType, fieldName: string): boolean {\n if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) {\n return type.getFields()[fieldName] != null;\n }\n return false;\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueFieldDefinitionNamesRule.mjs b/validation/rules/UniqueFieldDefinitionNamesRule.mjs new file mode 100644 index 0000000000..804de823e0 --- /dev/null +++ b/validation/rules/UniqueFieldDefinitionNamesRule.mjs @@ -0,0 +1,51 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { isInputObjectType, isInterfaceType, isObjectType, } from "../../type/definition.mjs"; +/** + * Unique field definition names + * + * A GraphQL complex type is only valid if all its fields are uniquely named. + */ +export function UniqueFieldDefinitionNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownFieldNames = new Map(); + return { + InputObjectTypeDefinition: checkFieldUniqueness, + InputObjectTypeExtension: checkFieldUniqueness, + InterfaceTypeDefinition: checkFieldUniqueness, + InterfaceTypeExtension: checkFieldUniqueness, + ObjectTypeDefinition: checkFieldUniqueness, + ObjectTypeExtension: checkFieldUniqueness, + }; + function checkFieldUniqueness(node) { + const typeName = node.name.value; + let fieldNames = knownFieldNames.get(typeName); + if (fieldNames == null) { + fieldNames = new Map(); + knownFieldNames.set(typeName, fieldNames); + } + const fieldNodes = node.fields ?? []; + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + if (hasField(existingTypeMap[typeName], fieldName)) { + context.reportError(new GraphQLError(`Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, { nodes: fieldDef.name })); + continue; + } + const knownFieldName = fieldNames.get(fieldName); + if (knownFieldName != null) { + context.reportError(new GraphQLError(`Field "${typeName}.${fieldName}" can only be defined once.`, { nodes: [knownFieldName, fieldDef.name] })); + } + else { + fieldNames.set(fieldName, fieldDef.name); + } + } + return false; + } +} +function hasField(type, fieldName) { + if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) { + return type.getFields()[fieldName] != null; + } + return false; +} +//# sourceMappingURL=UniqueFieldDefinitionNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueFieldDefinitionNamesRule.mjs.map b/validation/rules/UniqueFieldDefinitionNamesRule.mjs.map new file mode 100644 index 0000000000..201410b5c2 --- /dev/null +++ b/validation/rules/UniqueFieldDefinitionNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueFieldDefinitionNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFieldDefinitionNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAU3D,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,YAAY,GACb,kCAAiC;AAIlC;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiC,CAAC;IAEjE,OAAO;QACL,yBAAyB,EAAE,oBAAoB;QAC/C,wBAAwB,EAAE,oBAAoB;QAC9C,uBAAuB,EAAE,oBAAoB;QAC7C,sBAAsB,EAAE,oBAAoB;QAC5C,oBAAoB,EAAE,oBAAoB;QAC1C,mBAAmB,EAAE,oBAAoB;KAC1C,CAAC;IAEF,SAAS,oBAAoB,CAAC,IAK7B;QACC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAEjC,IAAI,UAAU,GAAG,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,UA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,IAAI,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n FieldDefinitionNode,\n InputValueDefinitionNode,\n NameNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLNamedType } from '../../type/definition.js';\nimport {\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n} from '../../type/definition.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique field definition names\n *\n * A GraphQL complex type is only valid if all its fields are uniquely named.\n */\nexport function UniqueFieldDefinitionNamesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownFieldNames = new Map>();\n\n return {\n InputObjectTypeDefinition: checkFieldUniqueness,\n InputObjectTypeExtension: checkFieldUniqueness,\n InterfaceTypeDefinition: checkFieldUniqueness,\n InterfaceTypeExtension: checkFieldUniqueness,\n ObjectTypeDefinition: checkFieldUniqueness,\n ObjectTypeExtension: checkFieldUniqueness,\n };\n\n function checkFieldUniqueness(node: {\n readonly name: NameNode;\n readonly fields?:\n | ReadonlyArray\n | undefined;\n }) {\n const typeName = node.name.value;\n\n let fieldNames = knownFieldNames.get(typeName);\n if (fieldNames == null) {\n fieldNames = new Map();\n knownFieldNames.set(typeName, fieldNames);\n }\n\n const fieldNodes = node.fields ?? [];\n\n for (const fieldDef of fieldNodes) {\n const fieldName = fieldDef.name.value;\n\n if (hasField(existingTypeMap[typeName], fieldName)) {\n context.reportError(\n new GraphQLError(\n `Field \"${typeName}.${fieldName}\" already exists in the schema. It cannot also be defined in this type extension.`,\n { nodes: fieldDef.name },\n ),\n );\n continue;\n }\n\n const knownFieldName = fieldNames.get(fieldName);\n if (knownFieldName != null) {\n context.reportError(\n new GraphQLError(\n `Field \"${typeName}.${fieldName}\" can only be defined once.`,\n { nodes: [knownFieldName, fieldDef.name] },\n ),\n );\n } else {\n fieldNames.set(fieldName, fieldDef.name);\n }\n }\n\n return false;\n }\n}\n\nfunction hasField(type: GraphQLNamedType, fieldName: string): boolean {\n if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) {\n return type.getFields()[fieldName] != null;\n }\n return false;\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueFragmentNamesRule.d.ts b/validation/rules/UniqueFragmentNamesRule.d.ts new file mode 100644 index 0000000000..b74bb1fe6a --- /dev/null +++ b/validation/rules/UniqueFragmentNamesRule.d.ts @@ -0,0 +1,10 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * Unique fragment names + * + * A GraphQL document is only valid if all defined fragments have unique names. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness + */ +export declare function UniqueFragmentNamesRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueFragmentNamesRule.js b/validation/rules/UniqueFragmentNamesRule.js new file mode 100644 index 0000000000..9c02c24fc0 --- /dev/null +++ b/validation/rules/UniqueFragmentNamesRule.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueFragmentNamesRule = UniqueFragmentNamesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique fragment names + * + * A GraphQL document is only valid if all defined fragments have unique names. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness + */ +function UniqueFragmentNamesRule(context) { + const knownFragmentNames = new Map(); + return { + OperationDefinition: () => false, + FragmentDefinition(node) { + const fragmentName = node.name.value; + const knownFragmentName = knownFragmentNames.get(fragmentName); + if (knownFragmentName != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one fragment named "${fragmentName}".`, { nodes: [knownFragmentName, node.name] })); + } + else { + knownFragmentNames.set(fragmentName, node.name); + } + return false; + }, + }; +} +//# sourceMappingURL=UniqueFragmentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueFragmentNamesRule.js.map b/validation/rules/UniqueFragmentNamesRule.js.map new file mode 100644 index 0000000000..ef0fd49553 --- /dev/null +++ b/validation/rules/UniqueFragmentNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFragmentNamesRule.ts"],"names":[],"mappings":";;AAcA,0DAsBC;AApCD,iEAA2D;AAO3D;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,OAA6B;IAE7B,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvD,OAAO;QACL,mBAAmB,EAAE,GAAG,EAAE,CAAC,KAAK;QAChC,kBAAkB,CAAC,IAAI;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC/D,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;gBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,yCAAyC,YAAY,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1C,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique fragment names\n *\n * A GraphQL document is only valid if all defined fragments have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness\n */\nexport function UniqueFragmentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownFragmentNames = new Map();\n return {\n OperationDefinition: () => false,\n FragmentDefinition(node) {\n const fragmentName = node.name.value;\n const knownFragmentName = knownFragmentNames.get(fragmentName);\n if (knownFragmentName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one fragment named \"${fragmentName}\".`,\n { nodes: [knownFragmentName, node.name] },\n ),\n );\n } else {\n knownFragmentNames.set(fragmentName, node.name);\n }\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueFragmentNamesRule.mjs b/validation/rules/UniqueFragmentNamesRule.mjs new file mode 100644 index 0000000000..a50d078e81 --- /dev/null +++ b/validation/rules/UniqueFragmentNamesRule.mjs @@ -0,0 +1,26 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique fragment names + * + * A GraphQL document is only valid if all defined fragments have unique names. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness + */ +export function UniqueFragmentNamesRule(context) { + const knownFragmentNames = new Map(); + return { + OperationDefinition: () => false, + FragmentDefinition(node) { + const fragmentName = node.name.value; + const knownFragmentName = knownFragmentNames.get(fragmentName); + if (knownFragmentName != null) { + context.reportError(new GraphQLError(`There can be only one fragment named "${fragmentName}".`, { nodes: [knownFragmentName, node.name] })); + } + else { + knownFragmentNames.set(fragmentName, node.name); + } + return false; + }, + }; +} +//# sourceMappingURL=UniqueFragmentNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueFragmentNamesRule.mjs.map b/validation/rules/UniqueFragmentNamesRule.mjs.map new file mode 100644 index 0000000000..b8d098ac59 --- /dev/null +++ b/validation/rules/UniqueFragmentNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFragmentNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAO3D;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAA6B;IAE7B,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvD,OAAO;QACL,mBAAmB,EAAE,GAAG,EAAE,CAAC,KAAK;QAChC,kBAAkB,CAAC,IAAI;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC/D,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;gBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yCAAyC,YAAY,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1C,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique fragment names\n *\n * A GraphQL document is only valid if all defined fragments have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness\n */\nexport function UniqueFragmentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownFragmentNames = new Map();\n return {\n OperationDefinition: () => false,\n FragmentDefinition(node) {\n const fragmentName = node.name.value;\n const knownFragmentName = knownFragmentNames.get(fragmentName);\n if (knownFragmentName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one fragment named \"${fragmentName}\".`,\n { nodes: [knownFragmentName, node.name] },\n ),\n );\n } else {\n knownFragmentNames.set(fragmentName, node.name);\n }\n return false;\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueInputFieldNamesRule.d.ts b/validation/rules/UniqueInputFieldNamesRule.d.ts new file mode 100644 index 0000000000..6e177d799f --- /dev/null +++ b/validation/rules/UniqueInputFieldNamesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + */ +export declare function UniqueInputFieldNamesRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueInputFieldNamesRule.js b/validation/rules/UniqueInputFieldNamesRule.js new file mode 100644 index 0000000000..4d49920ccd --- /dev/null +++ b/validation/rules/UniqueInputFieldNamesRule.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueInputFieldNamesRule = UniqueInputFieldNamesRule; +const invariant_js_1 = require("../../jsutils/invariant.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + */ +function UniqueInputFieldNamesRule(context) { + const knownNameStack = []; + let knownNames = new Map(); + return { + ObjectValue: { + enter() { + knownNameStack.push(knownNames); + knownNames = new Map(); + }, + leave() { + const prevKnownNames = knownNameStack.pop(); + (prevKnownNames != null) || (0, invariant_js_1.invariant)(false); + knownNames = prevKnownNames; + }, + }, + ObjectField(node) { + const fieldName = node.name.value; + const knownName = knownNames.get(fieldName); + if (knownName != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one input field named "${fieldName}".`, { nodes: [knownName, node.name] })); + } + else { + knownNames.set(fieldName, node.name); + } + }, + }; +} +//# sourceMappingURL=UniqueInputFieldNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueInputFieldNamesRule.js.map b/validation/rules/UniqueInputFieldNamesRule.js.map new file mode 100644 index 0000000000..2698717d39 --- /dev/null +++ b/validation/rules/UniqueInputFieldNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueInputFieldNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueInputFieldNamesRule.ts"],"names":[],"mappings":";;AAiBA,8DAiCC;AAlDD,6DAAuD;AAEvD,iEAA2D;AAO3D;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CACvC,OAA6B;IAE7B,MAAM,cAAc,GAAiC,EAAE,CAAC;IACxD,IAAI,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE7C,OAAO;QACL,WAAW,EAAE;YACX,KAAK;gBACH,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAChC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;YACzB,CAAC;YACD,KAAK;gBACH,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC;gBAC5C,CAAU,cAAc,IAAI,IAAI,SAAhC,wBAAS,SAAyB;gBAClC,UAAU,GAAG,cAAc,CAAC;YAC9B,CAAC;SACF;QACD,WAAW,CAAC,IAAI;YACd,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAClC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACtB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,4CAA4C,SAAS,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAClC,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from '../../jsutils/invariant.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique input field names\n *\n * A GraphQL input object value is only valid if all supplied fields are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness\n */\nexport function UniqueInputFieldNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownNameStack: Array> = [];\n let knownNames = new Map();\n\n return {\n ObjectValue: {\n enter() {\n knownNameStack.push(knownNames);\n knownNames = new Map();\n },\n leave() {\n const prevKnownNames = knownNameStack.pop();\n invariant(prevKnownNames != null);\n knownNames = prevKnownNames;\n },\n },\n ObjectField(node) {\n const fieldName = node.name.value;\n const knownName = knownNames.get(fieldName);\n if (knownName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one input field named \"${fieldName}\".`,\n { nodes: [knownName, node.name] },\n ),\n );\n } else {\n knownNames.set(fieldName, node.name);\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueInputFieldNamesRule.mjs b/validation/rules/UniqueInputFieldNamesRule.mjs new file mode 100644 index 0000000000..03139156fc --- /dev/null +++ b/validation/rules/UniqueInputFieldNamesRule.mjs @@ -0,0 +1,38 @@ +import { invariant } from "../../jsutils/invariant.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + */ +export function UniqueInputFieldNamesRule(context) { + const knownNameStack = []; + let knownNames = new Map(); + return { + ObjectValue: { + enter() { + knownNameStack.push(knownNames); + knownNames = new Map(); + }, + leave() { + const prevKnownNames = knownNameStack.pop(); + (prevKnownNames != null) || invariant(false); + knownNames = prevKnownNames; + }, + }, + ObjectField(node) { + const fieldName = node.name.value; + const knownName = knownNames.get(fieldName); + if (knownName != null) { + context.reportError(new GraphQLError(`There can be only one input field named "${fieldName}".`, { nodes: [knownName, node.name] })); + } + else { + knownNames.set(fieldName, node.name); + } + }, + }; +} +//# sourceMappingURL=UniqueInputFieldNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueInputFieldNamesRule.mjs.map b/validation/rules/UniqueInputFieldNamesRule.mjs.map new file mode 100644 index 0000000000..3843a34a79 --- /dev/null +++ b/validation/rules/UniqueInputFieldNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueInputFieldNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueInputFieldNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oCAAmC;AAEvD,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAO3D;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAA6B;IAE7B,MAAM,cAAc,GAAiC,EAAE,CAAC;IACxD,IAAI,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE7C,OAAO;QACL,WAAW,EAAE;YACX,KAAK;gBACH,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAChC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;YACzB,CAAC;YACD,KAAK;gBACH,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC;gBAC5C,CAAU,cAAc,IAAI,IAAI,KAAhC,SAAS,QAAyB;gBAClC,UAAU,GAAG,cAAc,CAAC;YAC9B,CAAC;SACF;QACD,WAAW,CAAC,IAAI;YACd,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAClC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACtB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,4CAA4C,SAAS,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAClC,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from '../../jsutils/invariant.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique input field names\n *\n * A GraphQL input object value is only valid if all supplied fields are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness\n */\nexport function UniqueInputFieldNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownNameStack: Array> = [];\n let knownNames = new Map();\n\n return {\n ObjectValue: {\n enter() {\n knownNameStack.push(knownNames);\n knownNames = new Map();\n },\n leave() {\n const prevKnownNames = knownNameStack.pop();\n invariant(prevKnownNames != null);\n knownNames = prevKnownNames;\n },\n },\n ObjectField(node) {\n const fieldName = node.name.value;\n const knownName = knownNames.get(fieldName);\n if (knownName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one input field named \"${fieldName}\".`,\n { nodes: [knownName, node.name] },\n ),\n );\n } else {\n knownNames.set(fieldName, node.name);\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueOperationNamesRule.d.ts b/validation/rules/UniqueOperationNamesRule.d.ts new file mode 100644 index 0000000000..112ddd039b --- /dev/null +++ b/validation/rules/UniqueOperationNamesRule.d.ts @@ -0,0 +1,10 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * Unique operation names + * + * A GraphQL document is only valid if all defined operations have unique names. + * + * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness + */ +export declare function UniqueOperationNamesRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueOperationNamesRule.js b/validation/rules/UniqueOperationNamesRule.js new file mode 100644 index 0000000000..331626a1b8 --- /dev/null +++ b/validation/rules/UniqueOperationNamesRule.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueOperationNamesRule = UniqueOperationNamesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique operation names + * + * A GraphQL document is only valid if all defined operations have unique names. + * + * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness + */ +function UniqueOperationNamesRule(context) { + const knownOperationNames = new Map(); + return { + OperationDefinition(node) { + const operationName = node.name; + if (operationName != null) { + const knownOperationName = knownOperationNames.get(operationName.value); + if (knownOperationName != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one operation named "${operationName.value}".`, { nodes: [knownOperationName, operationName] })); + } + else { + knownOperationNames.set(operationName.value, operationName); + } + } + return false; + }, + FragmentDefinition: () => false, + }; +} +//# sourceMappingURL=UniqueOperationNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueOperationNamesRule.js.map b/validation/rules/UniqueOperationNamesRule.js.map new file mode 100644 index 0000000000..157898facd --- /dev/null +++ b/validation/rules/UniqueOperationNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueOperationNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationNamesRule.ts"],"names":[],"mappings":";;AAcA,4DAwBC;AAtCD,iEAA2D;AAO3D;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxD,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC;YAChC,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBAC1B,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACxE,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;oBAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,0CAA0C,aAAa,CAAC,KAAK,IAAI,EACjE,EAAE,KAAK,EAAE,CAAC,kBAAkB,EAAE,aAAa,CAAC,EAAE,CAC/C,CACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK;KAChC,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique operation names\n *\n * A GraphQL document is only valid if all defined operations have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness\n */\nexport function UniqueOperationNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownOperationNames = new Map();\n return {\n OperationDefinition(node) {\n const operationName = node.name;\n if (operationName != null) {\n const knownOperationName = knownOperationNames.get(operationName.value);\n if (knownOperationName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one operation named \"${operationName.value}\".`,\n { nodes: [knownOperationName, operationName] },\n ),\n );\n } else {\n knownOperationNames.set(operationName.value, operationName);\n }\n }\n return false;\n },\n FragmentDefinition: () => false,\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueOperationNamesRule.mjs b/validation/rules/UniqueOperationNamesRule.mjs new file mode 100644 index 0000000000..273e228dff --- /dev/null +++ b/validation/rules/UniqueOperationNamesRule.mjs @@ -0,0 +1,28 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique operation names + * + * A GraphQL document is only valid if all defined operations have unique names. + * + * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness + */ +export function UniqueOperationNamesRule(context) { + const knownOperationNames = new Map(); + return { + OperationDefinition(node) { + const operationName = node.name; + if (operationName != null) { + const knownOperationName = knownOperationNames.get(operationName.value); + if (knownOperationName != null) { + context.reportError(new GraphQLError(`There can be only one operation named "${operationName.value}".`, { nodes: [knownOperationName, operationName] })); + } + else { + knownOperationNames.set(operationName.value, operationName); + } + } + return false; + }, + FragmentDefinition: () => false, + }; +} +//# sourceMappingURL=UniqueOperationNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueOperationNamesRule.mjs.map b/validation/rules/UniqueOperationNamesRule.mjs.map new file mode 100644 index 0000000000..8c7f52aff8 --- /dev/null +++ b/validation/rules/UniqueOperationNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueOperationNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAO3D;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxD,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC;YAChC,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBAC1B,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACxE,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;oBAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,0CAA0C,aAAa,CAAC,KAAK,IAAI,EACjE,EAAE,KAAK,EAAE,CAAC,kBAAkB,EAAE,aAAa,CAAC,EAAE,CAC/C,CACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK;KAChC,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique operation names\n *\n * A GraphQL document is only valid if all defined operations have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness\n */\nexport function UniqueOperationNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownOperationNames = new Map();\n return {\n OperationDefinition(node) {\n const operationName = node.name;\n if (operationName != null) {\n const knownOperationName = knownOperationNames.get(operationName.value);\n if (knownOperationName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one operation named \"${operationName.value}\".`,\n { nodes: [knownOperationName, operationName] },\n ),\n );\n } else {\n knownOperationNames.set(operationName.value, operationName);\n }\n }\n return false;\n },\n FragmentDefinition: () => false,\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueOperationTypesRule.d.ts b/validation/rules/UniqueOperationTypesRule.d.ts new file mode 100644 index 0000000000..8f2da14eba --- /dev/null +++ b/validation/rules/UniqueOperationTypesRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. + */ +export declare function UniqueOperationTypesRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueOperationTypesRule.js b/validation/rules/UniqueOperationTypesRule.js new file mode 100644 index 0000000000..ddb6a1f0fd --- /dev/null +++ b/validation/rules/UniqueOperationTypesRule.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueOperationTypesRule = UniqueOperationTypesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. + */ +function UniqueOperationTypesRule(context) { + const schema = context.getSchema(); + const definedOperationTypes = new Map(); + const existingOperationTypes = schema + ? { + query: schema.getQueryType(), + mutation: schema.getMutationType(), + subscription: schema.getSubscriptionType(), + } + : {}; + return { + SchemaDefinition: checkOperationTypes, + SchemaExtension: checkOperationTypes, + }; + function checkOperationTypes(node) { + const operationTypesNodes = node.operationTypes ?? []; + for (const operationType of operationTypesNodes) { + const operation = operationType.operation; + const alreadyDefinedOperationType = definedOperationTypes.get(operation); + if (existingOperationTypes[operation]) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Type for ${operation} already defined in the schema. It cannot be redefined.`, { nodes: operationType })); + } + else if (alreadyDefinedOperationType) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one ${operation} type in schema.`, { nodes: [alreadyDefinedOperationType, operationType] })); + } + else { + definedOperationTypes.set(operation, operationType); + } + } + return false; + } +} +//# sourceMappingURL=UniqueOperationTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueOperationTypesRule.js.map b/validation/rules/UniqueOperationTypesRule.js.map new file mode 100644 index 0000000000..8b51a61925 --- /dev/null +++ b/validation/rules/UniqueOperationTypesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueOperationTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationTypesRule.ts"],"names":[],"mappings":";;AAgBA,4DAgDC;AAhED,iEAA2D;AAW3D;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAuC,CAAC;IAC7E,MAAM,sBAAsB,GAAG,MAAM;QACnC,CAAC,CAAC;YACE,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE;YAC5B,QAAQ,EAAE,MAAM,CAAC,eAAe,EAAE;YAClC,YAAY,EAAE,MAAM,CAAC,mBAAmB,EAAE;SAC3C;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,gBAAgB,EAAE,mBAAmB;QACrC,eAAe,EAAE,mBAAmB;KACrC,CAAC;IAEF,SAAS,mBAAmB,CAC1B,IAAgD;QAEhD,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;QAEtD,KAAK,MAAM,aAAa,IAAI,mBAAmB,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC;YAC1C,MAAM,2BAA2B,GAAG,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAEzE,IAAI,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC;gBACtC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,YAAY,SAAS,yDAAyD,EAC9E,EAAE,KAAK,EAAE,aAAa,EAAE,CACzB,CACF,CAAC;YACJ,CAAC;iBAAM,IAAI,2BAA2B,EAAE,CAAC;gBACvC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,yBAAyB,SAAS,kBAAkB,EACpD,EAAE,KAAK,EAAE,CAAC,2BAA2B,EAAE,aAAa,CAAC,EAAE,CACxD,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,qBAAqB,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n OperationTypeDefinitionNode,\n SchemaDefinitionNode,\n SchemaExtensionNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique operation types\n *\n * A GraphQL document is only valid if it has only one type per operation.\n */\nexport function UniqueOperationTypesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const definedOperationTypes = new Map();\n const existingOperationTypes = schema\n ? {\n query: schema.getQueryType(),\n mutation: schema.getMutationType(),\n subscription: schema.getSubscriptionType(),\n }\n : {};\n\n return {\n SchemaDefinition: checkOperationTypes,\n SchemaExtension: checkOperationTypes,\n };\n\n function checkOperationTypes(\n node: SchemaDefinitionNode | SchemaExtensionNode,\n ) {\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n const operation = operationType.operation;\n const alreadyDefinedOperationType = definedOperationTypes.get(operation);\n\n if (existingOperationTypes[operation]) {\n context.reportError(\n new GraphQLError(\n `Type for ${operation} already defined in the schema. It cannot be redefined.`,\n { nodes: operationType },\n ),\n );\n } else if (alreadyDefinedOperationType) {\n context.reportError(\n new GraphQLError(\n `There can be only one ${operation} type in schema.`,\n { nodes: [alreadyDefinedOperationType, operationType] },\n ),\n );\n } else {\n definedOperationTypes.set(operation, operationType);\n }\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueOperationTypesRule.mjs b/validation/rules/UniqueOperationTypesRule.mjs new file mode 100644 index 0000000000..4eead27a2c --- /dev/null +++ b/validation/rules/UniqueOperationTypesRule.mjs @@ -0,0 +1,39 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. + */ +export function UniqueOperationTypesRule(context) { + const schema = context.getSchema(); + const definedOperationTypes = new Map(); + const existingOperationTypes = schema + ? { + query: schema.getQueryType(), + mutation: schema.getMutationType(), + subscription: schema.getSubscriptionType(), + } + : {}; + return { + SchemaDefinition: checkOperationTypes, + SchemaExtension: checkOperationTypes, + }; + function checkOperationTypes(node) { + const operationTypesNodes = node.operationTypes ?? []; + for (const operationType of operationTypesNodes) { + const operation = operationType.operation; + const alreadyDefinedOperationType = definedOperationTypes.get(operation); + if (existingOperationTypes[operation]) { + context.reportError(new GraphQLError(`Type for ${operation} already defined in the schema. It cannot be redefined.`, { nodes: operationType })); + } + else if (alreadyDefinedOperationType) { + context.reportError(new GraphQLError(`There can be only one ${operation} type in schema.`, { nodes: [alreadyDefinedOperationType, operationType] })); + } + else { + definedOperationTypes.set(operation, operationType); + } + } + return false; + } +} +//# sourceMappingURL=UniqueOperationTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueOperationTypesRule.mjs.map b/validation/rules/UniqueOperationTypesRule.mjs.map new file mode 100644 index 0000000000..2509518f13 --- /dev/null +++ b/validation/rules/UniqueOperationTypesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueOperationTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationTypesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAW3D;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAuC,CAAC;IAC7E,MAAM,sBAAsB,GAAG,MAAM;QACnC,CAAC,CAAC;YACE,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE;YAC5B,QAAQ,EAAE,MAAM,CAAC,eAAe,EAAE;YAClC,YAAY,EAAE,MAAM,CAAC,mBAAmB,EAAE;SAC3C;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,gBAAgB,EAAE,mBAAmB;QACrC,eAAe,EAAE,mBAAmB;KACrC,CAAC;IAEF,SAAS,mBAAmB,CAC1B,IAAgD;QAEhD,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;QAEtD,KAAK,MAAM,aAAa,IAAI,mBAAmB,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC;YAC1C,MAAM,2BAA2B,GAAG,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAEzE,IAAI,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC;gBACtC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,YAAY,SAAS,yDAAyD,EAC9E,EAAE,KAAK,EAAE,aAAa,EAAE,CACzB,CACF,CAAC;YACJ,CAAC;iBAAM,IAAI,2BAA2B,EAAE,CAAC;gBACvC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yBAAyB,SAAS,kBAAkB,EACpD,EAAE,KAAK,EAAE,CAAC,2BAA2B,EAAE,aAAa,CAAC,EAAE,CACxD,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,qBAAqB,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type {\n OperationTypeDefinitionNode,\n SchemaDefinitionNode,\n SchemaExtensionNode,\n} from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique operation types\n *\n * A GraphQL document is only valid if it has only one type per operation.\n */\nexport function UniqueOperationTypesRule(\n context: SDLValidationContext,\n): ASTVisitor {\n const schema = context.getSchema();\n const definedOperationTypes = new Map();\n const existingOperationTypes = schema\n ? {\n query: schema.getQueryType(),\n mutation: schema.getMutationType(),\n subscription: schema.getSubscriptionType(),\n }\n : {};\n\n return {\n SchemaDefinition: checkOperationTypes,\n SchemaExtension: checkOperationTypes,\n };\n\n function checkOperationTypes(\n node: SchemaDefinitionNode | SchemaExtensionNode,\n ) {\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n const operation = operationType.operation;\n const alreadyDefinedOperationType = definedOperationTypes.get(operation);\n\n if (existingOperationTypes[operation]) {\n context.reportError(\n new GraphQLError(\n `Type for ${operation} already defined in the schema. It cannot be redefined.`,\n { nodes: operationType },\n ),\n );\n } else if (alreadyDefinedOperationType) {\n context.reportError(\n new GraphQLError(\n `There can be only one ${operation} type in schema.`,\n { nodes: [alreadyDefinedOperationType, operationType] },\n ),\n );\n } else {\n definedOperationTypes.set(operation, operationType);\n }\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueTypeNamesRule.d.ts b/validation/rules/UniqueTypeNamesRule.d.ts new file mode 100644 index 0000000000..1b08a8e056 --- /dev/null +++ b/validation/rules/UniqueTypeNamesRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { SDLValidationContext } from '../ValidationContext.js'; +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +export declare function UniqueTypeNamesRule(context: SDLValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueTypeNamesRule.js b/validation/rules/UniqueTypeNamesRule.js new file mode 100644 index 0000000000..a409329229 --- /dev/null +++ b/validation/rules/UniqueTypeNamesRule.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueTypeNamesRule = UniqueTypeNamesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +function UniqueTypeNamesRule(context) { + const knownTypeNames = new Map(); + const schema = context.getSchema(); + return { + ScalarTypeDefinition: checkTypeName, + ObjectTypeDefinition: checkTypeName, + InterfaceTypeDefinition: checkTypeName, + UnionTypeDefinition: checkTypeName, + EnumTypeDefinition: checkTypeName, + InputObjectTypeDefinition: checkTypeName, + }; + function checkTypeName(node) { + const typeName = node.name.value; + if (schema?.getType(typeName)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, { nodes: node.name })); + return; + } + const knownNameNode = knownTypeNames.get(typeName); + if (knownNameNode != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one type named "${typeName}".`, { + nodes: [knownNameNode, node.name], + })); + } + else { + knownTypeNames.set(typeName, node.name); + } + return false; + } +} +//# sourceMappingURL=UniqueTypeNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueTypeNamesRule.js.map b/validation/rules/UniqueTypeNamesRule.js.map new file mode 100644 index 0000000000..e8eee6949d --- /dev/null +++ b/validation/rules/UniqueTypeNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueTypeNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueTypeNamesRule.ts"],"names":[],"mappings":";;AAYA,kDAuCC;AAnDD,iEAA2D;AAO3D;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAoB,CAAC;IACnD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEnC,OAAO;QACL,oBAAoB,EAAE,aAAa;QACnC,oBAAoB,EAAE,aAAa;QACnC,uBAAuB,EAAE,aAAa;QACtC,mBAAmB,EAAE,aAAa;QAClC,kBAAkB,EAAE,aAAa;QACjC,yBAAyB,EAAE,aAAa;KACzC,CAAC;IAEF,SAAS,aAAa,CAAC,IAAwB;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAEjC,IAAI,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,SAAS,QAAQ,oFAAoF,EACrG,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CACrB,CACF,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;YAC1B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CAAC,qCAAqC,QAAQ,IAAI,EAAE;gBAClE,KAAK,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC;aAClC,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode, TypeDefinitionNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique type names\n *\n * A GraphQL document is only valid if all defined types have unique names.\n */\nexport function UniqueTypeNamesRule(context: SDLValidationContext): ASTVisitor {\n const knownTypeNames = new Map();\n const schema = context.getSchema();\n\n return {\n ScalarTypeDefinition: checkTypeName,\n ObjectTypeDefinition: checkTypeName,\n InterfaceTypeDefinition: checkTypeName,\n UnionTypeDefinition: checkTypeName,\n EnumTypeDefinition: checkTypeName,\n InputObjectTypeDefinition: checkTypeName,\n };\n\n function checkTypeName(node: TypeDefinitionNode) {\n const typeName = node.name.value;\n\n if (schema?.getType(typeName)) {\n context.reportError(\n new GraphQLError(\n `Type \"${typeName}\" already exists in the schema. It cannot also be defined in this type definition.`,\n { nodes: node.name },\n ),\n );\n return;\n }\n\n const knownNameNode = knownTypeNames.get(typeName);\n if (knownNameNode != null) {\n context.reportError(\n new GraphQLError(`There can be only one type named \"${typeName}\".`, {\n nodes: [knownNameNode, node.name],\n }),\n );\n } else {\n knownTypeNames.set(typeName, node.name);\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueTypeNamesRule.mjs b/validation/rules/UniqueTypeNamesRule.mjs new file mode 100644 index 0000000000..2049062170 --- /dev/null +++ b/validation/rules/UniqueTypeNamesRule.mjs @@ -0,0 +1,36 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +export function UniqueTypeNamesRule(context) { + const knownTypeNames = new Map(); + const schema = context.getSchema(); + return { + ScalarTypeDefinition: checkTypeName, + ObjectTypeDefinition: checkTypeName, + InterfaceTypeDefinition: checkTypeName, + UnionTypeDefinition: checkTypeName, + EnumTypeDefinition: checkTypeName, + InputObjectTypeDefinition: checkTypeName, + }; + function checkTypeName(node) { + const typeName = node.name.value; + if (schema?.getType(typeName)) { + context.reportError(new GraphQLError(`Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, { nodes: node.name })); + return; + } + const knownNameNode = knownTypeNames.get(typeName); + if (knownNameNode != null) { + context.reportError(new GraphQLError(`There can be only one type named "${typeName}".`, { + nodes: [knownNameNode, node.name], + })); + } + else { + knownTypeNames.set(typeName, node.name); + } + return false; + } +} +//# sourceMappingURL=UniqueTypeNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueTypeNamesRule.mjs.map b/validation/rules/UniqueTypeNamesRule.mjs.map new file mode 100644 index 0000000000..1b019294b0 --- /dev/null +++ b/validation/rules/UniqueTypeNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueTypeNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueTypeNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAO3D;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAoB,CAAC;IACnD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEnC,OAAO;QACL,oBAAoB,EAAE,aAAa;QACnC,oBAAoB,EAAE,aAAa;QACnC,uBAAuB,EAAE,aAAa;QACtC,mBAAmB,EAAE,aAAa;QAClC,kBAAkB,EAAE,aAAa;QACjC,yBAAyB,EAAE,aAAa;KACzC,CAAC;IAEF,SAAS,aAAa,CAAC,IAAwB;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAEjC,IAAI,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,SAAS,QAAQ,oFAAoF,EACrG,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CACrB,CACF,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;YAC1B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CAAC,qCAAqC,QAAQ,IAAI,EAAE;gBAClE,KAAK,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC;aAClC,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { NameNode, TypeDefinitionNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { SDLValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique type names\n *\n * A GraphQL document is only valid if all defined types have unique names.\n */\nexport function UniqueTypeNamesRule(context: SDLValidationContext): ASTVisitor {\n const knownTypeNames = new Map();\n const schema = context.getSchema();\n\n return {\n ScalarTypeDefinition: checkTypeName,\n ObjectTypeDefinition: checkTypeName,\n InterfaceTypeDefinition: checkTypeName,\n UnionTypeDefinition: checkTypeName,\n EnumTypeDefinition: checkTypeName,\n InputObjectTypeDefinition: checkTypeName,\n };\n\n function checkTypeName(node: TypeDefinitionNode) {\n const typeName = node.name.value;\n\n if (schema?.getType(typeName)) {\n context.reportError(\n new GraphQLError(\n `Type \"${typeName}\" already exists in the schema. It cannot also be defined in this type definition.`,\n { nodes: node.name },\n ),\n );\n return;\n }\n\n const knownNameNode = knownTypeNames.get(typeName);\n if (knownNameNode != null) {\n context.reportError(\n new GraphQLError(`There can be only one type named \"${typeName}\".`, {\n nodes: [knownNameNode, node.name],\n }),\n );\n } else {\n knownTypeNames.set(typeName, node.name);\n }\n\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueVariableNamesRule.d.ts b/validation/rules/UniqueVariableNamesRule.d.ts new file mode 100644 index 0000000000..46db49fdca --- /dev/null +++ b/validation/rules/UniqueVariableNamesRule.d.ts @@ -0,0 +1,8 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ASTValidationContext } from '../ValidationContext.js'; +/** + * Unique variable names + * + * A GraphQL operation is only valid if all its variables are uniquely named. + */ +export declare function UniqueVariableNamesRule(context: ASTValidationContext): ASTVisitor; diff --git a/validation/rules/UniqueVariableNamesRule.js b/validation/rules/UniqueVariableNamesRule.js new file mode 100644 index 0000000000..a2d6acdabb --- /dev/null +++ b/validation/rules/UniqueVariableNamesRule.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueVariableNamesRule = UniqueVariableNamesRule; +const groupBy_js_1 = require("../../jsutils/groupBy.js"); +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +/** + * Unique variable names + * + * A GraphQL operation is only valid if all its variables are uniquely named. + */ +function UniqueVariableNamesRule(context) { + return { + OperationDefinition(operationNode) { + const variableDefinitions = operationNode.variableDefinitions ?? []; + const seenVariableDefinitions = (0, groupBy_js_1.groupBy)(variableDefinitions, (node) => node.variable.name.value); + for (const [variableName, variableNodes] of seenVariableDefinitions) { + if (variableNodes.length > 1) { + context.reportError(new GraphQLError_js_1.GraphQLError(`There can be only one variable named "$${variableName}".`, { nodes: variableNodes.map((node) => node.variable.name) })); + } + } + }, + }; +} +//# sourceMappingURL=UniqueVariableNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueVariableNamesRule.js.map b/validation/rules/UniqueVariableNamesRule.js.map new file mode 100644 index 0000000000..2f21d4c757 --- /dev/null +++ b/validation/rules/UniqueVariableNamesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueVariableNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueVariableNamesRule.ts"],"names":[],"mappings":";;AAaA,0DAwBC;AArCD,yDAAmD;AAEnD,iEAA2D;AAM3D;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,mBAAmB,CAAC,aAAa;YAC/B,MAAM,mBAAmB,GAAG,aAAa,CAAC,mBAAmB,IAAI,EAAE,CAAC;YAEpE,MAAM,uBAAuB,GAAG,IAAA,oBAAO,EACrC,mBAAmB,EACnB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CACnC,CAAC;YAEF,KAAK,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,uBAAuB,EAAE,CAAC;gBACpE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC7B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,0CAA0C,YAAY,IAAI,EAC1D,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAC3D,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { groupBy } from '../../jsutils/groupBy.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique variable names\n *\n * A GraphQL operation is only valid if all its variables are uniquely named.\n */\nexport function UniqueVariableNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(operationNode) {\n const variableDefinitions = operationNode.variableDefinitions ?? [];\n\n const seenVariableDefinitions = groupBy(\n variableDefinitions,\n (node) => node.variable.name.value,\n );\n\n for (const [variableName, variableNodes] of seenVariableDefinitions) {\n if (variableNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one variable named \"$${variableName}\".`,\n { nodes: variableNodes.map((node) => node.variable.name) },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/UniqueVariableNamesRule.mjs b/validation/rules/UniqueVariableNamesRule.mjs new file mode 100644 index 0000000000..250825a084 --- /dev/null +++ b/validation/rules/UniqueVariableNamesRule.mjs @@ -0,0 +1,21 @@ +import { groupBy } from "../../jsutils/groupBy.mjs"; +import { GraphQLError } from "../../error/GraphQLError.mjs"; +/** + * Unique variable names + * + * A GraphQL operation is only valid if all its variables are uniquely named. + */ +export function UniqueVariableNamesRule(context) { + return { + OperationDefinition(operationNode) { + const variableDefinitions = operationNode.variableDefinitions ?? []; + const seenVariableDefinitions = groupBy(variableDefinitions, (node) => node.variable.name.value); + for (const [variableName, variableNodes] of seenVariableDefinitions) { + if (variableNodes.length > 1) { + context.reportError(new GraphQLError(`There can be only one variable named "$${variableName}".`, { nodes: variableNodes.map((node) => node.variable.name) })); + } + } + }, + }; +} +//# sourceMappingURL=UniqueVariableNamesRule.js.map \ No newline at end of file diff --git a/validation/rules/UniqueVariableNamesRule.mjs.map b/validation/rules/UniqueVariableNamesRule.mjs.map new file mode 100644 index 0000000000..00f585f64b --- /dev/null +++ b/validation/rules/UniqueVariableNamesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueVariableNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueVariableNamesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAEnD,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAM3D;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,mBAAmB,CAAC,aAAa;YAC/B,MAAM,mBAAmB,GAAG,aAAa,CAAC,mBAAmB,IAAI,EAAE,CAAC;YAEpE,MAAM,uBAAuB,GAAG,OAAO,CACrC,mBAAmB,EACnB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CACnC,CAAC;YAEF,KAAK,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,uBAAuB,EAAE,CAAC;gBACpE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC7B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,0CAA0C,YAAY,IAAI,EAC1D,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAC3D,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { groupBy } from '../../jsutils/groupBy.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { ASTValidationContext } from '../ValidationContext.js';\n\n/**\n * Unique variable names\n *\n * A GraphQL operation is only valid if all its variables are uniquely named.\n */\nexport function UniqueVariableNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(operationNode) {\n const variableDefinitions = operationNode.variableDefinitions ?? [];\n\n const seenVariableDefinitions = groupBy(\n variableDefinitions,\n (node) => node.variable.name.value,\n );\n\n for (const [variableName, variableNodes] of seenVariableDefinitions) {\n if (variableNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one variable named \"$${variableName}\".`,\n { nodes: variableNodes.map((node) => node.variable.name) },\n ),\n );\n }\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ValuesOfCorrectTypeRule.d.ts b/validation/rules/ValuesOfCorrectTypeRule.d.ts new file mode 100644 index 0000000000..c4801cff6f --- /dev/null +++ b/validation/rules/ValuesOfCorrectTypeRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Value literals of correct type + * + * A GraphQL document is only valid if all value literals are of the type + * expected at their position. + * + * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type + */ +export declare function ValuesOfCorrectTypeRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/ValuesOfCorrectTypeRule.js b/validation/rules/ValuesOfCorrectTypeRule.js new file mode 100644 index 0000000000..08da9ee17f --- /dev/null +++ b/validation/rules/ValuesOfCorrectTypeRule.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ValuesOfCorrectTypeRule = ValuesOfCorrectTypeRule; +const validateInputValue_js_1 = require("../../utilities/validateInputValue.js"); +/** + * Value literals of correct type + * + * A GraphQL document is only valid if all value literals are of the type + * expected at their position. + * + * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type + */ +function ValuesOfCorrectTypeRule(context) { + return { + NullValue: (node) => isValidValueNode(context, node, context.getInputType()), + ListValue: (node) => + // Note: TypeInfo will traverse into a list's item type, so look to the + // parent input type to check if it is a list. + isValidValueNode(context, node, context.getParentInputType()), + ObjectValue: (node) => isValidValueNode(context, node, context.getInputType()), + EnumValue: (node) => isValidValueNode(context, node, context.getInputType()), + IntValue: (node) => isValidValueNode(context, node, context.getInputType()), + FloatValue: (node) => isValidValueNode(context, node, context.getInputType()), + StringValue: (node) => isValidValueNode(context, node, context.getInputType()), + BooleanValue: (node) => isValidValueNode(context, node, context.getInputType()), + }; +} +/** + * Any value literal may be a valid representation of a Scalar, depending on + * that scalar type. + */ +function isValidValueNode(context, node, inputType) { + if (inputType) { + (0, validateInputValue_js_1.validateInputLiteral)(node, inputType, (error) => { + context.reportError(error); + }, undefined, undefined, context.hideSuggestions); + } + return false; +} +//# sourceMappingURL=ValuesOfCorrectTypeRule.js.map \ No newline at end of file diff --git a/validation/rules/ValuesOfCorrectTypeRule.js.map b/validation/rules/ValuesOfCorrectTypeRule.js.map new file mode 100644 index 0000000000..ab1fc1fd0c --- /dev/null +++ b/validation/rules/ValuesOfCorrectTypeRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ValuesOfCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ValuesOfCorrectTypeRule.ts"],"names":[],"mappings":";;AAmBA,0DAsBC;AAlCD,iFAA6E;AAI7E;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,OAA0B;IAE1B,OAAO;QACL,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;QAClB,uEAAuE;QACvE,8CAA8C;QAC9C,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC/D,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QAC3E,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CACnB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CACrB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CACvB,OAA0B,EAC1B,IAAe,EACf,SAAkC;IAElC,IAAI,SAAS,EAAE,CAAC;QACd,IAAA,4CAAoB,EAClB,IAAI,EACJ,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;YACR,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC,EACD,SAAS,EACT,SAAS,EACT,OAAO,CAAC,eAAe,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Maybe } from '../../jsutils/Maybe.js';\n\nimport type { ValueNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLInputType } from '../../type/index.js';\n\nimport { validateInputLiteral } from '../../utilities/validateInputValue.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Value literals of correct type\n *\n * A GraphQL document is only valid if all value literals are of the type\n * expected at their position.\n *\n * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type\n */\nexport function ValuesOfCorrectTypeRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n NullValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n ListValue: (node) =>\n // Note: TypeInfo will traverse into a list's item type, so look to the\n // parent input type to check if it is a list.\n isValidValueNode(context, node, context.getParentInputType()),\n ObjectValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n EnumValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n IntValue: (node) => isValidValueNode(context, node, context.getInputType()),\n FloatValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n StringValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n BooleanValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n };\n}\n\n/**\n * Any value literal may be a valid representation of a Scalar, depending on\n * that scalar type.\n */\nfunction isValidValueNode(\n context: ValidationContext,\n node: ValueNode,\n inputType: Maybe,\n): false {\n if (inputType) {\n validateInputLiteral(\n node,\n inputType,\n (error) => {\n context.reportError(error);\n },\n undefined,\n undefined,\n context.hideSuggestions,\n );\n }\n return false;\n}\n"]} \ No newline at end of file diff --git a/validation/rules/ValuesOfCorrectTypeRule.mjs b/validation/rules/ValuesOfCorrectTypeRule.mjs new file mode 100644 index 0000000000..2e50acdf43 --- /dev/null +++ b/validation/rules/ValuesOfCorrectTypeRule.mjs @@ -0,0 +1,37 @@ +import { validateInputLiteral } from "../../utilities/validateInputValue.mjs"; +/** + * Value literals of correct type + * + * A GraphQL document is only valid if all value literals are of the type + * expected at their position. + * + * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type + */ +export function ValuesOfCorrectTypeRule(context) { + return { + NullValue: (node) => isValidValueNode(context, node, context.getInputType()), + ListValue: (node) => + // Note: TypeInfo will traverse into a list's item type, so look to the + // parent input type to check if it is a list. + isValidValueNode(context, node, context.getParentInputType()), + ObjectValue: (node) => isValidValueNode(context, node, context.getInputType()), + EnumValue: (node) => isValidValueNode(context, node, context.getInputType()), + IntValue: (node) => isValidValueNode(context, node, context.getInputType()), + FloatValue: (node) => isValidValueNode(context, node, context.getInputType()), + StringValue: (node) => isValidValueNode(context, node, context.getInputType()), + BooleanValue: (node) => isValidValueNode(context, node, context.getInputType()), + }; +} +/** + * Any value literal may be a valid representation of a Scalar, depending on + * that scalar type. + */ +function isValidValueNode(context, node, inputType) { + if (inputType) { + validateInputLiteral(node, inputType, (error) => { + context.reportError(error); + }, undefined, undefined, context.hideSuggestions); + } + return false; +} +//# sourceMappingURL=ValuesOfCorrectTypeRule.js.map \ No newline at end of file diff --git a/validation/rules/ValuesOfCorrectTypeRule.mjs.map b/validation/rules/ValuesOfCorrectTypeRule.mjs.map new file mode 100644 index 0000000000..cf57d80ce2 --- /dev/null +++ b/validation/rules/ValuesOfCorrectTypeRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ValuesOfCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ValuesOfCorrectTypeRule.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,+CAA8C;AAI7E;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAA0B;IAE1B,OAAO;QACL,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;QAClB,uEAAuE;QACvE,8CAA8C;QAC9C,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC/D,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QAC3E,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CACnB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CACrB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CACvB,OAA0B,EAC1B,IAAe,EACf,SAAkC;IAElC,IAAI,SAAS,EAAE,CAAC;QACd,oBAAoB,CAClB,IAAI,EACJ,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;YACR,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC,EACD,SAAS,EACT,SAAS,EACT,OAAO,CAAC,eAAe,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Maybe } from '../../jsutils/Maybe.js';\n\nimport type { ValueNode } from '../../language/ast.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLInputType } from '../../type/index.js';\n\nimport { validateInputLiteral } from '../../utilities/validateInputValue.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Value literals of correct type\n *\n * A GraphQL document is only valid if all value literals are of the type\n * expected at their position.\n *\n * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type\n */\nexport function ValuesOfCorrectTypeRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n NullValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n ListValue: (node) =>\n // Note: TypeInfo will traverse into a list's item type, so look to the\n // parent input type to check if it is a list.\n isValidValueNode(context, node, context.getParentInputType()),\n ObjectValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n EnumValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n IntValue: (node) => isValidValueNode(context, node, context.getInputType()),\n FloatValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n StringValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n BooleanValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n };\n}\n\n/**\n * Any value literal may be a valid representation of a Scalar, depending on\n * that scalar type.\n */\nfunction isValidValueNode(\n context: ValidationContext,\n node: ValueNode,\n inputType: Maybe,\n): false {\n if (inputType) {\n validateInputLiteral(\n node,\n inputType,\n (error) => {\n context.reportError(error);\n },\n undefined,\n undefined,\n context.hideSuggestions,\n );\n }\n return false;\n}\n"]} \ No newline at end of file diff --git a/validation/rules/VariablesAreInputTypesRule.d.ts b/validation/rules/VariablesAreInputTypesRule.d.ts new file mode 100644 index 0000000000..3ca7550ee6 --- /dev/null +++ b/validation/rules/VariablesAreInputTypesRule.d.ts @@ -0,0 +1,11 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Variables are input types + * + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + * + * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types + */ +export declare function VariablesAreInputTypesRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/VariablesAreInputTypesRule.js b/validation/rules/VariablesAreInputTypesRule.js new file mode 100644 index 0000000000..ff03bcf44c --- /dev/null +++ b/validation/rules/VariablesAreInputTypesRule.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VariablesAreInputTypesRule = VariablesAreInputTypesRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const printer_js_1 = require("../../language/printer.js"); +const definition_js_1 = require("../../type/definition.js"); +const typeFromAST_js_1 = require("../../utilities/typeFromAST.js"); +/** + * Variables are input types + * + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + * + * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types + */ +function VariablesAreInputTypesRule(context) { + return { + VariableDefinition(node) { + const type = (0, typeFromAST_js_1.typeFromAST)(context.getSchema(), node.type); + if (type !== undefined && !(0, definition_js_1.isInputType)(type)) { + const variableName = node.variable.name.value; + const typeName = (0, printer_js_1.print)(node.type); + context.reportError(new GraphQLError_js_1.GraphQLError(`Variable "$${variableName}" cannot be non-input type "${typeName}".`, { nodes: node.type })); + } + }, + }; +} +//# sourceMappingURL=VariablesAreInputTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/VariablesAreInputTypesRule.js.map b/validation/rules/VariablesAreInputTypesRule.js.map new file mode 100644 index 0000000000..da2a2d1e20 --- /dev/null +++ b/validation/rules/VariablesAreInputTypesRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"VariablesAreInputTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/VariablesAreInputTypesRule.ts"],"names":[],"mappings":";;AAoBA,gEAoBC;AAxCD,iEAA2D;AAG3D,0DAAkD;AAGlD,4DAAuD;AAEvD,mEAA6D;AAI7D;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CACxC,OAA0B;IAE1B,OAAO;QACL,kBAAkB,CAAC,IAA4B;YAC7C,MAAM,IAAI,GAAG,IAAA,4BAAW,EAAC,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAEzD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,IAAA,2BAAW,EAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC9C,MAAM,QAAQ,GAAG,IAAA,kBAAK,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAElC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,cAAc,YAAY,+BAA+B,QAAQ,IAAI,EACrE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CACrB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { VariableDefinitionNode } from '../../language/ast.js';\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isInputType } from '../../type/definition.js';\n\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Variables are input types\n *\n * A GraphQL operation is only valid if all the variables it defines are of\n * input types (scalar, enum, or input object).\n *\n * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types\n */\nexport function VariablesAreInputTypesRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n VariableDefinition(node: VariableDefinitionNode) {\n const type = typeFromAST(context.getSchema(), node.type);\n\n if (type !== undefined && !isInputType(type)) {\n const variableName = node.variable.name.value;\n const typeName = print(node.type);\n\n context.reportError(\n new GraphQLError(\n `Variable \"$${variableName}\" cannot be non-input type \"${typeName}\".`,\n { nodes: node.type },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/VariablesAreInputTypesRule.mjs b/validation/rules/VariablesAreInputTypesRule.mjs new file mode 100644 index 0000000000..27a58981fe --- /dev/null +++ b/validation/rules/VariablesAreInputTypesRule.mjs @@ -0,0 +1,25 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { print } from "../../language/printer.mjs"; +import { isInputType } from "../../type/definition.mjs"; +import { typeFromAST } from "../../utilities/typeFromAST.mjs"; +/** + * Variables are input types + * + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + * + * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types + */ +export function VariablesAreInputTypesRule(context) { + return { + VariableDefinition(node) { + const type = typeFromAST(context.getSchema(), node.type); + if (type !== undefined && !isInputType(type)) { + const variableName = node.variable.name.value; + const typeName = print(node.type); + context.reportError(new GraphQLError(`Variable "$${variableName}" cannot be non-input type "${typeName}".`, { nodes: node.type })); + } + }, + }; +} +//# sourceMappingURL=VariablesAreInputTypesRule.js.map \ No newline at end of file diff --git a/validation/rules/VariablesAreInputTypesRule.mjs.map b/validation/rules/VariablesAreInputTypesRule.mjs.map new file mode 100644 index 0000000000..1ccb9c7926 --- /dev/null +++ b/validation/rules/VariablesAreInputTypesRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"VariablesAreInputTypesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/VariablesAreInputTypesRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,KAAK,EAAE,mCAAkC;AAGlD,OAAO,EAAE,WAAW,EAAE,kCAAiC;AAEvD,OAAO,EAAE,WAAW,EAAE,wCAAuC;AAI7D;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA0B;IAE1B,OAAO;QACL,kBAAkB,CAAC,IAA4B;YAC7C,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAEzD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAElC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,cAAc,YAAY,+BAA+B,QAAQ,IAAI,EACrE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CACrB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { VariableDefinitionNode } from '../../language/ast.js';\nimport { print } from '../../language/printer.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport { isInputType } from '../../type/definition.js';\n\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Variables are input types\n *\n * A GraphQL operation is only valid if all the variables it defines are of\n * input types (scalar, enum, or input object).\n *\n * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types\n */\nexport function VariablesAreInputTypesRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n VariableDefinition(node: VariableDefinitionNode) {\n const type = typeFromAST(context.getSchema(), node.type);\n\n if (type !== undefined && !isInputType(type)) {\n const variableName = node.variable.name.value;\n const typeName = print(node.type);\n\n context.reportError(\n new GraphQLError(\n `Variable \"$${variableName}\" cannot be non-input type \"${typeName}\".`,\n { nodes: node.type },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/VariablesInAllowedPositionRule.d.ts b/validation/rules/VariablesInAllowedPositionRule.d.ts new file mode 100644 index 0000000000..bdd7a12760 --- /dev/null +++ b/validation/rules/VariablesInAllowedPositionRule.d.ts @@ -0,0 +1,10 @@ +import type { ASTVisitor } from '../../language/visitor.js'; +import type { ValidationContext } from '../ValidationContext.js'; +/** + * Variables in allowed position + * + * Variable usages must be compatible with the arguments they are passed to. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed + */ +export declare function VariablesInAllowedPositionRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/VariablesInAllowedPositionRule.js b/validation/rules/VariablesInAllowedPositionRule.js new file mode 100644 index 0000000000..bdecc77755 --- /dev/null +++ b/validation/rules/VariablesInAllowedPositionRule.js @@ -0,0 +1,77 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VariablesInAllowedPositionRule = VariablesInAllowedPositionRule; +const GraphQLError_js_1 = require("../../error/GraphQLError.js"); +const kinds_js_1 = require("../../language/kinds.js"); +const definition_js_1 = require("../../type/definition.js"); +const typeComparators_js_1 = require("../../utilities/typeComparators.js"); +const typeFromAST_js_1 = require("../../utilities/typeFromAST.js"); +/** + * Variables in allowed position + * + * Variable usages must be compatible with the arguments they are passed to. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed + */ +function VariablesInAllowedPositionRule(context) { + let varDefMap; + return { + OperationDefinition: { + enter() { + varDefMap = new Map(); + }, + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + for (const { node, type, parentType, defaultValue, fragmentVariableDefinition, } of usages) { + const varName = node.name.value; + let varDef = fragmentVariableDefinition; + if (!varDef) { + varDef = varDefMap.get(varName); + } + if (varDef && type) { + // A var type is allowed if it is the same or more strict (e.g. is + // a subtype of) than the expected type. It can be more strict if + // the variable type is non-null when the expected type is nullable. + // If both are list types, the variable item type can be more strict + // than the expected item type (contravariant). + const schema = context.getSchema(); + const varType = (0, typeFromAST_js_1.typeFromAST)(schema, varDef.type); + if (varType && + !allowedVariableUsage(schema, varType, varDef.defaultValue, type, defaultValue)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Variable "$${varName}" of type "${varType}" used in position expecting type "${type}".`, { nodes: [varDef, node] })); + } + if ((0, definition_js_1.isInputObjectType)(parentType) && + parentType.isOneOf && + (0, definition_js_1.isNullableType)(varType)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`Variable "$${varName}" is of type "${varType}" but must be non-nullable to be used for OneOf Input Object "${parentType}".`, { nodes: [varDef, node] })); + } + } + } + }, + }, + VariableDefinition(node) { + varDefMap.set(node.variable.name.value, node); + }, + }; +} +/** + * Returns true if the variable is allowed in the location it was found, + * including considering if default values exist for either the variable + * or the location at which it is located. + * + * OneOf Input Object Type fields are considered separately above to + * provide a more descriptive error message. + */ +function allowedVariableUsage(schema, varType, varDefaultValue, locationType, locationDefaultValue) { + if ((0, definition_js_1.isNonNullType)(locationType) && !(0, definition_js_1.isNonNullType)(varType)) { + const hasNonNullVariableDefaultValue = varDefaultValue != null && varDefaultValue.kind !== kinds_js_1.Kind.NULL; + const hasLocationDefaultValue = locationDefaultValue !== undefined; + if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { + return false; + } + const nullableLocationType = locationType.ofType; + return (0, typeComparators_js_1.isTypeSubTypeOf)(schema, varType, nullableLocationType); + } + return (0, typeComparators_js_1.isTypeSubTypeOf)(schema, varType, locationType); +} +//# sourceMappingURL=VariablesInAllowedPositionRule.js.map \ No newline at end of file diff --git a/validation/rules/VariablesInAllowedPositionRule.js.map b/validation/rules/VariablesInAllowedPositionRule.js.map new file mode 100644 index 0000000000..26991b64fb --- /dev/null +++ b/validation/rules/VariablesInAllowedPositionRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"VariablesInAllowedPositionRule.js","sourceRoot":"","sources":["../../../src/validation/rules/VariablesInAllowedPositionRule.ts"],"names":[],"mappings":";;AA4BA,wEAwEC;AAlGD,iEAA2D;AAG3D,sDAA+C;AAI/C,4DAIkC;AAGlC,2EAAqE;AACrE,mEAA6D;AAI7D;;;;;;GAMG;AACH,SAAgB,8BAA8B,CAC5C,OAA0B;IAE1B,IAAI,SAA8C,CAAC;IAEnD,OAAO;QACL,mBAAmB,EAAE;YACnB,KAAK;gBACH,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;YACxB,CAAC;YACD,KAAK,CAAC,SAAS;gBACb,MAAM,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;gBAE7D,KAAK,MAAM,EACT,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,0BAA0B,GAC3B,IAAI,MAAM,EAAE,CAAC;oBACZ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;oBAEhC,IAAI,MAAM,GAAG,0BAA0B,CAAC;oBACxC,IAAI,CAAC,MAAM,EAAE,CAAC;wBACZ,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;oBAClC,CAAC;oBACD,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;wBACnB,kEAAkE;wBAClE,iEAAiE;wBACjE,oEAAoE;wBACpE,oEAAoE;wBACpE,+CAA+C;wBAC/C,MAA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CAAC,IAAI,CAAC;QAChE,MAAM,uBAAuB,GAAG,oBAAoB,KAAK,SAAS,CAAC;QACnE,IAAI,CAAC,8BAA8B,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAChE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,oBAAoB,GAAG,YAAY,CAAC,MAAM,CAAC;QACjD,OAAO,IAAA,oCAAe,EAAC,MAAM,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,IAAA,oCAAe,EAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { Maybe } from '../../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ValueNode, VariableDefinitionNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLType } from '../../type/definition.js';\nimport {\n isInputObjectType,\n isNonNullType,\n isNullableType,\n} from '../../type/definition.js';\nimport type { GraphQLSchema } from '../../type/schema.js';\n\nimport { isTypeSubTypeOf } from '../../utilities/typeComparators.js';\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Variables in allowed position\n *\n * Variable usages must be compatible with the arguments they are passed to.\n *\n * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed\n */\nexport function VariablesInAllowedPositionRule(\n context: ValidationContext,\n): ASTVisitor {\n let varDefMap: Map;\n\n return {\n OperationDefinition: {\n enter() {\n varDefMap = new Map();\n },\n leave(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node,\n type,\n parentType,\n defaultValue,\n fragmentVariableDefinition,\n } of usages) {\n const varName = node.name.value;\n\n let varDef = fragmentVariableDefinition;\n if (!varDef) {\n varDef = varDefMap.get(varName);\n }\n if (varDef && type) {\n // A var type is allowed if it is the same or more strict (e.g. is\n // a subtype of) than the expected type. It can be more strict if\n // the variable type is non-null when the expected type is nullable.\n // If both are list types, the variable item type can be more strict\n // than the expected item type (contravariant).\n const schema = context.getSchema();\n const varType = typeFromAST(schema, varDef.type);\n if (\n varType &&\n !allowedVariableUsage(\n schema,\n varType,\n varDef.defaultValue,\n type,\n defaultValue,\n )\n ) {\n context.reportError(\n new GraphQLError(\n `Variable \"$${varName}\" of type \"${varType}\" used in position expecting type \"${type}\".`,\n { nodes: [varDef, node] },\n ),\n );\n }\n\n if (\n isInputObjectType(parentType) &&\n parentType.isOneOf &&\n isNullableType(varType)\n ) {\n context.reportError(\n new GraphQLError(\n `Variable \"$${varName}\" is of type \"${varType}\" but must be non-nullable to be used for OneOf Input Object \"${parentType}\".`,\n { nodes: [varDef, node] },\n ),\n );\n }\n }\n }\n },\n },\n VariableDefinition(node) {\n varDefMap.set(node.variable.name.value, node);\n },\n };\n}\n\n/**\n * Returns true if the variable is allowed in the location it was found,\n * including considering if default values exist for either the variable\n * or the location at which it is located.\n *\n * OneOf Input Object Type fields are considered separately above to\n * provide a more descriptive error message.\n */\nfunction allowedVariableUsage(\n schema: GraphQLSchema,\n varType: GraphQLType,\n varDefaultValue: Maybe,\n locationType: GraphQLType,\n locationDefaultValue: unknown,\n): boolean {\n if (isNonNullType(locationType) && !isNonNullType(varType)) {\n const hasNonNullVariableDefaultValue =\n varDefaultValue != null && varDefaultValue.kind !== Kind.NULL;\n const hasLocationDefaultValue = locationDefaultValue !== undefined;\n if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {\n return false;\n }\n const nullableLocationType = locationType.ofType;\n return isTypeSubTypeOf(schema, varType, nullableLocationType);\n }\n return isTypeSubTypeOf(schema, varType, locationType);\n}\n"]} \ No newline at end of file diff --git a/validation/rules/VariablesInAllowedPositionRule.mjs b/validation/rules/VariablesInAllowedPositionRule.mjs new file mode 100644 index 0000000000..13917ae86d --- /dev/null +++ b/validation/rules/VariablesInAllowedPositionRule.mjs @@ -0,0 +1,74 @@ +import { GraphQLError } from "../../error/GraphQLError.mjs"; +import { Kind } from "../../language/kinds.mjs"; +import { isInputObjectType, isNonNullType, isNullableType, } from "../../type/definition.mjs"; +import { isTypeSubTypeOf } from "../../utilities/typeComparators.mjs"; +import { typeFromAST } from "../../utilities/typeFromAST.mjs"; +/** + * Variables in allowed position + * + * Variable usages must be compatible with the arguments they are passed to. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed + */ +export function VariablesInAllowedPositionRule(context) { + let varDefMap; + return { + OperationDefinition: { + enter() { + varDefMap = new Map(); + }, + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + for (const { node, type, parentType, defaultValue, fragmentVariableDefinition, } of usages) { + const varName = node.name.value; + let varDef = fragmentVariableDefinition; + if (!varDef) { + varDef = varDefMap.get(varName); + } + if (varDef && type) { + // A var type is allowed if it is the same or more strict (e.g. is + // a subtype of) than the expected type. It can be more strict if + // the variable type is non-null when the expected type is nullable. + // If both are list types, the variable item type can be more strict + // than the expected item type (contravariant). + const schema = context.getSchema(); + const varType = typeFromAST(schema, varDef.type); + if (varType && + !allowedVariableUsage(schema, varType, varDef.defaultValue, type, defaultValue)) { + context.reportError(new GraphQLError(`Variable "$${varName}" of type "${varType}" used in position expecting type "${type}".`, { nodes: [varDef, node] })); + } + if (isInputObjectType(parentType) && + parentType.isOneOf && + isNullableType(varType)) { + context.reportError(new GraphQLError(`Variable "$${varName}" is of type "${varType}" but must be non-nullable to be used for OneOf Input Object "${parentType}".`, { nodes: [varDef, node] })); + } + } + } + }, + }, + VariableDefinition(node) { + varDefMap.set(node.variable.name.value, node); + }, + }; +} +/** + * Returns true if the variable is allowed in the location it was found, + * including considering if default values exist for either the variable + * or the location at which it is located. + * + * OneOf Input Object Type fields are considered separately above to + * provide a more descriptive error message. + */ +function allowedVariableUsage(schema, varType, varDefaultValue, locationType, locationDefaultValue) { + if (isNonNullType(locationType) && !isNonNullType(varType)) { + const hasNonNullVariableDefaultValue = varDefaultValue != null && varDefaultValue.kind !== Kind.NULL; + const hasLocationDefaultValue = locationDefaultValue !== undefined; + if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { + return false; + } + const nullableLocationType = locationType.ofType; + return isTypeSubTypeOf(schema, varType, nullableLocationType); + } + return isTypeSubTypeOf(schema, varType, locationType); +} +//# sourceMappingURL=VariablesInAllowedPositionRule.js.map \ No newline at end of file diff --git a/validation/rules/VariablesInAllowedPositionRule.mjs.map b/validation/rules/VariablesInAllowedPositionRule.mjs.map new file mode 100644 index 0000000000..59665aec94 --- /dev/null +++ b/validation/rules/VariablesInAllowedPositionRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"VariablesInAllowedPositionRule.js","sourceRoot":"","sources":["../../../src/validation/rules/VariablesInAllowedPositionRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAI/C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,kCAAiC;AAGlC,OAAO,EAAE,eAAe,EAAE,4CAA2C;AACrE,OAAO,EAAE,WAAW,EAAE,wCAAuC;AAI7D;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAA0B;IAE1B,IAAI,SAA8C,CAAC;IAEnD,OAAO;QACL,mBAAmB,EAAE;YACnB,KAAK;gBACH,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;YACxB,CAAC;YACD,KAAK,CAAC,SAAS;gBACb,MAAM,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;gBAE7D,KAAK,MAAM,EACT,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,0BAA0B,GAC3B,IAAI,MAAM,EAAE,CAAC;oBACZ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;oBAEhC,IAAI,MAAM,GAAG,0BAA0B,CAAC;oBACxC,IAAI,CAAC,MAAM,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EACzB,oBAA6B;IAE7B,IAAI,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3D,MAAM,8BAA8B,GAClC,eAAe,IAAI,IAAI,IAAI,eAAe,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;QAChE,MAAM,uBAAuB,GAAG,oBAAoB,KAAK,SAAS,CAAC;QACnE,IAAI,CAAC,8BAA8B,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAChE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,oBAAoB,GAAG,YAAY,CAAC,MAAM,CAAC;QACjD,OAAO,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { Maybe } from '../../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../../error/GraphQLError.js';\n\nimport type { ValueNode, VariableDefinitionNode } from '../../language/ast.js';\nimport { Kind } from '../../language/kinds.js';\nimport type { ASTVisitor } from '../../language/visitor.js';\n\nimport type { GraphQLType } from '../../type/definition.js';\nimport {\n isInputObjectType,\n isNonNullType,\n isNullableType,\n} from '../../type/definition.js';\nimport type { GraphQLSchema } from '../../type/schema.js';\n\nimport { isTypeSubTypeOf } from '../../utilities/typeComparators.js';\nimport { typeFromAST } from '../../utilities/typeFromAST.js';\n\nimport type { ValidationContext } from '../ValidationContext.js';\n\n/**\n * Variables in allowed position\n *\n * Variable usages must be compatible with the arguments they are passed to.\n *\n * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed\n */\nexport function VariablesInAllowedPositionRule(\n context: ValidationContext,\n): ASTVisitor {\n let varDefMap: Map;\n\n return {\n OperationDefinition: {\n enter() {\n varDefMap = new Map();\n },\n leave(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node,\n type,\n parentType,\n defaultValue,\n fragmentVariableDefinition,\n } of usages) {\n const varName = node.name.value;\n\n let varDef = fragmentVariableDefinition;\n if (!varDef) {\n varDef = varDefMap.get(varName);\n }\n if (varDef && type) {\n // A var type is allowed if it is the same or more strict (e.g. is\n // a subtype of) than the expected type. It can be more strict if\n // the variable type is non-null when the expected type is nullable.\n // If both are list types, the variable item type can be more strict\n // than the expected item type (contravariant).\n const schema = context.getSchema();\n const varType = typeFromAST(schema, varDef.type);\n if (\n varType &&\n !allowedVariableUsage(\n schema,\n varType,\n varDef.defaultValue,\n type,\n defaultValue,\n )\n ) {\n context.reportError(\n new GraphQLError(\n `Variable \"$${varName}\" of type \"${varType}\" used in position expecting type \"${type}\".`,\n { nodes: [varDef, node] },\n ),\n );\n }\n\n if (\n isInputObjectType(parentType) &&\n parentType.isOneOf &&\n isNullableType(varType)\n ) {\n context.reportError(\n new GraphQLError(\n `Variable \"$${varName}\" is of type \"${varType}\" but must be non-nullable to be used for OneOf Input Object \"${parentType}\".`,\n { nodes: [varDef, node] },\n ),\n );\n }\n }\n }\n },\n },\n VariableDefinition(node) {\n varDefMap.set(node.variable.name.value, node);\n },\n };\n}\n\n/**\n * Returns true if the variable is allowed in the location it was found,\n * including considering if default values exist for either the variable\n * or the location at which it is located.\n *\n * OneOf Input Object Type fields are considered separately above to\n * provide a more descriptive error message.\n */\nfunction allowedVariableUsage(\n schema: GraphQLSchema,\n varType: GraphQLType,\n varDefaultValue: Maybe,\n locationType: GraphQLType,\n locationDefaultValue: unknown,\n): boolean {\n if (isNonNullType(locationType) && !isNonNullType(varType)) {\n const hasNonNullVariableDefaultValue =\n varDefaultValue != null && varDefaultValue.kind !== Kind.NULL;\n const hasLocationDefaultValue = locationDefaultValue !== undefined;\n if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {\n return false;\n }\n const nullableLocationType = locationType.ofType;\n return isTypeSubTypeOf(schema, varType, nullableLocationType);\n }\n return isTypeSubTypeOf(schema, varType, locationType);\n}\n"]} \ No newline at end of file diff --git a/validation/rules/custom/NoDeprecatedCustomRule.d.ts b/validation/rules/custom/NoDeprecatedCustomRule.d.ts new file mode 100644 index 0000000000..2fb5636b3b --- /dev/null +++ b/validation/rules/custom/NoDeprecatedCustomRule.d.ts @@ -0,0 +1,13 @@ +import type { ASTVisitor } from '../../../language/visitor.js'; +import type { ValidationContext } from '../../ValidationContext.js'; +/** + * No deprecated + * + * A GraphQL document is only valid if all selected fields and all used enum values have not been + * deprecated. + * + * Note: This rule is optional and is not part of the Validation section of the GraphQL + * Specification. The main purpose of this rule is detection of deprecated usages and not + * necessarily to forbid their use when querying a service. + */ +export declare function NoDeprecatedCustomRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/custom/NoDeprecatedCustomRule.js b/validation/rules/custom/NoDeprecatedCustomRule.js new file mode 100644 index 0000000000..73024543e7 --- /dev/null +++ b/validation/rules/custom/NoDeprecatedCustomRule.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NoDeprecatedCustomRule = NoDeprecatedCustomRule; +const GraphQLError_js_1 = require("../../../error/GraphQLError.js"); +const definition_js_1 = require("../../../type/definition.js"); +/** + * No deprecated + * + * A GraphQL document is only valid if all selected fields and all used enum values have not been + * deprecated. + * + * Note: This rule is optional and is not part of the Validation section of the GraphQL + * Specification. The main purpose of this rule is detection of deprecated usages and not + * necessarily to forbid their use when querying a service. + */ +function NoDeprecatedCustomRule(context) { + return { + Field(node) { + const fieldDef = context.getFieldDef(); + const deprecationReason = fieldDef?.deprecationReason; + if (fieldDef && deprecationReason != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`The field ${fieldDef} is deprecated. ${deprecationReason}`, { nodes: node })); + } + }, + Argument(node) { + const argDef = context.getArgument(); + const deprecationReason = argDef?.deprecationReason; + if (argDef && deprecationReason != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`The argument "${argDef}" is deprecated. ${deprecationReason}`, { nodes: node })); + } + }, + ObjectField(node) { + const inputObjectDef = (0, definition_js_1.getNamedType)(context.getParentInputType()); + if ((0, definition_js_1.isInputObjectType)(inputObjectDef)) { + const inputFieldDef = inputObjectDef.getFields()[node.name.value]; + const deprecationReason = inputFieldDef?.deprecationReason; + if (deprecationReason != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`The input field ${inputFieldDef} is deprecated. ${deprecationReason}`, { nodes: node })); + } + } + }, + EnumValue(node) { + const enumValueDef = context.getEnumValue(); + const deprecationReason = enumValueDef?.deprecationReason; + if (enumValueDef && deprecationReason != null) { + context.reportError(new GraphQLError_js_1.GraphQLError(`The enum value "${enumValueDef}" is deprecated. ${deprecationReason}`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=NoDeprecatedCustomRule.js.map \ No newline at end of file diff --git a/validation/rules/custom/NoDeprecatedCustomRule.js.map b/validation/rules/custom/NoDeprecatedCustomRule.js.map new file mode 100644 index 0000000000..088a5468fb --- /dev/null +++ b/validation/rules/custom/NoDeprecatedCustomRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NoDeprecatedCustomRule.js","sourceRoot":"","sources":["../../../../src/validation/rules/custom/NoDeprecatedCustomRule.ts"],"names":[],"mappings":";;AAkBA,wDAsDC;AAxED,oEAA8D;AAI9D,+DAA8E;AAI9E;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CAAC,OAA0B;IAC/D,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,iBAAiB,GAAG,QAAQ,EAAE,iBAAiB,CAAC;YACtD,IAAI,QAAQ,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;gBAC1C,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,aAAa,QAAQ,mBAAmB,iBAAiB,EAAE,EAC3D,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,QAAQ,CAAC,IAAI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AAC","sourcesContent":["import { GraphQLError } from '../../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../../language/visitor.js';\n\nimport { getNamedType, isInputObjectType } from '../../../type/definition.js';\n\nimport type { ValidationContext } from '../../ValidationContext.js';\n\n/**\n * No deprecated\n *\n * A GraphQL document is only valid if all selected fields and all used enum values have not been\n * deprecated.\n *\n * Note: This rule is optional and is not part of the Validation section of the GraphQL\n * Specification. The main purpose of this rule is detection of deprecated usages and not\n * necessarily to forbid their use when querying a service.\n */\nexport function NoDeprecatedCustomRule(context: ValidationContext): ASTVisitor {\n return {\n Field(node) {\n const fieldDef = context.getFieldDef();\n const deprecationReason = fieldDef?.deprecationReason;\n if (fieldDef && deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The field ${fieldDef} is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n },\n Argument(node) {\n const argDef = context.getArgument();\n const deprecationReason = argDef?.deprecationReason;\n if (argDef && deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The argument \"${argDef}\" is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n },\n ObjectField(node) {\n const inputObjectDef = getNamedType(context.getParentInputType());\n if (isInputObjectType(inputObjectDef)) {\n const inputFieldDef = inputObjectDef.getFields()[node.name.value];\n const deprecationReason = inputFieldDef?.deprecationReason;\n if (deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The input field ${inputFieldDef} is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n }\n },\n EnumValue(node) {\n const enumValueDef = context.getEnumValue();\n const deprecationReason = enumValueDef?.deprecationReason;\n if (enumValueDef && deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The enum value \"${enumValueDef}\" is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/custom/NoDeprecatedCustomRule.mjs b/validation/rules/custom/NoDeprecatedCustomRule.mjs new file mode 100644 index 0000000000..1ab1a2a5bb --- /dev/null +++ b/validation/rules/custom/NoDeprecatedCustomRule.mjs @@ -0,0 +1,48 @@ +import { GraphQLError } from "../../../error/GraphQLError.mjs"; +import { getNamedType, isInputObjectType } from "../../../type/definition.mjs"; +/** + * No deprecated + * + * A GraphQL document is only valid if all selected fields and all used enum values have not been + * deprecated. + * + * Note: This rule is optional and is not part of the Validation section of the GraphQL + * Specification. The main purpose of this rule is detection of deprecated usages and not + * necessarily to forbid their use when querying a service. + */ +export function NoDeprecatedCustomRule(context) { + return { + Field(node) { + const fieldDef = context.getFieldDef(); + const deprecationReason = fieldDef?.deprecationReason; + if (fieldDef && deprecationReason != null) { + context.reportError(new GraphQLError(`The field ${fieldDef} is deprecated. ${deprecationReason}`, { nodes: node })); + } + }, + Argument(node) { + const argDef = context.getArgument(); + const deprecationReason = argDef?.deprecationReason; + if (argDef && deprecationReason != null) { + context.reportError(new GraphQLError(`The argument "${argDef}" is deprecated. ${deprecationReason}`, { nodes: node })); + } + }, + ObjectField(node) { + const inputObjectDef = getNamedType(context.getParentInputType()); + if (isInputObjectType(inputObjectDef)) { + const inputFieldDef = inputObjectDef.getFields()[node.name.value]; + const deprecationReason = inputFieldDef?.deprecationReason; + if (deprecationReason != null) { + context.reportError(new GraphQLError(`The input field ${inputFieldDef} is deprecated. ${deprecationReason}`, { nodes: node })); + } + } + }, + EnumValue(node) { + const enumValueDef = context.getEnumValue(); + const deprecationReason = enumValueDef?.deprecationReason; + if (enumValueDef && deprecationReason != null) { + context.reportError(new GraphQLError(`The enum value "${enumValueDef}" is deprecated. ${deprecationReason}`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=NoDeprecatedCustomRule.js.map \ No newline at end of file diff --git a/validation/rules/custom/NoDeprecatedCustomRule.mjs.map b/validation/rules/custom/NoDeprecatedCustomRule.mjs.map new file mode 100644 index 0000000000..039219b091 --- /dev/null +++ b/validation/rules/custom/NoDeprecatedCustomRule.mjs.map @@ -0,0 +1 @@ +{"version":3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aAAa,EAAE,iBAAiB,CAAC;gBAC3D,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;oBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,mBAAmB,aAAa,mBAAmB,iBAAiB,EAAE,EACtE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,SAAS,CAAC,IAAI;YACZ,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YAC5C,MAAM,iBAAiB,GAAG,YAAY,EAAE,iBAAiB,CAAC;YAC1D,IAAI,YAAY,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;gBAC9C,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,mBAAmB,YAAY,oBAAoB,iBAAiB,EAAE,EACtE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../../error/GraphQLError.js';\n\nimport type { ASTVisitor } from '../../../language/visitor.js';\n\nimport { getNamedType, isInputObjectType } from '../../../type/definition.js';\n\nimport type { ValidationContext } from '../../ValidationContext.js';\n\n/**\n * No deprecated\n *\n * A GraphQL document is only valid if all selected fields and all used enum values have not been\n * deprecated.\n *\n * Note: This rule is optional and is not part of the Validation section of the GraphQL\n * Specification. The main purpose of this rule is detection of deprecated usages and not\n * necessarily to forbid their use when querying a service.\n */\nexport function NoDeprecatedCustomRule(context: ValidationContext): ASTVisitor {\n return {\n Field(node) {\n const fieldDef = context.getFieldDef();\n const deprecationReason = fieldDef?.deprecationReason;\n if (fieldDef && deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The field ${fieldDef} is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n },\n Argument(node) {\n const argDef = context.getArgument();\n const deprecationReason = argDef?.deprecationReason;\n if (argDef && deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The argument \"${argDef}\" is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n },\n ObjectField(node) {\n const inputObjectDef = getNamedType(context.getParentInputType());\n if (isInputObjectType(inputObjectDef)) {\n const inputFieldDef = inputObjectDef.getFields()[node.name.value];\n const deprecationReason = inputFieldDef?.deprecationReason;\n if (deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The input field ${inputFieldDef} is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n }\n },\n EnumValue(node) {\n const enumValueDef = context.getEnumValue();\n const deprecationReason = enumValueDef?.deprecationReason;\n if (enumValueDef && deprecationReason != null) {\n context.reportError(\n new GraphQLError(\n `The enum value \"${enumValueDef}\" is deprecated. ${deprecationReason}`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts b/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts new file mode 100644 index 0000000000..02d9fb8a59 --- /dev/null +++ b/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts @@ -0,0 +1,13 @@ +import type { ASTVisitor } from '../../../language/visitor.js'; +import type { ValidationContext } from '../../ValidationContext.js'; +/** + * Prohibit introspection queries + * + * A GraphQL document is only valid if all fields selected are not fields that + * return an introspection type. + * + * Note: This rule is optional and is not part of the Validation section of the + * GraphQL Specification. This rule effectively disables introspection, which + * does not reflect best practices and should only be done if absolutely necessary. + */ +export declare function NoSchemaIntrospectionCustomRule(context: ValidationContext): ASTVisitor; diff --git a/validation/rules/custom/NoSchemaIntrospectionCustomRule.js b/validation/rules/custom/NoSchemaIntrospectionCustomRule.js new file mode 100644 index 0000000000..a143c8fd5b --- /dev/null +++ b/validation/rules/custom/NoSchemaIntrospectionCustomRule.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NoSchemaIntrospectionCustomRule = NoSchemaIntrospectionCustomRule; +const GraphQLError_js_1 = require("../../../error/GraphQLError.js"); +const definition_js_1 = require("../../../type/definition.js"); +const introspection_js_1 = require("../../../type/introspection.js"); +/** + * Prohibit introspection queries + * + * A GraphQL document is only valid if all fields selected are not fields that + * return an introspection type. + * + * Note: This rule is optional and is not part of the Validation section of the + * GraphQL Specification. This rule effectively disables introspection, which + * does not reflect best practices and should only be done if absolutely necessary. + */ +function NoSchemaIntrospectionCustomRule(context) { + return { + Field(node) { + const type = (0, definition_js_1.getNamedType)(context.getType()); + if (type && (0, introspection_js_1.isIntrospectionType)(type)) { + context.reportError(new GraphQLError_js_1.GraphQLError(`GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=NoSchemaIntrospectionCustomRule.js.map \ No newline at end of file diff --git a/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map b/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map new file mode 100644 index 0000000000..e257abf814 --- /dev/null +++ b/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NoSchemaIntrospectionCustomRule.js","sourceRoot":"","sources":["../../../../src/validation/rules/custom/NoSchemaIntrospectionCustomRule.ts"],"names":[],"mappings":";;AAoBA,0EAgBC;AApCD,oEAA8D;AAK9D,+DAA2D;AAC3D,qEAAqE;AAIrE;;;;;;;;;GASG;AACH,SAAgB,+BAA+B,CAC7C,OAA0B;IAE1B,OAAO;QACL,KAAK,CAAC,IAAe;YACnB,MAAM,IAAI,GAAG,IAAA,4BAAY,EAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7C,IAAI,IAAI,IAAI,IAAA,sCAAmB,EAAC,IAAI,CAAC,EAAE,CAAC;gBACtC,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,yFAAyF,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAC5G,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../../error/GraphQLError.js';\n\nimport type { FieldNode } from '../../../language/ast.js';\nimport type { ASTVisitor } from '../../../language/visitor.js';\n\nimport { getNamedType } from '../../../type/definition.js';\nimport { isIntrospectionType } from '../../../type/introspection.js';\n\nimport type { ValidationContext } from '../../ValidationContext.js';\n\n/**\n * Prohibit introspection queries\n *\n * A GraphQL document is only valid if all fields selected are not fields that\n * return an introspection type.\n *\n * Note: This rule is optional and is not part of the Validation section of the\n * GraphQL Specification. This rule effectively disables introspection, which\n * does not reflect best practices and should only be done if absolutely necessary.\n */\nexport function NoSchemaIntrospectionCustomRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Field(node: FieldNode) {\n const type = getNamedType(context.getType());\n if (type && isIntrospectionType(type)) {\n context.reportError(\n new GraphQLError(\n `GraphQL introspection has been disabled, but the requested query contained the field \"${node.name.value}\".`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs b/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs new file mode 100644 index 0000000000..1c508b3e04 --- /dev/null +++ b/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs @@ -0,0 +1,24 @@ +import { GraphQLError } from "../../../error/GraphQLError.mjs"; +import { getNamedType } from "../../../type/definition.mjs"; +import { isIntrospectionType } from "../../../type/introspection.mjs"; +/** + * Prohibit introspection queries + * + * A GraphQL document is only valid if all fields selected are not fields that + * return an introspection type. + * + * Note: This rule is optional and is not part of the Validation section of the + * GraphQL Specification. This rule effectively disables introspection, which + * does not reflect best practices and should only be done if absolutely necessary. + */ +export function NoSchemaIntrospectionCustomRule(context) { + return { + Field(node) { + const type = getNamedType(context.getType()); + if (type && isIntrospectionType(type)) { + context.reportError(new GraphQLError(`GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, { nodes: node })); + } + }, + }; +} +//# sourceMappingURL=NoSchemaIntrospectionCustomRule.js.map \ No newline at end of file diff --git a/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map b/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map new file mode 100644 index 0000000000..07702a6bc1 --- /dev/null +++ b/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"NoSchemaIntrospectionCustomRule.js","sourceRoot":"","sources":["../../../../src/validation/rules/custom/NoSchemaIntrospectionCustomRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,wCAAuC;AAK9D,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,wCAAuC;AAIrE;;;;;;;;;GASG;AACH,MAAM,UAAU,+BAA+B,CAC7C,OAA0B;IAE1B,OAAO;QACL,KAAK,CAAC,IAAe;YACnB,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7C,IAAI,IAAI,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtC,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yFAAyF,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAC5G,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { GraphQLError } from '../../../error/GraphQLError.js';\n\nimport type { FieldNode } from '../../../language/ast.js';\nimport type { ASTVisitor } from '../../../language/visitor.js';\n\nimport { getNamedType } from '../../../type/definition.js';\nimport { isIntrospectionType } from '../../../type/introspection.js';\n\nimport type { ValidationContext } from '../../ValidationContext.js';\n\n/**\n * Prohibit introspection queries\n *\n * A GraphQL document is only valid if all fields selected are not fields that\n * return an introspection type.\n *\n * Note: This rule is optional and is not part of the Validation section of the\n * GraphQL Specification. This rule effectively disables introspection, which\n * does not reflect best practices and should only be done if absolutely necessary.\n */\nexport function NoSchemaIntrospectionCustomRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n Field(node: FieldNode) {\n const type = getNamedType(context.getType());\n if (type && isIntrospectionType(type)) {\n context.reportError(\n new GraphQLError(\n `GraphQL introspection has been disabled, but the requested query contained the field \"${node.name.value}\".`,\n { nodes: node },\n ),\n );\n }\n },\n };\n}\n"]} \ No newline at end of file diff --git a/validation/specifiedRules.d.ts b/validation/specifiedRules.d.ts new file mode 100644 index 0000000000..708225d20f --- /dev/null +++ b/validation/specifiedRules.d.ts @@ -0,0 +1,18 @@ +import { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule.js'; +import type { SDLValidationRule, ValidationRule } from './ValidationContext.js'; +/** + * Technically these aren't part of the spec but they are strongly encouraged + * validation rules. + */ +export declare const recommendedRules: readonly (typeof MaxIntrospectionDepthRule)[]; +/** + * This set includes all validation rules defined by the GraphQL spec. + * + * The order of the rules in this list has been adjusted to lead to the + * most clear output when encountering multiple validation errors. + */ +export declare const specifiedRules: ReadonlyArray; +/** + * @internal + */ +export declare const specifiedSDLRules: ReadonlyArray; diff --git a/validation/specifiedRules.js b/validation/specifiedRules.js new file mode 100644 index 0000000000..8d85bbbd20 --- /dev/null +++ b/validation/specifiedRules.js @@ -0,0 +1,142 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.specifiedSDLRules = exports.specifiedRules = exports.recommendedRules = void 0; +// Spec Section: "Defer And Stream Directive Labels Are Unique" +const DeferStreamDirectiveLabelRule_js_1 = require("./rules/DeferStreamDirectiveLabelRule.js"); +// Spec Section: "Defer And Stream Directives Are Used On Valid Root Field" +const DeferStreamDirectiveOnRootFieldRule_js_1 = require("./rules/DeferStreamDirectiveOnRootFieldRule.js"); +// Spec Section: "Defer And Stream Directives Are Used On Valid Operations" +const DeferStreamDirectiveOnValidOperationsRule_js_1 = require("./rules/DeferStreamDirectiveOnValidOperationsRule.js"); +// Spec Section: "Executable Definitions" +const ExecutableDefinitionsRule_js_1 = require("./rules/ExecutableDefinitionsRule.js"); +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +const FieldsOnCorrectTypeRule_js_1 = require("./rules/FieldsOnCorrectTypeRule.js"); +// Spec Section: "Fragments on Composite Types" +const FragmentsOnCompositeTypesRule_js_1 = require("./rules/FragmentsOnCompositeTypesRule.js"); +// Spec Section: "Argument Names" +const KnownArgumentNamesRule_js_1 = require("./rules/KnownArgumentNamesRule.js"); +// Spec Section: "Directives Are Defined" +const KnownDirectivesRule_js_1 = require("./rules/KnownDirectivesRule.js"); +// Spec Section: "Fragment spread target defined" +const KnownFragmentNamesRule_js_1 = require("./rules/KnownFragmentNamesRule.js"); +// Spec Section: "Operation Type Existence" +const KnownOperationTypesRule_js_1 = require("./rules/KnownOperationTypesRule.js"); +// Spec Section: "Fragment Spread Type Existence" +const KnownTypeNamesRule_js_1 = require("./rules/KnownTypeNamesRule.js"); +// Spec Section: "Lone Anonymous Operation" +const LoneAnonymousOperationRule_js_1 = require("./rules/LoneAnonymousOperationRule.js"); +// SDL-specific validation rules +const LoneSchemaDefinitionRule_js_1 = require("./rules/LoneSchemaDefinitionRule.js"); +// TODO: Spec Section +const MaxIntrospectionDepthRule_js_1 = require("./rules/MaxIntrospectionDepthRule.js"); +// Spec Section: "Fragments must not form cycles" +const NoFragmentCyclesRule_js_1 = require("./rules/NoFragmentCyclesRule.js"); +// Spec Section: "All Variable Used Defined" +const NoUndefinedVariablesRule_js_1 = require("./rules/NoUndefinedVariablesRule.js"); +// Spec Section: "Fragments must be used" +const NoUnusedFragmentsRule_js_1 = require("./rules/NoUnusedFragmentsRule.js"); +// Spec Section: "All Variables Used" +const NoUnusedVariablesRule_js_1 = require("./rules/NoUnusedVariablesRule.js"); +// Spec Section: "Field Selection Merging" +const OverlappingFieldsCanBeMergedRule_js_1 = require("./rules/OverlappingFieldsCanBeMergedRule.js"); +// Spec Section: "Fragment spread is possible" +const PossibleFragmentSpreadsRule_js_1 = require("./rules/PossibleFragmentSpreadsRule.js"); +const PossibleTypeExtensionsRule_js_1 = require("./rules/PossibleTypeExtensionsRule.js"); +// Spec Section: "Argument Optionality" +const ProvidedRequiredArgumentsRule_js_1 = require("./rules/ProvidedRequiredArgumentsRule.js"); +// Spec Section: "Leaf Field Selections" +const ScalarLeafsRule_js_1 = require("./rules/ScalarLeafsRule.js"); +// Spec Section: "Subscriptions with Single Root Field" +const SingleFieldSubscriptionsRule_js_1 = require("./rules/SingleFieldSubscriptionsRule.js"); +// Spec Section: "Stream Directives Are Used On List Fields" +const StreamDirectiveOnListFieldRule_js_1 = require("./rules/StreamDirectiveOnListFieldRule.js"); +const UniqueArgumentDefinitionNamesRule_js_1 = require("./rules/UniqueArgumentDefinitionNamesRule.js"); +// Spec Section: "Argument Uniqueness" +const UniqueArgumentNamesRule_js_1 = require("./rules/UniqueArgumentNamesRule.js"); +const UniqueDirectiveNamesRule_js_1 = require("./rules/UniqueDirectiveNamesRule.js"); +// Spec Section: "Directives Are Unique Per Location" +const UniqueDirectivesPerLocationRule_js_1 = require("./rules/UniqueDirectivesPerLocationRule.js"); +const UniqueEnumValueNamesRule_js_1 = require("./rules/UniqueEnumValueNamesRule.js"); +const UniqueFieldDefinitionNamesRule_js_1 = require("./rules/UniqueFieldDefinitionNamesRule.js"); +// Spec Section: "Fragment Name Uniqueness" +const UniqueFragmentNamesRule_js_1 = require("./rules/UniqueFragmentNamesRule.js"); +// Spec Section: "Input Object Field Uniqueness" +const UniqueInputFieldNamesRule_js_1 = require("./rules/UniqueInputFieldNamesRule.js"); +// Spec Section: "Operation Name Uniqueness" +const UniqueOperationNamesRule_js_1 = require("./rules/UniqueOperationNamesRule.js"); +const UniqueOperationTypesRule_js_1 = require("./rules/UniqueOperationTypesRule.js"); +const UniqueTypeNamesRule_js_1 = require("./rules/UniqueTypeNamesRule.js"); +// Spec Section: "Variable Uniqueness" +const UniqueVariableNamesRule_js_1 = require("./rules/UniqueVariableNamesRule.js"); +// Spec Section: "Value Type Correctness" +const ValuesOfCorrectTypeRule_js_1 = require("./rules/ValuesOfCorrectTypeRule.js"); +// Spec Section: "Variables are Input Types" +const VariablesAreInputTypesRule_js_1 = require("./rules/VariablesAreInputTypesRule.js"); +// Spec Section: "All Variable Usages Are Allowed" +const VariablesInAllowedPositionRule_js_1 = require("./rules/VariablesInAllowedPositionRule.js"); +/** + * Technically these aren't part of the spec but they are strongly encouraged + * validation rules. + */ +exports.recommendedRules = Object.freeze([MaxIntrospectionDepthRule_js_1.MaxIntrospectionDepthRule]); +/** + * This set includes all validation rules defined by the GraphQL spec. + * + * The order of the rules in this list has been adjusted to lead to the + * most clear output when encountering multiple validation errors. + */ +exports.specifiedRules = Object.freeze([ + ExecutableDefinitionsRule_js_1.ExecutableDefinitionsRule, + KnownOperationTypesRule_js_1.KnownOperationTypesRule, + UniqueOperationNamesRule_js_1.UniqueOperationNamesRule, + LoneAnonymousOperationRule_js_1.LoneAnonymousOperationRule, + SingleFieldSubscriptionsRule_js_1.SingleFieldSubscriptionsRule, + KnownTypeNamesRule_js_1.KnownTypeNamesRule, + FragmentsOnCompositeTypesRule_js_1.FragmentsOnCompositeTypesRule, + VariablesAreInputTypesRule_js_1.VariablesAreInputTypesRule, + ScalarLeafsRule_js_1.ScalarLeafsRule, + FieldsOnCorrectTypeRule_js_1.FieldsOnCorrectTypeRule, + UniqueFragmentNamesRule_js_1.UniqueFragmentNamesRule, + KnownFragmentNamesRule_js_1.KnownFragmentNamesRule, + NoUnusedFragmentsRule_js_1.NoUnusedFragmentsRule, + PossibleFragmentSpreadsRule_js_1.PossibleFragmentSpreadsRule, + NoFragmentCyclesRule_js_1.NoFragmentCyclesRule, + UniqueVariableNamesRule_js_1.UniqueVariableNamesRule, + NoUndefinedVariablesRule_js_1.NoUndefinedVariablesRule, + NoUnusedVariablesRule_js_1.NoUnusedVariablesRule, + KnownDirectivesRule_js_1.KnownDirectivesRule, + UniqueDirectivesPerLocationRule_js_1.UniqueDirectivesPerLocationRule, + DeferStreamDirectiveOnRootFieldRule_js_1.DeferStreamDirectiveOnRootFieldRule, + DeferStreamDirectiveOnValidOperationsRule_js_1.DeferStreamDirectiveOnValidOperationsRule, + DeferStreamDirectiveLabelRule_js_1.DeferStreamDirectiveLabelRule, + StreamDirectiveOnListFieldRule_js_1.StreamDirectiveOnListFieldRule, + KnownArgumentNamesRule_js_1.KnownArgumentNamesRule, + UniqueArgumentNamesRule_js_1.UniqueArgumentNamesRule, + ValuesOfCorrectTypeRule_js_1.ValuesOfCorrectTypeRule, + ProvidedRequiredArgumentsRule_js_1.ProvidedRequiredArgumentsRule, + VariablesInAllowedPositionRule_js_1.VariablesInAllowedPositionRule, + OverlappingFieldsCanBeMergedRule_js_1.OverlappingFieldsCanBeMergedRule, + UniqueInputFieldNamesRule_js_1.UniqueInputFieldNamesRule, + ...exports.recommendedRules, +]); +/** + * @internal + */ +exports.specifiedSDLRules = Object.freeze([ + LoneSchemaDefinitionRule_js_1.LoneSchemaDefinitionRule, + UniqueOperationTypesRule_js_1.UniqueOperationTypesRule, + UniqueTypeNamesRule_js_1.UniqueTypeNamesRule, + UniqueEnumValueNamesRule_js_1.UniqueEnumValueNamesRule, + UniqueFieldDefinitionNamesRule_js_1.UniqueFieldDefinitionNamesRule, + UniqueArgumentDefinitionNamesRule_js_1.UniqueArgumentDefinitionNamesRule, + UniqueDirectiveNamesRule_js_1.UniqueDirectiveNamesRule, + KnownTypeNamesRule_js_1.KnownTypeNamesRule, + KnownDirectivesRule_js_1.KnownDirectivesRule, + UniqueDirectivesPerLocationRule_js_1.UniqueDirectivesPerLocationRule, + PossibleTypeExtensionsRule_js_1.PossibleTypeExtensionsRule, + KnownArgumentNamesRule_js_1.KnownArgumentNamesOnDirectivesRule, + UniqueArgumentNamesRule_js_1.UniqueArgumentNamesRule, + UniqueInputFieldNamesRule_js_1.UniqueInputFieldNamesRule, + ProvidedRequiredArgumentsRule_js_1.ProvidedRequiredArgumentsOnDirectivesRule, +]); +//# sourceMappingURL=specifiedRules.js.map \ No newline at end of file diff --git a/validation/specifiedRules.js.map b/validation/specifiedRules.js.map new file mode 100644 index 0000000000..8c9e402295 --- /dev/null +++ b/validation/specifiedRules.js.map @@ -0,0 +1 @@ +{"version":3,"file":"specifiedRules.js","sourceRoot":"","sources":["../../src/validation/specifiedRules.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAC/D,+FAAyF;AACzF,2EAA2E;AAC3E,2GAAqG;AACrG,2EAA2E;AAC3E,uHAAiH;AACjH,yCAAyC;AACzC,uFAAiF;AACjF,4EAA4E;AAC5E,mFAA6E;AAC7E,+CAA+C;AAC/C,+FAAyF;AACzF,iCAAiC;AACjC,iFAG2C;AAC3C,yCAAyC;AACzC,2EAAqE;AACrE,iDAAiD;AACjD,iFAA2E;AAC3E,2CAA2C;AAC3C,mFAA6E;AAC7E,iDAAiD;AACjD,yEAAmE;AACnE,2CAA2C;AAC3C,yFAAmF;AACnF,gCAAgC;AAChC,qFAA+E;AAC/E,qBAAqB;AACrB,uFAAiF;AACjF,iDAAiD;AACjD,6EAAuE;AACvE,4CAA4C;AAC5C,qFAA+E;AAC/E,yCAAyC;AACzC,+EAAyE;AACzE,qCAAqC;AACrC,+EAAyE;AACzE,0CAA0C;AAC1C,qGAA+F;AAC/F,8CAA8C;AAC9C,2FAAqF;AACrF,yFAAmF;AACnF,uCAAuC;AACvC,+FAGkD;AAClD,wCAAwC;AACxC,mEAA6D;AAC7D,uDAAuD;AACvD,6FAAuF;AACvF,4DAA4D;AAC5D,iGAA2F;AAC3F,uGAAiG;AACjG,sCAAsC;AACtC,mFAA6E;AAC7E,qFAA+E;AAC/E,qDAAqD;AACrD,mGAA6F;AAC7F,qFAA+E;AAC/E,iGAA2F;AAC3F,2CAA2C;AAC3C,mFAA6E;AAC7E,gDAAgD;AAChD,uFAAiF;AACjF,4CAA4C;AAC5C,qFAA+E;AAC/E,qFAA+E;AAC/E,2EAAqE;AACrE,sCAAsC;AACtC,mFAA6E;AAC7E,yCAAyC;AACzC,mFAA6E;AAC7E,4CAA4C;AAC5C,yFAAmF;AACnF,kDAAkD;AAClD,iGAA2F;AAG3F;;;GAGG;AACU,QAAA,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,wDAAyB,CAAC,CAAC,CAAC;AAE3E;;;;;GAKG;AACU,QAAA,cAAc,GAAkC,MAAM,CAAC,MAAM,CAAC;IACzE,wDAAyB;IACzB,oDAAuB;IACvB,sDAAwB;IACxB,0DAA0B;IAC1B,8DAA4B;IAC5B,0CAAkB;IAClB,gEAA6B;IAC7B,0DAA0B;IAC1B,oCAAe;IACf,oDAAuB;IACvB,oDAAuB;IACvB,kDAAsB;IACtB,gDAAqB;IACrB,4DAA2B;IAC3B,8CAAoB;IACpB,oDAAuB;IACvB,sDAAwB;IACxB,gDAAqB;IACrB,4CAAmB;IACnB,oEAA+B;IAC/B,4EAAmC;IACnC,wFAAyC;IACzC,gEAA6B;IAC7B,kEAA8B;IAC9B,kDAAsB;IACtB,oDAAuB;IACvB,oDAAuB;IACvB,gEAA6B;IAC7B,kEAA8B;IAC9B,sEAAgC;IAChC,wDAAyB;IACzB,GAAG,wBAAgB;CACpB,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,iBAAiB,GAC5B,MAAM,CAAC,MAAM,CAAC;IACZ,sDAAwB;IACxB,sDAAwB;IACxB,4CAAmB;IACnB,sDAAwB;IACxB,kEAA8B;IAC9B,wEAAiC;IACjC,sDAAwB;IACxB,0CAAkB;IAClB,4CAAmB;IACnB,oEAA+B;IAC/B,0DAA0B;IAC1B,8DAAkC;IAClC,oDAAuB;IACvB,wDAAyB;IACzB,4EAAyC;CAC1C,CAAC,CAAC","sourcesContent":["// Spec Section: \"Defer And Stream Directive Labels Are Unique\"\nimport { DeferStreamDirectiveLabelRule } from './rules/DeferStreamDirectiveLabelRule.js';\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Root Field\"\nimport { DeferStreamDirectiveOnRootFieldRule } from './rules/DeferStreamDirectiveOnRootFieldRule.js';\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Operations\"\nimport { DeferStreamDirectiveOnValidOperationsRule } from './rules/DeferStreamDirectiveOnValidOperationsRule.js';\n// Spec Section: \"Executable Definitions\"\nimport { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule.js';\n// Spec Section: \"Field Selections on Objects, Interfaces, and Unions Types\"\nimport { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule.js';\n// Spec Section: \"Fragments on Composite Types\"\nimport { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule.js';\n// Spec Section: \"Argument Names\"\nimport {\n KnownArgumentNamesOnDirectivesRule,\n KnownArgumentNamesRule,\n} from './rules/KnownArgumentNamesRule.js';\n// Spec Section: \"Directives Are Defined\"\nimport { KnownDirectivesRule } from './rules/KnownDirectivesRule.js';\n// Spec Section: \"Fragment spread target defined\"\nimport { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule.js';\n// Spec Section: \"Operation Type Existence\"\nimport { KnownOperationTypesRule } from './rules/KnownOperationTypesRule.js';\n// Spec Section: \"Fragment Spread Type Existence\"\nimport { KnownTypeNamesRule } from './rules/KnownTypeNamesRule.js';\n// Spec Section: \"Lone Anonymous Operation\"\nimport { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule.js';\n// SDL-specific validation rules\nimport { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule.js';\n// TODO: Spec Section\nimport { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule.js';\n// Spec Section: \"Fragments must not form cycles\"\nimport { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule.js';\n// Spec Section: \"All Variable Used Defined\"\nimport { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule.js';\n// Spec Section: \"Fragments must be used\"\nimport { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule.js';\n// Spec Section: \"All Variables Used\"\nimport { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule.js';\n// Spec Section: \"Field Selection Merging\"\nimport { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule.js';\n// Spec Section: \"Fragment spread is possible\"\nimport { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule.js';\nimport { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule.js';\n// Spec Section: \"Argument Optionality\"\nimport {\n ProvidedRequiredArgumentsOnDirectivesRule,\n ProvidedRequiredArgumentsRule,\n} from './rules/ProvidedRequiredArgumentsRule.js';\n// Spec Section: \"Leaf Field Selections\"\nimport { ScalarLeafsRule } from './rules/ScalarLeafsRule.js';\n// Spec Section: \"Subscriptions with Single Root Field\"\nimport { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule.js';\n// Spec Section: \"Stream Directives Are Used On List Fields\"\nimport { StreamDirectiveOnListFieldRule } from './rules/StreamDirectiveOnListFieldRule.js';\nimport { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule.js';\n// Spec Section: \"Argument Uniqueness\"\nimport { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule.js';\nimport { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule.js';\n// Spec Section: \"Directives Are Unique Per Location\"\nimport { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule.js';\nimport { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule.js';\nimport { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule.js';\n// Spec Section: \"Fragment Name Uniqueness\"\nimport { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule.js';\n// Spec Section: \"Input Object Field Uniqueness\"\nimport { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule.js';\n// Spec Section: \"Operation Name Uniqueness\"\nimport { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule.js';\nimport { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule.js';\nimport { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule.js';\n// Spec Section: \"Variable Uniqueness\"\nimport { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule.js';\n// Spec Section: \"Value Type Correctness\"\nimport { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule.js';\n// Spec Section: \"Variables are Input Types\"\nimport { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule.js';\n// Spec Section: \"All Variable Usages Are Allowed\"\nimport { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule.js';\nimport type { SDLValidationRule, ValidationRule } from './ValidationContext.js';\n\n/**\n * Technically these aren't part of the spec but they are strongly encouraged\n * validation rules.\n */\nexport const recommendedRules = Object.freeze([MaxIntrospectionDepthRule]);\n\n/**\n * This set includes all validation rules defined by the GraphQL spec.\n *\n * The order of the rules in this list has been adjusted to lead to the\n * most clear output when encountering multiple validation errors.\n */\nexport const specifiedRules: ReadonlyArray = Object.freeze([\n ExecutableDefinitionsRule,\n KnownOperationTypesRule,\n UniqueOperationNamesRule,\n LoneAnonymousOperationRule,\n SingleFieldSubscriptionsRule,\n KnownTypeNamesRule,\n FragmentsOnCompositeTypesRule,\n VariablesAreInputTypesRule,\n ScalarLeafsRule,\n FieldsOnCorrectTypeRule,\n UniqueFragmentNamesRule,\n KnownFragmentNamesRule,\n NoUnusedFragmentsRule,\n PossibleFragmentSpreadsRule,\n NoFragmentCyclesRule,\n UniqueVariableNamesRule,\n NoUndefinedVariablesRule,\n NoUnusedVariablesRule,\n KnownDirectivesRule,\n UniqueDirectivesPerLocationRule,\n DeferStreamDirectiveOnRootFieldRule,\n DeferStreamDirectiveOnValidOperationsRule,\n DeferStreamDirectiveLabelRule,\n StreamDirectiveOnListFieldRule,\n KnownArgumentNamesRule,\n UniqueArgumentNamesRule,\n ValuesOfCorrectTypeRule,\n ProvidedRequiredArgumentsRule,\n VariablesInAllowedPositionRule,\n OverlappingFieldsCanBeMergedRule,\n UniqueInputFieldNamesRule,\n ...recommendedRules,\n]);\n\n/**\n * @internal\n */\nexport const specifiedSDLRules: ReadonlyArray =\n Object.freeze([\n LoneSchemaDefinitionRule,\n UniqueOperationTypesRule,\n UniqueTypeNamesRule,\n UniqueEnumValueNamesRule,\n UniqueFieldDefinitionNamesRule,\n UniqueArgumentDefinitionNamesRule,\n UniqueDirectiveNamesRule,\n KnownTypeNamesRule,\n KnownDirectivesRule,\n UniqueDirectivesPerLocationRule,\n PossibleTypeExtensionsRule,\n KnownArgumentNamesOnDirectivesRule,\n UniqueArgumentNamesRule,\n UniqueInputFieldNamesRule,\n ProvidedRequiredArgumentsOnDirectivesRule,\n ]);\n"]} \ No newline at end of file diff --git a/validation/specifiedRules.mjs b/validation/specifiedRules.mjs new file mode 100644 index 0000000000..e27f2ffa0b --- /dev/null +++ b/validation/specifiedRules.mjs @@ -0,0 +1,139 @@ +// Spec Section: "Defer And Stream Directive Labels Are Unique" +import { DeferStreamDirectiveLabelRule } from "./rules/DeferStreamDirectiveLabelRule.mjs"; +// Spec Section: "Defer And Stream Directives Are Used On Valid Root Field" +import { DeferStreamDirectiveOnRootFieldRule } from "./rules/DeferStreamDirectiveOnRootFieldRule.mjs"; +// Spec Section: "Defer And Stream Directives Are Used On Valid Operations" +import { DeferStreamDirectiveOnValidOperationsRule } from "./rules/DeferStreamDirectiveOnValidOperationsRule.mjs"; +// Spec Section: "Executable Definitions" +import { ExecutableDefinitionsRule } from "./rules/ExecutableDefinitionsRule.mjs"; +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +import { FieldsOnCorrectTypeRule } from "./rules/FieldsOnCorrectTypeRule.mjs"; +// Spec Section: "Fragments on Composite Types" +import { FragmentsOnCompositeTypesRule } from "./rules/FragmentsOnCompositeTypesRule.mjs"; +// Spec Section: "Argument Names" +import { KnownArgumentNamesOnDirectivesRule, KnownArgumentNamesRule, } from "./rules/KnownArgumentNamesRule.mjs"; +// Spec Section: "Directives Are Defined" +import { KnownDirectivesRule } from "./rules/KnownDirectivesRule.mjs"; +// Spec Section: "Fragment spread target defined" +import { KnownFragmentNamesRule } from "./rules/KnownFragmentNamesRule.mjs"; +// Spec Section: "Operation Type Existence" +import { KnownOperationTypesRule } from "./rules/KnownOperationTypesRule.mjs"; +// Spec Section: "Fragment Spread Type Existence" +import { KnownTypeNamesRule } from "./rules/KnownTypeNamesRule.mjs"; +// Spec Section: "Lone Anonymous Operation" +import { LoneAnonymousOperationRule } from "./rules/LoneAnonymousOperationRule.mjs"; +// SDL-specific validation rules +import { LoneSchemaDefinitionRule } from "./rules/LoneSchemaDefinitionRule.mjs"; +// TODO: Spec Section +import { MaxIntrospectionDepthRule } from "./rules/MaxIntrospectionDepthRule.mjs"; +// Spec Section: "Fragments must not form cycles" +import { NoFragmentCyclesRule } from "./rules/NoFragmentCyclesRule.mjs"; +// Spec Section: "All Variable Used Defined" +import { NoUndefinedVariablesRule } from "./rules/NoUndefinedVariablesRule.mjs"; +// Spec Section: "Fragments must be used" +import { NoUnusedFragmentsRule } from "./rules/NoUnusedFragmentsRule.mjs"; +// Spec Section: "All Variables Used" +import { NoUnusedVariablesRule } from "./rules/NoUnusedVariablesRule.mjs"; +// Spec Section: "Field Selection Merging" +import { OverlappingFieldsCanBeMergedRule } from "./rules/OverlappingFieldsCanBeMergedRule.mjs"; +// Spec Section: "Fragment spread is possible" +import { PossibleFragmentSpreadsRule } from "./rules/PossibleFragmentSpreadsRule.mjs"; +import { PossibleTypeExtensionsRule } from "./rules/PossibleTypeExtensionsRule.mjs"; +// Spec Section: "Argument Optionality" +import { ProvidedRequiredArgumentsOnDirectivesRule, ProvidedRequiredArgumentsRule, } from "./rules/ProvidedRequiredArgumentsRule.mjs"; +// Spec Section: "Leaf Field Selections" +import { ScalarLeafsRule } from "./rules/ScalarLeafsRule.mjs"; +// Spec Section: "Subscriptions with Single Root Field" +import { SingleFieldSubscriptionsRule } from "./rules/SingleFieldSubscriptionsRule.mjs"; +// Spec Section: "Stream Directives Are Used On List Fields" +import { StreamDirectiveOnListFieldRule } from "./rules/StreamDirectiveOnListFieldRule.mjs"; +import { UniqueArgumentDefinitionNamesRule } from "./rules/UniqueArgumentDefinitionNamesRule.mjs"; +// Spec Section: "Argument Uniqueness" +import { UniqueArgumentNamesRule } from "./rules/UniqueArgumentNamesRule.mjs"; +import { UniqueDirectiveNamesRule } from "./rules/UniqueDirectiveNamesRule.mjs"; +// Spec Section: "Directives Are Unique Per Location" +import { UniqueDirectivesPerLocationRule } from "./rules/UniqueDirectivesPerLocationRule.mjs"; +import { UniqueEnumValueNamesRule } from "./rules/UniqueEnumValueNamesRule.mjs"; +import { UniqueFieldDefinitionNamesRule } from "./rules/UniqueFieldDefinitionNamesRule.mjs"; +// Spec Section: "Fragment Name Uniqueness" +import { UniqueFragmentNamesRule } from "./rules/UniqueFragmentNamesRule.mjs"; +// Spec Section: "Input Object Field Uniqueness" +import { UniqueInputFieldNamesRule } from "./rules/UniqueInputFieldNamesRule.mjs"; +// Spec Section: "Operation Name Uniqueness" +import { UniqueOperationNamesRule } from "./rules/UniqueOperationNamesRule.mjs"; +import { UniqueOperationTypesRule } from "./rules/UniqueOperationTypesRule.mjs"; +import { UniqueTypeNamesRule } from "./rules/UniqueTypeNamesRule.mjs"; +// Spec Section: "Variable Uniqueness" +import { UniqueVariableNamesRule } from "./rules/UniqueVariableNamesRule.mjs"; +// Spec Section: "Value Type Correctness" +import { ValuesOfCorrectTypeRule } from "./rules/ValuesOfCorrectTypeRule.mjs"; +// Spec Section: "Variables are Input Types" +import { VariablesAreInputTypesRule } from "./rules/VariablesAreInputTypesRule.mjs"; +// Spec Section: "All Variable Usages Are Allowed" +import { VariablesInAllowedPositionRule } from "./rules/VariablesInAllowedPositionRule.mjs"; +/** + * Technically these aren't part of the spec but they are strongly encouraged + * validation rules. + */ +export const recommendedRules = Object.freeze([MaxIntrospectionDepthRule]); +/** + * This set includes all validation rules defined by the GraphQL spec. + * + * The order of the rules in this list has been adjusted to lead to the + * most clear output when encountering multiple validation errors. + */ +export const specifiedRules = Object.freeze([ + ExecutableDefinitionsRule, + KnownOperationTypesRule, + UniqueOperationNamesRule, + LoneAnonymousOperationRule, + SingleFieldSubscriptionsRule, + KnownTypeNamesRule, + FragmentsOnCompositeTypesRule, + VariablesAreInputTypesRule, + ScalarLeafsRule, + FieldsOnCorrectTypeRule, + UniqueFragmentNamesRule, + KnownFragmentNamesRule, + NoUnusedFragmentsRule, + PossibleFragmentSpreadsRule, + NoFragmentCyclesRule, + UniqueVariableNamesRule, + NoUndefinedVariablesRule, + NoUnusedVariablesRule, + KnownDirectivesRule, + UniqueDirectivesPerLocationRule, + DeferStreamDirectiveOnRootFieldRule, + DeferStreamDirectiveOnValidOperationsRule, + DeferStreamDirectiveLabelRule, + StreamDirectiveOnListFieldRule, + KnownArgumentNamesRule, + UniqueArgumentNamesRule, + ValuesOfCorrectTypeRule, + ProvidedRequiredArgumentsRule, + VariablesInAllowedPositionRule, + OverlappingFieldsCanBeMergedRule, + UniqueInputFieldNamesRule, + ...recommendedRules, +]); +/** + * @internal + */ +export const specifiedSDLRules = Object.freeze([ + LoneSchemaDefinitionRule, + UniqueOperationTypesRule, + UniqueTypeNamesRule, + UniqueEnumValueNamesRule, + UniqueFieldDefinitionNamesRule, + UniqueArgumentDefinitionNamesRule, + UniqueDirectiveNamesRule, + KnownTypeNamesRule, + KnownDirectivesRule, + UniqueDirectivesPerLocationRule, + PossibleTypeExtensionsRule, + KnownArgumentNamesOnDirectivesRule, + UniqueArgumentNamesRule, + UniqueInputFieldNamesRule, + ProvidedRequiredArgumentsOnDirectivesRule, +]); +//# sourceMappingURL=specifiedRules.js.map \ No newline at end of file diff --git a/validation/specifiedRules.mjs.map b/validation/specifiedRules.mjs.map new file mode 100644 index 0000000000..06941d57c5 --- /dev/null +++ b/validation/specifiedRules.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"specifiedRules.js","sourceRoot":"","sources":["../../src/validation/spec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IAC5B,kBAAkB;IAClB,6BAA6B;IAC7B,0BAA0B;IAC1B,eAAe;IACf,uBAAuB;IACvB,uBAAuB;IACvB,sBAAsB;IACtB,qBAAqB;IACrB,2BAA2B;IAC3B,oBAAoB;IACpB,uBAAuB;IACvB,wBAAwB;IACxB,qBAAqB;IACrB,mBAAmB;IACnB,+BAA+B;IAC/B,mCAAmC;IACnC,yCAAyC;IACzC,6BAA6B;IAC7B,8BAA8B;IAC9B,sBAAsB;IACtB,uBAAuB;IACvB,uBAAuB;IACvB,6BAA6B;IAC7B,8BAA8B;IAC9B,gCAAgC;IAChC,yBAAyB;IACzB,GAAG,gBAAgB;CACpB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,MAAM,CAAC,MAAM,CAAC;IACZ,wBAAwB;IACxB,wBAAwB;IACxB,mBAAmB;IACnB,wBAAwB;IACxB,8BAA8B;IAC9B,iCAAiC;IACjC,wBAAwB;IACxB,kBAAkB;IAClB,mBAAmB;IACnB,+BAA+B;IAC/B,0BAA0B;IAC1B,kCAAkC;IAClC,uBAAuB;IACvB,yBAAyB;IACzB,yCAAyC;CAC1C,CAAC,CAAC","sourcesContent":["// Spec Section: \"Defer And Stream Directive Labels Are Unique\"\nimport { DeferStreamDirectiveLabelRule } from './rules/DeferStreamDirectiveLabelRule.js';\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Root Field\"\nimport { DeferStreamDirectiveOnRootFieldRule } from './rules/DeferStreamDirectiveOnRootFieldRule.js';\n// Spec Section: \"Defer And Stream Directives Are Used On Valid Operations\"\nimport { DeferStreamDirectiveOnValidOperationsRule } from './rules/DeferStreamDirectiveOnValidOperationsRule.js';\n// Spec Section: \"Executable Definitions\"\nimport { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule.js';\n// Spec Section: \"Field Selections on Objects, Interfaces, and Unions Types\"\nimport { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule.js';\n// Spec Section: \"Fragments on Composite Types\"\nimport { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule.js';\n// Spec Section: \"Argument Names\"\nimport {\n KnownArgumentNamesOnDirectivesRule,\n KnownArgumentNamesRule,\n} from './rules/KnownArgumentNamesRule.js';\n// Spec Section: \"Directives Are Defined\"\nimport { KnownDirectivesRule } from './rules/KnownDirectivesRule.js';\n// Spec Section: \"Fragment spread target defined\"\nimport { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule.js';\n// Spec Section: \"Operation Type Existence\"\nimport { KnownOperationTypesRule } from './rules/KnownOperationTypesRule.js';\n// Spec Section: \"Fragment Spread Type Existence\"\nimport { KnownTypeNamesRule } from './rules/KnownTypeNamesRule.js';\n// Spec Section: \"Lone Anonymous Operation\"\nimport { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule.js';\n// SDL-specific validation rules\nimport { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule.js';\n// TODO: Spec Section\nimport { MaxIntrospectionDepthRule } from './rules/MaxIntrospectionDepthRule.js';\n// Spec Section: \"Fragments must not form cycles\"\nimport { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule.js';\n// Spec Section: \"All Variable Used Defined\"\nimport { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule.js';\n// Spec Section: \"Fragments must be used\"\nimport { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule.js';\n// Spec Section: \"All Variables Used\"\nimport { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule.js';\n// Spec Section: \"Field Selection Merging\"\nimport { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule.js';\n// Spec Section: \"Fragment spread is possible\"\nimport { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule.js';\nimport { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule.js';\n// Spec Section: \"Argument Optionality\"\nimport {\n ProvidedRequiredArgumentsOnDirectivesRule,\n ProvidedRequiredArgumentsRule,\n} from './rules/ProvidedRequiredArgumentsRule.js';\n// Spec Section: \"Leaf Field Selections\"\nimport { ScalarLeafsRule } from './rules/ScalarLeafsRule.js';\n// Spec Section: \"Subscriptions with Single Root Field\"\nimport { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule.js';\n// Spec Section: \"Stream Directives Are Used On List Fields\"\nimport { StreamDirectiveOnListFieldRule } from './rules/StreamDirectiveOnListFieldRule.js';\nimport { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule.js';\n// Spec Section: \"Argument Uniqueness\"\nimport { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule.js';\nimport { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule.js';\n// Spec Section: \"Directives Are Unique Per Location\"\nimport { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule.js';\nimport { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule.js';\nimport { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule.js';\n// Spec Section: \"Fragment Name Uniqueness\"\nimport { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule.js';\n// Spec Section: \"Input Object Field Uniqueness\"\nimport { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule.js';\n// Spec Section: \"Operation Name Uniqueness\"\nimport { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule.js';\nimport { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule.js';\nimport { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule.js';\n// Spec Section: \"Variable Uniqueness\"\nimport { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule.js';\n// Spec Section: \"Value Type Correctness\"\nimport { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule.js';\n// Spec Section: \"Variables are Input Types\"\nimport { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule.js';\n// Spec Section: \"All Variable Usages Are Allowed\"\nimport { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule.js';\nimport type { SDLValidationRule, ValidationRule } from './ValidationContext.js';\n\n/**\n * Technically these aren't part of the spec but they are strongly encouraged\n * validation rules.\n */\nexport const recommendedRules = Object.freeze([MaxIntrospectionDepthRule]);\n\n/**\n * This set includes all validation rules defined by the GraphQL spec.\n *\n * The order of the rules in this list has been adjusted to lead to the\n * most clear output when encountering multiple validation errors.\n */\nexport const specifiedRules: ReadonlyArray = Object.freeze([\n ExecutableDefinitionsRule,\n KnownOperationTypesRule,\n UniqueOperationNamesRule,\n LoneAnonymousOperationRule,\n SingleFieldSubscriptionsRule,\n KnownTypeNamesRule,\n FragmentsOnCompositeTypesRule,\n VariablesAreInputTypesRule,\n ScalarLeafsRule,\n FieldsOnCorrectTypeRule,\n UniqueFragmentNamesRule,\n KnownFragmentNamesRule,\n NoUnusedFragmentsRule,\n PossibleFragmentSpreadsRule,\n NoFragmentCyclesRule,\n UniqueVariableNamesRule,\n NoUndefinedVariablesRule,\n NoUnusedVariablesRule,\n KnownDirectivesRule,\n UniqueDirectivesPerLocationRule,\n DeferStreamDirectiveOnRootFieldRule,\n DeferStreamDirectiveOnValidOperationsRule,\n DeferStreamDirectiveLabelRule,\n StreamDirectiveOnListFieldRule,\n KnownArgumentNamesRule,\n UniqueArgumentNamesRule,\n ValuesOfCorrectTypeRule,\n ProvidedRequiredArgumentsRule,\n VariablesInAllowedPositionRule,\n OverlappingFieldsCanBeMergedRule,\n UniqueInputFieldNamesRule,\n ...recommendedRules,\n]);\n\n/**\n * @internal\n */\nexport const specifiedSDLRules: ReadonlyArray =\n Object.freeze([\n LoneSchemaDefinitionRule,\n UniqueOperationTypesRule,\n UniqueTypeNamesRule,\n UniqueEnumValueNamesRule,\n UniqueFieldDefinitionNamesRule,\n UniqueArgumentDefinitionNamesRule,\n UniqueDirectiveNamesRule,\n KnownTypeNamesRule,\n KnownDirectivesRule,\n UniqueDirectivesPerLocationRule,\n PossibleTypeExtensionsRule,\n KnownArgumentNamesOnDirectivesRule,\n UniqueArgumentNamesRule,\n UniqueInputFieldNamesRule,\n ProvidedRequiredArgumentsOnDirectivesRule,\n ]);\n"]} \ No newline at end of file diff --git a/validation/validate.d.ts b/validation/validate.d.ts new file mode 100644 index 0000000000..ac5237c0cc --- /dev/null +++ b/validation/validate.d.ts @@ -0,0 +1,47 @@ +import type { Maybe } from '../jsutils/Maybe.js'; +import { GraphQLError } from '../error/GraphQLError.js'; +import type { DocumentNode } from '../language/ast.js'; +import type { GraphQLSchema } from '../type/schema.js'; +import type { SDLValidationRule, ValidationRule } from './ValidationContext.js'; +/** + * Implements the "Validation" section of the spec. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the document is valid. + * + * A list of specific validation rules may be provided. If not provided, the + * default list of rules defined by the GraphQL specification will be used. + * + * Each validation rules is a function which returns a visitor + * (see the language/visitor API). Visitor methods are expected to return + * GraphQLErrors, or Arrays of GraphQLErrors when invalid. + * + * Validate will stop validation after a `maxErrors` limit has been reached. + * Attackers can send pathologically invalid queries to induce a DoS attack, + * so by default `maxErrors` set to 100 errors. + * + * Optionally a custom TypeInfo instance may be provided. If not provided, one + * will be created from the provided schema. + */ +export declare function validate(schema: GraphQLSchema, documentAST: DocumentNode, rules?: ReadonlyArray, options?: { + maxErrors?: number; + hideSuggestions?: Maybe; +}): ReadonlyArray; +/** + * @internal + */ +export declare function validateSDL(documentAST: DocumentNode, schemaToExtend?: Maybe, rules?: ReadonlyArray): ReadonlyArray; +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ +export declare function assertValidSDL(documentAST: DocumentNode): void; +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ +export declare function assertValidSDLExtension(documentAST: DocumentNode, schema: GraphQLSchema): void; diff --git a/validation/validate.js b/validation/validate.js new file mode 100644 index 0000000000..11ed2a9e6f --- /dev/null +++ b/validation/validate.js @@ -0,0 +1,100 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validate = validate; +exports.validateSDL = validateSDL; +exports.assertValidSDL = assertValidSDL; +exports.assertValidSDLExtension = assertValidSDLExtension; +const GraphQLError_js_1 = require("../error/GraphQLError.js"); +const visitor_js_1 = require("../language/visitor.js"); +const validate_js_1 = require("../type/validate.js"); +const TypeInfo_js_1 = require("../utilities/TypeInfo.js"); +const specifiedRules_js_1 = require("./specifiedRules.js"); +const ValidationContext_js_1 = require("./ValidationContext.js"); +/** + * Implements the "Validation" section of the spec. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the document is valid. + * + * A list of specific validation rules may be provided. If not provided, the + * default list of rules defined by the GraphQL specification will be used. + * + * Each validation rules is a function which returns a visitor + * (see the language/visitor API). Visitor methods are expected to return + * GraphQLErrors, or Arrays of GraphQLErrors when invalid. + * + * Validate will stop validation after a `maxErrors` limit has been reached. + * Attackers can send pathologically invalid queries to induce a DoS attack, + * so by default `maxErrors` set to 100 errors. + * + * Optionally a custom TypeInfo instance may be provided. If not provided, one + * will be created from the provided schema. + */ +function validate(schema, documentAST, rules = specifiedRules_js_1.specifiedRules, options) { + const maxErrors = options?.maxErrors ?? 100; + const hideSuggestions = options?.hideSuggestions ?? false; + // If the schema used for validation is invalid, throw an error. + (0, validate_js_1.assertValidSchema)(schema); + const abortError = new GraphQLError_js_1.GraphQLError('Too many validation errors, error limit reached. Validation aborted.'); + const errors = []; + const typeInfo = new TypeInfo_js_1.TypeInfo(schema); + const context = new ValidationContext_js_1.ValidationContext(schema, documentAST, typeInfo, (error) => { + if (errors.length >= maxErrors) { + throw abortError; + } + errors.push(error); + }, hideSuggestions); + // This uses a specialized visitor which runs multiple visitors in parallel, + // while maintaining the visitor skip and break API. + const visitor = (0, visitor_js_1.visitInParallel)(rules.map((rule) => rule(context))); + // Visit the whole document with each instance of all provided rules. + try { + (0, visitor_js_1.visit)(documentAST, (0, TypeInfo_js_1.visitWithTypeInfo)(typeInfo, visitor)); + } + catch (e) { + if (e === abortError) { + errors.push(abortError); + } + else { + throw e; + } + } + return errors; +} +/** + * @internal + */ +function validateSDL(documentAST, schemaToExtend, rules = specifiedRules_js_1.specifiedSDLRules) { + const errors = []; + const context = new ValidationContext_js_1.SDLValidationContext(documentAST, schemaToExtend, (error) => { + errors.push(error); + }); + const visitors = rules.map((rule) => rule(context)); + (0, visitor_js_1.visit)(documentAST, (0, visitor_js_1.visitInParallel)(visitors)); + return errors; +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ +function assertValidSDL(documentAST) { + const errors = validateSDL(documentAST); + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ +function assertValidSDLExtension(documentAST, schema) { + const errors = validateSDL(documentAST, schema); + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +//# sourceMappingURL=validate.js.map \ No newline at end of file diff --git a/validation/validate.js.map b/validation/validate.js.map new file mode 100644 index 0000000000..ca8f79f095 --- /dev/null +++ b/validation/validate.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validation/validate.ts"],"names":[],"mappings":";;AAuCA,4BA6CC;AAKD,kCAiBC;AAQD,wCAKC;AAQD,0DAQC;AArID,8DAAwD;AAGxD,uDAAgE;AAGhE,qDAAwD;AAExD,0DAAuE;AAEvE,2DAAwE;AAExE,iEAGgC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,QAAQ,CACtB,MAAqB,EACrB,WAAyB,EACzB,QAAuC,kCAAc,EACrD,OAAkE;IAElE,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,GAAG,CAAC;IAC5C,MAAM,eAAe,GAAG,OAAO,EAAE,eAAe,IAAI,KAAK,CAAC;IAE1D,gEAAgE;IAChE,IAAA,+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AI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CACF,CAAC;IAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACpD,IAAA,kBAAK,EAAC,WAAW,EAAE,IAAA,4BAAe,EAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,WAAyB;IACtD,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,WAAyB,EACzB,MAAqB;IAErB,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type { DocumentNode } from '../language/ast.js';\nimport { visit, visitInParallel } from '../language/visitor.js';\n\nimport type { GraphQLSchema } from '../type/schema.js';\nimport { assertValidSchema } from '../type/validate.js';\n\nimport { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo.js';\n\nimport { specifiedRules, specifiedSDLRules } from './specifiedRules.js';\nimport type { SDLValidationRule, ValidationRule } from './ValidationContext.js';\nimport {\n SDLValidationContext,\n ValidationContext,\n} from './ValidationContext.js';\n\n/**\n * Implements the \"Validation\" section of the spec.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the document is valid.\n *\n * A list of specific validation rules may be provided. If not provided, the\n * default list of rules defined by the GraphQL specification will be used.\n *\n * Each validation rules is a function which returns a visitor\n * (see the language/visitor API). Visitor methods are expected to return\n * GraphQLErrors, or Arrays of GraphQLErrors when invalid.\n *\n * Validate will stop validation after a `maxErrors` limit has been reached.\n * Attackers can send pathologically invalid queries to induce a DoS attack,\n * so by default `maxErrors` set to 100 errors.\n *\n * Optionally a custom TypeInfo instance may be provided. If not provided, one\n * will be created from the provided schema.\n */\nexport function validate(\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules: ReadonlyArray = specifiedRules,\n options?: { maxErrors?: number; hideSuggestions?: Maybe },\n): ReadonlyArray {\n const maxErrors = options?.maxErrors ?? 100;\n const hideSuggestions = options?.hideSuggestions ?? false;\n\n // If the schema used for validation is invalid, throw an error.\n assertValidSchema(schema);\n\n const abortError = new GraphQLError(\n 'Too many validation errors, error limit reached. Validation aborted.',\n );\n const errors: Array = [];\n const typeInfo = new TypeInfo(schema);\n const context = new ValidationContext(\n schema,\n documentAST,\n typeInfo,\n (error) => {\n if (errors.length >= maxErrors) {\n throw abortError;\n }\n errors.push(error);\n },\n hideSuggestions,\n );\n\n // This uses a specialized visitor which runs multiple visitors in parallel,\n // while maintaining the visitor skip and break API.\n const visitor = visitInParallel(rules.map((rule) => rule(context)));\n\n // Visit the whole document with each instance of all provided rules.\n try {\n visit(documentAST, visitWithTypeInfo(typeInfo, visitor));\n } catch (e: unknown) {\n if (e === abortError) {\n errors.push(abortError);\n } else {\n throw e;\n }\n }\n return errors;\n}\n\n/**\n * @internal\n */\nexport function validateSDL(\n documentAST: DocumentNode,\n schemaToExtend?: Maybe,\n rules: ReadonlyArray = specifiedSDLRules,\n): ReadonlyArray {\n const errors: Array = [];\n const context = new SDLValidationContext(\n documentAST,\n schemaToExtend,\n (error) => {\n errors.push(error);\n },\n );\n\n const visitors = rules.map((rule) => rule(context));\n visit(documentAST, visitInParallel(visitors));\n return errors;\n}\n\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\nexport function assertValidSDL(documentAST: DocumentNode): void {\n const errors = validateSDL(documentAST);\n if (errors.length !== 0) {\n throw new Error(errors.map((error) => error.message).join('\\n\\n'));\n }\n}\n\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\nexport function assertValidSDLExtension(\n documentAST: DocumentNode,\n schema: GraphQLSchema,\n): void {\n const errors = validateSDL(documentAST, schema);\n if (errors.length !== 0) {\n throw new Error(errors.map((error) => error.message).join('\\n\\n'));\n }\n}\n"]} \ No newline at end of file diff --git a/validation/validate.mjs b/validation/validate.mjs new file mode 100644 index 0000000000..a2a657f2a8 --- /dev/null +++ b/validation/validate.mjs @@ -0,0 +1,94 @@ +import { GraphQLError } from "../error/GraphQLError.mjs"; +import { visit, visitInParallel } from "../language/visitor.mjs"; +import { assertValidSchema } from "../type/validate.mjs"; +import { TypeInfo, visitWithTypeInfo } from "../utilities/TypeInfo.mjs"; +import { specifiedRules, specifiedSDLRules } from "./specifiedRules.mjs"; +import { SDLValidationContext, ValidationContext, } from "./ValidationContext.mjs"; +/** + * Implements the "Validation" section of the spec. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the document is valid. + * + * A list of specific validation rules may be provided. If not provided, the + * default list of rules defined by the GraphQL specification will be used. + * + * Each validation rules is a function which returns a visitor + * (see the language/visitor API). Visitor methods are expected to return + * GraphQLErrors, or Arrays of GraphQLErrors when invalid. + * + * Validate will stop validation after a `maxErrors` limit has been reached. + * Attackers can send pathologically invalid queries to induce a DoS attack, + * so by default `maxErrors` set to 100 errors. + * + * Optionally a custom TypeInfo instance may be provided. If not provided, one + * will be created from the provided schema. + */ +export function validate(schema, documentAST, rules = specifiedRules, options) { + const maxErrors = options?.maxErrors ?? 100; + const hideSuggestions = options?.hideSuggestions ?? false; + // If the schema used for validation is invalid, throw an error. + assertValidSchema(schema); + const abortError = new GraphQLError('Too many validation errors, error limit reached. Validation aborted.'); + const errors = []; + const typeInfo = new TypeInfo(schema); + const context = new ValidationContext(schema, documentAST, typeInfo, (error) => { + if (errors.length >= maxErrors) { + throw abortError; + } + errors.push(error); + }, hideSuggestions); + // This uses a specialized visitor which runs multiple visitors in parallel, + // while maintaining the visitor skip and break API. + const visitor = visitInParallel(rules.map((rule) => rule(context))); + // Visit the whole document with each instance of all provided rules. + try { + visit(documentAST, visitWithTypeInfo(typeInfo, visitor)); + } + catch (e) { + if (e === abortError) { + errors.push(abortError); + } + else { + throw e; + } + } + return errors; +} +/** + * @internal + */ +export function validateSDL(documentAST, schemaToExtend, rules = specifiedSDLRules) { + const errors = []; + const context = new SDLValidationContext(documentAST, schemaToExtend, (error) => { + errors.push(error); + }); + const visitors = rules.map((rule) => rule(context)); + visit(documentAST, visitInParallel(visitors)); + return errors; +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ +export function assertValidSDL(documentAST) { + const errors = validateSDL(documentAST); + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ +export function assertValidSDLExtension(documentAST, schema) { + const errors = validateSDL(documentAST, schema); + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +//# sourceMappingURL=validate.js.map \ No newline at end of file diff --git a/validation/validate.mjs.map b/validation/validate.mjs.map new file mode 100644 index 0000000000..90e976f2a2 --- /dev/null +++ b/validation/validate.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validation/validate.ts"],"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AM,MAAM,GAAG,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import type { Maybe } from '../jsutils/Maybe.js';\n\nimport { GraphQLError } from '../error/GraphQLError.js';\n\nimport type { DocumentNode } from '../language/ast.js';\nimport { visit, visitInParallel } from '../language/visitor.js';\n\nimport type { GraphQLSchema } from '../type/schema.js';\nimport { assertValidSchema } from '../type/validate.js';\n\nimport { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo.js';\n\nimport { specifiedRules, specifiedSDLRules } from './specifiedRules.js';\nimport type { SDLValidationRule, ValidationRule } from './ValidationContext.js';\nimport {\n SDLValidationContext,\n ValidationContext,\n} from './ValidationContext.js';\n\n/**\n * Implements the \"Validation\" section of the spec.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the document is valid.\n *\n * A list of specific validation rules may be provided. If not provided, the\n * default list of rules defined by the GraphQL specification will be used.\n *\n * Each validation rules is a function which returns a visitor\n * (see the language/visitor API). Visitor methods are expected to return\n * GraphQLErrors, or Arrays of GraphQLErrors when invalid.\n *\n * Validate will stop validation after a `maxErrors` limit has been reached.\n * Attackers can send pathologically invalid queries to induce a DoS attack,\n * so by default `maxErrors` set to 100 errors.\n *\n * Optionally a custom TypeInfo instance may be provided. If not provided, one\n * will be created from the provided schema.\n */\nexport function validate(\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules: ReadonlyArray = specifiedRules,\n options?: { maxErrors?: number; hideSuggestions?: Maybe },\n): ReadonlyArray {\n const maxErrors = options?.maxErrors ?? 100;\n const hideSuggestions = options?.hideSuggestions ?? false;\n\n // If the schema used for validation is invalid, throw an error.\n assertValidSchema(schema);\n\n const abortError = new GraphQLError(\n 'Too many validation errors, error limit reached. Validation aborted.',\n );\n const errors: Array = [];\n const typeInfo = new TypeInfo(schema);\n const context = new ValidationContext(\n schema,\n documentAST,\n typeInfo,\n (error) => {\n if (errors.length >= maxErrors) {\n throw abortError;\n }\n errors.push(error);\n },\n hideSuggestions,\n );\n\n // This uses a specialized visitor which runs multiple visitors in parallel,\n // while maintaining the visitor skip and break API.\n const visitor = visitInParallel(rules.map((rule) => rule(context)));\n\n // Visit the whole document with each instance of all provided rules.\n try {\n visit(documentAST, visitWithTypeInfo(typeInfo, visitor));\n } catch (e: unknown) {\n if (e === abortError) {\n errors.push(abortError);\n } else {\n throw e;\n }\n }\n return errors;\n}\n\n/**\n * @internal\n */\nexport function validateSDL(\n documentAST: DocumentNode,\n schemaToExtend?: Maybe,\n rules: ReadonlyArray = specifiedSDLRules,\n): ReadonlyArray {\n const errors: Array = [];\n const context = new SDLValidationContext(\n documentAST,\n schemaToExtend,\n (error) => {\n errors.push(error);\n },\n );\n\n const visitors = rules.map((rule) => rule(context));\n visit(documentAST, visitInParallel(visitors));\n return errors;\n}\n\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\nexport function assertValidSDL(documentAST: DocumentNode): void {\n const errors = validateSDL(documentAST);\n if (errors.length !== 0) {\n throw new Error(errors.map((error) => error.message).join('\\n\\n'));\n }\n}\n\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\nexport function assertValidSDLExtension(\n documentAST: DocumentNode,\n schema: GraphQLSchema,\n): void {\n const errors = validateSDL(documentAST, schema);\n if (errors.length !== 0) {\n throw new Error(errors.map((error) => error.message).join('\\n\\n'));\n }\n}\n"]} \ No newline at end of file diff --git a/version.d.ts b/version.d.ts new file mode 100644 index 0000000000..b37ef218c7 --- /dev/null +++ b/version.d.ts @@ -0,0 +1,13 @@ +/** + * A string containing the version of the GraphQL.js library + */ +export declare const version: string; +/** + * An object containing the components of the GraphQL.js version string + */ +export declare const versionInfo: Readonly<{ + major: number; + minor: number; + patch: number; + preReleaseTag: string | null; +}>; diff --git a/version.js b/version.js new file mode 100644 index 0000000000..cfa94d5db4 --- /dev/null +++ b/version.js @@ -0,0 +1,19 @@ +"use strict"; +// Note: This file is autogenerated using "resources/gen-version.js" script and +// automatically updated by "npm version" command. +Object.defineProperty(exports, "__esModule", { value: true }); +exports.versionInfo = exports.version = void 0; +/** + * A string containing the version of the GraphQL.js library + */ +exports.version = '17.0.0-alpha.8'; +/** + * An object containing the components of the GraphQL.js version string + */ +exports.versionInfo = Object.freeze({ + major: 17, + minor: 0, + patch: 0, + preReleaseTag: 'alpha.8', +}); +//# sourceMappingURL=version.js.map \ No newline at end of file diff --git a/version.js.map b/version.js.map new file mode 100644 index 0000000000..2da55a0f7d --- /dev/null +++ b/version.js.map @@ -0,0 +1 @@ +{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,kDAAkD;;;AAElD;;GAEG;AACU,QAAA,OAAO,GAAG,gBAA0B,CAAC;AAElD;;GAEG;AACU,QAAA,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,EAAY;IACnB,KAAK,EAAE,CAAW;IAClB,KAAK,EAAE,CAAW;IAClB,aAAa,EAAE,SAA0B;CAC1C,CAAC,CAAC","sourcesContent":["// Note: This file is autogenerated using \"resources/gen-version.js\" script and\n// automatically updated by \"npm version\" command.\n\n/**\n * A string containing the version of the GraphQL.js library\n */\nexport const version = '17.0.0-alpha.8' as string;\n\n/**\n * An object containing the components of the GraphQL.js version string\n */\nexport const versionInfo = Object.freeze({\n major: 17 as number,\n minor: 0 as number,\n patch: 0 as number,\n preReleaseTag: 'alpha.8' as string | null,\n});\n"]} \ No newline at end of file diff --git a/version.mjs b/version.mjs new file mode 100644 index 0000000000..6eb516485a --- /dev/null +++ b/version.mjs @@ -0,0 +1,16 @@ +// Note: This file is autogenerated using "resources/gen-version.js" script and +// automatically updated by "npm version" command. +/** + * A string containing the version of the GraphQL.js library + */ +export const version = '17.0.0-alpha.8'; +/** + * An object containing the components of the GraphQL.js version string + */ +export const versionInfo = Object.freeze({ + major: 17, + minor: 0, + patch: 0, + preReleaseTag: 'alpha.8', +}); +//# sourceMappingURL=version.js.map \ No newline at end of file diff --git a/version.mjs.map b/version.mjs.map new file mode 100644 index 0000000000..5301538bab --- /dev/null +++ b/version.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kDAAkD;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,gBAA0B,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,EAAY;IACnB,KAAK,EAAE,CAAW;IAClB,KAAK,EAAE,CAAW;IAClB,aAAa,EAAE,SAA0B;CAC1C,CAAC,CAAC","sourcesContent":["// Note: This file is autogenerated using \"resources/gen-version.js\" script and\n// automatically updated by \"npm version\" command.\n\n/**\n * A string containing the version of the GraphQL.js library\n */\nexport const version = '17.0.0-alpha.8' as string;\n\n/**\n * An object containing the components of the GraphQL.js version string\n */\nexport const versionInfo = Object.freeze({\n major: 17 as number,\n minor: 0 as number,\n patch: 0 as number,\n preReleaseTag: 'alpha.8' as string | null,\n});\n"]} \ No newline at end of file diff --git a/website/.eslintignore b/website/.eslintignore deleted file mode 100644 index e435ba4756..0000000000 --- a/website/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -/pages/_document.tsx -/pages/_app.tsx diff --git a/website/css/globals.css b/website/css/globals.css deleted file mode 100644 index d8207c0885..0000000000 --- a/website/css/globals.css +++ /dev/null @@ -1,480 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -:root { - --foreground-rgb: 0, 0, 0; - --background-start-rgb: 214, 219, 220; - --background-end-rgb: 255, 255, 255; -} - -@media (prefers-color-scheme: dark) { - :root { - --foreground-rgb: 255, 255, 255; - --background-start-rgb: 0, 0, 0; - --background-end-rgb: 0, 0, 0; - } -} - -.conf-hero { - background: linear-gradient( - 360deg, - #0e031c 10.63%, - #0e031c 10.65%, - rgba(14, 3, 28, 0) 166.98% - ), - url('/img/conf/graphql-conf-bg.png'); - @apply text-white max-md:text-base; -} - -.with-arrow:after { - @apply content-['_β†’'] font-sans text-xl; - @apply transition-all duration-75 hover:ml-1; -} - -footer { - @apply !bg-transparent; -} - -.nextra-logo { - mask-image: linear-gradient( - 60deg, - black 25%, - rgba(0, 0, 0, 0.2) 50%, - black 75% - ); - mask-size: 400%; - mask-position: 0; - - &:hover { - mask-position: 100%; - transition: mask-position 1s ease, -webkit-mask-position 1s ease; - } -} - -div[role='menu'][data-headlessui-state] { - @apply left-0 right-auto; -} - -div[id^='headlessui-menu-items'] { - @apply rounded-none; - - > a { - @apply py-3.5; - } -} - -/* should be fixed in Nextra 4 */ -._max-w-\[90rem\] { - @apply container; -} - -.nextra-nav-container + ._max-w-\[90rem\] { - @apply px-0; -} - -.nextra-nav-container > nav { - @apply gap-6; -} - -/* Move nav links to the left */ -.nextra-nav-container nav { - @apply justify-start; - - > a { - @apply hover:!text-primary; - } - - button[id^='headlessui-menu-button'] { - @apply hover:text-primary; - - + div > a { - @apply hover:text-primary; - } - } - - .nextra-search { - @apply ml-auto; - - + * { - @apply max-md:ml-auto; - } - } -} - -/*._max-w-\[90rem\] {*/ -/* !* TODO: maybe add to nextra as option to configure width? *!*/ -/* @apply container;*/ -/*}*/ - -.miniGraphiQL { - @apply !shadow-none border-2 dark:border-neutral-900 dark:!bg-neutral-900/10 !rounded-md dark:brightness-200; -} - -.result-window { - @apply !shadow-none border-l-2 dark:border-neutral-900 !rounded-none; -} - -.variable-editor { - @apply before:!bg-transparent border-t-2 dark:border-neutral-900; -} - -.CodeMirror-selected { - @apply !bg-primary/50 dark:bg-primary/40; -} - -.CodeMirror-cursor { - @apply dark:border-white; -} - -.CodeMirror { - @apply p-2; -} - -::selection { - @apply bg-primary/50 dark:bg-primary; -} - -@media (prefers-color-scheme: dark) { - body { - /*background: linear-gradient(*/ - /* 125deg,*/ - /* rgba(234, 117, 195, 0.3) -10%,*/ - /* rgba(234, 117, 195, 0) 8%*/ - /* ),*/ - /* linear-gradient(*/ - /* -125deg,*/ - /* rgba(234, 117, 195, 0.3) -10%,*/ - /* rgba(234, 117, 195, 0) 8%*/ - /* ),*/ - /* linear-gradient(0deg, #05031c, #05031c);*/ - /*@apply bg-gradient-to-b from-primary/10 to-[#05031c]*/ - - /*background:*/ - /* !*linear-gradient(0deg, #05031c, #05031c),*!*/ - /* linear-gradient(*/ - /* 125.93deg,*/ - /* rgba(234, 117, 195, 0.7) -10.45%,*/ - /* rgba(234, 117, 195, 0) 28.49%*/ - /* ),*/ - /* linear-gradient(*/ - /* -125.93deg,*/ - /* rgba(234, 117, 195, 0.7) -33.25%,*/ - /* rgba(234, 117, 195, 0) 26.45%*/ - /* );*/ - } -} - -.donts-images ul { - gap: 0 3em; - @apply flex flex-wrap; - - li { - @apply flex gap-3 grow md:basis-1/3; - - div { - @apply grow; - } - - img { - @apply bg-gray-200 p-4 h-20; - } - } -} - -.dos > ul:first-child li:before { - background: url('/img/brand/do.svg'); -} - -.donts > ul:first-child li:before { - background: url('/img/brand/dont.svg'); -} - -.dos, -.donts { - @apply mt-6; - - > ul ul { - @apply mt-0; - - li:before { - @apply grayscale; - } - } - - & > ul:first-child li { - @apply list-none relative; - - &:before { - @apply size-4 absolute content-[''] top-1 -left-6; - } - } -} - -.code-page { - background: linear-gradient( - 303.75deg, - rgba(124, 124, 124, 0.2) 0.8%, - rgba(124, 124, 124, 0) 74.17% - ), - linear-gradient(0deg, #f8f8f8, #f8f8f8); -} - -.dark .code-page { - background: linear-gradient( - 303.75deg, - rgba(124, 124, 124, 0.2) 0.8%, - rgba(124, 124, 124, 0) 74.17% - ), - linear-gradient(0deg, #1b1b1b, #1b1b1b); -} - -.dark .blog-page { - background: linear-gradient( - 250.93deg, - rgba(115, 119, 125, 0.1), - rgba(115, 119, 125, 0) - ), - #18181b; -} - -.blog-page { - background: linear-gradient( - 231.79deg, - rgba(225, 0, 152, 0.4) -23.67%, - rgba(225, 0, 152, 0) 25.9% - ), - linear-gradient( - 113.65deg, - rgba(229, 53, 171, 0.4) -49.55%, - rgba(225, 0, 152, 0) 33.97% - ), - linear-gradient(180deg, #f3f4f6 0%, #fff 100%); -} - -.conf-heading { - @apply text-3xl lg:text-[50px]/[4rem] font-bold text-balance; -} - -.conf-block { - @apply py-14 lg:py-24; -} - -.tag { - @apply hover:text-white hover:border-transparent hover:bg-primary; - @apply text-sm border border-current rounded px-2.5 py-1 font-bold transition-colors; -} - -.index { - p { - @apply text-lg lg:text-xl/9 mb-5 max-w-2xl; - } - - h2 { - @apply text-3xl lg:text-5xl font-bold mb-10 text-balance; - } - - pre { - @apply bg-white; - } -} - -.add, -.remove { - @apply shadow-[2px_0_currentColor_inset]; -} - -.add { - @apply !bg-green-200 dark:!bg-green-200/50 text-green-300; - - &::before { - @apply absolute start-1.5 content-['+']; - } -} - -.remove { - @apply !bg-red-200 dark:!bg-red-200/50 text-red-300; - - &::before { - @apply absolute start-1.5 content-['-']; - } -} - -.step0, -.step6 { - .v2 { - @apply opacity-0; - } -} - -.step1 .v2 code > span:nth-child(5) { - @apply add; -} - -.step2 .v3 code > span:nth-child(6) { - @apply add; -} - -.step3 .v4 code > { - span:nth-child(7), - span:nth-last-child(-n + 5) { - @apply add; - } -} - -.step4 { - .v4 code > span:nth-child(6) { - @apply remove; - } - - .v5 code > span:nth-child(6) { - @apply add; - } -} - -.index-button { - @apply border border-current rounded-md transition-colors py-2.5 px-6; - - &:hover, - &:focus { - @apply bg-primary border-transparent text-white; - } -} - -.nextra-codeblocks { - div.nextra-code { - pre { - @apply h-full; - } - - &:not(:first-child) { - @apply mt-0; - - > div { - @apply first:rounded-l-none; - } - - pre { - @apply rounded-l-none; - } - } - - &:not(:last-child) { - > div { - @apply first:rounded-r-none; - } - - pre { - @apply rounded-r-none; - } - } - } -} - -.index-bg { - background: linear-gradient( - 303.75deg, - rgba(124, 124, 124, 0.2) 0.8%, - rgba(124, 124, 124, 0) 74.17% - ), - linear-gradient(0deg, #f8f8f8, #f8f8f8); - - .dark & { - background: linear-gradient(0deg, #111, #111), - linear-gradient( - 303.75deg, - rgba(124, 124, 124, 0.2) 0.8%, - rgba(124, 124, 124, 0) 74.17% - ); - } -} - -.index-gradient { - @apply bg-gradient-to-b from-transparent to-primary/5 dark:to-primary/10; -} - -.type-evolution { - @apply w-full overflow-hidden; - - #typeEvolveView { - @apply select-none h-full relative left-0 flex; - - .v1, - .v2, - .v3, - .v4 { - @apply border-r dark:border-neutral-800 w-1/2 shrink-0; - } - - .v5 { - @apply w-full shrink-0; - } - - &.step1 { - .v2 { - opacity: 1; - transition: opacity 0.5s ease-in-out; - } - } - - &.step2 { - left: calc(-1 * 50%); - transition: left 0.5s ease-in-out; - } - - &.step3 { - left: calc(-2 * 50%); - transition: left 0.5s ease-in-out; - } - - &.step4 { - left: calc(-3 * 50%); - transition: left 0.5s ease-in-out; - } - - &.step5 { - left: calc(-4 * 50%); - transition: left 0.5s ease-in-out; - } - - &.step6 { - .v5 { - left: calc(-4 * 50%); - opacity: 0; - transition: opacity 0.5s ease-in-out; - } - } - } -} - -.apiIndex { - @apply mt-6; -} - -.apiIndex li { - margin: 0 0 5px 0; -} - -.apiIndex li a { - color: inherit; - display: block; - position: relative; - text-decoration: none; -} - -.apiIndex li a:hover::before { - @apply text-primary; - content: '#'; - font-size: 16px; - left: -2em; - line-height: 20px; - position: absolute; -} - -.apiIndex li { - @apply bg-white dark:bg-black; - @apply [box-shadow:inset_0_0_0_1px_#ddd,inset_4px_0_0_#ddd]; - @apply dark:[box-shadow:inset_0_0_0_1px_#444,inset_4px_0_0_#444]; - font-size: 13px; - padding: 7px 14px; -} diff --git a/website/icons/discord.svg b/website/icons/discord.svg deleted file mode 100644 index 57ea755cc5..0000000000 --- a/website/icons/discord.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/website/icons/github.svg b/website/icons/github.svg deleted file mode 100644 index 66cb3d3791..0000000000 --- a/website/icons/github.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - \ No newline at end of file diff --git a/website/icons/graphql-wordmark.svg b/website/icons/graphql-wordmark.svg deleted file mode 100644 index c407187504..0000000000 --- a/website/icons/graphql-wordmark.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/website/icons/graphql.svg b/website/icons/graphql.svg deleted file mode 100644 index 857fa8d9df..0000000000 --- a/website/icons/graphql.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/website/icons/index.ts b/website/icons/index.ts deleted file mode 100644 index 3935beb8e7..0000000000 --- a/website/icons/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { default as DiscordIcon } from './discord.svg'; -export { default as GitHubIcon } from './github.svg'; -export { default as GraphQLLogo } from './graphql.svg'; -export { default as GraphQLWordmarkLogo } from './graphql-wordmark.svg'; -export { default as StackOverflowIcon } from './stackoverflow.svg'; -export { default as TwitterIcon } from './twitter.svg'; diff --git a/website/icons/stackoverflow.svg b/website/icons/stackoverflow.svg deleted file mode 100644 index d210d7768a..0000000000 --- a/website/icons/stackoverflow.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - \ No newline at end of file diff --git a/website/icons/twitter.svg b/website/icons/twitter.svg deleted file mode 100644 index 377365e1cf..0000000000 --- a/website/icons/twitter.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/website/next-env.d.ts b/website/next-env.d.ts deleted file mode 100644 index a4a7b3f5cf..0000000000 --- a/website/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information. diff --git a/website/next.config.mjs b/website/next.config.mjs deleted file mode 100644 index 737a985d5d..0000000000 --- a/website/next.config.mjs +++ /dev/null @@ -1,57 +0,0 @@ -import nextra from 'nextra'; -import path from 'node:path'; -import fs from 'node:fs'; - -const fileContents = fs.readFileSync('./vercel.json', 'utf-8'); -const vercel = JSON.parse(fileContents); - -const withNextra = nextra({ - theme: 'nextra-theme-docs', - themeConfig: './theme.config.tsx', -}); - -const sep = path.sep === '/' ? '/' : '\\\\'; - -const ALLOWED_SVG_REGEX = new RegExp(`${sep}icons${sep}.+\\.svg$`); - -/** - * @type {import('next').NextConfig} - */ -export default withNextra({ - webpack(config) { - const fileLoaderRule = config.module.rules.find((rule) => - rule.test?.test?.('.svg'), - ); - - fileLoaderRule.exclude = ALLOWED_SVG_REGEX; - - config.module.rules.push({ - test: ALLOWED_SVG_REGEX, - use: ['@svgr/webpack'], - }); - return config; - }, - redirects: async () => vercel.redirects, - output: 'export', - images: { - loader: 'custom', - imageSizes: [16, 32, 48, 64, 96, 128, 256, 384], - deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840], - }, - transpilePackages: ['next-image-export-optimizer'], - env: { - nextImageExportOptimizer_imageFolderPath: 'public/images', - nextImageExportOptimizer_exportFolderPath: 'out', - nextImageExportOptimizer_quality: '75', - nextImageExportOptimizer_storePicturesInWEBP: 'true', - nextImageExportOptimizer_exportFolderName: 'nextImageExportOptimizer', - // If you do not want to use blurry placeholder images, then you can set - // nextImageExportOptimizer_generateAndUseBlurImages to false and pass - // `placeholder="empty"` to all components. - nextImageExportOptimizer_generateAndUseBlurImages: 'true', - // If you want to cache the remote images, you can set the time to live of the cache in seconds. - // The default value is 0 seconds. - nextImageExportOptimizer_remoteImageCacheTTL: '0', - }, - trailingSlash: true, -}); diff --git a/website/package-lock.json b/website/package-lock.json deleted file mode 100644 index 4bdfc8cfe7..0000000000 --- a/website/package-lock.json +++ /dev/null @@ -1,9536 +0,0 @@ -{ - "name": "website", - "version": "0.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "website", - "version": "0.0.0", - "devDependencies": { - "@svgr/webpack": "^8.1.0", - "@tailwindcss/typography": "^0.5.10", - "@types/node": "^22.7.5", - "autoprefixer": "^10.4.20", - "next": "^14.2.15", - "nextra": "^3.0.13", - "nextra-theme-docs": "^3.0.13", - "postcss": "^8.4.47", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "tailwindcss": "^3.4.14", - "typescript": "^5.6.3" - } - }, - "node_modules/@alloc/quick-lru": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", - "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@ampproject/remapping": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", - "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", - "dev": true, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@antfu/install-pkg": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@antfu/install-pkg/-/install-pkg-0.4.1.tgz", - "integrity": "sha512-T7yB5QNG29afhWVkVq7XeIMBa5U/vs9mX69YqayXypPRmYzUmzwnYltplHmPtZ4HPCn+sQKeXW8I47wCbuBOjw==", - "dev": true, - "dependencies": { - "package-manager-detector": "^0.2.0", - "tinyexec": "^0.3.0" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, - "node_modules/@antfu/utils": { - "version": "0.7.10", - "resolved": "https://registry.npmjs.org/@antfu/utils/-/utils-0.7.10.tgz", - "integrity": "sha512-+562v9k4aI80m1+VuMHehNJWLOFjBnXn3tdOitzD0il5b7smkSBal4+a3oKiQTbrwMmN/TBUMDvbdoWDehgOww==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.7.tgz", - "integrity": "sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g==", - "dev": true, - "dependencies": { - "@babel/highlight": "^7.25.7", - "picocolors": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.8.tgz", - "integrity": "sha512-ZsysZyXY4Tlx+Q53XdnOFmqwfB9QDTHYxaZYajWRoBLuLEAwI2UIbtxOjWh/cFaa9IKUlcB+DDuoskLuKu56JA==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.8.tgz", - "integrity": "sha512-Oixnb+DzmRT30qu9d3tJSQkxuygWm32DFykT4bRoORPa9hZ/L4KhVB/XiRm6KG+roIEM7DBQlmg27kw2HZkdZg==", - "dev": true, - "dependencies": { - "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.25.7", - "@babel/generator": "^7.25.7", - "@babel/helper-compilation-targets": "^7.25.7", - "@babel/helper-module-transforms": "^7.25.7", - "@babel/helpers": "^7.25.7", - "@babel/parser": "^7.25.8", - "@babel/template": "^7.25.7", - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.8", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/generator": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.7.tgz", - "integrity": "sha512-5Dqpl5fyV9pIAD62yK9P7fcA768uVPUyrQmqpqstHWgMma4feF1x/oFysBCVZLY5wJ2GkMUCdsNDnGZrPoR6rA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.25.7", - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25", - "jsesc": "^3.0.2" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-annotate-as-pure": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.25.7.tgz", - "integrity": "sha512-4xwU8StnqnlIhhioZf1tqnVWeQ9pvH/ujS8hRfw/WOza+/a+1qv69BWNy+oY231maTCWgKWhfBU7kDpsds6zAA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-builder-binary-assignment-operator-visitor": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.25.7.tgz", - "integrity": "sha512-12xfNeKNH7jubQNm7PAkzlLwEmCs1tfuX3UjIw6vP6QXi+leKh6+LyC/+Ed4EIQermwd58wsyh070yjDHFlNGg==", - "dev": true, - "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.7.tgz", - "integrity": "sha512-DniTEax0sv6isaw6qSQSfV4gVRNtw2rte8HHM45t9ZR0xILaufBRNkpMifCRiAPyvL4ACD6v0gfCwCmtOQaV4A==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.25.7", - "@babel/helper-validator-option": "^7.25.7", - "browserslist": "^4.24.0", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true - }, - "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.25.7.tgz", - "integrity": "sha512-bD4WQhbkx80mAyj/WCm4ZHcF4rDxkoLFO6ph8/5/mQ3z4vAzltQXAmbc7GvVJx5H+lk5Mi5EmbTeox5nMGCsbw==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "@babel/helper-member-expression-to-functions": "^7.25.7", - "@babel/helper-optimise-call-expression": "^7.25.7", - "@babel/helper-replace-supers": "^7.25.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7", - "@babel/traverse": "^7.25.7", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-create-regexp-features-plugin": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.25.7.tgz", - "integrity": "sha512-byHhumTj/X47wJ6C6eLpK7wW/WBEcnUeb7D0FNc/jFQnQVw7DOso3Zz5u9x/zLrFVkHa89ZGDbkAa1D54NdrCQ==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "regexpu-core": "^6.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-define-polyfill-provider": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.2.tgz", - "integrity": "sha512-LV76g+C502biUK6AyZ3LK10vDpDyCzZnhZFXkH1L75zHPj68+qc8Zfpx2th+gzwA2MzyK+1g/3EPl62yFnVttQ==", - "dev": true, - "dependencies": { - "@babel/helper-compilation-targets": "^7.22.6", - "@babel/helper-plugin-utils": "^7.22.5", - "debug": "^4.1.1", - "lodash.debounce": "^4.0.8", - "resolve": "^1.14.2" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.25.7.tgz", - "integrity": "sha512-O31Ssjd5K6lPbTX9AAYpSKrZmLeagt9uwschJd+Ixo6QiRyfpvgtVQp8qrDR9UNFjZ8+DO34ZkdrN+BnPXemeA==", - "dev": true, - "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.7.tgz", - "integrity": "sha512-o0xCgpNmRohmnoWKQ0Ij8IdddjyBFE4T2kagL/x6M3+4zUgc+4qTOUBoNe4XxDskt1HPKO007ZPiMgLDq2s7Kw==", - "dev": true, - "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.7.tgz", - "integrity": "sha512-k/6f8dKG3yDz/qCwSM+RKovjMix563SLxQFo0UhRNo239SP6n9u5/eLtKD6EAjwta2JHJ49CsD8pms2HdNiMMQ==", - "dev": true, - "dependencies": { - "@babel/helper-module-imports": "^7.25.7", - "@babel/helper-simple-access": "^7.25.7", - "@babel/helper-validator-identifier": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-optimise-call-expression": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.25.7.tgz", - "integrity": "sha512-VAwcwuYhv/AT+Vfr28c9y6SHzTan1ryqrydSTFGjU0uDJHw3uZ+PduI8plCLkRsDnqK2DMEDmwrOQRsK/Ykjng==", - "dev": true, - "dependencies": { - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-plugin-utils": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.7.tgz", - "integrity": "sha512-eaPZai0PiqCi09pPs3pAFfl/zYgGaE6IdXtYvmf0qlcDTd3WCtO7JWCcRd64e0EQrcYgiHibEZnOGsSY4QSgaw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-remap-async-to-generator": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.25.7.tgz", - "integrity": "sha512-kRGE89hLnPfcz6fTrlNU+uhgcwv0mBE4Gv3P9Ke9kLVJYpi4AMVVEElXvB5CabrPZW4nCM8P8UyyjrzCM0O2sw==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "@babel/helper-wrap-function": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-replace-supers": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.25.7.tgz", - "integrity": "sha512-iy8JhqlUW9PtZkd4pHM96v6BdJ66Ba9yWSE4z0W4TvSZwLBPkyDsiIU3ENe4SmrzRBs76F7rQXTy1lYC49n6Lw==", - "dev": true, - "dependencies": { - "@babel/helper-member-expression-to-functions": "^7.25.7", - "@babel/helper-optimise-call-expression": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.7.tgz", - "integrity": "sha512-FPGAkJmyoChQeM+ruBGIDyrT2tKfZJO8NcxdC+CWNJi7N8/rZpSxK7yvBJ5O/nF1gfu5KzN7VKG3YVSLFfRSxQ==", - "dev": true, - "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.25.7.tgz", - "integrity": "sha512-pPbNbchZBkPMD50K0p3JGcFMNLVUCuU/ABybm/PGNj4JiHrpmNyqqCphBk4i19xXtNV0JhldQJJtbSW5aUvbyA==", - "dev": true, - "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz", - "integrity": "sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz", - "integrity": "sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.7.tgz", - "integrity": "sha512-ytbPLsm+GjArDYXJ8Ydr1c/KJuutjF2besPNbIZnZ6MKUxi/uTA22t2ymmA4WFjZFpjiAMO0xuuJPqK2nvDVfQ==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-wrap-function": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.25.7.tgz", - "integrity": "sha512-MA0roW3JF2bD1ptAaJnvcabsVlNQShUaThyJbCDD4bCp8NEgiFvpoqRI2YS22hHlc2thjO/fTg2ShLMC3jygAg==", - "dev": true, - "dependencies": { - "@babel/template": "^7.25.7", - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.7.tgz", - "integrity": "sha512-Sv6pASx7Esm38KQpF/U/OXLwPPrdGHNKoeblRxgZRLXnAtnkEe4ptJPDtAZM7fBLadbc1Q07kQpSiGQ0Jg6tRA==", - "dev": true, - "dependencies": { - "@babel/template": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.7.tgz", - "integrity": "sha512-iYyACpW3iW8Fw+ZybQK+drQre+ns/tKpXbNESfrhNnPLIklLbXr7MYJ6gPEd0iETGLOK+SxMjVvKb/ffmk+FEw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.25.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/parser": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz", - "integrity": "sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==", - "dev": true, - "dependencies": { - "@babel/types": "^7.25.8" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-firefox-class-in-computed-class-key": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-firefox-class-in-computed-class-key/-/plugin-bugfix-firefox-class-in-computed-class-key-7.25.7.tgz", - "integrity": "sha512-UV9Lg53zyebzD1DwQoT9mzkEKa922LNUp5YkTJ6Uta0RbyXaQNUgcvSt7qIu1PpPzVb6rd10OVNTzkyBGeVmxQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-safari-class-field-initializer-scope": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-class-field-initializer-scope/-/plugin-bugfix-safari-class-field-initializer-scope-7.25.7.tgz", - "integrity": "sha512-GDDWeVLNxRIkQTnJn2pDOM1pkCgYdSqPeT1a9vh9yIqu2uzzgw1zcqEb+IJOhy+dTBMlNdThrDIksr2o09qrrQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.25.7.tgz", - "integrity": "sha512-wxyWg2RYaSUYgmd9MR0FyRGyeOMQE/Uzr1wzd/g5cf5bwi9A4v6HFdDm7y1MgDtod/fLOSTZY6jDgV0xU9d5bA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.25.7.tgz", - "integrity": "sha512-Xwg6tZpLxc4iQjorYsyGMyfJE7nP5MV8t/Ka58BgiA7Jw0fRqQNcANlLfdJ/yvBt9z9LD2We+BEkT7vLqZRWng==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7", - "@babel/plugin-transform-optional-chaining": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.13.0" - } - }, - "node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.25.7.tgz", - "integrity": "sha512-UVATLMidXrnH+GMUIuxq55nejlj02HP7F5ETyBONzP6G87fPBogG4CH6kxrSrdIuAjdwNO9VzyaYsrZPscWUrw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", - "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", - "dev": true, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-assertions": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.25.7.tgz", - "integrity": "sha512-ZvZQRmME0zfJnDQnVBKYzHxXT7lYBB3Revz1GuS7oLXWMgqUPX4G+DDbT30ICClht9WKV34QVrZhSw6WdklwZQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.7.tgz", - "integrity": "sha512-AqVo+dguCgmpi/3mYBdu9lkngOBlQ2w2vnNpa6gfiCxQZLzV4ZbhsXitJ2Yblkoe1VQwtHSaNmIaGll/26YWRw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.7.tgz", - "integrity": "sha512-ruZOnKO+ajVL/MVx+PwNBPOkrnXTXoWMtte1MBpegfCArhqOe3Bj52avVj1huLLxNKYKXYaSxZ2F+woK1ekXfw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.7.tgz", - "integrity": "sha512-rR+5FDjpCHqqZN2bzZm18bVYGaejGq5ZkpVCJLXor/+zlSrSoc4KWcHI0URVWjl/68Dyr1uwZUz/1njycEAv9g==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-unicode-sets-regex": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz", - "integrity": "sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-arrow-functions": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.25.7.tgz", - "integrity": "sha512-EJN2mKxDwfOUCPxMO6MUI58RN3ganiRAG/MS/S3HfB6QFNjroAMelQo/gybyYq97WerCBAZoyrAoW8Tzdq2jWg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-async-generator-functions": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.25.8.tgz", - "integrity": "sha512-9ypqkozyzpG+HxlH4o4gdctalFGIjjdufzo7I2XPda0iBnZ6a+FO0rIEQcdSPXp02CkvGsII1exJhmROPQd5oA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-remap-async-to-generator": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-async-to-generator": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.25.7.tgz", - "integrity": "sha512-ZUCjAavsh5CESCmi/xCpX1qcCaAglzs/7tmuvoFnJgA1dM7gQplsguljoTg+Ru8WENpX89cQyAtWoaE0I3X3Pg==", - "dev": true, - "dependencies": { - "@babel/helper-module-imports": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-remap-async-to-generator": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoped-functions": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.25.7.tgz", - "integrity": "sha512-xHttvIM9fvqW+0a3tZlYcZYSBpSWzGBFIt/sYG3tcdSzBB8ZeVgz2gBP7Df+sM0N1850jrviYSSeUuc+135dmQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.25.7.tgz", - "integrity": "sha512-ZEPJSkVZaeTFG/m2PARwLZQ+OG0vFIhPlKHK/JdIMy8DbRJ/htz6LRrTFtdzxi9EHmcwbNPAKDnadpNSIW+Aow==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-class-properties": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.25.7.tgz", - "integrity": "sha512-mhyfEW4gufjIqYFo9krXHJ3ElbFLIze5IDp+wQTxoPd+mwFb1NxatNAwmv8Q8Iuxv7Zc+q8EkiMQwc9IhyGf4g==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-class-static-block": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.25.8.tgz", - "integrity": "sha512-e82gl3TCorath6YLf9xUwFehVvjvfqFhdOo4+0iVIVju+6XOi5XHkqB3P2AXnSwoeTX0HBoXq5gJFtvotJzFnQ==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.12.0" - } - }, - "node_modules/@babel/plugin-transform-classes": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.25.7.tgz", - "integrity": "sha512-9j9rnl+YCQY0IGoeipXvnk3niWicIB6kCsWRGLwX241qSXpbA4MKxtp/EdvFxsc4zI5vqfLxzOd0twIJ7I99zg==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "@babel/helper-compilation-targets": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-replace-supers": "^7.25.7", - "@babel/traverse": "^7.25.7", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-computed-properties": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.25.7.tgz", - "integrity": "sha512-QIv+imtM+EtNxg/XBKL3hiWjgdLjMOmZ+XzQwSgmBfKbfxUjBzGgVPklUuE55eq5/uVoh8gg3dqlrwR/jw3ZeA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/template": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-destructuring": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.25.7.tgz", - "integrity": "sha512-xKcfLTlJYUczdaM1+epcdh1UGewJqr9zATgrNHcLBcV2QmfvPPEixo/sK/syql9cEmbr7ulu5HMFG5vbbt/sEA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-dotall-regex": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.25.7.tgz", - "integrity": "sha512-kXzXMMRzAtJdDEgQBLF4oaiT6ZCU3oWHgpARnTKDAqPkDJ+bs3NrZb310YYevR5QlRo3Kn7dzzIdHbZm1VzJdQ==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-duplicate-keys": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.25.7.tgz", - "integrity": "sha512-by+v2CjoL3aMnWDOyCIg+yxU9KXSRa9tN6MbqggH5xvymmr9p4AMjYkNlQy4brMceBnUyHZ9G8RnpvT8wP7Cfg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-duplicate-named-capturing-groups-regex": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-named-capturing-groups-regex/-/plugin-transform-duplicate-named-capturing-groups-regex-7.25.7.tgz", - "integrity": "sha512-HvS6JF66xSS5rNKXLqkk7L9c/jZ/cdIVIcoPVrnl8IsVpLggTjXs8OWekbLHs/VtYDDh5WXnQyeE3PPUGm22MA==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-dynamic-import": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.25.8.tgz", - "integrity": "sha512-gznWY+mr4ZQL/EWPcbBQUP3BXS5FwZp8RUOw06BaRn8tQLzN4XLIxXejpHN9Qo8x8jjBmAAKp6FoS51AgkSA/A==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-exponentiation-operator": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.25.7.tgz", - "integrity": "sha512-yjqtpstPfZ0h/y40fAXRv2snciYr0OAoMXY/0ClC7tm4C/nG5NJKmIItlaYlLbIVAWNfrYuy9dq1bE0SbX0PEg==", - "dev": true, - "dependencies": { - "@babel/helper-builder-binary-assignment-operator-visitor": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-export-namespace-from": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.25.8.tgz", - "integrity": "sha512-sPtYrduWINTQTW7FtOy99VCTWp4H23UX7vYcut7S4CIMEXU+54zKX9uCoGkLsWXteyaMXzVHgzWbLfQ1w4GZgw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-for-of": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.25.7.tgz", - "integrity": "sha512-n/TaiBGJxYFWvpJDfsxSj9lEEE44BFM1EPGz4KEiTipTgkoFVVcCmzAL3qA7fdQU96dpo4gGf5HBx/KnDvqiHw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-function-name": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.25.7.tgz", - "integrity": "sha512-5MCTNcjCMxQ63Tdu9rxyN6cAWurqfrDZ76qvVPrGYdBxIj+EawuuxTu/+dgJlhK5eRz3v1gLwp6XwS8XaX2NiQ==", - "dev": true, - "dependencies": { - "@babel/helper-compilation-targets": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-json-strings": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.25.8.tgz", - "integrity": "sha512-4OMNv7eHTmJ2YXs3tvxAfa/I43di+VcF+M4Wt66c88EAED1RoGaf1D64cL5FkRpNL+Vx9Hds84lksWvd/wMIdA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-literals": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.25.7.tgz", - "integrity": "sha512-fwzkLrSu2fESR/cm4t6vqd7ebNIopz2QHGtjoU+dswQo/P6lwAG04Q98lliE3jkz/XqnbGFLnUcE0q0CVUf92w==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-logical-assignment-operators": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.25.8.tgz", - "integrity": "sha512-f5W0AhSbbI+yY6VakT04jmxdxz+WsID0neG7+kQZbCOjuyJNdL5Nn4WIBm4hRpKnUcO9lP0eipUhFN12JpoH8g==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-member-expression-literals": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.25.7.tgz", - "integrity": "sha512-Std3kXwpXfRV0QtQy5JJcRpkqP8/wG4XL7hSKZmGlxPlDqmpXtEPRmhF7ztnlTCtUN3eXRUJp+sBEZjaIBVYaw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-amd": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.25.7.tgz", - "integrity": "sha512-CgselSGCGzjQvKzghCvDTxKHP3iooenLpJDO842ehn5D2G5fJB222ptnDwQho0WjEvg7zyoxb9P+wiYxiJX5yA==", - "dev": true, - "dependencies": { - "@babel/helper-module-transforms": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.25.7.tgz", - "integrity": "sha512-L9Gcahi0kKFYXvweO6n0wc3ZG1ChpSFdgG+eV1WYZ3/dGbJK7vvk91FgGgak8YwRgrCuihF8tE/Xg07EkL5COg==", - "dev": true, - "dependencies": { - "@babel/helper-module-transforms": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-simple-access": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.25.7.tgz", - "integrity": "sha512-t9jZIvBmOXJsiuyOwhrIGs8dVcD6jDyg2icw1VL4A/g+FnWyJKwUfSSU2nwJuMV2Zqui856El9u+ElB+j9fV1g==", - "dev": true, - "dependencies": { - "@babel/helper-module-transforms": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-validator-identifier": "^7.25.7", - "@babel/traverse": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-umd": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.25.7.tgz", - "integrity": "sha512-p88Jg6QqsaPh+EB7I9GJrIqi1Zt4ZBHUQtjw3z1bzEXcLh6GfPqzZJ6G+G1HBGKUNukT58MnKG7EN7zXQBCODw==", - "dev": true, - "dependencies": { - "@babel/helper-module-transforms": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.25.7.tgz", - "integrity": "sha512-BtAT9LzCISKG3Dsdw5uso4oV1+v2NlVXIIomKJgQybotJY3OwCwJmkongjHgwGKoZXd0qG5UZ12JUlDQ07W6Ow==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-new-target": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.25.7.tgz", - "integrity": "sha512-CfCS2jDsbcZaVYxRFo2qtavW8SpdzmBXC2LOI4oO0rP+JSRDxxF3inF4GcPsLgfb5FjkhXG5/yR/lxuRs2pySA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-nullish-coalescing-operator": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.25.8.tgz", - "integrity": "sha512-Z7WJJWdQc8yCWgAmjI3hyC+5PXIubH9yRKzkl9ZEG647O9szl9zvmKLzpbItlijBnVhTUf1cpyWBsZ3+2wjWPQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-numeric-separator": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.25.8.tgz", - "integrity": "sha512-rm9a5iEFPS4iMIy+/A/PiS0QN0UyjPIeVvbU5EMZFKJZHt8vQnasbpo3T3EFcxzCeYO0BHfc4RqooCZc51J86Q==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-object-rest-spread": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.25.8.tgz", - "integrity": "sha512-LkUu0O2hnUKHKE7/zYOIjByMa4VRaV2CD/cdGz0AxU9we+VA3kDDggKEzI0Oz1IroG+6gUP6UmWEHBMWZU316g==", - "dev": true, - "dependencies": { - "@babel/helper-compilation-targets": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/plugin-transform-parameters": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-object-super": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.25.7.tgz", - "integrity": "sha512-pWT6UXCEW3u1t2tcAGtE15ornCBvopHj9Bps9D2DsH15APgNVOTwwczGckX+WkAvBmuoYKRCFa4DK+jM8vh5AA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-replace-supers": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-optional-catch-binding": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.25.8.tgz", - "integrity": "sha512-EbQYweoMAHOn7iJ9GgZo14ghhb9tTjgOc88xFgYngifx7Z9u580cENCV159M4xDh3q/irbhSjZVpuhpC2gKBbg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-optional-chaining": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.25.8.tgz", - "integrity": "sha512-q05Bk7gXOxpTHoQ8RSzGSh/LHVB9JEIkKnk3myAWwZHnYiTGYtbdrYkIsS8Xyh4ltKf7GNUSgzs/6P2bJtBAQg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-parameters": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.25.7.tgz", - "integrity": "sha512-FYiTvku63me9+1Nz7TOx4YMtW3tWXzfANZtrzHhUZrz4d47EEtMQhzFoZWESfXuAMMT5mwzD4+y1N8ONAX6lMQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-private-methods": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.25.7.tgz", - "integrity": "sha512-KY0hh2FluNxMLwOCHbxVOKfdB5sjWG4M183885FmaqWWiGMhRZq4DQRKH6mHdEucbJnyDyYiZNwNG424RymJjA==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-private-property-in-object": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.25.8.tgz", - "integrity": "sha512-8Uh966svuB4V8RHHg0QJOB32QK287NBksJOByoKmHMp1TAobNniNalIkI2i5IPj5+S9NYCG4VIjbEuiSN8r+ow==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "@babel/helper-create-class-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-property-literals": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.25.7.tgz", - "integrity": "sha512-lQEeetGKfFi0wHbt8ClQrUSUMfEeI3MMm74Z73T9/kuz990yYVtfofjf3NuA42Jy3auFOpbjDyCSiIkTs1VIYw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-constant-elements": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-constant-elements/-/plugin-transform-react-constant-elements-7.25.7.tgz", - "integrity": "sha512-/qXt69Em8HgsjCLu7G3zdIQn7A2QwmYND7Wa0LTp09Na+Zn8L5d0A7wSXrKi18TJRc/Q5S1i1De/SU1LzVkSvA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-display-name": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.25.7.tgz", - "integrity": "sha512-r0QY7NVU8OnrwE+w2IWiRom0wwsTbjx4+xH2RTd7AVdof3uurXOF+/mXHQDRk+2jIvWgSaCHKMgggfvM4dyUGA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-jsx": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.25.7.tgz", - "integrity": "sha512-vILAg5nwGlR9EXE8JIOX4NHXd49lrYbN8hnjffDtoULwpL9hUx/N55nqh2qd0q6FyNDfjl9V79ecKGvFbcSA0Q==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "@babel/helper-module-imports": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/plugin-syntax-jsx": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-jsx-development": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.25.7.tgz", - "integrity": "sha512-5yd3lH1PWxzW6IZj+p+Y4OLQzz0/LzlOG8vGqonHfVR3euf1vyzyMUJk9Ac+m97BH46mFc/98t9PmYLyvgL3qg==", - "dev": true, - "dependencies": { - "@babel/plugin-transform-react-jsx": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-pure-annotations": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.25.7.tgz", - "integrity": "sha512-6YTHJ7yjjgYqGc8S+CbEXhLICODk0Tn92j+vNJo07HFk9t3bjFgAKxPLFhHwF2NjmQVSI1zBRfBWUeVBa2osfA==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-regenerator": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.25.7.tgz", - "integrity": "sha512-mgDoQCRjrY3XK95UuV60tZlFCQGXEtMg8H+IsW72ldw1ih1jZhzYXbJvghmAEpg5UVhhnCeia1CkGttUvCkiMQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "regenerator-transform": "^0.15.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-reserved-words": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.25.7.tgz", - "integrity": "sha512-3OfyfRRqiGeOvIWSagcwUTVk2hXBsr/ww7bLn6TRTuXnexA+Udov2icFOxFX9abaj4l96ooYkcNN1qi2Zvqwng==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-shorthand-properties": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.25.7.tgz", - "integrity": "sha512-uBbxNwimHi5Bv3hUccmOFlUy3ATO6WagTApenHz9KzoIdn0XeACdB12ZJ4cjhuB2WSi80Ez2FWzJnarccriJeA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-spread": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.25.7.tgz", - "integrity": "sha512-Mm6aeymI0PBh44xNIv/qvo8nmbkpZze1KvR8MkEqbIREDxoiWTi18Zr2jryfRMwDfVZF9foKh060fWgni44luw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-sticky-regex": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.25.7.tgz", - "integrity": "sha512-ZFAeNkpGuLnAQ/NCsXJ6xik7Id+tHuS+NT+ue/2+rn/31zcdnupCdmunOizEaP0JsUmTFSTOPoQY7PkK2pttXw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-template-literals": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.25.7.tgz", - "integrity": "sha512-SI274k0nUsFFmyQupiO7+wKATAmMFf8iFgq2O+vVFXZ0SV9lNfT1NGzBEhjquFmD8I9sqHLguH+gZVN3vww2AA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-typeof-symbol": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.25.7.tgz", - "integrity": "sha512-OmWmQtTHnO8RSUbL0NTdtpbZHeNTnm68Gj5pA4Y2blFNh+V4iZR68V1qL9cI37J21ZN7AaCnkfdHtLExQPf2uA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-typescript": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.25.7.tgz", - "integrity": "sha512-VKlgy2vBzj8AmEzunocMun2fF06bsSWV+FvVXohtL6FGve/+L217qhHxRTVGHEDO/YR8IANcjzgJsd04J8ge5Q==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.25.7", - "@babel/helper-create-class-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7", - "@babel/plugin-syntax-typescript": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-escapes": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.25.7.tgz", - "integrity": "sha512-BN87D7KpbdiABA+t3HbVqHzKWUDN3dymLaTnPFAMyc8lV+KN3+YzNhVRNdinaCPA4AUqx7ubXbQ9shRjYBl3SQ==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-property-regex": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.25.7.tgz", - "integrity": "sha512-IWfR89zcEPQGB/iB408uGtSPlQd3Jpq11Im86vUgcmSTcoWAiQMCTOa2K2yNNqFJEBVICKhayctee65Ka8OB0w==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-regex": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.25.7.tgz", - "integrity": "sha512-8JKfg/hiuA3qXnlLx8qtv5HWRbgyFx2hMMtpDDuU2rTckpKkGu4ycK5yYHwuEa16/quXfoxHBIApEsNyMWnt0g==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-sets-regex": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.25.7.tgz", - "integrity": "sha512-YRW8o9vzImwmh4Q3Rffd09bH5/hvY0pxg+1H1i0f7APoUeg12G7+HhLj9ZFNIrYkgBXhIijPJ+IXypN0hLTIbw==", - "dev": true, - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/preset-env": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.25.8.tgz", - "integrity": "sha512-58T2yulDHMN8YMUxiLq5YmWUnlDCyY1FsHM+v12VMx+1/FlrUj5tY50iDCpofFQEM8fMYOaY9YRvym2jcjn1Dg==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.25.8", - "@babel/helper-compilation-targets": "^7.25.7", - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-validator-option": "^7.25.7", - "@babel/plugin-bugfix-firefox-class-in-computed-class-key": "^7.25.7", - "@babel/plugin-bugfix-safari-class-field-initializer-scope": "^7.25.7", - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.25.7", - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.25.7", - "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": "^7.25.7", - "@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", - "@babel/plugin-syntax-import-assertions": "^7.25.7", - "@babel/plugin-syntax-import-attributes": "^7.25.7", - "@babel/plugin-syntax-unicode-sets-regex": "^7.18.6", - "@babel/plugin-transform-arrow-functions": "^7.25.7", - "@babel/plugin-transform-async-generator-functions": "^7.25.8", - "@babel/plugin-transform-async-to-generator": "^7.25.7", - "@babel/plugin-transform-block-scoped-functions": "^7.25.7", - "@babel/plugin-transform-block-scoping": "^7.25.7", - "@babel/plugin-transform-class-properties": "^7.25.7", - "@babel/plugin-transform-class-static-block": "^7.25.8", - "@babel/plugin-transform-classes": "^7.25.7", - "@babel/plugin-transform-computed-properties": "^7.25.7", - "@babel/plugin-transform-destructuring": "^7.25.7", - "@babel/plugin-transform-dotall-regex": "^7.25.7", - "@babel/plugin-transform-duplicate-keys": "^7.25.7", - "@babel/plugin-transform-duplicate-named-capturing-groups-regex": "^7.25.7", - "@babel/plugin-transform-dynamic-import": "^7.25.8", - "@babel/plugin-transform-exponentiation-operator": "^7.25.7", - "@babel/plugin-transform-export-namespace-from": "^7.25.8", - "@babel/plugin-transform-for-of": "^7.25.7", - "@babel/plugin-transform-function-name": "^7.25.7", - "@babel/plugin-transform-json-strings": "^7.25.8", - "@babel/plugin-transform-literals": "^7.25.7", - "@babel/plugin-transform-logical-assignment-operators": "^7.25.8", - "@babel/plugin-transform-member-expression-literals": "^7.25.7", - "@babel/plugin-transform-modules-amd": "^7.25.7", - "@babel/plugin-transform-modules-commonjs": "^7.25.7", - "@babel/plugin-transform-modules-systemjs": "^7.25.7", - "@babel/plugin-transform-modules-umd": "^7.25.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.25.7", - "@babel/plugin-transform-new-target": "^7.25.7", - "@babel/plugin-transform-nullish-coalescing-operator": "^7.25.8", - "@babel/plugin-transform-numeric-separator": "^7.25.8", - "@babel/plugin-transform-object-rest-spread": "^7.25.8", - "@babel/plugin-transform-object-super": "^7.25.7", - "@babel/plugin-transform-optional-catch-binding": "^7.25.8", - "@babel/plugin-transform-optional-chaining": "^7.25.8", - "@babel/plugin-transform-parameters": "^7.25.7", - "@babel/plugin-transform-private-methods": "^7.25.7", - "@babel/plugin-transform-private-property-in-object": "^7.25.8", - "@babel/plugin-transform-property-literals": "^7.25.7", - "@babel/plugin-transform-regenerator": "^7.25.7", - "@babel/plugin-transform-reserved-words": "^7.25.7", - "@babel/plugin-transform-shorthand-properties": "^7.25.7", - "@babel/plugin-transform-spread": "^7.25.7", - "@babel/plugin-transform-sticky-regex": "^7.25.7", - "@babel/plugin-transform-template-literals": "^7.25.7", - "@babel/plugin-transform-typeof-symbol": "^7.25.7", - "@babel/plugin-transform-unicode-escapes": "^7.25.7", - "@babel/plugin-transform-unicode-property-regex": "^7.25.7", - "@babel/plugin-transform-unicode-regex": "^7.25.7", - "@babel/plugin-transform-unicode-sets-regex": "^7.25.7", - "@babel/preset-modules": "0.1.6-no-external-plugins", - "babel-plugin-polyfill-corejs2": "^0.4.10", - "babel-plugin-polyfill-corejs3": "^0.10.6", - "babel-plugin-polyfill-regenerator": "^0.6.1", - "core-js-compat": "^3.38.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-modules": { - "version": "0.1.6-no-external-plugins", - "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz", - "integrity": "sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/types": "^7.4.4", - "esutils": "^2.0.2" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/@babel/preset-react": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.25.7.tgz", - "integrity": "sha512-GjV0/mUEEXpi1U5ZgDprMRRgajGMRW3G5FjMr5KLKD8nT2fTG8+h/klV3+6Dm5739QE+K5+2e91qFKAYI3pmRg==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-validator-option": "^7.25.7", - "@babel/plugin-transform-react-display-name": "^7.25.7", - "@babel/plugin-transform-react-jsx": "^7.25.7", - "@babel/plugin-transform-react-jsx-development": "^7.25.7", - "@babel/plugin-transform-react-pure-annotations": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-typescript": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.25.7.tgz", - "integrity": "sha512-rkkpaXJZOFN45Fb+Gki0c+KMIglk4+zZXOoMJuyEK8y8Kkc8Jd3BDmP7qPsz0zQMJj+UD7EprF+AqAXcILnexw==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-validator-option": "^7.25.7", - "@babel/plugin-syntax-jsx": "^7.25.7", - "@babel/plugin-transform-modules-commonjs": "^7.25.7", - "@babel/plugin-transform-typescript": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/runtime": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.7.tgz", - "integrity": "sha512-FjoyLe754PMiYsFaN5C94ttGiOmBNYTf6pLr4xXHAT5uctHb092PBszndLDR5XA/jghQvn4n7JMHl7dmTgbm9w==", - "dev": true, - "dependencies": { - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.7.tgz", - "integrity": "sha512-wRwtAgI3bAS+JGU2upWNL9lSlDcRCqD05BZ1n3X2ONLH1WilFP6O1otQjeMK/1g0pvYcXC7b/qVUB1keofjtZA==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.25.7", - "@babel/parser": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.7.tgz", - "integrity": "sha512-jatJPT1Zjqvh/1FyJs6qAHL+Dzb7sTb+xr7Q+gM1b+1oBsMsQQ4FkVKb6dFlJvLlVssqkRzV05Jzervt9yhnzg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.25.7", - "@babel/generator": "^7.25.7", - "@babel/parser": "^7.25.7", - "@babel/template": "^7.25.7", - "@babel/types": "^7.25.7", - "debug": "^4.3.1", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz", - "integrity": "sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==", - "dev": true, - "dependencies": { - "@babel/helper-string-parser": "^7.25.7", - "@babel/helper-validator-identifier": "^7.25.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@braintree/sanitize-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-7.1.0.tgz", - "integrity": "sha512-o+UlMLt49RvtCASlOMW0AkHnabN9wR9rwCCherxO0yG4Npy34GkvrAqdXQvrhNs+jh+gkK8gB8Lf05qL/O7KWg==", - "dev": true - }, - "node_modules/@chevrotain/cst-dts-gen": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@chevrotain/cst-dts-gen/-/cst-dts-gen-11.0.3.tgz", - "integrity": "sha512-BvIKpRLeS/8UbfxXxgC33xOumsacaeCKAjAeLyOn7Pcp95HiRbrpl14S+9vaZLolnbssPIUuiUd8IvgkRyt6NQ==", - "dev": true, - "dependencies": { - "@chevrotain/gast": "11.0.3", - "@chevrotain/types": "11.0.3", - "lodash-es": "4.17.21" - } - }, - "node_modules/@chevrotain/gast": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@chevrotain/gast/-/gast-11.0.3.tgz", - "integrity": "sha512-+qNfcoNk70PyS/uxmj3li5NiECO+2YKZZQMbmjTqRI3Qchu8Hig/Q9vgkHpI3alNjr7M+a2St5pw5w5F6NL5/Q==", - "dev": true, - "dependencies": { - "@chevrotain/types": "11.0.3", - "lodash-es": "4.17.21" - } - }, - "node_modules/@chevrotain/regexp-to-ast": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@chevrotain/regexp-to-ast/-/regexp-to-ast-11.0.3.tgz", - "integrity": "sha512-1fMHaBZxLFvWI067AVbGJav1eRY7N8DDvYCTwGBiE/ytKBgP8azTdgyrKyWZ9Mfh09eHWb5PgTSO8wi7U824RA==", - "dev": true - }, - "node_modules/@chevrotain/types": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@chevrotain/types/-/types-11.0.3.tgz", - "integrity": "sha512-gsiM3G8b58kZC2HaWR50gu6Y1440cHiJ+i3JUvcp/35JchYejb2+5MVeJK0iKThYpAa/P2PYFV4hoi44HD+aHQ==", - "dev": true - }, - "node_modules/@chevrotain/utils": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@chevrotain/utils/-/utils-11.0.3.tgz", - "integrity": "sha512-YslZMgtJUyuMbZ+aKvfF3x1f5liK4mWNxghFRv7jqRR9C3R3fAOGTTKvxXDa2Y1s9zSbcpuO0cAxDYsc9SrXoQ==", - "dev": true - }, - "node_modules/@floating-ui/core": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.8.tgz", - "integrity": "sha512-7XJ9cPU+yI2QeLS+FCSlqNFZJq8arvswefkZrYI1yQBbftw6FyrZOxYSh+9S7z7TpeWlRt9zJ5IhM1WIL334jA==", - "dev": true, - "dependencies": { - "@floating-ui/utils": "^0.2.8" - } - }, - "node_modules/@floating-ui/dom": { - "version": "1.6.11", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.11.tgz", - "integrity": "sha512-qkMCxSR24v2vGkhYDo/UzxfJN3D4syqSjyuTFz6C7XcpU1pASPRieNI0Kj5VP3/503mOfYiGY891ugBX1GlABQ==", - "dev": true, - "dependencies": { - "@floating-ui/core": "^1.6.0", - "@floating-ui/utils": "^0.2.8" - } - }, - "node_modules/@floating-ui/react": { - "version": "0.26.25", - "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.26.25.tgz", - "integrity": "sha512-hZOmgN0NTOzOuZxI1oIrDu3Gcl8WViIkvPMpB4xdd4QD6xAMtwgwr3VPoiyH/bLtRcS1cDnhxLSD1NsMJmwh/A==", - "dev": true, - "dependencies": { - "@floating-ui/react-dom": "^2.1.2", - "@floating-ui/utils": "^0.2.8", - "tabbable": "^6.0.0" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@floating-ui/react-dom": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.2.tgz", - "integrity": "sha512-06okr5cgPzMNBy+Ycse2A6udMi4bqwW/zgBF/rwjcNqWkyr82Mcg8b0vjX8OJpZFy/FKjJmw6wV7t44kK6kW7A==", - "dev": true, - "dependencies": { - "@floating-ui/dom": "^1.0.0" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@floating-ui/utils": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.8.tgz", - "integrity": "sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==", - "dev": true - }, - "node_modules/@formatjs/intl-localematcher": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.5.5.tgz", - "integrity": "sha512-t5tOGMgZ/i5+ALl2/offNqAQq/lfUnKLEw0mXQI4N4bqpedhrSE+fyKLpwnd22sK0dif6AV+ufQcTsKShB9J1g==", - "dev": true, - "dependencies": { - "tslib": "^2.7.0" - } - }, - "node_modules/@headlessui/react": { - "version": "2.1.10", - "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-2.1.10.tgz", - "integrity": "sha512-6mLa2fjMDAFQi+/R10B+zU3edsUk/MDtENB2zHho0lqKU1uzhAfJLUduWds4nCo8wbl3vULtC5rJfZAQ1yqIng==", - "dev": true, - "dependencies": { - "@floating-ui/react": "^0.26.16", - "@react-aria/focus": "^3.17.1", - "@react-aria/interactions": "^3.21.3", - "@tanstack/react-virtual": "^3.8.1" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "react": "^18", - "react-dom": "^18" - } - }, - "node_modules/@iconify/types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz", - "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==", - "dev": true - }, - "node_modules/@iconify/utils": { - "version": "2.1.33", - "resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-2.1.33.tgz", - "integrity": "sha512-jP9h6v/g0BIZx0p7XGJJVtkVnydtbgTgt9mVNcGDYwaa7UhdHdI9dvoq+gKj9sijMSJKxUPEG2JyjsgXjxL7Kw==", - "dev": true, - "dependencies": { - "@antfu/install-pkg": "^0.4.0", - "@antfu/utils": "^0.7.10", - "@iconify/types": "^2.0.0", - "debug": "^4.3.6", - "kolorist": "^1.8.0", - "local-pkg": "^0.5.0", - "mlly": "^1.7.1" - } - }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", - "dev": true, - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", - "dev": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@mdx-js/mdx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@mdx-js/mdx/-/mdx-3.0.1.tgz", - "integrity": "sha512-eIQ4QTrOWyL3LWEe/bu6Taqzq2HQvHcyTMaOrI95P2/LmJE7AsfPfgJGuFLPVqBUE1BC1rik3VIhU+s9u72arA==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/mdx": "^2.0.0", - "collapse-white-space": "^2.0.0", - "devlop": "^1.0.0", - "estree-util-build-jsx": "^3.0.0", - "estree-util-is-identifier-name": "^3.0.0", - "estree-util-to-js": "^2.0.0", - "estree-walker": "^3.0.0", - "hast-util-to-estree": "^3.0.0", - "hast-util-to-jsx-runtime": "^2.0.0", - "markdown-extensions": "^2.0.0", - "periscopic": "^3.0.0", - "remark-mdx": "^3.0.0", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.0.0", - "source-map": "^0.7.0", - "unified": "^11.0.0", - "unist-util-position-from-estree": "^2.0.0", - "unist-util-stringify-position": "^4.0.0", - "unist-util-visit": "^5.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/@mdx-js/react": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-3.0.1.tgz", - "integrity": "sha512-9ZrPIU4MGf6et1m1ov3zKf+q9+deetI51zprKB1D/z3NOb+rUxxtEl3mCjW5wTGh6VhRdwPueh1oRzi6ezkA8A==", - "dev": true, - "dependencies": { - "@types/mdx": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - }, - "peerDependencies": { - "@types/react": ">=16", - "react": ">=16" - } - }, - "node_modules/@mermaid-js/parser": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@mermaid-js/parser/-/parser-0.3.0.tgz", - "integrity": "sha512-HsvL6zgE5sUPGgkIDlmAWR1HTNHz2Iy11BAWPTa4Jjabkpguy4Ze2gzfLrg6pdRuBvFwgUYyxiaNqZwrEEXepA==", - "dev": true, - "dependencies": { - "langium": "3.0.0" - } - }, - "node_modules/@napi-rs/simple-git": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git/-/simple-git-0.1.19.tgz", - "integrity": "sha512-jMxvwzkKzd3cXo2EB9GM2ic0eYo2rP/BS6gJt6HnWbsDO1O8GSD4k7o2Cpr2YERtMpGF/MGcDfsfj2EbQPtrXw==", - "dev": true, - "engines": { - "node": ">= 10" - }, - "optionalDependencies": { - "@napi-rs/simple-git-android-arm-eabi": "0.1.19", - "@napi-rs/simple-git-android-arm64": "0.1.19", - "@napi-rs/simple-git-darwin-arm64": "0.1.19", - "@napi-rs/simple-git-darwin-x64": "0.1.19", - "@napi-rs/simple-git-freebsd-x64": "0.1.19", - "@napi-rs/simple-git-linux-arm-gnueabihf": "0.1.19", - "@napi-rs/simple-git-linux-arm64-gnu": "0.1.19", - "@napi-rs/simple-git-linux-arm64-musl": "0.1.19", - "@napi-rs/simple-git-linux-powerpc64le-gnu": "0.1.19", - "@napi-rs/simple-git-linux-s390x-gnu": "0.1.19", - "@napi-rs/simple-git-linux-x64-gnu": "0.1.19", - "@napi-rs/simple-git-linux-x64-musl": "0.1.19", - "@napi-rs/simple-git-win32-arm64-msvc": "0.1.19", - "@napi-rs/simple-git-win32-x64-msvc": "0.1.19" - } - }, - "node_modules/@napi-rs/simple-git-android-arm-eabi": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-android-arm-eabi/-/simple-git-android-arm-eabi-0.1.19.tgz", - "integrity": "sha512-XryEH/hadZ4Duk/HS/HC/cA1j0RHmqUGey3MsCf65ZS0VrWMqChXM/xlTPWuY5jfCc/rPubHaqI7DZlbexnX/g==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-android-arm64": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-android-arm64/-/simple-git-android-arm64-0.1.19.tgz", - "integrity": "sha512-ZQ0cPvY6nV9p7zrR9ZPo7hQBkDAcY/CHj3BjYNhykeUCiSNCrhvwX+WEeg5on8M1j4d5jcI/cwVG2FslfiByUg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-darwin-arm64": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-darwin-arm64/-/simple-git-darwin-arm64-0.1.19.tgz", - "integrity": "sha512-viZB5TYgjA1vH+QluhxZo0WKro3xBA+1xSzYx8mcxUMO5gnAoUMwXn0ZO/6Zy6pai+aGae+cj6XihGnrBRu3Pg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-darwin-x64": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-darwin-x64/-/simple-git-darwin-x64-0.1.19.tgz", - "integrity": "sha512-6dNkzSNUV5X9rsVYQbpZLyJu4Gtkl2vNJ3abBXHX/Etk0ILG5ZasO3ncznIANZQpqcbn/QPHr49J2QYAXGoKJA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-freebsd-x64": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-freebsd-x64/-/simple-git-freebsd-x64-0.1.19.tgz", - "integrity": "sha512-sB9krVIchzd20FjI2ZZ8FDsTSsXLBdnwJ6CpeVyrhXHnoszfcqxt49ocZHujAS9lMpXq7i2Nv1EXJmCy4KdhwA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-linux-arm-gnueabihf": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm-gnueabihf/-/simple-git-linux-arm-gnueabihf-0.1.19.tgz", - "integrity": "sha512-6HPn09lr9N1n5/XKfP8Np53g4fEXVxOFqNkS6rTH3Rm1lZHdazTRH62RggXLTguZwjcE+MvOLvoTIoR5kAS8+g==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-linux-arm64-gnu": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm64-gnu/-/simple-git-linux-arm64-gnu-0.1.19.tgz", - "integrity": "sha512-G0gISckt4cVDp3oh5Z6PV3GHJrJO6Z8bIS+9xA7vTtKdqB1i5y0n3cSFLlzQciLzhr+CajFD27doW4lEyErQ/Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-linux-arm64-musl": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm64-musl/-/simple-git-linux-arm64-musl-0.1.19.tgz", - "integrity": "sha512-OwTRF+H4IZYxmDFRi1IrLMfqbdIpvHeYbJl2X94NVsLVOY+3NUHvEzL3fYaVx5urBaMnIK0DD3wZLbcueWvxbA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-linux-powerpc64le-gnu": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-powerpc64le-gnu/-/simple-git-linux-powerpc64le-gnu-0.1.19.tgz", - "integrity": "sha512-p7zuNNVyzpRvkCt2RIGv9FX/WPcPbZ6/FRUgUTZkA2WU33mrbvNqSi4AOqCCl6mBvEd+EOw5NU4lS9ORRJvAEg==", - "cpu": [ - "powerpc64le" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-linux-s390x-gnu": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-s390x-gnu/-/simple-git-linux-s390x-gnu-0.1.19.tgz", - "integrity": "sha512-6N2vwJUPLiak8GLrS0a3is0gSb0UwI2CHOOqtvQxPmv+JVI8kn3vKiUscsktdDb0wGEPeZ8PvZs0y8UWix7K4g==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-linux-x64-gnu": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-x64-gnu/-/simple-git-linux-x64-gnu-0.1.19.tgz", - "integrity": "sha512-61YfeO1J13WK7MalLgP3QlV6of2rWnVw1aqxWkAgy/lGxoOFSJ4Wid6ANVCEZk4tJpPX/XNeneqkUz5xpeb2Cw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-linux-x64-musl": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-x64-musl/-/simple-git-linux-x64-musl-0.1.19.tgz", - "integrity": "sha512-cCTWNpMJnN3PrUBItWcs3dQKCydsIasbrS3laMzq8k7OzF93Zrp2LWDTPlLCO9brbBVpBzy2Qk5Xg9uAfe/Ukw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-win32-arm64-msvc": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-win32-arm64-msvc/-/simple-git-win32-arm64-msvc-0.1.19.tgz", - "integrity": "sha512-sWavb1BjeLKKBA+PbTsRSSzVNfb7V/dOpaJvkgR5d2kWFn/AHmCZHSSj/3nyZdYf0BdDC+DIvqk3daAEZ6QMVw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/simple-git-win32-x64-msvc": { - "version": "0.1.19", - "resolved": "https://registry.npmjs.org/@napi-rs/simple-git-win32-x64-msvc/-/simple-git-win32-x64-msvc-0.1.19.tgz", - "integrity": "sha512-FmNuPoK4+qwaSCkp8lm3sJlrxk374enW+zCE5ZksXlZzj/9BDJAULJb5QUJ7o9Y8A/G+d8LkdQLPBE2Jaxe5XA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/env": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.15.tgz", - "integrity": "sha512-S1qaj25Wru2dUpcIZMjxeMVSwkt8BK4dmWHHiBuRstcIyOsMapqT4A4jSB6onvqeygkSSmOkyny9VVx8JIGamQ==", - "dev": true - }, - "node_modules/@next/swc-darwin-arm64": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.15.tgz", - "integrity": "sha512-Rvh7KU9hOUBnZ9TJ28n2Oa7dD9cvDBKua9IKx7cfQQ0GoYUwg9ig31O2oMwH3wm+pE3IkAQ67ZobPfEgurPZIA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-x64": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.15.tgz", - "integrity": "sha512-5TGyjFcf8ampZP3e+FyCax5zFVHi+Oe7sZyaKOngsqyaNEpOgkKB3sqmymkZfowy3ufGA/tUgDPPxpQx931lHg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.15.tgz", - "integrity": "sha512-3Bwv4oc08ONiQ3FiOLKT72Q+ndEMyLNsc/D3qnLMbtUYTQAmkx9E/JRu0DBpHxNddBmNT5hxz1mYBphJ3mfrrw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.15.tgz", - "integrity": "sha512-k5xf/tg1FBv/M4CMd8S+JL3uV9BnnRmoe7F+GWC3DxkTCD9aewFRH1s5rJ1zkzDa+Do4zyN8qD0N8c84Hu96FQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.15.tgz", - "integrity": "sha512-kE6q38hbrRbKEkkVn62reLXhThLRh6/TvgSP56GkFNhU22TbIrQDEMrO7j0IcQHcew2wfykq8lZyHFabz0oBrA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.15.tgz", - "integrity": "sha512-PZ5YE9ouy/IdO7QVJeIcyLn/Rc4ml9M2G4y3kCM9MNf1YKvFY4heg3pVa/jQbMro+tP6yc4G2o9LjAz1zxD7tQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.15.tgz", - "integrity": "sha512-2raR16703kBvYEQD9HNLyb0/394yfqzmIeyp2nDzcPV4yPjqNUG3ohX6jX00WryXz6s1FXpVhsCo3i+g4RUX+g==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.15.tgz", - "integrity": "sha512-fyTE8cklgkyR1p03kJa5zXEaZ9El+kDNM5A+66+8evQS5e/6v0Gk28LqA0Jet8gKSOyP+OTm/tJHzMlGdQerdQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.15.tgz", - "integrity": "sha512-SzqGbsLsP9OwKNUG9nekShTwhj6JSB9ZLMWQ8g1gG6hdE5gQLncbnbymrwy2yVmH9nikSLYRYxYMFu78Ggp7/g==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "optional": true, - "engines": { - "node": ">=14" - } - }, - "node_modules/@react-aria/focus": { - "version": "3.18.4", - "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.18.4.tgz", - "integrity": "sha512-91J35077w9UNaMK1cpMUEFRkNNz0uZjnSwiyBCFuRdaVuivO53wNC9XtWSDNDdcO5cGy87vfJRVAiyoCn/mjqA==", - "dev": true, - "dependencies": { - "@react-aria/interactions": "^3.22.4", - "@react-aria/utils": "^3.25.3", - "@react-types/shared": "^3.25.0", - "@swc/helpers": "^0.5.0", - "clsx": "^2.0.0" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" - } - }, - "node_modules/@react-aria/interactions": { - "version": "3.22.4", - "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.22.4.tgz", - "integrity": "sha512-E0vsgtpItmknq/MJELqYJwib+YN18Qag8nroqwjk1qOnBa9ROIkUhWJerLi1qs5diXq9LHKehZDXRlwPvdEFww==", - "dev": true, - "dependencies": { - "@react-aria/ssr": "^3.9.6", - "@react-aria/utils": "^3.25.3", - "@react-types/shared": "^3.25.0", - "@swc/helpers": "^0.5.0" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" - } - }, - "node_modules/@react-aria/ssr": { - "version": "3.9.6", - "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.6.tgz", - "integrity": "sha512-iLo82l82ilMiVGy342SELjshuWottlb5+VefO3jOQqQRNYnJBFpUSadswDPbRimSgJUZuFwIEYs6AabkP038fA==", - "dev": true, - "dependencies": { - "@swc/helpers": "^0.5.0" - }, - "engines": { - "node": ">= 12" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" - } - }, - "node_modules/@react-aria/utils": { - "version": "3.25.3", - "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.25.3.tgz", - "integrity": "sha512-PR5H/2vaD8fSq0H/UB9inNbc8KDcVmW6fYAfSWkkn+OAdhTTMVKqXXrZuZBWyFfSD5Ze7VN6acr4hrOQm2bmrA==", - "dev": true, - "dependencies": { - "@react-aria/ssr": "^3.9.6", - "@react-stately/utils": "^3.10.4", - "@react-types/shared": "^3.25.0", - "@swc/helpers": "^0.5.0", - "clsx": "^2.0.0" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" - } - }, - "node_modules/@react-stately/utils": { - "version": "3.10.4", - "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.4.tgz", - "integrity": "sha512-gBEQEIMRh5f60KCm7QKQ2WfvhB2gLUr9b72sqUdIZ2EG+xuPgaIlCBeSicvjmjBvYZwOjoOEnmIkcx2GHp/HWw==", - "dev": true, - "dependencies": { - "@swc/helpers": "^0.5.0" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" - } - }, - "node_modules/@react-types/shared": { - "version": "3.25.0", - "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.25.0.tgz", - "integrity": "sha512-OZSyhzU6vTdW3eV/mz5i6hQwQUhkRs7xwY2d1aqPvTdMe0+2cY7Fwp45PAiwYLEj73i9ro2FxF9qC4DvHGSCgQ==", - "dev": true, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" - } - }, - "node_modules/@shikijs/core": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.22.0.tgz", - "integrity": "sha512-S8sMe4q71TJAW+qG93s5VaiihujRK6rqDFqBnxqvga/3LvqHEnxqBIOPkt//IdXVtHkQWKu4nOQNk0uBGicU7Q==", - "dev": true, - "dependencies": { - "@shikijs/engine-javascript": "1.22.0", - "@shikijs/engine-oniguruma": "1.22.0", - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0", - "@types/hast": "^3.0.4", - "hast-util-to-html": "^9.0.3" - } - }, - "node_modules/@shikijs/engine-javascript": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.22.0.tgz", - "integrity": "sha512-AeEtF4Gcck2dwBqCFUKYfsCq0s+eEbCEbkUuFou53NZ0sTGnJnJ/05KHQFZxpii5HMXbocV9URYVowOP2wH5kw==", - "dev": true, - "dependencies": { - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0", - "oniguruma-to-js": "0.4.3" - } - }, - "node_modules/@shikijs/engine-oniguruma": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.22.0.tgz", - "integrity": "sha512-5iBVjhu/DYs1HB0BKsRRFipRrD7rqjxlWTj4F2Pf+nQSPqc3kcyqFFeZXnBMzDf0HdqaFVvhDRAGiYNvyLP+Mw==", - "dev": true, - "dependencies": { - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0" - } - }, - "node_modules/@shikijs/twoslash": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.22.0.tgz", - "integrity": "sha512-r5F/x4GTh18XzhAREehgT9lCDFZlISBSIsOFZQQaqjiOLG81PIqJN1I1D6XY58UN9OJt+3mffuKq19K4FOJKJA==", - "dev": true, - "dependencies": { - "@shikijs/core": "1.22.0", - "@shikijs/types": "1.22.0", - "twoslash": "^0.2.12" - } - }, - "node_modules/@shikijs/types": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.22.0.tgz", - "integrity": "sha512-Fw/Nr7FGFhlQqHfxzZY8Cwtwk5E9nKDUgeLjZgt3UuhcM3yJR9xj3ZGNravZZok8XmEZMiYkSMTPlPkULB8nww==", - "dev": true, - "dependencies": { - "@shikijs/vscode-textmate": "^9.3.0", - "@types/hast": "^3.0.4" - } - }, - "node_modules/@shikijs/vscode-textmate": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-9.3.0.tgz", - "integrity": "sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==", - "dev": true - }, - "node_modules/@svgr/babel-plugin-add-jsx-attribute": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-8.0.0.tgz", - "integrity": "sha512-b9MIk7yhdS1pMCZM8VeNfUlSKVRhsHZNMl5O9SfaX0l0t5wjdgu4IDzGB8bpnGBBOjGST3rRFVsaaEtI4W6f7g==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-plugin-remove-jsx-attribute": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-8.0.0.tgz", - "integrity": "sha512-BcCkm/STipKvbCl6b7QFrMh/vx00vIP63k2eM66MfHJzPr6O2U0jYEViXkHJWqXqQYjdeA9cuCl5KWmlwjDvbA==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-plugin-remove-jsx-empty-expression": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-8.0.0.tgz", - "integrity": "sha512-5BcGCBfBxB5+XSDSWnhTThfI9jcO5f0Ai2V24gZpG+wXF14BzwxxdDb4g6trdOux0rhibGs385BeFMSmxtS3uA==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-plugin-replace-jsx-attribute-value": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-replace-jsx-attribute-value/-/babel-plugin-replace-jsx-attribute-value-8.0.0.tgz", - "integrity": "sha512-KVQ+PtIjb1BuYT3ht8M5KbzWBhdAjjUPdlMtpuw/VjT8coTrItWX6Qafl9+ji831JaJcu6PJNKCV0bp01lBNzQ==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-plugin-svg-dynamic-title": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-dynamic-title/-/babel-plugin-svg-dynamic-title-8.0.0.tgz", - "integrity": "sha512-omNiKqwjNmOQJ2v6ge4SErBbkooV2aAWwaPFs2vUY7p7GhVkzRkJ00kILXQvRhA6miHnNpXv7MRnnSjdRjK8og==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-plugin-svg-em-dimensions": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-em-dimensions/-/babel-plugin-svg-em-dimensions-8.0.0.tgz", - "integrity": "sha512-mURHYnu6Iw3UBTbhGwE/vsngtCIbHE43xCRK7kCw4t01xyGqb2Pd+WXekRRoFOBIY29ZoOhUCTEweDMdrjfi9g==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-plugin-transform-react-native-svg": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-react-native-svg/-/babel-plugin-transform-react-native-svg-8.1.0.tgz", - "integrity": "sha512-Tx8T58CHo+7nwJ+EhUwx3LfdNSG9R2OKfaIXXs5soiy5HtgoAEkDay9LIimLOcG8dJQH1wPZp/cnAv6S9CrR1Q==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-plugin-transform-svg-component": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-svg-component/-/babel-plugin-transform-svg-component-8.0.0.tgz", - "integrity": "sha512-DFx8xa3cZXTdb/k3kfPeaixecQLgKh5NVBMwD0AQxOzcZawK4oo1Jh9LbrcACUivsCA7TLG8eeWgrDXjTMhRmw==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/babel-preset": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-preset/-/babel-preset-8.1.0.tgz", - "integrity": "sha512-7EYDbHE7MxHpv4sxvnVPngw5fuR6pw79SkcrILHJ/iMpuKySNCl5W1qcwPEpU+LgyRXOaAFgH0KhwD18wwg6ug==", - "dev": true, - "dependencies": { - "@svgr/babel-plugin-add-jsx-attribute": "8.0.0", - "@svgr/babel-plugin-remove-jsx-attribute": "8.0.0", - "@svgr/babel-plugin-remove-jsx-empty-expression": "8.0.0", - "@svgr/babel-plugin-replace-jsx-attribute-value": "8.0.0", - "@svgr/babel-plugin-svg-dynamic-title": "8.0.0", - "@svgr/babel-plugin-svg-em-dimensions": "8.0.0", - "@svgr/babel-plugin-transform-react-native-svg": "8.1.0", - "@svgr/babel-plugin-transform-svg-component": "8.0.0" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@svgr/core": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@svgr/core/-/core-8.1.0.tgz", - "integrity": "sha512-8QqtOQT5ACVlmsvKOJNEaWmRPmcojMOzCz4Hs2BGG/toAp/K38LcsMRyLp349glq5AzJbCEeimEoxaX6v/fLrA==", - "dev": true, - "dependencies": { - "@babel/core": "^7.21.3", - "@svgr/babel-preset": "8.1.0", - "camelcase": "^6.2.0", - "cosmiconfig": "^8.1.3", - "snake-case": "^3.0.4" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/hast-util-to-babel-ast": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@svgr/hast-util-to-babel-ast/-/hast-util-to-babel-ast-8.0.0.tgz", - "integrity": "sha512-EbDKwO9GpfWP4jN9sGdYwPBU0kdomaPIL2Eu4YwmgP+sJeXT+L7bMwJUBnhzfH8Q2qMBqZ4fJwpCyYsAN3mt2Q==", - "dev": true, - "dependencies": { - "@babel/types": "^7.21.3", - "entities": "^4.4.0" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/plugin-jsx": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@svgr/plugin-jsx/-/plugin-jsx-8.1.0.tgz", - "integrity": "sha512-0xiIyBsLlr8quN+WyuxooNW9RJ0Dpr8uOnH/xrCVO8GLUcwHISwj1AG0k+LFzteTkAA0GbX0kj9q6Dk70PTiPA==", - "dev": true, - "dependencies": { - "@babel/core": "^7.21.3", - "@svgr/babel-preset": "8.1.0", - "@svgr/hast-util-to-babel-ast": "8.0.0", - "svg-parser": "^2.0.4" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@svgr/core": "*" - } - }, - "node_modules/@svgr/plugin-svgo": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@svgr/plugin-svgo/-/plugin-svgo-8.1.0.tgz", - "integrity": "sha512-Ywtl837OGO9pTLIN/onoWLmDQ4zFUycI1g76vuKGEz6evR/ZTJlJuz3G/fIkb6OVBJ2g0o6CGJzaEjfmEo3AHA==", - "dev": true, - "dependencies": { - "cosmiconfig": "^8.1.3", - "deepmerge": "^4.3.1", - "svgo": "^3.0.2" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - }, - "peerDependencies": { - "@svgr/core": "*" - } - }, - "node_modules/@svgr/webpack": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@svgr/webpack/-/webpack-8.1.0.tgz", - "integrity": "sha512-LnhVjMWyMQV9ZmeEy26maJk+8HTIbd59cH4F2MJ439k9DqejRisfFNGAPvRYlKETuh9LrImlS8aKsBgKjMA8WA==", - "dev": true, - "dependencies": { - "@babel/core": "^7.21.3", - "@babel/plugin-transform-react-constant-elements": "^7.21.3", - "@babel/preset-env": "^7.20.2", - "@babel/preset-react": "^7.18.6", - "@babel/preset-typescript": "^7.21.0", - "@svgr/core": "8.1.0", - "@svgr/plugin-jsx": "8.1.0", - "@svgr/plugin-svgo": "8.1.0" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@swc/counter": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", - "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", - "dev": true - }, - "node_modules/@swc/helpers": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.5.tgz", - "integrity": "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==", - "dev": true, - "dependencies": { - "@swc/counter": "^0.1.3", - "tslib": "^2.4.0" - } - }, - "node_modules/@tailwindcss/typography": { - "version": "0.5.15", - "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.15.tgz", - "integrity": "sha512-AqhlCXl+8grUz8uqExv5OTtgpjuVIwFTSXTrh8y9/pw6q2ek7fJ+Y8ZEVw7EB2DCcuCOtEjf9w3+J3rzts01uA==", - "dev": true, - "dependencies": { - "lodash.castarray": "^4.4.0", - "lodash.isplainobject": "^4.0.6", - "lodash.merge": "^4.6.2", - "postcss-selector-parser": "6.0.10" - }, - "peerDependencies": { - "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20" - } - }, - "node_modules/@tanstack/react-virtual": { - "version": "3.10.8", - "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.10.8.tgz", - "integrity": "sha512-VbzbVGSsZlQktyLrP5nxE+vE1ZR+U0NFAWPbJLoG2+DKPwd2D7dVICTVIIaYlJqX1ZCEnYDbaOpmMwbsyhBoIA==", - "dev": true, - "dependencies": { - "@tanstack/virtual-core": "3.10.8" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/@tanstack/virtual-core": { - "version": "3.10.8", - "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.10.8.tgz", - "integrity": "sha512-PBu00mtt95jbKFi6Llk9aik8bnR3tR/oQP1o3TSi+iG//+Q2RTIzCEgKkHG8BB86kxMNW6O8wku+Lmi+QFR6jA==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - } - }, - "node_modules/@theguild/remark-mermaid": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@theguild/remark-mermaid/-/remark-mermaid-0.1.3.tgz", - "integrity": "sha512-2FjVlaaKXK7Zj7UJAgOVTyaahn/3/EAfqYhyXg0BfDBVUl+lXcoIWRaxzqfnDr2rv8ax6GsC5mNh6hAaT86PDw==", - "dev": true, - "dependencies": { - "mermaid": "^11.0.0", - "unist-util-visit": "^5.0.0" - }, - "peerDependencies": { - "react": "^18.2.0" - } - }, - "node_modules/@theguild/remark-npm2yarn": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@theguild/remark-npm2yarn/-/remark-npm2yarn-0.3.2.tgz", - "integrity": "sha512-H9T/GOuS/+4H7AY1cfD5DJIIIcGIIw1zMCB8OeTgXk7azJULsnuOurZ/CR54rvuTD+Krx0MVQccaUCvCWfP+vw==", - "dev": true, - "dependencies": { - "npm-to-yarn": "^3.0.0", - "unist-util-visit": "^5.0.0" - } - }, - "node_modules/@trysound/sax": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", - "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", - "dev": true, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/@types/acorn": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.6.tgz", - "integrity": "sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==", - "dev": true, - "dependencies": { - "@types/estree": "*" - } - }, - "node_modules/@types/debug": { - "version": "4.1.12", - "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", - "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", - "dev": true, - "dependencies": { - "@types/ms": "*" - } - }, - "node_modules/@types/estree": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", - "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", - "dev": true - }, - "node_modules/@types/estree-jsx": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree-jsx/-/estree-jsx-1.0.5.tgz", - "integrity": "sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==", - "dev": true, - "dependencies": { - "@types/estree": "*" - } - }, - "node_modules/@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", - "dev": true, - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/@types/katex": { - "version": "0.16.7", - "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz", - "integrity": "sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==", - "dev": true - }, - "node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "dev": true, - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/@types/mdx": { - "version": "2.0.13", - "resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.13.tgz", - "integrity": "sha512-+OWZQfAYyio6YkJb3HLxDrvnx6SWWDbC0zVPfBRzUk0/nqoDyf6dNxQi3eArPe8rJ473nobTMQ/8Zk+LxJ+Yuw==", - "dev": true - }, - "node_modules/@types/ms": { - "version": "0.7.34", - "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", - "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==", - "dev": true - }, - "node_modules/@types/nlcst": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@types/nlcst/-/nlcst-2.0.3.tgz", - "integrity": "sha512-vSYNSDe6Ix3q+6Z7ri9lyWqgGhJTmzRjZRqyq15N0Z/1/UnVsno9G/N40NBijoYx2seFDIl0+B2mgAb9mezUCA==", - "dev": true, - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/@types/node": { - "version": "22.7.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz", - "integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==", - "dev": true, - "dependencies": { - "undici-types": "~6.19.2" - } - }, - "node_modules/@types/prop-types": { - "version": "15.7.13", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.13.tgz", - "integrity": "sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==", - "dev": true, - "peer": true - }, - "node_modules/@types/react": { - "version": "18.3.11", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.11.tgz", - "integrity": "sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ==", - "dev": true, - "peer": true, - "dependencies": { - "@types/prop-types": "*", - "csstype": "^3.0.2" - } - }, - "node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", - "dev": true - }, - "node_modules/@typescript/vfs": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.6.0.tgz", - "integrity": "sha512-hvJUjNVeBMp77qPINuUvYXj4FyWeeMMKZkxEATEU3hqBAQ7qdTBCUFT7Sp0Zu0faeEtFf+ldXxMEDr/bk73ISg==", - "dev": true, - "dependencies": { - "debug": "^4.1.1" - }, - "peerDependencies": { - "typescript": "*" - } - }, - "node_modules/@ungap/structured-clone": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", - "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", - "dev": true - }, - "node_modules/acorn": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.13.0.tgz", - "integrity": "sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", - "dev": true - }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/arch": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/arch/-/arch-2.2.0.tgz", - "integrity": "sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/arg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/arg/-/arg-1.0.0.tgz", - "integrity": "sha512-Wk7TEzl1KqvTGs/uyhmHO/3XLd3t1UeU4IstvPXVzGPM522cTjqjNZ99esCkcL52sjqjo8e8CTBcWhkxvGzoAw==", - "dev": true - }, - "node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/array-iterate": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/array-iterate/-/array-iterate-2.0.1.tgz", - "integrity": "sha512-I1jXZMjAgCMmxT4qxXfPXa6SthSoE8h6gkSI9BGGNv8mP8G/v0blc+qFnZu6K42vTOiuME596QaLO0TP3Lk0xg==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/astring": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/astring/-/astring-1.9.0.tgz", - "integrity": "sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==", - "dev": true, - "bin": { - "astring": "bin/astring" - } - }, - "node_modules/autoprefixer": { - "version": "10.4.20", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.20.tgz", - "integrity": "sha512-XY25y5xSv/wEoqzDyXXME4AFfkZI0P23z6Fs3YgymDnKJkCGOnkL0iTxCa85UTqaSgfcqyf3UA6+c7wUvx/16g==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/autoprefixer" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "browserslist": "^4.23.3", - "caniuse-lite": "^1.0.30001646", - "fraction.js": "^4.3.7", - "normalize-range": "^0.1.2", - "picocolors": "^1.0.1", - "postcss-value-parser": "^4.2.0" - }, - "bin": { - "autoprefixer": "bin/autoprefixer" - }, - "engines": { - "node": "^10 || ^12 || >=14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/babel-plugin-polyfill-corejs2": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.11.tgz", - "integrity": "sha512-sMEJ27L0gRHShOh5G54uAAPaiCOygY/5ratXuiyb2G46FmlSpc9eFCzYVyDiPxfNbwzA7mYahmjQc5q+CZQ09Q==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.22.6", - "@babel/helper-define-polyfill-provider": "^0.6.2", - "semver": "^6.3.1" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.10.6", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.10.6.tgz", - "integrity": "sha512-b37+KR2i/khY5sKmWNVQAnitvquQbNdWy6lJdsr0kmquCKEEUgMKK4SboVM3HtfnZilfjr4MMQ7vY58FVWDtIA==", - "dev": true, - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.6.2", - "core-js-compat": "^3.38.0" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/babel-plugin-polyfill-regenerator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.2.tgz", - "integrity": "sha512-2R25rQZWP63nGwaAswvDazbPXfrM3HwVoBXK6HcqeKrSrL/JqcC/rDcf95l4r7LXLyxDXc8uQDa064GubtCABg==", - "dev": true, - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.6.2" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/bail": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", - "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "node_modules/better-react-mathjax": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/better-react-mathjax/-/better-react-mathjax-2.0.3.tgz", - "integrity": "sha512-wfifT8GFOKb1TWm2+E50I6DJpLZ5kLbch283Lu043EJtwSv0XvZDjr4YfR4d2MjAhqP6SH4VjjrKgbX8R00oCQ==", - "dev": true, - "dependencies": { - "mathjax-full": "^3.2.2" - }, - "peerDependencies": { - "react": ">=16.8" - } - }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/boolbase": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", - "dev": true - }, - "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/browserslist": { - "version": "4.24.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz", - "integrity": "sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "caniuse-lite": "^1.0.30001663", - "electron-to-chromium": "^1.5.28", - "node-releases": "^2.0.18", - "update-browserslist-db": "^1.1.0" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/busboy": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", - "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", - "dev": true, - "dependencies": { - "streamsearch": "^1.1.0" - }, - "engines": { - "node": ">=10.16.0" - } - }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/camelcase-css": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", - "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001669", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz", - "integrity": "sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ] - }, - "node_modules/ccount": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", - "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/chalk": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", - "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.1.0", - "escape-string-regexp": "^1.0.5", - "supports-color": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/chalk/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/character-entities": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", - "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/character-entities-html4": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", - "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/character-entities-legacy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", - "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/character-reference-invalid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz", - "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/chevrotain": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-11.0.3.tgz", - "integrity": "sha512-ci2iJH6LeIkvP9eJW6gpueU8cnZhv85ELY8w8WiFtNjMHA5ad6pQLaJo9mEly/9qUyCpvqX8/POVUTf18/HFdw==", - "dev": true, - "dependencies": { - "@chevrotain/cst-dts-gen": "11.0.3", - "@chevrotain/gast": "11.0.3", - "@chevrotain/regexp-to-ast": "11.0.3", - "@chevrotain/types": "11.0.3", - "@chevrotain/utils": "11.0.3", - "lodash-es": "4.17.21" - } - }, - "node_modules/chevrotain-allstar": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/chevrotain-allstar/-/chevrotain-allstar-0.3.1.tgz", - "integrity": "sha512-b7g+y9A0v4mxCW1qUhf3BSVPg+/NvGErk/dOkrDaHA0nQIQGAtrOjlX//9OQtRlSCy+x9rfB5N8yC71lH1nvMw==", - "dev": true, - "dependencies": { - "lodash-es": "^4.17.21" - }, - "peerDependencies": { - "chevrotain": "^11.0.0" - } - }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/chokidar/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/client-only": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", - "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==", - "dev": true - }, - "node_modules/clipboardy": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-1.2.2.tgz", - "integrity": "sha512-16KrBOV7bHmHdxcQiCvfUFYVFyEah4FI8vYT1Fr7CGSA4G+xBWMEfUEQJS1hxeHGtI9ju1Bzs9uXSbj5HZKArw==", - "dev": true, - "dependencies": { - "arch": "^2.1.0", - "execa": "^0.8.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/collapse-white-space": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-2.1.0.tgz", - "integrity": "sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, - "node_modules/comma-separated-tokens": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", - "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", - "dev": true, - "engines": { - "node": ">= 12" - } - }, - "node_modules/compute-scroll-into-view": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-3.1.0.tgz", - "integrity": "sha512-rj8l8pD4bJ1nx+dAkMhV1xB5RuZEyVysfxJqB1pRchh1KVvwOv9b7CGB8ZfjTImVv2oF+sYMUkMZq6Na5Ftmbg==", - "dev": true - }, - "node_modules/confbox": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", - "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==", - "dev": true - }, - "node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true - }, - "node_modules/core-js-compat": { - "version": "3.38.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz", - "integrity": "sha512-JRH6gfXxGmrzF3tZ57lFx97YARxCXPaMzPo6jELZhv88pBH5VXpQ+y0znKGlFnzuaihqhLbefxSJxWJMPtfDzw==", - "dev": true, - "dependencies": { - "browserslist": "^4.23.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/cose-base": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz", - "integrity": "sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg==", - "dev": true, - "dependencies": { - "layout-base": "^1.0.0" - } - }, - "node_modules/cosmiconfig": { - "version": "8.3.6", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz", - "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", - "dev": true, - "dependencies": { - "import-fresh": "^3.3.0", - "js-yaml": "^4.1.0", - "parse-json": "^5.2.0", - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/d-fischer" - }, - "peerDependencies": { - "typescript": ">=4.9.5" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/cosmiconfig/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "node_modules/cosmiconfig/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==", - "dev": true, - "dependencies": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "node_modules/css-select": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", - "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", - "dev": true, - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.1.0", - "domhandler": "^5.0.2", - "domutils": "^3.0.1", - "nth-check": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/css-tree": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", - "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", - "dev": true, - "dependencies": { - "mdn-data": "2.0.30", - "source-map-js": "^1.0.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" - } - }, - "node_modules/css-what": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", - "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", - "dev": true, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/cssesc": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", - "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", - "dev": true, - "bin": { - "cssesc": "bin/cssesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/csso": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz", - "integrity": "sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==", - "dev": true, - "dependencies": { - "css-tree": "~2.2.0" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/csso/node_modules/css-tree": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.2.1.tgz", - "integrity": "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==", - "dev": true, - "dependencies": { - "mdn-data": "2.0.28", - "source-map-js": "^1.0.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/csso/node_modules/mdn-data": { - "version": "2.0.28", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", - "integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==", - "dev": true - }, - "node_modules/csstype": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", - "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", - "dev": true, - "peer": true - }, - "node_modules/cytoscape": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/cytoscape/-/cytoscape-3.30.2.tgz", - "integrity": "sha512-oICxQsjW8uSaRmn4UK/jkczKOqTrVqt5/1WL0POiJUT2EKNc9STM4hYFHv917yu55aTBMFNRzymlJhVAiWPCxw==", - "dev": true, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/cytoscape-cose-bilkent": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cytoscape-cose-bilkent/-/cytoscape-cose-bilkent-4.1.0.tgz", - "integrity": "sha512-wgQlVIUJF13Quxiv5e1gstZ08rnZj2XaLHGoFMYXz7SkNfCDOOteKBE6SYRfA9WxxI/iBc3ajfDoc6hb/MRAHQ==", - "dev": true, - "dependencies": { - "cose-base": "^1.0.0" - }, - "peerDependencies": { - "cytoscape": "^3.2.0" - } - }, - "node_modules/cytoscape-fcose": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cytoscape-fcose/-/cytoscape-fcose-2.2.0.tgz", - "integrity": "sha512-ki1/VuRIHFCzxWNrsshHYPs6L7TvLu3DL+TyIGEsRcvVERmxokbf5Gdk7mFxZnTdiGtnA4cfSmjZJMviqSuZrQ==", - "dev": true, - "dependencies": { - "cose-base": "^2.2.0" - }, - "peerDependencies": { - "cytoscape": "^3.2.0" - } - }, - "node_modules/cytoscape-fcose/node_modules/cose-base": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-2.2.0.tgz", - "integrity": "sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g==", - "dev": true, - "dependencies": { - "layout-base": "^2.0.0" - } - }, - "node_modules/cytoscape-fcose/node_modules/layout-base": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-2.0.1.tgz", - "integrity": "sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==", - "dev": true - }, - "node_modules/d3": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.0.tgz", - "integrity": "sha512-e1U46jVP+w7Iut8Jt8ri1YsPOvFpg46k+K8TpCb0P+zjCkjkPnV7WzfDJzMHy1LnA+wj5pLT1wjO901gLXeEhA==", - "dev": true, - "dependencies": { - "d3-array": "3", - "d3-axis": "3", - "d3-brush": "3", - "d3-chord": "3", - "d3-color": "3", - "d3-contour": "4", - "d3-delaunay": "6", - "d3-dispatch": "3", - "d3-drag": "3", - "d3-dsv": "3", - "d3-ease": "3", - "d3-fetch": "3", - "d3-force": "3", - "d3-format": "3", - "d3-geo": "3", - "d3-hierarchy": "3", - "d3-interpolate": "3", - "d3-path": "3", - "d3-polygon": "3", - "d3-quadtree": "3", - "d3-random": "3", - "d3-scale": "4", - "d3-scale-chromatic": "3", - "d3-selection": "3", - "d3-shape": "3", - "d3-time": "3", - "d3-time-format": "4", - "d3-timer": "3", - "d3-transition": "3", - "d3-zoom": "3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-array": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", - "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", - "dev": true, - "dependencies": { - "internmap": "1 - 2" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-axis": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.0.tgz", - "integrity": "sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-brush": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.0.tgz", - "integrity": "sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==", - "dev": true, - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-drag": "2 - 3", - "d3-interpolate": "1 - 3", - "d3-selection": "3", - "d3-transition": "3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-chord": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.1.tgz", - "integrity": "sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==", - "dev": true, - "dependencies": { - "d3-path": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-color": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", - "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-contour": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.2.tgz", - "integrity": "sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==", - "dev": true, - "dependencies": { - "d3-array": "^3.2.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-delaunay": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz", - "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==", - "dev": true, - "dependencies": { - "delaunator": "5" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-dispatch": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", - "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-drag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", - "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", - "dev": true, - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-selection": "3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-dsv": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz", - "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==", - "dev": true, - "dependencies": { - "commander": "7", - "iconv-lite": "0.6", - "rw": "1" - }, - "bin": { - "csv2json": "bin/dsv2json.js", - "csv2tsv": "bin/dsv2dsv.js", - "dsv2dsv": "bin/dsv2dsv.js", - "dsv2json": "bin/dsv2json.js", - "json2csv": "bin/json2dsv.js", - "json2dsv": "bin/json2dsv.js", - "json2tsv": "bin/json2dsv.js", - "tsv2csv": "bin/dsv2dsv.js", - "tsv2json": "bin/dsv2json.js" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-dsv/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/d3-ease": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", - "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-fetch": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.1.tgz", - "integrity": "sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==", - "dev": true, - "dependencies": { - "d3-dsv": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-force": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz", - "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==", - "dev": true, - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-quadtree": "1 - 3", - "d3-timer": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-format": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.0.tgz", - "integrity": "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-geo": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz", - "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==", - "dev": true, - "dependencies": { - "d3-array": "2.5.0 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-hierarchy": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", - "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-interpolate": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", - "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", - "dev": true, - "dependencies": { - "d3-color": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-path": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz", - "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-polygon": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.1.tgz", - "integrity": "sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-quadtree": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", - "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-random": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz", - "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-sankey": { - "version": "0.12.3", - "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz", - "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==", - "dev": true, - "dependencies": { - "d3-array": "1 - 2", - "d3-shape": "^1.2.0" - } - }, - "node_modules/d3-sankey/node_modules/d3-array": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz", - "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==", - "dev": true, - "dependencies": { - "internmap": "^1.0.0" - } - }, - "node_modules/d3-sankey/node_modules/d3-path": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz", - "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==", - "dev": true - }, - "node_modules/d3-sankey/node_modules/d3-shape": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz", - "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==", - "dev": true, - "dependencies": { - "d3-path": "1" - } - }, - "node_modules/d3-sankey/node_modules/internmap": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz", - "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==", - "dev": true - }, - "node_modules/d3-scale": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", - "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", - "dev": true, - "dependencies": { - "d3-array": "2.10.0 - 3", - "d3-format": "1 - 3", - "d3-interpolate": "1.2.0 - 3", - "d3-time": "2.1.1 - 3", - "d3-time-format": "2 - 4" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-scale-chromatic": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", - "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", - "dev": true, - "dependencies": { - "d3-color": "1 - 3", - "d3-interpolate": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-selection": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", - "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-shape": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", - "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==", - "dev": true, - "dependencies": { - "d3-path": "^3.1.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-time": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", - "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", - "dev": true, - "dependencies": { - "d3-array": "2 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-time-format": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", - "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", - "dev": true, - "dependencies": { - "d3-time": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-timer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", - "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-transition": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", - "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", - "dev": true, - "dependencies": { - "d3-color": "1 - 3", - "d3-dispatch": "1 - 3", - "d3-ease": "1 - 3", - "d3-interpolate": "1 - 3", - "d3-timer": "1 - 3" - }, - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "d3-selection": "2 - 3" - } - }, - "node_modules/d3-zoom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", - "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", - "dev": true, - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-drag": "2 - 3", - "d3-interpolate": "1 - 3", - "d3-selection": "2 - 3", - "d3-transition": "2 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/dagre-d3-es": { - "version": "7.0.10", - "resolved": "https://registry.npmjs.org/dagre-d3-es/-/dagre-d3-es-7.0.10.tgz", - "integrity": "sha512-qTCQmEhcynucuaZgY5/+ti3X/rnszKZhEQH/ZdWdtP1tA/y3VoHJzcVrO9pjjJCNpigfscAtoUB5ONcd2wNn0A==", - "dev": true, - "dependencies": { - "d3": "^7.8.2", - "lodash-es": "^4.17.21" - } - }, - "node_modules/dayjs": { - "version": "1.11.13", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", - "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==", - "dev": true - }, - "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decode-named-character-reference": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz", - "integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==", - "dev": true, - "dependencies": { - "character-entities": "^2.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/deepmerge": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", - "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/delaunator": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz", - "integrity": "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==", - "dev": true, - "dependencies": { - "robust-predicates": "^3.0.2" - } - }, - "node_modules/dequal": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", - "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/devlop": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", - "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", - "dev": true, - "dependencies": { - "dequal": "^2.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/didyoumean": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", - "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", - "dev": true - }, - "node_modules/dlv": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", - "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", - "dev": true - }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "dev": true, - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ] - }, - "node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "dev": true, - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/dompurify": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.6.tgz", - "integrity": "sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ==", - "dev": true - }, - "node_modules/domutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", - "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", - "dev": true, - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dev": true, - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true - }, - "node_modules/electron-to-chromium": { - "version": "1.5.39", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.39.tgz", - "integrity": "sha512-4xkpSR6CjuiaNyvwiWDI85N9AxsvbPawB8xc7yzLPonYTuP19BVgYweKyUMFtHEZgIcHWMt1ks5Cqx2m+6/Grg==", - "dev": true - }, - "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "dependencies": { - "is-arrayish": "^0.2.1" - } - }, - "node_modules/escalade": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", - "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/esm": { - "version": "3.2.25", - "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", - "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/estree-util-attach-comments": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/estree-util-attach-comments/-/estree-util-attach-comments-3.0.0.tgz", - "integrity": "sha512-cKUwm/HUcTDsYh/9FgnuFqpfquUbwIqwKM26BVCGDPVgvaCl/nDCCjUfiLlx6lsEZ3Z4RFxNbOQ60pkaEwFxGw==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/estree-util-build-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/estree-util-build-jsx/-/estree-util-build-jsx-3.0.1.tgz", - "integrity": "sha512-8U5eiL6BTrPxp/CHbs2yMgP8ftMhR5ww1eIKoWRMlqvltHF8fZn5LRDvTKuxD3DUn+shRbLGqXemcP51oFCsGQ==", - "dev": true, - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "devlop": "^1.0.0", - "estree-util-is-identifier-name": "^3.0.0", - "estree-walker": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/estree-util-is-identifier-name": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz", - "integrity": "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==", - "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/estree-util-to-js": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/estree-util-to-js/-/estree-util-to-js-2.0.0.tgz", - "integrity": "sha512-WDF+xj5rRWmD5tj6bIqRi6CkLIXbbNQUcxQHzGysQzvHmdYG2G7p/Tf0J0gpxGgkeMZNTIjT/AoSvC9Xehcgdg==", - "dev": true, - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "astring": "^1.8.0", - "source-map": "^0.7.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/estree-util-value-to-estree": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/estree-util-value-to-estree/-/estree-util-value-to-estree-3.1.2.tgz", - "integrity": "sha512-S0gW2+XZkmsx00tU2uJ4L9hUT7IFabbml9pHh2WQqFmAbxit++YGZne0sKJbNwkj9Wvg9E4uqWl4nCIFQMmfag==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/remcohaszing" - } - }, - "node_modules/estree-util-visit": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/estree-util-visit/-/estree-util-visit-2.0.0.tgz", - "integrity": "sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==", - "dev": true, - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/estree-walker": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", - "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/execa": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz", - "integrity": "sha512-zDWS+Rb1E8BlqqhALSt9kUhss8Qq4nN3iof3gsOdyINksElaPyNBtKUMTR62qhvgVWR0CqCX7sdnKe4MnUbFEA==", - "dev": true, - "dependencies": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", - "dev": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/fast-glob": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fast-glob/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fastq": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", - "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", - "dev": true, - "dependencies": { - "reusify": "^1.0.4" - } - }, - "node_modules/fault": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fault/-/fault-2.0.1.tgz", - "integrity": "sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==", - "dev": true, - "dependencies": { - "format": "^0.2.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/flexsearch": { - "version": "0.7.43", - "resolved": "https://registry.npmjs.org/flexsearch/-/flexsearch-0.7.43.tgz", - "integrity": "sha512-c5o/+Um8aqCSOXGcZoqZOm+NqtVwNsvVpWv6lfmSclU954O3wvQKxxK8zj74fPaSJbXpSLTs4PRhh+wnoCXnKg==", - "dev": true - }, - "node_modules/foreground-child": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", - "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/foreground-child/node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/foreground-child/node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/foreground-child/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/format": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz", - "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==", - "dev": true, - "engines": { - "node": ">=0.4.x" - } - }, - "node_modules/fraction.js": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", - "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", - "dev": true, - "engines": { - "node": "*" - }, - "funding": { - "type": "patreon", - "url": "https://github.com/sponsors/rawify" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/github-slugger": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz", - "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==", - "dev": true - }, - "node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", - "dev": true, - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true - }, - "node_modules/gray-matter": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz", - "integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==", - "dev": true, - "dependencies": { - "js-yaml": "^3.13.1", - "kind-of": "^6.0.2", - "section-matter": "^1.0.0", - "strip-bom-string": "^1.0.0" - }, - "engines": { - "node": ">=6.0" - } - }, - "node_modules/hachure-fill": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/hachure-fill/-/hachure-fill-0.5.2.tgz", - "integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==", - "dev": true - }, - "node_modules/has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/hast-util-from-dom": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/hast-util-from-dom/-/hast-util-from-dom-5.0.0.tgz", - "integrity": "sha512-d6235voAp/XR3Hh5uy7aGLbM3S4KamdW0WEgOaU1YoewnuYw4HXb5eRtv9g65m/RFGEfUY1Mw4UqCc5Y8L4Stg==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "hastscript": "^8.0.0", - "web-namespaces": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-from-html": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-2.0.3.tgz", - "integrity": "sha512-CUSRHXyKjzHov8yKsQjGOElXy/3EKpyX56ELnkHH34vDVw1N1XSQ1ZcAvTyAPtGqLTuKP/uxM+aLkSPqF/EtMw==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "devlop": "^1.1.0", - "hast-util-from-parse5": "^8.0.0", - "parse5": "^7.0.0", - "vfile": "^6.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-from-html-isomorphic": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hast-util-from-html-isomorphic/-/hast-util-from-html-isomorphic-2.0.0.tgz", - "integrity": "sha512-zJfpXq44yff2hmE0XmwEOzdWin5xwH+QIhMLOScpX91e/NSGPsAzNCvLQDIEPyO2TXi+lBmU6hjLIhV8MwP2kw==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "hast-util-from-dom": "^5.0.0", - "hast-util-from-html": "^2.0.0", - "unist-util-remove-position": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-from-parse5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.1.tgz", - "integrity": "sha512-Er/Iixbc7IEa7r/XLtuG52zoqn/b3Xng/w6aZQ0xGVxzhw5xUFxcRqdPzP6yFi/4HBYRaifaI5fQ1RH8n0ZeOQ==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/unist": "^3.0.0", - "devlop": "^1.0.0", - "hastscript": "^8.0.0", - "property-information": "^6.0.0", - "vfile": "^6.0.0", - "vfile-location": "^5.0.0", - "web-namespaces": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-is-element": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-3.0.0.tgz", - "integrity": "sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-parse-selector": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz", - "integrity": "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-raw": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.0.4.tgz", - "integrity": "sha512-LHE65TD2YiNsHD3YuXcKPHXPLuYh/gjp12mOfU8jxSrm1f/yJpsb0F/KKljS6U9LJoP0Ux+tCe8iJ2AsPzTdgA==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/unist": "^3.0.0", - "@ungap/structured-clone": "^1.0.0", - "hast-util-from-parse5": "^8.0.0", - "hast-util-to-parse5": "^8.0.0", - "html-void-elements": "^3.0.0", - "mdast-util-to-hast": "^13.0.0", - "parse5": "^7.0.0", - "unist-util-position": "^5.0.0", - "unist-util-visit": "^5.0.0", - "vfile": "^6.0.0", - "web-namespaces": "^2.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-to-estree": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hast-util-to-estree/-/hast-util-to-estree-3.1.0.tgz", - "integrity": "sha512-lfX5g6hqVh9kjS/B9E2gSkvHH4SZNiQFiqWS0x9fENzEl+8W12RqdRxX6d/Cwxi30tPQs3bIO+aolQJNp1bIyw==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "comma-separated-tokens": "^2.0.0", - "devlop": "^1.0.0", - "estree-util-attach-comments": "^3.0.0", - "estree-util-is-identifier-name": "^3.0.0", - "hast-util-whitespace": "^3.0.0", - "mdast-util-mdx-expression": "^2.0.0", - "mdast-util-mdx-jsx": "^3.0.0", - "mdast-util-mdxjs-esm": "^2.0.0", - "property-information": "^6.0.0", - "space-separated-tokens": "^2.0.0", - "style-to-object": "^0.4.0", - "unist-util-position": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-to-html": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.3.tgz", - "integrity": "sha512-M17uBDzMJ9RPCqLMO92gNNUDuBSq10a25SDBI08iCCxmorf4Yy6sYHK57n9WAbRAAaU+DuR4W6GN9K4DFZesYg==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/unist": "^3.0.0", - "ccount": "^2.0.0", - "comma-separated-tokens": "^2.0.0", - "hast-util-whitespace": "^3.0.0", - "html-void-elements": "^3.0.0", - "mdast-util-to-hast": "^13.0.0", - "property-information": "^6.0.0", - "space-separated-tokens": "^2.0.0", - "stringify-entities": "^4.0.0", - "zwitch": "^2.0.4" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-to-jsx-runtime": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.2.tgz", - "integrity": "sha512-1ngXYb+V9UT5h+PxNRa1O1FYguZK/XL+gkeqvp7EdHlB9oHUG0eYRo/vY5inBdcqo3RkPMC58/H94HvkbfGdyg==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/unist": "^3.0.0", - "comma-separated-tokens": "^2.0.0", - "devlop": "^1.0.0", - "estree-util-is-identifier-name": "^3.0.0", - "hast-util-whitespace": "^3.0.0", - "mdast-util-mdx-expression": "^2.0.0", - "mdast-util-mdx-jsx": "^3.0.0", - "mdast-util-mdxjs-esm": "^2.0.0", - "property-information": "^6.0.0", - "space-separated-tokens": "^2.0.0", - "style-to-object": "^1.0.0", - "unist-util-position": "^5.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-to-jsx-runtime/node_modules/inline-style-parser": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.4.tgz", - "integrity": "sha512-0aO8FkhNZlj/ZIbNi7Lxxr12obT7cL1moPfE4tg1LkX7LlLfC6DeX4l2ZEud1ukP9jNQyNnfzQVqwbwmAATY4Q==", - "dev": true - }, - "node_modules/hast-util-to-jsx-runtime/node_modules/style-to-object": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-1.0.8.tgz", - "integrity": "sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==", - "dev": true, - "dependencies": { - "inline-style-parser": "0.2.4" - } - }, - "node_modules/hast-util-to-parse5": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-8.0.0.tgz", - "integrity": "sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "comma-separated-tokens": "^2.0.0", - "devlop": "^1.0.0", - "property-information": "^6.0.0", - "space-separated-tokens": "^2.0.0", - "web-namespaces": "^2.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-to-string": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/hast-util-to-string/-/hast-util-to-string-3.0.1.tgz", - "integrity": "sha512-XelQVTDWvqcl3axRfI0xSeoVKzyIFPwsAGSLIsKdJKQMXDYJS4WYrBNF/8J7RdhIcFI2BOHgAifggsvsxp/3+A==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-to-text": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.2.tgz", - "integrity": "sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/unist": "^3.0.0", - "hast-util-is-element": "^3.0.0", - "unist-util-find-after": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-whitespace": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", - "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hastscript": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-8.0.0.tgz", - "integrity": "sha512-dMOtzCEd3ABUeSIISmrETiKuyydk1w0pa+gE/uormcTpSYuaNJPbX1NU3JLyscSLjwAQM8bWMhhIlnCqnRvDTw==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "comma-separated-tokens": "^2.0.0", - "hast-util-parse-selector": "^4.0.0", - "property-information": "^6.0.0", - "space-separated-tokens": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/html-void-elements": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", - "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/inline-style-parser": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.1.1.tgz", - "integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==", - "dev": true - }, - "node_modules/internmap": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", - "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/is-alphabetical": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", - "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/is-alphanumerical": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", - "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", - "dev": true, - "dependencies": { - "is-alphabetical": "^2.0.0", - "is-decimal": "^2.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "dev": true - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-core-module": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", - "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", - "dev": true, - "dependencies": { - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-decimal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", - "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-hexadecimal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz", - "integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-plain-obj": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", - "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-reference": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz", - "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==", - "dev": true, - "dependencies": { - "@types/estree": "*" - } - }, - "node_modules/is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "dev": true, - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, - "node_modules/jiti": { - "version": "1.21.6", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.6.tgz", - "integrity": "sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==", - "dev": true, - "bin": { - "jiti": "bin/jiti.js" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/jsesc": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", - "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", - "dev": true, - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/katex": { - "version": "0.16.11", - "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.11.tgz", - "integrity": "sha512-RQrI8rlHY92OLf3rho/Ts8i/XvjgguEjOkO1BEXcU3N8BqPpSzBNwV/G0Ukr+P/l3ivvJUE/Fa/CwbS6HesGNQ==", - "dev": true, - "funding": [ - "https://opencollective.com/katex", - "https://github.com/sponsors/katex" - ], - "dependencies": { - "commander": "^8.3.0" - }, - "bin": { - "katex": "cli.js" - } - }, - "node_modules/khroma": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/khroma/-/khroma-2.1.0.tgz", - "integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw==", - "dev": true - }, - "node_modules/kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/kolorist": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", - "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", - "dev": true - }, - "node_modules/langium": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/langium/-/langium-3.0.0.tgz", - "integrity": "sha512-+Ez9EoiByeoTu/2BXmEaZ06iPNXM6thWJp02KfBO/raSMyCJ4jw7AkWWa+zBCTm0+Tw1Fj9FOxdqSskyN5nAwg==", - "dev": true, - "dependencies": { - "chevrotain": "~11.0.3", - "chevrotain-allstar": "~0.3.0", - "vscode-languageserver": "~9.0.1", - "vscode-languageserver-textdocument": "~1.0.11", - "vscode-uri": "~3.0.8" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/layout-base": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-1.0.2.tgz", - "integrity": "sha512-8h2oVEZNktL4BH2JCOI90iD1yXwL6iNW7KcCKT2QZgQJR2vbqDsldCTPRU9NifTCqHZci57XvQQ15YTu+sTYPg==", - "dev": true - }, - "node_modules/lilconfig": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", - "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true - }, - "node_modules/local-pkg": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz", - "integrity": "sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==", - "dev": true, - "dependencies": { - "mlly": "^1.4.2", - "pkg-types": "^1.0.3" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, - "node_modules/lodash-es": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", - "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", - "dev": true - }, - "node_modules/lodash.castarray": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", - "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==", - "dev": true - }, - "node_modules/lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", - "dev": true - }, - "node_modules/lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", - "dev": true - }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true - }, - "node_modules/longest-streak": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz", - "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } - }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dev": true, - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", - "dev": true, - "dependencies": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "node_modules/markdown-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-2.0.0.tgz", - "integrity": "sha512-o5vL7aDWatOTX8LzaS1WMoaoxIiLRQJuIKKe2wAw6IeULDHaqbiqiggmx+pKvZDb1Sj+pE46Sn1T7lCqfFtg1Q==", - "dev": true, - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/markdown-table": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.3.tgz", - "integrity": "sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/marked": { - "version": "13.0.3", - "resolved": "https://registry.npmjs.org/marked/-/marked-13.0.3.tgz", - "integrity": "sha512-rqRix3/TWzE9rIoFGIn8JmsVfhiuC8VIQ8IdX5TfzmeBucdY05/0UlzKaw0eVtpcN/OdVFpBk7CjKGo9iHJ/zA==", - "dev": true, - "bin": { - "marked": "bin/marked.js" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/mathjax-full": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/mathjax-full/-/mathjax-full-3.2.2.tgz", - "integrity": "sha512-+LfG9Fik+OuI8SLwsiR02IVdjcnRCy5MufYLi0C3TdMT56L/pjB0alMVGgoWJF8pN9Rc7FESycZB9BMNWIid5w==", - "dev": true, - "dependencies": { - "esm": "^3.2.25", - "mhchemparser": "^4.1.0", - "mj-context-menu": "^0.6.1", - "speech-rule-engine": "^4.0.6" - } - }, - "node_modules/mdast-util-find-and-replace": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.1.tgz", - "integrity": "sha512-SG21kZHGC3XRTSUhtofZkBzZTJNM5ecCi0SK2IMKmSXR8vO3peL+kb1O0z7Zl83jKtutG4k5Wv/W7V3/YHvzPA==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "escape-string-regexp": "^5.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-from-markdown": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.1.tgz", - "integrity": "sha512-aJEUyzZ6TzlsX2s5B4Of7lN7EQtAxvtradMMglCQDyaTFgse6CmtmdJ15ElnVRlCg1vpNyVtbem0PWzlNieZsA==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark": "^4.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-decode-string": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-frontmatter": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-frontmatter/-/mdast-util-frontmatter-2.0.1.tgz", - "integrity": "sha512-LRqI9+wdgC25P0URIJY9vwocIzCcksduHQ9OF2joxQoyTNVduwLAFUzjoopuRJbJAReaKrNQKAZKL3uCMugWJA==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "escape-string-regexp": "^5.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0", - "micromark-extension-frontmatter": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.0.0.tgz", - "integrity": "sha512-dgQEX5Amaq+DuUqf26jJqSK9qgixgd6rYDHAv4aTBuA92cTknZlKpPfa86Z/s8Dj8xsAQpFfBmPUHWJBWqS4Bw==", - "dev": true, - "dependencies": { - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-gfm-autolink-literal": "^2.0.0", - "mdast-util-gfm-footnote": "^2.0.0", - "mdast-util-gfm-strikethrough": "^2.0.0", - "mdast-util-gfm-table": "^2.0.0", - "mdast-util-gfm-task-list-item": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-autolink-literal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz", - "integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "ccount": "^2.0.0", - "devlop": "^1.0.0", - "mdast-util-find-and-replace": "^3.0.0", - "micromark-util-character": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-footnote": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.0.0.tgz", - "integrity": "sha512-5jOT2boTSVkMnQ7LTrd6n/18kqwjmuYqo7JUPe+tRCY6O7dAuTFMtTPauYYrMPpox9hlN0uOx/FL8XvEfG9/mQ==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "devlop": "^1.1.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-strikethrough": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz", - "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-table": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz", - "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "markdown-table": "^3.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-gfm-task-list-item": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz", - "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-math": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-3.0.0.tgz", - "integrity": "sha512-Tl9GBNeG/AhJnQM221bJR2HPvLOSnLE/T9cJI9tlc6zwQk2nPk/4f0cHkOdEixQPC/j8UtKDdITswvLAy1OZ1w==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "longest-streak": "^3.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.1.0", - "unist-util-remove-position": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-mdx/-/mdast-util-mdx-3.0.0.tgz", - "integrity": "sha512-JfbYLAW7XnYTTbUsmpu0kdBUVe+yKVJZBItEjwyYJiDJuZ9w4eeaqks4HQO+R7objWgS2ymV60GYpI14Ug554w==", - "dev": true, - "dependencies": { - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-mdx-expression": "^2.0.0", - "mdast-util-mdx-jsx": "^3.0.0", - "mdast-util-mdxjs-esm": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-expression": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz", - "integrity": "sha512-J6f+9hUp+ldTZqKRSg7Vw5V6MqjATc+3E4gf3CFNcuZNWD8XdyI6zQ8GqH7f8169MM6P7hMBRDVGnn7oHB9kXQ==", - "dev": true, - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdx-jsx": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.1.3.tgz", - "integrity": "sha512-bfOjvNt+1AcbPLTFMFWY149nJz0OjmewJs3LQQ5pIyVGxP4CdOqNVJL6kTaM5c68p8q82Xv3nCyFfUnuEcH3UQ==", - "dev": true, - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "ccount": "^2.0.0", - "devlop": "^1.1.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0", - "parse-entities": "^4.0.0", - "stringify-entities": "^4.0.0", - "unist-util-stringify-position": "^4.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-mdxjs-esm": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-2.0.1.tgz", - "integrity": "sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==", - "dev": true, - "dependencies": { - "@types/estree-jsx": "^1.0.0", - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "devlop": "^1.0.0", - "mdast-util-from-markdown": "^2.0.0", - "mdast-util-to-markdown": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-phrasing": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", - "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-hast": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz", - "integrity": "sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "@ungap/structured-clone": "^1.0.0", - "devlop": "^1.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "trim-lines": "^3.0.0", - "unist-util-position": "^5.0.0", - "unist-util-visit": "^5.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-markdown": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", - "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "@types/unist": "^3.0.0", - "longest-streak": "^3.0.0", - "mdast-util-phrasing": "^4.0.0", - "mdast-util-to-string": "^4.0.0", - "micromark-util-decode-string": "^2.0.0", - "unist-util-visit": "^5.0.0", - "zwitch": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", - "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdn-data": { - "version": "2.0.30", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", - "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", - "dev": true - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/mermaid": { - "version": "11.3.0", - "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.3.0.tgz", - "integrity": "sha512-fFmf2gRXLtlGzug4wpIGN+rQdZ30M8IZEB1D3eZkXNqC7puhqeURBcD/9tbwXsqBO+A6Nzzo3MSSepmnw5xSeg==", - "dev": true, - "dependencies": { - "@braintree/sanitize-url": "^7.0.1", - "@iconify/utils": "^2.1.32", - "@mermaid-js/parser": "^0.3.0", - "cytoscape": "^3.29.2", - "cytoscape-cose-bilkent": "^4.1.0", - "cytoscape-fcose": "^2.2.0", - "d3": "^7.9.0", - "d3-sankey": "^0.12.3", - "dagre-d3-es": "7.0.10", - "dayjs": "^1.11.10", - "dompurify": "^3.0.11 <3.1.7", - "katex": "^0.16.9", - "khroma": "^2.1.0", - "lodash-es": "^4.17.21", - "marked": "^13.0.2", - "roughjs": "^4.6.6", - "stylis": "^4.3.1", - "ts-dedent": "^2.2.0", - "uuid": "^9.0.1" - } - }, - "node_modules/mhchemparser": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/mhchemparser/-/mhchemparser-4.2.1.tgz", - "integrity": "sha512-kYmyrCirqJf3zZ9t/0wGgRZ4/ZJw//VwaRVGA75C4nhE60vtnIzhl9J9ndkX/h6hxSN7pjg/cE0VxbnNM+bnDQ==", - "dev": true - }, - "node_modules/micromark": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.0.tgz", - "integrity": "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "@types/debug": "^4.0.0", - "debug": "^4.0.0", - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-core-commonmark": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.1.tgz", - "integrity": "sha512-CUQyKr1e///ZODyD1U3xit6zXwy1a8q2a1S1HKtIlmgvurrEpaw/Y9y6KSIbF8P59cn/NjzHyO+Q2fAyYLQrAA==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-destination": "^2.0.0", - "micromark-factory-label": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-factory-title": "^2.0.0", - "micromark-factory-whitespace": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-html-tag-name": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-subtokenize": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-frontmatter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-frontmatter/-/micromark-extension-frontmatter-2.0.0.tgz", - "integrity": "sha512-C4AkuM3dA58cgZha7zVnuVxBhDsbttIMiytjgsM2XbHAB2faRVaHRle40558FBN+DJcrLNCoqG5mlrpdU4cRtg==", - "dev": true, - "dependencies": { - "fault": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz", - "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==", - "dev": true, - "dependencies": { - "micromark-extension-gfm-autolink-literal": "^2.0.0", - "micromark-extension-gfm-footnote": "^2.0.0", - "micromark-extension-gfm-strikethrough": "^2.0.0", - "micromark-extension-gfm-table": "^2.0.0", - "micromark-extension-gfm-tagfilter": "^2.0.0", - "micromark-extension-gfm-task-list-item": "^2.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-autolink-literal": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz", - "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==", - "dev": true, - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-footnote": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz", - "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==", - "dev": true, - "dependencies": { - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-normalize-identifier": "^2.0.0", - "micromark-util-sanitize-uri": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-strikethrough": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz", - "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==", - "dev": true, - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-classify-character": "^2.0.0", - "micromark-util-resolve-all": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-table": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.0.tgz", - "integrity": "sha512-Ub2ncQv+fwD70/l4ou27b4YzfNaCJOvyX4HxXU15m7mpYY+rjuWzsLIPZHJL253Z643RpbcP1oeIJlQ/SKW67g==", - "dev": true, - "dependencies": { - "devlop": "^1.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-tagfilter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz", - "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==", - "dev": true, - "dependencies": { - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-gfm-task-list-item": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz", - "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==", - "dev": true, - "dependencies": { - "devlop": "^1.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-math": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-3.1.0.tgz", - "integrity": "sha512-lvEqd+fHjATVs+2v/8kg9i5Q0AP2k85H0WUOwpIVvUML8BapsMvh1XAogmQjOCsLpoKRCVQqEkQBB3NhVBcsOg==", - "dev": true, - "dependencies": { - "@types/katex": "^0.16.0", - "devlop": "^1.0.0", - "katex": "^0.16.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdx-expression": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdx-expression/-/micromark-extension-mdx-expression-3.0.0.tgz", - "integrity": "sha512-sI0nwhUDz97xyzqJAbHQhp5TfaxEvZZZ2JDqUo+7NvyIYG6BZ5CPPqj2ogUoPJlmXHBnyZUzISg9+oUmU6tUjQ==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-mdx-expression": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-extension-mdx-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/micromark-extension-mdx-jsx/-/micromark-extension-mdx-jsx-3.0.1.tgz", - "integrity": "sha512-vNuFb9czP8QCtAQcEJn0UJQJZA8Dk6DXKBqx+bg/w0WGuSxDxNr7hErW89tHUY31dUW4NqEOWwmEUNhjTFmHkg==", - "dev": true, - "dependencies": { - "@types/acorn": "^4.0.0", - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "estree-util-is-identifier-name": "^3.0.0", - "micromark-factory-mdx-expression": "^2.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdx-md": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdx-md/-/micromark-extension-mdx-md-2.0.0.tgz", - "integrity": "sha512-EpAiszsB3blw4Rpba7xTOUptcFeBFi+6PY8VnJ2hhimH+vCQDirWgsMpz7w1XcZE7LVrSAUGb9VJpG9ghlYvYQ==", - "dev": true, - "dependencies": { - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdxjs": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdxjs/-/micromark-extension-mdxjs-3.0.0.tgz", - "integrity": "sha512-A873fJfhnJ2siZyUrJ31l34Uqwy4xIFmvPY1oj+Ean5PHcPBYzEsvqvWGaWcfEIr11O5Dlw3p2y0tZWpKHDejQ==", - "dev": true, - "dependencies": { - "acorn": "^8.0.0", - "acorn-jsx": "^5.0.0", - "micromark-extension-mdx-expression": "^3.0.0", - "micromark-extension-mdx-jsx": "^3.0.0", - "micromark-extension-mdx-md": "^2.0.0", - "micromark-extension-mdxjs-esm": "^3.0.0", - "micromark-util-combine-extensions": "^2.0.0", - "micromark-util-types": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-extension-mdxjs-esm": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdxjs-esm/-/micromark-extension-mdxjs-esm-3.0.0.tgz", - "integrity": "sha512-DJFl4ZqkErRpq/dAPyeWp15tGrcrrJho1hKK5uBS70BCtfrIFg81sqcTVu3Ta+KD1Tk5vAtBNElWxtAa+m8K9A==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "micromark-core-commonmark": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-position-from-estree": "^2.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/micromark-factory-destination": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.0.tgz", - "integrity": "sha512-j9DGrQLm/Uhl2tCzcbLhy5kXsgkHUrjJHg4fFAeoMRwJmJerT9aw4FEhIbZStWN8A3qMwOp1uzHr4UL8AInxtA==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-factory-label": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.0.tgz", - "integrity": "sha512-RR3i96ohZGde//4WSe/dJsxOX6vxIg9TimLAS3i4EhBAFx8Sm5SmqVfR8E87DPSR31nEAjZfbt91OMZWcNgdZw==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-factory-mdx-expression": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-factory-mdx-expression/-/micromark-factory-mdx-expression-2.0.2.tgz", - "integrity": "sha512-5E5I2pFzJyg2CtemqAbcyCktpHXuJbABnsb32wX2U8IQKhhVFBqkcZR5LRm1WVoFqa4kTueZK4abep7wdo9nrw==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "@types/estree": "^1.0.0", - "devlop": "^1.0.0", - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-events-to-acorn": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unist-util-position-from-estree": "^2.0.0", - "vfile-message": "^4.0.0" - } - }, - "node_modules/micromark-factory-space": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.0.tgz", - "integrity": "sha512-TKr+LIDX2pkBJXFLzpyPyljzYK3MtmllMUMODTQJIUfDGncESaqB90db9IAUcz4AZAJFdd8U9zOp9ty1458rxg==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-factory-title": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.0.tgz", - "integrity": "sha512-jY8CSxmpWLOxS+t8W+FG3Xigc0RDQA9bKMY/EwILvsesiRniiVMejYTE4wumNc2f4UbAa4WsHqe3J1QS1sli+A==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-factory-whitespace": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.0.tgz", - "integrity": "sha512-28kbwaBjc5yAI1XadbdPYHX/eDnqaUFVikLwrO7FDnKG7lpgxnvk/XGRhX/PN0mOZ+dBSZ+LgunHS+6tYQAzhA==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-factory-space": "^2.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-util-character": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.0.tgz", - "integrity": "sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-util-chunked": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.0.tgz", - "integrity": "sha512-anK8SWmNphkXdaKgz5hJvGa7l00qmcaUQoMYsBwDlSKFKjc6gjGXPDw3FNL3Nbwq5L8gE+RCbGqTw49FK5Qyvg==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-util-classify-character": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.0.tgz", - "integrity": "sha512-S0ze2R9GH+fu41FA7pbSqNWObo/kzwf8rN/+IGlW/4tC6oACOs8B++bh+i9bVyNnwCcuksbFwsBme5OCKXCwIw==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-util-combine-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.0.tgz", - "integrity": "sha512-vZZio48k7ON0fVS3CUgFatWHoKbbLTK/rT7pzpJ4Bjp5JjkZeasRfrS9wsBdDJK2cJLHMckXZdzPSSr1B8a4oQ==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-chunked": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-util-decode-numeric-character-reference": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.1.tgz", - "integrity": "sha512-bmkNc7z8Wn6kgjZmVHOX3SowGmVdhYS7yBpMnuMnPzDq/6xwVA604DuOXMZTO1lvq01g+Adfa0pE2UKGlxL1XQ==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-util-decode-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.0.tgz", - "integrity": "sha512-r4Sc6leeUTn3P6gk20aFMj2ntPwn6qpDZqWvYmAG6NgvFTIlj4WtrAudLi65qYoaGdXYViXYw2pkmn7QnIFasA==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "decode-named-character-reference": "^1.0.0", - "micromark-util-character": "^2.0.0", - "micromark-util-decode-numeric-character-reference": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-util-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", - "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/micromark-util-events-to-acorn": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/micromark-util-events-to-acorn/-/micromark-util-events-to-acorn-2.0.2.tgz", - "integrity": "sha512-Fk+xmBrOv9QZnEDguL9OI9/NQQp6Hz4FuQ4YmCb/5V7+9eAh1s6AYSvL20kHkD67YIg7EpE54TiSlcsf3vyZgA==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "@types/acorn": "^4.0.0", - "@types/estree": "^1.0.0", - "@types/unist": "^3.0.0", - "devlop": "^1.0.0", - "estree-util-visit": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0", - "vfile-message": "^4.0.0" - } - }, - "node_modules/micromark-util-html-tag-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.0.tgz", - "integrity": "sha512-xNn4Pqkj2puRhKdKTm8t1YHC/BAjx6CEwRFXntTaRf/x16aqka6ouVoutm+QdkISTlT7e2zU7U4ZdlDLJd2Mcw==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/micromark-util-normalize-identifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.0.tgz", - "integrity": "sha512-2xhYT0sfo85FMrUPtHcPo2rrp1lwbDEEzpx7jiH2xXJLqBuy4H0GgXk5ToU8IEwoROtXuL8ND0ttVa4rNqYK3w==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-util-resolve-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.0.tgz", - "integrity": "sha512-6KU6qO7DZ7GJkaCgwBNtplXCvGkJToU86ybBAUdavvgsCiG8lSSvYxr9MhwmQ+udpzywHsl4RpGJsYWG1pDOcA==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-util-sanitize-uri": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", - "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" - } - }, - "node_modules/micromark-util-subtokenize": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.1.tgz", - "integrity": "sha512-jZNtiFl/1aY73yS3UGQkutD0UbhTt68qnRpw2Pifmz5wV9h8gOVsN70v+Lq/f1rKaU/W8pxRe8y8Q9FX1AOe1Q==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "dependencies": { - "devlop": "^1.0.0", - "micromark-util-chunked": "^2.0.0", - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" - } - }, - "node_modules/micromark-util-symbol": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", - "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/micromark-util-types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", - "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", - "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ] - }, - "node_modules/micromatch": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", - "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", - "dev": true, - "dependencies": { - "braces": "^3.0.3", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/mj-context-menu": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/mj-context-menu/-/mj-context-menu-0.6.1.tgz", - "integrity": "sha512-7NO5s6n10TIV96d4g2uDpG7ZDpIhMh0QNfGdJw/W47JswFcosz457wqz/b5sAKvl12sxINGFCn80NZHKwxQEXA==", - "dev": true - }, - "node_modules/mlly": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.2.tgz", - "integrity": "sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==", - "dev": true, - "dependencies": { - "acorn": "^8.12.1", - "pathe": "^1.1.2", - "pkg-types": "^1.2.0", - "ufo": "^1.5.4" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "node_modules/mz": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", - "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", - "dev": true, - "dependencies": { - "any-promise": "^1.0.0", - "object-assign": "^4.0.1", - "thenify-all": "^1.0.0" - } - }, - "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/next": { - "version": "14.2.15", - "resolved": "https://registry.npmjs.org/next/-/next-14.2.15.tgz", - "integrity": "sha512-h9ctmOokpoDphRvMGnwOJAedT6zKhwqyZML9mDtspgf4Rh3Pn7UTYKqePNoDvhsWBAO5GoPNYshnAUGIazVGmw==", - "dev": true, - "dependencies": { - "@next/env": "14.2.15", - "@swc/helpers": "0.5.5", - "busboy": "1.6.0", - "caniuse-lite": "^1.0.30001579", - "graceful-fs": "^4.2.11", - "postcss": "8.4.31", - "styled-jsx": "5.1.1" - }, - "bin": { - "next": "dist/bin/next" - }, - "engines": { - "node": ">=18.17.0" - }, - "optionalDependencies": { - "@next/swc-darwin-arm64": "14.2.15", - "@next/swc-darwin-x64": "14.2.15", - "@next/swc-linux-arm64-gnu": "14.2.15", - "@next/swc-linux-arm64-musl": "14.2.15", - "@next/swc-linux-x64-gnu": "14.2.15", - "@next/swc-linux-x64-musl": "14.2.15", - "@next/swc-win32-arm64-msvc": "14.2.15", - "@next/swc-win32-ia32-msvc": "14.2.15", - "@next/swc-win32-x64-msvc": "14.2.15" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.1.0", - "@playwright/test": "^1.41.2", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sass": "^1.3.0" - }, - "peerDependenciesMeta": { - "@opentelemetry/api": { - "optional": true - }, - "@playwright/test": { - "optional": true - }, - "sass": { - "optional": true - } - } - }, - "node_modules/next-themes": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.3.0.tgz", - "integrity": "sha512-/QHIrsYpd6Kfk7xakK4svpDI5mmXP0gfvCoJdGpZQ2TOrQZmsW0QxjaiLn8wbIKjtm4BTSqLoix4lxYYOnLJ/w==", - "dev": true, - "peerDependencies": { - "react": "^16.8 || ^17 || ^18", - "react-dom": "^16.8 || ^17 || ^18" - } - }, - "node_modules/next/node_modules/postcss": { - "version": "8.4.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", - "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "nanoid": "^3.3.6", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/nextra": { - "version": "3.0.13", - "resolved": "https://registry.npmjs.org/nextra/-/nextra-3.0.13.tgz", - "integrity": "sha512-aK5ZEnKGE2lWhJvFfpj7T35JeA4ytvo2zUiXJ5JApIpFrwkzy8IYTa+irGHB0l9sxGiRlss4p+nAM8Kunvmlug==", - "dev": true, - "dependencies": { - "@formatjs/intl-localematcher": "^0.5.4", - "@headlessui/react": "^2.1.2", - "@mdx-js/mdx": "^3.0.0", - "@mdx-js/react": "^3.0.0", - "@napi-rs/simple-git": "^0.1.9", - "@shikijs/twoslash": "^1.0.0", - "@theguild/remark-mermaid": "^0.1.2", - "@theguild/remark-npm2yarn": "^0.3.2", - "better-react-mathjax": "^2.0.3", - "clsx": "^2.0.0", - "estree-util-to-js": "^2.0.0", - "estree-util-value-to-estree": "^3.0.1", - "github-slugger": "^2.0.0", - "graceful-fs": "^4.2.11", - "gray-matter": "^4.0.3", - "hast-util-to-estree": "^3.1.0", - "katex": "^0.16.9", - "negotiator": "^0.6.3", - "p-limit": "^6.0.0", - "rehype-katex": "^7.0.0", - "rehype-pretty-code": "0.14.0", - "rehype-raw": "^7.0.0", - "remark-frontmatter": "^5.0.0", - "remark-gfm": "^4.0.0", - "remark-math": "^6.0.0", - "remark-reading-time": "^2.0.1", - "remark-smartypants": "^3.0.0", - "shiki": "^1.0.0", - "slash": "^5.1.0", - "title": "^3.5.3", - "unist-util-remove": "^4.0.0", - "unist-util-visit": "^5.0.0", - "yaml": "^2.3.2", - "zod": "^3.22.3", - "zod-validation-error": "^3.0.0" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "next": ">=13", - "react": ">=18", - "react-dom": ">=18" - } - }, - "node_modules/nextra-theme-docs": { - "version": "3.0.13", - "resolved": "https://registry.npmjs.org/nextra-theme-docs/-/nextra-theme-docs-3.0.13.tgz", - "integrity": "sha512-1NEo4NJxXRsNPE2PXlYdVlW7N8ZWe5XssePFKUq0comQaxDNc6SaxfBNw0VoQlwB3T5ifTp9f5wb9xfIjPa6OA==", - "dev": true, - "dependencies": { - "@headlessui/react": "^2.1.2", - "clsx": "^2.0.0", - "escape-string-regexp": "^5.0.0", - "flexsearch": "^0.7.43", - "next-themes": "^0.3.0", - "scroll-into-view-if-needed": "^3.1.0", - "zod": "^3.22.3" - }, - "peerDependencies": { - "next": ">=13", - "nextra": "3.0.13", - "react": ">=18", - "react-dom": ">=18" - } - }, - "node_modules/nlcst-to-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/nlcst-to-string/-/nlcst-to-string-4.0.0.tgz", - "integrity": "sha512-YKLBCcUYKAg0FNlOBT6aI91qFmSiFKiluk655WzPF+DDMA02qIyy8uiRqI8QXtcFpEvll12LpL5MXqEmAZ+dcA==", - "dev": true, - "dependencies": { - "@types/nlcst": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dev": true, - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, - "node_modules/node-releases": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", - "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", - "dev": true - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/normalize-range": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", - "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==", - "dev": true, - "dependencies": { - "path-key": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/npm-to-yarn": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/npm-to-yarn/-/npm-to-yarn-3.0.0.tgz", - "integrity": "sha512-76YnmsbfrYp0tMsWxM0RNX0Vs+x8JxpJGu6B/jDn4lW8+laiTcKmKi9MeMh4UikO4RkJ1oqURoDy9bXJmMXS6A==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/nebrelbug/npm-to-yarn?sponsor=1" - } - }, - "node_modules/nth-check": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", - "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", - "dev": true, - "dependencies": { - "boolbase": "^1.0.0" - }, - "funding": { - "url": "https://github.com/fb55/nth-check?sponsor=1" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-hash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", - "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/oniguruma-to-js": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/oniguruma-to-js/-/oniguruma-to-js-0.4.3.tgz", - "integrity": "sha512-X0jWUcAlxORhOqqBREgPMgnshB7ZGYszBNspP+tS9hPD3l13CdaXcHbgImoHUHlrvGx/7AvFEkTRhAGYh+jzjQ==", - "dev": true, - "dependencies": { - "regex": "^4.3.2" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, - "node_modules/p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/p-limit": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.1.0.tgz", - "integrity": "sha512-H0jc0q1vOzlEk0TqAKXKZxdl7kX3OFUzCnNVUnq5Pc3DGo0kpeaMuPqxQn235HibwBEb0/pm9dgKTjXy66fBkg==", - "dev": true, - "dependencies": { - "yocto-queue": "^1.1.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true - }, - "node_modules/package-manager-detector": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-0.2.2.tgz", - "integrity": "sha512-VgXbyrSNsml4eHWIvxxG/nTL4wgybMTXCV2Un/+yEc3aDKKU6nQBZjbeP3Pl3qm9Qg92X/1ng4ffvCeD/zwHgg==", - "dev": true - }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/parse-entities": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.1.tgz", - "integrity": "sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==", - "dev": true, - "dependencies": { - "@types/unist": "^2.0.0", - "character-entities": "^2.0.0", - "character-entities-legacy": "^3.0.0", - "character-reference-invalid": "^2.0.0", - "decode-named-character-reference": "^1.0.0", - "is-alphanumerical": "^2.0.0", - "is-decimal": "^2.0.0", - "is-hexadecimal": "^2.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/parse-entities/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", - "dev": true - }, - "node_modules/parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/parse-latin": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/parse-latin/-/parse-latin-7.0.0.tgz", - "integrity": "sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ==", - "dev": true, - "dependencies": { - "@types/nlcst": "^2.0.0", - "@types/unist": "^3.0.0", - "nlcst-to-string": "^4.0.0", - "unist-util-modify-children": "^4.0.0", - "unist-util-visit-children": "^3.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/parse-numeric-range": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/parse-numeric-range/-/parse-numeric-range-1.3.0.tgz", - "integrity": "sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ==", - "dev": true - }, - "node_modules/parse5": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.0.tgz", - "integrity": "sha512-ZkDsAOcxsUMZ4Lz5fVciOehNcJ+Gb8gTzcA4yl3wnc273BAybYWrQ+Ks/OjCjSEpjvQkDSeZbybK9qj2VHHdGA==", - "dev": true, - "dependencies": { - "entities": "^4.5.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/path-data-parser": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz", - "integrity": "sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==", - "dev": true - }, - "node_modules/path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, - "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", - "dev": true, - "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "engines": { - "node": ">=16 || 14 >=14.18" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true - }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/pathe": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", - "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", - "dev": true - }, - "node_modules/periscopic": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz", - "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "estree-walker": "^3.0.0", - "is-reference": "^3.0.0" - } - }, - "node_modules/picocolors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", - "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", - "dev": true - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pirates": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", - "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/pkg-types": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.2.1.tgz", - "integrity": "sha512-sQoqa8alT3nHjGuTjuKgOnvjo4cljkufdtLMnO2LBP/wRwuDlo1tkaEdMxCRhyGRPacv/ztlZgDPm2b7FAmEvw==", - "dev": true, - "dependencies": { - "confbox": "^0.1.8", - "mlly": "^1.7.2", - "pathe": "^1.1.2" - } - }, - "node_modules/points-on-curve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", - "integrity": "sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==", - "dev": true - }, - "node_modules/points-on-path": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/points-on-path/-/points-on-path-0.2.1.tgz", - "integrity": "sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==", - "dev": true, - "dependencies": { - "path-data-parser": "0.1.0", - "points-on-curve": "0.2.0" - } - }, - "node_modules/postcss": { - "version": "8.4.47", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", - "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "nanoid": "^3.3.7", - "picocolors": "^1.1.0", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/postcss-import": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", - "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", - "dev": true, - "dependencies": { - "postcss-value-parser": "^4.0.0", - "read-cache": "^1.0.0", - "resolve": "^1.1.7" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "postcss": "^8.0.0" - } - }, - "node_modules/postcss-js": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz", - "integrity": "sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==", - "dev": true, - "dependencies": { - "camelcase-css": "^2.0.1" - }, - "engines": { - "node": "^12 || ^14 || >= 16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - "peerDependencies": { - "postcss": "^8.4.21" - } - }, - "node_modules/postcss-load-config": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.2.tgz", - "integrity": "sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "lilconfig": "^3.0.0", - "yaml": "^2.3.4" - }, - "engines": { - "node": ">= 14" - }, - "peerDependencies": { - "postcss": ">=8.0.9", - "ts-node": ">=9.0.0" - }, - "peerDependenciesMeta": { - "postcss": { - "optional": true - }, - "ts-node": { - "optional": true - } - } - }, - "node_modules/postcss-load-config/node_modules/lilconfig": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.2.tgz", - "integrity": "sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/antonk52" - } - }, - "node_modules/postcss-selector-parser": { - "version": "6.0.10", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", - "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", - "dev": true, - "dependencies": { - "cssesc": "^3.0.0", - "util-deprecate": "^1.0.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/postcss-value-parser": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", - "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", - "dev": true - }, - "node_modules/property-information": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz", - "integrity": "sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==", - "dev": true - }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", - "dev": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react-dom": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", - "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", - "dev": true, - "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.2" - }, - "peerDependencies": { - "react": "^18.3.1" - } - }, - "node_modules/read-cache": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", - "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", - "dev": true, - "dependencies": { - "pify": "^2.3.0" - } - }, - "node_modules/read-cache/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/reading-time": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/reading-time/-/reading-time-1.5.0.tgz", - "integrity": "sha512-onYyVhBNr4CmAxFsKS7bz+uTLRakypIe4R+5A824vBSkQy/hB3fZepoVEf8OVAxzLvK+H/jm9TzpI3ETSm64Kg==", - "dev": true - }, - "node_modules/regenerate": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", - "dev": true - }, - "node_modules/regenerate-unicode-properties": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.2.0.tgz", - "integrity": "sha512-DqHn3DwbmmPVzeKj9woBadqmXxLvQoQIwu7nopMc72ztvxVmVk2SBhSnx67zuye5TP+lJsb/TBQsjLKhnDf3MA==", - "dev": true, - "dependencies": { - "regenerate": "^1.4.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regenerator-runtime": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", - "dev": true - }, - "node_modules/regenerator-transform": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.2.tgz", - "integrity": "sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg==", - "dev": true, - "dependencies": { - "@babel/runtime": "^7.8.4" - } - }, - "node_modules/regex": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/regex/-/regex-4.3.3.tgz", - "integrity": "sha512-r/AadFO7owAq1QJVeZ/nq9jNS1vyZt+6t1p/E59B56Rn2GCya+gr1KSyOzNL/er+r+B7phv5jG2xU2Nz1YkmJg==", - "dev": true - }, - "node_modules/regexpu-core": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-6.1.1.tgz", - "integrity": "sha512-k67Nb9jvwJcJmVpw0jPttR1/zVfnKf8Km0IPatrU/zJ5XeG3+Slx0xLXs9HByJSzXzrlz5EDvN6yLNMDc2qdnw==", - "dev": true, - "dependencies": { - "regenerate": "^1.4.2", - "regenerate-unicode-properties": "^10.2.0", - "regjsgen": "^0.8.0", - "regjsparser": "^0.11.0", - "unicode-match-property-ecmascript": "^2.0.0", - "unicode-match-property-value-ecmascript": "^2.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regjsgen": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.8.0.tgz", - "integrity": "sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==", - "dev": true - }, - "node_modules/regjsparser": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.11.1.tgz", - "integrity": "sha512-1DHODs4B8p/mQHU9kr+jv8+wIC9mtG4eBHxWxIq5mhjE3D5oORhCc6deRKzTjs9DcfRFmj9BHSDguZklqCGFWQ==", - "dev": true, - "dependencies": { - "jsesc": "~3.0.2" - }, - "bin": { - "regjsparser": "bin/parser" - } - }, - "node_modules/rehype-katex": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.1.tgz", - "integrity": "sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/katex": "^0.16.0", - "hast-util-from-html-isomorphic": "^2.0.0", - "hast-util-to-text": "^4.0.0", - "katex": "^0.16.0", - "unist-util-visit-parents": "^6.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/rehype-parse": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-9.0.1.tgz", - "integrity": "sha512-ksCzCD0Fgfh7trPDxr2rSylbwq9iYDkSn8TCDmEJ49ljEUBxDVCzCHv7QNzZOfODanX4+bWQ4WZqLCRWYLfhag==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "hast-util-from-html": "^2.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/rehype-pretty-code": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/rehype-pretty-code/-/rehype-pretty-code-0.14.0.tgz", - "integrity": "sha512-hBeKF/Wkkf3zyUS8lal9RCUuhypDWLQc+h9UrP9Pav25FUm/AQAVh4m5gdvJxh4Oz+U+xKvdsV01p1LdvsZTiQ==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.4", - "hast-util-to-string": "^3.0.0", - "parse-numeric-range": "^1.3.0", - "rehype-parse": "^9.0.0", - "unified": "^11.0.5", - "unist-util-visit": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "shiki": "^1.3.0" - } - }, - "node_modules/rehype-raw": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz", - "integrity": "sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "hast-util-raw": "^9.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-frontmatter": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/remark-frontmatter/-/remark-frontmatter-5.0.0.tgz", - "integrity": "sha512-XTFYvNASMe5iPN0719nPrdItC9aU0ssC4v14mH1BCi1u0n1gAocqcujWUrByftZTbLhRtiKRyjYTSIOcr69UVQ==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-frontmatter": "^2.0.0", - "micromark-extension-frontmatter": "^2.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-gfm": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.0.tgz", - "integrity": "sha512-U92vJgBPkbw4Zfu/IiW2oTZLSL3Zpv+uI7My2eq8JxKgqraFdU8YUGicEJCEgSbeaG+QDFqIcwwfMTOEelPxuA==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-gfm": "^3.0.0", - "micromark-extension-gfm": "^3.0.0", - "remark-parse": "^11.0.0", - "remark-stringify": "^11.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-math": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/remark-math/-/remark-math-6.0.0.tgz", - "integrity": "sha512-MMqgnP74Igy+S3WwnhQ7kqGlEerTETXMvJhrUzDikVZ2/uogJCb+WHUg97hK9/jcfc0dkD73s3LN8zU49cTEtA==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-math": "^3.0.0", - "micromark-extension-math": "^3.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-mdx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-3.0.1.tgz", - "integrity": "sha512-3Pz3yPQ5Rht2pM5R+0J2MrGoBSrzf+tJG94N+t/ilfdh8YLyyKYtidAYwTveB20BoHAcwIopOUqhcmh2F7hGYA==", - "dev": true, - "dependencies": { - "mdast-util-mdx": "^3.0.0", - "micromark-extension-mdxjs": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-parse": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz", - "integrity": "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-from-markdown": "^2.0.0", - "micromark-util-types": "^2.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-reading-time": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/remark-reading-time/-/remark-reading-time-2.0.1.tgz", - "integrity": "sha512-fy4BKy9SRhtYbEHvp6AItbRTnrhiDGbqLQTSYVbQPGuRCncU1ubSsh9p/W5QZSxtYcUXv8KGL0xBgPLyNJA1xw==", - "dev": true, - "dependencies": { - "estree-util-is-identifier-name": "^2.0.0", - "estree-util-value-to-estree": "^1.3.0", - "reading-time": "^1.3.0", - "unist-util-visit": "^3.1.0" - } - }, - "node_modules/remark-reading-time/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", - "dev": true - }, - "node_modules/remark-reading-time/node_modules/estree-util-is-identifier-name": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-2.1.0.tgz", - "integrity": "sha512-bEN9VHRyXAUOjkKVQVvArFym08BTWB0aJPppZZr0UNyAqWsLaVfAqP7hbaTJjzHifmB5ebnR8Wm7r7yGN/HonQ==", - "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-reading-time/node_modules/estree-util-value-to-estree": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/estree-util-value-to-estree/-/estree-util-value-to-estree-1.3.0.tgz", - "integrity": "sha512-Y+ughcF9jSUJvncXwqRageavjrNPAI+1M/L3BI3PyLp1nmgYTGUXU6t5z1Y7OWuThoDdhPME07bQU+d5LxdJqw==", - "dev": true, - "dependencies": { - "is-plain-obj": "^3.0.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/remark-reading-time/node_modules/is-plain-obj": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", - "integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/remark-reading-time/node_modules/unist-util-is": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.2.1.tgz", - "integrity": "sha512-u9njyyfEh43npf1M+yGKDGVPbY/JWEemg5nH05ncKPfi+kBbKBJoTdsogMu33uhytuLlv9y0O7GH7fEdwLdLQw==", - "dev": true, - "dependencies": { - "@types/unist": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-reading-time/node_modules/unist-util-visit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", - "integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==", - "dev": true, - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-reading-time/node_modules/unist-util-visit-parents": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", - "integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==", - "dev": true, - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-rehype": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-11.1.1.tgz", - "integrity": "sha512-g/osARvjkBXb6Wo0XvAeXQohVta8i84ACbenPpoSsxTOQH/Ae0/RGP4WZgnMH5pMLpsj4FG7OHmcIcXxpza8eQ==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "mdast-util-to-hast": "^13.0.0", - "unified": "^11.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-smartypants": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/remark-smartypants/-/remark-smartypants-3.0.2.tgz", - "integrity": "sha512-ILTWeOriIluwEvPjv67v7Blgrcx+LZOkAUVtKI3putuhlZm84FnqDORNXPPm+HY3NdZOMhyDwZ1E+eZB/Df5dA==", - "dev": true, - "dependencies": { - "retext": "^9.0.0", - "retext-smartypants": "^6.0.0", - "unified": "^11.0.4", - "unist-util-visit": "^5.0.0" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/remark-stringify": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz", - "integrity": "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==", - "dev": true, - "dependencies": { - "@types/mdast": "^4.0.0", - "mdast-util-to-markdown": "^2.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", - "dev": true, - "dependencies": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/retext": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/retext/-/retext-9.0.0.tgz", - "integrity": "sha512-sbMDcpHCNjvlheSgMfEcVrZko3cDzdbe1x/e7G66dFp0Ff7Mldvi2uv6JkJQzdRcvLYE8CA8Oe8siQx8ZOgTcA==", - "dev": true, - "dependencies": { - "@types/nlcst": "^2.0.0", - "retext-latin": "^4.0.0", - "retext-stringify": "^4.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/retext-latin": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/retext-latin/-/retext-latin-4.0.0.tgz", - "integrity": "sha512-hv9woG7Fy0M9IlRQloq/N6atV82NxLGveq+3H2WOi79dtIYWN8OaxogDm77f8YnVXJL2VD3bbqowu5E3EMhBYA==", - "dev": true, - "dependencies": { - "@types/nlcst": "^2.0.0", - "parse-latin": "^7.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/retext-smartypants": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/retext-smartypants/-/retext-smartypants-6.2.0.tgz", - "integrity": "sha512-kk0jOU7+zGv//kfjXEBjdIryL1Acl4i9XNkHxtM7Tm5lFiCog576fjNC9hjoR7LTKQ0DsPWy09JummSsH1uqfQ==", - "dev": true, - "dependencies": { - "@types/nlcst": "^2.0.0", - "nlcst-to-string": "^4.0.0", - "unist-util-visit": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/retext-stringify": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/retext-stringify/-/retext-stringify-4.0.0.tgz", - "integrity": "sha512-rtfN/0o8kL1e+78+uxPTqu1Klt0yPzKuQ2BfWwwfgIUSayyzxpM1PJzkKt4V8803uB9qSy32MvI7Xep9khTpiA==", - "dev": true, - "dependencies": { - "@types/nlcst": "^2.0.0", - "nlcst-to-string": "^4.0.0", - "unified": "^11.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true, - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/robust-predicates": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", - "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==", - "dev": true - }, - "node_modules/roughjs": { - "version": "4.6.6", - "resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz", - "integrity": "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==", - "dev": true, - "dependencies": { - "hachure-fill": "^0.5.2", - "path-data-parser": "^0.1.0", - "points-on-curve": "^0.2.0", - "points-on-path": "^0.2.1" - } - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "node_modules/rw": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", - "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", - "dev": true - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, - "node_modules/scheduler": { - "version": "0.23.2", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", - "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", - "dev": true, - "dependencies": { - "loose-envify": "^1.1.0" - } - }, - "node_modules/scroll-into-view-if-needed": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/scroll-into-view-if-needed/-/scroll-into-view-if-needed-3.1.0.tgz", - "integrity": "sha512-49oNpRjWRvnU8NyGVmUaYG4jtTkNonFZI86MmGRDqBphEK2EXT9gdEUoQPZhuBM8yWHxCWbobltqYO5M4XrUvQ==", - "dev": true, - "dependencies": { - "compute-scroll-into-view": "^3.0.2" - } - }, - "node_modules/section-matter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz", - "integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==", - "dev": true, - "dependencies": { - "extend-shallow": "^2.0.1", - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", - "dev": true, - "dependencies": { - "shebang-regex": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/shiki": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.22.0.tgz", - "integrity": "sha512-/t5LlhNs+UOKQCYBtl5ZsH/Vclz73GIqT2yQsCBygr8L/ppTdmpL4w3kPLoZJbMKVWtoG77Ue1feOjZfDxvMkw==", - "dev": true, - "dependencies": { - "@shikijs/core": "1.22.0", - "@shikijs/engine-javascript": "1.22.0", - "@shikijs/engine-oniguruma": "1.22.0", - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0", - "@types/hast": "^3.0.4" - } - }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, - "node_modules/slash": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", - "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", - "dev": true, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "dev": true, - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/source-map": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", - "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/source-map-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", - "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/space-separated-tokens": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", - "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/speech-rule-engine": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/speech-rule-engine/-/speech-rule-engine-4.0.7.tgz", - "integrity": "sha512-sJrL3/wHzNwJRLBdf6CjJWIlxC04iYKkyXvYSVsWVOiC2DSkHmxsqOhEeMsBA9XK+CHuNcsdkbFDnoUfAsmp9g==", - "dev": true, - "dependencies": { - "commander": "9.2.0", - "wicked-good-xpath": "1.3.0", - "xmldom-sre": "0.1.31" - }, - "bin": { - "sre": "bin/sre" - } - }, - "node_modules/speech-rule-engine/node_modules/commander": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.2.0.tgz", - "integrity": "sha512-e2i4wANQiSXgnrBlIatyHtP1odfUp0BbV5Y5nEGbxtIrStkEOAAzCUirvLBNXHLr7kwLvJl6V+4V3XV9x7Wd9w==", - "dev": true, - "engines": { - "node": "^12.20.0 || >=14" - } - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true - }, - "node_modules/streamsearch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", - "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", - "dev": true, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/stringify-entities": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", - "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", - "dev": true, - "dependencies": { - "character-entities-html4": "^2.0.0", - "character-entities-legacy": "^3.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-bom-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", - "integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/style-to-object": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.4.4.tgz", - "integrity": "sha512-HYNoHZa2GorYNyqiCaBgsxvcJIn7OHq6inEga+E6Ke3m5JkoqpQbnFssk4jwe+K7AhGa2fcha4wSOf1Kn01dMg==", - "dev": true, - "dependencies": { - "inline-style-parser": "0.1.1" - } - }, - "node_modules/styled-jsx": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz", - "integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==", - "dev": true, - "dependencies": { - "client-only": "0.0.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "peerDependencies": { - "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "babel-plugin-macros": { - "optional": true - } - } - }, - "node_modules/stylis": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.4.tgz", - "integrity": "sha512-osIBl6BGUmSfDkyH2mB7EFvCJntXDrLhKjHTRj/rK6xLH0yuPrHULDRQzKokSOD4VoorhtKpfcfW1GAntu8now==", - "dev": true - }, - "node_modules/sucrase": { - "version": "3.35.0", - "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", - "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", - "dev": true, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.2", - "commander": "^4.0.0", - "glob": "^10.3.10", - "lines-and-columns": "^1.1.6", - "mz": "^2.7.0", - "pirates": "^4.0.1", - "ts-interface-checker": "^0.1.9" - }, - "bin": { - "sucrase": "bin/sucrase", - "sucrase-node": "bin/sucrase-node" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/sucrase/node_modules/commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/supports-color": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", - "integrity": "sha512-ycQR/UbvI9xIlEdQT1TQqwoXtEldExbCEAJgRo5YXlmSKjv6ThHnP9/vwGa1gr19Gfw+LkFd7KqYMhzrRC5JYw==", - "dev": true, - "dependencies": { - "has-flag": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/svg-parser": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz", - "integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ==", - "dev": true - }, - "node_modules/svgo": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-3.3.2.tgz", - "integrity": "sha512-OoohrmuUlBs8B8o6MB2Aevn+pRIH9zDALSR+6hhqVfa6fRwG/Qw9VUMSMW9VNg2CFc/MTIfabtdOVl9ODIJjpw==", - "dev": true, - "dependencies": { - "@trysound/sax": "0.2.0", - "commander": "^7.2.0", - "css-select": "^5.1.0", - "css-tree": "^2.3.1", - "css-what": "^6.1.0", - "csso": "^5.0.5", - "picocolors": "^1.0.0" - }, - "bin": { - "svgo": "bin/svgo" - }, - "engines": { - "node": ">=14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/svgo" - } - }, - "node_modules/svgo/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/tabbable": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz", - "integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==", - "dev": true - }, - "node_modules/tailwindcss": { - "version": "3.4.14", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.14.tgz", - "integrity": "sha512-IcSvOcTRcUtQQ7ILQL5quRDg7Xs93PdJEk1ZLbhhvJc7uj/OAhYOnruEiwnGgBvUtaUAJ8/mhSw1o8L2jCiENA==", - "dev": true, - "dependencies": { - "@alloc/quick-lru": "^5.2.0", - "arg": "^5.0.2", - "chokidar": "^3.5.3", - "didyoumean": "^1.2.2", - "dlv": "^1.1.3", - "fast-glob": "^3.3.0", - "glob-parent": "^6.0.2", - "is-glob": "^4.0.3", - "jiti": "^1.21.0", - "lilconfig": "^2.1.0", - "micromatch": "^4.0.5", - "normalize-path": "^3.0.0", - "object-hash": "^3.0.0", - "picocolors": "^1.0.0", - "postcss": "^8.4.23", - "postcss-import": "^15.1.0", - "postcss-js": "^4.0.1", - "postcss-load-config": "^4.0.1", - "postcss-nested": "^6.0.1", - "postcss-selector-parser": "^6.0.11", - "resolve": "^1.22.2", - "sucrase": "^3.32.0" - }, - "bin": { - "tailwind": "lib/cli.js", - "tailwindcss": "lib/cli.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/tailwindcss/node_modules/arg": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", - "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", - "dev": true - }, - "node_modules/tailwindcss/node_modules/postcss-nested": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz", - "integrity": "sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "postcss-selector-parser": "^6.1.1" - }, - "engines": { - "node": ">=12.0" - }, - "peerDependencies": { - "postcss": "^8.2.14" - } - }, - "node_modules/tailwindcss/node_modules/postcss-selector-parser": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", - "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", - "dev": true, - "dependencies": { - "cssesc": "^3.0.0", - "util-deprecate": "^1.0.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/thenify": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", - "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", - "dev": true, - "dependencies": { - "any-promise": "^1.0.0" - } - }, - "node_modules/thenify-all": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", - "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", - "dev": true, - "dependencies": { - "thenify": ">= 3.1.0 < 4" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/tinyexec": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.1.tgz", - "integrity": "sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==", - "dev": true - }, - "node_modules/title": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/title/-/title-3.5.3.tgz", - "integrity": "sha512-20JyowYglSEeCvZv3EZ0nZ046vLarO37prvV0mbtQV7C8DJPGgN967r8SJkqd3XK3K3lD3/Iyfp3avjfil8Q2Q==", - "dev": true, - "dependencies": { - "arg": "1.0.0", - "chalk": "2.3.0", - "clipboardy": "1.2.2", - "titleize": "1.0.0" - }, - "bin": { - "title": "bin/title.js" - } - }, - "node_modules/titleize": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/titleize/-/titleize-1.0.0.tgz", - "integrity": "sha512-TARUb7z1pGvlLxgPk++7wJ6aycXF3GJ0sNSBTAsTuJrQG5QuZlkUQP+zl+nbjAh4gMX9yDw9ZYklMd7vAfJKEw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/trim-lines": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", - "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/trough": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz", - "integrity": "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/ts-dedent": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", - "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", - "dev": true, - "engines": { - "node": ">=6.10" - } - }, - "node_modules/ts-interface-checker": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", - "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", - "dev": true - }, - "node_modules/tslib": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", - "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==", - "dev": true - }, - "node_modules/twoslash": { - "version": "0.2.12", - "resolved": "https://registry.npmjs.org/twoslash/-/twoslash-0.2.12.tgz", - "integrity": "sha512-tEHPASMqi7kqwfJbkk7hc/4EhlrKCSLcur+TcvYki3vhIfaRMXnXjaYFgXpoZRbT6GdprD4tGuVBEmTpUgLBsw==", - "dev": true, - "dependencies": { - "@typescript/vfs": "^1.6.0", - "twoslash-protocol": "0.2.12" - }, - "peerDependencies": { - "typescript": "*" - } - }, - "node_modules/twoslash-protocol": { - "version": "0.2.12", - "resolved": "https://registry.npmjs.org/twoslash-protocol/-/twoslash-protocol-0.2.12.tgz", - "integrity": "sha512-5qZLXVYfZ9ABdjqbvPc4RWMr7PrpPaaDSeaYY55vl/w1j6H6kzsWK/urAEIXlzYlyrFmyz1UbwIt+AA0ck+wbg==", - "dev": true - }, - "node_modules/typescript": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", - "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/ufo": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.5.4.tgz", - "integrity": "sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==", - "dev": true - }, - "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true - }, - "node_modules/unicode-canonical-property-names-ecmascript": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz", - "integrity": "sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", - "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", - "dev": true, - "dependencies": { - "unicode-canonical-property-names-ecmascript": "^2.0.0", - "unicode-property-aliases-ecmascript": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-value-ecmascript": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.0.tgz", - "integrity": "sha512-4IehN3V/+kkr5YeSSDDQG8QLqO26XpL2XP3GQtqwlT/QYSECAwFztxVHjlbh0+gjJ3XmNLS0zDsbgs9jWKExLg==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-property-aliases-ecmascript": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", - "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/unified": { - "version": "11.0.5", - "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", - "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "bail": "^2.0.0", - "devlop": "^1.0.0", - "extend": "^3.0.0", - "is-plain-obj": "^4.0.0", - "trough": "^2.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-find-after": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-5.0.0.tgz", - "integrity": "sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-modify-children": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-modify-children/-/unist-util-modify-children-4.0.0.tgz", - "integrity": "sha512-+tdN5fGNddvsQdIzUF3Xx82CU9sMM+fA0dLgR9vOmT0oPT2jH+P1nd5lSqfCfXAw+93NhcXNY2qqvTUtE4cQkw==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "array-iterate": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-position": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", - "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-position-from-estree": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unist-util-position-from-estree/-/unist-util-position-from-estree-2.0.0.tgz", - "integrity": "sha512-KaFVRjoqLyF6YXCbVLNad/eS4+OfPQQn2yOd7zF/h5T/CSL2v8NpN6a5TPvtbXthAGw5nG+PuTtq+DdIZr+cRQ==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-remove": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-remove/-/unist-util-remove-4.0.0.tgz", - "integrity": "sha512-b4gokeGId57UVRX/eVKej5gXqGlc9+trkORhFJpu9raqZkZhU0zm8Doi05+HaiBsMEIJowL+2WtQ5ItjsngPXg==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-remove-position": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-5.0.0.tgz", - "integrity": "sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-visit": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-stringify-position": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", - "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-visit-children": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-children/-/unist-util-visit-children-3.0.0.tgz", - "integrity": "sha512-RgmdTfSBOg04sdPcpTSD1jzoNBjt9a80/ZCzp5cI9n1qPzLZWF9YdvWGN2zmTumP1HWhXKdUWexjy/Wy/lJ7tA==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/update-browserslist-db": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", - "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "escalade": "^3.2.0", - "picocolors": "^1.1.0" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true - }, - "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/vfile": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", - "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "vfile-message": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/vfile-location": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.3.tgz", - "integrity": "sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "vfile": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/vfile-message": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz", - "integrity": "sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==", - "dev": true, - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-stringify-position": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/vscode-jsonrpc": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", - "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", - "dev": true, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/vscode-languageserver": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz", - "integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==", - "dev": true, - "dependencies": { - "vscode-languageserver-protocol": "3.17.5" - }, - "bin": { - "installServerIntoExtension": "bin/installServerIntoExtension" - } - }, - "node_modules/vscode-languageserver-protocol": { - "version": "3.17.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz", - "integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==", - "dev": true, - "dependencies": { - "vscode-jsonrpc": "8.2.0", - "vscode-languageserver-types": "3.17.5" - } - }, - "node_modules/vscode-languageserver-textdocument": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", - "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", - "dev": true - }, - "node_modules/vscode-languageserver-types": { - "version": "3.17.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", - "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==", - "dev": true - }, - "node_modules/vscode-uri": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", - "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==", - "dev": true - }, - "node_modules/web-namespaces": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz", - "integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" - } - }, - "node_modules/wicked-good-xpath": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/wicked-good-xpath/-/wicked-good-xpath-1.3.0.tgz", - "integrity": "sha512-Gd9+TUn5nXdwj/hFsPVx5cuHHiF5Bwuc30jZ4+ronF1qHK5O7HD0sgmXWSEgwKquT3ClLoKPVbO6qGwVwLzvAw==", - "dev": true - }, - "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/xmldom-sre": { - "version": "0.1.31", - "resolved": "https://registry.npmjs.org/xmldom-sre/-/xmldom-sre-0.1.31.tgz", - "integrity": "sha512-f9s+fUkX04BxQf+7mMWAp5zk61pciie+fFLC9hX9UVvCeJQfNHRHXpeo5MPcR0EUf57PYLdt+ZO4f3Ipk2oZUw==", - "dev": true, - "engines": { - "node": ">=0.1" - } - }, - "node_modules/yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", - "dev": true - }, - "node_modules/yaml": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.0.tgz", - "integrity": "sha512-a6ae//JvKDEra2kdi1qzCyrJW/WZCgFi8ydDV+eXExl95t+5R+ijnqHJbz9tmMh8FUjx3iv2fCQ4dclAQlO2UQ==", - "dev": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/yocto-queue": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", - "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==", - "dev": true, - "engines": { - "node": ">=12.20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/zod": { - "version": "3.23.8", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", - "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, - "node_modules/zod-validation-error": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/zod-validation-error/-/zod-validation-error-3.4.0.tgz", - "integrity": "sha512-ZOPR9SVY6Pb2qqO5XHt+MkkTRxGXb4EVtnjc9JpXUOtUB1T9Ru7mZOT361AN3MsetVe7R0a1KZshJDZdgp9miQ==", - "dev": true, - "engines": { - "node": ">=18.0.0" - }, - "peerDependencies": { - "zod": "^3.18.0" - } - }, - "node_modules/zwitch": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", - "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - } - } -} diff --git a/website/package.json b/website/package.json deleted file mode 100644 index a69e6e4043..0000000000 --- a/website/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "website", - "version": "0.0.0", - "description": "The GraphQL.JS documentation website", - "private": true, - "directories": { - "doc": "docs" - }, - "scripts": { - "build": "next build", - "dev": "next" - }, - "devDependencies": { - "@svgr/webpack": "^8.1.0", - "@tailwindcss/typography": "^0.5.10", - "@types/node": "^22.7.5", - "autoprefixer": "^10.4.20", - "next": "^14.2.15", - "nextra": "^3.0.13", - "nextra-theme-docs": "^3.0.13", - "postcss": "^8.4.47", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "tailwindcss": "^3.4.14", - "typescript": "^5.6.3" - } -} diff --git a/website/pages/_app.tsx b/website/pages/_app.tsx deleted file mode 100644 index c50ff45c1e..0000000000 --- a/website/pages/_app.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import type { AppProps } from 'next/app'; -import { Roboto_Flex, Roboto_Mono } from 'next/font/google'; - -import '../css/globals.css'; - -const robotoFlex = Roboto_Flex({ - subsets: ['latin'], -}); - -const robotoMono = Roboto_Mono({ - subsets: ['latin'], -}); - -// TODO: do we need google analytics? - -export default function App({ Component, pageProps }: AppProps) { - return ( - <> - - - - ); -} diff --git a/website/pages/_document.tsx b/website/pages/_document.tsx deleted file mode 100644 index e1e9cbbb75..0000000000 --- a/website/pages/_document.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Html, Head, Main, NextScript } from 'next/document'; - -export default function Document() { - return ( - - - -
- - - - ); -} diff --git a/website/pages/_meta.ts b/website/pages/_meta.ts deleted file mode 100644 index 7bf4b6e9cd..0000000000 --- a/website/pages/_meta.ts +++ /dev/null @@ -1,28 +0,0 @@ -const meta = { - docs: { - type: 'page', - title: 'Documentation', - }, - 'upgrade-guides': { - type: 'menu', - title: 'Upgrade Guides', - items: { - 'v16-v17': { - title: 'v16 to v17', - href: '/upgrade-guides/v16-v17', - }, - }, - }, - 'api-v16': { - type: 'menu', - title: 'API', - items: { - 2: { - title: 'V16', - href: '/api-v16/graphql', - }, - }, - }, -}; - -export default meta; diff --git a/website/pages/api-v16/_meta.ts b/website/pages/api-v16/_meta.ts deleted file mode 100644 index 075de90bca..0000000000 --- a/website/pages/api-v16/_meta.ts +++ /dev/null @@ -1,12 +0,0 @@ -const meta = { - graphql: '', - error: '', - execution: '', - language: '', - type: '', - utilities: '', - validation: '', - 'graphql-http': '', -}; - -export default meta; diff --git a/website/pages/api-v16/error.mdx b/website/pages/api-v16/error.mdx deleted file mode 100644 index 50cb70e4ea..0000000000 --- a/website/pages/api-v16/error.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: graphql/error ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql/error` - -The `graphql/error` module is responsible for creating and formatting -GraphQL errors. You can import either from the `graphql/error` module, or from the root `graphql` module. For example: - -```js -import { GraphQLError } from 'graphql'; -``` - -## Overview - - - -## Errors - -### `GraphQLError` - -```ts -class GraphQLError extends Error { - constructor( - message: string, - nodes?: any[], - stack?: string, - source?: Source, - positions?: number[], - originalError?: Error, - extensions?: Record, - ); -} -``` - -A representation of an error that occurred within GraphQL. Contains -information about where in the query the error occurred for debugging. Most -commonly constructed with `locatedError` below. - -### `syntaxError` - -```ts -function syntaxError( - source: Source, - position: number, - description: string, -): GraphQLError; -``` - -Produces a GraphQLError representing a syntax error, containing useful -descriptive information about the syntax error's position in the source. - -### `locatedError` - -```ts -function locatedError(error: Error, nodes: any[]): GraphQLError; -``` - -Given an arbitrary Error, presumably thrown while attempting to execute a -GraphQL operation, produce a new GraphQLError aware of the location in the -document responsible for the original Error. - -### `formatError` - -```ts -function formatError(error: GraphQLError): GraphQLFormattedError; - -type GraphQLFormattedError = { - message: string; - locations: GraphQLErrorLocation[]; -}; - -type GraphQLErrorLocation = { - line: number; - column: number; -}; -``` - -Given a GraphQLError, format it according to the rules described by the -Response Format, Errors section of the GraphQL Specification. diff --git a/website/pages/api-v16/execution.mdx b/website/pages/api-v16/execution.mdx deleted file mode 100644 index c160797aa0..0000000000 --- a/website/pages/api-v16/execution.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: graphql/execution ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql/execution` - -The `graphql/execution` module is responsible for the execution phase of -fulfilling a GraphQL request. You can import either from the `graphql/execution` module, or from the root `graphql` module. For example: - -```js -import { execute } from 'graphql'; -``` - -## Overview - - - -## Execution - -### execute - -```ts -export function execute({ - schema, - document - rootValue, - contextValue, - variableValues, - operationName, - options, -}: ExecutionParams): MaybePromise; - -type ExecutionParams = { - schema: GraphQLSchema; - document: Document; - rootValue?: unknown; - contextValue?: unknown; - variableValues?: Record; - operationName?: string; - options?: { - /** Set the maximum number of errors allowed for coercing (defaults to 50). */ - maxCoercionErrors?: number; - } -}; - -type MaybePromise = Promise | T; - -interface ExecutionResult< - TData = ObjMap, - TExtensions = ObjMap, -> { - errors?: ReadonlyArray; - data?: TData | null; - extensions?: TExtensions; -} -``` - -We have another approach with positional arguments, this is however deprecated and set -to be removed in v17. - -```ts -export function execute( - schema: GraphQLSchema, - documentAST: Document, - rootValue?: unknown, - contextValue?: unknown, - variableValues?: Record, - operationName?: string, -): MaybePromise; -``` - -Implements the "Evaluating requests" section of the GraphQL specification. - -Returns a Promise that will eventually be resolved and never rejected. - -If the arguments to this function do not result in a legal execution context, -a GraphQLError will be thrown immediately explaining the invalid input. - -`ExecutionResult` represents the result of execution. `data` is the result of -executing the query, `errors` is null if no errors occurred, and is a -non-empty array if an error occurred. - -### executeSync - -This is a short-hand method that will call `execute` and when the response can -be returned synchronously it will be returned, when a `Promise` is returned this -method will throw an error. - -```ts -export function executeSync({ - schema, - document, - rootValue, - contextValue, - variableValues, - operationName, - options, -}: ExecutionParams): MaybePromise; - -type ExecutionParams = { - schema: GraphQLSchema; - document: Document; - rootValue?: unknown; - contextValue?: unknown; - variableValues?: Record; - operationName?: string; - options?: { - /** Set the maximum number of errors allowed for coercing (defaults to 50). */ - maxCoercionErrors?: number; - } -}; - -type MaybePromise = Promise | T; - -interface ExecutionResult< - TData = ObjMap, - TExtensions = ObjMap, -> { - errors?: ReadonlyArray; - data?: TData | null; - extensions?: TExtensions; -} -``` - -We have another approach with positional arguments, this is however deprecated and set -to be removed in v17. - -```ts -export function executeSync( - schema: GraphQLSchema, - documentAST: Document, - rootValue?: unknown, - contextValue?: unknown, - variableValues?: Record, - operationName?: string, -): ExecutionResult; -``` - -#### Execution options - -##### maxCoercionErrors - -Set the maximum number of errors allowed for coercing variables, this implements a default limit of 50 errors. diff --git a/website/pages/api-v16/graphql-http.mdx b/website/pages/api-v16/graphql-http.mdx deleted file mode 100644 index 9b8285cd6c..0000000000 --- a/website/pages/api-v16/graphql-http.mdx +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: graphql-http ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql-http` - -The [official `graphql-http` package](https://github.com/graphql/graphql-http) provides a simple way to create a fully compliant GraphQL server. It has a handler for Node.js native [`http`](https://nodejs.org/api/http.html), together with handlers for well-known frameworks like [Express](https://expressjs.com/), [Fastify](https://www.fastify.io/) and [Koa](https://koajs.com/); as well as handlers for different runtimes like [Deno](https://deno.land/) and [Bun](https://bun.sh/). - -## Express - -```js -import { createHandler } from 'graphql-http/lib/use/express'; -``` - -### createHandler - -```ts -function createHandler({ - schema, - rootValue, - context, - formatError, - validationRules, -}: { - rootValue?: any; - context?: any; - formatError?: Function; - validationRules?: any[]; -}): Handler; -``` - -Constructs an Express handler based on a GraphQL schema. - -See the [tutorial](/running-an-express-graphql-server/) for sample usage. - -See the [GitHub README](https://github.com/graphql/graphql-http) for more extensive documentation, including how to use `graphql-http` with other server frameworks and runtimes. diff --git a/website/pages/api-v16/graphql.mdx b/website/pages/api-v16/graphql.mdx deleted file mode 100644 index 2c736c87ff..0000000000 --- a/website/pages/api-v16/graphql.mdx +++ /dev/null @@ -1,180 +0,0 @@ ---- -title: graphql ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql` - -The `graphql` module exports a core subset of GraphQL functionality for creation -of GraphQL type systems and servers. - -```js -import { graphql } from 'graphql'; -``` - -## Overview - -### Entry Point - - - -### Schema - - - -### Type Definitions - - - -### Scalars - - - -### Errors - - - -## Entry Point - -### `graphql` - -```ts -function graphql( - schema: GraphQLSchema, - requestString: string, - rootValue?: any, - contextValue?: any, - variableValues?: { [key: string]: any }, - operationName?: string, -): Promise; - -interface ExecutionResult< - TData = ObjMap, - TExtensions = ObjMap, -> { - errors?: ReadonlyArray; - data?: TData | null; - extensions?: TExtensions; -} -``` - -The `graphql` function lexes, parses, validates and executes a GraphQL request. -It requires a `schema` and a `requestString`. Optional arguments include a -`rootValue`, which will get passed as the root value to the executor, a `contextValue`, -which will get passed to all resolve functions, -`variableValues`, which will get passed to the executor to provide values for -any variables in `requestString`, and `operationName`, which allows the caller -to specify which operation in `requestString` will be run, in cases where -`requestString` contains multiple top-level operations. - -## Schema - -See the [Type System API Reference](/type#schema). - -## Type Definitions - -See the [Type System API Reference](/type#definitions). - -## Scalars - -See the [Type System API Reference](/type#scalars). - -## Errors - -See the [Errors API Reference](/error) diff --git a/website/pages/api-v16/language.mdx b/website/pages/api-v16/language.mdx deleted file mode 100644 index cd96ce4101..0000000000 --- a/website/pages/api-v16/language.mdx +++ /dev/null @@ -1,294 +0,0 @@ ---- -title: graphql/language ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql/language` - -The `graphql/language` module is responsible for parsing and operating on the GraphQL language. You can import either from the `graphql/language` module, or from the root `graphql` module. For example: - -```js -import { Source } from 'graphql'; -``` - -## Overview - -### Source - - - -### Lexer - - - -### Parser - - - -### Visitor - - - -### Printer - - - -## Source - -### Source - -```ts -export class Source { - constructor(body: string, name?: string); -} -``` - -A representation of source input to GraphQL. The name is optional, -but is mostly useful for clients who store GraphQL documents in -source files; for example, if the GraphQL input is in a file Foo.graphql, -it might be useful for name to be "Foo.graphql". - -### getLocation - -```ts -function getLocation(source: Source, position: number): SourceLocation; - -type SourceLocation = { - line: number; - column: number; -}; -``` - -Takes a Source and a UTF-8 character offset, and returns the corresponding -line and column as a SourceLocation. - -## Lexer - -### `lex` - -```ts -function lex(source: Source): Lexer; - -type Lexer = (resetPosition?: number) => Token; - -export type Token = { - kind: number; - start: number; - end: number; - value: string; -}; -``` - -Given a Source object, this returns a Lexer for that source. -A Lexer is a function that acts like a generator in that every time -it is called, it returns the next token in the Source. Assuming the -source lexes, the final Token emitted by the lexer will be of kind -EOF, after which the lexer will repeatedly return EOF tokens whenever -called. - -The argument to the lexer function is optional, and can be used to -rewind or fast forward the lexer to a new position in the source. - -## Parser - -### `parse` - -```ts -export function parse( - source: Source | string, - options?: ParseOptions, -): Document; -``` - -Given a GraphQL source, parses it into a Document. - -Throws GraphQLError if a syntax error is encountered. - -### `parseValue` - -```ts -export function parseValue( - source: Source | string, - options?: ParseOptions, -): Value; -``` - -Given a string containing a GraphQL value, parse the AST for that value. - -Throws GraphQLError if a syntax error is encountered. - -This is useful within tools that operate upon GraphQL Values directly and -in isolation of complete GraphQL documents. - -### `Kind` - -An enum that describes the different kinds of AST nodes. - -## Visitor - -### `visit` - -```ts -function visit(root, visitor, keyMap); -``` - -visit() will walk through an AST using a depth first traversal, calling -the visitor's enter function at each node in the traversal, and calling the -leave function after visiting that node and all of its child nodes. - -By returning different values from the enter and leave functions, the -behavior of the visitor can be altered, including skipping over a sub-tree of -the AST (by returning false), editing the AST by returning a value or null -to remove the value, or to stop the whole traversal by returning BREAK. - -When using visit() to edit an AST, the original AST will not be modified, and -a new version of the AST with the changes applied will be returned from the -visit function. - -```js -const editedAST = visit(ast, { - enter(node, key, parent, path, ancestors) { - // @return - // undefined: no action - // false: skip visiting this node - // visitor.BREAK: stop visiting altogether - // null: delete this node - // any value: replace this node with the returned value - }, - leave(node, key, parent, path, ancestors) { - // @return - // undefined: no action - // false: no action - // visitor.BREAK: stop visiting altogether - // null: delete this node - // any value: replace this node with the returned value - }, -}); -``` - -Alternatively to providing enter() and leave() functions, a visitor can -instead provide functions named the same as the kinds of AST nodes, or -enter/leave visitors at a named key, leading to four permutations of -visitor API: - -1. Named visitors triggered when entering a node a specific kind. - -```js -visit(ast, { - Kind(node) { - // enter the "Kind" node - }, -}); -``` - -2. Named visitors that trigger upon entering and leaving a node of - a specific kind. - -```js -visit(ast, { - Kind: { - enter(node) { - // enter the "Kind" node - }, - leave(node) { - // leave the "Kind" node - }, - }, -}); -``` - -3. Generic visitors that trigger upon entering and leaving any node. - -```js -visit(ast, { - enter(node) { - // enter any node - }, - leave(node) { - // leave any node - }, -}); -``` - -4. Parallel visitors for entering and leaving nodes of a specific kind. - -```js -visit(ast, { - enter: { - Kind(node) { - // enter the "Kind" node - }, - }, - leave: { - Kind(node) { - // leave the "Kind" node - }, - }, -}); -``` - -### `BREAK` - -The sentinel `BREAK` value described in the documentation of `visitor`. - -## Printer - -### `print` - -```ts -function print(ast): string; -``` - -Converts an AST into a string, using one set of reasonable -formatting rules. diff --git a/website/pages/api-v16/type.mdx b/website/pages/api-v16/type.mdx deleted file mode 100644 index c829d9708d..0000000000 --- a/website/pages/api-v16/type.mdx +++ /dev/null @@ -1,672 +0,0 @@ ---- -title: graphql/type ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql/type` - -The `graphql/type` module is responsible for defining GraphQL types and schema. You can import either from the `graphql/type` module, or from the root `graphql` module. For example: - -```js -import { GraphQLSchema } from 'graphql'; -``` - -## Overview - -### Schema - - - -### Definitions - - - -### Predicates - - - -### Un-modifiers - - - -### Scalars - - - -## Schema - -### GraphQLSchema - -```ts -class GraphQLSchema { - constructor(config: GraphQLSchemaConfig); -} - -type GraphQLSchemaConfig = { - query: GraphQLObjectType; - mutation?: GraphQLObjectType; -}; -``` - -A Schema is created by supplying the root types of each type of operation, -query and mutation (optional). A schema definition is then supplied to the -validator and executor. - -#### Example - -```js -const MyAppSchema = new GraphQLSchema({ - query: MyAppQueryRootType, - mutation: MyAppMutationRootType, -}); -``` - -## Definitions - -### GraphQLScalarType - -```ts -class GraphQLScalarType { - constructor(config: GraphQLScalarTypeConfig); -} - -type GraphQLScalarTypeConfig = { - name: string; - description?: string; - specifiedByURL?: Maybe; - serialize: (outputValue: unknown) => ExternalType; - parseValue?: (inputValue: unknown) => InternalType; - parseLiteral?: ( - valueAST: Value, - variables?: Maybe>, - ) => InternalType; -}; -``` - -The leaf values of any request and input values to arguments are -Scalars (or Enums) and are defined with a name and a series of serialization -functions used to ensure validity. - -#### Example - -```js -const OddType = new GraphQLScalarType({ - name: 'Odd', - // Can be used to link to a specification - // for this scalar, for instance the JSON - // specification. - specifiedByURL: '', - description: - 'This custom scalar will only return a value if the passed in value is an odd integer, when it's not it will return null.' - serialize: (outputValue) => { - // This function gets called for response-data, the application returns data - // for a property and in the schema we see that this value has the "Odd" type. - return typeof outputValue === 'number' && outputValue % 2 === 1 ? value : null; - }, - parseValue: (inputValue) => { - // This function gets called for input-data, i.e. variables being passed in - return typeof inputValue === 'number' && outputValue % 2 === 1 ? value : null; - }, - parseLiteral(ast) { - // This function gets called when the value is passed in as a literal on the - // Executable GraphQL Document - if (ast.kind === Kind.INT) { - return oddValue(parseInt(ast.value, 10)); - } - return null; - }, -}); -``` - -### GraphQLObjectType - -```ts -class GraphQLObjectType { - constructor(config: GraphQLObjectTypeConfig); -} - -type GraphQLObjectTypeConfig = { - name: string; - interfaces?: GraphQLInterfacesThunk | GraphQLInterfaceType[]; - fields: GraphQLFieldConfigMapThunk | GraphQLFieldConfigMap; - isTypeOf?: (value: any, info?: GraphQLResolveInfo) => boolean; - description?: string; -}; - -type GraphQLInterfacesThunk = () => Array; - -type GraphQLFieldConfigMapThunk = () => GraphQLFieldConfigMap; - -// See below about resolver functions. -type GraphQLFieldResolveFn = ( - source?: any, - args?: { [argName: string]: any }, - context?: any, - info?: GraphQLResolveInfo, -) => any; - -type GraphQLResolveInfo = { - fieldName: string; - fieldNodes: Array; - returnType: GraphQLOutputType; - parentType: GraphQLCompositeType; - schema: GraphQLSchema; - fragments: { [fragmentName: string]: FragmentDefinition }; - rootValue: any; - operation: OperationDefinition; - variableValues: { [variableName: string]: any }; -}; - -type GraphQLFieldConfig = { - type: GraphQLOutputType; - args?: GraphQLFieldConfigArgumentMap; - resolve?: GraphQLFieldResolveFn; - deprecationReason?: string; - description?: string; -}; - -type GraphQLFieldConfigArgumentMap = { - [argName: string]: GraphQLArgumentConfig; -}; - -type GraphQLArgumentConfig = { - type: GraphQLInputType; - defaultValue?: any; - description?: string; -}; - -type GraphQLFieldConfigMap = { - [fieldName: string]: GraphQLFieldConfig; -}; -``` - -Almost all of the GraphQL types you define will be object types. Object types -have a name, but most importantly describe their fields. - -When two types need to refer to each other, or a type needs to refer to -itself in a field, you can use a function expression (aka a closure or a -thunk) to supply the fields lazily. - -Note that resolver functions are provided the `source` object as the first parameter. -However, if a resolver function is not provided, then the default resolver is -used, which looks for a method on `source` of the same name as the field. If found, -the method is called with `(args, context, info)`. Since it is a method on `source`, -that value can always be referenced with `this`. - -#### Examples - -```js -const AddressType = new GraphQLObjectType({ - name: 'Address', - fields: { - street: { type: GraphQLString }, - number: { type: GraphQLInt }, - formatted: { - type: GraphQLString, - resolve(obj) { - return obj.number + ' ' + obj.street; - }, - }, - }, -}); - -const PersonType = new GraphQLObjectType({ - name: 'Person', - fields: () => ({ - name: { type: GraphQLString }, - bestFriend: { type: PersonType }, - }), -}); -``` - -### GraphQLInterfaceType - -```ts -class GraphQLInterfaceType { - constructor(config: GraphQLInterfaceTypeConfig); -} - -type GraphQLInterfaceTypeConfig = { - name: string; - fields: GraphQLFieldConfigMapThunk | GraphQLFieldConfigMap; - resolveType?: (value: any, info?: GraphQLResolveInfo) => GraphQLObjectType; - description?: string; -}; -``` - -When a field can return one of a heterogeneous set of types, a Interface type -is used to describe what types are possible, what fields are in common across -all types, as well as a function to determine which type is actually used -when the field is resolved. - -#### Example - -```js -const EntityType = new GraphQLInterfaceType({ - name: 'Entity', - fields: { - name: { type: GraphQLString }, - }, -}); -``` - -### GraphQLUnionType - -```ts -class GraphQLUnionType { - constructor(config: GraphQLUnionTypeConfig); -} - -type GraphQLUnionTypeConfig = { - name: string; - types: GraphQLObjectsThunk | GraphQLObjectType[]; - resolveType?: (value: any, info?: GraphQLResolveInfo) => GraphQLObjectType; - description?: string; -}; - -type GraphQLObjectsThunk = () => GraphQLObjectType[]; -``` - -When a field can return one of a heterogeneous set of types, a Union type -is used to describe what types are possible as well as providing a function -to determine which type is actually used when the field is resolved. - -### Example - -```js -const PetType = new GraphQLUnionType({ - name: 'Pet', - types: [DogType, CatType], - resolveType(value) { - if (value instanceof Dog) { - return DogType; - } - if (value instanceof Cat) { - return CatType; - } - }, -}); -``` - -### GraphQLEnumType - -```ts -class GraphQLEnumType { - constructor(config: GraphQLEnumTypeConfig); -} - -type GraphQLEnumTypeConfig = { - name: string; - values: GraphQLEnumValueConfigMap; - description?: string; -}; - -type GraphQLEnumValueConfigMap = { - [valueName: string]: GraphQLEnumValueConfig; -}; - -type GraphQLEnumValueConfig = { - value?: any; - deprecationReason?: string; - description?: string; -}; - -type GraphQLEnumValueDefinition = { - name: string; - value?: any; - deprecationReason?: string; - description?: string; -}; -``` - -Some leaf values of requests and input values are Enums. GraphQL serializes -Enum values as strings, however internally Enums can be represented by any -kind of type, often integers. - -Note: If a value is not provided in a definition, the name of the enum value -will be used as its internal value. - -#### Example - -```js -const RGBType = new GraphQLEnumType({ - name: 'RGB', - values: { - RED: { value: 0 }, - GREEN: { value: 1 }, - BLUE: { value: 2 }, - }, -}); -``` - -### GraphQLInputObjectType - -```ts -class GraphQLInputObjectType { - constructor(config: GraphQLInputObjectConfig); -} - -type GraphQLInputObjectConfig = { - name: string; - fields: - | GraphQLInputObjectConfigFieldMapThunk - | GraphQLInputObjectConfigFieldMap; - description?: string; -}; - -type GraphQLInputObjectConfigFieldMapThunk = - () => GraphQLInputObjectConfigFieldMap; - -type GraphQLInputObjectFieldConfig = { - type: GraphQLInputType; - defaultValue?: any; - description?: string; -}; - -type GraphQLInputObjectConfigFieldMap = { - [fieldName: string]: GraphQLInputObjectFieldConfig; -}; - -type GraphQLInputObjectField = { - name: string; - type: GraphQLInputType; - defaultValue?: any; - description?: string; -}; - -type GraphQLInputObjectFieldMap = { - [fieldName: string]: GraphQLInputObjectField; -}; -``` - -An input object defines a structured collection of fields which may be -supplied to a field argument. - -Using `NonNull` will ensure that a value must be provided by the query - -#### Example - -```js -const GeoPoint = new GraphQLInputObjectType({ - name: 'GeoPoint', - fields: { - lat: { type: new GraphQLNonNull(GraphQLFloat) }, - lon: { type: new GraphQLNonNull(GraphQLFloat) }, - alt: { type: GraphQLFloat, defaultValue: 0 }, - }, -}); -``` - -### GraphQLList - -```ts -class GraphQLList { - constructor(type: GraphQLType); -} -``` - -A list is a kind of type marker, a wrapping type which points to another -type. Lists are often created within the context of defining the fields of -an object type. - -#### Example - -```js -const PersonType = new GraphQLObjectType({ - name: 'Person', - fields: () => ({ - parents: { type: new GraphQLList(PersonType) }, - children: { type: new GraphQLList(PersonType) }, - }), -}); -``` - -### GraphQLNonNull - -```ts -class GraphQLNonNull { - constructor(type: GraphQLType); -} -``` - -A non-null is a kind of type marker, a wrapping type which points to another -type. Non-null types enforce that their values are never null and can ensure -an error is raised if this ever occurs during a request. It is useful for -fields which you can make a strong guarantee on non-nullability, for example -usually the id field of a database row will never be null. - -#### Example - -```js -const RowType = new GraphQLObjectType({ - name: 'Row', - fields: () => ({ - id: { type: new GraphQLNonNull(String) }, - }), -}); -``` - -## Predicates - -### isInputType - -```js -function isInputType(type: GraphQLType): boolean -``` - -These types may be used as input types for arguments and directives. - -### isOutputType - -```ts -function isOutputType(type: GraphQLType): boolean; -``` - -These types may be used as output types as the result of fields - -### isLeafType - -```ts -function isLeafType(type: GraphQLType): boolean; -``` - -These types may describe types which may be leaf values - -### isCompositeType - -```ts -function isCompositeType(type: GraphQLType): boolean; -``` - -These types may describe the parent context of a selection set - -### isAbstractType - -```ts -function isAbstractType(type: GraphQLType): boolean; -``` - -These types may describe a combination of object types - -## Un-modifiers - -### getNullableType - -```ts -function getNullableType(type: GraphQLType): GraphQLNullableType; -``` - -If a given type is non-nullable, this strips the non-nullability and -returns the underlying type. - -### getNamedType - -```ts -function getNamedType(type: GraphQLType): GraphQLNamedType; -``` - -If a given type is non-nullable or a list, this repeated strips the -non-nullability and list wrappers and returns the underlying type. - -## Scalars - -### GraphQLInt - -```ts -let GraphQLInt: GraphQLScalarType; -``` - -A `GraphQLScalarType` that represents an int. - -### GraphQLFloat - -```ts -let GraphQLFloat: GraphQLScalarType; -``` - -A `GraphQLScalarType` that represents a float. - -### GraphQLString - -```ts -let GraphQLString: GraphQLScalarType; -``` - -A `GraphQLScalarType` that represents a string. - -### GraphQLBoolean - -```ts -let GraphQLBoolean: GraphQLScalarType; -``` - -A `GraphQLScalarType` that represents a boolean. - -### GraphQLID - -```ts -let GraphQLID: GraphQLScalarType; -``` - -A `GraphQLScalarType` that represents an ID. diff --git a/website/pages/api-v16/utilities.mdx b/website/pages/api-v16/utilities.mdx deleted file mode 100644 index 1e646d8be7..0000000000 --- a/website/pages/api-v16/utilities.mdx +++ /dev/null @@ -1,231 +0,0 @@ ---- -title: graphql/utilities ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql/utilities` - -The `graphql/utilities` module contains common useful computations to use with -the GraphQL language and type objects. You can import either from the `graphql/utilities` module, or from the root `graphql` module. For example: - -```js -import { introspectionQuery } from 'graphql'; -``` - -## Overview - -### Introspection - - - -### Schema Language - - - -### Visitors - - - -### Value Validation - - - -## Introspection - -### introspectionQuery - -```js -const introspectionQuery: string; -``` - -A GraphQL query that queries a server's introspection system for enough -information to reproduce that server's type system. - -### `buildClientSchema` - -```ts -function buildClientSchema(introspection: IntrospectionQuery): GraphQLSchema; -``` - -Build a GraphQLSchema for use by client tools. - -Given the result of a client running the introspection query, creates and -returns a GraphQLSchema instance which can be then used with all GraphQL.js -tools, but cannot be used to execute a query, as introspection does not -represent the "resolver", "parse" or "serialize" functions or any other -server-internal mechanisms. - -## Schema Representation - -### `buildSchema` - -```ts -function buildSchema(source: string | Source): GraphQLSchema; -``` - -Creates a GraphQLSchema object from GraphQL schema language. The schema will use default resolvers. For more detail on the GraphQL schema language, see the [schema language docs](/learn/schema/) or this [schema language cheat sheet](https://wehavefaces.net/graphql-shorthand-notation-cheatsheet-17cd715861b6#.9oztv0a7n). - -### `printSchema` - -```ts -function printSchema(schema: GraphQLSchema): string; -``` - -Prints the provided schema in the Schema Language format. - -### `printIntrospectionSchema` - -```ts -function printIntrospectionSchema(schema: GraphQLSchema): string; -``` - -Prints the built-in introspection schema in the Schema Language format. - -### `buildASTSchema` - -```ts -function buildASTSchema( - ast: SchemaDocument, - queryTypeName: string, - mutationTypeName: string, -): GraphQLSchema; -``` - -This takes the ast of a schema document produced by `parseSchemaIntoAST` in -`graphql/language/schema` and constructs a GraphQLSchema instance which can be -then used with all GraphQL.js tools, but cannot be used to execute a query, as -introspection does not represent the "resolver", "parse" or "serialize" -functions or any other server-internal mechanisms. - -### `typeFromAST` - -```ts -function typeFromAST(schema: GraphQLSchema, inputTypeAST: Type): GraphQLType; -``` - -Given the name of a Type as it appears in a GraphQL AST and a Schema, return the -corresponding GraphQLType from that schema. - -### `astFromValue` - -```ts -function astFromValue(value: any, type: GraphQLInputType): Value; -``` - -Produces a GraphQL Input Value AST given a JavaScript value. - -Optionally, a GraphQL type may be provided, which will be used to -disambiguate between value primitives. - -## Visitors - -### `TypeInfo` - -```ts -class TypeInfo { - constructor(schema: GraphQLSchema); - getType(): GraphQLOutputType; - getParentType(): GraphQLCompositeType; - getInputType(): GraphQLInputType; - getFieldDef(): GraphQLFieldDefinition; - getDirective(): GraphQLDirective; - getArgument(): GraphQLArgument; -} -``` - -TypeInfo is a utility class which, given a GraphQL schema, can keep track -of the current field and type definitions at any point in a GraphQL document -AST during a recursive descent by calling `enter(node)` and `leave(node)`. - -## Value Validation - -### `isValidJSValue` - -```ts -function isValidJSValue(value: any, type: GraphQLInputType): string[]; -``` - -Given a JavaScript value and a GraphQL type, determine if the value will be -accepted for that type. This is primarily useful for validating the -runtime values of query variables. - -### `isValidLiteralValue` - -```ts -function isValidLiteralValue(type: GraphQLInputType, valueAST: Value): string[]; -``` - -Utility for validators which determines if a value literal AST is valid given -an input type. - -Note that this only validates literal values, variables are assumed to -provide values of the correct type. diff --git a/website/pages/api-v16/validation.mdx b/website/pages/api-v16/validation.mdx deleted file mode 100644 index 1acc121da6..0000000000 --- a/website/pages/api-v16/validation.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: graphql/validation ---- - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# `graphql/validation` - -The `graphql/validation` module fulfills the Validation phase of fulfilling a -GraphQL result. You can import either from the `graphql/validation` module, or from the root `graphql` module. For example: - -```js -import { validate } from 'graphql/validation'; -``` - -## Overview - - - -## Validation - -### `validate` - -```ts -function validate( - schema: GraphQLSchema, - ast: Document, - rules?: any[], -): GraphQLError[]; -``` - -Implements the "Validation" section of the spec. - -Validation runs synchronously, returning an array of encountered errors, or -an empty array if no errors were encountered and the document is valid. - -A list of specific validation rules may be provided. If not provided, the -default list of rules defined by the GraphQL specification will be used. - -Each validation rules is a function which returns a visitor -(see the language/visitor API). Visitor methods are expected to return -GraphQLErrors, or Arrays of GraphQLErrors when invalid. - -Visitors can also supply `visitSpreadFragments: true` which will alter the -behavior of the visitor to skip over top level defined fragments, and instead -visit those fragments at every point a spread is encountered. - -### `specifiedRules` - -```ts -let specifiedRules: Array<(context: ValidationContext) => any>; -``` - -This set includes all validation rules defined by the GraphQL spec diff --git a/website/pages/docs/_meta.ts b/website/pages/docs/_meta.ts deleted file mode 100644 index 2e6156976b..0000000000 --- a/website/pages/docs/_meta.ts +++ /dev/null @@ -1,48 +0,0 @@ -const meta = { - index: '', - '-- 1': { - type: 'separator', - title: 'Getting Started', - }, - 'getting-started': '', - 'running-an-express-graphql-server': '', - 'graphql-clients': '', - 'authentication-and-express-middleware': '', - '-- 2': { - type: 'separator', - title: 'Core Concepts', - }, - 'basic-types': '', - 'passing-arguments': '', - 'object-types': '', - 'mutations-and-input-types': '', - nullability: '', - 'abstract-types': '', - 'custom-scalars': '', - '-- 3': { - type: 'separator', - title: 'Advanced Guides', - }, - 'constructing-types': '', - 'oneof-input-objects': '', - 'defer-stream': '', - subscriptions: '', - 'type-generation': '', - 'cursor-based-pagination': '', - 'advanced-custom-scalars': '', - 'operation-complexity-controls': '', - 'n1-dataloader': '', - 'caching-strategies': '', - 'resolver-anatomy': '', - 'graphql-errors': '', - 'using-directives': '', - 'authorization-strategies': '', - '-- 4': { - type: 'separator', - title: 'Production & Scaling', - }, - 'going-to-production': '', - 'scaling-graphql': '', -}; - -export default meta; diff --git a/website/pages/docs/abstract-types.mdx b/website/pages/docs/abstract-types.mdx deleted file mode 100644 index 1762f9bb53..0000000000 --- a/website/pages/docs/abstract-types.mdx +++ /dev/null @@ -1,214 +0,0 @@ ---- -title: Abstract types in GraphQL.js ---- - -# Abstract types in GraphQL.js - -GraphQL includes two kinds of abstract types: interfaces and unions. These types let a single -field return values of different object types, while keeping your schema type-safe. - -This guide covers how to define and resolve abstract types using GraphQL.js. It focuses on -constructing types in JavaScript using the GraphQL.js type system, not the schema definition -language (SDL). - -## What are abstract types? - -Most GraphQL types are concrete. They represent a specific kind of object, for example, a -`Book` or an `Author`. Abstract types let a field return different types of objects depending -on the data. - -This is useful when the return type can vary but comes from a known set. For example, a `search` -field might return a book, an author, or a publisher. Abstract types let you model this kind of -flexibility while preserving validation, introspection, and tool support. - -GraphQL provides two kinds of abstract types: - -- Interfaces define a set of fields that multiple object types must implement. - - Use case: A `ContentItem` interface with fields like `id`, `title`, and `publishedAt`, - implemented by types such as `Article` and `PodcastEpisode`. -- Unions group together unrelated types that don't share any fields. - - Use case: A `SearchResult` union that includes `Book`, `Author`, and `Publisher` types. - -## Defining interfaces - -To define an interface in GraphQL.js, use the `GraphQLInterfaceType` constructor. An interface -must include a `name`, definition of the shared `fields`, and should include a `resolveType` -function telling GraphQL which concrete type a given value corresponds to. - -The following example defines a `ContentItem` interface for a publishing platform: - -```js filename="ContentItemInterface.js" -import { GraphQLInterfaceType, GraphQLString, GraphQLNonNull } from 'graphql'; - -const ContentItemInterface = new GraphQLInterfaceType({ - name: 'ContentItem', - fields: { - id: { type: new GraphQLNonNull(GraphQLString) }, - title: { type: GraphQLString }, - publishedAt: { type: GraphQLString }, - }, - resolveType(value) { - if (value.audioUrl) { - return 'PodcastEpisode'; - } - if (value.bodyText) { - return 'Article'; - } - return null; - }, -}); - -exports.ContentItemInterface = ContentItemInterface; -``` - -The `resolveType` function must return either the string type name corresponding -to the `GraphQLObjectType` of the given `value`, or `null` if the type could not -be determined. - -## Implementing interfaces with object types - -To implement an interface, define a `GraphQLObjectType` and include the interface in its -`interfaces` array. The object type must implement all fields defined by the interface. - -The following example implements the `Article` and `PodcastEpisode` types that -conform to the `ContentItem` interface: - -```js -import { GraphQLObjectType, GraphQLString, GraphQLNonNull } from 'graphql'; -import { ContentItemInterface } from './ContentItemInterface.js'; - -const ArticleType = new GraphQLObjectType({ - name: 'Article', - interfaces: [ContentItemInterface], - fields: { - id: { type: new GraphQLNonNull(GraphQLString) }, - title: { type: GraphQLString }, - publishedAt: { type: GraphQLString }, - bodyText: { type: GraphQLString }, - }, - isTypeOf: (value) => value.bodyText !== undefined, -}); - -const PodcastEpisodeType = new GraphQLObjectType({ - name: 'PodcastEpisode', - interfaces: [ContentItemInterface], - fields: { - id: { type: new GraphQLNonNull(GraphQLString) }, - title: { type: GraphQLString }, - publishedAt: { type: GraphQLString }, - audioUrl: { type: GraphQLString }, - }, - isTypeOf: (value) => value.audioUrl !== undefined, -}); -``` - -The `isTypeOf` function is optional. It provides a fallback when `resolveType` isn't defined, or -when runtime values could match multiple types. If both `resolveType` and `isTypeOf` are defined, -GraphQL uses `resolveType`. - -## Defining union types - -Use the `GraphQLUnionType` constructor to define a union. A union allows a field to return one -of several object types that don't need to share fields. - -A union requires a name and a list of object types (`types`). It should also be -provided a `resolveType` function the same as explained for interfaces above. - -The following example defines a `SearchResult` union: - -```js -import { GraphQLUnionType } from 'graphql'; - -const SearchResultType = new GraphQLUnionType({ - name: 'SearchResult', - types: [BookType, AuthorType, PublisherType], - resolveType(value) { - if (value.isbn) { - return 'Book'; - } - if (value.bio) { - return 'Author'; - } - if (value.catalogSize) { - return 'Publisher'; - } - return null; - }, -}); -``` - -Unlike interfaces, unions don't declare any fields their members must implement. -Clients use a fragment with a type condition to query fields from a concrete type. - -## Resolving abstract types at runtime - -GraphQL resolves abstract types dynamically during execution using the `resolveType` function, if -present. - -This function receives the following arguments: - -{/* prettier-ignore */} -```js -resolveType(value, context, info) -``` - -It can return: - -- The name of a type as a string -- `null` if the type could not be determined -- A `Promise` resolving to either of the above - -If `resolveType` isn't defined, GraphQL falls back to checking each possible type's `isTypeOf` -function. This fallback is less efficient and makes type resolution harder to debug. For most cases, -explicitly defining `resolveType` is recommended. - -## Querying abstract types - -To query a field that returns an abstract type, use fragments to select fields from the possible -concrete types. GraphQL evaluates each fragment based on the runtime type of the result. - -For example: - -```graphql -query Search($term: String! = "deep learning") { - search(term: $term) { - # Inline fragments with type condition: - ... on Book { - title - isbn - } - ... on Author { - name - bio - } - # Named fragment: - ...publisherFrag - } -} - -fragment publisherFrag on Publisher { - name - catalogSize -} -``` - -GraphQL's introspection system lists all possible types for each interface and union, which -enables code generation and editor tooling to provide type-aware completions; however you should -keep in mind the possibility that more types will implement the interface or be included in the -union in future, and thus ensure that you have a default case to handle additional types. - -## Best practices - -- Always implement `resolveType` for interfaces and unions to handle runtime type resolution. -- Keep `resolveType` logic simple, using consistent field shapes or tags to distinguish - types. -- Test `resolveType` logic carefully. Errors in `resolveType` can cause runtime errors that can - be hard to trace. -- Use interfaces when types share fields and unions when types are structurally unrelated. - -## Additional resources - -- [Constructing Types](./constructing-types) -- GraphQL Specification: - - [Interfaces](https://spec.graphql.org/October2021/#sec-Interfaces) - - [Unions](https://spec.graphql.org/October2021/#sec-Unions) diff --git a/website/pages/docs/advanced-custom-scalars.mdx b/website/pages/docs/advanced-custom-scalars.mdx deleted file mode 100644 index b71aa450fc..0000000000 --- a/website/pages/docs/advanced-custom-scalars.mdx +++ /dev/null @@ -1,223 +0,0 @@ ---- -title: Best Practices for Custom Scalars ---- - -# Custom Scalars: Best Practices and Testing - -Custom scalars must behave predictably and clearly. To maintain a consistent, reliable -schema, follow these best practices. - -### Document expected formats and validation - -Provide a clear description of the scalar's accepted input and output formats. For example, a -`DateTime` scalar should explain that it expects [ISO-8601](https://www.iso.org/iso-8601-date-and-time-format.html) strings ending with `Z`. - -Clear descriptions help clients understand valid input and reduce mistakes. - -### Validate consistently across `parseValue` and `parseLiteral` - -Clients can send values either through variables or inline literals. -Your `parseValue` and `parseLiteral` functions should apply the same validation logic in -both cases. - -Use a shared helper to avoid duplication: - -```js -function parseDate(value) { - const date = new Date(value); - if (isNaN(date.getTime())) { - throw new TypeError(`DateTime cannot represent an invalid date: ${value}`); - } - return date; -} -``` - -Both `parseValue` and `parseLiteral` should call this function. - -### Return clear errors - -When validation fails, throw descriptive errors. Avoid generic messages like "Invalid input." -Instead, use targeted messages that explain the problem, such as: - -```text -DateTime cannot represent an invalid date: `abc123` -``` - -Clear error messages speed up debugging and make mistakes easier to fix. - -### Serialize consistently - -Always serialize internal values into a predictable format. -For example, a `DateTime` scalar should always produce an ISO string, even if its -internal value is a `Date` object. - -```js -serialize(value) { - if (!(value instanceof Date)) { - throw new TypeError('DateTime can only serialize Date instances'); - } - return value.toISOString(); -} -``` - -Serialization consistency prevents surprises on the client side. - -## Testing custom scalars - -Testing ensures your custom scalars work reliably with both valid and invalid inputs. -Tests should cover three areas: coercion functions, schema integration, and error handling. - -### Unit test serialization and parsing - -Write unit tests for each function: `serialize`, `parseValue`, and `parseLiteral`. -Test with both valid and invalid inputs. - -```js -describe('DateTime scalar', () => { - it('serializes Date instances to ISO strings', () => { - const date = new Date('2024-01-01T00:00:00Z'); - expect(DateTime.serialize(date)).toBe('2024-01-01T00:00:00.000Z'); - }); - - it('throws if serializing a non-Date value', () => { - expect(() => DateTime.serialize('not a date')).toThrow(TypeError); - }); - - it('parses ISO strings into Date instances', () => { - const result = DateTime.parseValue('2024-01-01T00:00:00Z'); - expect(result).toBeInstanceOf(Date); - expect(result.toISOString()).toBe('2024-01-01T00:00:00.000Z'); - }); - - it('throws if parsing an invalid date string', () => { - expect(() => DateTime.parseValue('invalid-date')).toThrow(TypeError); - }); -}); -``` - -### Test custom scalars in a schema - -Integrate the scalar into a schema and run real GraphQL queries to validate end-to-end behavior. - -```js -import { graphql, GraphQLSchema, GraphQLObjectType } from 'graphql'; -import { DateTimeResolver as DateTime } from 'graphql-scalars'; - -const Query = new GraphQLObjectType({ - name: 'Query', - fields: { - now: { - type: DateTime, - resolve() { - return new Date(); - }, - }, - }, -}); - -/* - scalar DateTime - - type Query { - now: DateTime - } -*/ -const schema = new GraphQLSchema({ - query: Query, -}); - -async function testQuery() { - const response = await graphql({ - schema, - source: '{ now }', - }); - console.log(response); -} - -testQuery(); -``` - -Schema-level tests verify that the scalar behaves correctly during execution, not just -in isolation. - -## Common use cases for custom scalars - -Custom scalars solve real-world needs by handling types that built-in scalars don't cover. - -- `DateTime`: Serializes and parses ISO-8601 date-time strings. -- `Email`: Validates syntactically correct email addresses. - -```js -function validateEmail(value) { - const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; - if (!emailRegex.test(value)) { - throw new TypeError(`Email cannot represent invalid email address: ${value}`); - } - return value; -} -``` - -- `URL`: Ensures well-formatted, absolute URLs. - -```js -function validateURL(value) { - try { - new URL(value); - return value; - } catch { - throw new TypeError(`URL cannot represent an invalid URL: ${value}`); - } -} -``` - -- `JSON`: Represents arbitrary JSON structures, but use carefully because it bypasses -GraphQL's strict type checking. - -## When to use existing libraries - -Writing scalars is deceptively tricky. Validation edge cases can lead to subtle bugs if -not handled carefully. - -Whenever possible, use trusted libraries like [`graphql-scalars`](https://www.npmjs.com/package/graphql-scalars). They offer production-ready -scalars for DateTime, EmailAddress, URL, UUID, and many others. - -### Example: Handling email validation - -Handling email validation correctly requires dealing with Unicode, quoted local parts, and -domain validation. Rather than writing your own regex, it's better to use a library scalar -that's already validated against standards. - -If you need domain-specific behavior, you can wrap an existing scalar with custom rules: - -```js -import { EmailAddressResolver } from 'graphql-scalars'; - -const StrictEmailAddress = new GraphQLScalarType({ - ...EmailAddressResolver, - name: 'StrictEmailAddress', - parseValue(value) { - const email = EmailAddressResolver.parseValue(value); - if (!email.endsWith('@example.com')) { - throw new TypeError('Only example.com emails are allowed.'); - } - return email; - }, - parseLiteral(literal, variables) { - const email = EmailAddressResolver.parseLiteral(literal, variables); - if (!email.endsWith('@example.com')) { - throw new TypeError('Only example.com emails are allowed.'); - } - return email; - }, -}); -``` - -By following these best practices and using trusted tools where needed, you can build custom -scalars that are reliable, maintainable, and easy for clients to work with. - -## Additional resources - -- [GraphQL Scalars by The Guild](https://the-guild.dev/graphql/scalars): A production-ready -library of common custom scalars. -- [GraphQL Scalars Specification](https://github.com/graphql/graphql-scalars): This -specification is no longer actively maintained, but useful for historical context. diff --git a/website/pages/docs/authentication-and-express-middleware.mdx b/website/pages/docs/authentication-and-express-middleware.mdx deleted file mode 100644 index a633168f52..0000000000 --- a/website/pages/docs/authentication-and-express-middleware.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: Using Express Middleware with GraphQL.js -sidebarTitle: Using Express Middleware ---- - -# Authentication and Express Middleware - -import { Tabs } from 'nextra/components'; - -It's simple to use any Express middleware in conjunction with `graphql-http`. In particular, this is a great pattern for handling authentication. - -To use middleware with a GraphQL resolver, just use the middleware like you would with a normal Express app. The `request` object is then available as the second argument in any resolver. - -For example, let's say we wanted our server to log the IP address of every request, and we also want to write an API that returns the IP address of the caller. We can do the former with middleware, and the latter by accessing the `request` object in a resolver. Here's server code that implements this: - - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { buildSchema } from 'graphql'; - -const schema = buildSchema(`type Query { ip: String }`); - -function loggingMiddleware(req, res, next) { - console.log('ip:', req.ip); - next(); -} - -const root = { - ip(args, context) { - return context.ip; - }, -}; - -const app = express(); -app.use(loggingMiddleware); -app.all( - '/graphql', - createHandler({ - schema: schema, - rootValue: root, - context: (req) => ({ - ip: req.raw.ip, - }), - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); - -``` - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { - GraphQLObjectType, - GraphQLSchema, - GraphQLString, -} from 'graphql'; - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - ip: { - type: GraphQLString, - resolve: (_, args, context) => { - return context.ip; - } - } - }, - }), -}); - -function loggingMiddleware(req, res, next) { - console.log('ip:', req.ip); - next(); -} - -const app = express(); -app.use(loggingMiddleware); -app.all( - '/graphql', - createHandler({ - schema: schema, - context: (req) => ({ - ip: req.raw.ip, - }), - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); - -``` - - - -In a REST API, authentication is often handled with a header, that contains an auth token which proves what user is making this request. Express middleware processes these headers and puts authentication data on the Express `request` object. Some middleware modules that handle authentication like this are [Passport](http://passportjs.org/), [express-jwt](https://github.com/auth0/express-jwt), and [express-session](https://github.com/expressjs/session). Each of these modules works with `graphql-http`. - -If you aren't familiar with any of these authentication mechanisms, we recommend using `express-jwt` because it's simple without sacrificing any future flexibility. - -If you've read through the docs linearly to get to this point, congratulations! You now know everything you need to build a practical GraphQL API server. - -Want to control access to specific operations or fields? See [Authorization Strategies](./authorization-strategies). \ No newline at end of file diff --git a/website/pages/docs/authorization-strategies.mdx b/website/pages/docs/authorization-strategies.mdx deleted file mode 100644 index d43e19f123..0000000000 --- a/website/pages/docs/authorization-strategies.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -title: Authorization Strategies ---- - -import { Callout } from 'nextra/components' - -GraphQL gives you complete control over how to define and enforce access control. -That flexibility means it's up to you to decide where authorization rules live and -how they're enforced. - -This guide covers common strategies for implementing authorization in GraphQL -servers using GraphQL.js. It assumes you're authenticating requests and passing a user or -session object into the `context`. - - - In production systems authorization should be handled in your business logic layer, not your - GraphQL resolvers. GraphQL is intended to be a thin execution layer that calls into your application's - domain logic, which enforces access control. - - -## What is authorization? - -Authorization determines what a user is allowed to do. It's different from -authentication, which verifies who a user is. - -In GraphQL, authorization typically involves restricting: - -- Access to certain queries or mutations -- Visibility of specific fields -- Ability to perform mutations based on roles or ownership - -## Resolver-based authorization - -You can implement simple authorization checks directly in resolvers using `context.user`: - -```js -export const resolvers = { - Query: { - secretData: (parent, args, context) => { - if (!context.user || context.user.role !== 'admin') { - throw new Error('Not authorized'); - } - return getSecretData(); - }, - }, -}; -``` - -This approach can help when you're learning how context works or building quick prototypes. -However, for production systems, you should enforce access control in your business logic layer -rather than in GraphQL resolvers. - -## Centralizing access control logic - -If you're experimenting or building a small project, repeating checks like -`context.user.role !== 'admin'` across resolvers can become error-prone. One -way to manage that duplication is by extracting shared logic into utility functions: - -```js -export function requireUser(user) { - if (!user) { - throw new Error('Not authenticated'); - } -} - -export function requireRole(user, role) { - requireUser(user); - if (user.role !== role) { - throw new Error(`Must be a ${role}`); - } -} -``` - -Then use those helpers in resolvers: - -```js -import { requireRole } from './auth.js'; - -export const resolvers = { - Mutation: { - deleteUser: (parent, args, context) => { - requireRole(context.user, 'admin'); - return deleteUser(args.id); - }, - }, -}; -``` - -This pattern improves readability and reusability, but like all resolver-based authorization, -it's best suited for prototypes or early-stage development. - -For production use, move authorization into your business logic layer. These helpers can still be useful -there, but they should be applied outside the GraphQL execution layer. - -## Field-level access control - -You can also conditionally return or hide data at the field level. This -is useful when, for example, users should only see their own private data: - -```js -export const resolvers = { - User: { - email: (parent, args, context) => { - if (context.user.id !== parent.id && context.user.role !== 'admin') { - return null; - } - return parent.email; - }, - }, -}; -``` - -Returning `null` is a common pattern when fields should be hidden from -unauthorized users without triggering an error. - -## Declarative authorization with directives - -If you prefer a schema-first or declarative style, you can define custom -schema directives like `@auth(role: "admin")` directly in your SDL: - -```graphql -type Query { - users: [User] @auth(role: "admin") -} -``` - -To enforce this directive during execution, you need to inspect it in your resolvers -using `getDirectiveValues`: - -```js -import { getDirectiveValues } from 'graphql'; - -function withAuthCheck(resolverFn, schema, fieldNode, variableValues, context) { - const directive = getDirectiveValues( - schema.getDirective('auth'), - fieldNode, - variableValues - ); - - if (directive?.role && context.user?.role !== directive.role) { - throw new Error('Unauthorized'); - } - - return resolverFn(); -} -``` - -You can wrap individual resolvers with this logic, or apply it more broadly using a -schema visitor or transformation. - -GraphQL.js doesn't interpret directives by default, they're just annotations. -You must implement their behavior manually, usually by: - -- Wrapping resolvers in custom logic -- Using a schema transformation library to inject authorization checks - -Directive-based authorization can add complexity, so many teams start with -resolver-based checks and adopt directives later if needed. - -## Best practices - -- Keep authorization logic in your business logic layer, not in your GraphQL resolvers. -- Use shared helper functions to reduce duplication and improve clarity. -- Avoid tightly coupling authorization logic to your schema. Make it -reusable where possible. -- Consider using `null` to hide fields from unauthorized users, rather than -throwing errors. -- Be mindful of tools like introspection or GraphQL Playground that can -expose your schema. Use caution when deploying introspection in production -environments. - -## Additional resources - -- [Anatomy of a Resolver](./resolver-anatomy): Shows how resolvers work and how the `context` -object is passed in. Helpful if you're new to writing custom resolvers or -want to understand where authorization logic fits. -- [GraphQL Specification, Execution section](https://spec.graphql.org/October2021/#sec-Execution): Defines how fields are -resolved, including field-level error propagation and execution order. Useful -background when building advanced authorization patterns that rely on the -structure of GraphQL execution. -- [`graphql-shield`](https://github.com/dimatill/graphql-shield): A community library for adding rule-based -authorization as middleware to resolvers. -- [`graphql-auth-directives`](https://github.com/the-guild-org/graphql-auth-directives): Adds support for custom directives like -`@auth(role: "admin")`, letting you declare access control rules in SDL. -Helpful if you're building a schema-first API and prefer declarative access -control. - - diff --git a/website/pages/docs/basic-types.mdx b/website/pages/docs/basic-types.mdx deleted file mode 100644 index 4913b5a11e..0000000000 --- a/website/pages/docs/basic-types.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: Basic Types ---- - -# Basic Types - -import { Tabs } from 'nextra/components'; - -In most situations, all you need to do is to specify the types for your API using the GraphQL schema language, taken as an argument to the `buildSchema` function. - -The GraphQL schema language supports the scalar types of `String`, `Int`, `Float`, `Boolean`, and `ID`, so you can use these directly in the schema you pass to `buildSchema`. - -By default, every type is nullable - it's legitimate to return `null` as any of the scalar types. Use an exclamation point to indicate a type cannot be nullable, so `String!` is a non-nullable string. - -To use a list type, surround the type in square brackets, so `[Int]` is a list of integers. - -Each of these types maps straightforwardly to JavaScript, so you can just return plain old JavaScript objects in APIs that return these types. Here's an example that shows how to use some of these basic types: - - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { buildSchema } from 'graphql'; - -// Construct a schema, using GraphQL schema language -const schema = buildSchema(` - type Query { - quoteOfTheDay: String - random: Float! - rollThreeDice: [Int] - } -`); - -// The root provides a resolver function for each API endpoint -const root = { - quoteOfTheDay() { - return Math.random() < 0.5 ? 'Take it easy' : 'Salvation lies within'; - }, - random() { - return Math.random(); - }, - rollThreeDice() { - return [1, 2, 3].map((_) => 1 + Math.floor(Math.random() * 6)); - }, -}; - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - rootValue: root, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); - -``` - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { - GraphQLObjectType, - GraphQLSchema, - GraphQLString, - GraphQLFloat, - GraphQLList, -} from 'graphql'; - -// Construct a schema -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - quoteOfTheDay: { - type: GraphQLString, - resolve: () => Math.random() < 0.5 ? 'Take it easy' : 'Salvation lies within' - }, - random: { - type: GraphQLFloat, - resolve: () => Math.random() - }, - rollThreeDice: { - type: new GraphQLList(GraphQLFloat), - resolve: () => [1, 2, 3].map((_) => 1 + Math.floor(Math.random() * 6)) - }, - }, - }), -}); - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - }), -); - -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); - -``` - - - -If you run this code with `node server.js` and browse to http://localhost:4000/graphql you can try out these APIs. - -These examples show you how to call APIs that return different types. To send different types of data into an API, you will also need to learn about [passing arguments to a GraphQL API](./passing-arguments). diff --git a/website/pages/docs/caching-strategies.mdx b/website/pages/docs/caching-strategies.mdx deleted file mode 100644 index b33cdb4d6e..0000000000 --- a/website/pages/docs/caching-strategies.mdx +++ /dev/null @@ -1,298 +0,0 @@ ---- -title: Caching Strategies ---- - -# Caching Strategies - -Caching is a core strategy for improving the performance and scalability of GraphQL -servers. Because GraphQL allows clients to specify exactly what they need, the server often -does more work per request (but fewer requests) compared to many other APIs. - -This guide explores different levels of caching in a GraphQL.js so you can apply the right -strategy for your application. - -## Why caching matters - -GraphQL servers commonly face performance bottlenecks due to repeated fetching of the -same data, costly resolver logic, or expensive database queries. Since GraphQL shifts -much of the composition responsibility to the server, caching becomes essential for maintaining -fast response times and managing backend load. - -## Caching levels - -There are several opportunities to apply caching within a GraphQL server: - -- **Resolver-level caching**: Cache the result of specific fields. -- **Request-level caching**: Batch and cache repeated access to backend resources -within a single operation. -- **Operation result caching**: Reuse the entire response for repeated identical queries. -- **Schema caching**: Cache the compiled schema when startup cost is high. -- **Transport/middleware caching**: Leverage caching behavior in HTTP servers or proxies. - -Understanding where caching fits in your application flow helps you apply it strategically -without overcomplicating your system. - -## Resolver-level caching - -Resolver-level caching is useful when a specific field’s value is expensive to compute and -commonly requested with the same arguments. Instead of recomputing or refetching the data on -every request, you can store the result temporarily in memory and return it directly when the -same input appears again. - -### Use cases - -- Fields backed by slow or rate-limited APIs -- Fields that require complex computation -- Data that doesn't change frequently - -For example, consider a field that returns information about a product: - -```js -// utils/cache.js -import LRU from 'lru-cache'; - -export const productCache = new LRU({ max: 1000, ttl: 1000 * 60 }); // 1 min TTL -``` - -The next example shows how to use that cache inside a resolver to avoid repeated database -lookups: - -```js -// resolvers/product.js -import { productCache } from '../utils/cache.js'; - -export const resolvers = { - Query: { - product(_, { id }, context) { - const cached = productCache.get(id); - if (cached) return cached; - - const productPromise = context.db.products.findById(id); - productCache.set(id, productPromise); - return productPromise; - }, - }, -}; -``` - -This example uses [`lru-cache`](https://www.npmjs.com/package/lru-cache), which limits the -number of stored items and support TTL-based expiration. You can replace it with Redis or -another cache if you need cross-process consistency. - -### Guidelines - -- Resolver-level caches are global. Be careful with authorization-sensitive data. -- This technique works best for data that doesn't change often or can tolerate short-lived -staleness. -- TTL should match how often the underlying data is expected to change. - -## Request-level caching with DataLoader - -[DataLoader](https://github.com/graphql/dataloader) is a utility for batching and caching -backend access during a single GraphQL operation. It's designed to solve the N+1 problem, -where the same resource is fetched repeatedly in a single query across multiple fields. - -### Use cases - -- Resolving nested relationships -- Avoiding duplicate database or API calls -- Scoping caching to a single request, without persisting globally - -The following example defines a DataLoader instance that batches user lookups by ID: - -```js -// loaders/userLoader.js -import DataLoader from 'dataloader'; -import { batchGetUsers } from '../services/users.js'; - -export const createUserLoader = () => new DataLoader(ids => batchGetUsers(ids)); -``` - -You can then include the loader in the per-request context to isolate it from other -operations: - -```js -// context.js -import { createUserLoader } from './loaders/userLoader.js'; - -export function createContext() { - return { - userLoader: createUserLoader(), - }; -} -``` - -Finally, use the loader in your resolvers to batch-fetch users efficiently: - -```js -// resolvers/user.js -export const resolvers = { - Query: { - async users(_, __, context) { - return context.userLoader.loadMany([1, 2, 3]); - }, - }, -}; -``` - -### Guidelines - -- The cache is scoped to the request. Each request gets a fresh loader instance. -- This strategy works best for resolving repeated references to the same resource type. -- This isn't a long-lived cache. Combine it with other layers for broader coverage. - -To read more about DataLoader and the N+1 problem, -see [Solving the N+1 Problem with DataLoader](./n1-dataloader). - -## Operation result caching - -Operation result caching stores the complete response of a query, keyed by the query string, variables, and potentially -HTTP headers. It can dramatically improve performance when the same query is sent frequently, particularly for read-heavy -applications. - -### Use cases - -- Public data or anonymous content -- Expensive queries that return stable results -- Scenarios where the same query is sent frequently - -The following example defines two functions to interact with a Redis cache, -storing and retrieving cached results: - -```js -// cache/queryCache.js -import Redis from 'ioredis'; -const redis = new Redis(); - -export async function getCachedResponse(cacheKey) { - const cached = await redis.get(cacheKey); - return cached ? JSON.parse(cached) : null; -} - -export async function cacheResponse(cacheKey, result, ttl = 60) { - await redis.set(cacheKey, JSON.stringify(result), 'EX', ttl); -} -``` - -The next example shows how to wrap your execution logic to check the cache first and store results -afterward: - -```js -// graphql/executeWithCache.js -import { getCachedResponse, cacheResponse } from '../cache/queryCache.js'; - -/** - * Stores in-flight requests to executeWithCache such that concurrent - * requests with the same cacheKey will only result in one call to - * `getCachedResponse` / `cacheResponse`. Once a request completes - * (with or without error) it is removed from the map. - */ -const inflight = new Map(); - -export function executeWithCache({ cacheKey, executeFn }) { - const existing = inflight.get(cacheKey); - if (existing) return existing; - - const promise = _executeWithCacheUnbatched({ cacheKey, executeFn }); - inflight.set(cacheKey, promise); - return promise.finally(() => inflight.delete(cacheKey)); -} - -async function _executeWithCacheUnbatched({ cacheKey, executeFn }) { - const cached = await getCachedResponse(cacheKey); - if (cached) return cached; - - const result = await executeFn(); - await cacheResponse(cacheKey, result); - return result; -} -``` - -### Guidelines - -- Don't cache personalized or auth-sensitive data unless you scope the cache per user or token. -- Invalidation is nontrivial. Consider TTLs, cache versioning, or event-driven purging. - -## Schema caching - -Schema caching is useful when your schema construction is expensive, for example, when -you are dynamically generating types, you are stitching multiple schemas, or fetching -remote GraphQL services. This is especially important in serverless environments, -where cold starts can significantly impact performance. - -### Use cases - -- Serverless functions that rebuild the schema on each invocation -- Applications that use schema stitching or remote schema delegation -- Environments where schema generation takes noticeable time on startup - -The following example shows how to cache a schema in memory after the first build: - -```js -import { buildSchema } from 'graphql'; - -let cachedSchema; - -export function getSchema() { - if (!cachedSchema) { - cachedSchema = buildSchema(schemaSDLString); // or makeExecutableSchema() - } - return cachedSchema; -} -``` - -## Cache invalidation - -No caching strategy is complete without an invalidation plan. Cached data can -become stale or incorrect, and serving outdated information can lead to bugs or a -degraded user experience. - -The following are common invalidation techniques: - -- **TTL (time-to-live)**: Automatically expire cached items after a time window -- **Manual purging**: Remove or refresh cache entries when related data is updated -- **Key versioning**: Encode version or timestamp metadata into cache keys -- **Stale-while-revalidate**: Serve stale data while refreshing it in the background - -Design your invalidation strategy based on your data’s volatility and your clients’ -tolerance for staleness. - -## Third-party and edge caching - -While GraphQL.js does not include built-in support for third-party or edge caching, it integrates -well with external tools and middleware that handle full response caching or caching by query -signature. - -### Use cases - -- Serving public, cacheable content to unauthenticated users -- Deploying behind a CDN or reverse proxy -- Using a gateway service that supports persistent response caching - -The following tools and layers are commonly used: - -- Redis or Memcached for in-memory and cross-process caching -- CDN-level caching for static, cache-friendly GraphQL queries -- API gateways - -### Guidelines - -- Partition cache entries for personalized data using auth tokens or headers -- Monitor cache hit/miss ratios to identify tuning opportunities -- Consider varying cache strategy per query or operation type - -## Client-side caching - -GraphQL clients include sophisticated client-side caches that store -normalized query results and reuse them across views or components. While this is out of scope for GraphQL.js -itself, server-side caching should be designed with client behavior in mind. - -### When to consider it in server design - -- You want to avoid redundant server work for cold-started clients -- You need consistency between server and client freshness guarantees -- You're coordinating with clients that rely on local cache behavior - -Server-side and client-side caches should align on freshness guarantees and invalidation -behavior. If the client doesn't re-fetch automatically, server-side staleness -may be invisible but impactful. diff --git a/website/pages/docs/constructing-types.mdx b/website/pages/docs/constructing-types.mdx deleted file mode 100644 index 2744ab7c81..0000000000 --- a/website/pages/docs/constructing-types.mdx +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: Constructing Types ---- - -# Constructing Types - -import { Tabs } from 'nextra/components'; - -For many apps, you can define a fixed schema when the application starts, and define it using GraphQL schema language. In some cases, it's useful to construct a schema programmatically. You can do this using the `GraphQLSchema` constructor. - -When you are using the `GraphQLSchema` constructor to create a schema, instead of defining `Query` and `Mutation` types solely using schema language, you create them as separate object types. - -For example, let's say we are building a simple API that lets you fetch user data for a few hardcoded users based on an id. Using `buildSchema` we could write a server with: - - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { buildSchema } from 'graphql'; - -const schema = buildSchema(` -type User { - id: String - name: String -} - -type Query { - user(id: String): User -} -`); - -// Maps id to User object -const fakeDatabase = { - a: { - id: 'a', - name: 'alice', - }, - b: { - id: 'b', - name: 'bob', - }, -}; - -const root = { - user({ id }) { - return fakeDatabase[id]; - }, -}; - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - rootValue: root, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); - -```` - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import * as graphql from 'graphql'; - -// Maps id to User object -const fakeDatabase = { - a: { - id: 'a', - name: 'alice', - }, - b: { - id: 'b', - name: 'bob', - }, -}; - -// Define the User type -const userType = new graphql.GraphQLObjectType({ - name: 'User', - fields: { - id: { type: graphql.GraphQLString }, - name: { type: graphql.GraphQLString }, - }, -}); - -// Define the Query type with inline resolver -const queryType = new graphql.GraphQLObjectType({ - name: 'Query', - fields: { - user: { - type: userType, - // `args` describes the arguments that the `user` query accepts - args: { - id: { type: graphql.GraphQLString }, - }, - resolve: (_, { id }) => { - return fakeDatabase[id]; - }, - }, - }, -}); - -const schema = new graphql.GraphQLSchema({ query: queryType }); - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); -```` - - - - -When we use the `GraphQLSchema` constructor method of creating the API, the root level resolvers are implemented on the `Query` and `Mutation` types rather than on a `root` object. - -This can be particularly useful if you want to create a GraphQL schema automatically from something else, like a database schema. You might have a common format for something like creating and updating database records. This is also useful for implementing features like union types which don't map cleanly to ES6 classes and schema language. diff --git a/website/pages/docs/cursor-based-pagination.mdx b/website/pages/docs/cursor-based-pagination.mdx deleted file mode 100644 index 93eefdd98a..0000000000 --- a/website/pages/docs/cursor-based-pagination.mdx +++ /dev/null @@ -1,326 +0,0 @@ ---- -title: Implementing Cursor-based Pagination ---- - -import { Callout } from "nextra/components"; - -# Implementing Cursor-based Pagination - -When a GraphQL API returns a list of data, pagination helps avoid -fetching too much data at once. Cursor-based pagination fetches items -relative to a specific point in the list, rather than using numeric offsets. -This pattern works well with dynamic datasets, where users frequently add or -remove items between requests. - -GraphQL.js doesn't include cursor pagination out of the box, but you can implement -it using custom types and resolvers. This guide shows how to build a paginated field -using the connection pattern popularized by [Relay](https://relay.dev). By the end of this -guide, you will be able to define cursors and return results in a consistent structure -that works well with clients. - -## The connection pattern - -Cursor-based pagination typically uses a structured format that separates -pagination metadata from the actual data. The most widely adopted pattern follows the -[GraphQL Cursor Connections Specification](https://relay.dev/graphql/connections.htm). While -this format originated in Relay, many GraphQL APIs use it independently because of its -clarity and flexibility. - -This pattern wraps your list of items in a connection type, which includes the following fields: - -- `edges`: A list of edge objects, representing for each item in the list: - - `node`: The actual object you want to retrieve, such as user, post, or comment. - - `cursor`: An opaque string that identifies the position of the item in the list. -- `pageInfo`: Metadata about the list, such as whether more items are available. - -The following query and response show how this structure works: - -```graphql -query { - users(first: 2) { - edges { - node { - id - name - } - cursor - } - pageInfo { - hasNextPage - endCursor - } - } -} -``` - -```json -{ - "data": { - "users": { - "edges": [ - { - "node": { - "id": "1", - "name": "Ada Lovelace" - }, - "cursor": "cursor-1" - }, - { - "node": { - "id": "2", - "name": "Alan Turing" - }, - "cursor": "cursor-2" - } - ], - "pageInfo": { - "hasNextPage": true, - "endCursor": "cursor-2" - } - } - } -} -``` - -This structure gives clients everything they need to paginate. It provides the actual data (`node`), -the cursor to continue from (`endCursor`), and a flag (`hasNextPage`) that indicates whether -more data is available. - -## Defining connection types in GraphQL.js - -To support this structure in your schema, define a few custom types: - -```js -const PageInfoType = new GraphQLObjectType({ - name: 'PageInfo', - fields: { - hasNextPage: { type: new GraphQLNonNull(GraphQLBoolean) }, - hasPreviousPage: { type: new GraphQLNonNull(GraphQLBoolean) }, - startCursor: { type: GraphQLString }, - endCursor: { type: GraphQLString }, - }, -}); -``` - -The `PageInfo` type provides metadata about the current page of results. -The `hasNextPage` and `hasPreviousPage` fields indicate whether more -results are available in either direction. The `startCursor` and `endCursor` -fields help clients resume pagination from a specific point. - -Next, define an edge type to represent individual items in the connection: - -```js -const UserEdgeType = new GraphQLObjectType({ - name: 'UserEdge', - fields: { - node: { type: UserType }, - cursor: { type: new GraphQLNonNull(GraphQLString) }, - }, -}); -``` - -Each edge includes a `node` and a `cursor`, which marks its position in -the list. - -Then, define the connection type itself: - -```js -const UserConnectionType = new GraphQLObjectType({ - name: 'UserConnection', - fields: { - edges: { - type: new GraphQLNonNull( - new GraphQLList(new GraphQLNonNull(UserEdgeType)) - ), - }, - pageInfo: { type: new GraphQLNonNull(PageInfoType) }, - }, -}); -``` - -The connection type wraps a list of edges and includes the pagination -metadata. - -Paginated fields typically accept the following arguments: - -```js -const connectionArgs = { - first: { type: GraphQLInt }, - after: { type: GraphQLString }, - last: { type: GraphQLInt }, - before: { type: GraphQLString }, -}; -``` - -Use `first` and `after` for forward pagination. The `last` and `before` -arguments enable backward pagination if needed. - -## Writing a paginated resolver - -Once you've defined your connection types and pagination arguments, you can write a resolver -that slices your data and returns a connection object. The key steps are: - -1. Decode the incoming cursor. -2. Slice the data based on the decoded index. -3. Generate cursors for each returned item. -4. Build the `edges` and `pageInfo` objects. - -The exact logic will vary depending on how your data is stored. The following example uses an -in-memory list of users: - -```js -// Sample data -const users = [ - { id: '1', name: 'Ada Lovelace' }, - { id: '2', name: 'Alan Turing' }, - { id: '3', name: 'Grace Hopper' }, - { id: '4', name: 'Katherine Johnson' }, -]; - -// Encode/decode cursors -function encodeCursor(index) { - return Buffer.from(`cursor:${index}`).toString('base64'); -} - -function decodeCursor(cursor) { - const decoded = Buffer.from(cursor, 'base64').toString('ascii'); - const match = decoded.match(/^cursor:(\d+)$/); - return match ? parseInt(match[1], 10) : null; -} - -// Resolver for paginated users -const usersField = { - type: UserConnectionType, - args: connectionArgs, - resolve: (_, args) => { - let start = 0; - if (args.after) { - const index = decodeCursor(args.after); - if (Number.isFinite(index)) { - start = index + 1; - } - } - - const slice = users.slice(start, start + (args.first || users.length)); - - const edges = slice.map((user, i) => ({ - node: user, - cursor: encodeCursor(start + i), - })); - - const startCursor = edges.length > 0 ? edges[0].cursor : null; - const endCursor = edges.length > 0 ? edges[edges.length - 1].cursor : null; - const hasNextPage = start + slice.length < users.length; - const hasPreviousPage = start > 0; - - return { - edges, - pageInfo: { - startCursor, - endCursor, - hasNextPage, - hasPreviousPage, - }, - }; - }, -}; -``` - -This resolver handles forward pagination using `first` and `after`. You can extend it to -support `last` and `before` by reversing the logic. - -## Using a database for pagination - -In production, you'll usually paginate data stored in a database. The same cursor-based -logic applies, but you'll translate cursors into SQL query parameters, typically -as an `OFFSET`. - -The following example shows how to paginate a list of users using PostgreSQL and a Node.js -client like `pg`: - -```js -import db from './db'; - -async function resolveUsers(_, args) { - const limit = args.first ?? 10; - let offset = 0; - - if (args.after) { - const index = decodeCursor(args.after); - if (Number.isFinite(index)) { - offset = index + 1; - } - } - - const result = await db.query( - 'SELECT id, name FROM users ORDER BY id ASC LIMIT $1 OFFSET $2', - [limit + 1, offset] // Fetch one extra row to compute hasNextPage - ); - - const slice = result.rows.slice(0, limit); - const edges = slice.map((user, i) => ({ - node: user, - cursor: encodeCursor(offset + i), - })); - - const startCursor = edges.length > 0 ? edges[0].cursor : null; - const endCursor = edges.length > 0 ? edges[edges.length - 1].cursor : null; - - return { - edges, - pageInfo: { - startCursor, - endCursor, - hasNextPage: result.rows.length > limit, - hasPreviousPage: offset > 0, - }, - }; -} -``` - -This approach supports forward pagination by translating the decoded cursor into -an `OFFSET`. To paginate backward, you can reverse the sort order and slice the -results accordingly, or use keyset pagination for improved performance on large -datasets. - - - -The above is just an example to aid understanding; in a production application, -for most databases it is better to use `WHERE` clauses to implement cursor -pagination rather than using `OFFSET`. Using `WHERE` can leverage indices -(indexes) to jump directly to the relevant records, whereas `OFFSET` typically -must scan over and discard that number of records. When paginating very large -datasets, `OFFSET` can become more expensive as the value grows, whereas using -`WHERE` tends to have fixed cost. Using `WHERE` can also typically handle the -addition or removal of data more gracefully. - -For example, if you were ordering a collection of users by username, you could -use the username itself as the `cursor`, thus GraphQL's `allUsers(first: 10, -after: $cursor)` could become SQL's `WHERE username > $1 LIMIT 10`. Even if -that user was deleted, you could still continue to paginate from that position -onwards. - - - -## Handling edge cases - -When implementing pagination, consider how your resolver should handle the following scenarios: - -- **Empty result sets**: Return an empty `edges` array and a `pageInfo` object with -`hasNextPage: false` and `endCursor: null`. -- **Invalid cursors**: If decoding a cursor fails, treat it as a `null` or return an error, -depending on your API's behavior. -- **End of list**: If the requested `first` exceeds the available data, return all remaining -items and set `hasNextPage: false`. - -Always test your pagination with multiple boundaries: beginning, middle, end, and out-of-bounds -errors. - -## Additional resources - -To learn more about cursor-based pagination patterns and best practices, see: - -- [GraphQL Cursor Connections Specification](https://relay.dev/graphql/connections.htm) -- [Pagination](https://graphql.org/learn/pagination/) guide on graphql.org -- [`graphql-relay-js`](https://github.com/graphql/graphql-relay-js): Utility library for -building Relay-compatible GraphQL servers using GraphQL.js diff --git a/website/pages/docs/custom-scalars.mdx b/website/pages/docs/custom-scalars.mdx deleted file mode 100644 index 043a729b29..0000000000 --- a/website/pages/docs/custom-scalars.mdx +++ /dev/null @@ -1,131 +0,0 @@ ---- -title: Using Custom Scalars ---- - -# Custom Scalars: When and How to Use Them - -In GraphQL, scalar types represent primitive data like strings, numbers, and booleans. -The GraphQL specification defines five built-in scalars: `Int`, `Float`, -`String`, `Boolean`, and `ID`. - -However, these default types don't cover all the formats or domain-specific values real-world -APIs often need. For example, you might want to represent a timestamp as an ISO 8601 string, or -ensure a user-submitted field is a valid email address. In these cases, you can define a custom -scalar type. - -In GraphQL.js, custom scalars are created using the `GraphQLScalarType` class. This gives you -full control over how values are serialized, parsed, and validated. - -Here’s a simple example of a custom scalar that handles date-time strings: - -```js -import { GraphQLScalarType, Kind } from 'graphql'; - -const DateTime = new GraphQLScalarType({ - name: 'DateTime', - description: 'An ISO-8601 encoded UTC date string.', - serialize(value) { - return value instanceof Date ? value.toISOString() : null; - }, - parseValue(value) { - return typeof value === 'string' ? new Date(value) : null; - }, - parseLiteral(ast) { - return ast.kind === Kind.STRING ? new Date(ast.value) : null; - }, -}); -``` -Custom scalars offer flexibility, but they also shift responsibility onto you. You're -defining not just the format of a value, but also how it is validated and how it moves -through your schema. - -This guide covers when to use custom scalars and how to define them in GraphQL.js. - -## When to use custom scalars - -Define a custom scalar when you need to enforce a specific format, encapsulate domain-specific -logic, or standardize a primitive value across your schema. For example: - -- Validation: Ensure that inputs like email addresses, URLs, or date strings match a -strict format. -- Serialization and parsing: Normalize how values are converted between internal and -client-facing formats. -- Domain primitives: Represent domain-specific values that behave like scalars, such as -UUIDs or currency codes. - -Common examples of useful custom scalars include: - -- `DateTime`: An ISO 8601 timestamp string -- `Email`: A syntactically valid email address -- `URL`: A well-formed web address -- `BigInt`: An integer that exceeds the range of GraphQL's built-in `Int` -- `UUID`: A string that follows a specific identifier format - -## When not to use a custom scalar - -Custom scalars are not a substitute for object types. Avoid using a custom scalar if: - -- The value naturally contains multiple fields or nested data (even if serialized as a string). -- Validation depends on relationships between fields or requires complex cross-checks. -- You're tempted to bypass GraphQL’s type system using a catch-all scalar like `JSON` or `Any`. - -Custom scalars reduce introspection and composability. Use them to extend GraphQL's scalar -system, not to replace structured types altogether. - -## How to define a custom scalar in GraphQL.js - -In GraphQL.js, a custom scalar is defined by creating an instance of `GraphQLScalarType`, -providing a name, description, and three functions: - -- `serialize`: How the server sends internal values to clients. -- `parseValue`: How the server parses incoming variable values. -- `parseLiteral`: How the server parses inline values in queries. -- `specifiedByURL` (optional): A URL specifying the behavior of your scalar; - this can be used by clients and tooling to recognize and handle common scalars - such as [date-time](https://scalars.graphql.org/andimarek/date-time.html) - independent of their name. - -The following example is a custom `DateTime` scalar that handles ISO-8601 encoded -date strings: - -```js -import { GraphQLScalarType, Kind } from 'graphql'; - -const DateTime = new GraphQLScalarType({ - name: 'DateTime', - description: 'An ISO-8601 encoded UTC date string.', - specifiedByURL: 'https://scalars.graphql.org/andimarek/date-time.html', - - serialize(value) { - if (!(value instanceof Date)) { - throw new TypeError('DateTime can only serialize Date instances'); - } - return value.toISOString(); - }, - - parseValue(value) { - const date = new Date(value); - if (isNaN(date.getTime())) { - throw new TypeError(`DateTime cannot represent an invalid date: ${value}`); - } - return date; - }, - - parseLiteral(ast) { - if (ast.kind !== Kind.STRING) { - throw new TypeError(`DateTime can only parse string values, but got: ${ast.kind}`); - } - const date = new Date(ast.value); - if (isNaN(date.getTime())) { - throw new TypeError(`DateTime cannot represent an invalid date: ${ast.value}`); - } - return date; - }, -}); -``` - -These functions give you full control over validation and data flow. - -## Learn more - -- [Custom Scalars: Best Practices and Testing](./advanced-custom-scalars): Dive deeper into validation, testing, and building production-grade custom scalars. \ No newline at end of file diff --git a/website/pages/docs/defer-stream.mdx b/website/pages/docs/defer-stream.mdx deleted file mode 100644 index d52296f0a5..0000000000 --- a/website/pages/docs/defer-stream.mdx +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: Enabling Defer & Stream ---- - -# Enabling Defer and Stream - -import { Callout } from 'nextra/components' - - - These exports are only available in v17 and beyond. - - -The `@defer` and `@stream` directives are not enabled by default. -In order to use these directives, you must add them to your GraphQL Schema and -use the `experimentalExecuteIncrementally` function instead of `execute`. - -```js -import { - GraphQLSchema, - GraphQLDeferDirective, - GraphQLStreamDirective, - specifiedDirectives, -} from 'graphql'; - -const schema = new GraphQLSchema({ - query, - directives: [ - ...specifiedDirectives, - GraphQLDeferDirective, - GraphQLStreamDirective, - ], -}); - -const result = experimentalExecuteIncrementally({ - schema, - document, -}); -``` - -If the `directives` option is passed to `GraphQLSchema`, the default directives will not be included. `specifiedDirectives` must be passed to ensure all standard directives are added in addition to `defer` & `stream`. diff --git a/website/pages/docs/getting-started.mdx b/website/pages/docs/getting-started.mdx deleted file mode 100644 index 7a0286c890..0000000000 --- a/website/pages/docs/getting-started.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: Getting Started With GraphQL.js -sidebarTitle: Getting Started ---- - -import { Tabs } from 'nextra/components'; - -{/* title can be removed in Nextra 4, since sidebar title will take from first h1 */} - -# Getting Started With GraphQL.js - -## Prerequisites - -Before getting started, you should have at least Node 20 installed, the examples can be tweaked to work with Node versions -before that by switching to require syntax. -For this guide, we won't use any language features that require transpilation, but we will use some ES6 features like -[Promises](http://web.dev/articles/promises/), classes, -and arrow functions, so if you aren't familiar with them you might want to read up on them first. - -> Alternatively you can start from [this StackBlitz](https://stackblitz.com/edit/stackblitz-starters-znvgwr) - if you choose -> this route you can skip to [Basic Types](./basic-types.mdx). - -To create a new project and install GraphQL.js in your current directory: - -```sh npm2yarn -npm init -npm install graphql --save -``` - -## Writing Code - -To handle GraphQL queries, we need a schema that defines the `Query` type, and we need an API root with a function called a "resolver" for each API endpoint. For an API that just returns "Hello world!", we can put this code in a file named `server.js`: - - - -```javascript -import { graphql, buildSchema } from 'graphql'; - -// Construct a schema, using GraphQL schema language -const schema = buildSchema(`type Query { hello: String } `); - -// The rootValue provides a resolver function for each API endpoint -const rootValue = { - hello() { - return 'Hello world!'; - }, -}; - -// Run the GraphQL query '{ hello }' and print out the response -graphql({ - schema, - source: '{ hello }', - rootValue, - }).then((response) => { - console.log(response); - }); - -``` - - -```javascript -import { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString } from 'graphql'; - -// Construct a schema -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - hello: { - type: GraphQLString, - resolve: () => 'Hello world!' - }, - }, - }), -}); - -graphql({ - schema, - source: '{ hello }', -}).then((response) => { - console.log(response); -}); -``` - - - -If you run this with: - -```sh -node server.js -``` - -You should see the GraphQL response printed out: - -```json -{ - "data": { - "hello": "Hello world!" - } -} -``` - -Congratulations - you just executed a GraphQL query! - -For practical applications, you'll probably want to run GraphQL queries from an API server, rather than executing GraphQL with a command line tool. To use GraphQL for an API server over HTTP, check out [Running an Express GraphQL Server](./running-an-express-graphql-server). \ No newline at end of file diff --git a/website/pages/docs/going-to-production.mdx b/website/pages/docs/going-to-production.mdx deleted file mode 100644 index da69a36942..0000000000 --- a/website/pages/docs/going-to-production.mdx +++ /dev/null @@ -1,496 +0,0 @@ ---- -title: Going to Production ---- - -# Going to Production - -GraphQL.JS contains a few development checks which in production will cause slower performance and -an increase in bundle-size. Every bundler goes about these changes different, in here we'll list -out the most popular ones. - -GraphQL.js includes development-time checks that are useful during local testing but should -be disabled in production to reduce overhead. Additional concerns include caching, error handling, -schema management, and operational monitoring. - -This guide covers key practices to prepare a server built with GraphQL.js for production use. - -## Optimize your build for production - -In development, GraphQL.js includes validation checks to catch common mistakes like invalid schemas -or resolver returns. These checks are not needed in production and can increase runtime overhead. - -You can disable them by setting `process.env.NODE_ENV` to `'production'` during your build process. -GraphQL.js will automatically skip over development-only code paths. - -Bundlers are tools that compile and optimize JavaScript for deployment. Most can be configured to -replace environment variables such as `process.env.NODE_ENV` at build time, -allowing for unused code (such as development only code paths) to be elided by -minification tools. - -### Bundler configuration examples - -The following examples show how to configure common bundlers to set `process.env.NODE_ENV` -and remove development-only code: - -#### Vite - -```js -// vite.config.js -import { defineConfig } from 'vite'; - -export default defineConfig({ - define: { - 'process.env.NODE_ENV': '"production"', - }, -}); -``` - -#### Next.js - -When you build your application with `next build` and run it using `next start`, Next.js sets -`process.env.NODE_ENV` to `'production'` automatically. No additional configuration is required. - -```bash -next build -next start -``` - -If you run a custom server, make sure `NODE_ENV` is set manually. - -#### Create React App (CRA) - -To customize Webpack behavior in CRA, you can use a tool like [`craco`](https://craco.js.org/). -This example uses CommonJS syntax instead of ESM syntax, which is required by `craco.config.js`: - -```js -// craco.config.js -const webpack = require('webpack'); - -module.exports = { - webpack: { - plugins: [ - new webpack.DefinePlugin({ - 'globalThis.process': JSON.stringify(true), - 'process.env.NODE_ENV': JSON.stringify('production'), - }), - ], - }, -}; -``` - -#### esbuild - -```json -{ - "define": { - "globalThis.process": true, - "process.env.NODE_ENV": "production" - } -} -``` - -#### Webpack - -```js -// webpack.config.js -import { fileURLToPath } from 'url'; -import { dirname } from 'path'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); - -export default { - mode: 'production', // Automatically sets NODE_ENV - context: __dirname, -}; -``` - -#### Rollup - -```js -// rollup.config.js -import replace from '@rollup/plugin-replace'; - -export default { - plugins: [ - replace({ - preventAssignment: true, - 'process.env.NODE_ENV': JSON.stringify('production'), - }), - ], -}; -``` - -#### SWC - -```json filename=".swcrc" -{ - "jsc": { - "transform": { - "optimizer": { - "globals": { - "vars": { - "globalThis.process": true, - "process.env.NODE_ENV": "production" - } - } - } - } - } -} -``` - -## Secure your schema - -GraphQL gives clients a lot of flexibility, which can be a strength or a liability depending on -how it's used. In production, it's important to control how much of your schema is exposed -and how much work a single query is allowed to do. - -Common strategies for securing a schema include: - -- Disabling introspection for some users -- Limiting query depth or cost -- Enforcing authentication and authorization -- Applying rate limits - -These techniques can help protect your server from accidental misuse or intentional abuse. - -### Only allow trusted documents - -The most reliable way to protect your GraphQL endpoint from malicious requests -is to only allow operations that you trust — those written by your own -engineers — to be executed. - -This technique is not suitable for public APIs that are intended to accept -ad-hoc queries from third parties, but if your GraphQL API is only meant to -power your own websites and apps then it is a simple yet incredibly effective -technique to protect your API endpoint. - -Implementing the trusted documents pattern is straightforward: - -- When deploying a website or application, SHA256 hash the GraphQL documents - (queries, mutations, subscriptions and associated fragments) it contains, and - place them in a trusted store the server has access to. -- When issuing a request from the client, omit the document (`"query":"{...}"`) and - instead provide the document hash (`"documentId": "sha256:..."`). -- The server should retrieve the document from your trusted store via this hash; - if no document is found or no hash is provided then the request should be - rejected. - -This pattern not only improves security significantly by preventing malicious -queries, it has a number of additional benefits: - -- Reduces network size since you're sending a hash (~64 bytes) rather than the - entire GraphQL document (which can be tens of kilobytes). -- Makes schema evolution easier because you have a concrete list of all the - fields/types that are in use. -- Makes tracking issues easier because you can tie a hash to the - client/deployment that introduced it. - -Be careful not to confuse trusted documents (the key component of which are -trust) with automatic persisted queries (APQ) which are a network optimization -potentially open for anyone to use. - -Additional resources: - -- [GraphQL over HTTP Appendix -A: Persisted Documents](https://github.com/graphql/graphql-over-http/pull/264) -- [GraphQL Trusted Documents](https://benjie.dev/graphql/trusted-documents) and - [Techniques to Protect Your GraphQL API](https://benjie.dev/talks/techniques-to-protect) at benjie.dev -- [@graphql-codegen/client-preset persisted documents](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#persisted-documents) or [graphql-codegen-persisted-query-ids](https://github.com/valu-digital/graphql-codegen-persisted-query-ids#integrating-with-apollo-client) for Apollo Client -- [Persisted queries in Relay](https://relay.dev/docs/guides/persisted-queries/) -- [Persisted queries in URQL](https://www.npmjs.com/package/@urql/exchange-persisted) -- [Persisted documents in gql.tada](https://gql-tada.0no.co/guides/persisted-documents) -- [persisted queries with `fetch()`](https://github.com/jasonkuhrt/graffle/issues/269) - -### Control schema introspection - -(Unnecessary if you only allow trusted documents.) - -Introspection lets clients query the structure of your schema, including types -and fields. While helpful during development, it may be an unnecessary in -production and disabling it may reduce your API's attack surface. - -You can disable introspection in production, or only for unauthenticated users: - -```js -import { validate, specifiedRules, NoSchemaIntrospectionCustomRule } from 'graphql'; - -const validationRules = isPublicRequest - ? [...specifiedRules, NoSchemaIntrospectionCustomRule] - : specifiedRules; -``` - -Note that many developer tools rely on introspection to function properly. Use introspection -control as needed for your tools and implementation. - -### Limit query complexity - -(Can be a development-only concern if you only allow trusted documents.) - -GraphQL allows deeply nested queries, which can be expensive to resolve. You can prevent this -with query depth limits or cost analysis. - -The following example shows how to limit query depth: - -```js -import depthLimit from 'graphql-depth-limit'; - -const validationRules = [ - depthLimit(10), - ...specifiedRules, -]; -``` - -Instead of depth, you can assign each field a cost and reject queries that exceed a total budget. -Tools like [`graphql-cost-analysis`](https://github.com/pa-bru/graphql-cost-analysis) can help. - -### Require authentication and authorization - -GraphQL doesn't include built-in authentication. Instead, you can attach user data to the request -using middleware, and pass this through to the business logic where -authorization should take place: - -```js -// From your business logic -const postRepository = { - getBody({ user, post }) { - if (user?.id && (user.id === post.authorId)) { - return post.body - } - return null - } -} - -// Resolver for the `Post.body` field: -function Post_body(source, args, context, info) { - // return the post body only if the user is the post's author - return postRepository.getBody({ user: context.user, post: obj }) -} -``` - -For more details, see the [Authentication and Middleware](./authentication-and-express-middleware/) guide. - -### Apply rate limiting - -To prevent abuse, you can limit how often clients access specific operations or fields. The -[`graphql-rate-limit`](https://github.com/teamplanes/graphql-rate-limit#field-config) package lets -you define rate limits directly in your schema using custom directives. - -For more control, you can also implement your own rate-limiting logic using the request -context, such as limiting by user, client ID, or operation name. - -## Improve performance - -In production, performance often depends on how efficiently your resolvers fetch and process data. -GraphQL allows flexible queries, which means a single poorly optimized query can result in -excessive database calls or slow response times. - -### Use batching with DataLoader - -The most common performance issue in GraphQL is the N+1 query problem, where nested resolvers -make repeated calls for related data. `DataLoader` helps avoid this by batching and caching -field-level fetches within a single request. - -For more information on this issue and how to resolve it, see -[Solving the N+1 Problem with DataLoader](./n1-dataloader/). - -### Apply caching where appropriate - -You can apply caching at several levels, depending on your server architecture: - -- **Resolver-level caching**: Cache the results of expensive operations for a short duration. -- **HTTP caching**: Use persisted queries and edge caching to avoid re-processing -common queries. -- **Schema caching**: If your schema is static, avoid rebuilding it on every request. - -For larger applications, consider request-scoped caching or external systems like Redis to avoid -memory growth and stale data. - -## Monitor and debug in production - -Observability is key to diagnosing issues and ensuring your GraphQL server is running smoothly -in production. This includes structured logs, runtime metrics, and distributed traces to -follow requests through your system. - -### Add structured logging - -Use a structured logger to capture events in a machine-readable format. This makes logs easier -to filter and analyze in production systems. Popular options include: - -- [`pino`](https://github.com/pinojs/pino): Fast, minimal JSON logger -- [`winston`](https://github.com/winstonjs/winston): More configurable with plugin support - -You might log things like: - -- Incoming operation names -- Validation or execution errors -- Resolver-level timing -- User IDs or request metadata - -Avoid logging sensitive data like passwords or access tokens. - -### Collect metrics - -Operational metrics help track the health and behavior of your server over time. - -You can use tools like [Prometheus](https://prometheus.io) or [OpenTelemetry](https://opentelemetry.io) -to capture query counts, resolver durations, and error rates. - -There's no built-in GraphQL.js metrics hook, but you can wrap resolvers or use the `execute` -function directly to insert instrumentation. - -### Use tracing tools - -Distributed tracing shows how a request flows through services and where time is spent. This -is especially helpful for debugging performance issues. - -GraphQL.js allows you to hook into the execution pipeline using: - -- `execute`: Trace the overall operation -- `parse` and `validate`: Trace early steps -- `formatResponse`: Attach metadata - -Tracing tools that work with GraphQL include: - -- [Apollo Studio](https://www.apollographql.com/docs/studio/) -- [OpenTelemetry](https://opentelemetry.io) - -## Handle errors - -How you handle errors in production affects both security and client usability. Avoid exposing -internal details in errors, and return errors in a format clients can interpret consistently. - -For more information on how GraphQL.js formats and processes errors, see [Understanding GraphQL.js Errors](./graphql-errors/). - -### Control what errors are exposed - -By default, GraphQL.js includes full error messages and stack traces. In production, you may want -to return a generic error to avoid leaking implementation details. - -You can use a custom error formatter to control this: - -```js -import { GraphQLError } from 'graphql'; - -function formatError(error) { - if (process.env.NODE_ENV === 'production') { - return new GraphQLError('Internal server error'); - } - return error; -} -``` - -This function can be passed to your server, depending on the integration. - -### Add structured error metadata - -GraphQL allows errors to include an `extensions` object, which you can use to add -metadata such as error codes. This helps clients distinguish between different types of -errors: - -```js -throw new GraphQLError('Forbidden', { - extensions: { code: 'FORBIDDEN' }, -}); -``` - -You can also create and throw custom error classes to represent specific cases, such as -authentication or validation failures. - -## Manage your schema safely - -Schemas evolve over time, but removing or changing fields can break client applications. -In production environments, it's important to make schema changes carefully and with clear -migration paths. - -### Deprecate fields before removing them - -Use the `@deprecated` directive to mark fields or enum values that are planned for removal. -Always provide a reason so clients know what to use instead: - -```graphql -type User { - oldField: String @deprecated(reason: "Use `newField` instead.") -} -``` - -Only remove deprecated fields once you're confident no clients depend on them. - -### Detect breaking changes during deployment - -You can compare your current schema against the previous version to detect breaking changes. -Tools that support this include: - -- [`graphql-inspector`](https://github.com/graphql-hive/graphql-inspector) -- [`graphql-cli`](https://github.com/Urigo/graphql-cli) - -Integrate these checks into your CI/CD pipeline to catch issues before they reach production. - -## Use environment-aware configuration - -You should tailor your GraphQL server's behavior based on the runtime environment. - -- Disable introspection and show minimal error messages in production. -- Enable playgrounds like GraphiQL or Apollo Sandbox only in development. -- Control logging verbosity and other debug features via environment flags. - -Example: - -```js -const isDev = process.env.NODE_ENV !== 'production'; - -app.use( - '/graphql', - graphqlHTTP({ - schema, - graphiql: isDev, - customFormatErrorFn: formatError, - }) -); -``` - -## Production readiness checklist - -Use this checklist to verify that your GraphQL.js server is ready for production. -Before deploying, confirm the following checks are complete: - -### Build and environment -- Bundler sets `process.env.NODE_ENV` to `'production'` -- Development-only checks are removed from the production build - -### Schema security -- Authentication is required for requests -- Authorization is enforced via business logic -- Rate limiting is applied -- Only allow trusted documents, or: - - Introspection is disabled or restricted in production - - Query depth is limited - - Query cost limits are in place - -### Performance -- `DataLoader` is used to batch data fetching -- Expensive resolvers use caching (request-scoped or shared) -- Public queries use HTTP or CDN caching -- Schema is reused across requests (not rebuilt each time) - -### Monitoring and observability -- Logs are structured and machine-readable -- Metrics are collected (e.g., with Prometheus or OpenTelemetry) -- Tracing is enabled with a supported tool -- Logs do not include sensitive data - -### Error handling -- Stack traces and internal messages are hidden in production -- Custom error types are used for common cases -- Errors include `extensions.code` for consistent client handling -- A `formatError` function is used to control error output - -### Schema lifecycle -- Deprecated fields are marked with `@deprecated` and a clear reason -- Schema changes are validated before deployment -- CI/CD includes schema diff checks - -### Environment configuration -- Playground tools (e.g., GraphiQL) are only enabled in development -- Error formatting, logging, and introspection are environment-specific diff --git a/website/pages/docs/graphql-clients.mdx b/website/pages/docs/graphql-clients.mdx deleted file mode 100644 index e1c56e1fa7..0000000000 --- a/website/pages/docs/graphql-clients.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: GraphQL Clients ---- - -# GraphQL Clients - -Since a GraphQL API has more underlying structure than a REST API, there are more powerful clients like [Relay](https://facebook.github.io/relay/) which can automatically handle batching, caching, and other features. But you don't need a complex client to call a GraphQL server. With `graphql-http`, you can just send an HTTP POST request to the endpoint you mounted your GraphQL server on, passing the GraphQL query as the `query` field in a JSON payload. - -For example, let's say we mounted a GraphQL server on http://localhost:4000/graphql as in the example code for [running an Express GraphQL server](./running-an-express-graphql-server), and we want to send the GraphQL query `{ hello }`. We can do this from the command line with `curl`. If you paste this into a terminal: - -```bash -curl -X POST \ --H "Content-Type: application/json" \ --d '{"query": "{ hello }"}' \ -http://localhost:4000/graphql -``` - -You should see the output returned as JSON: - -```json -{ "data": { "hello": "Hello world!" } } -``` - -If you prefer to use a graphical user interface to send a test query, you can use clients such as [GraphiQL](https://github.com/graphql/graphiql), [Insomnia](https://github.com/getinsomnia/insomnia), and [Postman](https://www.postman.com/product/graphql-client/). - -It's also simple to send GraphQL from the browser. Open up http://localhost:4000/graphql, open a developer console, and paste in: - -```js -fetch('/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - body: JSON.stringify({ query: '{ hello }' }), -}) - .then((r) => r.json()) - .then((data) => console.log('data returned:', data)); -``` - -You should see the data returned, logged in the console: - -```text -data returned: Object { hello: "Hello world!" } -``` - -In this example, the query was just a hardcoded string. As your application becomes more complex, and you add GraphQL endpoints that take arguments as described in [Passing Arguments](./passing-arguments), you will want to construct GraphQL queries using variables in client code. You can do this by including a keyword prefixed with a dollar sign in the query, and passing an extra `variables` field on the payload. - -For example, let's say you're running the example server from [Passing Arguments](./passing-arguments) that has a schema of - -```graphql -type Query { - rollDice(numDice: Int!, numSides: Int): [Int] -} -``` - -You could access this from JavaScript with the code: - -```js -let dice = 3; -let sides = 6; -let query = /* GraphQL */ ` - query RollDice($dice: Int!, $sides: Int) { - rollDice(numDice: $dice, numSides: $sides) - } -`; - -fetch('/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - body: JSON.stringify({ - query, - variables: { dice, sides }, - }), -}) - .then((r) => r.json()) - .then((data) => console.log('data returned:', data)); -``` - -Using this syntax for variables is a good idea because it automatically prevents bugs due to escaping, and it makes it easier to monitor your server. - -In general, it will take a bit more time to set up a GraphQL client like Relay, but it's worth it to get more features as your application grows. You might want to start out just using HTTP requests as the underlying transport layer, and switching to a more complex client as your application gets more complex. - -At this point you can write a client and server in GraphQL for an API that receives a single string. To do more, you will want to [learn how to use the other basic data types](./basic-types). diff --git a/website/pages/docs/graphql-errors.mdx b/website/pages/docs/graphql-errors.mdx deleted file mode 100644 index 13e286f025..0000000000 --- a/website/pages/docs/graphql-errors.mdx +++ /dev/null @@ -1,203 +0,0 @@ ---- -title: Understanding GraphQL.js Errors ---- -import { Callout, GitHubNoteIcon } from "nextra/components"; - -# Understanding GraphQL.js Errors - -When executing a GraphQL operation, a server might encounter problems, such as failing to fetch -data, encountering invalid arguments, or running into unexpected internal issues. Instead of -crashing or halting execution, GraphQL.js collects these problems as structured errors -and includes them in the response. - -This guide explains how GraphQL.js represents errors internally, how errors propagate through a -query, and how you can customize error behavior. - -## How GraphQL.js represents errors in a response - -If an error occurs during execution, GraphQL.js includes it in a top-level `errors` array in the -response, alongside any successfully returned data. - -For example: - -```json -{ - "data": { - "user": null - }, - "errors": [ - { - "message": "User not found", - "locations": [{ "line": 2, "column": 3 }], - "path": ["user"] - } - ] -} -``` - -Each error object can include the following fields: - -- `message`: A human-readable description of the error. -- `locations` (optional): Where the error occurred in the operation document. -- `path` (optional): The path to the field that caused the error. -- `extensions` (optional): Additional error metadata, often used for error codes, HTTP status -codes or debugging information. - - - -The GraphQL specification separates errors into two types: _request_ errors, and -_execution_ errors. Request errors indicate something went wrong that prevented -the GraphQL operation from executing, for example the document is invalid, and -only requires the `message` field. Execution errors indicate something went -wrong during execution, typically due to the result of calling a resolver, and -requires both the `message` and `path` fields to be present. All others fields -are optional, but recommended to help clients understand and react to errors. - - - -## Creating and handling errors with `GraphQLError` - -Internally, GraphQL.js represents errors with the `GraphQLError` class, found in the -`graphql/error` module. - -You can create a `GraphQLError` manually: - -```js -import { GraphQLError } from 'graphql'; - -throw new GraphQLError('Something went wrong'); -``` - -To provide more context about an error, you can pass additional options: - -```js -throw new GraphQLError('Invalid input', { - nodes, - source, - positions, - path, - originalError, - extensions, -}); -``` - -Each option helps tie the error to specific parts of the GraphQL execution: - -- `nodes`: The AST nodes associated with the error. -- `source` and `positions`: The source document and character offsets. -- `path`: The field path leading to the error. -- `originalError`: The underlying JavaScript error, if available. -- `extensions`: Any custom metadata you want to include. - -When a resolver throws an error: - -- If the thrown value is a `GraphQLError` and contains the required information -(`path`), GraphQL.js uses it as-is. -- Otherwise, GraphQL.js wraps it into a `GraphQLError`. - -This ensures that all errors returned to the client follow a consistent structure. - -You may throw any type of error that makes sense in your application; throwing -`Error` is fine, you do not need to throw `GraphQLError`. However, ensure that -your errors do not reveal security sensitive information. - -## How errors propagate during execution - -Errors in GraphQL don't necessarily abort the entire operation. How an error affects the response -depends on the nullability of the field where the error occurs. - -- **Nullable fields**: If a resolver for a nullable field throws an error, GraphQL.js records -the error and sets the field's value to `null` in the `data` payload. -- **Non-nullable fields**: If a resolver for a non-nullable field throws an error, GraphQL.js -records the error and then sets the nearest parent nullable field to `null`. -If no such nullable field exists, then the operation root will be set `null` (`"data": null`). - -For example, consider the following schema: - -```graphql -type Query { - user: User -} - -type User { - id: ID! - name: String! -} -``` - -If the `name` resolver throws an error during execution: - -- Because `name` is non-nullable (`String!`), GraphQL.js can't return `null` for just that field. -- Instead, the `user` field itself becomes `null`. -- The error is recorded and included in the response. - -The result looks like: - -```json -{ - "data": { - "user": null - }, - "errors": [ - { - "message": "Failed to fetch user's name", - "path": ["user", "name"] - } - ] -} -``` - -This behavior ensures that non-nullability guarantees are respected even in the presence of errors. - -For more detailed rules, see the [GraphQL Specification on error handling](https://spec.graphql.org/October2021/#sec-Errors). - -## Customizing errors with `extensions` - -You can add additional information to errors using the `extensions` field. This is useful for -passing structured metadata like error codes, HTTP status codes, or debugging hints. - -For example: - -```js -throw new GraphQLError('Unauthorized', { - extensions: { - code: 'UNAUTHORIZED', - http: { - status: 401 - } - } -}); -``` - -Clients can inspect the `extensions` field instead of relying on parsing `message` strings. - -Common use cases for `extensions` include: - -- Assigning machine-readable error codes (`code: 'BAD_USER_INPUT'`) -- Specifying HTTP status codes -- Including internal debug information (hidden from production clients) - -Libraries like [Apollo Server](https://www.apollographql.com/docs/apollo-server/data/errors/) and -[Envelop](https://the-guild.dev/graphql/envelop/plugins/use-error-handler) offer conventions for -structured error extensions, if you want to adopt standardized patterns. - -## Best practices for error handling - -- Write clear, actionable messages. Error messages should help developers understand what went -wrong and how to fix it. -- Use error codes in extensions. Define a set of stable, documented error codes for your API -to make client-side error handling easier. -- Avoid leaking internal details. Do not expose stack traces, database errors, or other -sensitive information to clients. -- Wrap unexpected errors. Catch and wrap low-level exceptions to ensure that all errors passed -through your GraphQL server follow the `GraphQLError` structure. - -In larger servers, you might centralize error handling with a custom error formatting function -to enforce these best practices consistently. - -## Additional resources - -- [GraphQLError reference](https://graphql.org/graphql-js/error/#graphqlerror) -- [GraphQL Specification: Error handling](https://spec.graphql.org/October2021/#sec-Errors) -- [Apollo Server: Error handling](https://www.apollographql.com/docs/apollo-server/data/errors/) -- [Envelop: Error plugins](https://the-guild.dev/graphql/envelop/plugins/use-error-handler) \ No newline at end of file diff --git a/website/pages/docs/index.mdx b/website/pages/docs/index.mdx deleted file mode 100644 index 3b45c15e4b..0000000000 --- a/website/pages/docs/index.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: Overview -sidebarTitle: Overview ---- - -GraphQL.js is the official JavaScript implementation of the -[GraphQL Specification](https://spec.graphql.org/draft/). It provides the core building blocks -for constructing GraphQL servers, clients, tools, and utilities in JavaScript and TypeScript. - -This documentation site is for developers who want to: - -- Understand how GraphQL works -- Build a GraphQL API using GraphQL.js -- Extend, customize, or introspect GraphQL systems -- Learn best practices for using GraphQL.js in production - -Whether you're writing your own server, building a GraphQL clients, or creating tools -that work with GraphQL, this site guides you through core concepts, APIs, and -advanced use cases of GraphQL.js. diff --git a/website/pages/docs/mutations-and-input-types.mdx b/website/pages/docs/mutations-and-input-types.mdx deleted file mode 100644 index 397ff64f21..0000000000 --- a/website/pages/docs/mutations-and-input-types.mdx +++ /dev/null @@ -1,446 +0,0 @@ ---- -title: Mutations and Input Types ---- - -# Mutations and Input Types - -import { Tabs } from 'nextra/components'; - -If you have an API endpoint that alters data, like inserting data into a database or altering data already in a database, you should make this endpoint a `Mutation` rather than a `Query`. This is as simple as making the API endpoint part of the top-level `Mutation` type instead of the top-level `Query` type. - -Let's say we have a "message of the day" server, where anyone can update the message of the day, and anyone can read the current one. The GraphQL schema for this is simply: - - - -```graphql -type Mutation { - setMessage(message: String): String -} - -type Query { - getMessage: String -} -``` - - -```js -import { - GraphQLObjectType, - GraphQLString, - GraphQLSchema, -} from 'graphql'; - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - getMessage: { type: GraphQLString }, - }, - }), - mutation: new GraphQLObjectType({ - name: 'Mutation', - fields: { - setMessage: { type: GraphQLString }, - }, - }), -}); -``` - - - - -It's often convenient to have a mutation that maps to a database create or update operation, like `setMessage`, return the same thing that the server stored. That way, if you modify the data on the server, the client can learn about those modifications. - -Both mutations and queries can be handled by root resolvers, so the root that implements this schema can simply be: - -```js -const fakeDatabase = {}; -const root = { - setMessage({ message }) { - fakeDatabase.message = message; - return message; - }, - getMessage() { - return fakeDatabase.message; - }, -}; -``` - -You don't need anything more than this to implement mutations. But in many cases, you will find a number of different mutations that all accept the same input parameters. A common example is that creating an object in a database and updating an object in a database often take the same parameters. To make your schema simpler, you can use "input types" for this, by using the `input` keyword instead of the `type` keyword. - -For example, instead of a single message of the day, let's say we have many messages, indexed in a database by the `id` field, and each message has both a `content` string and an `author` string. We want a mutation API both for creating a new message and for updating an old message. We could use the schema: - - - -```graphql -input MessageInput { - content: String - author: String -} - -type Message { - id: ID! - content: String - author: String -} - -type Query { - getMessage(id: ID!): Message -} - -type Mutation { - createMessage(input: MessageInput): Message - updateMessage(id: ID!, input: MessageInput): Message -} - -``` - - -```js -import { - GraphQLObjectType, - GraphQLString, - GraphQLSchema, - GraphQLID, - GraphQLInputObjectType, - GraphQLNonNull, -} from 'graphql'; -import { randomBytes } from 'node:crypto'; - -// Maps username to content -const fakeDatabase = {}; - -const MessageInput = new GraphQLInputObjectType({ - name: 'MessageInput', - fields: { - content: { type: GraphQLString }, - author: { type: GraphQLString }, - }, -}); - -const Message = new GraphQLObjectType({ - name: 'Message', - fields: { - id: { type: GraphQLID }, - content: { type: GraphQLString }, - author: { type: GraphQLString }, - }, -}); - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - getMessage: { - type: Message, - args: { - id: { type: new GraphQLNonNull(GraphQLID) }, - }, - resolve: (_, { id }) => { - if (!fakeDatabase[id]) { - throw new Error('no message exists with id ' + id); - } - return fakeDatabase[id] ? { - id, - content: fakeDatabase[id].content, - author: fakeDatabase[id].author, - } : null; - } - }, - }, - }), - mutation: new GraphQLObjectType({ - name: 'Mutation', - fields: { - createMessage: { - type: Message, - args: { - input: { type: new GraphQLNonNull(MessageInput) }, - }, - resolve: (_, { input }) => { - // Create a random id for our "database". - const id = randomBytes(10).toString('hex'); - fakeDatabase[id] = input; - return { - id, - content: input.content, - author: input.author, - }; - } - }, - updateMessage: { - type: Message, - args: { - id: { type: new GraphQLNonNull(GraphQLID) }, - input: { type: new GraphQLNonNull(MessageInput) }, - }, - resolve: (_, { id, input }) => { - if (!fakeDatabase[id]) { - throw new Error('no message exists with id ' + id); - } - // This replaces all old data, but some apps might want partial update. - fakeDatabase[id] = input; - return { - id, - content: input.content, - author: input.author, - }; - } - }, - }, - }), -}); -``` - - - - -Here, the mutations return a `Message` type, so that the client can get more information about the newly-modified `Message` in the same request as the request that mutates it. - -Input types can't have fields that are other objects, only basic scalar types, list types, and other input types. - -Naming input types with `Input` on the end is a useful convention, because you will often want both an input type and an output type that are slightly different for a single conceptual object. - -Here's some runnable code that implements this schema, keeping the data in memory: - - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { buildSchema } from 'graphql'; - -const fakeDatabase = {}; - -// Construct a schema, using GraphQL schema language -const schema = buildSchema(` -input MessageInput { - content: String - author: String -} - -type Message { - id: ID! - content: String - author: String -} - -type Query { - getMessage(id: ID!): Message - getMessages: [Message] -} - -const root = { - getMessage: ({ id }) => { - return fakeDatabase[id] - }, - getMessages: () => { - return Object.values(fakeDatabase) - }, - createMessage: ({ input }) => { - const id = String(Object.keys(fakeDatabase).length + 1) - const message = new Message(id, input) - fakeDatabase[id] = message - return message - }, - updateMessage: ({ id, input }) => { - const message = fakeDatabase[id] - Object.assign(message, input) - return message - } -} - -type Mutation { - createMessage(input: MessageInput): Message - updateMessage(id: ID!, input: MessageInput): Message -} -`); - -// If Message had any complex fields, we'd put them on this object. -class Message { - constructor(id, { content, author }) { - this.id = id; - this.content = content; - this.author = author; - } -} - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - rootValue: root, - }), -); -app.listen(4000, () => { -console.log('Running a GraphQL API server at localhost:4000/graphql'); -}); -``` - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { - GraphQLObjectType, - GraphQLString, - GraphQLSchema, - GraphQLID, - GraphQLInputObjectType, - GraphQLNonNull, -} from 'graphql'; - -// If Message had any complex fields, we'd put them on this object. -class Message { - constructor(id, { content, author }) { - this.id = id; - this.content = content; - this.author = author; - } -} - -// Maps username to content -const fakeDatabase = {}; - -const MessageInput = new GraphQLInputObjectType({ - name: 'MessageInput', - fields: { - content: { type: GraphQLString }, - author: { type: GraphQLString }, - }, -}); - -const Message = new GraphQLObjectType({ - name: 'Message', - fields: { - id: { type: GraphQLID }, - content: { type: GraphQLString }, - author: { type: GraphQLString }, - }, -}); - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - getMessage: { - type: Message, - args: { - id: { type: new GraphQLNonNull(GraphQLID) }, - }, - resolve: (_, { id }) => { - if (!fakeDatabase[id]) { - throw new Error('no message exists with id ' + id); - } - return fakeDatabase[id] ? { - id, - content: fakeDatabase[id].content, - author: fakeDatabase[id].author, - } : null; - } - }, - }, - }), - mutation: new GraphQLObjectType({ - name: 'Mutation', - fields: { - createMessage: { - type: Message, - args: { - input: { type: new GraphQLNonNull(MessageInput) }, - }, - resolve: (_, { input }) => { - // Create a random id for our "database". - import { randomBytes } from 'crypto'; - const id = randomBytes(10).toString('hex'); - fakeDatabase[id] = input; - return { - id, - content: input.content, - author: input.author, - }; - } - }, - updateMessage: { - type: Message, - args: { - id: { type: new GraphQLNonNull(GraphQLID) }, - input: { type: new GraphQLNonNull(MessageInput) }, - }, - resolve: (_, { id, input }) => { - if (!fakeDatabase[id]) { - throw new Error('no message exists with id ' + id); - } - // This replaces all old data, but some apps might want partial update. - fakeDatabase[id] = input; - return { - id, - content: input.content, - author: input.author, - }; - } - }, - }, - }), -}); - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - }), -); -app.listen(4000, () => { - console.log('Running a GraphQL API server at localhost:4000/graphql'); -}); -``` - - - - -To call a mutation, you must use the keyword `mutation` before your GraphQL query. To pass an input type, provide the data written as if it's a JSON object. For example, with the server defined above, you can create a new message and return the `id` of the new message with this operation: - -```graphql -mutation { - createMessage(input: { author: "andy", content: "hope is a good thing" }) { - id - } -} -``` - -You can use variables to simplify mutation client logic just like you can with queries. For example, some JavaScript code that calls the server to execute this mutation is: - -```js -const author = 'andy'; -const content = 'hope is a good thing'; -const query = /* GraphQL */ ` - mutation CreateMessage($input: MessageInput) { - createMessage(input: $input) { - id - } - } -`; - -fetch('/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - body: JSON.stringify({ - query, - variables: { - input: { - author, - content, - }, - }, - }), -}) - .then((r) => r.json()) - .then((data) => console.log('data returned:', data)); -``` - -One particular type of mutation is operations that change users, like signing up a new user. While you can implement this using GraphQL mutations, you can reuse many existing libraries if you learn about [GraphQL with authentication and Express middleware](./authentication-and-express-middleware). diff --git a/website/pages/docs/n1-dataloader.mdx b/website/pages/docs/n1-dataloader.mdx deleted file mode 100644 index 00601ed783..0000000000 --- a/website/pages/docs/n1-dataloader.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: Solving the N+1 Problem with DataLoader ---- - -# Solving the N+1 Problem with DataLoader - -When building a server with GraphQL.js, it's common to encounter -performance issues related to the N+1 problem: a pattern that -results in many unnecessary database or service calls, -especially in nested query structures. - -This guide explains what the N+1 problem is, why it's relevant in -GraphQL field resolution, and how to address it using -[`DataLoader`](https://github.com/graphql/dataloader). - -## What is the N+1 problem? - -The N+1 problem happens when your API fetches a list of items using one -query, and then issues an additional query for each item in the list. -In GraphQL, this usually occurs in nested field resolvers. - -For example, in the following query: - -```graphql -{ - posts { - id - title - author { - name - } - } -} -``` - -If the `posts` field returns 10 items, and each `author` field fetches -the author by ID with a separate database call, the server performs -11 total queries: one to fetch the posts, and one for each post's author -(10 total authors). As the number of parent items increases, the number -of database calls grows, which can degrade performance. - -Even if several posts share the same author, the server will still issue -duplicate queries unless you implement deduplication or batching manually. - -## Why this happens in GraphQL.js - -In GraphQL.js, each field resolver runs independently. There's no built-in -coordination between resolvers, and no automatic batching. This makes field -resolvers composable and predictable, but it also creates the N+1 problem. -Nested resolutions, such as fetching an author for each post in the previous -example, will each call their own data-fetching logic, even if those calls -could be grouped. - -## Solving the problem with DataLoader - -[`DataLoader`](https://github.com/graphql/dataloader) is a utility library designed -to solve this problem. It batches multiple `.load(key)` calls into a single `batchLoadFn(keys)` -call and caches results during the life of a request. This means you can reduce redundant data -fetches and group related lookups into efficient operations. - -To use `DataLoader` in a `graphql-js` server: - -1. Create `DataLoader` instances for each request. -2. Attach the instance to the `contextValue` passed to GraphQL execution. You can attach the -loader when calling [`graphql()`](https://graphql.org/graphql-js/graphql/#graphql) directly, or -when setting up a GraphQL HTTP server such as [express-graphql](https://github.com/graphql/express-graphql). -3. Use `.load(id)` in resolvers to fetch data through the loader. - -### Example: Batching author lookups - -Suppose each `Post` has an `authorId`, and you have a `getUsersByIds(ids)` -function that can fetch multiple users in a single call: - -{/* prettier-ignore */} -```js {14-17,37} -import { - graphql, - GraphQLObjectType, - GraphQLSchema, - GraphQLString, - GraphQLList, - GraphQLID -} from 'graphql'; -import DataLoader from 'dataloader'; -import { getPosts, getUsersByIds } from './db.js'; - -function createContext() { - return { - userLoader: new DataLoader(async (userIds) => { - const users = await getUsersByIds(userIds); - return userIds.map(id => users.find(user => user.id === id)); - }), - }; -} - -const UserType = new GraphQLObjectType({ - name: 'User', - fields: () => ({ - id: { type: GraphQLID }, - name: { type: GraphQLString }, - }), -}); - -const PostType = new GraphQLObjectType({ - name: 'Post', - fields: () => ({ - id: { type: GraphQLID }, - title: { type: GraphQLString }, - author: { - type: UserType, - resolve(post, args, context) { - return context.userLoader.load(post.authorId); - }, - }, - }), -}); - -const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: () => ({ - posts: { - type: GraphQLList(PostType), - resolve: () => getPosts(), - }, - }), -}); - -const schema = new GraphQLSchema({ query: QueryType }); -``` - -With this setup, all `.load(authorId)` calls are automatically collected and batched -into a single call to `getUsersByIds`. `DataLoader` also caches results for the duration -of the request, so repeated `.load(id)` calls for the same ID don't trigger -additional fetches. - -## Best practices - -- Create a new `DataLoader` instance per request. This ensures that caching is scoped -correctly and avoids leaking data between users. -- Always return results in the same order as the input keys. This is required by the -`DataLoader` contract. If a key is not found, return `null` or throw depending on -your policy. -- Keep batch functions focused. Each loader should handle a specific data access pattern. -- Use `.loadMany()` sparingly. While it's useful when you already have a list of IDs, it's -typically not needed in field resolvers, since `.load()` already batches individual calls -made within the same execution cycle. - -## Additional resources - -- [`DataLoader` GitHub repository](https://github.com/graphql/dataloader): Includes full API docs and usage examples -- [GraphQL field resolvers](./resolver-anatomy): Background on how field resolution works. diff --git a/website/pages/docs/nullability.mdx b/website/pages/docs/nullability.mdx deleted file mode 100644 index 0e5ce6f0ff..0000000000 --- a/website/pages/docs/nullability.mdx +++ /dev/null @@ -1,235 +0,0 @@ ---- -title: Nullability -sidebarTitle: Nullability in GraphQL.js ---- - -# Nullability in GraphQL.js - -Nullability is a core concept in GraphQL that affects how schemas are defined, -how execution behaves, and how clients interpret results. In GraphQL.js, -nullability plays a critical role in both schema construction and -runtime behavior. - -This guide explains how nullability works, how it's represented in GraphQL.js, -and how to design schemas with nullability in mind. - -## How nullability works - -In GraphQL, fields are nullable by default. This means if a resolver function -returns `null`, the result will include a `null` value unless the field is -explicitly marked as non-nullable. - -When a non-nullable field resolves to `null`, the GraphQL execution engine -raises a runtime error and attempts to recover by replacing the nearest -nullable parent field with `null`. This behavior is known formally as "error -propagation" but more commonly as null bubbling. - -Understanding nullability requires familiarity with the GraphQL type system, -execution semantics, and the trade-offs involved in schema design. - -## The role of `GraphQLNonNull` - -GraphQL.js represents non-nullability using the `GraphQLNonNull` wrapper type. -By default, all fields are nullable: - -```js -import { - GraphQLObjectType, - GraphQLString, - GraphQLNonNull, -} from 'graphql'; - -const UserType = new GraphQLObjectType({ - name: 'User', - fields: () => ({ - id: { type: new GraphQLNonNull(GraphQLString) }, - email: { type: GraphQLString }, - }), -}); -``` - -In this example, the `id` field is non-nullable, meaning it must always -resolve to a string. The `email` field is nullable. - -You can use `GraphQLNonNull` with: - -- Field types -- Argument types -- Input object field types - -You can also combine it with other types to create more -specific constraints. For example: - -```js -new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(UserType))) -``` - -This structure corresponds to [User!]! in SDL: a non-nullable list of non-null -`User` values. When reading code like this, work from the inside out: `UserType` -is non-nullable, and wrapped in a list, which is itself non-nullable. - -## Execution behavior - -GraphQL.js uses nullability rules to determine how to handle `null` values -at runtime: - -- If a nullable field returns `null`, the result includes that field with -a `null` value. -- If a non-nullable field returns `null`, GraphQL throws an error and -sets the nearest nullable parent field to `null`. - -This bubbling behavior prevents partial data from being returned in cases where -a non-nullable guarantee is violated. - -Here's an example that shows this in action: - -```js -import { - GraphQLSchema, - GraphQLObjectType, - GraphQLString, - GraphQLNonNull, -} from 'graphql'; - -const UserType = new GraphQLObjectType({ - name: 'User', - fields: { - id: { type: new GraphQLNonNull(GraphQLString) }, - }, -}); - -const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - user: { - type: UserType, - resolve: () => ({ id: null }), - }, - }, -}); - -const schema = new GraphQLSchema({ query: QueryType }); -``` - -In this example, the `user` field returns an object with `id: null`. -Because `id` is non-nullable, GraphQL can't return `user.id`, and instead -nullifies the `user` field entirely. An error describing the violation is -added to the `errors` array in the response. - -## Schema design considerations - -Using non-null types communicates clear expectations to clients, but it's -also less forgiving. When deciding whether to use `GraphQLNonNull`, keep -the following in mind: - -- Use non-null types when a value is always expected. This reflects intent -and reduces ambiguity for clients. -- Avoid aggressive use of non-null types in early schema versions. It limits -your ability to evolve the API later. -- Be cautious of error bubbling. A `null` return from a deeply nested non-nullable -field can affect large portions of the response. - -### Versioning - -Non-null constraints are part of a field's contract: - -- Changing an output position (field type) from non-nullable to nullable is a - breaking change - clients may now receive `null` values which they do not have - handling code for. -- Changing an input position (argument or input field type) from nullable to - non-nullable is a breaking change - clients are now required to provide this - value, which they may not have been supplying previously. -- Changing an output position from nullable to non-nullable will not break - deployed clients since their null handling code will simply not be exercised. - -To reduce the risk of versioning issues, start with nullable fields and add -constraints as your schema matures. - -## Using `GraphQLNonNull` in schema and resolvers - -Let's walk through two practical scenarios that show how GraphQL.js enforces -nullability. - -### Defining a non-null field - -This example defines a `Product` type with a non-nullable `name` field: - -```js -import { GraphQLObjectType, GraphQLString, GraphQLNonNull } from 'graphql'; - -const ProductType = new GraphQLObjectType({ - name: 'Product', - fields: () => ({ - name: { type: new GraphQLNonNull(GraphQLString) }, - }), -}); -``` - -This configuration guarantees that `name` must always be a string -and never `null`. If a resolver returns `null` for this field, an -error will be thrown. - -### Resolver returns `null` for a non-null field - -In this example, the resolver returns an object with `name: null`, violating -the non-null constraint: - -```js -import { - GraphQLObjectType, - GraphQLString, - GraphQLNonNull, - GraphQLSchema, -} from 'graphql'; - -const ProductType = new GraphQLObjectType({ - name: 'Product', - fields: { - name: { type: new GraphQLNonNull(GraphQLString) }, - }, -}); - -const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - product: { - type: ProductType, - resolve: () => ({ name: null }), - }, - }, -}); - -const schema = new GraphQLSchema({ query: QueryType }); -``` - -In this example, the `product` resolver returns an object with `name: null`. -Because the `name` field is non-nullable, GraphQL.js responds by -nullifying the entire `product` field and appending a -corresponding error to the response. - -## Best practices - -- Default to nullable. Start with nullable fields and introduce non-null -constraints when data consistency is guaranteed. -- Express intent. Use non-null when a field must always be present for logical -correctness. -- Validate early. Add checks in resolvers to prevent returning `null` for -non-null fields. -- Consider error boundaries. Were an error to occur, where should it stop - bubbling? -- Watch for nesting. Distinguish between: - - `[User!]` - nullable list of non-null users - - `[User]!` - non-null list of nullable users - - `[User!]!` - non-null list of non-null users - -## Additional resources - -- [GraphQL Specification: Non-null](https://spec.graphql.org/draft/#sec-Non-Null): -Defines the formal behavior of non-null types in the GraphQL type system and -execution engine. -- [Understanding GraphQL.js Errors](./graphql-errors): Explains -how GraphQL.js propagates and formats execution-time errors. -- [Anatomy of a Resolver](./resolver-anatomy): Breaks down -how resolvers work in GraphQL.js. -- [Constructing Types](./constructing-types): Shows how -to define and compose types in GraphQL.js. \ No newline at end of file diff --git a/website/pages/docs/object-types.mdx b/website/pages/docs/object-types.mdx deleted file mode 100644 index 961d34e4d4..0000000000 --- a/website/pages/docs/object-types.mdx +++ /dev/null @@ -1,396 +0,0 @@ ---- -title: Object Types ---- - -# Object Types - -import { Tabs } from 'nextra/components'; - -In many cases, you don't want to return a number or a string from an API. You want to return an object that has its own complex behavior. GraphQL is a perfect fit for this. - -In GraphQL schema language, the way you define a new object type is the same way we have been defining the `Query` type in our examples. Each object can have fields that return a particular type, and methods that take arguments. For example, in the [Passing Arguments](./passing-arguments) documentation, we had a method to roll some random dice: - - - -```graphql -type Query { - rollDice(numDice: Int!, numSides: Int): [Int] -} -``` - - -```js -import { - GraphQLObjectType, - GraphQLNonNull, - GraphQLInt, - GraphQLString, - GraphQLList, - GraphQLFloat -} from 'graphql'; - -new GraphQLObjectType({ - name: 'Query', - fields: { - rollDice: { - type: new GraphQLList(GraphQLFloat), - args: { - numDice: { - type: new GraphQLNonNull(GraphQLInt) - }, - numSides: { - type: new GraphQLNonNull(GraphQLInt) - }, - }, - }, - }, -}) -``` - - - -If we wanted to have more and more methods based on a random die over time, we could implement this with a `RandomDie` object type instead. - - - -```graphql -type RandomDie { - roll(numRolls: Int!): [Int] -} - -type Query { - getDie(numSides: Int): RandomDie -} -``` - - - -```js -import { - GraphQLObjectType, - GraphQLNonNull, - GraphQLInt, - GraphQLString, - GraphQLList, - GraphQLFloat, - GraphQLSchema -} from 'graphql'; - -const RandomDie = new GraphQLObjectType({ - name: 'RandomDie', - fields: { - numSides: { - type: new GraphQLNonNull(GraphQLInt), - resolve: function(die) { - return die.numSides; - } - }, - rollOnce: { - type: new GraphQLNonNull(GraphQLInt), - resolve: function(die) { - return 1 + Math.floor(Math.random() * die.numSides); - } - }, - roll: { - type: new GraphQLList(GraphQLInt), - args: { - numRolls: { - type: new GraphQLNonNull(GraphQLInt) - }, - }, - resolve: function(die, { numRolls }) { - const output = []; - for (let i = 0; i < numRolls; i++) { - output.push(1 + Math.floor(Math.random() * die.numSides)); - } - return output; - } - } - } -}); - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - getDie: { - type: RandomDie, - args: { - numSides: { - type: GraphQLInt - } - }, - resolve: (_, { numSides }) => { - return { - numSides: numSides || 6, - } - } - } - } - }) -}); -``` - - - -Instead of a root-level resolver for the `RandomDie` type, we can instead use an ES6 class, where the resolvers are instance methods. This code shows how the `RandomDie` schema above can be implemented: - -```js -class RandomDie { - constructor(numSides) { - this.numSides = numSides; - } - - rollOnce() { - return 1 + Math.floor(Math.random() * this.numSides); - } - - roll({ numRolls }) { - const output = []; - for (let i = 0; i < numRolls; i++) { - output.push(this.rollOnce()); - } - return output; - } -} - -const root = { - getDie({ numSides }) { - return new RandomDie(numSides || 6); - }, -}; -``` - -For fields that don't use any arguments, you can use either properties on the object or instance methods. So for the example code above, both `numSides` and `rollOnce` can actually be used to implement GraphQL fields, so that code also implements the schema of: - - - -```graphql -type RandomDie { - numSides: Int! - rollOnce: Int! - roll(numRolls: Int!): [Int] -} - -type Query { - getDie(numSides: Int): RandomDie -} -``` - - -```js -import { - GraphQLObjectType, - GraphQLNonNull, - GraphQLInt, - GraphQLString, - GraphQLList, - GraphQLFloat, - GraphQLSchema -} from 'graphql'; - -const RandomDie = new GraphQLObjectType({ - name: 'RandomDie', - fields: { - numSides: { - type: new GraphQLNonNull(GraphQLInt), - resolve: (die) => die.numSides - }, - rollOnce: { - type: new GraphQLNonNull(GraphQLInt), - resolve: (die) => 1 + Math.floor(Math.random() * die.numSides) - }, - roll: { - type: new GraphQLList(GraphQLInt), - args: { - numRolls: { - type: new GraphQLNonNull(GraphQLInt) - }, - }, - resolve: (die, { numRolls }) => { - const output = []; - for (let i = 0; i < numRolls; i++) { - output.push(1 + Math.floor(Math.random() * die.numSides)); - } - return output; - } - } - } -}); - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - getDie: { - type: RandomDie, - args: { - numSides: { - type: GraphQLInt - } - }, - resolve: (_, { numSides }) => { - return { - numSides: numSides || 6, - } - } - } - } - }) -}); -``` - - - -Putting this all together, here is some sample code that runs a server with this GraphQL API: - - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { buildSchema } from 'graphql'; - -// Construct a schema, using GraphQL schema language -const schema = buildSchema(` -type RandomDie { - numSides: Int! - rollOnce: Int! - roll(numRolls: Int!): [Int] -} - -type Query { - getDie(numSides: Int): RandomDie -} -`); - -// This class implements the RandomDie GraphQL type -class RandomDie { - constructor(numSides) { - this.numSides = numSides; - } - - rollOnce() { - return 1 + Math.floor(Math.random() * this.numSides); - } - - roll({ numRolls }) { - const output = []; - for (let i = 0; i < numRolls; i++) { - output.push(this.rollOnce()); - } - return output; - } -} - -// The root provides the top-level API endpoints -const root = { - getDie({ numSides }) { - return new RandomDie(numSides || 6); - }, -}; - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - rootValue: root, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); -``` - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { - GraphQLObjectType, - GraphQLNonNull, - GraphQLInt, - GraphQLList, - GraphQLFloat, - GraphQLSchema -} from 'graphql'; - -const RandomDie = new GraphQLObjectType({ - name: 'RandomDie', - fields: { - numSides: { - type: new GraphQLNonNull(GraphQLInt), - resolve: (die) => die.numSides - }, - rollOnce: { - type: new GraphQLNonNull(GraphQLInt), - resolve: (die) => 1 + Math.floor(Math.random() * die.numSides) - }, - roll: { - type: new GraphQLList(GraphQLInt), - args: { - numRolls: { - type: new GraphQLNonNull(GraphQLInt) - }, - }, - resolve: (die, { numRolls }) => { - const output = []; - for (let i = 0; i < numRolls; i++) { - output.push(1 + Math.floor(Math.random() * die.numSides)); - } - return output; - } - } - } -}); - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - getDie: { - type: RandomDie, - args: { - numSides: { - type: GraphQLInt - } - }, - resolve: (_, { numSides }) => { - return { - numSides: numSides || 6, - } - } - } - } - }) -}); - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); -``` - - - -When you issue a GraphQL query against an API that returns object types, you can call multiple methods on the object at once by nesting the GraphQL field names. For example, if you wanted to call both `rollOnce` to roll a die once, and `roll` to roll a die three times, you could do it with this query: - -```graphql -{ - getDie(numSides: 6) { - rollOnce - roll(numRolls: 3) - } -} -``` - -If you run this code with `node server.js` and browse to http://localhost:4000/graphql you can try out these APIs with [GraphiQL](https://github.com/graphql/graphiql). - -This way of defining object types often provides advantages over a traditional REST API. Instead of doing one API request to get basic information about an object, and then multiple subsequent API requests to find out more information about that object, you can get all of that information in one API request. That saves bandwidth, makes your app run faster, and simplifies your client-side logic. - -So far, every API we've looked at is designed for returning data. In order to modify stored data or handle complex input, it helps to [learn about mutations and input types](./mutations-and-input-types). diff --git a/website/pages/docs/oneof-input-objects.mdx b/website/pages/docs/oneof-input-objects.mdx deleted file mode 100644 index 516da5b538..0000000000 --- a/website/pages/docs/oneof-input-objects.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: OneOf input objects ---- - -# OneOf input objects - -import { Tabs } from 'nextra/components'; - -Some inputs will behave differently depending on what input we choose. Let's look at the case for -a field named `product`, we can fetch a `Product` by either its `id` or its `name`. Currently we'd -make a tradeoff for this by introducing two arguments that are both nullable, now if both are passed -as null (or both non-null) we'd have to handle that in code - the type system wouldn't indicate that exactly one was required. To fix this, the `@oneOf` directive was introduced so we -can create this "exactly one option" constraint without sacrificing the strictly typed nature of our GraphQL Schema. - - - -```js -const schema = buildSchema(` - type Product { - id: ID! - name: String! - } - - input ProductLocation { - aisleNumber: Int! - shelfNumber: Int! - positionOnShelf: Int! - } - - input ProductSpecifier @oneOf { - id: ID - name: String - location: ProductLocation - } - - type Query { - product(by: ProductSpecifier!): Product - } -`); -``` - - -```js -const Product = new GraphQLObjectType({ - name: 'Product', - fields: { - id: { - type: new GraphQLNonNull(GraphQLID), - }, - name: { - type: new GraphQLNonNull(GraphQLString), - }, - }, -}); - -const ProductLocation = new GraphQLInputObjectType({ - name: 'ProductLocation', - isOneOf: true, - fields: { - aisleNumber: { type: GraphQLInt }, - shelfNumber: { type: GraphQLInt }, - positionOnShelf: { type: GraphQLInt }, - }, -}); - -const ProductSpecifier = new GraphQLInputObjectType({ - name: 'ProductSpecifier', - isOneOf: true, - fields: { - id: { type: GraphQLID }, - name: { type: GraphQLString }, - location: { type: ProductLocation }, - }, -}); - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - product: { - type: Product, - args: { by: { type: ProductSpecifier } }, - }, - }, - }), -}); -``` - - - -It doesn't matter whether you have 2 or more inputs here, all that matters is -that your user will have to specify one, and only one, for this input to be valid. -The values are not limited to scalars, lists and other input object types are also allowed. diff --git a/website/pages/docs/operation-complexity-controls.mdx b/website/pages/docs/operation-complexity-controls.mdx deleted file mode 100644 index 9aff4dc67e..0000000000 --- a/website/pages/docs/operation-complexity-controls.mdx +++ /dev/null @@ -1,264 +0,0 @@ ---- -title: Operation Complexity Controls ---- - -import { Callout } from 'nextra/components' - -# Operation Complexity Controls - -GraphQL gives clients a lot of flexibility to shape responses, but that -flexibility can also introduce risk. Clients can request deeply nested fields or -large volumes of data in a single operation. Without controls, these operations can slow -down your server or expose security vulnerabilities. - -This guide explains how to measure and limit operation complexity in GraphQL.js -using static analysis. You'll learn how to estimate the cost -of an operation before execution and reject it if it exceeds a safe limit. - - - In production, we recommend using [trusted documents](/docs/going-to-production#only-allow-trusted-documents) - rather than analyzing arbitrary documents at runtime. Complexity analysis can still be - useful at build time to catch expensive operations before they're deployed. - - -## Why complexity control matters - -GraphQL lets clients choose exactly what data they want. That flexibility is powerful, -but it also makes it hard to predict the runtime cost of a query just by looking -at the schema. - -Without safeguards, clients could: - -- Request deeply nested object relationships -- Use nested fragments to multiply field resolution -- Exploit pagination arguments to retrieve excessive data - -Certain field types (e.g., lists, interfaces, unions) can also significantly -increase cost by multiplying the number of values returned or resolved. - -Complexity controls help prevent these issues. They allow you to: - -- Protect your backend from denial-of-service attacks or accidental load -- Enforce cost-based usage limits between clients or environments -- Detect expensive queries early in development -- Add an additional layer of protection alongside authentication, depth limits, and validation - -For more information, see [Security best practices](https://graphql.org/learn/security/). - -## Estimating operation cost - -To measure a query's complexity, you typically: - -1. Parse the incoming operation into a GraphQL document. -2. Walk the query's Abstract Syntax Tree (AST), which represents its structure. -3. Assign a cost to each field, often using static heuristics or metadata. -4. Reject or log the operation if it exceeds a maximum allowed complexity. - -You can do this using custom middleware or validation rules that run before execution. -No resolvers are called unless the operation passes these checks. - - - Fragment cycles or deep nesting can cause some complexity analyzers to perform - poorly or get stuck. Always run complexity analysis after validation unless your analyzer - explicitly handles cycles safely. - - -## Simple complexity calculation - -There are several community-maintained tools for complexity analysis. The examples in this -guide use [`graphql-query-complexity`](https://github.com/slicknode/graphql-query-complexity) as -an option, but we recommend choosing the approach that best fits your project. - -Here's a basic example using its `simpleEstimator`, which assigns a flat cost to every field: - -```js -import { parse } from 'graphql'; -import { getComplexity, simpleEstimator } from 'graphql-query-complexity'; -import { schema } from './schema.js'; - -const query = ` - query { - users { - id - name - posts { - id - title - } - } - } -`; - -const complexity = getComplexity({ - schema, - query: parse(query), - estimators: [simpleEstimator({ defaultComplexity: 1 })], - variables: {}, -}); - -if (complexity > 100) { - throw new Error(`Query is too complex: ${complexity}`); -} - -console.log(`Query complexity: ${complexity}`); -``` - -In this example, every field costs 1 point. The total complexity is the number of fields, -adjusted for nesting and fragments. The complexity is calculated before execution begins, -allowing you to reject costly operations early. - -## Custom cost estimators - -Some fields are more expensive than others. For example, a paginated list might be more -costly than a scalar field. You can define per-field costs using -`fieldExtensionsEstimator`, a feature supported by some complexity tools. - -This estimator reads cost metadata from the field's `extensions.complexity` function in -your schema. For example: - -```js -import { GraphQLObjectType, GraphQLList, GraphQLInt } from 'graphql'; -import { PostType } from './post-type.js'; - -const UserType = new GraphQLObjectType({ - name: 'User', - fields: { - posts: { - type: GraphQLList(PostType), - args: { - limit: { type: GraphQLInt }, - }, - extensions: { - complexity: ({ args, childComplexity }) => { - const limit = args.limit ?? 10; - return childComplexity * limit; - }, - }, - }, - }, -}); -``` - -In this example, the cost of `posts` depends on the number of items requested (`limit`) and the -complexity of each child field. - - - Most validation steps don't have access to variable values. If your complexity - calculation depends on variables (like `limit`), make sure it runs after validation, not - as part of it. - - -To evaluate the cost before execution, you can combine estimators like this: - -```js -import { parse } from 'graphql'; -import { - getComplexity, - simpleEstimator, - fieldExtensionsEstimator, -} from 'graphql-query-complexity'; -import { schema } from './schema.js'; - -const query = ` - query { - users { - id - posts(limit: 5) { - id - title - } - } - } -`; - -const document = parse(query); - -const complexity = getComplexity({ - schema, - query: document, - variables: {}, - estimators: [ - fieldExtensionsEstimator(), - simpleEstimator({ defaultComplexity: 1 }), - ], -}); - -console.log(`Query complexity: ${complexity}`); -``` - -Estimators are evaluated in order. The first one to return a numeric value is used -for a given field. This lets you define detailed logic for specific fields and fall back -to a default cost elsewhere. - -## Enforcing limits in your server - -Some tools allow you to enforce complexity limits during validation by adding a rule -to your GraphQL.js server. For example, `graphql-query-complexity` provides a -`createComplexityRule` helper: - -```js -import { graphql, specifiedRules, parse } from 'graphql'; -import { createComplexityRule, simpleEstimator } from 'graphql-query-complexity'; -import { schema } from './schema.js'; - -const source = ` - query { - users { - id - posts { - title - } - } - } -`; - -const document = parse(source); - -const result = await graphql({ - schema, - source, - validationRules: [ - ...specifiedRules, - createComplexityRule({ - estimators: [simpleEstimator({ defaultComplexity: 1 })], - maximumComplexity: 50, - onComplete: (complexity) => { - console.log('Query complexity:', complexity); - }, - }), - ], -}); - -console.log(result); -``` - - - Only use complexity rules in validation if you're sure the analysis is cycle-safe. - Otherwise, run complexity checks after validation and before execution. - - -## Complexity in trusted environments - -In environments that use persisted or precompiled operations, complexity analysis is still -useful, just in a different way. You can run it at build time to: - -- Warn engineers about expensive operations during development -- Track changes to operation cost across schema changes -- Define internal usage budgets by team, client, or role - -## Best practices - -- Only accept trusted documents in production when possible. -- Use complexity analysis as a development-time safeguard. -- Avoid running untrusted operations without additional validation and cost checks. -- Account for list fields and abstract types, which can significantly increase cost. -- Avoid estimating complexity before validation unless you're confident in your tooling. -- Use complexity analysis as part of your layered security strategy, alongside depth limits, -field guards, and authentication. - -## Additional resources - -- [`graphql-query-complexity`](https://github.com/slicknode/graphql-query-complexity): A community-maintained static analysis tool -- [`graphql-depth-limit`](https://github.com/graphile/depth-limit): A lightweight tool to restrict the maximum query depth -- [GraphQL Specification: Operations and execution](https://spec.graphql.org/draft/#sec-Language.Operations) -- [GraphQL.org: Security best practices](https://graphql.org/learn/security/) diff --git a/website/pages/docs/passing-arguments.mdx b/website/pages/docs/passing-arguments.mdx deleted file mode 100644 index 45eb087cd8..0000000000 --- a/website/pages/docs/passing-arguments.mdx +++ /dev/null @@ -1,236 +0,0 @@ ---- -title: Passing Arguments ---- - -# Passing Arguments - -import { Tabs } from 'nextra/components'; - -Just like a REST API, it's common to pass arguments to an endpoint in a GraphQL API. By defining the arguments in the schema language, typechecking happens automatically. Each argument must be named and have a type. For example, in the [Basic Types documentation](./basic-types) we had an endpoint called `rollThreeDice`: - -```graphql -type Query { - rollThreeDice: [Int] -} -``` - -Instead of hard coding "three", we might want a more general function that rolls `numDice` dice, each of which have `numSides` sides. We can add arguments to the GraphQL schema language like this: - - - -```graphql -type Query { - rollDice(numDice: Int!, numSides: Int): [Int] -} -``` - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { - GraphQLObjectType, - GraphQLSchema, - GraphQLList, - GraphQLFloat, - GraphQLInt, - GraphQLNonNull -} from 'graphql'; - -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - rollDice: { - type: new GraphQLList(GraphQLFloat), - args: { - numDice: { type: new GraphQLNonNull(GraphQLInt) }, - numSides: { type: GraphQLInt }, - }, - resolve: (_, { numDice, numSides }) => { - const output = []; - for (let i = 0; i < numDice; i++) { - output.push(1 + Math.floor(Math.random() * (numSides || 6))); - } - return output; - } - }, - }, - }), -}); - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); -``` - - - -The exclamation point in `Int!` indicates that `numDice` can't be null, which means we can skip a bit of validation logic to make our server code simpler. We can let `numSides` be null and assume that by default a die has 6 sides. - -So far, our resolver functions took no arguments. When a resolver takes arguments, they are passed as one "args" object, as the first argument to the function. So rollDice could be implemented as: - -```js -const root = { - rollDice(args) { - const output = []; - for (let i = 0; i < args.numDice; i++) { - output.push(1 + Math.floor(Math.random() * (args.numSides || 6))); - } - return output; - }, -}; -``` - -It's convenient to use [ES6 destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) for these parameters, since you know what format they will be. So we can also write `rollDice` as - -```js -const root = { - rollDice({ numDice, numSides }) { - const output = []; - for (let i = 0; i < numDice; i++) { - output.push(1 + Math.floor(Math.random() * (numSides || 6))); - } - return output; - }, -}; -``` - -If you're familiar with destructuring, this is a bit nicer because the line of code where `rollDice` is defined tells you about what the arguments are. - -The entire code for a server that hosts this `rollDice` API is: - - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { buildSchema } from 'graphql'; - -// Construct a schema, using GraphQL schema language -const schema = buildSchema(/_ GraphQL _/ ` type Query { rollDice(numDice: Int!, numSides: Int): [Int] }`); - -// The root provides a resolver function for each API endpoint -const root = { - rollDice({ numDice, numSides }) { - const output = []; - for (let i = 0; i < numDice; i++) { - output.push(1 + Math.floor(Math.random() * (numSides || 6))); - } - return output; - }, -}; - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - rootValue: root, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); -``` - - -```js -import express from 'express'; -import { createHandler } from 'graphql-http/lib/use/express'; -import { - GraphQLObjectType, - GraphQLNonNull, - GraphQLInt, - GraphQLString, - GraphQLList, - GraphQLFloat, - GraphQLSchema -} from 'graphql'; - -// Construct a schema, using GraphQL schema language -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - rollDice: { - type: new GraphQLList(GraphQLFloat), - args: { - numDice: { - type: new GraphQLNonNull(GraphQLInt) - }, - numSides: { - type: new GraphQLNonNull(GraphQLInt) - }, - }, - resolve: (_, { numDice, numSides }) => { - const output = []; - for (let i = 0; i < numDice; i++) { - output.push(1 + Math.floor(Math.random() * (numSides || 6))); - } - return output; - } - }, - }, - }) -}) - -const app = express(); -app.all( - '/graphql', - createHandler({ - schema: schema, - }), -); -app.listen(4000); -console.log('Running a GraphQL API server at localhost:4000/graphql'); -``` - - - -When you call this API, you have to pass each argument by name. So for the server above, you could issue this GraphQL query to roll three six-sided dice: - -```graphql -{ - rollDice(numDice: 3, numSides: 6) -} -``` - -If you run this code with `node server.js` and browse to http://localhost:4000/graphql you can try out this API. - -When you're passing arguments in code, it's generally better to avoid constructing the whole query string yourself. Instead, you can use `$` syntax to define variables in your query, and pass the variables as a separate map. - -For example, some JavaScript code that calls our server above is: - -```js -const dice = 3; -const sides = 6; -const query = /* GraphQL */ ` - query RollDice($dice: Int!, $sides: Int) { - rollDice(numDice: $dice, numSides: $sides) - } -`; - -fetch('/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - body: JSON.stringify({ - query, - variables: { dice, sides }, - }), -}) - .then((r) => r.json()) - .then((data) => console.log('data returned:', data)); -``` - -Using `$dice` and `$sides` as variables in GraphQL means we don't have to worry about escaping on the client side. - -With basic types and argument passing, you can implement anything you can implement in a REST API. But GraphQL supports even more powerful queries. You can replace multiple API calls with a single API call if you learn how to [define your own object types](./object-types). diff --git a/website/pages/docs/resolver-anatomy.mdx b/website/pages/docs/resolver-anatomy.mdx deleted file mode 100644 index 6799d021a0..0000000000 --- a/website/pages/docs/resolver-anatomy.mdx +++ /dev/null @@ -1,139 +0,0 @@ ---- -title: Anatomy of a Resolver ---- - -# Anatomy of a Resolver - -In GraphQL.js, a resolver is a function that returns the value for a -specific field in a schema. Resolvers connect a GraphQL query to the -underlying data or logic needed to fulfill it. - -This guide breaks down the anatomy of a resolver, how GraphQL.js uses -them during query execution, and best practices for writing them effectively. - -## What is a resolver? - -A resolver is responsible for returning the value for a specific field in a -GraphQL query. During execution, GraphQL.js calls a resolver for each field, -either using a custom function you provide or falling back to a default -behavior. - -If no resolver is provided, GraphQL.js tries to retrieve a property from the -parent object that matches the field name. If the property is a function, it -calls the function and uses the result. Otherwise, it returns the property -value directly. - -You can think of a resolver as a translator between the schema and the -actual data. The schema defines what can be queried, while resolvers -determine how to fetch or compute the data at runtime. - -## Resolver function signature - -When GraphQL.js executes a resolver, it calls the resolver function -with four arguments: - -```js -function resolve(source, args, context, info) { ... } -``` - -Each argument provides information that can help the resolver return the -correct value: - -- `source`: The result from the parent field's resolver. In nested fields, -`source` contains the value returned by the parent object (after resolving any -lists). For root fields, it is the `rootValue` passed to GraphQL, which is often -left `undefined`. -- `args`: An object containing the arguments passed to the field in the -query. For example, if a field is defined to accept an `id` argument, you can -access it as `args.id`. -- `context`: A shared object available to every resolver in an operation. -It is commonly used to store per-request state like authentication -information, database connections, or caching utilities. -- `info`: Information about the current execution state, including -the field name, path to the field from the root, the return type, the parent -type, and the full schema. It is mainly useful for advanced scenarios such -as query optimization or logging. - -Resolvers can use any combination of these arguments, depending on the needs -of the field they are resolving. - -## Default resolvers - -If you do not provide a resolver for a field, GraphQL.js uses a built-in -default resolver called `defaultFieldResolver`. - -The default behavior is simple: - -- It looks for a property on the `source` object that matches the name of -the field. -- If the property exists and is a function, it calls the function and uses the -result. -- Otherwise, it returns the property value directly. - -This default resolution makes it easy to build simple schemas without -writing custom resolvers for every field. For example, if your `source` object -already contains fields with matching names, GraphQL.js can resolve them -automatically. - -You can override the default behavior by specifying a `resolve` function when -defining a field in the schema. This is necessary when the field’s value -needs to be computed dynamically, fetched from an external service, or -otherwise requires custom logic. - -## Writing a custom resolver - -A custom resolver is a function you define to control exactly how a field's -value is fetched or computed. You can add a resolver by specifying a `resolve` -function when defining a field in your schema: - -```js {6-8} -const UserType = new GraphQLObjectType({ - name: 'User', - fields: { - fullName: { - type: GraphQLString, - resolve(source) { - return `${source.firstName} ${source.lastName}`; - }, - }, - }, -}); -``` - -Resolvers can be synchronous or asynchronous. If a resolver returns a -Promise, GraphQL.js automatically waits for the Promise to resolve before -continuing execution: - -```js -resolve(source, args, context) { - return database.getUserById(args.id); -} -``` - -Custom resolvers are often used to implement patterns such as batching, -caching, or delegation. For example, a resolver might use a batching utility -like DataLoader to fetch multiple related records efficiently, or delegate -part of the query to another API or service. - -## Best practices - -When writing resolvers, it's important to keep them focused and maintainable: - -- Keep business logic separate. A resolver should focus on fetching or -computing the value for a field, not on implementing business rules or -complex workflows. Move business logic into separate service layers -whenever possible. -- Handle errors carefully. Resolvers should catch and handle errors -appropriately, either by throwing GraphQL errors or returning `null` values -when fields are nullable. Avoid letting unhandled errors crash the server. -- Use context effectively. Store shared per-request information, such as -authentication data or database connections, in the `context` object rather -than passing it manually between resolvers. -- Prefer batching over nested requests. For fields that trigger multiple -database or API calls, use batching strategies to minimize round trips and -improve performance. A common solution for batching in GraphQL is [dataloader](https://github.com/graphql/dataloader). -- Keep resolvers simple. Aim for resolvers to be small, composable functions -that are easy to read, test, and reuse. - -Following these practices helps keep your GraphQL server reliable, efficient, -and easy to maintain as your schema grows. \ No newline at end of file diff --git a/website/pages/docs/running-an-express-graphql-server.mdx b/website/pages/docs/running-an-express-graphql-server.mdx deleted file mode 100644 index 8768a76480..0000000000 --- a/website/pages/docs/running-an-express-graphql-server.mdx +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: Running an Express GraphQL Server -sidebarTitle: Running Express + GraphQL ---- - -# Running an Express GraphQL Server - -import { Tabs } from 'nextra/components'; - -The simplest way to run a GraphQL API server is to use [Express](https://expressjs.com), a popular web application framework for Node.js. You will need to install two additional dependencies: - -```sh npm2yarn -npm install express graphql-http graphql --save -``` - -Let's modify our "hello world" example so that it's an API server rather than a script that runs a single query. We can use the 'express' module to run a webserver, and instead of executing a query directly with the `graphql` function, we can use the `graphql-http` library to mount a GraphQL API server on the "/graphql" HTTP endpoint: - - - -```javascript -import { buildSchema } from 'graphql'; -import { createHandler } from 'graphql-http/lib/use/express'; -import express from 'express'; - -// Construct a schema, using GraphQL schema language -const schema = buildSchema(`type Query { hello: String } `); - -// The root provides a resolver function for each API endpoint -const root = { - hello() { - return 'Hello world!'; - }, -}; - -const app = express(); - -// Create and use the GraphQL handler. -app.all( - '/graphql', - createHandler({ - schema: schema, - rootValue: root, - }), -); - -// Start the server at port -app.listen(4000); -console.log('Running a GraphQL API server at http://localhost:4000/graphql'); - -``` - - -```javascript -import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql'; -import { createHandler } from 'graphql-http/lib/use/express'; -import express from 'express'; - -// Construct a schema -const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { - hello: { - type: GraphQLString, - resolve: () => 'Hello world!' - }, - }, - }), -}); - -const app = express(); - -// Create and use the GraphQL handler. -app.all( - '/graphql', - createHandler({ - schema: schema, - }), -); - -// Start the server at port -app.listen(4000); -console.log('Running a GraphQL API server at http://localhost:4000/graphql'); - -``` - - - -You can run this GraphQL server with: - -```sh -node server.js -``` - -At this point you will have a running GraphQL API; but you can't just visit it in your web browser to use it - you need a GraphQL client to issue GraphQL queries to the API. Let's take a look at how to add the GraphiQL (GraphQL with an `i` in the middle) integrated development environment to your server. - -## Using GraphiQL - -[GraphiQL](https://github.com/graphql/graphiql) is GraphQL's IDE; a great way of querying and exploring your GraphQL API. -One easy way to add it to your server is via the MIT-licensed [ruru](https://github.com/graphile/crystal/blob/main/grafast/ruru/README.md) package which bundles a prebuilt GraphiQL with some popular enhancements. -To do so, install the `ruru` module with `npm install --save ruru` and then add the following to your `server.js` file, then restart the `node server.js` command: - -```js -import { ruruHTML } from 'ruru/server'; - -// Serve the GraphiQL IDE. -app.get('/', (_req, res) => { - res.type('html'); - res.end(ruruHTML({ endpoint: '/graphql' })); -}); -``` - -If you navigate to [http://localhost:4000](http://localhost:4000), you should see an interface that lets you enter queries; -now you can use the GraphiQL IDE tool to issue GraphQL queries directly in the browser. - -At this point you have learned how to run a GraphQL server. The next step is to learn how to [issue GraphQL queries from client code](./graphql-clients). diff --git a/website/pages/docs/scaling-graphql.mdx b/website/pages/docs/scaling-graphql.mdx deleted file mode 100644 index 7a29b313f4..0000000000 --- a/website/pages/docs/scaling-graphql.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -title: Scaling your GraphQL API ---- - -As your application grows, so does your GraphQL schema. What starts as a small, -self-contained monolith may eventually need to support multiple teams, services, and -domains. - -This guide introduces three common patterns for structuring GraphQL APIs at different -stages of scale: monolithic schemas, schema stitching, and federation. It also explains -how these patterns relate to GraphQL.js and what tradeoffs to consider as your -architecture evolves. - -## Monolithic schemas - -A monolithic schema is a single GraphQL schema served from a single service. All types, -resolvers, and business logic are located and deployed together. - -This is the default approach when using GraphQL.js. You define the entire schema in one -place using the `GraphQLSchema` constructor and expose it through a single HTTP endpoint. - -The following example defines a minimal schema that serves a single `hello` field: - -```js -import { GraphQLSchema, GraphQLObjectType, GraphQLString } from 'graphql'; - -const QueryType = new GraphQLObjectType({ - name: 'Query', - fields: { - hello: { - type: GraphQLString, - resolve: () => 'Hello from a monolithic schema!', - }, - }, -}); - -export const schema = new GraphQLSchema({ query: QueryType }); -``` - -This structure works well for small to medium projects, especially when a single team owns the entire -graph. It's simple to test, deploy, and reason about. As long as the schema remains manageable -in size and scope, there's often no need to introduce additional architectural complexity. - -## Schema stitching - -As your application evolves, you may want to split your schema across modules or services while -still presenting a unified graph to clients. Schema stitching allows you to do this by merging -multiple schemas into one executable schema at runtime. - -GraphQL.js does not include stitching capabilities directly, but the -[`@graphql-tools/stitch`](https://the-guild.dev/graphql/stitching/docs/approaches) package -implements stitching features on top of GraphQL.js primitives. - -The following example stitches two subschemas into a single stitched schema: - -```js -import { stitchSchemas } from '@graphql-tools/stitch'; - -export const schema = stitchSchemas({ - subschemas: [ - { schema: userSchema }, - { schema: productSchema }, - ], -}); -``` - -Each subschema can be developed and deployed independently. The stitched schema handles query delegation, -merging, and resolution across them. - -Stitching is useful when: - -- Integrating existing GraphQL services behind a single endpoint -- Incrementally breaking up a monolithic schema -- Creating internal-only aggregators - -However, stitching can add runtime complexity and often requires manual conflict resolution for -overlapping types or fields. - -## Federation - -Federation is a distributed architecture that composes a single GraphQL schema from multiple independently -developed services, known as subgraphs. Each subgraph owns a portion of the schema and is responsible -for defining and resolving its fields. - -Unlike schema stitching, federation is designed for large organizations where teams need autonomy over -their part of the schema and services must be deployed independently. - -Federation introduces a set of conventions to coordinate between services. For example: - -- `@key` declares how an entity is identified across subgraphs -- `@external`, `@requires`, and `@provides` describe field-level dependencies across service boundaries - -Rather than merging schemas at runtime, federation uses a composition step to build the final schema. -A dedicated gateway routes queries to subgraphs and resolves shared entities. - -GraphQL.js does not provide built-in support for federation. To implement a federated subgraph using -GraphQL.js, you'll need to: - -- Add custom directives to the schema -- Implement resolvers for reference types -- Output a schema that conforms to a federation-compliant format - -Most federation tooling today is based on -[Apollo Federation](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/federation). -However, other approaches exist: - -- [GraphQL Mesh](https://the-guild.dev/graphql/mesh) allows federation-like composition across -services using plugins. -- Custom gateways and tooling can be implemented using GraphQL.js or other frameworks. -- The [GraphQL Composite Schemas WG](https://github.com/graphql/composite-schemas-wg/) (formed of Apollo, ChilliCream, The Guild, Netflix, Graphile and many more) are working on an open specification for the next generation of GraphQL Federation - -Federation is most useful when schema ownership is distributed and teams need to evolve their subgraphs -independently under a shared contract. - -## Choosing the right architecture - -The best structure for your GraphQL API depends on your team size, deployment model, and how your -schema is expected to grow. - -| Pattern | Best for | GraphQL.js support | Tooling required | -|---|---|---|---| -| Monolith | Default choice for most projects; simpler, faster, easier to reason about | Built-in | None | -| Schema stitching | Aggregating services you control | External tooling required | `@graphql-tools/stitch` -| Federation | Large enterprises; many teams contributing to a distributed graph independently | Manual implementation | Significant tooling and infrastructure | - -## Migration paths - -Architectural patterns aren't mutually exclusive. In many cases, teams evolve from one approach to another -over time. - -### Monolith to schema stitching - -Schema stitching can act as a bridge when breaking apart a monolithic schema. Teams can extract parts -of the schema into standalone services while maintaining a unified entry point. This allows for gradual -refactoring without requiring a full rewrite. - -### Stitching to federation - -Federation formalizes ownership boundaries and removes the need to manually coordinate overlapping types. -If schema stitching becomes difficult to maintain, federation can offer better scalability and governance. - -### Starting with federation - -Some teams choose to adopt federation early, particularly in large organizations with multiple backend -domains and team boundaries already in place. This can work well if you have the infrastructure and -experience to support it. - -## Guidelines - -The following guidelines can help you choose and evolve your architecture over time: - -- Start simple. If you're building a new API, a monolithic schema is usually the right place -to begin. It's easier to reason about, test, and iterate on. -- Split only when needed. Don't reach for composition tools prematurely. Schema stitching or federation -should be introduced in response to real organizational or scalability needs. -- Favor clarity over flexibility. Stitching and federation add power, but they also increase complexity. -Make sure your team has the operational maturity to support the tooling and patterns involved. -- Define ownership boundaries. Federation is most useful when teams need clear control over parts of -the schema. Without strong ownership models, a federated graph can become harder to manage. -- Consider alternatives. Not all use cases need stitching or federation. Sometimes, versioning, modular -schema design, or schema delegation patterns within a monolith are sufficient. \ No newline at end of file diff --git a/website/pages/docs/subscriptions.mdx b/website/pages/docs/subscriptions.mdx deleted file mode 100644 index 7afeefed1b..0000000000 --- a/website/pages/docs/subscriptions.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: Subscriptions ---- - -# Subscriptions - -Subscriptions allow a GraphQL server to push updates to clients in real time. Unlike queries and mutations, which use a request/response model, subscriptions maintain a long-lived connection between the client and server to stream data as events occur. This is useful for building features like chat apps, live dashboards, or collaborative tools that require real-time updates. - -This guide covers how to implement subscriptions in GraphQL.js, when to use them, and what to consider in production environments. - -## What is a subscription? - -A subscription is a GraphQL operation that delivers ongoing results to the client when a specific event happens. Unlike queries or mutations, which return a single response, a subscription delivers data over time through a persistent connection. - -GraphQL.js implements the subscription execution algorithm, but it's up to you to connect it to your event system and transport layer. Most implementations use WebSockets for transport, though any full-duplex protocol can work. - -## How execution works - -The core of subscription execution in GraphQL.js is the `subscribe` function. It works similarly to `graphql()`, but returns an `AsyncIterable` of execution results -instead of a single response: - -```js -import { subscribe, parse } from 'graphql'; -import schema from './schema.js'; - -const document = parse(` - subscription { - messageSent - } -`); - -const iterator = await subscribe({ schema, document }); - -for await (const result of iterator) { - console.log(result); -} -``` - -Each time your application publishes a new `messageSent` event, the iterator emits a new result. It's up to your transport layer to manage the connection and forward these updates to the client. - -## When to use subscriptions - -Subscriptions are helpful when your application needs to respond to real-time events. For example: - -- Receiving new messages in a chat -- Updating a live feed or activity stream -- Displaying presence indicators (e.g., "user is online") -- Reflecting real-time price changes - -If real-time delivery isn’t essential, consider using polling with queries instead. Subscriptions require more infrastructure and introduce additional complexity, especially around scaling and connection management. - -## Implementing subscriptions in GraphQL.js - -GraphQL.js supports subscription execution, but you’re responsible for setting up the transport and event system. At a minimum, you’ll need: - -- A `Subscription` root type in your schema -- A `subscribe` resolver that returns an `AsyncIterable` -- An event-publishing mechanism -- A transport layer to maintain the connection - -The following examples use the [`graphql-subscriptions`](https://github.com/apollographql/graphql-subscriptions) package to set up an in-memory event system. - -### Install dependencies - -Start by installing the necessary packages: - -```bash -npm install graphql graphql-subscriptions -``` - -To serve subscriptions over a network, you’ll also need a transport implementation. One option is [`graphql-ws`](https://github.com/enisdenjo/graphql-ws), a community-maintained WebSocket library. This guide focuses on schema-level implementation. - -### Set up a pub/sub instance - -Create a `PubSub` instance to manage your in-memory event system: - -```js -import { PubSub } from 'graphql-subscriptions'; - -const pubsub = new PubSub(); -``` - -This `pubsub` object provides `publish` and `asyncIterator` methods, allowing -you to broadcast and listen for events. - -### Define a subscription type - -Next, define your `Subscription` root type. Each field on this type should return -an `AsyncIterable`. Subscribe functions can also accept standard resolver arguments -such as `args`, `context`, and `info`, depending on your use case: - -```js -import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql'; - -const SubscriptionType = new GraphQLObjectType({ - name: 'Subscription', - fields: { - messageSent: { - type: GraphQLString, - subscribe: () => pubsub.asyncIterator(['MESSAGE_SENT']), - }, - }, -}); -``` - -This schema defines a `messageSent` field that listens for the `MESSAGE_SENT` event and returns a string. - -### Publish events - -You can trigger a subscription event from any part of your application using the -`publish` method: - -```js -pubsub.publish('MESSAGE_SENT', { messageSent: 'Hello world!' }); -``` - -Clients subscribed to the `messageSent` field will receive this message. - -### Construct your schema - -Finally, build your schema and include the `Subscription` type: - -```js -const schema = new GraphQLSchema({ - subscription: SubscriptionType, -}); -``` - -A client can then initiate a subscription like this: - -```graphql -subscription { - messageSent -} -``` - -Whenever your server publishes a `MESSAGE_SENT` event, clients subscribed to -`messageSent` will receive the updated value over their active connection. - -## Planning for production - -The in-memory `PubSub` used in this example is suitable for development only. -It does not support multiple server instances or distributed environments. - -For production, consider using a more robust event system such as: - -- Redis Pub/Sub -- Message brokers like Kafka or NATS -- Custom implementations with persistent queues or durable event storage - -Subscriptions also require careful handling of connection limits, authentication, rate limiting, and network reliability. These responsibilities fall to your transport layer and infrastructure. diff --git a/website/pages/docs/type-generation.mdx b/website/pages/docs/type-generation.mdx deleted file mode 100644 index fdcaf8e3a4..0000000000 --- a/website/pages/docs/type-generation.mdx +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: Type Generation for GraphQL -sidebarTitle: Type Generation ---- - -# Type Generation for GraphQL - -Writing a GraphQL server in JavaScript or TypeScript often involves managing complex -types. As your API grows, keeping these types accurate and aligned with your schema -becomes increasingly difficult. - -Type generation tools automate this process. Instead of manually defining or maintaining -TypeScript types for your schema and operations, these tools can generate them for you. -This improves safety, reduces bugs, and makes development easier to scale. - -This guide walks through common type generation workflows for projects using -`graphql-js`, including when and how to use them effectively. - -## Why use type generation? - -Type generation improves reliability and developer experience across the development -lifecycle. It's especially valuable when: - -- You want strong type safety across your server logic -- Your schema is defined separately in SDL files -- Your API surface is large, rapidly evolving, or used by multiple teams -- You rely on TypeScript for editor tooling, autocomplete, or static analysis - -By generating types directly from your schema, you can avoid drift between schema -definitions and implementation logic. - -## Code-first development - -In a code-first workflow, the schema is constructed entirely in JavaScript or TypeScript -using `graphql-js` constructors like `GraphQLObjectType`, `GraphQLSchema`, and others. -This approach is flexible and lets you build your schema programmatically using native -language features. - -If you're using this approach with TypeScript, you already get some built-in type safety -with the types exposed by `graphql-js`. For example, TypeScript can help ensure your resolver -functions return values that match their expected shapes. - -However, code-first development has tradeoffs: - -- You won't get automatic type definitions for your resolvers unless you generate -them manually or infer them through wrappers. -- Schema documentation, testing, and tool compatibility may require you to provide - a description of the schema in SDL first. - -You can still use type generation tools like GraphQL Code Generator in a code-first setup. -You just need to convert your schema into SDL. - -To produce an SDL description of your schema: - -```ts -import { printSchema } from 'graphql'; -import { schema } from './schema'; -import { writeFileSync } from 'fs'; - -writeFileSync('./schema.graphql', printSchema(schema)); -``` - -Once you've written the SDL, you can treat the project like an SDL-first project -for type generation. - -## Schema-first development - -In a schema-first workflow, your GraphQL schema is written in SDL, for example, `.graphql` -or `.gql` (discouraged) files. This serves as the source of truth for your server. This approach -emphasizes clarity because your schema is defined independently from your business logic. - -Schema-first development pairs well with type generation because the schema is -serializable and can be directly used by tools like [GraphQL Code Generator](https://the-guild.dev/graphql/codegen). - -With a schema-first workflow, you can: - -- Generate resolver type definitions and files that match your schema -- Generate operation types for client queries, integration tests, or internal tooling -- Detect breaking changes and unused types through schema diffing tools - -## Generating resolver types - -To get started, install the required packages: - -```bash -npm install graphql @graphql-codegen/cli @eddeee888/gcg-typescript-resolver-files -``` - -This scoped package is published by a community maintainer and is widely used for GraphQL server -type generation. - -We recommend using the [Server Preset](https://www.npmjs.com/package/@eddeee888/gcg-typescript-resolver-files) for a -managed workflow. It automatically generates types and files based on your schema without needing extra plugin setup. - -The Server Preset generates: - -- Resolver types, including parent types, arguments, return values, and context -- Resolver files with types wired up, ready for your business logic -- A resolver map and type definitions to plug into GraphQL servers - -This setup expects your schema is split into modules to improve readability and maintainability. For example: - -```text -β”œβ”€β”€ src/ -β”‚ β”œβ”€β”€ schema/ -β”‚ β”‚ β”œβ”€β”€ base/ -β”‚ β”‚ β”‚ β”œβ”€β”€ schema.graphql -β”‚ β”‚ β”œβ”€β”€ user/ -β”‚ β”‚ β”‚ β”œβ”€β”€ schema.graphql -β”‚ β”‚ β”œβ”€β”€ book/ -β”‚ β”‚ β”‚ β”œβ”€β”€ schema.graphql -``` - -Here's an example `codegen.ts` file using the Server Preset: - -```ts filename="codegen.ts" -import type { CodegenConfig } from "@graphql-codegen/cli"; -import { defineConfig } from "@eddeee888/gcg-typescript-resolver-files"; - -const config: CodegenConfig = { - schema: "src/**/schema.graphql", - generates: { - "src/schema": defineConfig({ - resolverGeneration: "minimal", - }), - }, -}; - -export default config; -``` - -To generate the resolver types and files, run: - -```bash -npx graphql-codegen -``` - -This creates resolver files like: - -```ts filename="src/schema/user/resolvers/Query/user.ts" -import type { QueryResolvers } from "./../../../types.generated"; - -export const user: NonNullable = async ( - _parent, - _arg, - _ctx, -) => { - // Implement Query.user resolver logic here -}; -``` - -The user query resolver is typed to ensure that the user resolver expects an id argument and returns a -User, giving you confidence and autocomplete while implementing your server logic, which may look like this: - -```ts filename="src/schema/user/resolvers/Query/user.ts" -export const user: NonNullable = async ( - parent, - args, - context, -) => { - return context.db.getUser(args.id); -}; -``` - -See the official [Server Preset guide](https://the-guild.dev/graphql/codegen/docs/guides/graphql-server-apollo-yoga-with-server-preset) to learn about its other features, including mappers convention and static analysis for runtime safety. - -## Generating operation types - -In addition to resolver types, you can generate types for GraphQL operations such as queries, mutations, and -fragments. This is especially useful for shared integration tests or client logic that needs to match the schema -precisely. - -To get started, install the required packages: - -```bash -npm install graphql @graphql-codegen/cli -``` - -We recommend using the GraphQL Code Generator [Client Preset](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client) for a managed workflow: - -- Write operations with GraphQL syntax in the same file where it is used -- Get type-safety when using the result - -Here's an example configuration using the Client Preset: - -```ts filename="codegen.ts" -import type { CodegenConfig } from "@graphql-codegen/cli"; - -const config: CodegenConfig = { - schema: "src/**/schema.graphql", - documents: ["src/**/*.ts"], - ignoreNoDocuments: true, - generates: { - "./src/graphql/": { - preset: "client", - config: { - documentMode: "string", - }, - }, - }, -}; - -export default config; -``` - -To keep generated types up to date as you edit your code, run the generator in watch mode: - -```bash -npx graphql-codegen --config codegen.ts --watch -``` - -Once generated, import the `graphql` function from `src/graphql/` to write GraphQL operations -directly in your TypeScript files: - -```ts filename="src/index.ts" -import { graphql } from "./graphql"; - -const UserQuery = graphql(` - query User($id: ID!) { - user(id: ID!) { - id - fullName - } - } -`); - -const response = await fetch("https://graphql.org/graphql/", { - method: "POST", - headers: { - "Content-Type": "application/json", - Accept: "application/graphql-response+json", - }, - body: JSON.stringify({ - query: UserQuery, - variables: { id: "1" }, - }), -}); - -if (!response.ok) { - throw new Error("Network response was not ok"); -} - -const result: ResultOf = await response.json(); - -console.log(result); -``` - -For guides on using the Client Preset with popular frameworks and tools, see: - -- [Vanilla TypeScript](https://the-guild.dev/graphql/codegen/docs/guides/vanilla-typescript) -- [React Query](https://the-guild.dev/graphql/codegen/docs/guides/react-query) -- [React / Vue](https://the-guild.dev/graphql/codegen/docs/guides/react-vue) - -## Best practices for CI and maintenance - -To keep your type generation reliable and consistent: - -- Check in generated files to version control so teammates and CI systems don't produce -divergent results. -- Run type generation in CI to ensure types stay in sync with schema changes. -- Use schema diffing tools like `graphql-inspector` to catch breaking changes before -they're merged. -- Automate regeneration with pre-commit hooks, GitHub Actions, or lint-staged workflows. \ No newline at end of file diff --git a/website/pages/docs/using-directives.mdx b/website/pages/docs/using-directives.mdx deleted file mode 100644 index 4e24dfe643..0000000000 --- a/website/pages/docs/using-directives.mdx +++ /dev/null @@ -1,330 +0,0 @@ ---- -title: Using Directives in GraphQL.js -sidebarTitle: Using Directives ---- - -# Using Directives in GraphQL.js - -Directives let you customize query execution at a fine-grained level. They act like -annotations in a GraphQL document, giving the server instructions about whether to -include a field, how to format a response, or how to apply custom behavior. - -GraphQL.js supports built-in directives like `@include`, `@skip`, and `@deprecated` out -of the box. If you want to create your own directives and apply custom behavior, you'll -need to implement the logic yourself. - -This guide covers how GraphQL.js handles built-in directives, how to define and apply -custom directives, and how to implement directive behavior during execution. - -## How GraphQL.js handles built-in directives - -GraphQL defines several built-in directives, each serving a specific purpose during -execution or in the schema. These include: - -- `@include` and `@skip`: Used in the execution language to conditionally include or skip -fields and fragments at runtime. -- `@deprecated`: Used in Schema Definition Language (SDL) to mark fields or enum values as -deprecated, with an optional reason. It appears in introspection but doesn't affect query execution. - -For example, the `@include` directive conditionally includes a field based on a Boolean variable: - -```graphql -query($shouldInclude: Boolean!) { - greeting @include(if: $shouldInclude) -} -``` - -At runtime, GraphQL.js evaluates the `if` argument. If `shouldInclude` is `false`, the -`greeting` field in this example is skipped entirely and your resolver won't run. - -```js -import { graphql, buildSchema } from 'graphql'; - -const schema = buildSchema(` - type Query { - greeting: String - } -`); - -const rootValue = { - greeting: () => 'Hello!', -}; - -const query = ` - query($shouldInclude: Boolean!) { - greeting @include(if: $shouldInclude) - } -`; - -const variables = { shouldInclude: true }; - -const result = await graphql({ - schema, - source: query, - rootValue, - variableValues: variables, -}); - -console.log(result); -// β†’ { data: { greeting: 'Hello!' } } -``` - -If `shouldInclude` is `false`, the result would be `{ data: {} }`. - -The `@deprecated` directive is used in the schema to indicate that a field or enum -value should no longer be used. It doesn't affect execution, but is included -in introspection output: - -```graphql -{ - __type(name: "MyType") { - fields { - name - isDeprecated - deprecationReason - } - } -} -``` - -GraphQL.js automatically includes deprecation metadata in introspection. Tools like -GraphiQL use this to show warnings, but GraphQL.js itself doesn't block or modify behavior. -You can still query deprecated fields unless you add validation rules yourself. - -## Declaring custom directives in GraphQL.js - -To use a custom directive, you first define it in your schema using the -`GraphQLDirective` class. This defines the directive's name, where it can -be applied, and any arguments it accepts. - -A directive in GraphQL.js is just metadata. It doesn't perform any behavior on its own. - -Here's a basic example that declares an `@uppercase` directive that can be applied to fields: - -```js -import { - GraphQLDirective, - DirectiveLocation, - GraphQLNonNull, - GraphQLBoolean, -} from 'graphql'; - -const UppercaseDirective = new GraphQLDirective({ - name: 'uppercase', - description: 'Converts the result of a field to uppercase.', - locations: [DirectiveLocation.FIELD], - args: { - enabled: { - type: GraphQLNonNull(GraphQLBoolean), - defaultValue: true, - description: 'Whether to apply the transformation.', - }, - }, -}); -``` - -To make the directive available to your schema, you must explicitly include it: - -```js -import { GraphQLSchema } from 'graphql'; - -const schema = new GraphQLSchema({ - query: QueryType, - directives: [UppercaseDirective], -}); -``` - -Once added, tools like validation and introspection will recognize it. - -## Applying directives in queries - -After defining and adding your directive to the schema, clients can apply it in queries using -the `@directiveName` syntax. Arguments are passed in parentheses, similar to field arguments. - -You can apply directives to: - -- Fields -- Fragment spreads -- Named fragments -- Inline fragments -- Operations (query, mutation or subscription) -- Variable definitions - -The following examples show how to apply directives: - -```graphql -# Applied to a field -{ - greeting @uppercase -} -``` - -```graphql -# Applied to a fragment spread -{ - ...userFields @include(if: true) -} -``` - -```graphql -# Applied to an inline fragment -{ - ... on User @skip(if: false) { - email - } -} -``` - -When a query is parsed, GraphQL.js includes directive nodes in the field's -Abstract Syntax Tree (AST). You can access these via `info.fieldNodes` inside -a resolver. - -## Implementing custom directive behavior - -GraphQL.js doesn't execute custom directive logic for you. You must handle it during -execution. There are two common approaches: - -### 1. Handle directives in resolvers - -Inside a resolver, use the `info` object to access AST nodes and inspect directives. -You can check whether a directive is present and change behavior accordingly. - -```js -import { - graphql, - buildSchema, - getDirectiveValues, -} from 'graphql'; - -const schema = buildSchema(` - directive @uppercase(enabled: Boolean = true) on FIELD - - type Query { - greeting: String - } -`); - -const rootValue = { - greeting: (source, args, context, info) => { - const directive = getDirectiveValues( - schema.getDirective('uppercase'), - info.fieldNodes[0], - info.variableValues - ); - - const result = 'Hello, world'; - - if (directive?.enabled) { - return result.toUpperCase(); - } - - return result; - }, -}; - -const query = ` - query { - greeting @uppercase - } -`; - -const result = await graphql({ schema, source: query, rootValue }); -console.log(result); -// β†’ { data: { greeting: 'HELLO, WORLD' } } -``` - -### 2. Use AST visitors or schema wrappers - -For more complex logic, you can preprocess the schema or query using AST visitors or wrap -field resolvers. This lets you inject directive logic globally across -multiple types or fields. - -This approach is useful for: - -- Authorization -- Logging -- Schema transformations -- Feature flags - -## Use cases for custom directives - -Some common use cases for custom directives include: - -- **Formatting**: `@uppercase`, `@date(format: "YYYY-MM-DD")`, `@currency` -- **Authorization**: `@auth(role: "admin")` to protect fields -- **Feature flags**: `@feature(name: "newHeader")` to expose experimental features -- **Observability**: `@log`, `@tag(name: "important")`, or `@metrics(id: "xyz")` -- **Execution control**: Mask or transform fields at runtime with schema visitors - -## When to avoid custom directives - -Custom directives should not be used where an argument could achieve the same -goal. Custom directives in GraphQL requests complicate caching (particularly -normalized caches) and are less well understood by tooling such as GraphQL; by -using arguments instead we maximize compatibility and consistency. For example, -our `@uppercase` directive would fit naturally as a field argument: - -```js -import { - graphql, - buildSchema, -} from 'graphql'; - -const schema = buildSchema(` - enum Format { - VERBATIM - UPPERCASE - } - type Query { - greeting(format: Format! = VERBATIM): String - } -`); - -const rootValue = { - greeting: (source, args) => { - const result = 'Hello, world'; - - if (args.format === "UPPERCASE") { - return result.toUpperCase(); - } - - return result; - }, -}; - -const query = ` - query { - greeting(format: UPPERCASE) - } -`; - -const result = await graphql({ - schema, - source: query, - rootValue, -}); - -console.log(result); -``` - -## Best practices - -When working with custom directives in GraphQL.js, keep the following best practices in mind: - -- GraphQL.js doesn't have a directive middleware system. All custom directive logic must be implemented -manually. -- Weigh schema-driven logic against resolver logic. Directives can make queries more expressive, but they -may also hide behavior from developers reading the schema or resolvers. -- Always prefer field arguments over directives where possible. -- Keep directive behavior transparent and debuggable. Since directives are invisible at runtime unless -logged or documented, try to avoid magic behavior. -- Use directives when they offer real value. Avoid overusing directives to replace things that could be -handled more clearly in schema design or resolvers. -- Validate directive usage explicitly if needed. If your directive has rules or side effects, consider -writing custom validation rules to enforce correct usage. - -## Additional resources - -- [GraphQL Specification: Directives](https://spec.graphql.org/draft/#sec-Language.Directives) -- The Guild's guide on [Schema Directives](https://the-guild.dev/graphql/tools/docs/schema-directives) -- Apollo Server's guide on [Directives](https://www.apollographql.com/docs/apollo-server/schema/directives) diff --git a/website/pages/upgrade-guides/v16-v17.mdx b/website/pages/upgrade-guides/v16-v17.mdx deleted file mode 100644 index 00b8a27343..0000000000 --- a/website/pages/upgrade-guides/v16-v17.mdx +++ /dev/null @@ -1,187 +0,0 @@ ---- -title: Upgrading from v16 to v17 -sidebarTitle: v16 to v17 ---- - -import { Tabs } from 'nextra/components'; -import { Callout } from 'nextra/components' - - - Currently GraphQL v17 is in alpha, this guide is based on the alpha release and is subject to change. - - -# Breaking changes - -## Default values - -GraphQL schemas allow default values for input fields and arguments. Historically, GraphQL.js did not rigorously validate or coerce these -defaults during schema construction, leading to potential runtime errors or inconsistencies. For example: - -- A default value of "5" (string) for an Int-type argument would pass schema validation but fail at runtime. -- Internal serialization methods like astFromValue could produce invalid ASTs if inputs were not properly coerced. - -With the new changes default values will be validated and coerced during schema construction. - -```graphql -input ExampleInput { - value: Int = "invalid" # Now triggers a validation error -} -``` - -This goes hand-in-hand with the deprecation of `astFromValue` in favor of `valueToLiteral` or `default: { value: }`. - -```ts -// Before (deprecated) -const defaultValue = astFromValue(internalValue, type); -// After -const defaultValue = valueToLiteral(externalValue, type); -``` - -If you want to continue using the old behavior, you can use `defaultValue` in your schema definitions. The new -behavior will be exposed as `default: { literal: }`. - -## GraphQLError constructor arguments - -The `GraphQLError` constructor now only accepts a message and options object as arguments. Previously, it also accepted positional arguments. - -```diff -- new GraphQLError('message', 'source', 'positions', 'path', 'originalError', 'extensions'); -+ new GraphQLError('message', { source, positions, path, originalError, extensions }); -``` - -## `createSourceEventStream` arguments - -The `createSourceEventStream` function now only accepts an object as an argument. Previously, it also accepted positional arguments. - -```diff -- createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName); -+ createSourceEventStream({ schema, document, rootValue, contextValue, variableValues, operationName }); -``` - -## `execute` will error for incremental delivery - -The `execute` function will now throw an error if it sees a `@defer` or `@stream` directive. Use `experimentalExecuteIncrementally` instead. -If you know you are dealing with incremental delivery requests, you can replace the import. - -```diff -- import { execute } from 'graphql'; -+ import { experimentalExecuteIncrementally as execute } from 'graphql'; -``` - -## Remove incremental delivery support from `subscribe` - -In case you have fragments that you use with `defer/stream` that end up in a subscription, -use the `if` argument of the directive to disable it in your subscription operation - -## `subscribe` return type - -The `subscribe` function can now also return a non-Promise value, previously this was only a Promise. -This shouldn't change a lot as `await value` will still work as expected. This could lead to -some typing inconsistencies though. - -## Remove `singleResult` from incremental results - -You can remove branches that check for `singleResult` in your code, as it is no longer used. - -## Node support - -Dropped support for Node 14 (subject to change) - -## Removed `TokenKindEnum`, `KindEnum` and `DirectiveLocationEnum` types - -We have removed the `TokenKindEnum`, `KindEnum` and `DirectiveLocationEnum` types, -use `Kind`, `TokenKind` and `DirectiveLocation` instead. https://github.com/graphql/graphql-js/pull/3579 - -## Removed `graphql/subscription` module - -use `graphql/execution` instead for subscriptions, all execution related exports have been -unified there. - -## Removed `GraphQLInterfaceTypeNormalizedConfig` export - -Use `ReturnType` if you really need this - -## Empty AST collections will be undefined - -Empty AST collections will be presented by `undefined` rather than an empty array. - -## `Info.variableValues` - -The shape of `Info.variableValues` has changed to be an object containing -`sources` and `coerced` as keys. - -A Source contains the `signature` and provided `value` pre-coercion for the -variable. A `signature` is an object containing the `name`, `input-type` and -`defaultValue` for the variable. - -## Stream directive can't be on multiple instances of the same field - -The `@stream` directive can't be on multiple instances of the same field, -this won't pass `validate` anymore. - -See https://github.com/graphql/graphql-js/pull/4342 - -## Stream initialCount becomes non-nullable - -The `initialCount` argument of the `@stream` directive is now non-nullable. - -See https://github.com/graphql/graphql-js/pull/4322 - -## GraphQLSchemas converted to configuration may no longer be assumed valid - -The `assumeValid` config property exported by the `GraphQLSchema.toConfig()` method now passes through the original -flag passed on creation of the `GraphQLSchema`. -Previously, the `assumeValid` property would be to `true` if validation had been run, potentially concealing the original intent. - -See https://github.com/graphql/graphql-js/pull/4244 and https://github.com/graphql/graphql-js/issues/3448 - -## `coerceInputValue` returns `undefined` on error - -`coerceInputValue` now aborts early when an error occurs, to optimize execution speed on the happy path. -Use the `validateInputValue` helper to retrieve the actual errors. - -## Removals - -- Removed deprecated `getOperationType` function, use `getRootType` on the `GraphQLSchema` instance instead -- Removed deprecated `getVisitFn` function, use `getEnterLeaveForKind` instead -- Removed deprecated `printError` and `formatError` utilities, you can use `toString` or `toJSON` on the error as a replacement -- Removed deprecated `assertValidName` and `isValidNameError` utilities, use `assertName` instead -- Removed deprecated `assertValidExecutionArguments` function, use `assertValidSchema` instead -- Removed deprecated `getFieldDefFn` from `TypeInfo` -- Removed deprecated `TypeInfo` from `validate` https://github.com/graphql/graphql-js/pull/4187 - -## Deprecations - -- Deprecated `astFromValue` use `valueToLiteral` instead, when leveraging `valueToLiteral` ensure - that you are working with externally provided values i.e. the SDL provided defaultValue to a variable. -- Deprecated `valueFromAST` use `coerceInputLiteral` instead -- Deprecated `findBreakingChanges()` and `findDangerousChanges()`. Use `findSchemaChanges()` instead, which can also be used to find safe changes. -- Deprecated `serialize`. `parseValue`, and `parseLiteral` properties on scalar type configuration. Use `coerceOutputValue`, `coerceInputValue`, and `coerceInputLiteral` instead. - -## Experimental Features - -### Experimental Support for Incremental Delivery - -- [Spec PR](https://github.com/graphql/graphql-spec/pull/1110) / [RFC](https://github.com/graphql/graphql-wg/blob/main/rfcs/DeferStream.md) -- enabled only when using `experimentalExecuteIncrementally()`, use of a schema or operation with `@defer`/`@stream` directives within `execute()` will now throw. -- enable early execution with the new `enableEarlyExecution` configuration option for `experimentalExecuteIncrementally()`. - -### Experimental Support for Fragment Arguments - -- [Spec PR](https://github.com/graphql/graphql-spec/pull/1081) -- enable with the new `experimentalFragmentArguments` configuration option for `parse()`. -- new experimental `Kind.FRAGMENT_ARGUMENT` for visiting -- new experimental `TypeInfo` methods and options for handling fragment arguments. -- coerce AST via new function `coerceInputLiteral()` with experimental fragment variables argument (as opposed to deprecated `valueFromAST()` function). - -## Features - -- Added `hideSuggestions` option to `execute`/`validate`/`subscribe`/... to hide schema-suggestions in error messages -- Added `abortSignal` option to `graphql()`, `execute()`, and `subscribe()` allows cancellation of these methods; - the `abortSignal` can also be passed to field resolvers to cancel asynchronous work that they initiate. -- `extensions` support `symbol` keys, in addition to the normal string keys. -- Added ability for resolver functions to return async iterables. -- Added `perEventExecutor` execution option to allows specifying a custom executor for subscription source stream events, which can be useful for preparing a per event execution context argument. -- Added `validateInputValue` and `validateInputLiteral` helpers to validate input values and literals, respectively. -- Added `replaceVariableValues` helper to replace variables within complex scalars uses as inputs. Internally, this allows variables embedded within complex scalars to finally use the correct default values. -- Added new `printDirective` helper. diff --git a/website/postcss.config.js b/website/postcss.config.js deleted file mode 100644 index cdbe50f3a4..0000000000 --- a/website/postcss.config.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - plugins: { - 'tailwindcss/nesting': {}, - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/website/tailwind.config.js b/website/tailwind.config.js deleted file mode 100644 index 5f6a85cd2a..0000000000 --- a/website/tailwind.config.js +++ /dev/null @@ -1,40 +0,0 @@ -import typography from '@tailwindcss/typography'; - -module.exports = { - content: [ - './pages/**/*.{ts,tsx,mdx}', - './icons/**/*.{ts,tsx,mdx}', - './theme.config.tsx', - ], - theme: { - container: { - center: true, - padding: '1rem', - }, - extend: { - colors: { - primary: '#e10098', - 'conf-black': '#0e031c', - black: '#1b1b1b', - }, - backgroundImage: { - 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', - 'gradient-conic': - 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', - }, - animation: { - scroll: - 'scroll var(--animation-duration, 40s) var(--animation-direction, forwards) linear infinite', - }, - keyframes: { - scroll: { - to: { - transform: 'translate(calc(-50% - .5rem))', - }, - }, - }, - }, - }, - plugins: [typography], - darkMode: ['class', 'html[class~="dark"]'], -}; diff --git a/website/theme.config.tsx b/website/theme.config.tsx deleted file mode 100644 index 5d8d5ff3a7..0000000000 --- a/website/theme.config.tsx +++ /dev/null @@ -1,249 +0,0 @@ -import React from 'react'; -import { DocsThemeConfig, ThemeSwitch, useConfig } from 'nextra-theme-docs'; -import NextLink from 'next/link'; -import { - GraphQLWordmarkLogo, - StackOverflowIcon, - GitHubIcon, - DiscordIcon, - TwitterIcon, -} from './icons/index'; -import { useRouter } from 'next/router'; - -const graphQLLogo = ( - -); - -const classes = { - link: 'hover:underline decoration-from-font [text-underline-position:from-font]', -}; - -function List({ - title, - items, -}: { - title: string; - items: { title: string; url: string }[]; -}) { - return ( -
    -

    {title}

    - {items.map((item) => ( -
  • - - {item.title} - -
  • - ))} -
- ); -} - -function Footer() { - return ( -
-
- - {graphQLLogo} - - - - - -
-
-

- Copyright Β© {new Date().getFullYear()} The GraphQL Foundation. All - rights reserved. -
- For web site terms of use, trademark policy and general project - policies please see{' '} - - https://lfprojects.org - -

-
-
    - {[ - { url: 'https://github.com/graphql', icon: GitHubIcon }, - { url: 'https://discord.graphql.org', icon: DiscordIcon }, - { url: 'https://x.com/graphql', icon: TwitterIcon }, - { - url: 'http://stackoverflow.com/questions/tagged/graphql', - icon: StackOverflowIcon, - }, - ].map(({ url, icon: Icon }) => ( -
  • - - - -
  • - ))} -
- - Powered by{' '} - - - - - -
-
-
- ); -} - -const cfg: DocsThemeConfig = { - backgroundColor: { - dark: '27,27,27', - }, - head: function useHead() { - const { frontMatter, title: pageTitle } = useConfig(); - const { asPath } = useRouter(); - - const title = `${pageTitle}${asPath === '/' ? '' : ' | GraphQL'}`; - const { description, canonical, image } = frontMatter; - return ( - <> - {title} - - {description && ( - <> - - - - )} - {canonical && } - {image && } - - - - ); - }, - banner: { - content: ( - <> - 🎬 That's a Wrap for GraphQLConf 2024! β€’ Watch the Videos β€’{' '} - - Check out the recorded talks and workshops - - - ), - key: 'graphqlconf-2024', - }, - logo: graphQLLogo, - docsRepositoryBase: - 'https://github.com/graphql/graphql-js/tree/16.x.x/website', - color: { - hue: 319, - }, - sidebar: { - defaultMenuCollapseLevel: 1, - }, - footer: { - content: Footer, - }, - navbar: { - extraContent: , - }, - toc: { - backToTop: true, - }, - search: { - placeholder: 'Search…', - }, -}; - -export default cfg; diff --git a/website/tsconfig.json b/website/tsconfig.json deleted file mode 100644 index dd9c4aa58c..0000000000 --- a/website/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": false, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "incremental": true, - "esModuleInterop": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "plugins": [ - { - "name": "next" - } - ], - "strictNullChecks": true, - "module": "esnext" - }, - "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"] -} diff --git a/website/vercel.json b/website/vercel.json deleted file mode 100644 index 9f11ce21b7..0000000000 --- a/website/vercel.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "redirects": [ - { - "source": "/api", - "destination": "/api-v16/graphql", - "permanent": true - }, - { - "source": "/", - "destination": "/docs", - "permanent": true - } - ] -}